Skip to content

Commit ad5d5e5

Browse files
authored
Upgrade to Z3 4.16.0 (#2578)
1 parent 0eb7f17 commit ad5d5e5

16 files changed

Lines changed: 104 additions & 84 deletions

File tree

.github/workflows/get-z3.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

BUILD.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Change directory to `source`: `cd source`
2222
### On Windows: Get Z3 and set the `VERUS_Z3_PATH` environment variable
2323

2424
Download the [Z3 binaries](https://github.com/Z3Prover/z3/releases).
25-
Make sure you get Z3 4.12.5.
25+
Make sure you get Z3 4.16.0.
2626
The Z3 `bin` folder contain the executable `z3.exe`.
2727
Set the `VERUS_Z3_PATH` environment variable to the path of the Z3 executable file.
2828

examples/imo_1988_6.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ proof fn is_perfect_square_wlog(a: int, b: int, q: int) -> (sqrt: int)
4949
if a == 0 {
5050
assert(a * a == 0);
5151
assert(a * b == 0);
52+
assert(b * b == q) by (nonlinear_arith)
53+
requires
54+
a == 0,
55+
a * a + b * b == (a * b + 1) * q,
56+
;
5257
return b;
5358
} else {
5459
assert(b * b - (q * a) * b + (a * a - q) == 0) by {

source/air/src/smt_verify.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,15 @@ pub(crate) fn smt_add_decl<'ctx>(context: &mut Context, decl: &Decl) {
117117
}
118118

119119
impl SmtSolver {
120-
pub fn reason_unknown_canceled_str(&self) -> &str {
120+
/// The `(get-info :reason-unknown)` responses that mean "the solver hit its
121+
/// resource/time budget". These vary across Z3 versions.
122+
pub fn reason_unknown_canceled_strs(&self) -> &'static [&'static str] {
121123
match self {
122-
SmtSolver::Z3 => "(:reason-unknown \"canceled\")",
123-
SmtSolver::Cvc5 => "(:reason-unknown resourceout)",
124+
SmtSolver::Z3 => &[
125+
"(:reason-unknown \"canceled\")",
126+
"(:reason-unknown \"max. resource limit exceeded\")",
127+
],
128+
SmtSolver::Cvc5 => &["(:reason-unknown resourceout)"],
124129
}
125130
}
126131

@@ -290,7 +295,7 @@ pub(crate) fn smt_check_assertion<'ctx>(
290295

291296
let mut reason = None;
292297
for line in smt_output {
293-
if line == context.solver.reason_unknown_canceled_str() {
298+
if context.solver.reason_unknown_canceled_strs().iter().any(|s| line == *s) {
294299
assert!(reason == None);
295300
reason = Some(SmtReasonUnknown::Canceled);
296301
} else if line == "(:reason-unknown \"unknown\")" {

source/docs/guide/src/profiling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ error: function body check: Resource limit (rlimit) exceeded
5050
5151
note: Analyzing prover log for (profile rerun) trigger_loops::trigger_forever2 ...
5252
53-
Z3 4.12.5
53+
Z3 4.16.0
5454
note: Log analysis complete for (profile rerun) trigger_loops::trigger_forever2
5555
5656
note: Profile statistics for trigger_loops::trigger_forever2

source/rust_verify_test/tests/loops.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,12 @@ test_verify_one_file_with_options! {
13511351
if result as u64 * result as u64 > n as u64 {
13521352
break;
13531353
}
1354+
assert(n != 1 ==> 1 <= result < n) by (nonlinear_arith)
1355+
requires
1356+
1 <= result,
1357+
result as u64 * result as u64 <= n as u64,
1358+
1 <= n,
1359+
{ }
13541360
}
13551361
result - 1
13561362
}

source/rust_verify_test/tests/operators.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ test_verify_one_file! {
339339
let x = (-128i8) / (-1i8); // FAILS
340340
}
341341

342+
#[verifier::spinoff_prover]
342343
fn test_signed_mod() {
343344
let x = 53i8 % 10i8;
344345
assert(x == 3);

source/tools/get-z3.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$z3_version = "4.12.5"
1+
$z3_version = "4.16.0"
22
$filename = "z3-$z3_version-x64-win"
33

44
$download_url = "https://github.com/Z3Prover/z3/releases/download/z3-$z3_version/$filename.zip"

source/tools/get-z3.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
#! /bin/bash -eu
22

3-
z3_version="4.12.5"
3+
z3_version="4.16.0"
44

5+
# The OS/libc suffix in each release artifact's name is specific to the Z3
6+
# version (it tracks the platform Z3's CI built that release on), so these
7+
# strings must be revisited on every Z3 upgrade -- they cannot be derived from
8+
# $z3_version alone. See https://github.com/Z3Prover/z3/releases.
59
if [ `uname` == "Darwin" ]; then
610
if [[ $(uname -m) == 'arm64' ]]; then
7-
filename="z3-$z3_version-arm64-osx-11.0"
11+
filename="z3-$z3_version-arm64-osx-15.7.3"
812
elif [[ $(uname -m) == 'x86_64' ]]; then
9-
filename="z3-$z3_version-x64-osx-11.7.10"
13+
filename="z3-$z3_version-x64-osx-15.7.3"
1014
else
1115
echo "Unsupported architecture $(uname -m)"
1216
exit -1
1317
fi
1418
elif [ `uname` == "Linux" ]; then
1519
if [[ $(uname -m) == 'aarch64' ]]; then
16-
filename="z3-$z3_version-arm64-glibc-2.35"
20+
filename="z3-$z3_version-arm64-glibc-2.38"
1721
elif [[ $(uname -m) == 'x86_64' ]]; then
18-
filename="z3-$z3_version-x64-glibc-2.31"
22+
filename="z3-$z3_version-x64-glibc-2.39"
1923
else
2024
echo "Unsupported architecture $(uname -m)"
2125
exit -1

source/vstd/arithmetic/div_mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use super::super::prelude::*;
1717

1818
verus! {
1919

20+
#[verifier::inline]
2021
pub open spec fn rust_div(a: int, b: int) -> int
2122
recommends
2223
b != 0,
@@ -30,6 +31,7 @@ pub open spec fn rust_div(a: int, b: int) -> int
3031
}
3132
}
3233

34+
#[verifier::inline]
3335
pub open spec fn rust_rem(a: int, b: int) -> int
3436
recommends
3537
b != 0,
@@ -745,6 +747,7 @@ pub broadcast proof fn lemma_div_multiples_vanish_quotient(x: int, a: int, d: in
745747

746748
/// Proof that, since `a % d == 0` and `0 <= r < d`, we can conclude
747749
/// `a == d * (a + r) / d`.
750+
#[verifier::spinoff_prover]
748751
pub broadcast proof fn lemma_round_down(a: int, r: int, d: int)
749752
requires
750753
0 < d,

0 commit comments

Comments
 (0)