forked from leanprover-community/mathlib3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathext.lean
More file actions
130 lines (113 loc) · 2.9 KB
/
Copy pathext.lean
File metadata and controls
130 lines (113 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/-
Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
-/
import tactic.ext
import tactic.solve_by_elim
import data.stream.basic
import data.finset
@[ext] lemma unit.ext (x y : unit) : x = y :=
begin
cases x, cases y, refl
end
example : subsingleton unit :=
begin
split, intros, ext
end
example (x y : ℕ) : true :=
begin
have : x = y,
{ ext <|> admit },
have : x = y,
{ ext i <|> admit },
have : x = y,
{ ext : 1 <|> admit },
trivial
end
example (X Y : ℕ × ℕ) (h : X.1 = Y.1) (h : X.2 = Y.2) : X = Y :=
begin
ext; assumption
end
example (X Y : (ℕ → ℕ) × ℕ) (h : ∀ i, X.1 i = Y.1 i) (h : X.2 = Y.2) : X = Y :=
begin
ext x; solve_by_elim,
end
example (X Y : ℕ → ℕ × ℕ) (h : ∀ i, X i = Y i) : true :=
begin
have : X = Y,
{ ext i : 1,
guard_target X i = Y i,
admit },
have : X = Y,
{ ext i,
guard_target (X i).fst = (Y i).fst, admit,
guard_target (X i).snd = (Y i).snd, admit, },
have : X = Y,
{ ext : 1,
guard_target X x = Y x,
admit },
trivial,
end
example (s₀ s₁ : set ℕ) (h : s₁ = s₀) : s₀ = s₁ :=
by { ext1, guard_target x ∈ s₀ ↔ x ∈ s₁, simp * }
example (s₀ s₁ : stream ℕ) (h : s₁ = s₀) : s₀ = s₁ :=
by { ext1, guard_target s₀.nth n = s₁.nth n, simp * }
example (s₀ s₁ : ℤ → set (ℕ × ℕ))
(h : ∀ i a b, (a,b) ∈ s₀ i ↔ (a,b) ∈ s₁ i) : s₀ = s₁ :=
begin
ext i ⟨a,b⟩,
apply h
end
/- extensionality -/
example : true :=
begin
have : ∀ (s₀ s₁ : set ℤ), s₀ = s₁,
{ intros, ext1,
guard_target x ∈ s₀ ↔ x ∈ s₁,
admit },
have : ∀ (s₀ s₁ : finset ℕ), s₀ = s₁,
{ intros, ext1,
guard_target a ∈ s₀ ↔ a ∈ s₁,
admit },
have : ∀ (s₀ s₁ : multiset ℕ), s₀ = s₁,
{ intros, ext1,
guard_target multiset.count a s₀ = multiset.count a s₁,
admit },
have : ∀ (s₀ s₁ : list ℕ), s₀ = s₁,
{ intros, ext1,
guard_target list.nth s₀ n = list.nth s₁ n,
admit },
have : ∀ (s₀ s₁ : stream ℕ), s₀ = s₁,
{ intros, ext1,
guard_target stream.nth n s₀ = stream.nth n s₁,
admit },
have : ∀ n (s₀ s₁ : array n ℕ), s₀ = s₁,
{ intros, ext1,
guard_target array.read s₀ i = array.read s₁ i,
admit },
trivial
end
structure dependent_fields :=
(a : bool)
(v : if a then ℕ else ℤ)
@[ext] lemma df.ext (s t : dependent_fields) (h : s.a = t.a)
(w : (@eq.rec _ s.a (λ b, if b then ℕ else ℤ) s.v t.a h) = t.v) : s = t :=
begin
cases s, cases t,
dsimp at *,
congr,
exact h,
subst h,
simp,
simp at w,
exact w,
end
example (s : dependent_fields) : s = s :=
begin
tactic.ext1 [] {tactic.apply_cfg . new_goals := tactic.new_goals.all},
guard_target s.a = s.a,
refl,
refl,
end
@[ext] structure dumb (V : Type) := (val : V)