signature OBTAIN = sig val obtain_export: Proof.context -> thm -> cterm list -> Assumption.export val obtain_thesis: Proof.context -> ((string * typ) * term) * Proof.context val obtains_attributes: ('typ, 'term) Element.obtain list -> attribute list val obtains_attribs: ('typ, 'term) Element.obtain list -> Token.src list val read_obtains: Proof.context -> term -> Element.obtains -> (binding * term) list val cert_obtains: Proof.context -> term -> Element.obtains_i -> (binding * term) list val parse_obtains: Proof.context -> term -> Element.obtains -> (binding * term) list val consider: Element.obtains_i -> bool -> Proof.state -> Proof.state val consider_cmd: Element.obtains -> bool -> Proof.state -> Proof.state val obtain: binding -> (binding * typ option * mixfix) list ->
(binding * typ option * mixfix) list -> (term * term list) listlist ->
(Thm.binding * (term * term list) list) list -> bool -> Proof.state -> Proof.state val obtain_cmd: binding -> (binding * stringoption * mixfix) list ->
(binding * stringoption * mixfix) list -> (string * stringlist) listlist ->
(Attrib.binding * (string * stringlist) list) list -> bool -> Proof.state -> Proof.state val check_result: Proof.context -> term -> thm -> thm val result: (Proof.context -> tactic) -> thm list -> Proof.context ->
((string * cterm) list * thm list) * Proof.context end;
structure Obtain: OBTAIN = struct
(** specification elements **)
(* obtain_export *)
(* [x,Ax] : B -------- B
*) fun eliminate_term ctxt xs tm = let val vs = map (dest_Free o Thm.term_of) xs; val bads = Term.fold_aterms (fn t as Free v => if member (op =) vs v then insert (op aconv) t else I | _ => I) tm []; val _ = null bads orelse
error ("Result contains obtained parameters: " ^
implode_space (map (Syntax.string_of_term ctxt) bads)); in tm end;
fun eliminate ctxt rule xs As thm = let val _ = eliminate_term ctxt xs (Thm.full_prop_of thm); val _ = Object_Logic.is_judgment ctxt (Thm.concl_of thm) orelse
error "Conclusion in obtained context must be object-logic judgment";
fun obtain_thesis ctxt = let val ([x], ctxt') =
Proof_Context.add_fixes [(Binding.name Auto_Bind.thesisN, NONE, NoSyn)] ctxt; val t = Object_Logic.fixed_judgment ctxt x; val v = dest_Free (Object_Logic.drop_judgment ctxt t); in ((v, t), ctxt') end;
(* obtain clauses *)
local
val mk_all_external = Logic.all_constraint o Variable.default_type;
fun mk_all_internal ctxt (y, z) t = let val frees = Frees.build (t |> Term.fold_aterms (fn Free v => Frees.add_set v | _ => I)); val T =
Frees.get_first (fn ((x, T), _) => if x = z then SOME T else NONE) frees
|> \<^if_none>\<open>the_default dummyT (Variable.default_type ctxt z)\<close>; in Logic.all_const T $ Term.lambda_name (y, Free (z, T)) t end;
fun prepare_clause prep_var parse_prop mk_all ctxt thesis raw_vars raw_props = let val ((xs', vars), ctxt') = ctxt
|> fold_map prep_var raw_vars
|-> (fn vars => Proof_Context.add_fixes vars ##>> pair vars); val xs = map (Variable.check_name o #1) vars; in
Logic.list_implies (map (parse_prop ctxt') raw_props, thesis)
|> fold_rev (mk_all ctxt') (xs ~~ xs') end;
val obtain = gen_obtain Proof_Context.cert_stmt (K I); val obtain_cmd = gen_obtain Proof_Context.read_stmt Attrib.attribute_cmd;
end;
(** tactical result **)
fun check_result ctxt thesis th =
(case Thm.prems_of th of
[prem] => if Thm.concl_of th aconv thesis andalso
Logic.strip_assums_concl prem aconv thesis then th else error ("Guessed a different clause:\n" ^ Thm.string_of_thm ctxt th)
| [] => error "Goal solved -- nothing guessed"
| _ => error ("Guess split into several cases:\n" ^ Thm.string_of_thm ctxt th));
fun result tac facts ctxt = let val ((thesis_var, thesis), thesis_ctxt) = obtain_thesis ctxt; val st = Goal.init (Thm.cterm_of ctxt thesis); val rule =
(case SINGLE (Method.insert_tac thesis_ctxt facts 1THEN tac thesis_ctxt) st of
NONE => raise THM ("Obtain.result: tactic failed", 0, facts)
| SOME th =>
check_result thesis_ctxt thesis (Raw_Simplifier.norm_hhf thesis_ctxt (Goal.conclude th)));
val closed_rule = Thm.forall_intr (Thm.cterm_of ctxt (Free thesis_var)) rule; val ((_, [rule']), ctxt') = Variable.import false [closed_rule] ctxt; val obtain_rule =
Thm.forall_elim (Thm.cterm_of ctxt (Logic.varify_global (Free thesis_var))) rule'; val ((params, stmt), fix_ctxt) = Variable.focus_cterm NONE (Thm.cprem_of obtain_rule 1) ctxt'; val (prems, ctxt'') =
Assumption.add_assms (obtain_export fix_ctxt obtain_rule (map #2 params))
(Drule.strip_imp_prems stmt) fix_ctxt; in ((params, prems), ctxt'') end;
end;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-30)
¤
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.