Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 69db7a3

Browse files
committed
feat(data/subtype): setoid (subtype p)
1 parent aec307b commit 69db7a3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

data/subtype.lean

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,32 @@ theorem map_id {p : α → Prop} {h : ∀a, p a → p (id a)} : map (@id α) h =
5353
funext $ assume ⟨v, h⟩, rfl
5454

5555
end subtype
56+
57+
namespace subtype
58+
variables {α : Sort*}
59+
60+
instance [has_equiv α] (p : α → Prop) : has_equiv (subtype p) :=
61+
⟨λ s t, s.val ≈ t.val⟩
62+
63+
theorem equiv_iff [has_equiv α] {p : α → Prop} {s t : subtype p} :
64+
s ≈ t ↔ s.val ≈ t.val :=
65+
iff.rfl
66+
67+
variables [setoid α] {p : α → Prop}
68+
69+
protected theorem refl (s : subtype p) : s ≈ s :=
70+
setoid.refl s.val
71+
72+
protected theorem symm {s t : subtype p} (h : s ≈ t) : t ≈ s :=
73+
setoid.symm h
74+
75+
protected theorem trans {s t u : subtype p} (h₁ : s ≈ t) (h₂ : t ≈ u) : s ≈ u :=
76+
setoid.trans h₁ h₂
77+
78+
theorem equivalence (p : α → Prop) : equivalence (@has_equiv.equiv (subtype p) _) :=
79+
mk_equivalence _ subtype.refl (@subtype.symm _ _ p) (@subtype.trans _ _ p)
80+
81+
instance (p : α → Prop) : setoid (subtype p) :=
82+
setoid.mk (≈) (equivalence p)
83+
84+
end subtype

0 commit comments

Comments
 (0)