src/HOL/Tools/Meson/meson.ML
changeset 58957 c9e744ea8a38
parent 58839 ccda99401bc8
child 58963 26bf09b95dda
equal deleted inserted replaced
58956:a816aa3ff391 58957:c9e744ea8a38
    38     tactic -> (thm list -> thm list) -> (thm list -> tactic) -> Proof.context
    38     tactic -> (thm list -> thm list) -> (thm list -> tactic) -> Proof.context
    39     -> int -> tactic
    39     -> int -> tactic
    40   val best_meson_tac: (thm -> int) -> Proof.context -> int -> tactic
    40   val best_meson_tac: (thm -> int) -> Proof.context -> int -> tactic
    41   val safe_best_meson_tac: Proof.context -> int -> tactic
    41   val safe_best_meson_tac: Proof.context -> int -> tactic
    42   val depth_meson_tac: Proof.context -> int -> tactic
    42   val depth_meson_tac: Proof.context -> int -> tactic
    43   val prolog_step_tac': thm list -> int -> tactic
    43   val prolog_step_tac': Proof.context -> thm list -> int -> tactic
    44   val iter_deepen_prolog_tac: thm list -> tactic
    44   val iter_deepen_prolog_tac: Proof.context -> thm list -> tactic
    45   val iter_deepen_meson_tac: Proof.context -> thm list -> int -> tactic
    45   val iter_deepen_meson_tac: Proof.context -> thm list -> int -> tactic
    46   val make_meta_clause: thm -> thm
    46   val make_meta_clause: thm -> thm
    47   val make_meta_clauses: thm list -> thm list
    47   val make_meta_clauses: thm list -> thm list
    48   val meson_tac: Proof.context -> thm list -> int -> tactic
    48   val meson_tac: Proof.context -> thm list -> int -> tactic
    49 end
    49 end
   739 
   739 
   740 (** Iterative deepening version **)
   740 (** Iterative deepening version **)
   741 
   741 
   742 (*This version does only one inference per call;
   742 (*This version does only one inference per call;
   743   having only one eq_assume_tac speeds it up!*)
   743   having only one eq_assume_tac speeds it up!*)
   744 fun prolog_step_tac' horns =
   744 fun prolog_step_tac' ctxt horns =
   745     let val (horn0s, _) = (*0 subgoals vs 1 or more*)
   745     let val (horn0s, _) = (*0 subgoals vs 1 or more*)
   746             take_prefix Thm.no_prems horns
   746             take_prefix Thm.no_prems horns
   747         val nrtac = net_resolve_tac horns
   747         val nrtac = net_resolve_tac horns
   748     in  fn i => eq_assume_tac i ORELSE
   748     in  fn i => eq_assume_tac i ORELSE
   749                 match_tac horn0s i ORELSE  (*no backtracking if unit MATCHES*)
   749                 match_tac ctxt horn0s i ORELSE  (*no backtracking if unit MATCHES*)
   750                 ((assume_tac i APPEND nrtac i) THEN check_tac)
   750                 ((assume_tac i APPEND nrtac i) THEN check_tac)
   751     end;
   751     end;
   752 
   752 
   753 fun iter_deepen_prolog_tac horns =
   753 fun iter_deepen_prolog_tac ctxt horns =
   754     ITER_DEEPEN iter_deepen_limit (has_fewer_prems 1) (prolog_step_tac' horns);
   754     ITER_DEEPEN iter_deepen_limit (has_fewer_prems 1) (prolog_step_tac' ctxt horns);
   755 
   755 
   756 fun iter_deepen_meson_tac ctxt ths = ctxt |> MESON all_tac (make_clauses ctxt)
   756 fun iter_deepen_meson_tac ctxt ths = ctxt |> MESON all_tac (make_clauses ctxt)
   757   (fn cls =>
   757   (fn cls =>
   758     (case (gocls (cls @ ths)) of
   758     (case (gocls (cls @ ths)) of
   759       [] => no_tac  (*no goal clauses*)
   759       [] => no_tac  (*no goal clauses*)
   764             cat_lines ("meson method called:" ::
   764             cat_lines ("meson method called:" ::
   765               map (Display.string_of_thm ctxt) (cls @ ths) @
   765               map (Display.string_of_thm ctxt) (cls @ ths) @
   766               ["clauses:"] @ map (Display.string_of_thm ctxt) horns))
   766               ["clauses:"] @ map (Display.string_of_thm ctxt) horns))
   767         in
   767         in
   768           THEN_ITER_DEEPEN iter_deepen_limit
   768           THEN_ITER_DEEPEN iter_deepen_limit
   769             (resolve_tac goes 1) (has_fewer_prems 1) (prolog_step_tac' horns)
   769             (resolve_tac goes 1) (has_fewer_prems 1) (prolog_step_tac' ctxt horns)
   770         end));
   770         end));
   771 
   771 
   772 fun meson_tac ctxt ths =
   772 fun meson_tac ctxt ths =
   773   SELECT_GOAL (TRY (safe_tac ctxt) THEN TRYALL (iter_deepen_meson_tac ctxt ths));
   773   SELECT_GOAL (TRY (safe_tac ctxt) THEN TRYALL (iter_deepen_meson_tac ctxt ths));
   774 
   774