-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bf4994
commit 608a536
Showing
11 changed files
with
147 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
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,4 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
script: gen_boogie_and_dump.sh | ||
expected: expected |
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,7 @@ | ||
procedure | ||
var x: bv32; | ||
var y: bv32; | ||
x := 1bv32; | ||
y := x; | ||
x := 2bv32; | ||
assert |
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,13 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
set +e | ||
|
||
# Delete any leftover Boogie files | ||
rm *.bpl | ||
|
||
echo "[TEST] Run verification..." | ||
kani -Zboogie test.rs | ||
|
||
cat *.bpl |
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,38 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
//! A simple test that checks that assignment statements and asserts are | ||
//! translated to Boogie correctly. | ||
//! | ||
//! The `expected` file checks some elements of the expected output Boogie. | ||
//! | ||
//! This is a possible Boogie output (which may change with MIR changes): | ||
//! ``` | ||
//! // Procedures: | ||
//! procedure _RNvCshNorBqfmMTU_4test19check_assign_assert() | ||
//! { | ||
//! var x: bv32; | ||
//! var y: bv32; | ||
//! var _4: bool; | ||
//! var _5: bv32; | ||
//! var _7: bool; | ||
//! x := 1bv32; | ||
//! y := x; | ||
//! x := 2bv32; | ||
//! _5 := x; | ||
//! _4 := (_5 == 2bv32); | ||
//! assert _4; | ||
//! _7 := (y == 1bv32); | ||
//! assert _7; | ||
//! return; | ||
//! } | ||
//! ``` | ||
|
||
#[kani::proof] | ||
fn check_assign_assert() { | ||
let mut x = 1; | ||
let y = x; | ||
x = 2; | ||
kani::assert(x == 2, ""); | ||
kani::assert(y == 1, ""); | ||
} |
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 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
script: gen_boogie_and_dump.sh | ||
expected: expected |
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,19 @@ | ||
function {:bvbuiltin "bvslt"} $BvSignedLessThan<T>(lhs: T, rhs: T) returns (bool); | ||
|
||
function {:bvbuiltin "bvsgt"} $BvSignedGreaterThan<T>(lhs: T, rhs: T) returns (bool); | ||
|
||
function {:bvbuiltin "bvor"} $BvOr<T>(lhs: T, rhs: T) returns (T); | ||
|
||
procedure | ||
var _1: bv32; | ||
var _2: bv32; | ||
var _4: bool; | ||
var z: bv32; | ||
var _7: bool; | ||
_1 := 1bv32; | ||
_2 := 2bv32; | ||
_4 := $BvSignedGreaterThan(_2, _1); | ||
assert _4; | ||
z := $BvOr(_1, _2); | ||
_7 := $BvSignedLessThan(_1, z); | ||
assert _7; |
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,13 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
set +e | ||
|
||
# Delete any leftover Boogie files | ||
rm *.bpl | ||
|
||
echo "[TEST] Run verification..." | ||
kani -Zboogie test.rs | ||
|
||
cat *.bpl |
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,44 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
//! A simple test that checks that binary operations are translated to a | ||
//! function call to an SMT bv operator | ||
//! | ||
//! The `expected` file checks some elements of the expected output Boogie. | ||
//! | ||
//! This is a possible Boogie output (which may change with MIR changes): | ||
//! ``` | ||
//! function {:bvbuiltin "bvslt"} $BvSignedLessThan<T>(lhs: T, rhs: T) returns (bool); | ||
//! | ||
//! function {:bvbuiltin "bvsgt"} $BvSignedGreaterThan<T>(lhs: T, rhs: T) returns (bool); | ||
//! | ||
//! function {:bvbuiltin "bvor"} $BvOr<T>(lhs: T, rhs: T) returns (T); | ||
//! | ||
//! // Procedures: | ||
//! procedure _RNvCshNorBqfmMTU_4test14check_binop_gt() | ||
//! { | ||
//! var _1: bv32; | ||
//! var _2: bv32; | ||
//! var _4: bool; | ||
//! var z: bv32; | ||
//! var _7: bool; | ||
//! _1 := 1bv32; | ||
//! _2 := 2bv32; | ||
//! _4 := $BvSignedGreaterThan(_2, _1); | ||
//! assert _4; | ||
//! z := $BvAnd(_1, _2); | ||
//! _7 := $BvSignedLessThan(_1, z); | ||
//! assert _7; | ||
//! return; | ||
//! } | ||
//! | ||
//! ```` | ||
|
||
#[kani::proof] | ||
fn check_binop_gt() { | ||
let x = 1; | ||
let y = 2; | ||
kani::assert(y > x, ""); | ||
let z = x | y; | ||
kani::assert(x < z, ""); | ||
} |