1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "Fsub/defn2.ma".
17 (*** Lemma A.1 (Reflexivity) ***)
18 theorem JS_Refl : ∀T,G.WFType G T → WFEnv G → G ⊢ T ⊴ T.
21 | apply SA_All; [ autobatch | intros; autobatch depth=4 size=10]
26 * A slightly more general variant to lemma A.2.2, where weakening isn't
27 * defined as concatenation of any two disjoint environments, but as
31 lemma JS_weakening : ∀G,T,U.G ⊢ T ⊴ U → ∀H.WFEnv H → incl ? G H → H ⊢ T ⊴ U.
33 [1,2,3,4: autobatch depth=4 size=7
34 | apply (SA_All ? ? ? ? ? (H2 ? H6 H7));
35 intros; apply H4; autobatch depth=4 size=7]
39 ∀G:list bound.∀T1,T:Typ.
40 ∀P:list bound → Typ → Typ → Prop.
41 (∀t. WFEnv G → WFType G t → T=Top → P G t Top) →
42 (∀n. WFEnv G → n ∈ fv_env G → T=TFree n → P G (TFree n) (TFree n)) →
44 (mk_bound true n t1) ∈ G → G ⊢ t1 ⊴ t → P G t1 t → T=t → P G (TFree n) T) →
45 (∀s1,s2,t1,t2. G ⊢ t1 ⊴ s1 → G ⊢ s2 ⊴ t2 → T=Arrow t1 t2 → P G (Arrow s1 s2) (Arrow t1 t2)) →
46 (∀s1,s2,t1,t2. G ⊢ t1 ⊴ s1 →
47 (∀X. ¬(X ∈ fv_env G) → (mk_bound true X t1)::G ⊢ subst_type_nat s2 (TFree X) O ⊴ subst_type_nat t2 (TFree X) O)
48 → T=Forall t1 t2 → P G (Forall s1 s2) (Forall t1 t2)) →
49 G ⊢ T1 ⊴ T → P G T1 T.
51 generalize in match (refl_eq ? T);
52 generalize in match (refl_eq ? G);
53 elim H5 in ⊢ (? ? ? % → ? ? ? % → %); destruct; autobatch depth=3 width=4 size=7;
56 theorem narrowing:∀X,G,G1,U,P,M,N.
57 G1 ⊢ P ⊴ U → (∀G2,T.G2@G1 ⊢ U ⊴ T → G2@G1 ⊢ P ⊴ T) → G ⊢ M ⊴ N →
58 ∀l.G=l@(mk_bound true X U::G1) → l@(mk_bound true X P::G1) ⊢ M ⊴ N.
59 intros 10.elim H2; destruct;
60 [letin x \def fv_env. letin y ≝incl. autobatch depth=4 size=8.
61 | autobatch depth=4 size=7;
62 | elim (decidable_eq_nat X n)
63 [apply (SA_Trans_TVar ? ? ? P); destruct;
65 | rewrite > append_cons; apply H1;
66 lapply (WFE_bound_bound true X t1 U ? ? H3); destruct;autobatch]
67 | apply (SA_Trans_TVar ? ? ? t1); autobatch]
71 | intros; apply (H6 ? ? (mk_bound true X1 t2::l1));autobatch]]
74 lemma JS_trans_prova: ∀T,G1.WFType G1 T →
75 ∀G,R,U.incl ? (fv_env G1) (fv_env G) → G ⊢ R ⊴ T → G ⊢ T ⊴ U → G ⊢ R ⊴ U.
76 intros 3;elim H;clear H; try autobatch;
77 [ apply (JSubtype_inv ? ? ? ? ? ? ? ? ? H3); intros; destruct; autobatch
78 | inversion H3; intros; destruct; assumption
79 |*: apply (JSubtype_inv ? ? ? ? ? ? ? ? ? H6); intros; destruct;
81 |*: inversion H7; intros; destruct;
82 [1,2: autobatch depth=4 width=4 size=9
87 | intros;autobatch depth =4]]
90 | intros;apply (H4 X);
92 |intro; autobatch depth=4.
94 |apply (narrowing X (mk_bound true X t::G) ? ? ? ? ? H9 ? ? [])
96 [unfold;intros;lapply (H5 ? H15);rewrite > fv_append;autobatch
103 theorem JS_trans : ∀G,T,U,V.G ⊢ T ⊴ U → G ⊢ U ⊴ V → G ⊢ T ⊴ V.
104 intros 5; apply (JS_trans_prova ? G); autobatch depth=2.
107 theorem JS_narrow : ∀G1,G2,X,P,Q,T,U.
108 (G2 @ (mk_bound true X Q :: G1)) ⊢ T ⊴ U → G1 ⊢ P ⊴ Q →
109 (G2 @ (mk_bound true X P :: G1)) ⊢ T ⊴ U.
110 intros;apply (narrowing ? ? ? ? ? ? ? H1 ? H) [|autobatch]
111 intros;apply (JS_trans ? ? ? ? ? H2);apply (JS_weakening ? ? ? H1);autobatch.