108 val untaglist: (int * 'a) list -> 'a list |
108 val untaglist: (int * 'a) list -> 'a list |
109 val orderlist: (int * 'a) list -> 'a list |
109 val orderlist: (int * 'a) list -> 'a list |
110 val rewrite: bool -> thm list -> cterm -> thm |
110 val rewrite: bool -> thm list -> cterm -> thm |
111 val simplify: bool -> thm list -> thm -> thm |
111 val simplify: bool -> thm list -> thm -> thm |
112 val conjunction_tac: tactic |
112 val conjunction_tac: tactic |
|
113 val smart_conjunction_tac: int -> tactic |
|
114 val prove_multi: Sign.sg -> string list -> term list -> term list -> |
|
115 (thm list -> tactic) -> thm list |
|
116 val prove_multi_standard: Sign.sg -> string list -> term list -> term list -> |
|
117 (thm list -> tactic) -> thm list |
113 val prove: Sign.sg -> string list -> term list -> term -> (thm list -> tactic) -> thm |
118 val prove: Sign.sg -> string list -> term list -> term -> (thm list -> tactic) -> thm |
114 val prove_standard: Sign.sg -> string list -> term list -> term -> (thm list -> tactic) -> thm |
119 val prove_standard: Sign.sg -> string list -> term list -> term -> |
|
120 (thm list -> tactic) -> thm |
115 val compose_inst_tac' : (indexname * string) list -> (bool * thm * int) -> |
121 val compose_inst_tac' : (indexname * string) list -> (bool * thm * int) -> |
116 int -> tactic |
122 int -> tactic |
117 val lift_inst_rule' : thm * int * (indexname * string) list * thm -> thm |
123 val lift_inst_rule' : thm * int * (indexname * string) list * thm -> thm |
118 val eres_inst_tac' : (indexname * string) list -> thm -> int -> tactic |
124 val eres_inst_tac' : (indexname * string) list -> thm -> int -> tactic |
119 val res_inst_tac' : (indexname * string) list -> thm -> int -> tactic |
125 val res_inst_tac' : (indexname * string) list -> thm -> int -> tactic |
639 compose_tac (false, Drule.incr_indexes_wrt [] [] [] [st] Drule.conj_intr_thm, 2) i st) |
645 compose_tac (false, Drule.incr_indexes_wrt [] [] [] [st] Drule.conj_intr_thm, 2) i st) |
640 | _ => no_tac); |
646 | _ => no_tac); |
641 |
647 |
642 val conjunction_tac = ALLGOALS (REPEAT_ALL_NEW conj_tac); |
648 val conjunction_tac = ALLGOALS (REPEAT_ALL_NEW conj_tac); |
643 |
649 |
644 |
650 fun smart_conjunction_tac 0 = assume_tac 1 |
645 |
651 | smart_conjunction_tac _ = TRY conjunction_tac; |
646 (** minimal goal interface for internal use *) |
652 |
647 |
653 |
648 fun prove sign xs asms prop tac = |
654 |
|
655 (** minimal goal interface for programmed proofs *) |
|
656 |
|
657 fun prove_multi sign xs asms props tac = |
649 let |
658 let |
|
659 val prop = Logic.mk_conjunction_list props; |
650 val statement = Logic.list_implies (asms, prop); |
660 val statement = Logic.list_implies (asms, prop); |
651 val frees = map Term.dest_Free (Term.term_frees statement); |
661 val frees = map Term.dest_Free (Term.term_frees statement); |
652 val fixed_frees = filter_out (fn (x, _) => x mem_string xs) frees; |
662 val fixed_frees = filter_out (fn (x, _) => x mem_string xs) frees; |
653 val fixed_tfrees = foldr Term.add_typ_tfrees [] (map #2 fixed_frees); |
663 val fixed_tfrees = foldr Term.add_typ_tfrees [] (map #2 fixed_frees); |
654 val params = List.mapPartial (fn x => Option.map (pair x) (assoc_string (frees, x))) xs; |
664 val params = List.mapPartial (fn x => Option.map (pair x) (assoc_string (frees, x))) xs; |
669 val goal = Drule.mk_triv_goal (cert_safe prop); |
679 val goal = Drule.mk_triv_goal (cert_safe prop); |
670 |
680 |
671 val goal' = |
681 val goal' = |
672 (case Seq.pull (tac prems goal) of SOME (goal', _) => goal' | _ => err "Tactic failed."); |
682 (case Seq.pull (tac prems goal) of SOME (goal', _) => goal' | _ => err "Tactic failed."); |
673 val ngoals = Thm.nprems_of goal'; |
683 val ngoals = Thm.nprems_of goal'; |
|
684 val _ = conditional (ngoals <> 0) (fn () => |
|
685 err ("Proof failed.\n" ^ |
|
686 Pretty.string_of (Pretty.chunks (Display.pretty_goals ngoals goal')) ^ |
|
687 ("\n" ^ string_of_int ngoals ^ " unsolved goal(s)!"))); |
|
688 |
674 val raw_result = goal' RS Drule.rev_triv_goal; |
689 val raw_result = goal' RS Drule.rev_triv_goal; |
675 val prop' = prop_of raw_result; |
690 val prop' = prop_of raw_result; |
|
691 val _ = conditional (not (Pattern.matches (Sign.tsig_of sign) (prop, prop'))) (fn () => |
|
692 err ("Proved a different theorem: " ^ Sign.string_of_term sign prop')); |
676 in |
693 in |
677 if ngoals <> 0 then |
694 Drule.conj_elim_precise (length props) raw_result |
678 err ("Proof failed.\n" ^ Pretty.string_of (Pretty.chunks (Display.pretty_goals ngoals goal')) |
695 |> map (fn res => res |
679 ^ ("\n" ^ string_of_int ngoals ^ " unsolved goal(s)!")) |
|
680 else if not (Pattern.matches (Sign.tsig_of sign) (prop, prop')) then |
|
681 err ("Proved a different theorem: " ^ Sign.string_of_term sign prop') |
|
682 else |
|
683 raw_result |
|
684 |> Drule.implies_intr_list casms |
696 |> Drule.implies_intr_list casms |
685 |> Drule.forall_intr_list cparams |
697 |> Drule.forall_intr_list cparams |
686 |> norm_hhf_rule |
698 |> norm_hhf_rule |
687 |> (#1 o Thm.varifyT' fixed_tfrees) |
699 |> (#1 o Thm.varifyT' fixed_tfrees) |
688 |> Drule.zero_var_indexes |
700 |> Drule.zero_var_indexes) |
689 end; |
701 end; |
690 |
702 |
|
703 fun prove_multi_standard sign xs asms prop tac = |
|
704 map Drule.standard (prove_multi sign xs asms prop tac); |
|
705 |
|
706 fun prove sign xs asms prop tac = hd (prove_multi sign xs asms [prop] tac); |
691 fun prove_standard sign xs asms prop tac = Drule.standard (prove sign xs asms prop tac); |
707 fun prove_standard sign xs asms prop tac = Drule.standard (prove sign xs asms prop tac); |
692 |
708 |
693 end; |
709 end; |
694 |
710 |
695 structure BasicTactic: BASIC_TACTIC = Tactic; |
711 structure BasicTactic: BASIC_TACTIC = Tactic; |