]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/tests/destruct_bb.ma
basic_rg: reduction was not tail recursive by mistake
[helm.git] / helm / software / matita / tests / destruct_bb.ma
index a494909f71d24084c52aa457c014b1960c5d00a2..494d5805a286f72977ac220c98b2eeb28cb721e6 100644 (file)
 (*        v         GNU General Public License Version 2                  *)
 (*                                                                        *)
 (**************************************************************************)
-(*
+
+include "logic/equality.ma".
+
 include "nat/nat.ma".
 include "list/list.ma".
 
+inductive list_x : Type ≝
+| nil_x  : list_x
+| cons_x : ∀T:Type.∀x:T.list_x → list_x.
+
+let rec mk_prod (l:list_x) ≝
+  match l with
+  [ nil_x ⇒ Type
+  | cons_x T x tl ⇒ ∀y0:T.∀p0:x = y0. mk_prod tl ].
+  
+let rec appl (l:list_x) : mk_prod l →  Type ≝ 
+ match l return λl:list_x.mk_prod l →Type
+ with
+ [ nil_x ⇒ λT:mk_prod nil_x.T
+ | cons_x Ty hd tl ⇒ λT:mk_prod (cons_x Ty hd tl).appl tl (T hd (refl_eq Ty hd)) ].
+  
+inductive list_xyp : list_x → Type ≝
+| nil_xyp  : ∀l.list_xyp l
+| cons_xyp : ∀l.∀T:mk_prod l.∀x:appl l T.list_xyp (cons_x ? x l) → list_xyp l.
+
+(* let rec tau (l:list_x) (w:list_xyp l) on w: Type ≝ 
+ match w with
+ [ nil_xyp _ ⇒ Type
+ | cons_xyp l' T' x' w' ⇒ 
+     ∀y:appl l' T'.∀p:x' = y.
+     tau (cons_x ? y l') w' ].
+
+eval normalize on (
+  ∀T0:Type.
+  ∀a0:T0.
+  ∀T1:∀x0:T0. a0=x0 → Type.
+  ∀a1:T1 a0 (refl_eq ? a0).
+tau ? (cons_xyp nil_x T0 a0 (cons_xyp (cons_x T0 a0 nil_x) T1 a1 (nil_xyp ?))) Type).
+
 inductive index_list (T: nat → Type): ∀m,n:nat.Type ≝
 | il_s : ∀n.T n → index_list T n n
 | il_c : ∀m,n. T m → index_list T (S m) n → index_list T m n.
@@ -28,31 +63,23 @@ intros 5;elim i
  |apply f1
   [rewrite > H;reflexivity
   |assumption]]]
-qed.
+qed. *)
 
-definition r1 : ∀T0,T1,a0,b0,e0.T1 a0 → T1 b0 ≝
-  λT0:Type.λT1:T0 → Type.
-  λa0,b0:T0.
-  λe0:a0 = b0.
-  λso:T1 a0.
-  eq_rect' ?? (λy,p.T1 y) so ? e0.
-  *)
-  
 definition R1 ≝ eq_rect'.
 
-
 definition R2 :
   ∀T0:Type.
   ∀a0:T0.
   ∀T1:∀x0:T0. a0=x0 → Type.
   ∀a1:T1 a0 (refl_eq ? a0).
   ∀T2:∀x0:T0. ∀p0:a0=x0. ∀x1:T1 x0 p0. R1 ??? a1 ? p0 = x1 → Type.
+  ∀a2:T2 a0 (refl_eq ? a0) a1 (refl_eq ? a1).  
   ∀b0:T0.
   ∀e0:a0 = b0.
   ∀b1: T1 b0 e0.
   ∀e1:R1 ??? a1 ? e0 = b1.
