-
Notifications
You must be signed in to change notification settings - Fork 19
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
Simplify file #310
Simplify file #310
Conversation
src/libc/src/test-comp.c
Outdated
@@ -2,7 +2,7 @@ | |||
|
|||
_Bool __VERIFIER_nondet_bool(void) { | |||
_Bool var = owi_i32(); | |||
owi_assume(or_(var == 0, var == 1)); | |||
owi_assume(var == 0 || var == 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filipeom, I thought we were not using or_
and and_
anymore but actually we are using it there, do you think this is going to have a negative impact in some way to change it like this ? Maybe, we could also expose a owi_bool()
function instead, what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will depend on how the compiler decides to compile this. But most likely it will try to lazy evaluate the condition, possibly causing unnecessary branches. Creating a owi_bool
is cleaner. But, using a bitwise-or or chaining two owi_assume
would most-likely also work to reduce branching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Laplace-Demon, do you want to try to add a owi_bool
function ?
1b36ab7
to
e99e9f1
Compare
@Laplace-Demon oops, I meant, removed from the |
dw, it's fixed |
@Laplace-Demon, could you rebase this one so I can re-run the CI now that is has been fixed ? |
src/symbolic/symbolic_wasm_ffi.ml
Outdated
let symbol_bool () = | ||
let open Choice in | ||
let+ sym = symbol Ty_bool () in | ||
Expr.make (Cvtop (Ty_bool, Smtml.Ty.OfBool, sym)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need the following patch after rebasing to get the code to compile:
diff --git a/src/symbolic/symbolic_wasm_ffi.ml b/src/symbolic/symbolic_wasm_ffi.ml
index 3f4ed0b2..4ad1ba33 100644
--- a/src/symbolic/symbolic_wasm_ffi.ml
+++ b/src/symbolic/symbolic_wasm_ffi.ml
@@ -40,9 +40,7 @@ module M :
let symbol_f64 () = Choice.with_new_symbol (Ty_fp 64) Expr.symbol
let symbol_bool () =
- let open Choice in
- let+ sym = symbol Ty_bool () in
- Expr.make (Cvtop (Ty_bool, Smtml.Ty.OfBool, sym))
+ Choice.with_new_symbol Ty_bool Expr.symbol
open Expr
I started a benchmark to check if the boolean stuff makes any difference, it's in Results: Run 1216/1216: testcomp/sv-benchmarks/c/xcsp/aim-200-6-0-sat-4.c
Timeout in 30.0612 260.387 260.013
Nothing: 75 Reached: 560 Timeout: 469 Other: 112 Killed: 0 I'll investigate the |
@filipeom, I'm getting a lot of: owi: internal error, uncaught exception:
Z3.Error("Sorts Bool and (_ BitVec 32) are incompatible") Is my suggested patch incorrect ? 😅 |
…bol for the time being
0a8a28a
to
011692f
Compare
It's most likely because of owi/src/symbolic/symbolic_value.ml Lines 192 to 196 in 10b939f
diff --git a/src/symbolic/symbolic_value.ml b/src/symbolic/symbolic_value.ml
index d32f69fd..ed50be17 100644
--- a/src/symbolic/symbolic_value.ml
+++ b/src/symbolic/symbolic_value.ml
@@ -192,6 +192,7 @@ module I32 = struct
let to_bool (e : vbool) =
match view e with
| Val (Num (I32 i)) -> Bool.const @@ Int32.ne i 0l
+ | Symbol { ty = Ty_bool; _ } -> e
| Cvtop (_, OfBool, cond) -> cond
| _ -> make (Cvtop (ty, ToBool, e)) But, I'm not sure this is enough. I need to play around with this and most likely fix it directly in `smtml. |
OK, I'll wait then. If you want to find a reproduction case, you can look on the server with the results mentioned earlier. Then look at which tests are causing |
@Laplace-Demon, actually, maybe we could do a first PR without the |
Yes, I'm checking it out 😄 |
Ok so instead of this #310 (comment) We should use the following patch instead: diff --git a/src/cmd/cmd_utils.ml b/src/cmd/cmd_utils.ml
index be7ac19d..e9fb3d1d 100644
--- a/src/cmd/cmd_utils.ml
+++ b/src/cmd/cmd_utils.ml
@@ -8,7 +8,7 @@ let out_testcase ~dst testcase =
let o = Xmlm.make_output ~nl:true ~indent:(Some 2) dst in
let tag atts name = (("", name), atts) in
let atts = [ (("", "coversError"), "true") ] in
- let to_string v = Format.asprintf "%a" Smtml.Value.pp_num v in
+ let to_string v = Format.asprintf "%a" Smtml.Value.pp v in
let input v = `El (tag [] "input", [ `Data (to_string v) ]) in
let testcase = `El (tag atts "testcase", List.map input testcase) in
let dtd =
diff --git a/src/symbolic/symbolic_wasm_ffi.ml b/src/symbolic/symbolic_wasm_ffi.ml
index 3f4ed0b2..8eaee478 100644
--- a/src/symbolic/symbolic_wasm_ffi.ml
+++ b/src/symbolic/symbolic_wasm_ffi.ml
@@ -40,9 +40,8 @@ module M :
let symbol_f64 () = Choice.with_new_symbol (Ty_fp 64) Expr.symbol
let symbol_bool () =
- let open Choice in
- let+ sym = symbol Ty_bool () in
- Expr.make (Cvtop (Ty_bool, Smtml.Ty.OfBool, sym))
+ Choice.with_new_symbol (Ty_bitv 1) (fun sym ->
+ Expr.cvtop (Ty_bitv 32) (Smtml.Ty.Zero_extend 31) (Expr.symbol sym) )
open Expr
And the latest version of formalsec/smtml#179. But we should probably do this in another PR instead |
Yes you have raison :) |
src/libc/src/owi.c
Outdated
"i32.ne;" | ||
"i32.and;" | ||
"return;"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can still remove and_
and only keep or_
. :)
EDIT: you could actually remove both and inline the definition of or_
inside the definition of _Bool __VERIFIER_nondet_bool(void)
Thanks! |
No description provided.