z4
z3 with some improvements:
-
BitVec:- Change the right shift operation to be logical instead of arithmetic
-
Add the
ByteVecclass -
Add some helper methods for solving:
easy_solvefind_all_solutionseasy_prove
-
Add some helper methods for optimizing:
maximizeminimize
-
Add some helper functions for z3 variables/constants:
BoolToIntSgnTruncDiv
Features implemented upstream
These features were first provided by z4, before z3 included these features. They have now been removed from z4.
-
BoolRef: -
Helper functions:
Abscf08cdf
Usage
Install with pip install z4-solver.
easy_solve
import z4
a, b = z4.Ints("a b")
print(z4.easy_solve([a <= 10, b <= 10, a + b == 15]))
Output:
[b = 5, a = 10]
find_all_solutions
import z4
a, b = z4.Ints("a b")
print(*z4.find_all_solutions([a <= 10, b <= 10, a + b == 15]), sep="\n")
Output:
[b = 5, a = 10]
[b = 6, a = 9]
[b = 7, a = 8]
[b = 8, a = 7]
[b = 9, a = 6]
[b = 10, a = 5]
easy_prove
Let's try and prove that 2 * a >= a for all integers a:
import z4
a = z4.Int("a")
print(z4.easy_prove(2 * a >= a))
Output
Traceback (most recent call last):
...
z4.Z3CounterExample: [a = -1]
This isn't true so we get an exception with the counter-example a = -1. Of course 2 * -1 = -2 which is less than -1.
Let's try again with the assumption that a must be non-negative:
print(z4.easy_prove(z4.Implies(a >= 0, 2 * a >= a)))
Output:
True
Metadata
Release files for z4-solver 2024.12.14.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| z4_solver-2024.12.14.1.tar.gz | 24.0 kB | Without provenance | Details for z4_solver-2024.12.14.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| z4_solver-2024.12.14.1-py3-none-any.whl | Python 3 | none | any | Details for z4_solver-2024.12.14.1-py3-none-any.whl |
Total release size: 40.3 kB
Release files / z4_solver-2024.12.14.1.tar.gz
| Download URL | z4_solver-2024.12.14.1.tar.gz |
|---|---|
| Size | 24.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb7bc4de7309162b02f5ada3e2e872fe2b2adc8931ef732b868f55cb97242d3a
|
|
BLAKE2b-256 checksum How to use checksums |
1fcc13844191feac88cf273175b009cf783728c63c09e283f8860f8c43ab23ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.9
|
Release files / z4_solver-2024.12.14.1-py3-none-any.whl
| Download URL | z4_solver-2024.12.14.1-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5ca36cb1709583880ecce6ee73eae9efd6bf30b5a210ddedf188d90769c24f4
|
|
BLAKE2b-256 checksum How to use checksums |
0186527549af900f7034b0cba141be987f5b1e5096e6399d5c0b490c6892e563
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.9
|
Security for z4-solver 2024.12.14.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.