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 "logic/pts.ma".
17 ninductive peq (A:Type[0]) (x:A) : A \to Prop \def
20 interpretation "leibnitz's equality" 'eq t x y = (peq t x y).
22 ntheorem rewrite_l: ∀A.∀x.∀P:A → Prop. P x → ∀y. x = y → P y.
23 #A; #x; #P; #Hx; #y; #Heq;ncases Heq;nassumption.
26 ntheorem sym_peq: ∀A.∀x,y:A. x = y → y = x.
27 #A; #x; #y; #Heq; napply (rewrite_l A x (λz.z=x));
28 ##[ @; ##| nassumption; ##]
31 ntheorem rewrite_r: ∀A.∀x.∀P:A → Prop. P x → ∀y. y = x → P y.
32 #A; #x; #P; #Hx; #y; #Heq;ncases (sym_peq ? ? ?Heq);nassumption.
37 \forall A. \forall x:A. \forall P: \forall y:A. x=y \to Type.
38 P ? (refl_eq ? x) \to \forall y:A. \forall p:x=y. P y p.
41 (match p1 return \lambda y. \lambda p.P y p with
42 [refl_eq \Rightarrow p]).
45 variant reflexive_eq : \forall A:Type. reflexive A (eq A)
48 theorem symmetric_eq: \forall A:Type. symmetric A (eq A).
49 unfold symmetric.intros.elim H. apply refl_eq.
52 variant sym_eq : \forall A:Type.\forall x,y:A. x=y \to y=x
55 theorem transitive_eq : \forall A:Type. transitive A (eq A).
56 unfold transitive.intros.elim H1.assumption.
59 variant trans_eq : \forall A:Type.\forall x,y,z:A. x=y \to y=z \to x=z
62 theorem symmetric_not_eq: \forall A:Type. symmetric A (λx,y.x ≠ y).
63 unfold symmetric.simplify.intros.unfold.intro.apply H.apply sym_eq.assumption.
66 variant sym_neq: ∀A:Type.∀x,y.x ≠ y →y ≠ x
70 \forall A:Type.\forall x:A. \forall P: A \to Prop.
71 P x \to \forall y:A. y=x \to P y.
72 intros. elim (sym_eq ? ? ? H1).assumption.
76 \forall A:Type.\forall x:A. \forall P: A \to Set.
77 P x \to \forall y:A. y=x \to P y.
78 intros. elim (sym_eq ? ? ? H).assumption.
82 \forall A:Type.\forall x:A. \forall P: A \to Type.
83 P x \to \forall y:A. y=x \to P y.
84 intros. elim (sym_eq ? ? ? H).assumption.
87 theorem eq_f: \forall A,B:Type.\forall f:A\to B.
88 \forall x,y:A. x=y \to f x = f y.
89 intros.elim H.apply refl_eq.
92 theorem eq_f': \forall A,B:Type.\forall f:A\to B.
93 \forall x,y:A. x=y \to f y = f x.
94 intros.elim H.apply refl_eq.
104 cic:/matita/logic/equality/eq.ind
105 cic:/matita/logic/equality/sym_eq.con
106 cic:/matita/logic/equality/transitive_eq.con
107 cic:/matita/logic/equality/eq_ind.con
108 cic:/matita/logic/equality/eq_elim_r.con
109 cic:/matita/logic/equality/eq_rec.con
110 cic:/matita/logic/equality/eq_elim_r'.con
111 cic:/matita/logic/equality/eq_rect.con
112 cic:/matita/logic/equality/eq_elim_r''.con
113 cic:/matita/logic/equality/eq_f.con
115 cic:/matita/logic/equality/eq_OF_eq.con.
118 cic:/matita/logic/equality/eq_f'.con. (* \x.sym (eq_f x) *)
121 theorem eq_f2: \forall A,B,C:Type.\forall f:A\to B \to C.
122 \forall x1,x2:A. \forall y1,y2:B.
123 x1=x2 \to y1=y2 \to f x1 y1 = f x2 y2.
124 intros.elim H1.elim H.reflexivity.
132 eq_ind ? ? (\lambda a.a=y') eq2 ? eq1.
138 comp ? ? ? ? u u = refl_eq ? y.
140 apply (eq_rect' ? ? ? ? ? u).
146 \lambda H: \forall x,y:A. decidable (x=y).
147 \lambda x,y. \lambda p:x=y.
149 [ (or_introl p') \Rightarrow p'
150 | (or_intror K) \Rightarrow False_ind ? (K p) ].
154 \forall H: \forall x,y:A. decidable (x=y).
157 nu ? H ? ? u = nu ? H ? ? v.
160 unfold decidable in H.
161 apply (Or_ind' ? ? ? ? ? (H x y)); simplify.
166 definition nu_inv \def
168 \lambda H: \forall x,y:A. decidable (x=y).
171 comp ? ? ? ? (nu ? H ? ? (refl_eq ? x)) v.
175 \forall H: \forall x,y:A. decidable (x=y).
178 nu_inv ? H ? ? (nu ? H ? ? u) = u.
180 apply (eq_rect' ? ? ? ? ? u).
185 theorem eq_to_eq_to_eq_p_q:
186 \forall A. \forall x,y:A.
187 (\forall x,y:A. decidable (x=y)) \to
188 \forall p,q:x=y. p=q.
190 rewrite < (nu_left_inv ? H ? ? p).
191 rewrite < (nu_left_inv ? H ? ? q).
192 elim (nu_constant ? H ? ? q).
196 (*CSC: alternative proof that does not pollute the environment with
197 technical lemmata. Unfortunately, it is a pain to do without proper
199 theorem eq_to_eq_to_eq_p_q:
200 \forall A. \forall x,y:A.
201 (\forall x,y:A. decidable (x=y)) \to
202 \forall p,q:x=y. p=q.
205 (\lambda x,y. \lambda p:x=y.
207 [ (or_introl p') \Rightarrow p'
208 | (or_intror K) \Rightarrow False_ind ? (K p) ]).
211 eq_ind ? ? (\lambda z. z=y) (nu ? ? q) ? (nu ? ? (refl_eq ? x))
216 apply (eq_rect' ? ? ? ? ? q);
217 fold simplify (nu ? ? (refl_eq ? x)).
218 generalize in match (nu ? ? (refl_eq ? x)); intro.
221 (\lambda y. \lambda u.
222 eq_ind A x (\lambda a.a=y) u y u = refl_eq ? y)
226 rewrite < (Hcut p); fold simplify (nu ? ? p).
227 rewrite < (Hcut q); fold simplify (nu ? ? q).
228 apply (Or_ind' (x=x) (x \neq x)
229 (\lambda p:decidable (x=x). eq_ind A x (\lambda z.z=y) (nu x y p) x
230 ([\lambda H1.eq A x x]
232 [(or_introl p') \Rightarrow p'
233 |(or_intror K) \Rightarrow False_ind (x=x) (K (refl_eq A x))]) =
234 eq_ind A x (\lambda z.z=y) (nu x y q) x
235 ([\lambda H1.eq A x x]
237 [(or_introl p') \Rightarrow p'
238 |(or_intror K) \Rightarrow False_ind (x=x) (K (refl_eq A x))]))
240 intro; simplify; reflexivity.
241 intro q; elim (q (refl_eq ? x)).
246 theorem a:\forall x.x=x\land True.
251 exact (refl_eq Prop x);