Nominal/Ex/SingleLet.thy
author Christian Urban <urbanc@in.tum.de>
Sun, 08 Aug 2010 10:12:38 +0800
changeset 2392 9294d7cec5e2
parent 2389 0f24c961b5f6
child 2393 d9a0cf26a88c
permissions -rw-r--r--
proved rsp-helper lemmas of size functions

theory SingleLet
imports "../NewParser"
begin

atom_decl name

declare [[STEPS = 17]]

nominal_datatype trm  =
  Var "name"
| App "trm" "trm"
| Lam x::"name" t::"trm"  bind_set x in t
| Let a::"assg" t::"trm"  bind_set "bn a" in t
| Foo x::"name" y::"name" t::"trm" t1::"trm" t2::"trm" bind_set x in y t t1 t2
| Bar x::"name" y::"name" t::"trm" bind y x in t x y
| Baz x::"name" t1::"trm" t2::"trm" bind x in t1, bind x in t2 
and assg =
  As "name" x::"name" t::"trm" bind x in t
binder
  bn::"assg \<Rightarrow> atom set"
where
  "bn (As x y t) = {atom x}"

thm alpha_sym_thms
thm alpha_trans_thms
thm size_eqvt
thm size_simps
thm size_rsp
thm alpha_bn_imps
thm distinct
thm eq_iff
thm eq_iff_simps
thm fv_defs
thm perm_simps
thm perm_laws
thm funs_rsp


typ trm
typ assg
term Var 
term App
term Baz
term bn
term fv_trm
term alpha_bn

lemma exi_zero: "P 0 \<Longrightarrow> \<exists>(x::perm). P x" by auto

