Skip to content

Commit 5a605ba

Browse files
authored
Merge pull request #506 from sosy-lab/update_z3-4.15.3
Update Z3 to v4.15.4
2 parents c4ee2b2 + 88f037a commit 5a605ba

File tree

5 files changed

+60
-30
lines changed

5 files changed

+60
-30
lines changed

README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ Only a few SMT solvers provide support for theories like Arrays, Floating Point,
6060

6161
JavaSMT supports several SMT solvers (see [Getting Started](doc/Getting-started.md) for installation):
6262

63-
| SMT Solver | Linux x64 | Linux arm64 | Windows x64 | Windows arm64 | MacOS x64 | MacOS arm64 | Description |
64-
| --- |:---------------------:|:-------------------:|:---:|:---:|:------------------------------------------------------:|:---:|:--- |
65-
| [Bitwuzla](https://bitwuzla.github.io/) | :heavy_check_mark:² | :heavy_check_mark:² | :heavy_check_mark: | | | | a fast solver for bitvector logic |
66-
| [Boolector](https://boolector.github.io/) | :heavy_check_mark: | | | | | | a fast solver for bitvector logic, misses formula introspection, deprecated |
67-
| [CVC4](https://cvc4.github.io/) | :heavy_check_mark: | | | | | | |
68-
| [CVC5](https://cvc5.github.io/) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: | |
69-
| [MathSAT5](http://mathsat.fbk.eu/) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | [maybe](https://github.com/sosy-lab/java-smt/pull/430)³ | | |
70-
| [OpenSMT](https://verify.inf.usi.ch/opensmt) | :heavy_check_mark:² | :heavy_check_mark:² | | | | | |
71-
| [OptiMathSAT](http://optimathsat.disi.unitn.it/) | :heavy_check_mark: | | | | | | based on MathSAT5, with support for optimization queries |
72-
| [Princess](http://www.philipp.ruemmer.org/princess.shtml) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Java-based SMT solver |
73-
| [SMTInterpol](https://ultimate.informatik.uni-freiburg.de/smtinterpol/) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Java-based SMT solver |
74-
| [Yices2](https://yices.csl.sri.com/) | :heavy_check_mark: | | [maybe](https://github.com/sosy-lab/java-smt/pull/215) | | [maybe](https://github.com/sosy-lab/java-smt/pull/400)³ | | |
75-
| [Z3](https://github.com/Z3Prover/z3) | :heavy_check_mark:² | :heavy_check_mark:² | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | mature and well-known solver |
63+
| SMT Solver | Linux x64 | Linux arm64 | Windows x64 | Windows arm64 | MacOS x64 | MacOS arm64 | Description |
64+
| --- |:---:|:---:|:---:|:---:|:---:|:---:|:--- |
65+
| [Bitwuzla](https://bitwuzla.github.io/) | :heavy_check_mark:² | :heavy_check_mark:² | :heavy_check_mark: | | | | a fast solver for bitvector logic |
66+
| [Boolector](https://boolector.github.io/) | :heavy_check_mark: | | | | | | a fast solver for bitvector logic, misses formula introspection, deprecated |
67+
| [CVC4](https://cvc4.github.io/) | :heavy_check_mark: | | | | | | |
68+
| [CVC5](https://cvc5.github.io/) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: | |
69+
| [MathSAT5](http://mathsat.fbk.eu/) | :heavy_check_mark:³ | :heavy_check_mark:³ | :heavy_check_mark: | | [maybe](https://github.com/sosy-lab/java-smt/pull/430) | | |
70+
| [OpenSMT](https://verify.inf.usi.ch/opensmt) | :heavy_check_mark:² | :heavy_check_mark:² | | | | | |
71+
| [OptiMathSAT](http://optimathsat.disi.unitn.it/) | :heavy_check_mark: | | | | | | based on MathSAT5, with support for optimization queries |
72+
| [Princess](http://www.philipp.ruemmer.org/princess.shtml) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Java-based SMT solver |
73+
| [SMTInterpol](https://ultimate.informatik.uni-freiburg.de/smtinterpol/) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Java-based SMT solver |
74+
| [Yices2](https://yices.csl.sri.com/) | :heavy_check_mark: | | [maybe](https://github.com/sosy-lab/java-smt/pull/215) | | [maybe](https://github.com/sosy-lab/java-smt/pull/400) | | |
75+
| [Z3](https://github.com/Z3Prover/z3) | :heavy_check_mark:³ | :heavy_check_mark:³ | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | mature and well-known solver |
7676

7777
We support a reasonable list of operating systems and versions.
7878
- Our main target is Linux (mainly Ubuntu or comparable Linux distributions).
@@ -88,7 +88,9 @@ available with Ubuntu 18.04 or later.
8888

8989
² Solver requires at least `GLIBC_2.29`/`GLIBCXX_3.4.26` or `GLIBC_2.34`/`GLIBCXX_3.4.29`,
9090
available with Ubuntu 22.04 or later.
91-
³ We do not provide a signed solver library for macOS. The user needs to compile and sign it.
91+
³ Solver requires at least `GLIBC_2.38`/`GLIBCXX_3.4.31`,
92+
available with Ubuntu 24.04 or later.
93+
⁴ We do not provide a signed solver library for macOS. The user needs to compile and sign it.
9294

9395
#### Solver Features
9496

@@ -109,7 +111,7 @@ If something specific is missing, please [look for or file an issue](https://git
109111

110112
#### Multithreading Support
111113

112-
| SMT Solver | Concurrent context usage | Concurrent prover usage |
114+
| SMT Solver | Concurrent context usage | Concurrent prover usage |
113115
| --- |:---:|:---:|
114116
| [Bitwuzla](https://bitwuzla.github.io/) | :heavy_check_mark: | |
115117
| [Boolector](https://boolector.github.io/) | :heavy_check_mark: | |
@@ -126,13 +128,13 @@ If something specific is missing, please [look for or file an issue](https://git
126128
Interruption using a [ShutdownNotifier][] may be used to interrupt a solver from any thread.
127129
Formulas are translatable in between contexts/provers/threads using _FormulaManager.translateFrom()_.
128130

129-
Multiple contexts, but all operations on each context only from a single thread.
130-
Multiple provers on one or more contexts, with each prover using its own thread.
131+
Multiple contexts, but all operations on each context only from a single thread.
132+
Multiple provers on one or more contexts, with each prover using its own thread.
131133

132134
#### Garbage Collection in Native Solvers
133135

134136
JavaSMT exposes an API for performing garbage collection on solvers implemented in a native language.
135-
As a native solver has no way of knowing whether the created formula object is still referenced
137+
As a native solver has no way of knowing whether the created formula object is still referenced
136138
by the client application, this API is necessary to avoid leaking memory.
137139
Note that several solvers already support _hash consing_ and thus,
138140
there is never more than one copy of an identical formula object in memory.
@@ -141,9 +143,9 @@ in the application, it is not necessary to perform any garbage collection at all
141143
Additionally, the memory for formulas created on user-side (i.e., via JavaSMT) is negligible
142144
compared to solver-internal memory-consumption when solving a hard SMT query.
143145

144-
- **Z3**: The parameter `solver.z3.usePhantomReferences` may be used to control
145-
whether JavaSMT will attempt to decrease references on Z3 formula
146-
objects once they are no longer referenced.
146+
- **Z3**: The parameter `solver.z3.usePhantomReferences` may be used to control
147+
whether JavaSMT will attempt to decrease references on Z3 formula objects
148+
once they are no longer referenced.
147149
- **MathSAT5**: Currently we do not support performing garbage collection for MathSAT5.
148150
- **CVC4, CVC5, Bitwuzla, OpenSMT**: Solvers using SWIG bindings do perform garbage collection.
149151
- **Other native SMT solvers**: we do not perform garbage collection.

lib/ivy.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ SPDX-License-Identifier: Apache-2.0
189189

190190
<!-- Solver Binaries -->
191191
<dependency org="org.sosy_lab" name="javasmt-solver-mathsat" rev="5.6.12" conf="runtime-mathsat-x64->solver-mathsat-x64; runtime-mathsat-arm64->solver-mathsat-arm64" />
192-
<dependency org="org.sosy_lab" name="javasmt-solver-z3" rev="4.15.2" conf="runtime-z3-x64->solver-z3-x64; runtime-z3-arm64->solver-z3-arm64; contrib->sources,javadoc" />
192+
<dependency org="org.sosy_lab" name="javasmt-solver-z3" rev="4.15.4" conf="runtime-z3-x64->solver-z3-x64; runtime-z3-arm64->solver-z3-arm64; contrib->sources,javadoc" />
193193
<dependency org="org.sosy_lab" name="javasmt-solver-opensmt" rev="2.9.0-gef441e1c" conf="runtime-opensmt-x64->solver-opensmt-x64; runtime-opensmt-arm64->solver-opensmt-arm64; contrib->sources,javadoc"/>
194194
<dependency org="org.sosy_lab" name="javasmt-solver-optimathsat" rev="1.7.3-sosy1" conf="runtime-optimathsat->solver-optimathsat" />
195195
<dependency org="org.sosy_lab" name="javasmt-solver-cvc4" rev="1.8-prerelease-2020-06-24-g7825d8f28" conf="runtime-cvc4->solver-cvc4" />

src/org/sosy_lab/java_smt/api/UserPropagator.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,25 @@ public interface UserPropagator {
110110
* @param theoryExpr The expression to observe.
111111
*/
112112
void registerExpression(BooleanFormula theoryExpr);
113+
114+
/**
115+
* The on_binding method allows custom user-defined propagators to intercept and control
116+
* quantifier instantiations during solving. This callback is invoked whenever the solver performs
117+
* a quantifier instantiation (i.e., binds a quantifier to a specific instance). It provides a
118+
* hook for the user propagator to inspect the quantifier and its instantiation.
119+
*
120+
* <p>The default implementation does nothing and accepts all instantiations. It serves for
121+
* backward compatibility in the API.
122+
*
123+
* @param quantifiedVar The quantified variable being instantiated. This is a BooleanFormula
124+
* representing the variable in the quantifier.
125+
* @param instantiation The specific instantiation being applied to the quantified variable. It
126+
* has the same formula type as the quantified variable.
127+
* @since Z3 release 4.15.3
128+
* @return By returning false, the callback signals that the instantiation should be discarded by
129+
* the solver.
130+
*/
131+
default <T extends Formula> boolean onBinding(T quantifiedVar, T instantiation) {
132+
return true;
133+
}
113134
}

src/org/sosy_lab/java_smt/solvers/z3/Z3UserPropagator.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.Map;
1616
import java.util.Optional;
1717
import org.sosy_lab.java_smt.api.BooleanFormula;
18+
import org.sosy_lab.java_smt.api.Formula;
1819
import org.sosy_lab.java_smt.api.PropagatorBackend;
1920
import org.sosy_lab.java_smt.api.UserPropagator;
2021

@@ -28,7 +29,7 @@ final class Z3UserPropagator extends UserPropagatorBase implements PropagatorBac
2829
/* We use this map to reuse existing formula wrappers and avoid creating unnecessary phantom
2930
references (if enabled). This is particularly useful, because the user propagator frequently
3031
reports the same formulas. */
31-
private final Map<Long, BooleanFormula> canonicalizer = new HashMap<>();
32+
private final Map<Long, Formula> canonicalizer = new HashMap<>();
3233

3334
Z3UserPropagator(
3435
long ctx,
@@ -70,7 +71,7 @@ protected void eqWrapper(long pL, long pL1) {}
7071
@Override
7172
protected void fixedWrapper(long lvar, long lvalue) {
7273
assert lvalue == z3True || lvalue == z3False;
73-
userPropagator.onKnownValue(encapsulate(lvar), lvalue == z3True);
74+
userPropagator.onKnownValue(encapsulateBoolean(lvar), lvalue == z3True);
7475
}
7576

7677
// TODO: This method is called if Z3 re-instantiates a user propagator for a sub-problem
@@ -91,7 +92,12 @@ protected void createdWrapper(long le) {}
9192
protected void decideWrapper(long lvar, int bit, boolean isPositive) {
9293
// We currently only allow tracking of decision on boolean formulas,
9394
// so we ignore the <bit> parameter
94-
userPropagator.onDecision(encapsulate(lvar), isPositive);
95+
userPropagator.onDecision(encapsulateBoolean(lvar), isPositive);
96+
}
97+
98+
@Override
99+
protected boolean onBindingWrapper(long quantifiedVar, long instantiation) {
100+
return userPropagator.onBinding(encapsulate(quantifiedVar), encapsulate(instantiation));
95101
}
96102

97103
// ===========================================================================
@@ -160,12 +166,16 @@ private long[] extractInfoFromArray(BooleanFormula[] formulaArray) {
160166
return formulaInfos;
161167
}
162168

163-
private BooleanFormula encapsulate(final long z3Expr) {
169+
private BooleanFormula encapsulateBoolean(final long z3Expr) {
170+
return (BooleanFormula) encapsulate(z3Expr);
171+
}
172+
173+
private Formula encapsulate(final long z3Expr) {
164174
// Due to pointer alignment, the lowest 2-3 bits are always 0 which can lead to
165175
// more collisions in the hashmap. To counteract, we fill the lowest bits by rotating the
166176
// value. The rotation guarantees a bijective transformation.
167177
return canonicalizer.computeIfAbsent(
168-
Long.rotateRight(z3Expr, 3), key -> creator.encapsulateBoolean(z3Expr));
178+
Long.rotateRight(z3Expr, 3), key -> creator.encapsulateWithTypeOf(z3Expr));
169179
}
170180

171181
@Override

src/org/sosy_lab/java_smt/test/BitvectorFormulaManagerTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,6 @@ public void bvRotateByBV() throws SolverException, InterruptedException {
469469
case PRINCESS:
470470
bitsizes = new int[] {2, 3}; // Princess is too slow for larger bitvectors
471471
break;
472-
case Z3:
473-
bitsizes = new int[] {2, 3, 4, 8}; // Z3 is too slow for larger bitvectors since v4.15.0
474-
break;
475472
default:
476473
bitsizes = new int[] {2, 3, 4, 8, 13, 25, 31};
477474
break;

0 commit comments

Comments
 (0)