3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-21 08:00:27 +00:00
Commit graph

22748 commits

Author SHA1 Message Date
Arie
6d38d5ed41
NLA tracing: emit varmap and grobner-linear-eq for trace analysis (#9415)
Two TRACE blocks under the existing nla_solver tag:

1. theory_lra::false_case_of_check_nla emits a "varmap:" line for each
   NLA lemma, listing j-var → SMT-name mappings for variables in the
   lemma's collect_vars set. Lets lemur nla resolve the LP-internal
   j-numbering back to the original SMT term names when displaying
   lemmas. Without this, lemma-level analysis has to either guess at
   variable identities (and j-numbers are reused across nlsat
   invocations under backtracking — see j-vars-unstable note) or use a
   different trace tag entirely (-tr:nra) for stable algebraic-number
   IDs.

2. nla_grobner emits a "grobner-linear-eq:" line at each call to
   add_term + update_column_type_and_bound that produces a Linear
   Propagation row from completion. Lets us count Gröbner's effective
   contribution to the LP tableau independently of the lemma stream.
   Useful when investigating Gröbner-deficit hypotheses in NLA cascade
   diagnosis.

Both are pure trace emission, behind TRACE(nla_solver, ...). Zero
runtime cost when tracing is off; no semantic change.
2026-04-28 17:31:11 -07:00
Arie
dbb91de64b
Add adaptive growth knobs for Gröbner under arith.nl.grobner_adaptive (#9390)
* Add adaptive growth knobs for Gröbner under arith.nl.grobner_adaptive

When enabled, the per-call growth budget (m_eqs_growth, m_expr_size_growth,
m_expr_degree_growth, m_max_simplified) is scaled by m_growth_boost:
- two consecutive productive runs bump the boost by 3/2 (cap 4x)
- a miss resets the streak and decays the boost toward 1.0x by 1/4 of excess

Default is off; the existing miss-frequency throttle (m_quota / m_delay_base)
is unchanged, so this only affects per-call power, not call frequency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Update src/params/smt_params_helper.pyg

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Arie Gurfinkel <arie.gurfinkel@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-28 08:50:38 -07:00
Lev Nachmanson
c40f8a200e
smt: reset give-up state when escalating final_check level (#9408)
theory_lra reports num_final_check_levels()==2: full nlsat (m_nra.check)
only runs at level >= 2. When a level-1 round-trip ends with FC_GIVEUP
and the loop escalates to level 2, the previously accumulated 'result',
'f', and 'm_incomplete_theories' were retained, so a subsequent
successful (FC_DONE) round at level 2 was still reported as
(incomplete (theory arithmetic)). Reset that state on each level
escalation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-28 03:33:28 +02:00
Nikolaj Bjorner
6cbc504f0b upgrade workflows
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-27 13:59:30 -07:00
Nikolaj Bjorner
63003b5795 convert z3_exception to tactic exception in try_for
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-26 16:37:39 -07:00
Nikolaj Bjorner
7461103802 making try-for tactic exception resilient on cancelation
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-26 15:58:24 -07:00
Copilot
245c117aba
simplify: replace ad-hoc reset_unsafe RAII with on_scope_exit in solve_eqs::reduce() (#9383)
* Initial plan

* simplify: replace reset_unsafe RAII struct with on_scope_exit in solve_eqs::reduce()

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/ff5650aa-02db-4a71-976f-845debd7222f

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-04-26 22:21:02 +02:00
Nikolaj Bjorner
0e07b218bc exception protection for nlsat_tactic
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-26 13:12:08 -07:00
Arie
d99d5a736f
Improvements to NLA lemmas (#9391)
* Add dual-row shared-factor sandwich for NLA bound propagation

When enabled via arith.nl.monomial_sandwich (default off), monomial_bounds
finds LP term columns whose term has shape  a_m * m + a_v * v  with exactly
two variables — both factors of a binary monomial m = u*v. The term column's
bound bounds (a_m * m + a_v * v); substituting m = u*v gives v * (a_m*u + a_v),
and sign-aware interval division by v plus an affine shift yields a numeric
bound on u. The derived interval is fed to the existing propagate_value path
so the lemma channel and integer rounding logic are shared with the rest of
NLA's forward/backward propagation; no new emit code.

Catches conflicts of the form
  α_v1 * v + α_m * m ≥ k1
  α_v2 * v + α_m * m ≤ k2
that today require nlsat (when no single row alone yields infeasibility but
their conjunction tightly bounds u after factoring v).

Scope: binary monomials only (m.size()==2, no squares); cap of 16 term-columns
scanned per call; one lemma per (u,v) attempt to keep the lemma channel quiet.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Add arith.nl.order.binomial_sign flag (default true)

Granular gate for order_lemma_on_binomial_sign — the only order family that
embeds a model-snapshot literal (x ≷ val(x)) in the lemma body. Disabling it
keeps the always-good structural mon-ol family running while removing the
SAT-splitter shape that cascades under model perturbations (e.g., from
arith.nl.monomial_sandwich tightening factor bounds).

Default true preserves master behaviour; the flag is intended as an
experimental knob to measure how much of an observed cascade is specifically
attributable to the binomial-sign splitter vs. the structural cancellation
lemmas in the same module.

See ord-binom-opportunities.md for the full gap analysis and the
deterministic-replacement directions (sandwich, McCormick) that would let
this flag eventually default to false without regressing leaves where
ord-binom currently carries the proof.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Add sign-pinned binomial bound for NLA (Opportunity 1 from ord-binom doc)

When enabled via arith.nl.monomial_binomial_sign (default off), monomial_bounds
adds a third pass alongside propagate_down (existing) and propagate_shared_factor
(sandwich). For a binary monomial m = u*v in m_to_refine whose model value mv
disagrees with val(u)*val(v), and where v has a determined sign:

  1. synthesize a one-sided interval for m.var() at mv (no deps; the snapshot
     enters as a literal in the lemma body, not as an antecedent)
  2. divide by v's interval (sign-aware via dep.div<with_deps>) to get a
     deterministic interval for u
  3. emit a propagate_value-style lemma whose body is
        m.var() < mv (or > mv) ∨ u-bound
     conditioned on v's bound witness

Targets the case ord-binom currently handles: factors have determined signs,
m.var() may have no LP bound. The clause is sound modulo the monomial
definition (same condition propagate_down, propagate_shared_factor, and
ord-binom already rely on).

A new throttle kind MONOMIAL_BINOMIAL_SIGN keyed on (m.var, u, v, direction)
prevents cascading: without it, each new val(m.var()) snapshot would re-emit
across model changes the same way ord-binom does.

Validated via smt.arith.validate=true: 0 soundness errors across the
32-leaf test corpus.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Add McCormick box-corner tangent points (Opportunity 2 from ord-binom doc)

When enabled via arith.nl.tangents.box_corners (default off, sub-flag of
arith.nl.tangents), tangent_imp::get_points selects m_a, m_b at the corners
of the bound box [x_lo, x_hi] × [y_lo, y_hi] instead of the model-centered
points val(x) ± delta. The selection follows the classical McCormick
under/over envelope:

  - m_below=true (under-approximation):
      m_a = (x_lo, y_lo),  m_b = (x_hi, y_hi)
  - m_below=false (over-approximation):
      m_a = (x_lo, y_hi),  m_b = (x_hi, y_lo)

The existing generate_plane already produces the McCormick linear form
xy ≷ pl.y·x + pl.x·y − pl.x·pl.y at any chosen point pl. push_point is
skipped in box-corner mode: corners are extremes, so doubling the offset
moves out of the box and would invalidate the McCormick property.

Falls back to the existing model-driven point selection when either factor
has an unbounded side or the box is degenerate (single-point in a
dimension).

Soundness — non-strict inequality at corners. The classical model-driven
flow uses pl strictly in the interior of the box, so generate_plane emits
xy > T (strict). At the box corners the tangent meets the surface along
the box's edges (xy = T when x = pl.x or y = pl.y), so the strict
inequality is violated by any model with x at the box boundary. A new
m_pl_strict_interior member, set false on a successful set_box_corners(),
switches generate_plane's emission to ≥/≤ (non-strict). The model-driven
path keeps strict — its push_point + plane_is_correct_cut chain already
guarantees pl is interior.

Validated via smt.arith.validate=true: 0 validate_conflict() failures
across the 32-leaf test corpus with box_corners=true.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 21:07:28 +02:00
Nikolaj Bjorner
b0956429fe fix regression from nlsat integration
updates to nlsat polynomial simplification introduced checkpoints.
These can throw exceptions (if setting a timeout).
The code that uses this was not properly protected from exceptions to distinguish timeout based tactics from genuine exceptions that should terminate solving altogether.

see updates such as: 117da362f0
2026-04-26 11:52:46 -07:00
Nikolaj Bjorner
6420bff843 skip other tseitin literals 2026-04-26 11:52:46 -07:00
Copilot
c8453d05f9
Add noop report-as-issue: false to code-simplifier workflow (#9397)
Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/4dbec82b-a305-4164-bd35-294761afc2e7

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-04-26 18:28:30 +02:00
Nikolaj Bjorner
f461369ab8 fix tests
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-26 08:23:26 -07:00
Nikolaj Bjorner
014315764d re-fix the same bug pointed out to an earlier version
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-26 08:16:37 -07:00
Nikolaj Bjorner
cd6fad428b code review updates
1. unit extraction could skip some units
2. create a shared method to check satisfiability that handles exception cases. They are the same among different workers, so shared in the batch manager.
2026-04-25 17:34:09 -07:00
Nikolaj Bjorner
b28f83e2e0 add initial scaffolding for using assumption literals
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-25 08:09:25 -07:00
Nikolaj Bjorner
abbe36561d cleanup service
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-24 17:22:04 -07:00
Nikolaj Bjorner
cedd896ea5 redo length re-computation
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-24 15:49:19 -07:00
Nikolaj Bjorner
7fc68d20ea brain got parked somewhere?
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-23 19:16:18 -07:00
Nikolaj Bjorner
51cbbe0a0e fix #9293
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-23 17:19:48 -07:00
Nikolaj Bjorner
cd94f8541f fix #9234
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-23 13:54:09 -07:00
Nikolaj Bjorner
844e248b1e disable elim-uncnstr under quantifiers #9293 2026-04-23 13:42:53 -07:00
Nikolaj Bjorner
1cf5e3e300 remove unused function
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-23 13:04:02 -07:00
Nikolaj Bjorner
101a9233bc fix #9309
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-23 11:07:24 -07:00
CEisenhofer
e045e650da Fixed order of undoing 2026-04-23 17:18:04 +02:00
Nikolaj Bjorner
ace4105a90 fix test build
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-23 08:06:15 -07:00
Copilot
f37f87422a
[code-simplifier] Simplify backbone/parallel code from PR #9343 (#9357)
* Initial plan

* Simplify backbone and parallel code paths from PR #9343

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/5bcd7f31-c5cc-4d1f-9ef1-6647950bab25

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-04-23 16:17:42 +02:00
Copilot
99f64b80fa
Prevent unsound solve-eqs elimination across recursive-function definitions (#9358)
* Initial plan

* Prevent unsound solve-eqs elimination across recursive-function definitions

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/9a2fc92f-15e8-4806-988b-28bce96e8007

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

* Update solve_eqs.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-04-23 16:17:21 +02:00
Nikolaj Bjorner
abd378e9d8 assert backbone to local context in backbone worker
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-22 18:40:44 -07:00
Nikolaj Bjorner
725772dfec add failed literal backbone variant
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-22 17:30:10 -07:00
Nikolaj Bjorner
5f7e14315d fix tests
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-22 10:54:06 -07:00
CEisenhofer
3873f387be Model construction has to respect the length constraints 2026-04-22 19:51:09 +02:00
Nikolaj Bjorner
c6b595d981 fix inverted logic of is-linear, #9311
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-22 09:28:14 -07:00
Arie
87e45accd9
Throttle lia2card in QF_NIA preamble (#9362)
mk_qfnia_preamble invoked lia2card with no params, so the default
max_range=101 was in effect. Any integer variable with a concrete
range hi-lo <= 101 was expanded into that many fresh Booleans plus
a sum-of-ITEs, bloating SAT search alongside the nonlinear structure.
On an observed QF_UFNIA benchmark this drove a 0.2s problem to a 30s
timeout.

Mirror the throttle already applied in mk_preamble_tactic
(qflia_tactic.cpp, commit 99cbfa715): limit lia2card to 0-1 integer
variables and nesting depth 1. Wrap with using_params so the
override survives and_then's downstream updt_params calls (passing
the params to mk_lia2card_tactic alone is overwritten when and_then
re-propagates the ambient params to each child).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 17:58:28 +02:00
CEisenhofer
0a1eb26952 Avoid Skolem functions for length and symbolic characters introduced during Nielsen saturation (power exponents are still Skolem functions) 2026-04-22 11:06:55 +02:00
dependabot[bot]
a155b2f86f
Bump nuget/setup-nuget from 3 to 4 (#9350)
Bumps [nuget/setup-nuget](https://github.com/nuget/setup-nuget) from 3 to 4.
- [Release notes](https://github.com/nuget/setup-nuget/releases)
- [Commits](https://github.com/nuget/setup-nuget/compare/v3...v4)

---
updated-dependencies:
- dependency-name: nuget/setup-nuget
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-21 19:26:55 +02:00
dependabot[bot]
7c32f65c37
Bump julia-actions/setup-julia from 2 to 3 (#9349)
Bumps [julia-actions/setup-julia](https://github.com/julia-actions/setup-julia) from 2 to 3.
- [Release notes](https://github.com/julia-actions/setup-julia/releases)
- [Commits](https://github.com/julia-actions/setup-julia/compare/v2...v3)

---
updated-dependencies:
- dependency-name: julia-actions/setup-julia
  dependency-version: '3'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-21 19:26:41 +02:00
Nikolaj Bjorner
aed76af2b5 deal with code smells/duplicate
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-21 18:57:25 +02:00
CEisenhofer
46364a1502 Extract argument of unit when adding constant character to range 2026-04-21 18:54:36 +02:00
CEisenhofer
8b2643ff02 Missing unit around symbolic characters 2026-04-21 18:38:03 +02:00
Nikolaj Bjorner
b2fa00ecf4 fix vector<le, false> to vector<le> we need the copy and destructor semantics for expr_ref
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-21 18:37:23 +02:00
CEisenhofer
03c990e0e1 Push substitutions back to base solver 2026-04-21 18:29:40 +02:00
Nikolaj Bjorner
4446705eae clean up conflict generation
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-21 18:28:25 +02:00
Nikolaj Bjorner
3296681a19 add code review comments
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-21 17:17:19 +02:00
Nikolaj Bjorner
40122b494c add comments, fix a bug in early return for min-term version of expansion
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-21 16:49:29 +02:00
Nikolaj Bjorner
3beeadfe51 nits
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-21 16:20:17 +02:00
CEisenhofer
ec92a532b8 Use dedicated string variables based on mod. count 2026-04-21 10:53:35 +02:00
Nikolaj Bjorner
8cc85a7d7b code simplification, fix conflict in new_diseq_eh
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-21 10:17:43 +02:00
Nikolaj Bjorner
352b14fe2b fix and optimize not-contains and regex equalities
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-21 09:16:00 +02:00
Nikolaj Bjorner
c18188cba8 avoid crashes in cases like wildcard-matching-regex-67.smt2, need regex constraint solving
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-21 05:44:53 +02:00