-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add goal_when_num and goal_num_ite (#986)
add `goal_num_when` and `goal_num_ite` commands
- Loading branch information
Showing
7 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test.bc : test.c | ||
clang -O0 -c -emit-llvm -o test.bc test.c | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include<stdint.h> | ||
|
||
void g(uint64_t* a) { | ||
*a = 2*(*a); | ||
}; | ||
|
||
void h(uint64_t* a) { | ||
*a = 3*(*a); | ||
}; | ||
|
||
void f(uint64_t* x) { | ||
g(x); | ||
h(x); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
m <- llvm_load_module "test.bc"; | ||
|
||
let f_spec = do { | ||
xp <- llvm_alloc (llvm_int 64); | ||
x <- llvm_fresh_var "x" (llvm_int 64); | ||
llvm_points_to xp (crucible_term x); | ||
llvm_execute_func [xp]; | ||
llvm_points_to xp (crucible_term {{ 6*x }}); | ||
}; | ||
|
||
let g_spec = do { | ||
xp <- llvm_alloc (llvm_int 64); | ||
x <- llvm_fresh_var "x" (llvm_int 64); | ||
llvm_points_to xp (crucible_term x); | ||
llvm_execute_func [xp]; | ||
llvm_points_to xp (crucible_term {{(2*x):[64]}}); | ||
}; | ||
|
||
let h_spec = do { | ||
xp <- llvm_alloc (llvm_int 64); | ||
x <- llvm_fresh_var "x" (llvm_int 64); | ||
llvm_points_to xp (crucible_term {{x}}); | ||
llvm_precond {{ x > 1 }}; | ||
llvm_execute_func [xp]; | ||
llvm_points_to xp (crucible_term {{(3*x):[64]}}); | ||
}; | ||
|
||
g_ov <- llvm_verify m "g" [] false g_spec z3; | ||
h_ov <- llvm_verify m "h" [] false h_spec z3; | ||
|
||
enable_experimental; | ||
|
||
// we get two verification conditions: on for the precondition of h, and one for the postcondition of f | ||
// the override precondition of h is violated, but if we assume it's unsat then verification succeeds: | ||
llvm_verify m "f" [g_ov, h_ov] false f_spec | ||
(goal_num_ite 0 | ||
assume_unsat | ||
w4); | ||
|
||
// on the other hand, if we provide the wrong goal number, then it fails. | ||
fails ( | ||
llvm_verify m "f" [g_ov, h_ov] false f_spec | ||
(goal_num_ite 1 | ||
assume_unsat | ||
w4) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
set -e | ||
|
||
$SAW test.saw | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters