1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| A.Asperti, C.Sacerdoti Coen, *)
8 (* ||A|| E.Tassi, S.Zacchiroli *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU Lesser General Public License Version 2.1 *)
13 (**************************************************************************)
15 include "higher_order_defs/relations.ma".
17 inductive eq (A:Type) (x:A) : A \to Prop \def
20 interpretation "leibnitz's equality" 'eq t x y = (eq t x y).
22 interpretation "leibnitz's non-equality" 'neq t x y = (Not (eq t x y)).
25 \forall A. \forall x:A. \forall P: \forall y:A. x=y \to Type.
26 P ? (refl_eq ? x) \to \forall y:A. \forall p:x=y. P y p.
29 (match p1 return \lambda y. \lambda p.P y p with
30 [refl_eq \Rightarrow p]).
33 variant reflexive_eq : \forall A:Type. reflexive A (eq A)
35 (* simplify.intros.apply refl_eq. *)
37 theorem symmetric_eq: \forall A:Type. symmetric A (eq A).
38 unfold symmetric.intros.elim H. apply refl_eq.
41 variant sym_eq : \forall A:Type.\forall x,y:A. x=y \to y=x
44 theorem transitive_eq : \forall A:Type. transitive A (eq A).
45 unfold transitive.intros.elim H1.assumption.
48 variant trans_eq : \forall A:Type.\forall x,y,z:A. x=y \to y=z \to x=z
51 theorem symmetric_not_eq: \forall A:Type. symmetric A (λx,y.x ≠ y).
52 unfold symmetric.simplify.intros.unfold.intro.apply H.apply sym_eq.assumption.
55 variant sym_neq: ∀A:Type.∀x,y.x ≠ y →y ≠ x
59 \forall A:Type.\forall x:A. \forall P: A \to Prop.
60 P x \to \forall y:A. y=x \to P y.
61 intros. elim (sym_eq ? ? ? H1).assumption.
65 \forall A:Type.\forall x:A. \forall P: A \to Set.
66 P x \to \forall y:A. y=x \to P y.
67 intros. elim (sym_eq ? ? ? H).assumption.
71 \forall A:Type.\forall x:A. \forall P: A \to Type.
72 P x \to \forall y:A. y=x \to P y.
73 intros. elim (sym_eq ? ? ? H).assumption.
76 theorem eq_f: \forall A,B:Type.\forall f:A\to B.
77 \forall x,y:A. x=y \to f x = f y.
78 intros.elim H.apply refl_eq.
81 theorem eq_f': \forall A,B:Type.\forall f:A\to B.
82 \forall x,y:A. x=y \to f y = f x.
83 intros.elim H.apply refl_eq.
92 cic:/matita/logic/equality/eq.ind
93 cic:/matita/logic/equality/sym_eq.con
94 cic:/matita/logic/equality/transitive_eq.con
95 cic:/matita/logic/equality/eq_ind.con
96 cic:/matita/logic/equality/eq_elim_r.con
97 cic:/matita/logic/equality/eq_rec.con
98 cic:/matita/logic/equality/eq_elim_r'.con
99 cic:/matita/logic/equality/eq_rect.con
100 cic:/matita/logic/equality/eq_elim_r''.con
101 cic:/matita/logic/equality/eq_f.con
103 cic:/matita/logic/equality/eq_OF_eq.con.
106 cic:/matita/logic/equality/eq_f'.con. (* \x.sym (eq_f x) *)
109 theorem eq_f2: \forall A,B,C:Type.\forall f:A\to B \to C.
110 \forall x1,x2:A. \forall y1,y2:B.
111 x1=x2 \to y1=y2 \to f x1 y1 = f x2 y2.
112 intros.elim H1.elim H.reflexivity.
120 eq_ind ? ? (\lambda a.a=y') eq2 ? eq1.
126 comp ? ? ? ? u u = refl_eq ? y.
128 apply (eq_rect' ? ? ? ? ? u).
134 \lambda H: \forall x,y:A. decidable (x=y).
135 \lambda x,y. \lambda p:x=y.
137 [ (or_introl p') \Rightarrow p'
138 | (or_intror K) \Rightarrow False_ind ? (K p) ].
142 \forall H: \forall x,y:A. decidable (x=y).
145 nu ? H ? ? u = nu ? H ? ? v.
148 unfold decidable in H.
149 apply (Or_ind' ? ? ? ? ? (H x y)); simplify.
154 definition nu_inv \def
156 \lambda H: \forall x,y:A. decidable (x=y).
159 comp ? ? ? ? (nu ? H ? ? (refl_eq ? x)) v.
163 \forall H: \forall x,y:A. decidable (x=y).
166 nu_inv ? H ? ? (nu ? H ? ? u) = u.
168 apply (eq_rect' ? ? ? ? ? u).
173 theorem eq_to_eq_to_eq_p_q:
174 \forall A. \forall x,y:A.
175 (\forall x,y:A. decidable (x=y)) \to
176 \forall p,q:x=y. p=q.
178 rewrite < (nu_left_inv ? H ? ? p).
179 rewrite < (nu_left_inv ? H ? ? q).
180 elim (nu_constant ? H ? ? q).
184 (*CSC: alternative proof that does not pollute the environment with
185 technical lemmata. Unfortunately, it is a pain to do without proper
187 theorem eq_to_eq_to_eq_p_q:
188 \forall A. \forall x,y:A.
189 (\forall x,y:A. decidable (x=y)) \to
190 \forall p,q:x=y. p=q.
193 (\lambda x,y. \lambda p:x=y.
195 [ (or_introl p') \Rightarrow p'
196 | (or_intror K) \Rightarrow False_ind ? (K p) ]).
199 eq_ind ? ? (\lambda z. z=y) (nu ? ? q) ? (nu ? ? (refl_eq ? x))
204 apply (eq_rect' ? ? ? ? ? q);
205 fold simplify (nu ? ? (refl_eq ? x)).
206 generalize in match (nu ? ? (refl_eq ? x)); intro.
209 (\lambda y. \lambda u.
210 eq_ind A x (\lambda a.a=y) u y u = refl_eq ? y)
214 rewrite < (Hcut p); fold simplify (nu ? ? p).
215 rewrite < (Hcut q); fold simplify (nu ? ? q).
216 apply (Or_ind' (x=x) (x \neq x)
217 (\lambda p:decidable (x=x). eq_ind A x (\lambda z.z=y) (nu x y p) x
218 ([\lambda H1.eq A x x]
220 [(or_introl p') \Rightarrow p'
221 |(or_intror K) \Rightarrow False_ind (x=x) (K (refl_eq A x))]) =
222 eq_ind A x (\lambda z.z=y) (nu x y q) x
223 ([\lambda H1.eq A x x]
225 [(or_introl p') \Rightarrow p'
226 |(or_intror K) \Rightarrow False_ind (x=x) (K (refl_eq A x))]))
228 intro; simplify; reflexivity.
229 intro q; elim (q (refl_eq ? x)).
234 theorem a:\forall x.x=x\land True.
239 exact (refl_eq Prop x);