287 |
287 |
288 val verbose = ProofContext.verbose; |
288 val verbose = ProofContext.verbose; |
289 |
289 |
290 fun print_facts _ None = () |
290 fun print_facts _ None = () |
291 | print_facts s (Some ths) = |
291 | print_facts s (Some ths) = |
292 Pretty.writeln (Pretty.big_list (s ^ " facts:") (map pretty_thm ths)); |
292 (Pretty.writeln (Pretty.big_list (s ^ "this:") (map pretty_thm ths)); writeln ""); |
293 |
293 |
294 fun print_state nr (state as State (Node {context, facts, mode, goal = _}, nodes)) = |
294 fun print_state nr (state as State (Node {context, facts, mode, goal = _}, nodes)) = |
295 let |
295 let |
296 val ref (_, _, begin_goal) = Goals.current_goals_markers; |
296 val ref (_, _, begin_goal) = Goals.current_goals_markers; |
297 |
297 |
298 fun levels_up 0 = "" |
298 fun levels_up 0 = "" |
299 | levels_up 1 = " (1 level up)" |
299 | levels_up 1 = ", 1 level up" |
300 | levels_up i = " (" ^ string_of_int i ^ " levels up)"; |
300 | levels_up i = ", " ^ string_of_int i ^ " levels up"; |
301 |
301 |
302 fun print_goal (_, (i, (((kind, name, _), (goal_facts, thm)), _))) = |
302 fun print_goal (_, (i, (((kind, name, _), (goal_facts, thm)), _))) = |
303 (print_facts "Using" |
303 (print_facts "using " |
304 (if mode <> Backward orelse null goal_facts then None else Some goal_facts); |
304 (if mode <> Backward orelse null goal_facts then None else Some goal_facts); |
305 writeln (kind_name kind ^ " " ^ quote name ^ levels_up (i div 2) ^ ":"); |
305 writeln ("goal (" ^ kind_name kind ^ (if name = "" then "" else " " ^ name) ^ |
|
306 levels_up (i div 2) ^ "):"); |
306 Locale.print_goals_marker begin_goal (! goals_limit) thm); |
307 Locale.print_goals_marker begin_goal (! goals_limit) thm); |
307 |
308 |
308 val ctxt_strings = ProofContext.strings_of_context context; |
309 val ctxt_strings = |
|
310 if ! verbose orelse mode = Forward then ProofContext.strings_of_context context |
|
311 else if mode = Backward then ProofContext.strings_of_prems context |
|
312 else []; |
309 in |
313 in |
310 writeln ("Proof(" ^ mode_name mode ^ "): step " ^ string_of_int nr ^ |
314 writeln ("Proof(" ^ mode_name mode ^ "): step " ^ string_of_int nr ^ |
311 ", depth " ^ string_of_int (length nodes div 2)); |
315 ", depth " ^ string_of_int (length nodes div 2)); |
312 writeln ""; |
316 writeln ""; |
|
317 if null ctxt_strings then () else (seq writeln ctxt_strings; writeln ""); |
313 if ! verbose orelse mode = Forward then |
318 if ! verbose orelse mode = Forward then |
314 (if null ctxt_strings then () else (seq writeln ctxt_strings; writeln ""); |
319 (print_facts "" facts; print_goal (find_goal 0 state)) |
315 print_facts "Current" facts; |
320 else if mode = ForwardChain then print_facts "picking " facts |
316 print_goal (find_goal 0 state)) |
|
317 else if mode = ForwardChain then print_facts "Picking" facts |
|
318 else print_goal (find_goal 0 state) |
321 else print_goal (find_goal 0 state) |
319 end; |
322 end; |
320 |
323 |
321 |
324 |
322 |
325 |