36 val assert_forward_or_chain: state -> state |
36 val assert_forward_or_chain: state -> state |
37 val assert_backward: state -> state |
37 val assert_backward: state -> state |
38 val assert_no_chain: state -> state |
38 val assert_no_chain: state -> state |
39 val enter_forward: state -> state |
39 val enter_forward: state -> state |
40 val verbose: bool ref |
40 val verbose: bool ref |
41 val print_state: int -> state -> unit |
41 val pretty_state: int -> state -> Pretty.T list |
42 val pretty_goals: bool -> state -> Pretty.T list |
42 val pretty_goals: bool -> state -> Pretty.T list |
43 val level: state -> int |
43 val level: state -> int |
44 type method |
44 type method |
45 val method: (thm list -> tactic) -> method |
45 val method: (thm list -> tactic) -> method |
46 val method_cases: (thm list -> thm -> (thm * (string * RuleCases.T) list) Seq.seq) -> method |
46 val method_cases: (thm list -> thm -> (thm * (string * RuleCases.T) list) Seq.seq) -> method |
321 fun close_block (state as State (_, node :: nodes)) = State (node, nodes) |
321 fun close_block (state as State (_, node :: nodes)) = State (node, nodes) |
322 | close_block state = raise STATE ("Unbalanced block parentheses", state); |
322 | close_block state = raise STATE ("Unbalanced block parentheses", state); |
323 |
323 |
324 |
324 |
325 |
325 |
326 (** print_state **) |
326 (** pretty_state **) |
327 |
327 |
328 val verbose = ProofContext.verbose; |
328 val verbose = ProofContext.verbose; |
329 |
329 |
330 fun pretty_goals_local ctxt = Display.pretty_goals_aux |
330 fun pretty_goals_local ctxt = Display.pretty_goals_aux |
331 (ProofContext.pretty_sort ctxt, ProofContext.pretty_typ ctxt, ProofContext.pretty_term ctxt); |
331 (ProofContext.pretty_sort ctxt, ProofContext.pretty_typ ctxt, ProofContext.pretty_term ctxt); |
332 |
332 |
333 fun pretty_facts _ _ None = [] |
333 fun pretty_facts _ _ None = [] |
334 | pretty_facts s ctxt (Some ths) = |
334 | pretty_facts s ctxt (Some ths) = |
335 [Pretty.big_list (s ^ "this:") (map (ProofContext.pretty_thm ctxt) ths), Pretty.str ""]; |
335 [Pretty.big_list (s ^ "this:") (map (ProofContext.pretty_thm ctxt) ths), Pretty.str ""]; |
336 |
336 |
337 fun print_state nr (state as State (Node {context = ctxt, facts, mode, goal = _}, nodes)) = |
337 fun pretty_state nr (state as State (Node {context = ctxt, facts, mode, goal = _}, nodes)) = |
338 let |
338 let |
339 val ref (_, _, begin_goal) = Display.current_goals_markers; |
339 val ref (_, _, begin_goal) = Display.current_goals_markers; |
340 |
340 |
341 fun levels_up 0 = "" |
341 fun levels_up 0 = "" |
342 | levels_up 1 = ", 1 level up" |
342 | levels_up 1 = ", 1 level up" |
370 (if null ctxt_prts then [] else ctxt_prts @ [Pretty.str ""]) @ |
370 (if null ctxt_prts then [] else ctxt_prts @ [Pretty.str ""]) @ |
371 (if ! verbose orelse mode = Forward then |
371 (if ! verbose orelse mode = Forward then |
372 (pretty_facts "" ctxt facts @ prt_goal (find_goal state)) |
372 (pretty_facts "" ctxt facts @ prt_goal (find_goal state)) |
373 else if mode = ForwardChain then pretty_facts "picking " ctxt facts |
373 else if mode = ForwardChain then pretty_facts "picking " ctxt facts |
374 else prt_goal (find_goal state)) |
374 else prt_goal (find_goal state)) |
375 in Pretty.writeln (Pretty.chunks prts) end; |
375 in prts end; |
376 |
376 |
377 fun pretty_goals main state = |
377 fun pretty_goals main state = |
378 let val (ctxt, (_, ((_, (_, thm)), _))) = find_goal state |
378 let val (ctxt, (_, ((_, (_, thm)), _))) = find_goal state |
379 in pretty_goals_local ctxt "" (false, main) (! Display.goals_limit) thm end; |
379 in pretty_goals_local ctxt "" (false, main) (! Display.goals_limit) thm end; |
380 |
380 |