110 val untaglist: (int * 'a) list -> 'a list |
110 val untaglist: (int * 'a) list -> 'a list |
111 val orderlist: (int * 'a) list -> 'a list |
111 val orderlist: (int * 'a) list -> 'a list |
112 val rewrite: bool -> thm list -> cterm -> thm |
112 val rewrite: bool -> thm list -> cterm -> thm |
113 val rewrite_cterm: bool -> thm list -> cterm -> cterm |
113 val rewrite_cterm: bool -> thm list -> cterm -> cterm |
114 val simplify: bool -> thm list -> thm -> thm |
114 val simplify: bool -> thm list -> thm -> thm |
115 val prove: theory -> string list -> term list -> term -> (thm list -> tactic) -> thm |
115 val prove: Sign.sg -> string list -> term list -> term -> (thm list -> tactic) -> thm |
|
116 val prove_standard: Sign.sg -> string list -> term list -> term -> (thm list -> tactic) -> thm |
116 end; |
117 end; |
117 |
118 |
118 structure Tactic: TACTIC = |
119 structure Tactic: TACTIC = |
119 struct |
120 struct |
120 |
121 |
607 None => no_tac | Some tac => tac n |
608 None => no_tac | Some tac => tac n |
608 end) |
609 end) |
609 end; |
610 end; |
610 |
611 |
611 |
612 |
612 (** primitive goal interface for internal use -- avoids "standard" operation *) |
613 (** minimal goal interface for internal use *) |
613 |
614 |
614 fun prove thy xs asms prop tac = |
615 fun prove sign xs asms prop tac = |
615 let |
616 let |
616 val sg = Theory.sign_of thy; |
|
617 val statement = Logic.list_implies (asms, prop); |
617 val statement = Logic.list_implies (asms, prop); |
618 val frees = map Term.dest_Free (Term.term_frees statement); |
618 val frees = map Term.dest_Free (Term.term_frees statement); |
|
619 val fixed_frees = filter_out (fn (x, _) => x mem_string xs) frees; |
|
620 val fixed_tfrees = foldr Term.add_typ_tfree_names (map #2 fixed_frees, []); |
|
621 |
619 val params = mapfilter (fn x => apsome (pair x) (assoc_string (frees, x))) xs; |
622 val params = mapfilter (fn x => apsome (pair x) (assoc_string (frees, x))) xs; |
620 |
623 |
621 fun err msg = error (msg ^ "\nThe error(s) above occurred for the goal statement:\n" ^ |
624 fun err msg = error (msg ^ "\nThe error(s) above occurred for the goal statement:\n" ^ |
622 Sign.string_of_term sg (Term.list_all_free (params, statement))); |
625 Sign.string_of_term sign (Term.list_all_free (params, statement))); |
623 |
626 |
624 fun cert_safe t = Thm.cterm_of sg t |
627 fun cert_safe t = Thm.cterm_of sign t |
625 handle TERM (msg, _) => err msg | TYPE (msg, _, _) => err msg; |
628 handle TERM (msg, _) => err msg | TYPE (msg, _, _) => err msg; |
626 |
629 |
627 val _ = cert_safe statement; |
630 val _ = cert_safe statement; |
628 val _ = Term.no_dummy_patterns statement handle TERM (msg, _) => error msg; |
631 val _ = Term.no_dummy_patterns statement handle TERM (msg, _) => error msg; |
629 |
632 |
638 val prop' = #prop (Thm.rep_thm raw_result); |
641 val prop' = #prop (Thm.rep_thm raw_result); |
639 in |
642 in |
640 if ngoals <> 0 then |
643 if ngoals <> 0 then |
641 err ("Proof failed.\n" ^ Pretty.string_of (Pretty.chunks (Display.pretty_goals ngoals goal')) |
644 err ("Proof failed.\n" ^ Pretty.string_of (Pretty.chunks (Display.pretty_goals ngoals goal')) |
642 ^ ("\n" ^ string_of_int ngoals ^ " unsolved goal(s)!")) |
645 ^ ("\n" ^ string_of_int ngoals ^ " unsolved goal(s)!")) |
643 else if not (Pattern.matches (Sign.tsig_of sg) (prop, prop')) then |
646 else if not (Pattern.matches (Sign.tsig_of sign) (prop, prop')) then |
644 err ("Proved a different theorem: " ^ Sign.string_of_term sg prop') |
647 err ("Proved a different theorem: " ^ Sign.string_of_term sign prop') |
645 else |
648 else |
646 raw_result |
649 raw_result |
647 |> Drule.implies_intr_list casms |
650 |> Drule.implies_intr_list casms |
648 |> Drule.forall_intr_list (map (cert_safe o Free) params) |
651 |> Drule.forall_intr_list (map (cert_safe o Free) params) |
649 |> norm_hhf |
652 |> norm_hhf |
650 |> Thm.varifyT (* FIXME proper scope for polymorphisms!? *) |
653 |> Thm.varifyT' fixed_tfrees |
|
654 |> Drule.zero_var_indexes |
651 end; |
655 end; |
|
656 |
|
657 fun prove_standard sign xs asms prop tac = Drule.standard (prove sign xs asms prop tac); |
652 |
658 |
653 end; |
659 end; |
654 |
660 |
655 structure BasicTactic: BASIC_TACTIC = Tactic; |
661 structure BasicTactic: BASIC_TACTIC = Tactic; |
656 open BasicTactic; |
662 open BasicTactic; |