Skip to content

Commit fbaf190

Browse files
authored
fixes trivial assertions (#1108)
If an assertion doesn't contain a symbolic value then we were having an empty set of constraints, which trivially were true. In other words, `assert true` doesn't hold. This PR fixes this by treating non-symbolic values as symbolic constants.
1 parent 5a98402 commit fbaf190

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

plugins/primus_symbolic_executor/primus_symbolic_executor_main.ml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,12 @@ module SymbolicPrimitives(Machine : Primus.Machine.S) = struct
940940
>>= fun () ->
941941
Val.b1
942942

943+
let assertion_of_value x =
944+
Executor.value x >>| (function
945+
| None -> SMT.word (Primus.Value.to_word x)
946+
| Some x -> x) >>|
947+
SMT.formula ~refute:true
948+
943949
(* we can later add operators that manipulate the scopes
944950
in which the assertion is checked *)
945951
let assert_ name assertions =
@@ -948,17 +954,12 @@ module SymbolicPrimitives(Machine : Primus.Machine.S) = struct
948954
Constraints.get Context.Scope.path >>= fun path ->
949955
let constraints = Set.to_list @@ Set.union user path in
950956
Machine.List.fold assertions ~init:constraints
951-
~f:(fun constraints assertion ->
952-
Executor.value assertion >>| function
953-
| None -> constraints
954-
| Some expr ->
955-
956-
SMT.formula ~refute:true expr :: constraints) >>|
957-
SMT.check >>= function
957+
~f:(fun constraints x ->
958+
assertion_of_value x >>| fun assertion ->
959+
assertion :: constraints) >>| SMT.check >>= function
958960
| None -> Machine.return ()
959961
| Some model ->
960962
Val.Symbol.of_value name >>= fun name ->
961-
Debug.msg "%s doesn't hold!" name >>= fun () ->
962963
Executor.inputs >>| Seq.to_list >>= fun inputs ->
963964
report (name,model,inputs)) >>= fun () ->
964965
Val.b1

0 commit comments

Comments
 (0)