]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/contribs/ng_assembly/freescale/theory.ma
freescale translation (work in progress)
[helm.git] / helm / software / matita / contribs / ng_assembly / freescale / theory.ma
index 65800d2e5011e2b0a38769bd4e29ed2aafc4de3a..dcf3789fda825512c7a055221e8186059070bf44 100644 (file)
@@ -30,6 +30,8 @@ include "freescale/pts.ma".
 (* SOTTOINSIEME MINIMALE DELLA TEORIA *)
 (* ********************************** *)
 
+(* logic/connectives.ma *)
+
 ninductive True: Prop ≝
  I : True.
 
@@ -140,6 +142,8 @@ ndefinition ex2_ind : ΠA:Type.ΠQ,R:A → Prop.ΠP:Prop.(Πa:A.Q a → R a →
 ndefinition iff ≝
 λA,B.(A -> B) ∧ (B -> A).
 
+(* higher_order_defs/relations *)
+
 ndefinition relation : Type → Type ≝
 λA:Type.A → A → Prop. 
 
@@ -164,6 +168,8 @@ ndefinition tight_apart : ∀A:Type.∀eq,ap:relation A.Prop ≝
 ndefinition antisymmetric : ∀A:Type.∀R:relation A.Prop ≝
 λA.λR.∀x,y:A.R x y → ¬ (R y x).
 
+(* logic/equality.ma *)
+
 ninductive eq (A:Type) (x:A) : A → Prop ≝
  refl_eq : eq A x x.
 
@@ -203,3 +209,109 @@ ndefinition relationT : Type → Type → Type ≝
 
 ndefinition symmetricT: ∀A,T:Type.∀R:relationT A T.Prop ≝
 λA,T.λR.∀x,y:A.R x y = R y x.
+
+ndefinition associative : ∀A:Type.∀R:relationT A A.Prop ≝
+λA.λR.∀x,y,z:A.R (R x y) z = R x (R y z).
+
+(* list/list.ma *)
+
+ninductive list (A:Type) : Type ≝
+  nil: list A
+| cons: A -> list A -> list A.
+
+nlet rec list_ind (A:Type) (P:list A → Prop) (p:P (nil A)) (f:(Πa:A.Πl':list A.P l' → P (cons A a l'))) (l:list A) on l ≝
+ match l with [ nil ⇒ p | cons h t ⇒ f h t (list_ind A P p f t) ].
+
+nlet rec list_rec (A:Type) (P:list A → Set) (p:P (nil A)) (f:Πa:A.Πl':list A.P l' → P (cons A a l')) (l:list A) on l ≝
+ match l with [ nil ⇒ p | cons h t ⇒ f h t (list_rec A P p f t) ].
+
+nlet rec list_rect (A:Type) (P:list A → Type) (p:P (nil A)) (f:Πa:A.Πl':list A.P l' → P (cons A a l')) (l:list A) on l ≝
+ match l with [ nil ⇒ p | cons h t ⇒ f h t (list_rect A P p f t) ].
+
+nlet rec append A (l1: list A) l2 on l1 ≝
+ match l1 with
+  [ nil => l2
+  | (cons hd tl) => cons A hd (append A tl l2) ].
+
+notation "hvbox(hd break :: tl)"
+  right associative with precedence 47
+  for @{'cons $hd $tl}.
+
+notation "[ list0 x sep ; ]"
+  non associative with precedence 90
+  for ${fold right @'nil rec acc @{'cons $x $acc}}.
+
+notation "hvbox(l1 break @ l2)"
+  right associative with precedence 47
+  for @{'append $l1 $l2 }.
+
+interpretation "nil" 'nil = (nil ?).
+interpretation "cons" 'cons hd tl = (cons ? hd tl).
+interpretation "append" 'append l1 l2 = (append ? l1 l2).
+
+nlemma list_destruct_1 : ∀T.∀x1,x2:T.∀y1,y2:list T.cons T x1 y1 = cons T x2 y2 → x1 = x2.
+ #T; #x1; #x2; #y1; #y2; #H;
+ nchange with (match cons T x2 y2 with [ nil ⇒ False | cons a _ ⇒ x1 = a ]);
+ nrewrite < H;
+ nnormalize;
+ napply (refl_eq ??).
+nqed.
+
+nlemma list_destruct_2 : ∀T.∀x1,x2:T.∀y1,y2:list T.cons T x1 y1 = cons T x2 y2 → y1 = y2.
+ #T; #x1; #x2; #y1; #y2; #H;
+ nchange with (match cons T x2 y2 with [ nil ⇒ False | cons _ b ⇒ y1 = b ]);
+ nrewrite < H;
+ nnormalize;
+ napply (refl_eq ??).
+nqed.
+
+nlemma list_destruct_cons_nil : ∀T.∀x:T.∀y:list T.cons T x y = nil T → False.
+ #T; #x; #y; #H;
+ nchange with (match cons T x y with [ nil ⇒ True | cons a b ⇒ False ]);
+ nrewrite > H;
+ nnormalize;
+ napply I.
+nqed.
+
+nlemma list_destruct_nil_cons : ∀T.∀x:T.∀y:list T.nil T = cons T x y → False.
+ #T; #x; #y; #H;
+ nchange with (match cons T x y with [ nil ⇒ True | cons a b ⇒ False ]);
+ nrewrite < H;
+ nnormalize;
+ napply I.
+nqed.
+
+nlemma append_nil : ∀T:Type.∀l:list T.(l@[]) = l.
+ #T; #l;
+ napply (list_ind T ??? l);
+ nnormalize;
+ ##[ ##1: napply (refl_eq ??)
+ ##| ##2: #x; #y; #H;
+          nrewrite > H;
+          napply (refl_eq ??)
+ ##]
+nqed.
+
+nlemma associative_list : ∀T.associative (list T) (append T).
+ #T; #x; #y; #z;
+ napply (list_ind T ??? x);
+ nnormalize;
+ ##[ ##1: napply (refl_eq ??)
+ ##| ##2: #a; #b; #H;
+          nrewrite > H;
+          napply (refl_eq ??)
+ ##]
+nqed.
+
+nlemma cons_append_commute : ∀T:Type.∀l1,l2:list T.∀a:T.a :: (l1 @ l2) = (a :: l1) @ l2.
+ #T; #l1; #l2; #a;
+ nnormalize;
+ napply (refl_eq ??).
+nqed.
+
+nlemma append_cons_commute : ∀T:Type.∀a:T.∀l,l1:list T.l @ (a::l1) = (l@[a]) @ l1.
+ #T; #a; #l; #l1;
+ nrewrite > (associative_list T l [a] l1);
+ nnormalize;
+ napply (refl_eq ??).
+nqed.