feat(library): add has_equiv type class

This commit is contained in:
Leonardo de Moura 2017-12-03 13:42:30 -08:00
parent b6c8551753
commit d9322b16ca
4 changed files with 10 additions and 3 deletions

View file

@ -38,6 +38,8 @@ master branch (aka work in progress branch)
- Add support for structure instance notation `{...}` in patterns. Use `..` to ignore
unmatched fields.
- Type class has_equiv for `≈` notation.
*Changes*
- `string` is now a list of unicode scalar values. Moreover, in the VM,

View file

@ -315,6 +315,7 @@ class has_andthen (α : Type u) (β : Type v) (σ : inout Type w) := (andthen :
class has_union (α : Type u) := (union : ααα)
class has_inter (α : Type u) := (inter : ααα)
class has_sdiff (α : Type u) := (sdiff : ααα)
class has_equiv (α : Sort u) := (equiv : αα → Prop)
class has_subset (α : Type u) := (subset : αα → Prop)
class has_ssubset (α : Type u) := (ssubset : αα → Prop)
/- Type classes has_emptyc and has_insert are
@ -351,6 +352,7 @@ infix ∩ := has_inter.inter
infix ⊆ := has_subset.subset
infix ⊂ := has_ssubset.ssubset
infix \ := has_sdiff.sdiff
infix ≈ := has_equiv.equiv
export has_append (append)

View file

@ -10,14 +10,15 @@ universes u
class setoid (α : Sort u) :=
(r : αα → Prop) (iseqv : equivalence r)
namespace setoid
infix ` ≈ ` := setoid.r
instance setoid_has_equiv {α : Sort u} [setoid α] : has_equiv α :=
⟨setoid.r⟩
namespace setoid
variable {α : Sort u}
variable [s : setoid α]
include s
@[refl] lemma refl (a : α) : a ≈ a :=
@[refl] lemma refl [setoid α] (a : α) : a ≈ a :=
match setoid.iseqv α with
| ⟨h_refl, h_symm, h_trans⟩ := h_refl a
end

View file

@ -5,6 +5,7 @@ has_append : Type u → Type u
has_div : Type u → Type u
has_dvd : Type u → Type u
has_emptyc : Type u → Type u
has_equiv : Sort u → Sort (max 1 u)
has_insert : (inout Type u) → Type v → Type (max u v)
has_inter : Type u → Type u
has_inv : Type u → Type u
@ -31,6 +32,7 @@ has_append : Type u → Type u
has_div : Type u → Type u
has_dvd : Type u → Type u
has_emptyc : Type u → Type u
has_equiv : Sort u → Sort (max 1 u)
has_insert : (inout Type u) → Type v → Type (max u v)
has_inter : Type u → Type u
has_inv : Type u → Type u