24 type_intros Val_ValEnv.intros |
24 type_intros Val_ValEnv.intros |
25 |
25 |
26 (* Pointwise extension to environments *) |
26 (* Pointwise extension to environments *) |
27 |
27 |
28 definition |
28 definition |
29 hastyenv :: "[i,i] => o" where |
29 hastyenv :: "[i,i] \<Rightarrow> o" where |
30 "hastyenv(ve,te) \<equiv> |
30 "hastyenv(ve,te) \<equiv> |
31 ve_dom(ve) = te_dom(te) \<and> |
31 ve_dom(ve) = te_dom(te) \<and> |
32 (\<forall>x \<in> ve_dom(ve). <ve_app(ve,x),te_app(te,x)> \<in> HasTyRel)" |
32 (\<forall>x \<in> ve_dom(ve). <ve_app(ve,x),te_app(te,x)> \<in> HasTyRel)" |
33 |
33 |
34 (* Specialised co-induction rule *) |
34 (* Specialised co-induction rule *) |
53 |
53 |
54 lemmas HasTyRel_non_zero = |
54 lemmas HasTyRel_non_zero = |
55 HasTyRel.dom_subset [THEN subsetD, THEN SigmaD1, THEN ValNEE] |
55 HasTyRel.dom_subset [THEN subsetD, THEN SigmaD1, THEN ValNEE] |
56 |
56 |
57 lemma hastyenv_owr: |
57 lemma hastyenv_owr: |
58 "\<lbrakk>ve \<in> ValEnv; te \<in> TyEnv; hastyenv(ve,te); <v,t> \<in> HasTyRel\<rbrakk> |
58 "\<lbrakk>ve \<in> ValEnv; te \<in> TyEnv; hastyenv(ve,te); \<langle>v,t\<rangle> \<in> HasTyRel\<rbrakk> |
59 \<Longrightarrow> hastyenv(ve_owr(ve,x,v),te_owr(te,x,t))" |
59 \<Longrightarrow> hastyenv(ve_owr(ve,x,v),te_owr(te,x,t))" |
60 by (auto simp add: hastyenv_def ve_app_owr HasTyRel_non_zero) |
60 by (auto simp add: hastyenv_def ve_app_owr HasTyRel_non_zero) |
61 |
61 |
62 lemma basic_consistency_lem: |
62 lemma basic_consistency_lem: |
63 "\<lbrakk>ve \<in> ValEnv; te \<in> TyEnv; isofenv(ve,te)\<rbrakk> \<Longrightarrow> hastyenv(ve,te)" |
63 "\<lbrakk>ve \<in> ValEnv; te \<in> TyEnv; isofenv(ve,te)\<rbrakk> \<Longrightarrow> hastyenv(ve,te)" |
95 |
95 |
96 lemma consistency_fix: |
96 lemma consistency_fix: |
97 "\<lbrakk>ve \<in> ValEnv; x \<in> ExVar; e \<in> Exp; f \<in> ExVar; cl \<in> Val; |
97 "\<lbrakk>ve \<in> ValEnv; x \<in> ExVar; e \<in> Exp; f \<in> ExVar; cl \<in> Val; |
98 v_clos(x,e,ve_owr(ve,f,cl)) = cl; |
98 v_clos(x,e,ve_owr(ve,f,cl)) = cl; |
99 hastyenv(ve,te); <te,e_fix(f,x,e),t> \<in> ElabRel\<rbrakk> \<Longrightarrow> |
99 hastyenv(ve,te); <te,e_fix(f,x,e),t> \<in> ElabRel\<rbrakk> \<Longrightarrow> |
100 <cl,t> \<in> HasTyRel" |
100 \<langle>cl,t\<rangle> \<in> HasTyRel" |
101 apply (unfold hastyenv_def) |
101 apply (unfold hastyenv_def) |
102 apply (erule elab_fixE, safe) |
102 apply (erule elab_fixE, safe) |
103 apply hypsubst_thin |
103 apply hypsubst_thin |
104 apply (rule subst, assumption) |
104 apply (rule subst, assumption) |
105 apply (rule_tac te="te_owr(te, f, t_fun(t1, t2))" in htr_closCI) |
105 apply (rule_tac te="te_owr(te, f, t_fun(t1, t2))" in htr_closCI) |
128 v \<in> Val; |
128 v \<in> Val; |
129 <ve,e1,v_clos(xm,em,vem)> \<in> EvalRel; |
129 <ve,e1,v_clos(xm,em,vem)> \<in> EvalRel; |
130 \<forall>t te. hastyenv(ve,te) \<longrightarrow> |
130 \<forall>t te. hastyenv(ve,te) \<longrightarrow> |
131 <te,e1,t> \<in> ElabRel \<longrightarrow> <v_clos(xm,em,vem),t> \<in> HasTyRel; |
131 <te,e1,t> \<in> ElabRel \<longrightarrow> <v_clos(xm,em,vem),t> \<in> HasTyRel; |
132 <ve,e2,v2> \<in> EvalRel; |
132 <ve,e2,v2> \<in> EvalRel; |
133 \<forall>t te. hastyenv(ve,te) \<longrightarrow> <te,e2,t> \<in> ElabRel \<longrightarrow> <v2,t> \<in> HasTyRel; |
133 \<forall>t te. hastyenv(ve,te) \<longrightarrow> <te,e2,t> \<in> ElabRel \<longrightarrow> \<langle>v2,t\<rangle> \<in> HasTyRel; |
134 <ve_owr(vem,xm,v2),em,v> \<in> EvalRel; |
134 <ve_owr(vem,xm,v2),em,v> \<in> EvalRel; |
135 \<forall>t te. hastyenv(ve_owr(vem,xm,v2),te) \<longrightarrow> |
135 \<forall>t te. hastyenv(ve_owr(vem,xm,v2),te) \<longrightarrow> |
136 <te,em,t> \<in> ElabRel \<longrightarrow> <v,t> \<in> HasTyRel; |
136 <te,em,t> \<in> ElabRel \<longrightarrow> \<langle>v,t\<rangle> \<in> HasTyRel; |
137 hastyenv(ve,te); <te,e_app(e1,e2),t> \<in> ElabRel\<rbrakk> |
137 hastyenv(ve,te); <te,e_app(e1,e2),t> \<in> ElabRel\<rbrakk> |
138 \<Longrightarrow> <v,t> \<in> HasTyRel" |
138 \<Longrightarrow> \<langle>v,t\<rangle> \<in> HasTyRel" |
139 apply (erule elab_appE) |
139 apply (erule elab_appE) |
140 apply (drule spec [THEN spec, THEN mp, THEN mp], assumption+) |
140 apply (drule spec [THEN spec, THEN mp, THEN mp], assumption+) |
141 apply (drule spec [THEN spec, THEN mp, THEN mp], assumption+) |
141 apply (drule spec [THEN spec, THEN mp, THEN mp], assumption+) |
142 apply (erule htr_closE) |
142 apply (erule htr_closE) |
143 apply (erule elab_fnE, simp) |
143 apply (erule elab_fnE, simp) |
149 apply (simp add: hastyenv_def, blast+) |
149 apply (simp add: hastyenv_def, blast+) |
150 done |
150 done |
151 |
151 |
152 lemma consistency [rule_format]: |
152 lemma consistency [rule_format]: |
153 "<ve,e,v> \<in> EvalRel |
153 "<ve,e,v> \<in> EvalRel |
154 \<Longrightarrow> (\<forall>t te. hastyenv(ve,te) \<longrightarrow> <te,e,t> \<in> ElabRel \<longrightarrow> <v,t> \<in> HasTyRel)" |
154 \<Longrightarrow> (\<forall>t te. hastyenv(ve,te) \<longrightarrow> <te,e,t> \<in> ElabRel \<longrightarrow> \<langle>v,t\<rangle> \<in> HasTyRel)" |
155 apply (erule EvalRel.induct) |
155 apply (erule EvalRel.induct) |
156 apply (simp_all add: consistency_const consistency_var consistency_fn |
156 apply (simp_all add: consistency_const consistency_var consistency_fn |
157 consistency_fix consistency_app1) |
157 consistency_fix consistency_app1) |
158 apply (blast intro: consistency_app2) |
158 apply (blast intro: consistency_app2) |
159 done |
159 done |