Skip to content
Snippets Groups Projects
Commit ee021c67 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[wp/gui] fix tree node feedback

parent d6fbd57a
No related branches found
No related tags found
No related merge requests found
...@@ -26,12 +26,10 @@ let rec rootchain node ns = ...@@ -26,12 +26,10 @@ let rec rootchain node ns =
| Some p -> rootchain p (p::ns) | Some p -> rootchain p (p::ns)
let pp_status fmt node = let pp_status fmt node =
match ProofEngine.state node with match ProofEngine.pending node with
| `Opened -> Format.fprintf fmt "@{<red>opened@}" | 0 -> Format.fprintf fmt "@{<green>proved@}"
| `Proved | `Pending 0 -> Format.fprintf fmt "@{<green>proved@}" | 1 -> Format.fprintf fmt "@{<orange>pending@}"
| `Pending 1 -> Format.fprintf fmt "@{<orange>pending@}" | n -> Format.fprintf fmt "@{<orange>pending %d@}" n
| `Pending n -> Format.fprintf fmt "@{<orange>pending %d@}" n
| `Script n -> Format.fprintf fmt "script with %d leaves" n
class printer (text : Wtext.text) = class printer (text : Wtext.text) =
let nodes : ProofEngine.position Wtext.marker = text#marker in let nodes : ProofEngine.position Wtext.marker = text#marker in
...@@ -66,36 +64,25 @@ class printer (text : Wtext.text) = ...@@ -66,36 +64,25 @@ class printer (text : Wtext.text) =
VCS.pp_prover prv VCS.pp_result res VCS.pp_prover prv VCS.pp_result res
) (Wpo.get_results wpo) ) (Wpo.get_results wpo)
method private pp_state fmt node =
match ProofEngine.state node with
| `Proved -> Format.pp_print_string fmt "proved"
| `Opened -> Format.pp_print_string fmt "opened"
| `Pending 0 -> Format.pp_print_string fmt "terminated"
| `Pending 1 -> Format.pp_print_string fmt "pending"
| `Pending n -> Format.fprintf fmt "pending(%d)" n
| `Script 0 -> Format.pp_print_string fmt "script"
| `Script n -> Format.fprintf fmt "script(%d)" n
method private tactic header node = method private tactic header node =
text#printf "@{<bf>Tactical@}@} %s:" header ;
match ProofEngine.children node with match ProofEngine.children node with
| [] -> | [] ->
text#printf "@{<bf>Tactical@}@} %s: @{<green>proved@} (Qed).@\n" header text#printf "@{<green>proved@} (Qed).@\n"
| [_,child] -> | [_,child] ->
text#printf "@{<bf>Tactical@} %a: %a.@\n" self#pp_node child self#pp_state child text#printf "%a (%a).@\n" pp_status child self#pp_node child
| children -> | children ->
begin match ProofEngine.pending node with begin
| 0 -> text#printf "@{<green>@{<bf>Tactical@}@} %s: @{<green>proved@}.@\n" header text#printf " (%a)@\n@{<bf>Sub Goals:@}" pp_status node ;
| 1 -> text#printf "@{<bf>Tactical@} %s: @{<orange>pending@}.@\n" header ; List.iter
| n -> text#printf "@{<bf>Tactical@} %s: @{<orange>pending(%d)@}.@\n" header n ; (fun (part,child) -> text#printf "@\n - %s : %a" part pp_status child)
end ; children ;
List.iter text#printf "@." ;
(fun (part,child) -> text#printf "@{<bf>SubGoal@} %s : %a.@\n" end
part self#pp_state child)
children
method private alternative g a = method private alternative g a =
let open ProofScript in match a with let open ProofScript in match a with
| Tactic(0,{ header },_) -> text#printf "@{<bf>Script@} %s: terminating.@\n" header | Tactic(0,{ header },_) -> text#printf "@{<bf>Script@} %s: finished.@\n" header
| Tactic(n,{ header },_) -> text#printf "@{<bf>Script@} %s: pending %d.@\n" header n | Tactic(n,{ header },_) -> text#printf "@{<bf>Script@} %s: pending %d.@\n" header n
| Error(msg,_) -> text#printf "@{<bf>Script@} Error (%S).@\n" msg | Error(msg,_) -> text#printf "@{<bf>Script@} Error (%S).@\n" msg
| Prover(p,r) -> | Prover(p,r) ->
......
...@@ -206,33 +206,15 @@ let children n = ...@@ -206,33 +206,15 @@ let children n =
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
type status = [ `Main | `Proved | `Pending of int ] type status = [ `Main | `Proved | `Pending of int ]
type state = [ `Opened | `Proved | `Pending of int | `Script of int ]
let status t : status = let status t : status =
match t.root with match t.root with
| None -> | None ->
if Wpo.is_proved t.main then `Proved else `Main if Wpo.is_proved t.main then `Proved else `Main
| Some root -> | Some root ->
`Pending (pending root) match root.script with
| Opened | Script _ -> `Main
| Tactic _ -> `Pending (pending root)
let opened n = not (Wpo.is_proved n.goal)
let state n =
if Wpo.is_proved n.goal then `Proved else
match n.script with
| Opened -> `Opened
| Script s ->
begin
match List.partition ProofScript.is_prover s with
| [] , s -> `Script (ProofScript.status s)
| p , [] -> `Pending (ProofScript.status p)
| provers , scripts ->
let np = ProofScript.status provers in
let ns = ProofScript.status scripts in
`Script( min ns np )
end
| Tactic _ -> `Pending (pending n)
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
(* --- Navigation --- *) (* --- Navigation --- *)
......
...@@ -36,7 +36,6 @@ val validate : ?incomplete:bool -> tree -> unit ...@@ -36,7 +36,6 @@ val validate : ?incomplete:bool -> tree -> unit
(** Leaves are numbered from 0 to n-1 *) (** Leaves are numbered from 0 to n-1 *)
type status = [ `Main | `Proved | `Pending of int ] type status = [ `Main | `Proved | `Pending of int ]
type state = [ `Opened | `Proved | `Pending of int | `Script of int ]
type current = [ `Main | `Internal of node | `Leaf of int * node ] type current = [ `Main | `Internal of node | `Leaf of int * node ]
type position = [ `Main | `Node of node | `Leaf of int ] type position = [ `Main | `Node of node | `Leaf of int ]
...@@ -53,13 +52,11 @@ val head : tree -> Wpo.t ...@@ -53,13 +52,11 @@ val head : tree -> Wpo.t
val goal : node -> Wpo.t val goal : node -> Wpo.t
val tree_context : tree -> WpContext.t val tree_context : tree -> WpContext.t
val node_context : node -> WpContext.t val node_context : node -> WpContext.t
val opened : node -> bool (** not proved *)
val proved : node -> bool (** not opened *)
val title : node -> string val title : node -> string
val state : node -> state val proved : node -> bool
val pending : node -> int (** 0 means proved *)
val parent : node -> node option val parent : node -> node option
val pending : node -> int
val children : node -> (string * node) list val children : node -> (string * node) list
val tactical : node -> ProofScript.jtactic option val tactical : node -> ProofScript.jtactic option
val get_strategies : node -> int * Strategy.t array (* current index *) val get_strategies : node -> int * Strategy.t array (* current index *)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment