3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-18 06:34:22 +00:00
Commit graph

2780 commits

Author SHA1 Message Date
copilot-swe-agent[bot]
5a9f416837 Simplify Go bindings: refactor GetLowerAsVector and GetUpperAsVector to use astVectorToExprs helper
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-17 03:46:58 +00:00
copilot-swe-agent[bot]
96d9c66aff Fix formatting of z3.go using gofmt
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-16 22:00:07 +00:00
Nikolaj Bjorner
1fb405cf44
Merge pull request #8655 from Z3Prover/copilot/fix-go-bindings-reference-count
[WIP] Fix reference counting for Z3_ast_vector in go bindings
2026-02-16 13:58:03 -08:00
copilot-swe-agent[bot]
ea1f5a333a Fix Go bindings reference counting for Z3_ast_vector objects
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-16 21:48:49 +00:00
copilot-swe-agent[bot]
188880a20c Add missing high-priority Go bindings to Solver
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-16 21:28:24 +00:00
Nikolaj Bjorner
dd10826c99
Merge pull request #8646 from Z3Prover/copilot/build-go-bindings-ci
Enable Go bindings in ubuntu-cmake CI builds
2026-02-16 09:45:42 -08:00
Nikolaj Bjorner
e87cf5ad2b remove brittle pydoc example
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-02-16 09:20:57 -08:00
copilot-swe-agent[bot]
d33c0e5601 Fix trailing whitespace in Go source files
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-16 06:06:48 +00:00
copilot-swe-agent[bot]
3f4bd11f00 Fix Go bindings and enable in CI
- Fix all compilation errors in Go bindings
- Add missing type definitions (Pattern, ASTVector, ParamDescrs)
- Fix boolean comparisons to use bool() casts
- Fix Z3_app type casts using unsafe.Pointer
- Fix null symbol handling to use nil
- Fix unused variable in basic_example.go
- Fix CMake test target to run from examples/go directory
- Restore CI steps to build and test Go bindings

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-16 06:05:58 +00:00
copilot-swe-agent[bot]
bbc1e501ab Fix Go bindings compilation issues and add to CI
- Fix malformed z3.go with duplicate function body fragments
- Fix datatype.go to use Z3_del_constructor and Z3_del_constructor_list instead of non-existent inc_ref/dec_ref functions
- Remove non-existent Push/Pop methods from fixedpoint.go
- Fix CMake Go bindings targets quoting for proper LDFLAGS handling
- Add Go bindings support to ubuntu-cmake CI jobs

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-16 05:58:20 +00:00
Nikolaj Bjorner
e099c74985 Merge branch 'master' of https://github.com/z2prover/z3 2026-02-15 21:25:04 -08:00
Nikolaj Bjorner
66d0fb5477 git bindings v1.0 2026-02-15 21:24:40 -08:00
Nikolaj Bjorner
b0ebc78217
Merge pull request #8631 from danielzgtg/doc/solverSexpr
Document example for Solver.sexpr()
2026-02-15 20:51:54 -08:00
Daniel Tang
114a325cd4
Document example for Solver.sexpr() 2026-02-15 21:38:46 -05:00
Nikolaj Bjorner
166a9afab0
Merge pull request #8633 from danielzgtg/feat/solverSolutions
Add Solver.solutions(t)
2026-02-15 17:22:03 -08:00
Nikolaj Bjorner
24f3258c49
Merge pull request #8626 from danielzgtg/feat/modelRefGetitemErrorMessageModelRefEval
Suggest eval in ModelRef.__getitem__ error
2026-02-15 17:20:11 -08:00
Daniel Tang
32c4c87e22
Add Solver.solutions(t)
For parity with
[z3.rs](https://docs.rs/z3/latest/z3/struct.Solver.html#method.solutions)
.

Having a way to find all solutions is frequently requested:
* https://stackoverflow.com/q/63231398/10477326
* https://stackoverflow.com/q/11867611/10477326

In accordance with the Rust, I did not
[guess `t`](https://stackoverflow.com/a/11869410/10477326).
2026-02-15 01:18:02 -05:00
Daniel Tang
1ada488cb6
Suggest eval in ModelRef.__getitem__ error
This improves the previously cryptic error message. I searched multiple
websites before Google AI suggested using model.eval(arr[0]) for getting
solutions out of arrays.
2026-02-14 18:16:39 -05:00
Daniel Tang
c172b58268
Alias ArithRef.__abs__ to Abs
This integrates with the `abs(Int('x'))` Python builtin.
2026-02-14 01:37:58 -05:00
Nikolaj Bjorner
8077e3d031
Modify behavior for division by zero
Allow division by zero in z3 expressions without raising an error.
2026-02-12 07:10:00 -08:00
Nikolaj Bjorner
dcbafa9442
Delete src/api/python/test_critical_fixes.py 2026-02-12 07:07:15 -08:00
copilot-swe-agent[bot]
a8f32ed291 Fix error message capitalization for Python conventions
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-12 05:03:07 +00:00
copilot-swe-agent[bot]
69bf729a22 Add comprehensive tests for Python API bug fixes
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-12 05:01:41 +00:00
copilot-swe-agent[bot]
629d999fa2 Fix 9 critical assert statements and RatVal division by zero (Priority 1)
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-12 04:45:35 +00:00
copilot-swe-agent[bot]
6743d42ea4 Fix BOUNDS and ASSERT_FAIL issues in Python API
- Add negative index support to AstVector.__setitem__, ModelRef.__getitem__, ApplyResult.__getitem__
- Replace bare assertions with proper Z3Exception in z3num.Numeral methods
- All changes tested and validated with comprehensive test suite

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-12 03:05:06 +00:00
Nikolaj Bjorner
8eff8dc9c8
Merge branch 'master' into copilot/update-nightly-build-test-process 2026-02-08 11:28:21 -08:00
copilot-swe-agent[bot]
e685ea45ed Fix OCaml linker flag and align validation runners with build runners
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-08 17:26:30 +00:00
copilot-swe-agent[bot]
af76ac69d6 Apply headerpad fix to build systems (Python and CMake) and fix validation test paths
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-08 17:23:04 +00:00
copilot-swe-agent[bot]
a08e8a99f9 Add -headerpad_max_install_names flag for macOS dylib builds
This fixes the install_name_tool issue on macOS where the tool fails
with "larger updated load commands do not fit". The linker flag
-Wl,-headerpad_max_install_names ensures sufficient header padding
in the Mach-O binary for install_name_tool to modify install names.

Changes made:
- CMake: Added flag to libz3, z3java, z3jl shared libraries on Darwin
- Python build: Changed flag from ML-only to all macOS builds
- OCaml CMake: Added flag to OCaml stublib build on APPLE

Fixes #7623 (regression in 4.15.5)

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-08 03:26:13 +00:00
Nikolaj Bjorner
3bd5b5a5d4
Merge pull request #8500 from Z3Prover/copilot/update-functional-datatype
Add datatype_update_field to C++, Python, TypeScript, and OCaml bindings
2026-02-07 10:11:54 -08:00
copilot-swe-agent[bot]
52885a4d62 Add static linkage to internal functions
Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com>
2026-02-06 23:19:16 +00:00
copilot-swe-agent[bot]
decb0fffc1 Fix TypeScript compilation error: add updateField to Context interface
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-06 17:27:19 +00:00
Copilot
bb35267e46
Modern C++: Add std::span overload for mk_or, adopt std::clamp, optimize stream output (#8507)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-06 11:54:06 +00:00
Nikolaj Bjorner
384a8e291b
Merge pull request #8499 from Z3Prover/copilot/add-regex-support-typescript-api
Add regex support to TypeScript API
2026-02-05 23:08:19 -08:00
copilot-swe-agent[bot]
6e09a06307 Add move semantics to z3::context class
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-05 17:15:43 +00:00
copilot-swe-agent[bot]
316919e692 Fix JSDoc formatting and improve type safety in tests
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-04 22:05:23 +00:00
copilot-swe-agent[bot]
de14c0b3ce Document Loop function semantics and fix review comments
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-04 22:02:58 +00:00
copilot-swe-agent[bot]
910a9c2aa6 Add comprehensive tests for regex functionality
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-04 22:00:34 +00:00
copilot-swe-agent[bot]
ed111f023a Add regex support to TypeScript API - types and implementations
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-04 21:58:53 +00:00
copilot-swe-agent[bot]
ac39c021bf Add datatype_update_field to C++, Python, TypeScript, and OCaml bindings
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-04 21:57:57 +00:00
Copilot
9007728ddb
Add solve_for and import_model_converter to C++ solver API (#8465)
* Initial plan

* Add solve_for and import_model_converter methods to C++ API (fixes issues 6 and 8)

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Address code review feedback and add comprehensive test

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Remove accidentally committed binary

* Delete examples/c++/test_issues_6_7_8.cpp

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-02-02 09:01:23 -08:00
Copilot
f5a44cf0b9
Add missing solver APIs to Java and C# bindings (#8464)
* Initial plan

* Add missing solver APIs for Java and C#

- Issue 3: Add getTrailLevels() to Java and TrailLevels property to C#
- Issue 4: Add cube() iterator to Java (C# already had Cube())
- Issue 5: Add setInitialValue() to Java and SetInitialValue() to C#

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Fix code review feedback: eliminate redundant trail retrieval

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Improve documentation and efficiency based on code review

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-02 09:01:01 -08:00
Copilot
db6e15361b
Add Java APIs for polymorphic datatypes (#8438)
* Initial plan

* Add Java APIs for polymorphic datatypes and type variables

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Fix code review issue and add documentation

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Add TypeVarSort.java to CMakeLists.txt for Java bindings

The CMake build was failing because TypeVarSort.java was not included in the Z3_JAVA_JAR_SOURCE_FILES list in src/api/java/CMakeLists.txt. Added it in alphabetical order between TupleSort.java and UninterpretedSort.java.

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-01-31 15:31:36 -08:00
Copilot
01948e168b
Add polymorphic datatype support to ML API (#8378)
* Initial plan

* Add ML bindings for polymorphic datatypes (mk_type_variable and mk_polymorphic_sort)

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Add polymorphic datatype example for ML API

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Delete examples/ml/polymorphic_datatype_example.ml

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-01-27 11:44:35 -08:00
Nikolaj Bjorner
76d46ee48a Revert "Refactor find_tactic_cmd to use std::optional<tactic_cmd*> (#8331)"
This reverts commit 7b182c9440.
2026-01-26 13:20:03 -08:00
Nikolaj Bjorner
3f26d42215 Revert "Refactor find_probe() to use std::optional (#8334)"
This reverts commit 49817bc259.
2026-01-26 13:19:56 -08:00
Copilot
49817bc259
Refactor find_probe() to use std::optional (#8334)
* Initial plan

* Refactor find_probe() to use std::optional

- Updated tactic_manager.h: Changed return type to std::optional<probe_info*>
- Updated tactic_manager.cpp: Modified implementation to return std::nullopt or probe pointer
- Updated api_tactic.cpp: Changed 2 call sites to use optional checks and dereference
- Updated tactic_cmds.cpp: Changed 1 call site to use optional check and dereference
- Build verified successfully
- Probe functionality tested with Python bindings

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-01-25 15:13:36 -08:00
Copilot
7b182c9440
Refactor find_tactic_cmd to use std::optional<tactic_cmd*> (#8331)
* Initial plan

* Refactor find_tactic_cmd to use std::optional<tactic_cmd*>

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-01-25 12:38:34 -08:00
Lev Nachmanson
c0583b828d
preserve the initial state of the solver with push/pop for multiple objectives (#8264)
* preserve the initial state of the solver with push/pop for multiple objectives

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

* Fix memory corruption in Z3_polynomial_subresultants

The API function had a memory corruption bug where allocating the result
vector while the default_expr2polynomial converter was still in scope
could corrupt the converter's internal expr2var mapping.

Fixed by restructuring the code to:
1. Complete all polynomial computation in a scoped block
2. Store results in a temporary expr_ref_vector
3. Let the converter go out of scope
4. Then allocate and populate the result vector

Also improved the test to:
- Use randomized testing with 20 iterations
- Test both cases: variable in polynomials and variable not in polynomials
- Use proper reference counting (inc_ref before dec_ref)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 10:41:03 -08:00
Copilot
058a8c082d
Refactor mk_and and mk_app to use std::span API (#8285)
* Initial plan

* Refactor mk_and and mk_app to use std::span

- Made mk_and(unsigned num_args, expr * const * args) private
- Added new public mk_and(std::span<expr* const> args) method
- Added new public mk_app(family_id fid, decl_kind k, std::span<expr* const> args) method
- Updated all convenience overloads to use std::span version
- Updated all external call sites to use the new std::span API

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Fix remaining test files to use std::span API

- Updated src/test/sorting_network.cpp
- Updated src/test/ho_matcher.cpp with explicit cast to resolve ambiguity

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Revert overlapping changes superseded by PR #8286

Reverted 30 files to match the state from PR #8286 (commit ebc0688) which refactored mk_and/mk_or call sites to use vector overloads. This supersedes the std::span changes in those files.

Retained std::span changes in files unique to this PR:
- Core API changes (ast.h, ast.cpp)
- Files not affected by PR #8286 (api_context.cpp, ast_util.cpp, bool_rewriter.h, datatype_rewriter.cpp, dom_simplifier.cpp, factor_rewriter.cpp, pb2bv_rewriter.cpp, quant_hoist.cpp, spacer_cluster_util.cpp, sortmax.cpp, array_axioms.cpp, smtfd_solver.cpp, goal.cpp, ho_matcher.cpp, qe_arith.cpp, sorting_network.cpp)
- Special case in hnf.cpp where both PRs modified different lines

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-01-22 16:58:38 -08:00