ML {* 
  val pre_ss = @{thms fun_rel_def}
  val post_ss = @{thms alphas prod_alpha_def prod_rel.simps 
    prod_fv.simps fresh_star_zero permute_zero funs_rsp prod.cases alpha_bn_imps}

  val tac = 
    asm_full_simp_tac (HOL_ss addsimps pre_ss)
    THEN' REPEAT o (resolve_tac @{thms allI impI})
    THEN' resolve_tac @{thms alpha_trm_raw_alpha_assg_raw_alpha_bn_raw.intros} 
    THEN_ALL_NEW (TRY o (rtac @{thm exi_zero}) THEN' asm_full_simp_tac (HOL_ss addsimps post_ss))
*}

lemma [quot_respect]: 
  "(op= ===> alpha_trm_raw) Var_raw Var_raw"
  "(alpha_trm_raw ===> alpha_trm_raw ===> alpha_trm_raw) App_raw App_raw"
  "(op= ===> alpha_trm_raw ===> alpha_trm_raw) Lam_raw Lam_raw"
  "(alpha_assg_raw ===> alpha_trm_raw ===> alpha_trm_raw) Let_raw Let_raw"
  "(op= ===> op= ===> alpha_trm_raw ===> alpha_trm_raw ===> alpha_trm_raw ===> alpha_trm_raw)
     Foo_raw Foo_raw"
  "(op= ===> op= ===> alpha_trm_raw ===> alpha_trm_raw) Bar_raw Bar_raw"
  "(op= ===> alpha_trm_raw ===> alpha_trm_raw ===> alpha_trm_raw) Baz_raw Baz_raw"
  "(op = ===> op = ===> alpha_trm_raw ===> alpha_assg_raw) As_raw As_raw"
apply(tactic {* ALLGOALS tac *})
done

lemma [quot_respect]:
  "(alpha_trm_raw ===> op =) fv_trm_raw fv_trm_raw"
  "(alpha_assg_raw ===> op =) fv_bn_raw fv_bn_raw"
  "(alpha_assg_raw ===> op =) bn_raw bn_raw"
  "(alpha_assg_raw ===> op =) fv_assg_raw fv_assg_raw"
  "(op = ===> alpha_trm_raw ===> alpha_trm_raw) permute permute"
  "(alpha_trm_raw ===> op =) size size"
apply(simp_all add: alpha_bn_imps funs_rsp size_rsp)
sorry

ML {*
  val thms_d = map (lift_thm [@{typ trm}, @{typ assg}] @{context}) @{thms distinct}
*}

ML {* 
  val thms_i = map (lift_thm [@{typ trm}, @{typ assg}] @{context}) @{thms trm_raw_assg_raw.inducts}
*}

ML {*
  val thms_f = map (lift_thm [@{typ trm}, @{typ assg}] @{context}) @{thms fv_defs}
*}

thm perm_defs[no_vars]

instance trm :: pt sorry
instance assg :: pt sorry

lemma b1:
  "p \<bullet> Var name = Var (p \<bullet> name)"
  "p \<bullet> App trm1 trm2 = App (p \<bullet> trm1) (p \<bullet> trm2)"
  "p \<bullet> Lam name trm = Lam (p \<bullet> name) (p \<bullet> trm)"
  "p \<bullet> Let assg trm = Let (p \<bullet> assg) (p \<bullet> trm)"
  "p \<bullet> Foo name1 name2 trm1 trm2 trm3 =
     Foo (p \<bullet> name1) (p \<bullet> name2) (p \<bullet> trm1) (p \<bullet> trm2) (p \<bullet> trm3)"
  "p \<bullet> Bar name1 name2 trm = Bar (p \<bullet> name1) (p \<bullet> name2) (p \<bullet> trm)"
  "p \<bullet> Baz name trm1 trm2 = Baz (p \<bullet> name) (p \<bullet> trm1) (p \<bullet> trm2)"
  "p \<bullet> As name1 name2 trm = As (p \<bullet> name1) (p \<bullet> name2) (p \<bullet> trm)"
sorry


(*
ML {*
  val thms_p = map (lift_thm [@{typ trm}, @{typ assg}] @{context}) @{thms perm_defs}
*}
*)

thm eq_iff[no_vars]

ML {*
  val q1 = lift_thm [@{typ trm}, @{typ assg}] @{context} @{thm "eq_iff"(1)}
*}

local_setup {* Local_Theory.note ((@{binding d1}, []), thms_d) #> snd *}
local_setup {* Local_Theory.note ((@{binding i1}, []), thms_i) #> snd *}
local_setup {* Local_Theory.note ((@{binding f1}, []), thms_f) #> snd *}
local_setup {* Local_Theory.note ((@{binding q1}, []), [q1]) #> snd *}


thm perm_defs
thm perm_simps

lemma supp_fv:
  "supp t = fv_trm t"
  "supp b = fv_bn b"
apply(induct t and b rule: i1)
apply(simp_all add: f1)
apply(simp_all add: supp_def)
apply(simp_all add: b1)
sorry

consts perm_bn_trm :: "perm \<Rightarrow> trm \<Rightarrow> trm"
consts perm_bn_assg :: "perm \<Rightarrow> assg \<Rightarrow> assg"

lemma y:
  "perm_bn_trm p (Var x) = (Var x)"
  "perm_bn_trm p (App t1 t2) = (App t1 t2)"
  "perm_bn_trm p ("



ML {*
  map (lift_thm [@{typ trm}, @{typ assg}] @{context}) @{thms eq_iff}
*}





lemma "Var x \<noteq> App y1 y2"
apply(descending)
apply(simp add: trm_raw.distinct)



ML {*
  map (lift_thm [@{typ trm}, @{typ assg}] @{context}) @{thms trm_raw.distinct(1)}
*}




typ trm
typ assg

thm trm_assg.fv
thm trm_assg.supp
thm trm_assg.eq_iff
thm trm_assg.bn
thm trm_assg.perm
thm trm_assg.induct
thm trm_assg.inducts
thm trm_assg.distinct
ML {* Sign.of_sort @{theory} (@{typ trm}, @{sort fs}) *}

(* TEMPORARY
thm trm_assg.fv[simplified trm_assg.supp(1-2)]
*)

end