diff -r 54ad41f9e505 -r 996d4411e95e Nominal/Perm.thy --- a/Nominal/Perm.thy Mon Apr 19 15:37:54 2010 +0200 +++ b/Nominal/Perm.thy Mon Apr 19 16:55:36 2010 +0200 @@ -3,11 +3,6 @@ begin ML {* - open Datatype_Aux; (* typ_of_dtyp, DtRec, ... *) - open Nominal_Library; -*} - -ML {* fun quotient_lift_consts_export qtys spec ctxt = let val (result, ctxt') = fold_map (Quotient_Def.quotient_lift_const qtys) spec ctxt; @@ -26,54 +21,53 @@ val perm_types = map fastype_of perm_frees; val perm_indnames = Datatype_Prop.make_tnames (map body_type perm_types); fun glc ((perm, T), x) = - HOLogic.mk_eq (perm $ @{term "0 :: perm"} $ Free (x, T), Free (x, T)) + HOLogic.mk_eq (perm $ @{term "0::perm"} $ Free (x, T), Free (x, T)) val gl = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj (map glc (perm_frees ~~ map body_type perm_types ~~ perm_indnames))); fun tac _ = EVERY [ - indtac induct perm_indnames 1, + Datatype_Aux.indtac induct perm_indnames 1, ALLGOALS (asm_full_simp_tac (HOL_ss addsimps (@{thm permute_zero} :: perm_def))) ]; in - split_conj_thm (Goal.prove lthy perm_indnames [] gl tac) + Datatype_Aux.split_conj_thm (Goal.prove lthy perm_indnames [] gl tac) end; *} ML {* fun prove_perm_append lthy induct perm_def perm_frees = let - val add_perm = @{term "op + :: (perm \ perm \ perm)"} val pi1 = Free ("pi1", @{typ perm}); val pi2 = Free ("pi2", @{typ perm}); val perm_types = map fastype_of perm_frees val perm_indnames = Datatype_Prop.make_tnames (map body_type perm_types); fun glc ((perm, T), x) = HOLogic.mk_eq ( - perm $ (add_perm $ pi1 $ pi2) $ Free (x, T), + perm $ (mk_plus pi1 pi2) $ Free (x, T), perm $ pi1 $ (perm $ pi2 $ Free (x, T))) - val gl = + val goal = (HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj (map glc (perm_frees ~~ map body_type perm_types ~~ perm_indnames)))) fun tac _ = EVERY [ - indtac induct perm_indnames 1, + Datatype_Aux.indtac induct perm_indnames 1, ALLGOALS (asm_full_simp_tac (HOL_ss addsimps (@{thm permute_plus} :: perm_def))) ] in - split_conj_thm (Goal.prove lthy ("pi1" :: "pi2" :: perm_indnames) [] gl tac) + Datatype_Aux.split_conj_thm (Goal.prove lthy ("pi1" :: "pi2" :: perm_indnames) [] goal tac) end; *} ML {* -fun define_raw_perms (dt_info : info) number thy = +fun define_raw_perms (dt_info : Datatype_Aux.info) number thy = let val {descr, induct, sorts, ...} = dt_info; val all_full_tnames = map (fn (_, (n, _, _)) => n) descr; val full_tnames = List.take (all_full_tnames, number); - fun nth_dtyp i = typ_of_dtyp descr sorts (DtRec i); + fun nth_dtyp i = Datatype_Aux.typ_of_dtyp descr sorts (Datatype_Aux.DtRec i); val perm_names' = Datatype_Prop.indexify_names (map (fn (i, _) => - "permute_" ^ name_of_typ (nth_dtyp i)) descr); + "permute_" ^ Datatype_Aux.name_of_typ (nth_dtyp i)) descr); val perm_types = map (fn (i, _) => let val T = nth_dtyp i in @{typ perm} --> T --> T end) descr; @@ -81,17 +75,17 @@ val pi = Free ("pi", @{typ perm}); fun perm_eq_constr i (cname, dts) = let - val Ts = map (typ_of_dtyp descr sorts) dts; + val Ts = map (Datatype_Aux.typ_of_dtyp descr sorts) dts; val names = Name.variant_list ["pi"] (Datatype_Prop.make_tnames Ts); val args = map Free (names ~~ Ts); val c = Const (cname, Ts ---> (nth_dtyp i)); fun perm_arg (dt, x) = let val T = type_of x in - if is_rec_type dt then + if Datatype_Aux.is_rec_type dt then let val (Us, _) = strip_type T in list_abs (map (pair "x") Us, - Free (nth perm_names_types' (body_index dt)) $ pi $ + Free (nth perm_names_types' (Datatype_Aux.body_index dt)) $ pi $ list_comb (x, map (fn (i, U) => (mk_perm_ty U (mk_minus pi) (Bound i))) ((length Us - 1 downto 0) ~~ Us))) @@ -180,18 +174,18 @@ (* Test atom_decl name -datatype rtrm1 = - rVr1 "name" -| rAp1 "rtrm1" "rtrm1 list" -| rLm1 "name" "rtrm1" -| rLt1 "bp" "rtrm1" "rtrm1" +datatype trm = + Var "name" +| App "trm" "trm list" +| Lam "name" "trm" +| Let "bp" "trm" "trm" and bp = BUnit -| BVr "name" -| BPr "bp" "bp" +| BVar "name" +| BPair "bp" "bp" -setup {* snd o define_raw_perms ["rtrm1", "bp"] ["Perm.rtrm1", "Perm.bp"] *} +setup {* snd o define_raw_perms ["trm", "bp"] ["Perm.trm", "Perm.bp"] *} print_theorems *)