From: Wilmer Ricciotti Date: Wed, 3 Jun 2009 16:47:25 +0000 (+0000) Subject: Update, using induction/inversion. X-Git-Tag: make_still_working~3927 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;ds=inline;h=e2af8984bc1f706eb69b54c99870d8b64a6d75a7;p=helm.git Update, using induction/inversion. --- diff --git a/helm/software/matita/contribs/POPLmark/Fsub/defn.ma b/helm/software/matita/contribs/POPLmark/Fsub/defn.ma index d9e4e4695..cd7bbfdfe 100644 --- a/helm/software/matita/contribs/POPLmark/Fsub/defn.ma +++ b/helm/software/matita/contribs/POPLmark/Fsub/defn.ma @@ -15,16 +15,16 @@ include "Fsub/util.ma". (*** representation of Fsub types ***) -inductive Typ : Set \def - | TVar : nat \to Typ (* type var *) - | TFree: nat \to Typ (* free type name *) +inductive Typ : Set ≝ + | TVar : nat → Typ (* type var *) + | TFree: nat → Typ (* free type name *) | Top : Typ (* maximum type *) - | Arrow : Typ \to Typ \to Typ (* functions *) - | Forall : Typ \to Typ \to Typ. (* universal type *) + | Arrow : Typ → Typ → Typ (* functions *) + | Forall : Typ → Typ → Typ. (* universal type *) (* representation of bounds *) -record bound : Set \def { +record bound : Set ≝ { istype : bool; (* is subtyping bound? *) name : nat ; (* name *) btype : Typ (* type to which the name is bound *) @@ -33,259 +33,222 @@ record bound : Set \def { (*** Various kinds of substitution, not all will be used probably ***) (* substitutes i-th dangling index in type T with type U *) -let rec subst_type_nat T U i \def +let rec subst_type_nat T U i ≝ match T with - [ (TVar n) \Rightarrow match (eqb n i) with - [ true \Rightarrow U - | false \Rightarrow T] - | (TFree X) \Rightarrow T - | Top \Rightarrow T - | (Arrow T1 T2) \Rightarrow (Arrow (subst_type_nat T1 U i) (subst_type_nat T2 U i)) - | (Forall T1 T2) \Rightarrow (Forall (subst_type_nat T1 U i) (subst_type_nat T2 U (S i))) ]. + [ TVar n ⇒ match eqb n i with + [ true ⇒ U + | false ⇒ T] + | TFree X ⇒ T + | Top ⇒ T + | Arrow T1 T2 ⇒ Arrow (subst_type_nat T1 U i) (subst_type_nat T2 U i) + | Forall T1 T2 ⇒ Forall (subst_type_nat T1 U i) (subst_type_nat T2 U (S i)) ]. (*** definitions about lists ***) -definition fv_env : (list bound) \to (list nat) \def - \lambda G.(map ? ? (\lambda b.match b with - [(mk_bound B X T) \Rightarrow X]) G). +definition fv_env : list bound → list nat ≝ + λG.(map ? ? (λb.match b with [mk_bound B X T ⇒ X]) G). -let rec fv_type T \def +let rec fv_type T ≝ match T with - [(TVar n) \Rightarrow [] - |(TFree x) \Rightarrow [x] - |Top \Rightarrow [] - |(Arrow U V) \Rightarrow ((fv_type U) @ (fv_type V)) - |(Forall U V) \Rightarrow ((fv_type U) @ (fv_type V))]. + [TVar n ⇒ [] + |TFree x ⇒ [x] + |Top ⇒ [] + |Arrow U V ⇒ fv_type U @ fv_type V + |Forall U V ⇒ fv_type U @ fv_type V]. (*** Type Well-Formedness judgement ***) -inductive WFType : (list bound) \to Typ \to Prop \def - | WFT_TFree : \forall X,G.(in_list ? X (fv_env G)) - \to (WFType G (TFree X)) - | WFT_Top : \forall G.(WFType G Top) - | WFT_Arrow : \forall G,T,U.(WFType G T) \to (WFType G U) \to - (WFType G (Arrow T U)) - | WFT_Forall : \forall G,T,U.(WFType G T) \to - (\forall X:nat. - (\lnot (in_list ? X (fv_env G))) \to - (\lnot (in_list ? X (fv_type U))) \to - (WFType ((mk_bound true X T) :: G) - (subst_type_nat U (TFree X) O))) \to +inductive WFType : list bound → Typ → Prop ≝ + | WFT_TFree : ∀X,G.in_list ? X (fv_env G) → WFType G (TFree X) + | WFT_Top : ∀G.WFType G Top + | WFT_Arrow : ∀G,T,U.WFType G T → WFType G U → WFType G (Arrow T U) + | WFT_Forall : ∀G,T,U.WFType G T → + (∀X:nat. + (¬ (in_list ? X (fv_env G))) → + (¬ (in_list ? X (fv_type U))) → + (WFType ((mk_bound true X T) :: G) + (subst_type_nat U (TFree X) O))) → (WFType G (Forall T U)). (*** Environment Well-Formedness judgement ***) -inductive WFEnv : (list bound) \to Prop \def - | WFE_Empty : (WFEnv (nil ?)) - | WFE_cons : \forall B,X,T,G.(WFEnv G) \to - \lnot (in_list ? X (fv_env G)) \to - (WFType G T) \to (WFEnv ((mk_bound B X T) :: G)). +inductive WFEnv : list bound → Prop ≝ + | WFE_Empty : WFEnv (nil ?) + | WFE_cons : ∀B,X,T,G.WFEnv G → ¬ (in_list ? X (fv_env G)) → + WFType G T → WFEnv ((mk_bound B X T) :: G). (*** Subtyping judgement ***) -inductive JSubtype : (list bound) \to Typ \to Typ \to Prop \def - | SA_Top : \forall G.\forall T:Typ.(WFEnv G) \to - (WFType G T) \to (JSubtype G T Top) - | SA_Refl_TVar : \forall G.\forall X:nat.(WFEnv G) - \to (in_list ? X (fv_env G)) - \to (JSubtype G (TFree X) (TFree X)) - | SA_Trans_TVar : \forall G.\forall X:nat.\forall T:Typ. - \forall U:Typ. - (in_list ? (mk_bound true X U) G) \to - (JSubtype G U T) \to (JSubtype G (TFree X) T) - | SA_Arrow : \forall G.\forall S1,S2,T1,T2:Typ. - (JSubtype G T1 S1) \to (JSubtype G S2 T2) \to - (JSubtype G (Arrow S1 S2) (Arrow T1 T2)) - | SA_All : \forall G.\forall S1,S2,T1,T2:Typ. - (JSubtype G T1 S1) \to - (\forall X:nat.\lnot (in_list ? X (fv_env G)) \to - (JSubtype ((mk_bound true X T1) :: G) - (subst_type_nat S2 (TFree X) O) (subst_type_nat T2 (TFree X) O))) \to - (JSubtype G (Forall S1 S2) (Forall T1 T2)). +inductive JSubtype : list bound → Typ → Typ → Prop ≝ + | SA_Top : ∀G,T.WFEnv G → WFType G T → JSubtype G T Top + | SA_Refl_TVar : ∀G,X.WFEnv G → in_list ? X (fv_env G) + → JSubtype G (TFree X) (TFree X) + | SA_Trans_TVar : ∀G,X,T,U.in_list ? (mk_bound true X U) G → + JSubtype G U T → JSubtype G (TFree X) T + | SA_Arrow : ∀G,S1,S2,T1,T2. JSubtype G T1 S1 → JSubtype G S2 T2 → + JSubtype G (Arrow S1 S2) (Arrow T1 T2) + | SA_All : ∀G,S1,S2,T1,T2. JSubtype G T1 S1 → + (∀X.¬ (in_list ? X (fv_env G)) → + JSubtype ((mk_bound true X T1) :: G) + (subst_type_nat S2 (TFree X) O) (subst_type_nat T2 (TFree X) O)) → + JSubtype G (Forall S1 S2) (Forall T1 T2). notation "hvbox(e ⊢ break ta ⊴ break tb)" non associative with precedence 30 for @{ 'subjudg $e $ta $tb }. -interpretation "Fsub subtype judgement" 'subjudg e ta tb = - (cic:/matita/Fsub/defn/JSubtype.ind#xpointer(1/1) e ta tb). +interpretation "Fsub subtype judgement" 'subjudg e ta tb = (JSubtype e ta tb). notation > "hvbox(\Forall S.T)" non associative with precedence 60 for @{ 'forall $S $T}. notation < "hvbox('All' \sub S. break T)" non associative with precedence 60 for @{ 'forall $S $T}. -interpretation "universal type" 'forall S T = - (cic:/matita/Fsub/defn/Typ.ind#xpointer(1/1/5) S T). +interpretation "universal type" 'forall S T = (Forall S T). notation "#x" with precedence 79 for @{'tvar $x}. -interpretation "bound tvar" 'tvar x = - (cic:/matita/Fsub/defn/Typ.ind#xpointer(1/1/1) x). +interpretation "bound tvar" 'tvar x = (TVar x). notation "!x" with precedence 79 for @{'tname $x}. -interpretation "bound tname" 'tname x = - (cic:/matita/Fsub/defn/Typ.ind#xpointer(1/1/2) x). +interpretation "bound tname" 'tname x = (TFree x). notation "⊤" with precedence 90 for @{'toptype}. -interpretation "toptype" 'toptype = - (cic:/matita/Fsub/defn/Typ.ind#xpointer(1/1/3)). +interpretation "toptype" 'toptype = Top. notation "hvbox(s break ⇛ t)" right associative with precedence 55 for @{ 'arrow $s $t }. -interpretation "arrow type" 'arrow S T = - (cic:/matita/Fsub/defn/Typ.ind#xpointer(1/1/4) S T). +interpretation "arrow type" 'arrow S T = (Arrow S T). notation "hvbox(S [# n ↦ T])" non associative with precedence 80 for @{ 'substvar $S $T $n }. -interpretation "subst bound var" 'substvar S T n = - (cic:/matita/Fsub/defn/subst_type_nat.con S T n). +interpretation "subst bound var" 'substvar S T n = (subst_type_nat S T n). notation "hvbox(!X ⊴ T)" non associative with precedence 60 for @{ 'subtypebound $X $T }. -interpretation "subtyping bound" 'subtypebound X T = - (cic:/matita/Fsub/defn/bound.ind#xpointer(1/1/1) true X T). +interpretation "subtyping bound" 'subtypebound X T = (mk_bound true X T). (****** PROOFS ********) (*** theorems about lists ***) -lemma boundinenv_natinfv : \forall x,G. - (\exists B,T.(in_list ? (mk_bound B x T) G)) \to - (in_list ? x (fv_env G)). -intros 2;elim G - [elim H;elim H1;lapply (not_in_list_nil ? ? H2);elim Hletin - |elim H1;elim H2;elim (in_list_cons_case ? ? ? ? H3) - [rewrite < H4;simplify;apply in_list_head - |simplify;apply in_list_cons;apply H;apply (ex_intro ? ? a1); - apply (ex_intro ? ? a2);assumption]] +lemma boundinenv_natinfv : ∀x,G.(∃B,T.in_list ? (mk_bound B x T) G) → + in_list ? x (fv_env G). +intros 2;elim G;decompose + [elim (not_in_list_nil ? ? H) + |elim (in_list_cons_case ? ? ? ? H1) + [rewrite < H2;simplify;apply in_list_head + |simplify;apply in_list_cons;apply H;autobatch]] qed. -lemma natinfv_boundinenv : \forall x,G.(in_list ? x (fv_env G)) \to - \exists B,T.(in_list ? (mk_bound B x T) G). +lemma natinfv_boundinenv : ∀x,G.in_list ? x (fv_env G) → + ∃B,T.in_list ? (mk_bound B x T) G. intros 2;elim G 0 [simplify;intro;lapply (not_in_list_nil ? ? H);elim Hletin |intros 3; elim a;simplify in H1;elim (in_list_cons_case ? ? ? ? H1) - [rewrite < H2;apply (ex_intro ? ? b);apply (ex_intro ? ? t);apply in_list_head - |elim (H H2);elim H3;apply (ex_intro ? ? a1); - apply (ex_intro ? ? a2);apply in_list_cons;assumption]] + [rewrite < H2;autobatch + |elim (H H2);elim H3;apply ex_intro[apply a1];autobatch]] qed. -lemma incl_bound_fv : \forall l1,l2.(incl ? l1 l2) \to - (incl ? (fv_env l1) (fv_env l2)). -intros.unfold in H.unfold.intros.apply boundinenv_natinfv. -lapply (natinfv_boundinenv ? ? H1).elim Hletin.elim H2.apply ex_intro - [apply a - |apply ex_intro - [apply a1 - |apply (H ? H3)]] +lemma incl_bound_fv : ∀l1,l2.incl ? l1 l2 → incl ? (fv_env l1) (fv_env l2). +intros;unfold in H;unfold;intros;apply boundinenv_natinfv; +lapply (natinfv_boundinenv ? ? H1);decompose;autobatch depth=4; qed. -lemma incl_cons : \forall x,l1,l2. - (incl ? l1 l2) \to (incl nat (x :: l1) (x :: l2)). +lemma incl_cons : ∀x,l1,l2.incl ? l1 l2 → incl nat (x :: l1) (x :: l2). intros.unfold in H.unfold.intros.elim (in_list_cons_case ? ? ? ? H1) - [rewrite > H2;apply in_list_head|apply in_list_cons;apply (H ? H2)] + [applyS in_list_head|autobatch] qed. -lemma WFT_env_incl : \forall G,T.(WFType G T) \to - \forall H.(incl ? (fv_env G) (fv_env H)) \to (WFType H T). +lemma WFT_env_incl : ∀G,T.WFType G T → + ∀H.incl ? (fv_env G) (fv_env H) → WFType H T. intros 3.elim H [apply WFT_TFree;unfold in H3;apply (H3 ? H1) |apply WFT_Top - |apply WFT_Arrow [apply (H2 ? H6)|apply (H4 ? H6)] + |apply WFT_Arrow;autobatch |apply WFT_Forall [apply (H2 ? H6) |intros;apply (H4 ? ? H8) - [unfold;intro;apply H7;apply(H6 ? H9) + [unfold;intro;autobatch |simplify;apply (incl_cons ? ? ? H6)]]] qed. -lemma fv_env_extends : \forall H,x,B,C,T,U,G. - (fv_env (H @ ((mk_bound B x T) :: G))) = - (fv_env (H @ ((mk_bound C x U) :: G))). +lemma fv_env_extends : ∀H,x,B,C,T,U,G. + fv_env (H @ ((mk_bound B x T) :: G)) = + fv_env (H @ ((mk_bound C x U) :: G)). intros;elim H - [simplify;reflexivity|elim a;simplify;rewrite > H1;reflexivity] + [reflexivity|elim a;simplify;rewrite > H1;reflexivity] qed. -lemma lookup_env_extends : \forall G,H,B,C,D,T,U,V,x,y. - (in_list ? (mk_bound D y V) (H @ ((mk_bound C x U) :: G))) \to - (y \neq x) \to - (in_list ? (mk_bound D y V) (H @ ((mk_bound B x T) :: G))). +lemma lookup_env_extends : ∀G,H,B,C,D,T,U,V,x,y. + in_list ? (mk_bound D y V) (H @ ((mk_bound C x U) :: G)) → y ≠ x → + in_list ? (mk_bound D y V) (H @ ((mk_bound B x T) :: G)). intros 10;elim H [simplify in H1;elim (in_list_cons_case ? ? ? ? H1) - [destruct H3;elim (H2);reflexivity + [destruct H3;elim H2;reflexivity |simplify;apply (in_list_cons ? ? ? ? H3);] |simplify in H2;simplify;elim (in_list_cons_case ? ? ? ? H2) [rewrite > H4;apply in_list_head |apply (in_list_cons ? ? ? ? (H1 H4 H3))]] qed. -lemma in_FV_subst : \forall x,T,U,n.(in_list ? x (fv_type T)) \to - (in_list ? x (fv_type (subst_type_nat T U n))). +lemma in_FV_subst : ∀x,T,U,n.in_list ? x (fv_type T) → + in_list ? x (fv_type (subst_type_nat T U n)). intros 3;elim T [simplify in H;elim (not_in_list_nil ? ? H) |2,3:simplify;simplify in H;assumption - |*:simplify in H2;simplify;elim (in_list_append_to_or_in_list ? ? ? ? H2) - [1,3:apply in_list_to_in_list_append_l;apply (H ? H3) - |*:apply in_list_to_in_list_append_r;apply (H1 ? H3)]] + |*:simplify in H2;simplify;elim (in_list_append_to_or_in_list ? ? ? ? H2); + autobatch] qed. (*** lemma on fresh names ***) -lemma fresh_name : \forall l:(list nat).\exists n.\lnot (in_list ? n l). -cut (\forall l:(list nat).\exists n.\forall m. - (n \leq m) \to \lnot (in_list ? m l)) - [intros;lapply (Hcut l);elim Hletin;apply ex_intro - [apply a - |apply H;constructor 1] - |intros;elim l - [apply (ex_intro ? ? O);intros;unfold;intro;elim (not_in_list_nil ? ? H1) - |elim H; - apply (ex_intro ? ? (S (max a1 a))). - intros.unfold. intro. +lemma fresh_name : ∀l:list nat.∃n.¬in_list ? n l. +cut (∀l:list nat.∃n.∀m.n ≤ m → ¬ in_list ? m l);intros + [lapply (Hcut l);elim Hletin;apply ex_intro;autobatch + |elim l + [apply ex_intro[apply O];intros;unfold;intro;elim (not_in_list_nil ? ? H1) + |elim H;apply ex_intro[apply (S (max a1 a))]; + intros;unfold;intro; elim (in_list_cons_case ? ? ? ? H3) - [rewrite > H4 in H2.autobatch + [rewrite > H4 in H2;autobatch |elim H4 - [apply (H1 m ? H4).apply (trans_le ? (max a1 a));autobatch + [apply (H1 m ? H4);autobatch |assumption]]]] qed. (*** lemmata on well-formedness ***) -lemma fv_WFT : \forall T,x,G.(WFType G T) → x ∈ fv_type T → x ∈ fv_env G. +lemma fv_WFT : ∀T,x,G.WFType G T → in_list ? x (fv_type T) → + in_list ? x (fv_env G). intros 4.elim H [simplify in H2;elim (in_list_cons_case ? ? ? ? H2) - [rewrite > H3;assumption|elim (not_in_list_nil ? ? H3)] + [applyS H1|elim (not_in_list_nil ? ? H3)] |simplify in H1;elim (not_in_list_nil ? x H1) |simplify in H5;elim (in_list_append_to_or_in_list ? ? ? ? H5);autobatch |simplify in H5;elim (in_list_append_to_or_in_list ? ? ? ? H5) [apply (H2 H6) - |elim (fresh_name ((fv_type t1) @ (fv_env l))); - cut (¬ (a ∈ (fv_type t1)) ∧ ¬ (a ∈ (fv_env l))) + |elim (fresh_name (fv_type t1 @ fv_env l)); + cut (¬ in_list ? a (fv_type t1) ∧ ¬ in_list ? a (fv_env l)) [elim Hcut;lapply (H4 ? H9 H8) [cut (x ≠ a) [simplify in Hletin;elim (in_list_cons_case ? ? ? ? Hletin) [elim (Hcut1 H10) |assumption] |intro;apply H8;applyS H6] - |apply in_FV_subst;assumption] - |split - [intro;apply H7;apply in_list_to_in_list_append_l;assumption - |intro;apply H7;apply in_list_to_in_list_append_r;assumption]]]] + |autobatch] + |split;intro;apply H7;autobatch]]] qed. (*** lemmata relating subtyping and well-formedness ***) -lemma JS_to_WFE : \forall G,T,U.(G \vdash T ⊴ U) \to (WFEnv G). +lemma JS_to_WFE : ∀G,T,U.G ⊢ T ⊴ U → WFEnv G. intros;elim H;assumption. qed. -lemma JS_to_WFT : \forall G,T,U.(JSubtype G T U) \to ((WFType G T) \land - (WFType G U)). +lemma JS_to_WFT : ∀G,T,U.G ⊢ T ⊴ U → WFType G T ∧ WFType G U. intros;elim H - [split [assumption|apply WFT_Top] - |split;apply WFT_TFree;assumption + [1,2:autobatch |split - [apply WFT_TFree;apply boundinenv_natinfv;apply ex_intro - [apply true | apply ex_intro [apply t1 |assumption]] - |elim H3;assumption] - |elim H2;elim H4;split;apply WFT_Arrow;assumption + [apply WFT_TFree;(* FIXME! qui bastava autobatch, ma si e` rotto *) apply boundinenv_natinfv;autobatch + |elim H3;assumption] + |decompose;autobatch size=7 |elim H2;split [apply (WFT_Forall ? ? ? H6);intros;elim (H4 X H7); apply (WFT_env_incl ? ? H9);simplify;unfold;intros;assumption @@ -293,21 +256,21 @@ intros;elim H apply (WFT_env_incl ? ? H10);simplify;unfold;intros;assumption]] qed. -lemma JS_to_WFT1 : \forall G,T,U.(JSubtype G T U) \to (WFType G T). -intros;lapply (JS_to_WFT ? ? ? H);elim Hletin;assumption. +lemma JS_to_WFT1 : ∀G,T,U.G ⊢ T ⊴ U → WFType G T. +intros;elim (JS_to_WFT ? ? ? H);assumption; qed. -lemma JS_to_WFT2 : \forall G,T,U.(JSubtype G T U) \to (WFType G U). -intros;lapply (JS_to_WFT ? ? ? H);elim Hletin;assumption. +lemma JS_to_WFT2 : ∀G,T,U.G ⊢ T ⊴ U → WFType G U. +intros;elim (JS_to_WFT ? ? ? H);assumption; qed. -lemma WFE_Typ_subst : \forall H,x,B,C,T,U,G. - (WFEnv (H @ ((mk_bound B x T) :: G))) \to (WFType G U) \to - (WFEnv (H @ ((mk_bound C x U) :: G))). +lemma WFE_Typ_subst : ∀H,x,B,C,T,U,G. + WFEnv (H @ ((mk_bound B x T) :: G)) → WFType G U → + WFEnv (H @ ((mk_bound C x U) :: G)). intros 7;elim H 0 - [simplify;intros;(*FIXME*)generalize in match H1;intro;inversion H1;intros - [lapply (nil_cons ? G (mk_bound B x T));elim (Hletin H4) - |destruct H8;apply (WFE_cons ? ? ? ? H4 H6 H2)] + [simplify;intros;inversion H1;intros + [elim (nil_cons ? G (mk_bound B x T) H3) + |destruct H7;autobatch] |intros;simplify;generalize in match H2;elim a;simplify in H4; inversion H4;intros [destruct H5 @@ -319,27 +282,23 @@ intros 7;elim H 0 assumption]]] qed. -lemma WFE_bound_bound : \forall B,x,T,U,G. (WFEnv G) \to - (in_list ? (mk_bound B x T) G) \to - (in_list ? (mk_bound B x U) G) \to T = U. +lemma WFE_bound_bound : ∀B,x,T,U,G.WFEnv G → in_list ? (mk_bound B x T) G → + in_list ? (mk_bound B x U) G → T = U. intros 6;elim H [lapply (not_in_list_nil ? ? H1);elim Hletin |elim (in_list_cons_case ? ? ? ? H6) [destruct H7;destruct;elim (in_list_cons_case ? ? ? ? H5) [destruct H7;reflexivity - |elim H7;elim H3;apply boundinenv_natinfv;apply (ex_intro ? ? B); - apply (ex_intro ? ? T);assumption] + |elim H7;elim H3;apply boundinenv_natinfv;autobatch] |elim (in_list_cons_case ? ? ? ? H5) - [destruct H8;elim H3;apply boundinenv_natinfv;apply (ex_intro ? ? B); - apply (ex_intro ? ? U);assumption + [destruct H8;elim H3;apply boundinenv_natinfv;autobatch |apply (H2 H8 H7)]]] qed. -lemma WFT_to_incl: ∀G,T,U. - (∀X.(¬(X ∈ fv_env G)) → (¬(X ∈ fv_type U)) → - (WFType (mk_bound true X T::G) (subst_type_nat U (TFree X) O))) +lemma WFT_to_incl: ∀G,T,U.(∀X.¬in_list ? X (fv_env G) → ¬in_list ? X (fv_type U) → + WFType (mk_bound true X T::G) (subst_type_nat U (TFree X) O)) → incl ? (fv_type U) (fv_env G). -intros.elim (fresh_name ((fv_type U)@(fv_env G))).lapply(H a) +intros;elim (fresh_name (fv_type U@fv_env G));lapply(H a) [unfold;intros;lapply (fv_WFT ? x ? Hletin) [simplify in Hletin1;inversion Hletin1;intros [destruct H4;elim H1;autobatch @@ -354,26 +313,6 @@ lemma incl_fv_env: ∀X,G,G1,U,P. intros.rewrite < fv_env_extends.apply incl_A_A. qed. -lemma JSubtype_Top: ∀G,P.G ⊢ ⊤ ⊴ P → P = ⊤. -intros.inversion H;intros - [assumption|reflexivity - |destruct H5|*:destruct H6] -qed. - -(* -(* elim vs inversion *) -lemma JS_trans_TFree: ∀G,T,X.G ⊢ T ⊴ (TFree X) → - ∀U.G ⊢ (TFree X) ⊴ U → G ⊢ T ⊴ U. -intros 4.cut (∀Y.TFree Y = TFree X → ∀U.G ⊢ (TFree Y) ⊴ U → G ⊢ T ⊴ U) - [apply Hcut;reflexivity - |elim H;intros - [rewrite > H3 in H4;rewrite > (JSubtype_Top ? ? H4);apply SA_Top;assumption - |rewrite < H3;assumption - |apply (SA_Trans_TVar ? ? ? ? H1);apply (H3 Y);assumption - |*:destruct H5]] -qed. -*) - -lemma fv_append : ∀G,H.fv_env (G @ H) = (fv_env G @ fv_env H). +lemma fv_append : ∀G,H.fv_env (G @ H) = fv_env G @ fv_env H. intro;elim G;simplify;autobatch paramodulation; -qed. +qed. \ No newline at end of file diff --git a/helm/software/matita/contribs/POPLmark/Fsub/part1a.ma b/helm/software/matita/contribs/POPLmark/Fsub/part1a.ma index 4ae057be9..b113769dd 100644 --- a/helm/software/matita/contribs/POPLmark/Fsub/part1a.ma +++ b/helm/software/matita/contribs/POPLmark/Fsub/part1a.ma @@ -14,16 +14,13 @@ include "Fsub/defn.ma". +axiom daemon : False. + (*** Lemma A.1 (Reflexivity) ***) theorem JS_Refl : ∀T,G.WFType G T → WFEnv G → G ⊢ T ⊴ T. -intros 3.elim H - [apply SA_Refl_TVar [apply H2|assumption] - |apply SA_Top [assumption|apply WFT_Top] - |apply (SA_Arrow ? ? ? ? ? (H2 H5) (H4 H5)) - |apply (SA_All ? ? ? ? ? (H2 H5));intros;apply (H4 ? H6) - [intro;apply H6;apply (fv_WFT ? ? ? (WFT_Forall ? ? ? H1 H3)); - simplify;autobatch - |autobatch]] +intros 3; elim H; + [1,2,3: autobatch + | apply SA_All; [ autobatch | intros;autobatch depth=4 size=10]] qed. (* @@ -33,114 +30,59 @@ qed. *) lemma JS_weakening : ∀G,T,U.G ⊢ T ⊴ U → ∀H.WFEnv H → incl ? G H → H ⊢ T ⊴ U. -intros 4;elim H - [apply (SA_Top ? ? H4);apply (WFT_env_incl ? ? H2 ? (incl_bound_fv ? ? H5)) - |apply (SA_Refl_TVar ? ? H4);apply (incl_bound_fv ? ? H5 ? H2) - |apply (SA_Trans_TVar ? ? ? ? ? (H3 ? H5 H6));apply H6;assumption - |apply (SA_Arrow ? ? ? ? ? (H2 ? H6 H7) (H4 ? H6 H7)) - |apply (SA_All ? ? ? ? ? (H2 ? H6 H7));intros;apply H4 - [unfold;intro;apply H8;apply (incl_bound_fv ? ? H7 ? H9) - |apply (WFE_cons ? ? ? ? H6 H8);autobatch - |unfold;intros;inversion H9;intros - [destruct H11;apply in_list_head - |destruct H13;apply in_list_cons;apply (H7 ? H10)]]] +intros 4; elim H; + [1,2,3,4: autobatch depth=4 size=7 + | apply (SA_All ? ? ? ? ? (H2 ? H6 H7)); + intros; apply H4;autobatch depth=4 size=7] qed. +inverter JS_indinv for JSubtype (%?%). + theorem narrowing:∀X,G,G1,U,P,M,N. G1 ⊢ P ⊴ U → (∀G2,T.G2@G1 ⊢ U ⊴ T → G2@G1 ⊢ P ⊴ T) → G ⊢ M ⊴ N → ∀l.G=l@(mk_bound true X U::G1) → l@(mk_bound true X P::G1) ⊢ M ⊴ N. -intros 10.elim H2 - [letin x \def fv_env. letin y ≝incl. - (* autobatch depth=4 size=8 by SA_Top, WFE_Typ_subst, H3, JS_to_WFT1, H, H4, WFT_env_incl, incl_fv_env]*) - apply SA_Top - [autobatch by WFE_Typ_subst, H3, JS_to_WFT1, H. - (* - rewrite > H5 in H3; - apply (WFE_Typ_subst ? ? ? ? ? ? ? H3 (JS_to_WFT1 ? ? ? H)) *) - |autobatch by H4, WFT_env_incl, incl_fv_env] - (* rewrite > H5 in H4;apply (WFT_env_incl ? ? H4);apply incl_fv_env] *) - |autobatch depth=4 by SA_Refl_TVar, WFE_Typ_subst, H3, JS_to_WFT1, H, H4. - (* - apply SA_Refl_TVar; - [autobatch by WFE_Typ_subst, H3, JS_to_WFT1, H. - (* - rewrite > H5 in H3;apply (WFE_Typ_subst ? ? ? ? ? ? ? H3); - apply (JS_to_WFT1 ? ? ? H) *) - |autobatch by H4. (* rewrite > H5 in H4;rewrite < fv_env_extends;apply H4*)] *) - |elim (decidable_eq_nat X n) - [apply (SA_Trans_TVar ? ? ? P) - [rewrite < H7;elim l1;simplify - [constructor 1|constructor 2;assumption] - |applyS H1. - lapply (WFE_bound_bound true n t1 U ? ? H3); - [autobatch. (* apply (JS_to_WFE ? ? ? H4) *) - |autobatch. (* rewrite < Hletin;rewrite < append_cons;apply (H5 ? H6) *) - |destruct.elim l1;autobatch. - ]] - |(* autobatch depth=4 size=7 by SA_Trans_TVar, lookup_env_extends, H3, sym_neq, H5, H6, H7. *) - apply (SA_Trans_TVar ? ? ? t1); - [autobatch by lookup_env_extends, H3, sym_neq, H7. - (* rewrite > H6 in H3; apply (lookup_env_extends ? ? ? ? ? ? ? ? ? ? H3); - unfold;intro;apply H7;symmetry;assumption *) - |apply (H5 ? H6)]] - |autobatch; (* apply (SA_Arrow ? ? ? ? ? (H4 ? H7) (H6 ? H7)) *) - |apply (SA_All ? ? ? ? ? (H4 ? H7));intros;autobatch] - (* - apply (H6 ? ? (mk_bound true X1 t2::l1)) - [rewrite > H7;rewrite > fv_env_extends;apply H8 - |simplify;rewrite < H7;reflexivity]] *) +intros 10.elim H2; destruct; + [letin x \def fv_env. letin y ≝incl. autobatch depth=4 size=8. + | autobatch depth=4 size=7; + | elim (decidable_eq_nat X n) + [apply (SA_Trans_TVar ? ? ? P); destruct; + [ autobatch + | lapply (WFE_bound_bound true X t1 U ? ? H3); autobatch] + | apply (SA_Trans_TVar ? ? ? t1); autobatch] + | autobatch + | apply SA_All; + [ autobatch + | intros; apply (H6 ? ? (mk_bound true X1 t2::l1)); autobatch]] qed. lemma JS_trans_prova: ∀T,G1.WFType G1 T → ∀G,R,U.incl ? (fv_env G1) (fv_env G) → G ⊢ R ⊴ T → G ⊢ T ⊴ U → G ⊢ R ⊴ U. -intros 3;elim H;clear H; try autobatch; - [ - rewrite > (JSubtype_Top ? ? H3);autobatch - |generalize in match H7;generalize in match H4;generalize in match H2; - generalize in match H5;clear H7 H4 H2 H5; - generalize in match (refl_eq ? (Arrow t t1)); - elim H6 in ⊢ (? ? ? %→%); clear H6; intros; destruct; - [apply (SA_Trans_TVar ? ? ? ? H);apply (H4 ? ? H8 H9);autobatch - |inversion H11;intros; destruct; autobatch depth=4 width=4 size=9; - ] - |generalize in match H7;generalize in match H4;generalize in match H2; - generalize in match H5;clear H7 H4 H2 H5; - generalize in match (refl_eq ? (Forall t t1));elim H6 in ⊢ (? ? ? %→%);destruct; - [apply (SA_Trans_TVar ? ? ? ? H);apply (H4 ? H7 H8 H9 H10);reflexivity - |inversion H11;intros;destruct; - [apply SA_Top - [autobatch - |apply WFT_Forall - [autobatch - |intros;lapply (H4 ? H13);autobatch]] - |apply SA_All - [autobatch paramodulation - |intros;apply (H10 X) - [intro;apply H15;apply H8;assumption - |intro;apply H15;apply H8;apply (WFT_to_incl ? ? ? H3); - assumption - |simplify;autobatch - |apply (narrowing X (mk_bound true X t::l1) - ? ? ? ? ? H7 ? ? []) - [intros;apply H9 - [unfold;intros;lapply (H8 ? H17);rewrite > fv_append; - autobatch - |apply (JS_weakening ? ? ? H7) - [autobatch - |unfold;intros;autobatch] - |assumption] - |*:autobatch] - |autobatch]]]]] +intros 3;elim H;clear H; + [elim H3 using JS_indinv;destruct;autobatch + |inversion H3; intros; destruct; assumption + |*: elim H6 using JS_indinv;destruct; + [1,3: autobatch + |*: inversion H7; intros; destruct; + [1,2: autobatch depth=4 width=4 size=9 + | apply SA_Top + [ assumption + | apply WFT_Forall;intros;autobatch depth=4] + | apply SA_All + [ autobatch + | intros;apply (H4 X);simplify; + [4: apply (narrowing X (mk_bound true X t::G) ? ? ? ? ? H11 ? ? []) + [intros;apply H2;try unfold;intros;autobatch; + |*:autobatch] + |*:autobatch]]]]] qed. theorem JS_trans : ∀G,T,U,V.G ⊢ T ⊴ U → G ⊢ U ⊴ V → G ⊢ T ⊴ V. -intros 5;apply (JS_trans_prova ? G);autobatch; +intros 5; apply (JS_trans_prova ? G); autobatch depth=2. qed. theorem JS_narrow : ∀G1,G2,X,P,Q,T,U. (G2 @ (mk_bound true X Q :: G1)) ⊢ T ⊴ U → G1 ⊢ P ⊴ Q → (G2 @ (mk_bound true X P :: G1)) ⊢ T ⊴ U. intros;apply (narrowing ? ? ? ? ? ? ? H1 ? H) [|autobatch] -intros;apply (JS_trans ? ? ? ? ? H2);apply (JS_weakening ? ? ? H1); - [autobatch|unfold;intros;autobatch] +intros;apply (JS_trans ? ? ? ? ? H2);apply (JS_weakening ? ? ? H1);autobatch. qed.