2014-09-16 18:58:54 +00:00
|
|
|
import logic algebra.relation
|
2014-09-03 23:00:38 +00:00
|
|
|
open relation
|
2014-08-16 20:50:59 +00:00
|
|
|
|
|
|
|
namespace is_equivalence
|
2014-09-02 22:03:33 +00:00
|
|
|
inductive cls {T : Type} (R : T → T → Type) : Prop :=
|
|
|
|
mk : is_reflexive R → is_symmetric R → is_transitive R → cls R
|
2014-08-16 20:50:59 +00:00
|
|
|
|
2014-09-02 22:03:33 +00:00
|
|
|
theorem is_reflexive {T : Type} {R : T → T → Type} {C : cls R} : is_reflexive R :=
|
2014-09-04 22:03:59 +00:00
|
|
|
cls.rec (λx y z, x) C
|
2014-08-16 20:50:59 +00:00
|
|
|
|
2014-09-02 22:03:33 +00:00
|
|
|
theorem is_symmetric {T : Type} {R : T → T → Type} {C : cls R} : is_symmetric R :=
|
2014-09-04 22:03:59 +00:00
|
|
|
cls.rec (λx y z, y) C
|
2014-08-16 20:50:59 +00:00
|
|
|
|
2014-09-02 22:03:33 +00:00
|
|
|
theorem is_transitive {T : Type} {R : T → T → Type} {C : cls R} : is_transitive R :=
|
2014-09-04 22:03:59 +00:00
|
|
|
cls.rec (λx y z, z) C
|
2014-08-16 20:50:59 +00:00
|
|
|
|
|
|
|
end is_equivalence
|
|
|
|
|
|
|
|
instance is_equivalence.is_reflexive
|
|
|
|
instance is_equivalence.is_symmetric
|
|
|
|
instance is_equivalence.is_transitive
|
|
|
|
|
|
|
|
theorem and_inhabited_left {a : Prop} (b : Prop) (Ha : a) : a ∧ b ↔ b :=
|
2014-09-05 04:25:21 +00:00
|
|
|
iff.intro (take Hab, and.elim_right Hab) (take Hb, and.intro Ha Hb)
|
2014-08-16 20:50:59 +00:00
|
|
|
|
|
|
|
theorem test (a b c : Prop) (P : Prop → Prop) (H1 : a ↔ b) (H2 : c ∧ a) : c ∧ b :=
|
2014-09-05 04:25:21 +00:00
|
|
|
iff.subst H1 H2
|
2014-08-16 20:50:59 +00:00
|
|
|
|
|
|
|
theorem test2 (Q R S : Prop) (H3 : R ↔ Q) (H1 : S) : Q ↔ (S ∧ Q) :=
|
2014-09-05 04:25:21 +00:00
|
|
|
iff.symm (and_inhabited_left Q H1)
|
2014-08-16 20:50:59 +00:00
|
|
|
|
|
|
|
theorem test3 (Q R S : Prop) (H3 : R ↔ Q) (H1 : S) : R ↔ (S ∧ Q) :=
|
2014-09-05 04:25:21 +00:00
|
|
|
iff.subst (test2 Q R S H3 H1) H3
|
2014-08-16 20:50:59 +00:00
|
|
|
|
|
|
|
theorem test4 (Q R S : Prop) (H3 : R ↔ Q) (H1 : S) : R ↔ (S ∧ Q) :=
|
2014-09-05 04:25:21 +00:00
|
|
|
iff.subst (iff.symm (and_inhabited_left Q H1)) H3
|