-  ∀so:T2 a0 (refl_eq ? a0) a1 (refl_eq ? a1).T2 b0 e0 b1 e1.
-intros 8;intros 2 (e1 H);
+  T2 b0 e0 b1 e1.
+intros 9;intro e1;
 apply (eq_rect' ????? e1);
 apply (R1 ?? ? ?? e0);
 simplify;assumption;
@@ -66,63 +93,21 @@ definition R3 :
   ∀T2:∀x0:T0. ∀p0:a0=x0. ∀x1:T1 x0 p0. R1 ??? a1 ? p0 = x1 → Type.
   ∀a2:T2 a0 (refl_eq ? a0) a1 (refl_eq ? a1).
   ∀T3:∀x0:T0. ∀p0:a0=x0. ∀x1:T1 x0 p0.∀p1:R1 ??? a1 ? p0 = x1.
-      ∀x2:T2 x0 p0 x1 p1.R2 ?????? p0 ? p1 a2 = x2→ Type.
+      ∀x2:T2 x0 p0 x1 p1.R2 T0 a0 T1 a1 T2 a2 ? p0 ? p1 = x2→ Type.
   ∀b0:T0.
   ∀e0:a0 = b0.
   ∀b1: T1 b0 e0.
   ∀e1:R1 ??? a1 ? e0 = b1.
   ∀b2: T2 b0 e0 b1 e1.
-  ∀e2:R2 ?????? e0 ? e1 a2 = b2.
-  ∀so:T3 a0 (refl_eq ? a0) a1 (refl_eq ? a1) a2 (refl_eq ? a2).T3 b0 e0 b1 e1 b2 e2.
+  ∀e2:R2 T0 a0 T1 a1 T2 a2 ? e0 ? e1 = b2.
+  ∀a3:T3 a0 (refl_eq ? a0) a1 (refl_eq ? a1) a2 (refl_eq ? a2).T3 b0 e0 b1 e1 b2 e2.      
 intros 12;intros 2 (e2 H);
 apply (eq_rect' ????? e2);
-apply (R2 ?? ? ??? e0 ? e1);
+apply (R2 ?? ? ???? e0 ? e1);
 simplify;assumption;
 qed.
 
-
-
-definition r3 : ∀T0:Type.∀T1:T0 → Type.∀T2:∀t0:T0.∀t1:T1 t0.Type.
-                ∀T3:∀t0:T0.∀t1:T1 t0.∀t2:T2 t0 t1.Type.
-                ∀a0,b0:T0.∀e0:a0 = b0.
-                ∀a1:T1 a0.∀b1:T1 b0.∀e1:r1 ?? ?? e0 a1 = b1.
-                ∀a2:T2 a0 a1.∀b2:T2 b0 b1.
-                ∀e2: r2 ????? e0 ?? e1 a2 = b2.
-                T3 a0 a1 a2 → T3 b0 b1 b2.
-intros 12;intro e2;intro H;
-apply (eq_rect' ????? e2);
-apply (R2 ?? ?? (λy0,p0,y1,p1.T3 y0 y1 (r2 T0 T1 T2 a0 y0 p0 a1 y1 p1 a2)) ? e0 ? e1);
-simplify;assumption;
-qed.
-
-
-apply (R2 ?? (λy0,p0,y1,p1.T3 y0 y1 (r2 T0 T1 T2 a0 y0 p0 a1 y1 p1 a2)) ??? e0 e1);
-simplify;
-                
-                
-                
-                
-                
-  λT0:Type.λT1:T0 → Type.λT2:∀t0:T0.∀t1:T1 t0.Type.
-  λT3:∀t0:T0.∀t1:T1 t0.∀t2:T2 t0 t1.Type.
-
-  λa0,b0:T0.
-  λe0:a0 = b0.
-
-  λa1:T1 a0.λb1: T1 b0.
-  λe1:r1 ???? e0 a1 = b1.
-
-  λa2:T2 a0 a1.λb2: T2 b0 b1.
-  λe2:r2 ????? e0 ?? e1 a2 = b2.
-  λso:T3 a0 a1 a2.
-  eq_rect' ?? (λy,p.T3 b0 b1 y) 
-    (eq_rect' ?? (λy,p.T3 b0 y (r2 ??? ??e0 ??p a2)) 
-       (eq_rect' T0 a0 (λy.λp:a0 = y.T3 y (r1 ?? a0 y p a1) (r2 ??? ??p  a2)) so b0 e0) 
-    ? e1)
-  ? e2.
-
-let rec iter_type n (l1 : lista dei nomi fin qui creati) (l2: lista dei tipi dipendenti da applicare) ≝
+(*let rec iter_type n (l1 : lista dei nomi fin qui creati) (l2: lista dei tipi dipendenti da applicare) ≝
   match n with
   [ O ⇒ Type
   | S p ⇒ match l2 with
@@ -144,7 +129,7 @@ let rec build_dep_type n T acc ≝
   [ O ⇒ acc
   | S p ⇒ 
 Type → list Type → Type.
-  λta,l.match l
+  λta,l.match l *)
 
 inductive II : nat → Type ≝
 | k1 : ∀n.II n
@@ -192,6 +177,14 @@ intros;rewrite > H;elim y;simplify;intros;
 |apply f;reflexivity]
 qed.
 
+axiom daemon:False.
+
+lemma IIconflict: ∀c,d.
+  k3 c d (k1 c) (k2 d) = k3 d c (k2 d) (k1 c) → False.
+intros;apply (IInc ??? H);clear H;intro;
+apply (eq_rect' ?? (λx.λp.∀e2:x=c.eq_rect ℕ c II (k1 c) x p=k2 x→eq_rect nat x II (k2 x) c e2 = k1 c → False) ?? e1);
+simplify;intros;apply (IInc ??? H);
+
 inductive I1 : nat → Type ≝
 | kI1 : ∀n.I1 n.
 
@@ -206,15 +199,52 @@ definition I3d: I3 → I3 → Type ≝
 [ kI3 t1 t2 (t3:I2 t1 t2) ⇒ match y with
   [ kI3 u1 u2 u3 ⇒ ∀P:Type.
     (∀e1: t1 = u1.
-     ∀e2: (eq_rect ?? (λx.I1 x) t2 ? e1) = u2.
-     ∀e3: (eq_rect' ?? (λy,p.I2 u1 y)
-            (eq_rect' ?? (λy,p.I2 y (eq_rect ?? (λx.I1 x) t2 ? p)) t3 ? e1) 
-            ? e2) = u3.P) → P]].
+     ∀e2: R1 ?? (λy1,p1.I1 y1) ?? e1 = u2.
+     ∀e3: R2 ???? (λy1,p1,y2,p2.I2 y1 y2) ? e1 ? e2 t3 = u3.P) → P]].
 
 lemma I3nc : ∀a,b.a = b → I3d a b.
 intros;rewrite > H;elim b;simplify;intros;apply f;reflexivity;
 qed.
 
+(*lemma R1_r : ΠA:Type.Πx:A.ΠP:Πy:A.y=x→Type.P x (refl_eq A x)→Πy:A.Πp:y=x.P y p.
+intros;lapply (eq_rect' A x P p y (sym_eq A y x p1));
+generalize in match Hletin;
+cut (∀p1:y = x.sym_eq ??? (sym_eq ??? p1) = p1)
+[rewrite > Hcut;intro;assumption
+|intro;apply (eq_rect' ????? p2);simplify;reflexivity]
+qed.
+
+definition R2_r :
+  ∀T0:Type.
+  ∀a0:T0.
+  ∀T1:∀x0:T0. x0=a0 → Type.
+  ∀a1:T1 a0 (refl_eq ? a0).
+  ∀T2:∀x0:T0. ∀p0:x0=a0. ∀x1:T1 x0 p0. x1 = R1_r ??? a1 ? p0 → Type.
+  ∀b0:T0.
+  ∀e0:b0 = a0.
+  ∀b1: T1 b0 e0.
+  ∀e1:b1 = R1_r ??? a1 ? e0.
+  ∀so:T2 a0 (refl_eq ? a0) a1 (refl_eq ? a1).T2 b0 e0 b1 e1.
+intros 8;intros 2 (e1 H);
+apply (R1_r ????? e1);
+apply (R1_r ?? ? ?? e0);
+simplify;assumption;
+qed.*)
+
+definition I3prova : ∀a,b,c,d,e,f.kI3 a b c = kI3 d e f → ∃P.P d e f.
+intros;apply (I3nc ?? H);clear H;
+simplify;intro;
+generalize in match f as f;generalize in match e as e;
+generalize in match c as c;generalize in match b as b;
+clear f e c b;
+apply (R1 ????? e1);intros 5;simplify in e2;
+generalize in match f as f;generalize in match c as c;
+clear f c;
+apply (R1 ????? e2);intros;simplify in H;
+elim daemon;
+qed.
+
+
 definition KKd : ∀m,n,p,q.KK m n → KK p q → Type ≝
  λa,b,c,d,x,y.match x with
  [ c1 n ⇒ match y with
@@ -237,20 +267,3 @@ lemma KKnc : ∀a,b,e,f.e = f → KKd a b a b e f.
 intros;rewrite > H;elim f;simplify;intros;apply f1;reflexivity;
 qed.
 
-lemma IIconflict: ∀c,d.
-  k3 c d (k1 c) (k2 d) = k3 d c (k2 d) (k1 c) → False.
-intros;apply (IInc ??? H);clear H;intro;
-apply (eq_rec ????? e1);
-intro;generalize in match e1;elim
-apply (eq_rect' ?? (λx.λp.∀e2:x=c.eq_rect ℕ c II (k1 c) x p=k2 x→eq_rect nat x II (k2 x) c e2 = k1 c → False) ?? e1);
-simplify;intro;
-apply (eq_rect' nat ? (λx.λp:c=x.k1 x = k2 x → eq_rect nat c II (k2 c) x p = k1 x → False) ?? e2);
-simplify;intro;
-
-generalize in match H1;
-apply (eq_rect' ?? (λx.λp.eq_rect ℕ c II (k1 c) x p=k2 x→False) ?? e1);
-simplify;intro;destruct;
-qed.
-
-elim e1 in H1;
-