signature ISA_ND = sig val variant_names: Proof.context -> term list -> stringlist -> stringlist
(* meta level fixed params (i.e. !! vars) *) val fix_alls_term: Proof.context -> int -> term -> term * term list
(* assumptions/subgoals *) val fixed_subgoal_thms: Proof.context -> thm -> thm list * (thm list -> thm) end
structure IsaND : ISA_ND = struct
(* datatype to capture an exported result, ie a fix or assume. *) datatype export =
Export of
{fixes : Thm.cterm list, (* fixed vars *)
assumes : Thm.cterm list, (* hidden hyps/assumed prems *)
sgid : int,
gth : Thm.thm}; (* subgoal/goalthm *)
(* exporting function that takes a solution to the fixed/assumed goal,
and uses this to solve the subgoal in the main theorem *) fun export_solution (Export {fixes = cfvs, assumes = hcprems, sgid = i, gth = gth}) solth = let val solth' = solth
|> Drule.implies_intr_list hcprems
|> Drule.forall_intr_list cfvs; in Drule.compose (solth', i, gth) end;
fun variant_names ctxt ts xs = let val names =
Variable.names_of ctxt
|> fold (fn t => Term.declare_free_names t #> Term.declare_var_names (K true) t) ts; in Name.variants names xs end;
(* fix parameters of a subgoal "i", as free variables, and create an exportingfunctionthatwillusetheresultofthisprovedgoalto showthegoalintheoriginaltheorem.
looselycorrespondsto: Given"[|SG0;...!!x.As==>SGix;...SGm|]==>G":thm Result: ("(As==>SGix')==>(As==>SGix')":thm, expf: ("As==>SGix'":thm)-> ("[|SG0;...SGi-1;SGi+1;...SGm|]==>G"):thm)
*) fun fix_alls_term ctxt i t = let val gt = Logic.get_goal t i; val body = Term.strip_all_body gt; val alls = rev (Term.strip_all_vars gt); val xs = variant_names ctxt [t] (map fst alls); val fvs = map Free (xs ~~ map snd alls); in ((subst_bounds (fvs,body)), fvs) end;
fun fix_alls_cterm ctxt i th = let val (fixedbody, fvs) = fix_alls_term ctxt i (Thm.prop_of th); val cfvs = rev (map (Thm.cterm_of ctxt) fvs); val ct_body = Thm.cterm_of ctxt fixedbody; in (ct_body, cfvs) end;
fun fix_alls' ctxt i = apfst Thm.trivial o fix_alls_cterm ctxt i;
(* hide other goals *) (* note the export goal is rotated by (i - 1) and will have to be
unrotated to get backto the originial position(s) *) fun hide_other_goals th = let (* tl beacuse fst sg is the goal we are interested in *) val cprems = tl (Thm.cprems_of th); val aprems = map Thm.assume cprems; in (Drule.implies_elim_list (Drule.rotate_prems 1 th) aprems, cprems) end;
(* a nicer version of the above that leaves only a single subgoal (the othersubgoalsarehiddenhyps,thattheexportersufflesabout)
namely the subgoal that we were trying to solve. *) (* loosely corresponds to: Given"[|SG0;...!!x.As==>SGix;...SGm|]==>G":thm Result: ("(As==>SGix')==>SGix'":thm, expf: ("SGix'":thm)-> ("[|SG0;...SGi-1;SGi+1;...SGm|]==>G"):thm)
*) fun fix_alls ctxt i th = let val (fixed_gth, fixedvars) = fix_alls' ctxt i th val (sml_gth, othergoals) = hide_other_goals fixed_gth in (sml_gth, Export {fixes = fixedvars, assumes = othergoals, sgid = i, gth = th}) end;
(* Fixme: allow different order of subgoals given to expf *) (* make each subgoal into a separate thm that needs to be proved *) (* loosely corresponds to: Given "[|SG0;...SGm|]==>G":thm Result: (["SG0==>SG0",...,"SGm==>SGm"]:thmlist,--goals ["SG0",...,"SGm"]:thmlist->--exportfunction "G":thm)
*) fun subgoal_thms ctxt th = let val t = Thm.prop_of th;
val prems = Logic.strip_imp_prems t; val aprems = map (Thm.trivial o Thm.cterm_of ctxt) prems;
fun explortf premths = Drule.implies_elim_list th premths; in (aprems, explortf) end;
(* Fixme: allow different order of subgoals in exportf *) (* as above, but also fix all parameters in all subgoals, and uses fix_alls,notfix_alls',iedoesn'tleaveextraasumptionsasapparent
subgoals. *) (* loosely corresponds to: Given "[|!!x0s.A0sx0s==>SG0x0s; ...;!!xms.Amsxms==>SGmxms|]==>G":thm Result: (["(A0sx0s'==>SG0x0s')==>SG0x0s'", ...,"(Amsxms'==>SGmxms')==>SGmxms'"]:thmlist,--goals ["SG0x0s'",...,"SGmxms'"]:thmlist->--exportfunction "G":thm)
*) (* requires being given solutions! *) fun fixed_subgoal_thms ctxt th = let val (subgoals, expf) = subgoal_thms ctxt th; (* fun export_sg (th, exp) = exp th; *) fun export_sgs expfs solthms =
expf (map2 (curry (op |>)) solthms expfs); (* expf (map export_sg (ths ~~ expfs)); *) in
apsnd export_sgs
(Library.split_list (map (apsnd export_solution o fix_alls ctxt 1) subgoals)) end;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.