src/Tools/solve_direct.ML
changeset 43020 abb5d1f907e4
parent 43018 121aa59b4d17
child 43024 58150aa44941
equal deleted inserted replaced
43019:619f16bf2150 43020:abb5d1f907e4
     8 feature.
     8 feature.
     9 *)
     9 *)
    10 
    10 
    11 signature SOLVE_DIRECT =
    11 signature SOLVE_DIRECT =
    12 sig
    12 sig
       
    13   val solve_directN: string
       
    14   val someN: string
       
    15   val noneN: string
       
    16   val unknownN: string
    13   val auto: bool Unsynchronized.ref
    17   val auto: bool Unsynchronized.ref
    14   val max_solutions: int Unsynchronized.ref
    18   val max_solutions: int Unsynchronized.ref
    15   val solve_direct: bool -> Proof.state -> bool * Proof.state
    19   val solve_direct: bool -> Proof.state -> bool * (string * Proof.state)
    16   val setup: theory -> theory
    20   val setup: theory -> theory
    17 end;
    21 end;
    18 
    22 
    19 structure Solve_Direct: SOLVE_DIRECT =
    23 structure Solve_Direct: SOLVE_DIRECT =
    20 struct
    24 struct
    21 
    25 
    22 val solve_directN = "solve_direct";
    26 val solve_directN = "solve_direct";
    23 
    27 
       
    28 val someN = "some";
       
    29 val noneN = "none";
       
    30 val unknownN = "none";
    24 
    31 
    25 (* preferences *)
    32 (* preferences *)
    26 
    33 
    27 val auto = Unsynchronized.ref false;
    34 val auto = Unsynchronized.ref false;
    28 val max_solutions = Unsynchronized.ref 5;
    35 val max_solutions = Unsynchronized.ref 5;
    72           in if null results then NONE else SOME results end);
    79           in if null results then NONE else SOME results end);
    73     fun message results = separate (Pretty.brk 0) (map prt_result results);
    80     fun message results = separate (Pretty.brk 0) (map prt_result results);
    74   in
    81   in
    75     (case try seek_against_goal () of
    82     (case try seek_against_goal () of
    76       SOME (SOME results) =>
    83       SOME (SOME results) =>
    77         (true,
    84         (someN,
    78           state |>
    85           state |>
    79            (if auto then
    86            (if auto then
    80              Proof.goal_message
    87              Proof.goal_message
    81                (fn () =>
    88                (fn () =>
    82                  Pretty.chunks
    89                  Pretty.chunks
    83                   [Pretty.str "",
    90                   [Pretty.str "",
    84                    Pretty.markup Markup.hilite (message results)])
    91                    Pretty.markup Markup.hilite (message results)])
    85             else
    92             else
    86               tap (fn _ =>
    93               tap (fn _ =>
    87                 Output.urgent_message (Pretty.string_of (Pretty.chunks (message results))))))
    94                 Output.urgent_message (Pretty.string_of (Pretty.chunks (message results))))))
    88     | _ => (false, state))
    95     | SOME NONE => (noneN, state)
    89   end;
    96     | NONE => (unknownN, state))
       
    97   end
       
    98   |> `(fn (outcome_code, _) => outcome_code = someN);
    90 
    99 
    91 val _ =
   100 val _ =
    92   Outer_Syntax.improper_command solve_directN
   101   Outer_Syntax.improper_command solve_directN
    93     "try to solve conjectures directly with existing theorems" Keyword.diag
   102     "try to solve conjectures directly with existing theorems" Keyword.diag
    94     (Scan.succeed
   103     (Scan.succeed
    95       (Toplevel.keep (fn state => ignore (solve_direct false (Toplevel.proof_of state)))));
   104       (Toplevel.keep (fn state => ignore (solve_direct false (Toplevel.proof_of state)))));
    96 
   105 
    97 
   106 
    98 (* hook *)
   107 (* hook *)
    99 
   108 
   100 val auto_solve_direct = solve_direct true;
   109 val setup = Try.register_tool (solve_directN, (auto, solve_direct));
   101 
       
   102 val setup = Try.register_tool (auto, auto_solve_direct);
       
   103 
   110 
   104 end;
   111 end;