-
Notifications
You must be signed in to change notification settings - Fork 63
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
add goal_when_num and goal_num_ite #986
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit:
goal_num_when
, consistent withgoal_num_ite