fun the_sort tvars (ai, pos) : sort =
(case TVars.get_first (fn ((bi, S), _) => if ai = bi then SOME S else NONE) tvars of
SOME S => S
| NONE => error_var "No such type variable in theorem: " (ai, pos));
fun the_type vars (xi, pos) : typ =
(case Vartab.lookup vars xi of
SOME T => T
| NONE => error_var "No such variable in theorem: " (xi, pos));
fun read_type ctxt tvars ((xi, pos), s) = let val S = the_sort tvars (xi, pos); val T = Syntax.read_typ ctxt s; in if Sign.of_sort (Proof_Context.theory_of ctxt) (T, S) then ((xi, S), T) else error_var "Bad sort for instantiation of type variable: " (xi, pos) end;
fun make_instT f (tvars: TVars.set) = let fun add v = let val T = TVar v; val T' = f T; inif T = T' then I else cons (v, T') end; in TVars.fold (add o #1) tvars [] end;
fun make_inst f vars = let fun add v = let val t = Var v; val t' = f t; inif t aconv t' then I else cons (v, t') end; in fold add vars [] end;
fun read_terms ss Ts ctxt = let fun parse T = if T = propT then Syntax.parse_prop ctxt else Syntax.parse_term ctxt; val (ts, ctxt') = fold_map Variable.fix_dummy_patterns (map2 parse Ts ss) ctxt; val ts' =
map2 (Type.constraint o Type_Infer.paramify_vars) Ts ts
|> Syntax.check_terms ctxt'
|> Variable.polymorphic ctxt'; val Ts' = map Term.fastype_of ts'; val tyenv = Vartab.build (fold (Sign.typ_match (Proof_Context.theory_of ctxt)) (Ts ~~ Ts')); val tyenv' = Vartab.fold (fn (xi, (S, T)) => cons ((xi, S), T)) tyenv []; in ((ts', tyenv'), ctxt') end;
in
fun read_term s ctxt = let val (t, ctxt') = Variable.fix_dummy_patterns (Syntax.parse_term ctxt s) ctxt; val t' = Syntax.check_term ctxt' t; in (t', ctxt') end;
fun read_insts thm raw_insts raw_fixes ctxt = let val (type_insts, term_insts) = List.partition (fn (((x, _), _), _) => String.isPrefix "'" x) raw_insts;
val tvars = TVars.build (Thm.fold_terms {hyps = false} TVars.add_tvars thm); val vars = Vars.build (Thm.fold_terms {hyps = false} Vars.add_vars thm);
(*eigen-context*) val (_, ctxt1) = ctxt
|> TVars.fold (Variable.declare_internal o Logic.mk_type o TVar o #1) tvars
|> Vars.fold (Variable.declare_internal o Var o #1) vars
|> Proof_Context.add_fixes_cmd raw_fixes;
val thm' = Thm.lift_rule cgoal thm
|> Drule.instantiate_normalize (inst_tvars', inst_vars')
|> singleton (Variable.export inst_ctxt ctxt); in compose_tac ctxt (bires_flag, thm', Thm.nprems_of thm) i end) i st;
val res_inst_tac = bires_inst_tac false; val eres_inst_tac = bires_inst_tac true;
(* forward resolution *)
fun make_elim_preserve ctxt rl = let val maxidx = Thm.maxidx_of rl; fun var x = ((x, 0), propT); fun cvar xi = Thm.cterm_of ctxt (Var (xi, propT)); val revcut_rl' =
Drule.revcut_rl |> Drule.instantiate_normalize
(TVars.empty, Vars.make2 (var "V", cvar ("V", maxidx + 1)) (var "W", cvar ("W", maxidx + 1))); in
(case Seq.list_of
(Thm.bicompose (SOME ctxt) {flatten = true, match = false, incremented = false}
(false, rl, Thm.nprems_of rl) 1 revcut_rl') of
[th] => th
| _ => raise THM ("make_elim_preserve", 1, [rl])) end;
(*instantiate and cut -- for atomic fact*) fun cut_inst_tac ctxt insts fixes rule =
res_inst_tac ctxt insts fixes (make_elim_preserve ctxt rule);
(*forward tactic applies a rule to an assumption without deleting it*) fun forw_inst_tac ctxt insts fixes rule =
cut_inst_tac ctxt insts fixes rule THEN' assume_tac ctxt;
(*dresolve tactic applies a rule to replace an assumption*) fun dres_inst_tac ctxt insts fixes rule =
eres_inst_tac ctxt insts fixes (make_elim_preserve ctxt rule);
(* derived tactics *)
(*deletion of an assumption*) fun thin_tac ctxt s fixes =
eres_inst_tac ctxt [((("V", 0), Position.none), s)] fixes Drule.thin_rl;
(*Introduce the given proposition as lemma and subgoal*) fun subgoal_tac ctxt A fixes =
DETERM o res_inst_tac ctxt [((("psi", 0), Position.none), A)] fixes cut_rl;
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 ist noch experimentell.