Nominal/Terms.thy
changeset 1262 2f020819ada9
parent 1259 db158e995bfc
child 1263 a6eeca90fd4e
equal deleted inserted replaced
1261:853abc14c5c6 1262:2f020819ada9
     1 theory Terms
     1 theory Terms
     2 imports "Nominal2_Atoms" "Nominal2_Eqvt" "Nominal2_Supp" "Abs" "Perm" "Fv" "Rsp" "../../Attic/Prove"
     2 imports "Nominal2_Atoms" "Nominal2_Eqvt" "Nominal2_Supp" "Abs" "Perm" "Fv" "Rsp" "../Attic/Prove"
     3 begin
     3 begin
     4 
     4 
     5 atom_decl name
     5 atom_decl name
     6 
     6 
     7 text {* primrec seems to be genarally faster than fun *}
     7 text {* primrec seems to be genarally faster than fun *}
    60 lemma alpha_bp_eq: "alpha_bp = (op =)"
    60 lemma alpha_bp_eq: "alpha_bp = (op =)"
    61 apply (rule ext)+
    61 apply (rule ext)+
    62 apply (rule alpha_bp_eq_eq)
    62 apply (rule alpha_bp_eq_eq)
    63 done
    63 done
    64 
    64 
       
    65 ML {*
       
    66 fun build_eqvts funs perms simps induct ctxt =
       
    67 let
       
    68   val pi = Free ("pi", @{typ perm});
       
    69   val types = map (domain_type o fastype_of) funs;
       
    70   val fv_indnames = Datatype_Prop.make_tnames (map body_type types);
       
    71   val args = map Free (fv_indnames ~~ types);
       
    72   val perm_at = Const (@{const_name permute}, @{typ "perm \<Rightarrow> atom set \<Rightarrow> atom set"})
       
    73   fun eqvtc (fv, (arg, perm)) =
       
    74     HOLogic.mk_eq ((perm_at $ pi $ (fv $ arg)), (fv $ (perm $ pi $ arg)))
       
    75   val gl = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj (map eqvtc (funs ~~ (args ~~ perms))))
       
    76   fun tac _ = (indtac induct fv_indnames THEN_ALL_NEW
       
    77     (asm_full_simp_tac (HOL_ss addsimps 
       
    78       (@{thm atom_eqvt} :: (Nominal_ThmDecls.get_eqvts_thms ctxt) @ simps)))) 1
       
    79 in
       
    80   Goal.prove ctxt ("pi" :: fv_indnames) [] gl tac
       
    81 end
       
    82 *}
       
    83 
       
    84 ML {*
       
    85 build_eqvts [@{term bv1}] [@{term "permute :: perm \<Rightarrow> bp \<Rightarrow> bp"}] (@{thms bv1.simps permute_rtrm1_permute_bp.simps}) @{thm rtrm1_bp.inducts(2)} @{context}
       
    86 *}
    65 lemma bv1_eqvt[eqvt]:
    87 lemma bv1_eqvt[eqvt]:
    66   shows "(pi \<bullet> bv1 x) = bv1 (pi \<bullet> x)"
    88   shows "(pi \<bullet> bv1 x) = bv1 (pi \<bullet> x)"
    67   apply (induct x)
    89   apply (induct x)
    68   apply (simp_all add: eqvts atom_eqvt)
    90   apply (simp_all add: eqvts atom_eqvt)
    69   done
    91   done
    70 
    92 
       
    93 ML {*
       
    94 build_eqvts [@{term fv_rtrm1}, @{term fv_bp}] [@{term "permute :: perm \<Rightarrow> rtrm1 \<Rightarrow> rtrm1"},@{term "permute :: perm \<Rightarrow> bp \<Rightarrow> bp"}] (@{thms fv_rtrm1_fv_bp.simps permute_rtrm1_permute_bp.simps}) @{thm rtrm1_bp.induct} @{context}
       
    95 *}
    71 lemma fv_rtrm1_eqvt[eqvt]:
    96 lemma fv_rtrm1_eqvt[eqvt]:
    72     "(pi\<bullet>fv_rtrm1 t) = fv_rtrm1 (pi\<bullet>t)"
    97     "(pi\<bullet>fv_rtrm1 t) = fv_rtrm1 (pi\<bullet>t)"
    73     "(pi\<bullet>fv_bp b) = fv_bp (pi\<bullet>b)"
    98     "(pi\<bullet>fv_bp b) = fv_bp (pi\<bullet>b)"
    74   apply (induct t and b)
    99   apply (induct t and b)
    75   apply (simp_all add: eqvts atom_eqvt)
   100   apply (simp_all add: eqvts atom_eqvt)