LamEx.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Wed, 28 Oct 2009 16:05:59 +0100
changeset 221 f219011a5e3c
parent 219 329111e1c4ba
child 225 9b8e039ae960
permissions -rw-r--r--
Fixes

theory LamEx
imports Nominal QuotMain
begin

atom_decl name

nominal_datatype rlam =
  rVar "name"
| rApp "rlam" "rlam"
| rLam "name" "rlam"

inductive 
  alpha :: "rlam \<Rightarrow> rlam \<Rightarrow> bool" ("_ \<approx> _" [100, 100] 100)
where
  a1: "a = b \<Longrightarrow> (rVar a) \<approx> (rVar b)"
| a2: "\<lbrakk>t1 \<approx> t2; s1 \<approx> s2\<rbrakk> \<Longrightarrow> rApp t1 s1 \<approx> rApp t2 s2"
| a3: "\<lbrakk>t \<approx> ([(a,b)]\<bullet>s); a\<sharp>s\<rbrakk> \<Longrightarrow> rLam a t \<approx> rLam b s"

quotient lam = rlam / alpha
apply -
sorry

print_quotients

local_setup {*
  old_make_const_def @{binding Var} @{term "rVar"} NoSyn @{typ "rlam"} @{typ "lam"} #> snd #>
  old_make_const_def @{binding App} @{term "rApp"} NoSyn @{typ "rlam"} @{typ "lam"} #> snd #>
  old_make_const_def @{binding Lam} @{term "rLam"} NoSyn @{typ "rlam"} @{typ "lam"} #> snd
*}

thm Var_def
thm App_def
thm Lam_def

lemma real_alpha:
  assumes "t = ([(a,b)]\<bullet>s)" "a\<sharp>s"
  shows "Lam a t = Lam b s"
sorry





(* Construction Site code *)

lemma perm_rsp: "op = ===> alpha ===> alpha op \<bullet> op \<bullet>" sorry
lemma fresh_rsp: "op = ===> (alpha ===> op =) fresh fresh" sorry
lemma rLam_rsp: "op = ===> (alpha ===> alpha) rLam rLam" sorry

ML {* val defs = @{thms Var_def App_def Lam_def} *}
ML {* val consts = [@{const_name "rVar"}, @{const_name "rApp"}, @{const_name "rLam"}]; *}

ML {* val rty = @{typ "rlam"} *}
ML {* val qty = @{typ "lam"} *}
ML {* val rel = @{term "alpha"} *}
ML {* val rel_eqv = (#equiv_thm o hd) (quotdata_lookup @{theory}) *}
ML {* val rel_refl = @{thm EQUIV_REFL} OF [rel_eqv] *}
ML {* val quot = @{thm QUOTIENT_lam} *}
ML {* val rsp_thms = @{thms perm_rsp fresh_rsp rLam_rsp} @ @{thms ho_all_prs ho_ex_prs} *}
ML {* val trans2 = @{thm QUOT_TYPE_I_lam.R_trans2} *}
ML {* val reps_same = @{thm QUOT_TYPE_I_lam.REPS_same} *}

thm a3
ML {* val t_a = atomize_thm @{thm a3} *}
ML {* val t_r = regularize t_a rty rel rel_eqv @{context} *}
ML {* val t_t = repabs @{context} t_r consts rty qty quot rel_refl trans2 rsp_thms *}
ML {* val abs = findabs rty (prop_of t_a) *}
ML {* val simp_lam_prs_thms = map (make_simp_lam_prs_thm @{context} quot) abs *}
ML {* val t_l = repeat_eqsubst_thm @{context} simp_lam_prs_thms t_t *}
ML {* val t_c = simp_allex_prs @{context} quot t_l *}
ML {* val t_defs_sym = add_lower_defs @{context} defs *}
ML {* val t_d = repeat_eqsubst_thm @{context} t_defs_sym t_c *}
ML {* val t_b = MetaSimplifier.rewrite_rule [reps_same] t_d *}
ML {* ObjectLogic.rulify t_b *}

thm fresh_def
thm supp_def

local_setup {*
  make_const_def @{binding lperm} @{term "perm :: ('a \<times> 'a) list \<Rightarrow> rlam \<Rightarrow> rlam"} NoSyn @{typ "rlam"} @{typ "lam"} #> snd
*}

ML {* val consts = @{const_name perm} :: consts *}
ML {* val defs = @{thms lperm_def} @ defs *}
ML {* val t_u = MetaSimplifier.rewrite_rule @{thms fresh_def supp_def} @{thm a3} *}
ML {* val t_a = atomize_thm t_u *}
ML {* val t_r = regularize t_a rty rel rel_eqv @{context} *}

ML {*
fun r_mk_comb_tac_lam ctxt = r_mk_comb_tac ctxt rty quot rel_refl trans2 rsp_thms
*}

prove {* build_repabs_goal @{context} t_r consts rty qty *}
apply (atomize(full))
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
prefer 2
apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
nitpick
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})







ML {* val t_t = Toplevel.program (fn () => repabs @{context} t_r consts rty qty quot rel_refl trans2 rsp_thms) *}

ML {* val t_t = repabs @{context} t_r consts rty qty quot rel_refl trans2 rsp_thms *}

ML {* val t_l = repeat_eqsubst_thm @{context} simp_lam_prs_thms t_t *}
ML {* val t_c = simp_allex_prs @{context} quot t_l *}
ML {* val t_defs_sym = add_lower_defs @{context} defs *}
ML {* val t_d = repeat_eqsubst_thm @{context} t_defs_sym t_c *}
ML {* val t_b = MetaSimplifier.rewrite_rule [reps_same] t_d *}
ML {* ObjectLogic.rulify t_b *}
ML {* val rr =  (add_lower_defs @{context} @{thms lperm_def}) *}
ML {* val rrr = @{thm eq_reflection} OF [rr] *}
ML {* MetaSimplifier.rewrite_rule [rrr] t_b *}




local_setup {*
  make_const_def @{binding lfresh} @{term "fresh :: 'a \<Rightarrow> rlam \<Rightarrow> bool"} NoSyn @{typ "rlam"} @{typ "lam"} #> snd #>
*}
@{const_name fresh} :: 
lfresh_def 
ML {*
fun lift_thm_lam lthy t =
  lift_thm lthy consts rty qty rel rel_eqv rel_refl quot rsp_thms trans2 reps_same defs t
*}

ML {* Toplevel.program (fn () => lift_thm_lam @{context} @{thm a3}) *}