This repository has been archived by the owner on Oct 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The assertion in the divbin program is violable hence changed the
verdict of the program. Also adding the corrected program divbin2 with verifiable assertion.
- Loading branch information
1 parent
1ca0202
commit 0f331e9
Showing
4 changed files
with
89 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
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,48 @@ | ||
/* | ||
A division algorithm, by Kaldewaij | ||
returns A//B | ||
*/ | ||
|
||
#include <limits.h> | ||
|
||
extern void __VERIFIER_error() __attribute__((__noreturn__)); | ||
extern unsigned __VERIFIER_nondet_unsigned_int(void); | ||
extern void __VERIFIER_assume(int expression); | ||
void __VERIFIER_assert(int cond) { | ||
if (!(cond)) { | ||
ERROR: | ||
__VERIFIER_error(); | ||
} | ||
return; | ||
} | ||
|
||
int main() { | ||
unsigned A, B; | ||
unsigned q, r, b; | ||
A = __VERIFIER_nondet_unsigned_int(); | ||
B = 1; | ||
|
||
q = 0; | ||
r = A; | ||
b = B; | ||
|
||
while (1) { | ||
if (!(r >= b)) break; | ||
b = 2 * b; | ||
} | ||
|
||
while (1) { | ||
__VERIFIER_assert(A == q * b + r); | ||
if (!(b != B)) break; | ||
|
||
q = 2 * q; | ||
b = b / 2; | ||
if (r >= b) { | ||
q = q + 1; | ||
r = r - b; | ||
} | ||
} | ||
|
||
__VERIFIER_assert(A == q * b + r); | ||
return 0; | ||
} |
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,35 @@ | ||
extern void __VERIFIER_error() __attribute__((__noreturn__)); | ||
extern unsigned __VERIFIER_nondet_unsigned_int(void); | ||
extern void __VERIFIER_assume(int expression); | ||
void __VERIFIER_assert(int cond) { | ||
if (!(cond)) { | ||
ERROR: | ||
__VERIFIER_error(); | ||
} | ||
return; | ||
} | ||
int main() { | ||
unsigned A, B; | ||
unsigned q, r, b; | ||
A = __VERIFIER_nondet_unsigned_int(); | ||
B = 1; | ||
q = 0; | ||
r = A; | ||
b = B; | ||
while (1) { | ||
if (!(r >= b)) break; | ||
b = 2 * b; | ||
} | ||
while (1) { | ||
__VERIFIER_assert(A == q * b + r); | ||
if (!(b != B)) break; | ||
q = 2 * q; | ||
b = b / 2; | ||
if (r >= b) { | ||
q = q + 1; | ||
r = r - b; | ||
} | ||
} | ||
__VERIFIER_assert(A == q * b + r); | ||
return 0; | ||
} |
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,5 @@ | ||
format_version: '1.0' | ||
input_files: 'divbin2.i' | ||
properties: | ||
- property_file: ../properties/unreach-call.prp | ||
expected_verdict: true |