# HG changeset patch # User Christian Urban # Date 1273672072 -3600 # Node ID 5686d83db1f92389e4b094317220be2910b7c680 # Parent 409ecb7284dd44b8a82783fdd05a8e0e7b18749e ingnored parameters in equivariance; added a proper interface to be called from ML diff -r 409ecb7284dd -r 5686d83db1f9 Nominal-General/nominal_eqvt.ML --- a/Nominal-General/nominal_eqvt.ML Wed May 12 13:43:48 2010 +0100 +++ b/Nominal-General/nominal_eqvt.ML Wed May 12 14:47:52 2010 +0100 @@ -7,9 +7,11 @@ signature NOMINAL_EQVT = sig - val equivariance: string -> Proof.context -> local_theory val eqvt_rel_tac: Proof.context -> string list -> term -> thm -> thm list -> int -> tactic val eqvt_rel_single_case_tac: Proof.context -> string list -> term -> thm -> int -> tactic + + val equivariance: term list -> thm -> thm list -> Proof.context -> (string * thm list) list * local_theory + val equivariance_cmd: string -> Proof.context -> local_theory end structure Nominal_Eqvt : NOMINAL_EQVT = @@ -127,12 +129,11 @@ (* sets up goal and makes sure parameters are untouched PROBLEM: this violates the form of eqvt lemmas *) -fun prepare_goal params_no pi pred = +fun prepare_goal pi pred = let val (c, xs) = strip_comb pred; - val (xs1, xs2) = chop params_no xs in - HOLogic.mk_imp (pred, list_comb (c, xs1 @ map (mk_perm pi) xs2)) + HOLogic.mk_imp (pred, list_comb (c, map (mk_perm pi) xs)) end (* stores thm under name.eqvt and adds [eqvt]-attribute *) @@ -145,38 +146,43 @@ Local_Theory.note ((thm_name, [attr]), [thm]) ctxt end -fun equivariance pred_name ctxt = +fun equivariance pred_trms raw_induct intrs ctxt = let - val thy = ProofContext.theory_of ctxt - val ({names, ...}, {raw_induct, intrs, ...}) = - Inductive.the_inductive ctxt (Sign.intern_const thy pred_name) - val raw_induct = atomize_induct ctxt raw_induct - val intros = map atomize_intr intrs - val params_no = length (Inductive.params_of raw_induct) + val pred_names = map (fst o dest_Const) pred_trms + val raw_induct' = atomize_induct ctxt raw_induct + val intrs' = map atomize_intr intrs val (([raw_concl], [raw_pi]), ctxt') = ctxt - |> Variable.import_terms false [concl_of raw_induct] + |> Variable.import_terms false [concl_of raw_induct'] ||>> Variable.variant_fixes ["p"] val pi = Free (raw_pi, @{typ perm}) val preds = map (fst o HOLogic.dest_imp) (HOLogic.dest_conj (HOLogic.dest_Trueprop raw_concl)); val goal = HOLogic.mk_Trueprop - (foldr1 HOLogic.mk_conj (map (prepare_goal params_no pi) preds)) + (foldr1 HOLogic.mk_conj (map (prepare_goal pi) preds)) val thms = Datatype_Aux.split_conj_thm (Goal.prove ctxt' [] [] goal - (fn {context,...} => eqvt_rel_tac context names pi raw_induct intros 1) + (fn {context,...} => eqvt_rel_tac context pred_names pi raw_induct' intrs' 1) |> singleton (ProofContext.export ctxt' ctxt)) val thms' = map (fn th => zero_var_indexes (th RS mp)) thms in - ctxt |> fold_map note_named_thm (names ~~ thms') |> snd + ctxt |> fold_map note_named_thm (pred_names ~~ thms') end +fun equivariance_cmd pred_name ctxt = +let + val thy = ProofContext.theory_of ctxt + val (_, {preds, raw_induct, intrs, ...}) = + Inductive.the_inductive ctxt (Sign.intern_const thy pred_name) +in + equivariance preds raw_induct intrs ctxt |> snd +end local structure P = OuterParse and K = OuterKeyword in val _ = OuterSyntax.local_theory "equivariance" "Proves equivariance for inductive predicate involving nominal datatypes." - K.thy_decl (P.xname >> equivariance); + K.thy_decl (P.xname >> equivariance_cmd); end; end (* structure *) diff -r 409ecb7284dd -r 5686d83db1f9 Nominal/Ex/SingleLet.thy --- a/Nominal/Ex/SingleLet.thy Wed May 12 13:43:48 2010 +0100 +++ b/Nominal/Ex/SingleLet.thy Wed May 12 14:47:52 2010 +0100 @@ -16,7 +16,7 @@ where "bn (As x t) = {atom x}" - +ML {* Inductive.the_inductive *} thm trm_assg.fv thm trm_assg.supp thm trm_assg.eq_iff @@ -31,6 +31,7 @@ equivariance alpha_trm_raw + end diff -r 409ecb7284dd -r 5686d83db1f9 Nominal/NewParser.thy --- a/Nominal/NewParser.thy Wed May 12 13:43:48 2010 +0100 +++ b/Nominal/NewParser.thy Wed May 12 14:47:52 2010 +0100 @@ -367,11 +367,6 @@ if STEPS > 1 then raw_nominal_decls dts bn_funs bn_eqs bclauses lthy else raise TEST lthy - val _ = tracing ("raw_bn_eqs\n" ^ cat_lines (map (@{make_string} o prop_of) raw_bn_eqs)) - - val _ = tracing ("raw_bns\n" ^ @{make_string} raw_bns) - val _ = tracing ("raw_bclauses\n" ^ @{make_string} raw_bclauses) - val dtinfo = Datatype.the_info (ProofContext.theory_of lthy1) (hd raw_dt_names); val {descr, sorts, ...} = dtinfo; val raw_tys = map (fn (i, _) => nth_dtyp descr sorts i) descr; @@ -406,12 +401,11 @@ val lthy3 = Theory_Target.init NONE thy; val raw_bn_funs = map (fn (f, _, _) => f) bn_funs_decls; - (* val _ = tracing ("raw_bns\n" ^ @{make_string} raw_bns) val _ = tracing ("raw_bns\n" ^ @{make_string} raw_bns_exp) val _ = tracing ("bn_funs\n" ^ @{make_string} bn_funs_decls) val _ = tracing ("raw_bclauses\n" ^ @{make_string} raw_bclauses) - *) + val ((fv, fvbn), fv_def, lthy3a) = if STEPS > 3 then define_raw_fv descr sorts bn_funs_decls raw_bclauses lthy3 else raise TEST lthy3