54 val atomize_tac: int -> tactic |
54 val atomize_tac: int -> tactic |
55 val inner_atomize_tac: int -> tactic |
55 val inner_atomize_tac: int -> tactic |
56 val rulified_term: thm -> theory * term |
56 val rulified_term: thm -> theory * term |
57 val rulify_tac: int -> tactic |
57 val rulify_tac: int -> tactic |
58 val internalize: int -> thm -> thm |
58 val internalize: int -> thm -> thm |
59 val guess_instance: thm -> int -> thm -> thm Seq.seq |
59 val guess_instance: Proof.context -> thm -> int -> thm -> thm Seq.seq |
60 val cases_tac: Proof.context -> term option list list -> thm option -> |
60 val cases_tac: Proof.context -> term option list list -> thm option -> |
61 thm list -> int -> cases_tactic |
61 thm list -> int -> cases_tactic |
62 val induct_tac: Proof.context -> (string option * term) option list list -> |
62 val induct_tac: Proof.context -> (string option * term) option list list -> |
63 (string * typ) list list -> term option list -> thm list option -> |
63 (string * typ) list list -> term option list -> thm list option -> |
64 thm list -> int -> cases_tactic |
64 thm list -> int -> cases_tactic |
418 val xs = map2 (curry (cert o Var)) (map #1 pairs) (map (#T o Thm.rep_cterm) ts); |
418 val xs = map2 (curry (cert o Var)) (map #1 pairs) (map (#T o Thm.rep_cterm) ts); |
419 in (map (fn (xi, (S, T)) => (certT (TVar (xi, S)), certT T)) (Vartab.dest iTs), xs ~~ ts) end; |
419 in (map (fn (xi, (S, T)) => (certT (TVar (xi, S)), certT T)) (Vartab.dest iTs), xs ~~ ts) end; |
420 |
420 |
421 in |
421 in |
422 |
422 |
423 fun guess_instance rule i st = |
423 fun guess_instance ctxt rule i st = |
424 let |
424 let |
425 val thy = Thm.theory_of_thm st; |
425 val thy = ProofContext.theory_of ctxt; |
426 val maxidx = Thm.maxidx_of st; |
426 val maxidx = Thm.maxidx_of st; |
427 val goal = Thm.term_of (Thm.cprem_of st i); (*exception Subscript*) |
427 val goal = Thm.term_of (Thm.cprem_of st i); (*exception Subscript*) |
428 val params = rev (rename_wrt_term goal (Logic.strip_params goal)); |
428 val params = rev (rename_wrt_term goal (Logic.strip_params goal)); |
429 in |
429 in |
430 if not (null params) then |
430 if not (null params) then |
431 (warning ("Cannot determine rule instantiation due to pending parameter(s): " ^ |
431 (warning ("Cannot determine rule instantiation due to pending parameter(s): " ^ |
432 commas_quote (map (Sign.string_of_term thy o Syntax.mark_boundT) params)); |
432 commas_quote (map (Syntax.string_of_term ctxt o Syntax.mark_boundT) params)); |
433 Seq.single rule) |
433 Seq.single rule) |
434 else |
434 else |
435 let |
435 let |
436 val rule' = Thm.incr_indexes (maxidx + 1) rule; |
436 val rule' = Thm.incr_indexes (maxidx + 1) rule; |
437 val concl = Logic.strip_assums_concl goal; |
437 val concl = Logic.strip_assums_concl goal; |
603 THEN' fix_tac defs_ctxt |
603 THEN' fix_tac defs_ctxt |
604 (nth concls (j - 1) + more_consumes) |
604 (nth concls (j - 1) + more_consumes) |
605 (nth_list arbitrary (j - 1)))) |
605 (nth_list arbitrary (j - 1)))) |
606 THEN' inner_atomize_tac) j)) |
606 THEN' inner_atomize_tac) j)) |
607 THEN' atomize_tac) i st |> Seq.maps (fn st' => |
607 THEN' atomize_tac) i st |> Seq.maps (fn st' => |
608 guess_instance (internalize more_consumes rule) i st' |
608 guess_instance ctxt (internalize more_consumes rule) i st' |
609 |> Seq.map (rule_instance thy (burrow_options (Variable.polymorphic ctxt) taking)) |
609 |> Seq.map (rule_instance thy (burrow_options (Variable.polymorphic ctxt) taking)) |
610 |> Seq.maps (fn rule' => |
610 |> Seq.maps (fn rule' => |
611 CASES (rule_cases rule' cases) |
611 CASES (rule_cases rule' cases) |
612 (Tactic.rtac rule' i THEN |
612 (Tactic.rtac rule' i THEN |
613 PRIMITIVE (singleton (ProofContext.export defs_ctxt ctxt))) st')))) |
613 PRIMITIVE (singleton (ProofContext.export defs_ctxt ctxt))) st')))) |
659 in |
659 in |
660 SUBGOAL_CASES (fn (goal, i) => fn st => |
660 SUBGOAL_CASES (fn (goal, i) => fn st => |
661 ruleq goal |
661 ruleq goal |
662 |> Seq.maps (RuleCases.consume [] facts) |
662 |> Seq.maps (RuleCases.consume [] facts) |
663 |> Seq.maps (fn ((cases, (_, more_facts)), rule) => |
663 |> Seq.maps (fn ((cases, (_, more_facts)), rule) => |
664 guess_instance rule i st |
664 guess_instance ctxt rule i st |
665 |> Seq.map (rule_instance thy (burrow_options (Variable.polymorphic ctxt) taking)) |
665 |> Seq.map (rule_instance thy (burrow_options (Variable.polymorphic ctxt) taking)) |
666 |> Seq.maps (fn rule' => |
666 |> Seq.maps (fn rule' => |
667 CASES (RuleCases.make_common false (thy, Thm.prop_of rule') cases) |
667 CASES (RuleCases.make_common false (thy, Thm.prop_of rule') cases) |
668 (Method.insert_tac more_facts i THEN Tactic.rtac rule' i) st))) |
668 (Method.insert_tac more_facts i THEN Tactic.rtac rule' i) st))) |
669 end; |
669 end; |