Skip to content
Snippets Groups Projects
Commit 264d6732 authored by Michele Alberti's avatar Michele Alberti
Browse files

Avoid to index subgoals when not needed.

parent 712afe63
No related branches found
No related tags found
No related merge requests found
...@@ -18,8 +18,9 @@ type task = { ...@@ -18,8 +18,9 @@ type task = {
(* Original goal name. *) (* Original goal name. *)
goalname: string; goalname: string;
(* Subgoal identifier. (* Subgoal identifier.
Typically a goal is translated to multiple subgoals by a solver. *) Typically a goal is translated to multiple subgoals by a solver.
subgoal: int; [None] means the goal has no subgoals. *)
subgoal: int option;
(* The formula to verify. *) (* The formula to verify. *)
formula: string; formula: string;
(* Verification result. (* Verification result.
...@@ -70,6 +71,20 @@ let check_compatibility solver model = ...@@ -70,6 +71,20 @@ let check_compatibility solver model =
let tasks_of_property solver { axioms; goals } = let tasks_of_property solver { axioms; goals } =
let module S = (val solver: Solver.S) in let module S = (val solver: Solver.S) in
let make_task goalname subgoal formula =
let id =
Format.sprintf "%s%s"
goalname
(Option.value_map subgoal
~default:""
~f:(fun idx -> Format.sprintf ".%d" idx))
in
{ id;
goalname;
subgoal;
formula = Format.asprintf "%a" S.pretty formula;
result = None; }
in
let hypothesis = let hypothesis =
match axioms with match axioms with
| [] -> | [] ->
...@@ -86,14 +101,9 @@ let tasks_of_property solver { axioms; goals } = ...@@ -86,14 +101,9 @@ let tasks_of_property solver { axioms; goals } =
~f:(fun { name; formula; } -> ~f:(fun { name; formula; } ->
let elts = S.(repr (translate ~hypothesis ~goal:formula)) in let elts = S.(repr (translate ~hypothesis ~goal:formula)) in
let tasks = let tasks =
List.mapi if List.length elts = 1
elts then [ make_task name None (List.hd_exn elts) ]
~f:(fun idx elt -> else List.mapi elts ~f:(fun idx elt -> make_task name (Some idx) elt)
{ id = Format.sprintf "%s.%d" name idx;
goalname = name;
subgoal = idx;
formula = Format.asprintf "%a" S.pretty elt;
result = None; })
in in
Hashtbl.set table ~key:name ~data:tasks); Hashtbl.set table ~key:name ~data:tasks);
table table
...@@ -174,8 +184,13 @@ let exec_tasks ~raw_options solver config model tasks_htbl = ...@@ -174,8 +184,13 @@ let exec_tasks ~raw_options solver config model tasks_htbl =
tasks tasks
~f:(fun task -> ~f:(fun task ->
Logs.app (fun m -> Logs.app (fun m ->
m "Verifying goal `%s', subgoal %d (%s)." m "Verifying goal `%s'%s."
task.goalname task.subgoal task.id); task.goalname
(Option.value_map task.subgoal
~default:""
~f:(fun subgoal ->
Format.sprintf ", subgoal %d (%s)"
subgoal task.id)));
let res_exec_task = let res_exec_task =
(* Build the required command-line. *) (* Build the required command-line. *)
build_command ~raw_options solver config model task build_command ~raw_options solver config model task
...@@ -190,7 +205,7 @@ let exec_tasks ~raw_options solver config model tasks_htbl = ...@@ -190,7 +205,7 @@ let exec_tasks ~raw_options solver config model tasks_htbl =
else begin else begin
(* Extract and pretty-print verification result. *) (* Extract and pretty-print verification result. *)
let result = extract_result solver ~log ~output in let result = extract_result solver ~log ~output in
Logs.app (fun m -> m "Result %s: %a." Logs.app (fun m -> m "Result of `%s': %a."
task.id Solver.Result.pretty result); task.id Solver.Result.pretty result);
Sys.remove output; Sys.remove output;
if Solver.Result.equal result Solver.Result.Failure if Solver.Result.equal result Solver.Result.Failure
......
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