equal
deleted
inserted
replaced
11 |
11 |
12 val tryN : string |
12 val tryN : string |
13 |
13 |
14 val serial_commas : string -> string list -> string list |
14 val serial_commas : string -> string list -> string list |
15 val subgoal_count : Proof.state -> int |
15 val subgoal_count : Proof.state -> int |
16 val register_tool : tool -> theory -> theory |
|
17 val get_tools : theory -> tool list |
16 val get_tools : theory -> tool list |
18 val try_tools : Proof.state -> (string * string) option |
17 val try_tools : Proof.state -> (string * string) option |
|
18 val tool_setup : tool -> unit |
19 end; |
19 end; |
20 |
20 |
21 structure Try : TRY = |
21 structure Try : TRY = |
22 struct |
22 struct |
23 |
23 |
63 |
63 |
64 val get_tools = Data.get |
64 val get_tools = Data.get |
65 |
65 |
66 val register_tool = Data.map o Ord_List.insert tool_ord |
66 val register_tool = Data.map o Ord_List.insert tool_ord |
67 |
67 |
|
68 |
68 (* try command *) |
69 (* try command *) |
69 |
70 |
70 fun try_tools state = |
71 fun try_tools state = |
71 if subgoal_count state = 0 then |
72 if subgoal_count state = 0 then |
72 (Output.urgent_message "No subgoal!"; NONE) |
73 (Output.urgent_message "No subgoal!"; NONE) |
87 Outer_Syntax.improper_command @{command_spec "try"} |
88 Outer_Syntax.improper_command @{command_spec "try"} |
88 "try a combination of automatic proving and disproving tools" |
89 "try a combination of automatic proving and disproving tools" |
89 (Scan.succeed (Toplevel.unknown_proof o Toplevel.keep (ignore o try_tools o Toplevel.proof_of))) |
90 (Scan.succeed (Toplevel.unknown_proof o Toplevel.keep (ignore o try_tools o Toplevel.proof_of))) |
90 |
91 |
91 |
92 |
92 (* automatic try *) |
93 (* automatic try (TTY) *) |
93 |
94 |
94 fun auto_try state = |
95 fun auto_try state = |
95 get_tools (Proof.theory_of state) |
96 get_tools (Proof.theory_of state) |
96 |> map_filter (fn (_, (_, auto, tool)) => if Options.default_bool auto then SOME tool else NONE) |
97 |> map_filter (fn (_, (_, auto, tool)) => if Options.default_bool auto then SOME tool else NONE) |
97 |> Par_List.get_some (fn tool => |
98 |> Par_List.get_some (fn tool => |
109 handle TimeLimit.TimeOut => state |
110 handle TimeLimit.TimeOut => state |
110 else |
111 else |
111 state |
112 state |
112 end)) |
113 end)) |
113 |
114 |
|
115 |
|
116 (* asynchronous print function (PIDE) *) |
|
117 |
|
118 fun print_function ((name, (weight, auto, tool)): tool) = |
|
119 Command.print_function {name = name, pri = ~ weight, persistent = true} |
|
120 (fn {command_name} => |
|
121 if Keyword.is_theory_goal command_name andalso Options.default_bool auto then |
|
122 SOME (fn _ => fn st => |
|
123 let |
|
124 val auto_time_limit = Options.default_real @{option auto_time_limit} |
|
125 in |
|
126 if auto_time_limit > 0.0 then |
|
127 (case try Toplevel.proof_of st of |
|
128 SOME state => |
|
129 (case |
|
130 (try o TimeLimit.timeLimit (seconds auto_time_limit)) |
|
131 (fn () => tool true state) () of |
|
132 SOME (true, (_, state')) => |
|
133 Pretty.writeln (Pretty.chunks (Proof.pretty_goal_messages state')) |
|
134 | _ => ()) |
|
135 | NONE => ()) |
|
136 else () |
|
137 end) |
|
138 else NONE); |
|
139 |
|
140 |
|
141 (* hybrid tool setup *) |
|
142 |
|
143 fun tool_setup tool = |
|
144 (Context.>> (Context.map_theory (register_tool tool)); print_function tool); |
|
145 |
114 end; |
146 end; |