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 (* ********************************************************************** *)
16 (* Progetto FreeScale *)
18 (* Sviluppato da: Cosimo Oliboni, oliboni@cs.unibo.it *)
19 (* Cosimo Oliboni, oliboni@cs.unibo.it *)
21 (* ********************************************************************** *)
23 universe constraint Type[0] < Type[1].
25 (* ********************************** *)
26 (* SOTTOINSIEME MINIMALE DELLA TEORIA *)
27 (* ********************************** *)
29 (* logic/connectives.ma *)
31 ninductive True: Prop ≝
34 ninductive False: Prop ≝.
36 ndefinition Not: Prop → Prop ≝
39 interpretation "logical not" 'not x = (Not x).
41 nlemma absurd : ∀A,C:Prop.A → ¬A → C.
48 nlemma not_to_not : ∀A,B:Prop. (A → B) → ¬B →¬A.
55 nlemma prop_to_nnprop : ∀P.P → ¬¬P.
56 #P; nnormalize; #H; #H1;
61 naxiom RAA : ∀P:Prop.∀f:(¬P) → False.P.
63 nlemma nnprop_to_prop : ∀P.(¬¬P) → P.
64 #P; nchange with (((¬P) → False) → P);
69 ninductive And (A,B:Prop) : Prop ≝
70 conj : A → B → (And A B).
72 interpretation "logical and" 'and x y = (And x y).
74 nlemma proj1: ∀A,B:Prop.A ∧ B → A.
76 (* \ldots al posto di ??? *)
77 napply (And_ind A B … H);
82 nlemma proj2: ∀A,B:Prop.A ∧ B → B.
84 napply (And_ind A B … H);
89 ninductive Or (A,B:Prop) : Prop ≝
90 or_introl : A → (Or A B)
91 | or_intror : B → (Or A B).
93 interpretation "logical or" 'or x y = (Or x y).
95 ndefinition decidable : Prop → Prop ≝ λA:Prop.A ∨ ¬A.
98 nlemma decidable_prop : ∀P:Prop.decidable P.
102 napply (absurd (P ∨ (¬P)) …);
104 ##| ##1: napply (or_intror P (¬P));
107 napply (absurd (P ∨ (¬P)) …);
109 ##| ##1: napply (or_introl P (¬P));
110 napply (nnprop_to_prop P H1)
115 nlemma terzo_escluso : ∀P,G:Prop.∀ft:P → G.∀ff:(¬P) → G.G.
118 napply (Or_ind P (P → False) ? H H1 ?);
119 napply (decidable_prop P).
123 nlemma or_elim : ∀P,Q,G:Prop.Or P Q → ∀fp:P → G.∀fq:Q → G.G.
124 #P; #Q; #G; #H; #H1; #H2;
125 napply (Or_ind P Q ? H1 H2 ?);
129 ninductive ex (A:Type) (Q:A → Prop) : Prop ≝
130 ex_intro: ∀x:A.Q x → ex A Q.
132 interpretation "exists" 'exists x = (ex ? x).
134 ninductive ex2 (A:Type) (Q,R:A → Prop) : Prop ≝
135 ex_intro2: ∀x:A.Q x → R x → ex2 A Q R.
138 λA,B.(A → B) ∧ (B → A).
140 (* higher_order_defs/relations *)
142 ndefinition relation : Type → Type ≝
143 λA:Type.A → A → Prop.
145 ndefinition reflexive : ∀A:Type.∀R:relation A.Prop ≝
148 ndefinition symmetric : ∀A:Type.∀R:relation A.Prop ≝
149 λA.λR.∀x,y:A.R x y → R y x.
151 ndefinition transitive : ∀A:Type.∀R:relation A.Prop ≝
152 λA.λR.∀x,y,z:A.R x y → R y z → R x z.
154 ndefinition irreflexive : ∀A:Type.∀R:relation A.Prop ≝
155 λA.λR.∀x:A.¬ (R x x).
157 ndefinition cotransitive : ∀A:Type.∀R:relation A.Prop ≝
158 λA.λR.∀x,y:A.R x y → ∀z:A. R x z ∨ R z y.
160 ndefinition tight_apart : ∀A:Type.∀eq,ap:relation A.Prop ≝
161 λA.λeq,ap.∀x,y:A. (¬ (ap x y) → eq x y) ∧ (eq x y → ¬ (ap x y)).
163 ndefinition antisymmetric : ∀A:Type.∀R:relation A.Prop ≝
164 λA.λR.∀x,y:A.R x y → ¬ (R y x).
166 (* logic/equality.ma *)
168 ninductive eq (A:Type) (x:A) : A → Prop ≝
171 interpretation "leibnitz's equality" 'eq t x y = (eq t x y).
173 interpretation "leibnitz's non-equality" 'neq t x y = (Not (eq t x y)).
175 nlemma eq_f : ∀T1,T2:Type.∀x,y:T1.∀f:T1 → T2.x = y → (f x) = (f y).
176 #T1; #T2; #x; #y; #f; #H;
181 nlemma eq_f2 : ∀T1,T2,T3:Type.∀x1,y1:T1.∀x2,y2:T2.∀f:T1 → T2 → T3.x1 = y1 → x2 = y2 → f x1 x2 = f y1 y2.
182 #T1; #T2; #T3; #x1; #y1; #x2; #y2; #f; #H1; #H2;
188 nlemma neqf_to_neq : ∀T1,T2:Type.∀x,y:T1.∀f:T1 → T2.((f x) ≠ (f y)) → x ≠ y.
189 #T1; #T2; #x; #y; #f;
191 napply (H (eq_f … H1)).
195 nlemma neqf2_to_neq : ∀T1,T2,T3:Type.∀x1,y1:T1.∀x2,y2:T2.∀f:T1 → T2 → T3.f x1 x2 ≠ f y1 y2 → (x1 ≠ y1) ∨ (x2 ≠ y2).
196 #T1; #T2; #T3; #x1; #y1; #x2; #y2; #f; nnormalize; #H;
197 napply (terzo_escluso (x1 = y1) …);
198 ##[ ##2: #H1; napply (or_introl … H1)
199 ##| ##1: #H1; napply (terzo_escluso (x2 = y2) …)
200 ##[ ##2: #H2; napply (or_intror … H2)
201 ##| ##1: #H2; nrewrite < H1 in H:(%);
203 nelim (H (refl_eq …))
209 nlemma symmetric_eq: ∀A:Type. symmetric A (eq A).
217 nlemma eq_elim_r: ∀A:Type.∀x:A.∀P:A → Prop.P x → ∀y:A.y=x → P y.
218 #A; #x; #P; #H; #y; #H1;
219 nrewrite < (symmetric_eq … H1);
223 ndefinition relationT : Type → Type → Type ≝
226 ndefinition symmetricT: ∀A,T:Type.∀R:relationT A T.Prop ≝
227 λA,T.λR.∀x,y:A.R x y = R y x.
229 ndefinition associative : ∀A:Type.∀R:relationT A A.Prop ≝
230 λA.λR.∀x,y,z:A.R (R x y) z = R x (R y z).