Skip to content

Commit ce8f8ae

Browse files
committed
add a shortcut to avoid checking the false branch on an assume
1 parent 4c5f8e1 commit ce8f8ae

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/symbolic/symbolic_choice.ml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ module Make (Thread : Thread_intf.S) = struct
430430
| `Unknown -> assert false
431431

432432
let select_inner ~explore_first ?(with_breadcrumbs = true)
433-
(cond : Symbolic_value.bool) ~prio_true ~prio_false =
433+
~check_only_true_branch (cond : Symbolic_value.bool) ~prio_true ~prio_false
434+
=
434435
let v = Smtml.Expr.simplify cond in
435436
match Smtml.Expr.view v with
436437
| Val True -> return true
@@ -465,15 +466,21 @@ module Make (Thread : Thread_intf.S) = struct
465466
in
466467

467468
let true_branch = branch v true prio_true in
468-
let false_branch = branch (Symbolic_value.Bool.not v) false prio_false in
469-
let* thread in
470-
Thread.incr_path_count thread;
471-
if explore_first then choose true_branch false_branch
472-
else choose false_branch true_branch
469+
470+
if check_only_true_branch then true_branch
471+
else
472+
let false_branch =
473+
branch (Symbolic_value.Bool.not v) false prio_false
474+
in
475+
let* thread in
476+
Thread.incr_path_count thread;
477+
if explore_first then choose true_branch false_branch
478+
else choose false_branch true_branch
473479
[@@inline]
474480

475481
let select (cond : Symbolic_value.bool) ~prio_true ~prio_false =
476482
select_inner cond ~explore_first:true ~prio_true ~prio_false
483+
~check_only_true_branch:false
477484
[@@inline]
478485

479486
let summary_symbol (e : Smtml.Expr.t) =
@@ -537,6 +544,7 @@ module Make (Thread : Thread_intf.S) = struct
537544
let* assertion_true =
538545
select_inner c ~with_breadcrumbs:false ~explore_first:false
539546
~prio_true:Prio.Default ~prio_false:Prio.Default
547+
~check_only_true_branch:false
540548
in
541549
if assertion_true then return ()
542550
else
@@ -551,10 +559,9 @@ module Make (Thread : Thread_intf.S) = struct
551559

552560
let assume c =
553561
let* assertion_true =
554-
select_inner c ~with_breadcrumbs:false
555-
~explore_first:false
556-
(* TODO: make the prio false very low, we are not interested in such branches *)
562+
select_inner c ~with_breadcrumbs:false ~explore_first:true
557563
~prio_true:Prio.Default ~prio_false:Prio.Default
564+
~check_only_true_branch:true
558565
in
559566
if assertion_true then return () else stop
560567
end

test/replay/assert_false.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
$ owi sym assert_false.wat -w1
22
owi: [ERROR] Assert failure: (i32.lt_u symbol_1 symbol_0)
33
model {
4-
symbol symbol_0 i32 1107329090
5-
symbol symbol_1 i32 -1040154559
4+
symbol symbol_0 i32 134252706
5+
symbol symbol_1 i32 -2013230943
66
}
77
owi: [ERROR] Reached problem!
88
[13]

0 commit comments

Comments
 (0)