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 include "freescale/pts.ma".
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 ninductive And (A,B:Prop) : Prop ≝
56 conj : A → B → (And A B).
58 interpretation "logical and" 'and x y = (And x y).
60 nlemma proj1: ∀A,B:Prop.A ∧ B → A.
62 (* \ldots al posto di ??? *)
63 napply (And_ind A B … H);
68 nlemma proj2: ∀A,B:Prop.A ∧ B → B.
70 napply (And_ind A B … H);
75 ninductive Or (A,B:Prop) : Prop ≝
76 or_introl : A → (Or A B)
77 | or_intror : B → (Or A B).
79 interpretation "logical or" 'or x y = (Or x y).
81 ndefinition decidable : Prop → Prop ≝ λA:Prop.A ∨ ¬A.
83 ninductive ex (A:Type) (Q:A → Prop) : Prop ≝
84 ex_intro: ∀x:A.Q x → ex A Q.
86 interpretation "exists" 'exists x = (ex ? x).
88 ninductive ex2 (A:Type) (Q,R:A → Prop) : Prop ≝
89 ex_intro2: ∀x:A.Q x → R x → ex2 A Q R.
92 λA,B.(A → B) ∧ (B → A).
94 (* higher_order_defs/relations *)
96 ndefinition relation : Type → Type ≝
99 ndefinition reflexive : ∀A:Type.∀R:relation A.Prop ≝
102 ndefinition symmetric : ∀A:Type.∀R:relation A.Prop ≝
103 λA.λR.∀x,y:A.R x y → R y x.
105 ndefinition transitive : ∀A:Type.∀R:relation A.Prop ≝
106 λA.λR.∀x,y,z:A.R x y → R y z → R x z.
108 ndefinition irreflexive : ∀A:Type.∀R:relation A.Prop ≝
109 λA.λR.∀x:A.¬ (R x x).
111 ndefinition cotransitive : ∀A:Type.∀R:relation A.Prop ≝
112 λA.λR.∀x,y:A.R x y → ∀z:A. R x z ∨ R z y.
114 ndefinition tight_apart : ∀A:Type.∀eq,ap:relation A.Prop ≝
115 λA.λeq,ap.∀x,y:A. (¬ (ap x y) → eq x y) ∧ (eq x y → ¬ (ap x y)).
117 ndefinition antisymmetric : ∀A:Type.∀R:relation A.Prop ≝
118 λA.λR.∀x,y:A.R x y → ¬ (R y x).
120 (* logic/equality.ma *)
122 ninductive eq (A:Type) (x:A) : A → Prop ≝
125 interpretation "leibnitz's equality" 'eq t x y = (eq t x y).
127 interpretation "leibnitz's non-equality" 'neq t x y = (Not (eq t x y)).
129 nlemma symmetric_eq: ∀A:Type. symmetric A (eq A).
137 nlemma eq_elim_r: ∀A:Type.∀x:A.∀P:A → Prop.P x → ∀y:A.y=x → P y.
138 #A; #x; #P; #H; #y; #H1;
139 nrewrite < (symmetric_eq … H1);
143 ndefinition relationT : Type → Type → Type ≝
146 ndefinition symmetricT: ∀A,T:Type.∀R:relationT A T.Prop ≝
147 λA,T.λR.∀x,y:A.R x y = R y x.
149 ndefinition associative : ∀A:Type.∀R:relationT A A.Prop ≝
150 λA.λR.∀x,y,z:A.R (R x y) z = R x (R y z).
154 ninductive list (A:Type) : Type ≝
156 | cons: A → list A → list A.
158 nlet rec append A (l1: list A) l2 on l1 ≝
161 | (cons hd tl) ⇒ cons A hd (append A tl l2) ].
163 notation "hvbox(hd break :: tl)"
164 right associative with precedence 47
165 for @{'cons $hd $tl}.
167 notation "[ list0 x sep ; ]"
168 non associative with precedence 90
169 for ${fold right @'nil rec acc @{'cons $x $acc}}.
171 notation "hvbox(l1 break @ l2)"
172 right associative with precedence 47
173 for @{'append $l1 $l2 }.
175 interpretation "nil" 'nil = (nil ?).
176 interpretation "cons" 'cons hd tl = (cons ? hd tl).
177 interpretation "append" 'append l1 l2 = (append ? l1 l2).
179 nlemma list_destruct_1 : ∀T.∀x1,x2:T.∀y1,y2:list T.cons T x1 y1 = cons T x2 y2 → x1 = x2.
180 #T; #x1; #x2; #y1; #y2; #H;
181 nchange with (match cons T x2 y2 with [ nil ⇒ False | cons a _ ⇒ x1 = a ]);
187 nlemma list_destruct_2 : ∀T.∀x1,x2:T.∀y1,y2:list T.cons T x1 y1 = cons T x2 y2 → y1 = y2.
188 #T; #x1; #x2; #y1; #y2; #H;
189 nchange with (match cons T x2 y2 with [ nil ⇒ False | cons _ b ⇒ y1 = b ]);
195 nlemma list_destruct_cons_nil : ∀T.∀x:T.∀y:list T.cons T x y = nil T → False.
197 nchange with (match cons T x y with [ nil ⇒ True | cons a b ⇒ False ]);
203 nlemma list_destruct_nil_cons : ∀T.∀x:T.∀y:list T.nil T = cons T x y → False.
205 nchange with (match cons T x y with [ nil ⇒ True | cons a b ⇒ False ]);
211 nlemma append_nil : ∀T:Type.∀l:list T.(l@[]) = l.
215 ##[ ##1: napply refl_eq
222 nlemma associative_list : ∀T.associative (list T) (append T).
226 ##[ ##1: napply refl_eq
233 nlemma cons_append_commute : ∀T:Type.∀l1,l2:list T.∀a:T.a :: (l1 @ l2) = (a :: l1) @ l2.
239 nlemma append_cons_commute : ∀T:Type.∀a:T.∀l,l1:list T.l @ (a::l1) = (l@[a]) @ l1.
241 nrewrite > (associative_list T l [a] l1);