diff -r 733bac87d5bf -r 032649a694d2 Nominal/ExCoreHaskell.thy --- a/Nominal/ExCoreHaskell.thy Thu Mar 25 12:04:38 2010 +0100 +++ b/Nominal/ExCoreHaskell.thy Thu Mar 25 14:24:06 2010 +0100 @@ -91,30 +91,112 @@ lemmas eq_iff=tkind_ckind_ty_ty_lst_co_co_lst_trm_assoc_lst_pat_vt_lst_tvtk_lst_tvck_lst.eq_iff lemmas inducts=tkind_ckind_ty_ty_lst_co_co_lst_trm_assoc_lst_pat_vt_lst_tvtk_lst_tvck_lst.inducts +lemmas alpha_inducts=alpha_tkind_raw_alpha_ckind_raw_alpha_ty_raw_alpha_ty_lst_raw_alpha_co_raw_alpha_co_lst_raw_alpha_trm_raw_alpha_assoc_lst_raw_alpha_pat_raw_alpha_vt_lst_raw_alpha_tvtk_lst_raw_alpha_tvck_lst_raw_alpha_bv_raw_alpha_bv_vt_raw_alpha_bv_tvtk_raw_alpha_bv_tvck_raw.inducts +lemmas alpha_intros=alpha_tkind_raw_alpha_ckind_raw_alpha_ty_raw_alpha_ty_lst_raw_alpha_co_raw_alpha_co_lst_raw_alpha_trm_raw_alpha_assoc_lst_raw_alpha_pat_raw_alpha_vt_lst_raw_alpha_tvtk_lst_raw_alpha_tvck_lst_raw_alpha_bv_raw_alpha_bv_vt_raw_alpha_bv_tvtk_raw_alpha_bv_tvck_raw.intros + lemma fresh_star_minus_perm: "as \* - p = as \* (p :: perm)" unfolding fresh_star_def Ball_def by auto (simp_all add: fresh_minus_perm) -(*primrec - permute_bv_raw -where - "permute_bv_raw p (K c l1 l2 l3) = K c (permute_.. l1) ... +primrec permute_bv_vt_raw +where "permute_bv_vt_raw p VTNil_raw = VTNil_raw" +| "permute_bv_vt_raw p (VTCons_raw v t l) = VTCons_raw (p \ v) t (permute_bv_vt_raw p l)" +primrec permute_bv_tvck_raw +where "permute_bv_tvck_raw p TVCKNil_raw = TVCKNil_raw" +| "permute_bv_tvck_raw p (TVCKCons_raw v t l) = TVCKCons_raw (p \ v) t (permute_bv_tvck_raw p l)" +primrec permute_bv_tvtk_raw +where "permute_bv_tvtk_raw p TVTKNil_raw = TVTKNil_raw" +| "permute_bv_tvtk_raw p (TVTKCons_raw v t l) = TVTKCons_raw (p \ v) t (permute_bv_tvtk_raw p l)" +primrec permute_bv_raw +where "permute_bv_raw p (K_raw c l1 l2 l3) = + K_raw c (permute_bv_tvtk_raw p l1) (permute_bv_tvck_raw p l2) (permute_bv_vt_raw p l3)" + +quotient_definition "permute_bv_vt :: perm \ vt_lst \ vt_lst" +is "permute_bv_vt_raw" +quotient_definition "permute_bv_tvck :: perm \ tvck_lst \ tvck_lst" +is "permute_bv_tvck_raw" +quotient_definition "permute_bv_tvtk :: perm \ tvtk_lst \ tvtk_lst" +is "permute_bv_tvtk_raw" +quotient_definition "permute_bv :: perm \ pat \ pat" +is "permute_bv_raw" + +lemma rsp_pre: + "alpha_tvtk_lst_raw d a \ alpha_tvtk_lst_raw (permute_bv_tvtk_raw x d) (permute_bv_tvtk_raw x a)" + "alpha_tvck_lst_raw e b \ alpha_tvck_lst_raw (permute_bv_tvck_raw x e) (permute_bv_tvck_raw x b)" + "alpha_vt_lst_raw f c \ alpha_vt_lst_raw (permute_bv_vt_raw x f) (permute_bv_vt_raw x c)" + apply (erule_tac [!] alpha_inducts) + apply simp_all + apply (rule_tac [!] alpha_intros) + apply simp_all + done -(permute_bv p (K (q \ char) (q \ tvtk_lst) (q \ tvck_lst) (q \ vt_lst) -*) +lemma [quot_respect]: + "(op = ===> alpha_pat_raw ===> alpha_pat_raw) permute_bv_raw permute_bv_raw" + "(op = ===> alpha_tvtk_lst_raw ===> alpha_tvtk_lst_raw) permute_bv_tvtk_raw permute_bv_tvtk_raw" + "(op = ===> alpha_tvck_lst_raw ===> alpha_tvck_lst_raw) permute_bv_tvck_raw permute_bv_tvck_raw" + "(op = ===> alpha_vt_lst_raw ===> alpha_vt_lst_raw) permute_bv_vt_raw permute_bv_vt_raw" + apply (simp_all add: rsp_pre) + apply clarify + apply (erule_tac alpha_inducts) + apply (simp_all) + apply (rule alpha_intros) + apply (simp_all add: rsp_pre) + done + +lemmas permute_bv[simp] = permute_bv_raw.simps[quot_lifted] + permute_bv_vt_raw.simps[quot_lifted] + permute_bv_tvck_raw.simps[quot_lifted] + permute_bv_tvtk_raw.simps[quot_lifted] -consts - permute_bv :: "perm \ pat \ pat" +lemma perm_bv1: + "p \ bv_tvck b = bv_tvck (permute_bv_tvck p b)" + "p \ bv_tvtk c = bv_tvtk (permute_bv_tvtk p c)" + "p \ bv_vt d = bv_vt (permute_bv_vt p d)" + apply(induct b rule: inducts(12)) + apply(rule TrueI) + apply(simp_all add:permute_bv eqvts) + apply(induct c rule: inducts(11)) + apply(rule TrueI) + apply(simp_all add:permute_bv eqvts) + apply(induct d rule: inducts(10)) + apply(rule TrueI) + apply(simp_all add:permute_bv eqvts) + done + +lemma perm_bv2: + "p \ bv l = bv (permute_bv p l)" + apply(induct l rule: inducts(9)) + apply(rule TrueI) + apply(simp_all add:permute_bv) + apply(simp add: perm_bv1[symmetric]) + apply(simp add: eqvts) + done lemma ACons_subst: "supp (Abs (bv pat) trm) \* q \ (ACons pat trm al) = ACons (permute_bv q pat) (q \ trm) al" sorry -lemma perm_bv: - "p \ bv l = bv (permute_bv p l)" - sorry +lemma permute_bv_zero1: + "permute_bv_tvck 0 b = b" + "permute_bv_tvtk 0 c = c" + "permute_bv_vt 0 d = d" + apply(induct b rule: inducts(12)) + apply(rule TrueI) + apply(simp_all add:permute_bv eqvts) + apply(induct c rule: inducts(11)) + apply(rule TrueI) + apply(simp_all add:permute_bv eqvts) + apply(induct d rule: inducts(10)) + apply(rule TrueI) + apply(simp_all add:permute_bv eqvts) + done - +lemma permute_bv_zero2: + "permute_bv 0 a = a" + apply(induct a rule: inducts(9)) + apply(rule TrueI) + apply(simp_all add:permute_bv eqvts permute_bv_zero1) + done lemma fv_alpha1: "fv_bv_tvtk x \* pa \ alpha_bv_tvtk (pa \ x) x" apply (induct x rule: inducts(11)) @@ -270,8 +352,8 @@ P11 (k :: 'k :: pt) tvtk_lst \ P12 (l :: 'l :: pt) tvck_lst" proof - - have a: "(\p a. P1 a (p \ tkind)) \ (\p b. P2 b (p \ ckind)) \ (\p c. P3 c (p \ ty)) \ (\p d. P4 d (p \ ty_lst)) \ (\p e. P5 e (p \ co)) \ (\p f. P6 f (p \ co_lst)) \ (\p g. P7 g (p \ trm)) \ (\p h. P8 h (p \ assoc_lst)) \ (\p q i. P9 i (permute_bv p (q \ pat))) \ (\p j. P10 j (p \ vt_lst)) \ (\p k. P11 k (p \ tvtk_lst)) \ (\p l. P12 l (p \ tvck_lst))" - apply (rule tkind_ckind_ty_ty_lst_co_co_lst_trm_assoc_lst_pat_vt_lst_tvtk_lst_tvck_lst.induct) + have a1: "(\p a. P1 a (p \ tkind))" and "(\p b. P2 b (p \ ckind))" and "(\p c. P3 c (p \ ty))" and "(\p d. P4 d (p \ ty_lst))" and "(\p e. P5 e (p \ co))" and " (\p f. P6 f (p \ co_lst))" and "(\p g. P7 g (p \ trm))" and "(\p h. P8 h (p \ assoc_lst))" and a1:"(\p q i. P9 i (permute_bv p (q \ pat)))" and a2:"(\p q j. P10 j (permute_bv_vt q (p \ vt_lst)))" and a3:"(\p q k. P11 k ( permute_bv_tvtk q (p \ tvtk_lst)))" and a4:"(\p q l. P12 l (permute_bv_tvck q (p \ tvck_lst)))" + apply (induct rule: tkind_ckind_ty_ty_lst_co_co_lst_trm_assoc_lst_pat_vt_lst_tvtk_lst_tvck_lst.inducts) apply (tactic {* ALLGOALS (REPEAT o rtac allI) *}) apply (tactic {* ALLGOALS (TRY o SOLVED' (simp_tac @{simpset} THEN_ALL_NEW resolve_tac @{thms assms} THEN_ALL_NEW asm_full_simp_tac @{simpset})) *}) @@ -532,7 +614,7 @@ apply(erule_tac x="(pa + p)" in allE) apply simp apply simp - apply (simp add: perm_bv[symmetric]) + apply (simp add: perm_bv2[symmetric]) apply (simp add: eqvts eqvts_raw) apply (rule at_set_avoiding2) apply (simp add: fin_bv) @@ -541,16 +623,10 @@ apply (rule finite_Diff) apply (simp add: finite_supp) apply (simp add: fresh_star_def fresh_def supp_Abs eqvts) -(* Goal for K *) - apply (simp) - sorry - have g1: "P1 a (0 \ tkind)" using a[THEN conjunct1] by blast - have g2: "P2 b (0 \ ckind)" using a[THEN conjunct2,THEN conjunct1] by blast - have g3: "P3 c (0 \ ty) \ - P4 d (0 \ ty_lst) \ P5 e (0 \ co) \ P6 f (0 \ co_lst) \ - P7 g (0 \ trm) \ P8 h (0 \ assoc_lst) \ P9 i (0 \ pat) \ - P10 j (0 \ vt_lst) \ P11 k (0 \ tvtk_lst) \ P12 l (0 \ tvck_lst)" using a by blast - show ?thesis using g1 g2 g3 by simp + done + then have b: "P1 a (0 \ tkind)" and "P2 b (0 \ ckind)" "P3 c (0 \ ty)" and "P4 d (0 \ ty_lst)" and "P5 e (0 \ co)" and "P6 f (0 \ co_lst)" and "P7 g (0 \ trm)" and "P8 h (0 \ assoc_lst)" by (blast+) + moreover have "P9 i (permute_bv 0 (0 \ pat))" and "P10 j (permute_bv_vt 0 (0 \ vt_lst))" and "P11 k (permute_bv_tvtk 0 (0 \ tvtk_lst))" and "P12 l (permute_bv_tvck 0 (0 \ tvck_lst))" using a1 a2 a3 a4 by (blast+) + ultimately show ?thesis by (simp_all add: permute_bv_zero1 permute_bv_zero2) qed end