3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-03-16 18:20:00 +00:00
Commit graph

17868 commits

Author SHA1 Message Date
Lev Nachmanson
6fb68ac010
Nl2lin - integrate a linear under approximation of a CAD cell by Valentin Promies. (#8982)
* outline of signature for assignment based conflict generation

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* outline of interface contract

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* remove confusing construction

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* add material in nra-solver to interface

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* add marshaling from nlsat lemmas into core solver

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* tidy

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* add call to check-assignment

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* Nl2lin (#7795)

* add linearized projection in nlsat

* implement nlsat check for given assignment

* add some comments

* fixup loop

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* updates

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* fixes

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* debug nl2lin

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

* Nl2lin (#7827)

* fix linear projection

* fix linear projection

* use an explicit cell description in check_assignment

* clean up (#7844)

* Simplify no effect checks in nla_core.cpp

Move up linear nlsat call to replace bounded nlsat.

* t

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

* t

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

* detangle mess

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* remove the too early return

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

* do not set use_nra_model to true

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

* remove a comment

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

* add a hook to add new multiplication definitions in nla_core

* add internalization routine that uses macro-expanded polynomial representation

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* add internalization routine that uses macro-expanded polynomial representation

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* fixup backtranslation to not use roots

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* call setup_assignment_solver instead of setup_solver

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* debug the setup, still not working

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

* updated clang format

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* simplify

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* create polynomials with integer coefficients, use the hook to create new monomials

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

* integrating changes from master related to work with polynomials

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

* add forgotten files

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

* Update nlsat_explain.cpp

Remove a duplicate call

* fix

* move linear cell construction to levelwise

* fix

* fix

* Port throttle and soundness fixes from master

- Fix soundness: pop incomplete lemma from m_lemmas on add_lemma failure
- Gracefully handle root atoms in add_lemma
- Throttle check_assignment with failure counter (decrement on success)
- Add arith.nl.nra_check_assignment parameter

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add arith.nl.nra_check_assignment_max_fail parameter

Replace hardcoded failure threshold with configurable parameter (default 10).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add cha_abort_on_fail parameter to control failure counter decrement

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* abort nla check_assignment after a set number of allowed failures

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

* Add missing AST query methods to Java API (#8977)

* add Expr.isGround() to Java API

Expose Z3_is_ground as a public method on Expr. Returns true when the
expression contains no free variables.

* add Expr.isLambda() to Java API

Expose Z3_is_lambda as a public method on Expr. Returns true when the
expression is a lambda quantifier.

* add AST.getDepth() to Java API

Expose Z3_get_depth as a public method on AST. Returns the maximum
number of nodes on any path from root to leaf.

* add ArraySort.getArity() to Java API

Expose Z3_get_array_arity as a public method on ArraySort. Returns
the number of dimensions of a multi-dimensional array sort.

* add DatatypeSort.isRecursive() to Java API

Expose Z3_is_recursive_datatype_sort as a public method on
DatatypeSort. Returns true when the datatype refers to itself.

* add FPExpr.isNumeral() to Java API

Expose Z3_fpa_is_numeral as a public method on FPExpr. Returns true
when the expression is a concrete floating-point value.

* add isGroundExample test to JavaExample

Test Expr.isGround() on constants, variables, and compound
expressions.

* add astDepthExample test to JavaExample

Test AST.getDepth() on leaf nodes and nested expressions to verify
the depth computation.

* add arrayArityExample test to JavaExample

Test ArraySort.getArity() on single-domain and multi-domain array
sorts.

* add recursiveDatatypeExample test to JavaExample

Test DatatypeSort.isRecursive() on a recursive list datatype and a
non-recursive pair datatype.

* add fpNumeralExample test to JavaExample

Test FPExpr.isNumeral() on a floating point constant and a symbolic
variable.

* add isLambdaExample test to JavaExample

Test Expr.isLambda() on a lambda expression and a plain variable.

* change the default number of failures in check_assignment to 7

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

* Fix high and medium priority API coherence issues (Go, Java, C++, TypeScript) (#8983)

* Initial plan

* Add missing API functions to Go, Java, C++, and TypeScript 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>

* qf-s-benchmark: debug build + seq tracing + seq-fast/nseq-slow trace analysis (#8988)

* Initial plan

* Update qf-s-benchmark: debug build, seq tracing, trace analysis

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>

* disable linear approximation by default to check the merge

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

* set check_assignment to true

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

* fix restore_x by recalulating new column values

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

* fix restore_x by recalulating new column values

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

* fix a memory leak

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

---------

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com>
Co-authored-by: ValentinPromies <44966217+ValentinPromies@users.noreply.github.com>
Co-authored-by: Valentin Promies <valentin.promies@rwth-aachen.de>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Angelica Moreira <48168649+angelica-moreira@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-15 06:13:04 -10:00
Copilot
21bfb115ea
Fix high and medium priority API coherence issues (Go, Java, C++, TypeScript) (#8983)
* Initial plan

* Add missing API functions to Go, Java, C++, and TypeScript 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-03-14 10:46:03 -07:00
Angelica Moreira
b8e15f2121
Add missing AST query methods to Java API (#8977)
* add Expr.isGround() to Java API

Expose Z3_is_ground as a public method on Expr. Returns true when the
expression contains no free variables.

* add Expr.isLambda() to Java API

Expose Z3_is_lambda as a public method on Expr. Returns true when the
expression is a lambda quantifier.

* add AST.getDepth() to Java API

Expose Z3_get_depth as a public method on AST. Returns the maximum
number of nodes on any path from root to leaf.

* add ArraySort.getArity() to Java API

Expose Z3_get_array_arity as a public method on ArraySort. Returns
the number of dimensions of a multi-dimensional array sort.

* add DatatypeSort.isRecursive() to Java API

Expose Z3_is_recursive_datatype_sort as a public method on
DatatypeSort. Returns true when the datatype refers to itself.

* add FPExpr.isNumeral() to Java API

Expose Z3_fpa_is_numeral as a public method on FPExpr. Returns true
when the expression is a concrete floating-point value.

* add isGroundExample test to JavaExample

Test Expr.isGround() on constants, variables, and compound
expressions.

* add astDepthExample test to JavaExample

Test AST.getDepth() on leaf nodes and nested expressions to verify
the depth computation.

* add arrayArityExample test to JavaExample

Test ArraySort.getArity() on single-domain and multi-domain array
sorts.

* add recursiveDatatypeExample test to JavaExample

Test DatatypeSort.isRecursive() on a recursive list datatype and a
non-recursive pair datatype.

* add fpNumeralExample test to JavaExample

Test FPExpr.isNumeral() on a floating point constant and a symbolic
variable.

* add isLambdaExample test to JavaExample

Test Expr.isLambda() on a lambda expression and a plain variable.
2026-03-14 10:13:42 -07:00
Nikolaj Bjorner
6e5971641f
Merge pull request #8955 from Z3Prover/copilot/convert-injectivity-to-simplifier
Convert `injectivity` tactic to a dependent_expr_simplifier
2026-03-12 17:07:19 -07:00
Nikolaj Bjorner
ca9992c751
Merge pull request #8954 from Z3Prover/copilot/convert-special-relations-tactic
Convert `special-relations` tactic to a `dependent_expr_simplifier`
2026-03-12 17:07:02 -07:00
copilot-swe-agent[bot]
682fa3f815 Fix indentation: use spaces instead of tabs in api_model.cpp CHECK_NON_NULL
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-12 23:00:07 +00:00
copilot-swe-agent[bot]
f413a24408 Fix API bugs exercised by test/deep_api_bugs.cpp
- api_fpa.cpp: add RETURN_Z3(nullptr) after SET_ERROR_CODE in Z3_mk_fpa_sort to prevent fall-through to mk_float_sort with invalid params
- api_seq.cpp: add null check for str in Z3_mk_string; add null check for str when sz>0 in Z3_mk_lstring; add lo<=hi validation in Z3_mk_re_loop
- api_array.cpp: add explicit n==0 validation in Z3_mk_array_sort_n
- api_solver.cpp: rename local variable 'c' to avoid shadowing Z3_context param in Z3_solver_propagate_created/decide/on_binding; move init_solver call inside file-exists branches of Z3_solver_from_file
- api_ast.cpp: add null check for target in Z3_translate; add null check for _from/_to arrays when num_exprs>0 in Z3_substitute
- api_model.cpp: add CHECK_NON_NULL(m) in Z3_add_func_interp; add CHECK_NON_NULL(a) in Z3_model_get_const_interp; add null check for target in Z3_model_translate
- api_opt.cpp: add null check for weight string in Z3_optimize_assert_soft
- api_quant.cpp: add num_patterns==0 validation in Z3_mk_pattern

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-12 22:58:53 +00:00
Nikolaj Bjorner
397e3d404a add bugs
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-03-12 15:18:38 -07:00
copilot-swe-agent[bot]
56c88022e2 Fix build: use unquoted TRACE tag identifier instead of string literal
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-12 18:27:36 +00:00
copilot-swe-agent[bot]
646016742b Fix Python build: move special_relations_simplifier.h to tactic/core to resolve expr_pattern_match.h dependency
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-12 18:02:43 +00:00
copilot-swe-agent[bot]
7692dfc7d6 Delete injectivity_tactic.cpp (deprecated, replaced by injectivity_simplifier.h)
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-12 16:25:04 +00:00
Lev Nachmanson
11309424b3
Merge pull request #8944 from Z3Prover/feas
Fix the regression in maximize of theory_lra.
2026-03-12 06:10:26 -10:00
copilot-swe-agent[bot]
995e0e1f14 Deprecate injectivity_tactic.cpp: forward mk_injectivity_tactic to simplifier-based impl
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-12 05:32:32 +00:00
copilot-swe-agent[bot]
ec9fee969d Remove old special_relations_tactic class, use simplifier-based tactic as the sole special-relations tactic
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-12 05:30:57 +00:00
Lev Nachmanson
3176151cc2 rename bhn_opt to max_reg
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-03-11 19:18:45 -10:00
copilot-swe-agent[bot]
fb31b689ea Add special_relations_simplifier: new simplifier and tactic registration
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-12 04:39:05 +00:00
copilot-swe-agent[bot]
c303b56f04 Add injectivity_simplifier and register injectivity2 tactic + injectivity simplifier
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-12 04:37:17 +00:00
Lev Nachmanson
b8d6952e9e Enable som (sum of monomials) in optimizer simplification
The optimizer's simplification pass did not expand products of sums
into sum-of-monomials form. This caused mathematically equivalent
expressions like (5-x)^2 vs (x-5)^2 to simplify into different
internal forms, where the former produced nested multiplies
(+ 5.0 (* -1.0 x)) that led to harder purification constraints
and solver timeouts.

Enabling som=true in the first simplification tactic normalizes
polynomial objectives into canonical monomial form, making the
optimizer robust to operand ordering.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-11 18:28:40 -10:00
Lev Nachmanson
ce7c7f458e Add max_rev test: BNH with reversed argument order in f1/f2
Same as test_bnh_optimize but constructs f1 and f2 with reversed
parameter order in mk_add, mk_mul, mk_sub calls. Exposes optimizer
sensitivity to expression structure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-11 18:15:57 -10:00
copilot-swe-agent[bot]
01f9709ff6 Add vector::resize tests including vector<rational>
Co-authored-by: levnach <5377127+levnach@users.noreply.github.com>
2026-03-11 23:54:01 +00:00
Lev Nachmanson
8e47c0d842 Fixed the assertion violation in mpz.cpp:602 when running with -tr:arith.
**Root cause**: `vector::resize(SZ s, Args args...)` in `src/util/vector.h` took `args` by value and used `std::forward<Args>(args)` in a loop. The first iteration moved from `args`, leaving all subsequent elements with a moved-from state (`rational{0/0}` instead of
`rational{0/1}`). This corrupted the coefficient vector in the pretty printer, causing a division-by-zero assertion when multiplying.

**Fix**: Changed `resize` to take `Args const& args` and copy-construct each element instead of forwarding/moving.
2026-03-11 12:43:59 -10:00
Lev Nachmanson
274d64299e Address PR review: add ENSURE checks, fix duplicate test, fix comment
- Add ENSURE(result == Z3_L_TRUE) for each BNH optimization call and
  ENSURE(num_sat == 7) at the end so CI catches regressions.
- Remove test_bnh_optimize() from tst_api() to avoid duplicate
  execution under /a; keep standalone tst_bnh_opt() entry point.
- Fix Test 2 comment: it tests same-size backup, not backup-longer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-10 16:58:24 -10:00
Lev Nachmanson
6d890fb026 Fix NLA optimization regression and relax restore_x
- Relax restore_x() to handle backup/current size mismatches: when
  backup is shorter (new columns added), call
  move_non_basic_columns_to_bounds() to find a feasible solution.
- Fix 100x performance regression in nonlinear optimization: save LP
  optimum before check_nla and return it as bound regardless of NLA
  result, so opt_solver::check_bound() can validate via full re-solve
  with accumulated NLA lemmas.
- Refactor theory_lra::maximize() into three helpers: max_with_lp(),
  max_with_nl(), and max_result().
- Add mk_gt(theory_var, impq const&) overload for building blockers
  from saved LP optimum values.
- Add BNH multi-objective optimization test (7/7 sat in <1s vs 1/7
  in 30s before fix).
- Add restore_x test for backup size mismatch handling.

Fixes #8890

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-10 16:38:08 -10:00
copilot-swe-agent[bot]
42eee12c2f Code simplifications in sls_euf_plugin.cpp and realclosure.cpp
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-10 16:17:24 +00:00
Lev Nachmanson
78fa6d5ee8 allow calling lp().restore_x() only in case the number of column in lp() remained the same: it might grow
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-03-09 10:51:31 -10:00
Nikolaj Bjorner
4b377ae713
Merge pull request #8898 from Z3Prover/copilot/address-actionable-issues-discussion
Fix actionable null pointer dereferences and uninitialized variables from static analysis
2026-03-09 10:45:47 -07:00
copilot-swe-agent[bot]
a6c94a1bfc Refactor sls_euf_plugin.cpp validate_model and add SASSERT in udoc_relation.cpp
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-09 16:57:59 +00:00
copilot-swe-agent[bot]
391febed3b Fix null pointer dereferences and uninitialized variables from discussion #8891
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-09 16:51:12 +00:00
copilot-swe-agent[bot]
7d19851c2f fix: fix memory leaks detected by ASan in test code
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-09 16:48:17 +00:00
copilot-swe-agent[bot]
47e9c37fbb Go: Add MkBVRotateLeft, MkBVRotateRight, MkRepeat to bitvec.go
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-09 16:20:13 +00:00
Lev Nachmanson
8a146a92ec fix: replace UNREACHABLE with VERIFY for non-COI constraint/monic violations in nra_solver
The NRA solver's check() uses cone-of-influence (COI) to select a subset
of constraints for nlsat. When nlsat returns l_true, the model is validated
against all constraints, but non-COI constraints can legitimately be
violated since nlsat only solved over the COI subset.

- Non-COI violations gracefully return l_undef (fallback to other strategies)
- COI violations still trigger an assertion (indicating a real nlsat bug)

Fixes #8883

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-06 08:54:34 -10:00
copilot-swe-agent[bot]
822f19819c Remove unreachable return false in match_ubv2s1
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-05 17:59:50 +00:00
Nikolaj Bjorner
96285b0f91
Merge pull request #8824 from Z3Prover/copilot/fix-issues-except-rust
Fix issues reported in discussion 8823 for all languages except Rust
2026-03-02 10:35:31 -08:00
copilot-swe-agent[bot]
1461a53347 Fix TypeScript Array.fromFunc to use f.ptr instead of f.ast for Z3_func_decl type
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-02 16:22:08 +00:00
copilot-swe-agent[bot]
28fbe33114 Add missing API bindings: Python BvNand/BvNor/BvXnor, Go MkAsArray/MkRecFuncDecl/AddRecDef/Model.Translate, TS Array.fromFunc/Model.translate, OCaml Model.translate
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-02 00:21:57 +00:00
copilot-swe-agent[bot]
8e94cad8ab Fix static analysis findings: uninitialized vars, bitwise shift UB, garbage values
- nla_core.cpp: Initialize j = null_lpvar in is_octagon_term
- bit2int.cpp: Initialize sign_p, sign_n, sz_p, sz_n
- act_cache.cpp: Initialize debug vars to nullptr
- enum2bv_rewriter.cpp: Use unsigned literal in 1u << idx
- bit_matrix.cpp: Use unsigned literal in 1u << (n-1)
- bit_util.cpp: Guard against bit_shift == 0 in shl/shr
- mpff.cpp: Cast exp to unsigned before shifting
- sorting_network.h: Guard against bits == 0
- dl_sparse_table.h: Use >= 64 instead of == 64

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-02 00:13:55 +00:00
Nikolaj Bjorner
8a6d22d3f1
Merge pull request #8813 from Z3Prover/copilot/fix-issues-in-multiple-languages
Fix API discrepancies for Go, Python bindings
2026-03-01 12:09:23 -08:00
copilot-swe-agent[bot]
a15c659e81 Add Python Optimize.translate() and missing Go tactic/simplifier functions
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-01 02:14:16 +00:00
copilot-swe-agent[bot]
23d194502a Simplify def_ref smart pointer: default ctor, init list, clearer bool, remove extra semicolon
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-01 02:10:19 +00:00
copilot-swe-agent[bot]
2b8615f4fc Add 8 missing BV overflow/underflow check functions to Go bindings
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-01 01:51:27 +00:00
Lev Nachmanson
93ac330864 Fix assertion violation in q_mbi diagnostic output
The IF_VERBOSE(0,...) block at line 498 in q_mbi.cpp used operator[]
on values2root map which asserts the key exists. When the model
evaluation of the inverted term produces a value not present in the
EUF values2root map, this crashes.

Use find() instead to handle the missing key gracefully, since this
is diagnostic output and the missing key is expected when the model
inversion produces inconsistent results.

Fixes assertion violation from #7027 (obj_hashtable.h line 168/174)
with forall/array/eq2ineq combination.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 11:15:28 -10:00
Lev Nachmanson
7968669cf2
Merge pull request #8803 from Z3Prover/mbo_leak 2026-02-27 19:02:56 -10:00
Lev Nachmanson
835da14afa
Update src/math/simplex/model_based_opt.h
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-27 17:29:37 -10:00
Lev Nachmanson
fc6696c5e4 Fix memory leaks in model_based_opt def ref-counting
Three bugs in the def ref-counting infrastructure:

1. dec_ref() incremented (++) instead of decrementing (--) the ref count,
   so objects were never freed.

2. def_ref lacked copy and move constructors, so the compiler-generated
   default copy just copied the raw pointer without inc_ref. This caused
   use-after-free when def_ref values were copied into vectors.

3. Compound def types (add_def, mul_def, div_def) lacked destructors to
   dec_ref their children. Added virtual destructor to base def class
   and child-releasing destructors to compound types.

Fixes the memory leak from #7027 (model_based_opt.cpp:81).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-27 17:15:20 -10:00
Copilot
f4abd88ff5
Add arity and bit-width SASSERTs to internalize_overflow (#8802)
* Initial plan

* Add SASSERTs for arity and bit-width in internalize_overflow

Co-authored-by: levnach <5377127+levnach@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: levnach <5377127+levnach@users.noreply.github.com>
2026-02-27 14:30:50 -10:00
Lev Nachmanson
2dac76d19a Handle overflow predicates in new core bit-vector internalization
Add internalize_overflow() to handle OP_BUMUL_OVFL, OP_BSMUL_OVFL,
OP_BUADD_OVFL, OP_BSADD_OVFL, OP_BUSUB_OVFL, OP_BSSUB_OVFL,
OP_BSDIV_OVFL, and OP_BNEG_OVFL in the sat.euf=true solver path.

Previously these overflow predicates hit UNREACHABLE() in
internalize_circuit(). Now they are reduced to equivalent expressions
using existing BV operations and internalized via add_def().

Fixes the assertion violation from #7027 for bvuaddo and related
overflow predicates with tactic.default_tactic=smt sat.euf=true.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-27 13:07:39 -10:00
Lev Nachmanson
6ec40153cc fix #7677: treat FC_CONTINUE from check_nla as FEASIBLE in maximize
When check_nla returns FC_CONTINUE it means NLA found constraint
violations and added lemmas. The current LP value is a valid lower
bound, so the status should be FEASIBLE, not UNBOUNDED.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-27 12:29:14 -10:00
Lev Nachmanson
ffe29b1433 Fix #7951: add cancellation checks to polynomial gcd_prs and HNF computation
Add checkpoint() call in gcd_prs() main loop so polynomial GCD
computation respects rlimit/timeout. Add cancellation callback to
HNF calculation so it can be interrupted when the solver is cancelled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-27 10:26:28 -10:00
Nikolaj Bjorner
d906a0cc2d fix bug reported by Maria Novoszel
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-02-27 12:02:55 -08:00
Lev Nachmanson
5ff5b075b2
Merge pull request #8789 from Z3Prover/succ_int_mult
Fix #7507: simplify (>= product_of_consecutive_ints 0) to true
2026-02-27 09:45:26 -10:00