Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes trivial assertions #1108

Merged
merged 1 commit into from
May 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,12 @@ module SymbolicPrimitives(Machine : Primus.Machine.S) = struct
>>= fun () ->
Val.b1

let assertion_of_value x =
Executor.value x >>| (function
| None -> SMT.word (Primus.Value.to_word x)
| Some x -> x) >>|
SMT.formula ~refute:true

(* we can later add operators that manipulate the scopes
in which the assertion is checked *)
let assert_ name assertions =
Expand All @@ -948,17 +954,12 @@ module SymbolicPrimitives(Machine : Primus.Machine.S) = struct
Constraints.get Context.Scope.path >>= fun path ->
let constraints = Set.to_list @@ Set.union user path in
Machine.List.fold assertions ~init:constraints
~f:(fun constraints assertion ->
Executor.value assertion >>| function
| None -> constraints
| Some expr ->

SMT.formula ~refute:true expr :: constraints) >>|
SMT.check >>= function
~f:(fun constraints x ->
assertion_of_value x >>| fun assertion ->
assertion :: constraints) >>| SMT.check >>= function
| None -> Machine.return ()
| Some model ->
Val.Symbol.of_value name >>= fun name ->
Debug.msg "%s doesn't hold!" name >>= fun () ->
Executor.inputs >>| Seq.to_list >>= fun inputs ->
report (name,model,inputs)) >>= fun () ->
Val.b1
Expand Down