Skip to content

Commit

Permalink
Fix evaluation of goals
Browse files Browse the repository at this point in the history
  • Loading branch information
Gbury committed Sep 10, 2024
1 parent 0161bf4 commit 76fb043
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@

next
----

### Models

- Fix a bug where the condition on evaluated goals was incorrect.
This should not affect any current use, since only SMT-LIB2 model
verification is supported and it does not have goals.


v0.10
-----

Expand Down
15 changes: 7 additions & 8 deletions src/model/loop.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ let bad_model =
match kind with
| `Hyp ->
Format.fprintf fmt "This hypothesis/assertion evaluates to false"
| `Goals evaluated_goals ->
| `Goal true_goal ->
Format.fprintf fmt
"@[<v>All of the goals at the following locations evaluated to false:@ %a@]"
Fmt.(list pp_located) evaluated_goals
"@[<v>The goal at the following location evaluated to true:@ %a@]"
pp_located true_goal
| `Clause ->
Format.fprintf fmt "This assumed clause evaluates to false")
~name:"Incorrect model" ()
Expand Down Expand Up @@ -686,11 +686,10 @@ module Make
let _ = eval_acc_direct ~reraise:false st model delayed evaluated_goals acc in
assert false
end else begin
(* **3** Lastly check that at least one goal evaluated to "true" *)
match evaluated_goals with
| [] -> st
| l when List.exists (fun { contents; _ } -> contents) l -> st
| l -> State.error ~file ~loc st bad_model (`Goals l)
(* **3** Lastly check that all goals evaluated to "false" *)
match List.find_opt (fun { contents; _ } -> contents) evaluated_goals with
| None -> st
| Some g -> State.error ~file ~loc st bad_model (`Goal g)
end
| _ -> st
in
Expand Down
21 changes: 21 additions & 0 deletions tests/model/goals/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; File auto-generated by gentests.ml

; Auto-generated part begin
; Test for foo.ae
; Full mode test

(rule
(target foo.full)
(deps (:response foo.rsmt2) (:input foo.ae))
(package dolmen_bin)
(action (chdir %{workspace_root}
(with-outputs-to %{target}
(with-accepted-exit-codes (or 0 (not 0))
(run dolmen --check-model=true -r %{response} --mode=full --color=never %{input} %{read-lines:flags.dune}))))))
(rule
(alias runtest)
(package dolmen_bin)
(action (diff foo.expected foo.full)))


; Auto-generated part end
Empty file added tests/model/goals/flags.dune
Empty file.
7 changes: 7 additions & 0 deletions tests/model/goals/foo.ae
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

logic x : int

goal g : false



Empty file added tests/model/goals/foo.expected
Empty file.
2 changes: 2 additions & 0 deletions tests/model/goals/foo.rsmt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sat
()
2 changes: 1 addition & 1 deletion tools/gentests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let expected_of_problem file =

let response_of_problem file =
match Filename.extension file with
| ".smt2" -> Some (Filename.chop_extension file ^ ".rsmt2")
| ".smt2" | ".ae" -> Some (Filename.chop_extension file ^ ".rsmt2")
| _ -> None

let supports_incremental file =
Expand Down

0 comments on commit 76fb043

Please sign in to comment.