@@ -4,43 +4,34 @@ Released under Apache 2.0 license as described in the file LICENSE.
4
4
Author: Johannes Hölzl
5
5
-/
6
6
7
+ -- Lean complains if this section is turned into a namespace
7
8
section subtype
8
- variables {α : Sort *} {β : α → Prop }
9
+ variables {α : Sort *} {p : α → Prop }
9
10
10
- protected lemma subtype.eq' : ∀ {a1 a2 : {x // β x}}, a1.val = a2.val → a1 = a2
11
- | ⟨x, h1⟩ ⟨.(x), h2⟩ rfl := rfl
12
-
13
- lemma subtype.ext {a1 a2 : {x // β x}} : a1 = a2 ↔ a1.val = a2.val :=
14
- ⟨congr_arg _, subtype.eq'⟩
15
-
16
- lemma subtype.coe_ext {a1 a2 : {x // β x}} : a1 = a2 ↔ (a1 : α) = a2 :=
17
- subtype.ext
18
-
19
- theorem subtype.val_injective : function.injective (@subtype.val _ β) :=
20
- λ a b, subtype.eq'
21
-
22
- @[simp] theorem subtype.coe_eta {α : Type *} {β : α → Prop }
23
- (a : {a // β a}) (h : β a) : subtype.mk ↑a h = a := subtype.eta _ _
24
-
25
- @[simp] theorem subtype.coe_mk {α : Type *} {β : α → Prop }
26
- (a h) : (@subtype.mk α β a h : α) = a := rfl
27
-
28
- @[simp] theorem subtype.mk_eq_mk {α : Type *} {β : α → Prop }
29
- {a h a' h'} : @subtype.mk α β a h = @subtype.mk α β a' h' ↔ a = a' :=
30
- ⟨λ H, by injection H, λ H, by congr; assumption⟩
31
-
32
- @[simp] theorem subtype.forall {p : {a // β a} → Prop } :
33
- (∀ x, p x) ↔ (∀ a b, p ⟨a, b⟩) :=
11
+ @[simp] theorem subtype.forall {q : {a // p a} → Prop } :
12
+ (∀ x, q x) ↔ (∀ a b, q ⟨a, b⟩) :=
34
13
⟨assume h a b, h ⟨a, b⟩, assume h ⟨a, b⟩, h a b⟩
35
14
36
- @[simp] theorem subtype.exists {p : {a // β a} → Prop } :
37
- (∃ x, p x) ↔ (∃ a b, p ⟨a, b⟩) :=
15
+ @[simp] theorem subtype.exists {q : {a // p a} → Prop } :
16
+ (∃ x, q x) ↔ (∃ a b, q ⟨a, b⟩) :=
38
17
⟨assume ⟨⟨a, b⟩, h⟩, ⟨a, b, h⟩, assume ⟨a, b, h⟩, ⟨⟨a, b⟩, h⟩⟩
39
18
40
19
end subtype
41
20
42
21
namespace subtype
43
- variables {α : Sort *} {β : Sort *} {γ : Sort *}
22
+ variables {α : Sort *} {β : Sort *} {γ : Sort *} {p : α → Prop }
23
+
24
+ protected lemma eq' : ∀ {a1 a2 : {x // p x}}, a1.val = a2.val → a1 = a2
25
+ | ⟨x, h1⟩ ⟨.(x), h2⟩ rfl := rfl
26
+
27
+ lemma ext {a1 a2 : {x // p x}} : a1 = a2 ↔ a1.val = a2.val :=
28
+ ⟨congr_arg _, subtype.eq'⟩
29
+
30
+ lemma coe_ext {a1 a2 : {x // p x}} : a1 = a2 ↔ (a1 : α) = a2 :=
31
+ ext
32
+
33
+ theorem val_injective : function.injective (@val _ p) :=
34
+ λ a b, subtype.eq'
44
35
45
36
/-- Restriction of a function to a function on subtypes. -/
46
37
def map {p : α → Prop } {q : β → Prop } (f : α → β) (h : ∀a, p a → q (f a)) :
55
46
theorem map_id {p : α → Prop } {h : ∀a, p a → p (id a)} : map (@id α) h = id :=
56
47
funext $ assume ⟨v, h⟩, rfl
57
48
58
- end subtype
59
-
60
- namespace subtype
61
- variables {α : Sort *}
62
-
63
49
instance [has_equiv α] (p : α → Prop ) : has_equiv (subtype p) :=
64
50
⟨λ s t, s.val ≈ t.val⟩
65
51
66
52
theorem equiv_iff [has_equiv α] {p : α → Prop } {s t : subtype p} :
67
53
s ≈ t ↔ s.val ≈ t.val :=
68
54
iff.rfl
69
55
70
- variables [setoid α] {p : α → Prop }
56
+ variables [setoid α]
71
57
72
58
protected theorem refl (s : subtype p) : s ≈ s :=
73
59
setoid.refl s.val
@@ -79,9 +65,28 @@ protected theorem trans {s t u : subtype p} (h₁ : s ≈ t) (h₂ : t ≈ u) :
79
65
setoid.trans h₁ h₂
80
66
81
67
theorem equivalence (p : α → Prop ) : equivalence (@has_equiv.equiv (subtype p) _) :=
82
- mk_equivalence _ subtype.refl (@subtype.symm _ _ p ) (@subtype.trans _ _ p )
68
+ mk_equivalence _ subtype.refl (@subtype.symm _ p _ ) (@subtype.trans _ p _ )
83
69
84
70
instance (p : α → Prop ) : setoid (subtype p) :=
85
71
setoid.mk (≈) (equivalence p)
86
72
87
73
end subtype
74
+
75
+ namespace subtype
76
+ variables {α : Type *} {β : Type *} {γ : Type *} {p : α → Prop }
77
+
78
+ @[simp] theorem coe_eta {α : Type *} {p : α → Prop }
79
+ (a : {a // p a}) (h : p a) : mk ↑a h = a := eta _ _
80
+
81
+ @[simp] theorem coe_mk {α : Type *} {p : α → Prop }
82
+ (a h) : (@mk α p a h : α) = a := rfl
83
+
84
+ @[simp] theorem mk_eq_mk {α : Type *} {p : α → Prop }
85
+ {a h a' h'} : @mk α p a h = @mk α p a' h' ↔ a = a' :=
86
+ ⟨λ H, by injection H, λ H, by congr; assumption⟩
87
+
88
+ @[simp] lemma val_prop {S : set α} (a : {a // a ∈ S}) : a.val ∈ S := a.property
89
+
90
+ @[simp] lemma val_prop' {S : set α} (a : {a // a ∈ S}) : ↑a ∈ S := a.property
91
+
92
+ end subtype
0 commit comments