3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-07 09:42:14 +00:00
Commit graph

20697 commits

Author SHA1 Message Date
Lev Nachmanson
76a2bf5378 set nlsat.lws=true by default, enable levelwise
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-04 06:02:35 -10:00
Lev Nachmanson
879bc4cf73 set default to nlsat.lws=false for the merge with master
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-04 05:32:17 -10:00
Lev Nachmanson
beacd43587 fix issue 8397
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-03 12:14:34 -10:00
Lev Nachmanson
46eeddae52 fix the explosion in m_todo with lws.false
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-03 10:01:16 -10:00
Lev Nachmanson
7290df5794 untracking .beads
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-03 08:01:58 -10:00
Lev Nachmanson
156a7da4d1 remove warnings
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-02 16:45:01 -10:00
Lev Nachmanson
4587ecec9c add lc(p) and disc(p) for a rootless p in section case
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-02 16:39:30 -10:00
Lev Nachmanson
a19db1f7a7 fix a typo in poly_has_roots
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-02 14:41:55 -10:00
Lev Nachmanson
60f9edb65f preserve random seed in nlsat_solver::check_lemma
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-02 13:31:33 -10:00
Lev Nachmanson
f1a6f85ae5 fiddle with heuristics
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-02 11:47:48 -10:00
Lev Nachmanson
8d90031831 remove the unsound optimization
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-01 10:09:51 -10:00
Lev Nachmanson
ec3149cf33 fix a bug with skipping a vanishing discriminant
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-02-01 06:34:12 -10:00
Lev Nachmanson
8349e3eab6 add the discriminant in degenerated case
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 21:34:57 -10:00
Lev Nachmanson
8a708a85e6 bug fixes and cleanup
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
54661a7d22 simplifications and bug fixes in lws, use static_tree only with sector + different bound polynomials, otherwise us biggest cell
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
5e1c104667 t
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
7cfafc133f fix bug with skipping too many discriminants
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
f429a57384 Simplify levelwise: remove chain/lowest_degree heuristics, unify relation
mode

     - Remove chain and lowest_degree heuristics, keep only biggest_cell and spanning_tree
     - Unify m_sector_relation_mode and m_section_relation_mode into single m_rel_mode
     - Remove lws_rel_mode, lws_sector_rel_mode, lws_section_rel_mode, lws_dynamic_heuristic params
     - lws_spt_threshold < 2 now disables spanning tree (single tuning parameter)
     - Restore noDisc optimization for spanning_tree leaves connected to boundary
     - Add noDisc for sector with same_boundary_poly (treat like section case)
     - Significant code reduction (~390 lines removed)

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
b2268544d1 remove sector/section stats
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
881ec43256 restore a deleted function
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
6595c72f30 bug fixes
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
e84844a873 fix the build
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
7ffc5d9eb1 Enforce bound polynomial LC protection in compute_omit_lc functions
Move the invariant that bound-defining polynomials must never have their
LC omitted from add_level_projections_sector() into the source functions:
- compute_omit_lc_both_sides()
- compute_omit_lc_chain_extremes()

This centralizes the protection and removes the redundant override check.
2026-01-31 15:56:43 -10:00
Lev Nachmanson
831a02a1dd Remove deprecated project_original and cell_sample parameter
- Remove project_original() function from nlsat_explain.cpp
- Remove m_sample_cell_project member variable
- Simplify project() to just call project_cdcac()
- Remove cell_sample parameter from nlsat_params.pyg
- Update nlsat_solver.cpp to remove cell_sample() references
- Update nlsat_explain.h constructor signature
2026-01-31 15:56:43 -10:00
Lev Nachmanson
c4bc251aef Fix nlsat projection bug: ensure polynomials with assumptions are also projected
When polynomials are added as assumptions (via add_assumption or ensure_sign),
they must also be added to the projection set (m_todo) to ensure proper cell
construction. Previously, assumptions were added without corresponding projection,
leading to unsound lemmas.

Fixes:
1. In normalize(): collect lower-stage polynomials in m_lower_stage_polys and
   add them to m_ps in main() before projection.
2. In ensure_sign(): call insert_fresh_factors_in_todo(p) after adding assumption.
3. In project_cdcac(): when levelwise fails, use flet to set m_add_all_coeffs=true
   for the fallback projection.
2026-01-31 15:56:43 -10:00
Lev Nachmanson
a8b8e10d20 add both side spanning tree heuristic
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
a297f2d5cb count added lcs in the heuriistic estimates
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
e4140a737e remove m_level_tags
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
d2e086fe79 use std_vector
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
777b289546 call omit_lc only when both bounds are present
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
39dbbd0174 local optimization
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
3ebc378fa3 Add dynamic heuristic selection for levelwise projection
Implement weight-based dynamic selection of projection heuristics in
levelwise CAD. The weight function w(p, level) = deg(p, level) estimates
projection complexity, with w(res(a,b)) ≈ w(a) + w(b).

At each level, all three heuristics (biggest_cell, chain, lowest_degree)
are evaluated and the one with minimum estimated resultant weight is
selected. When fewer than 2 root functions exist, the default heuristic
is used since all produce equivalent results.

Add parameter nlsat.lws_dynamic_heuristic (default: true) to enable or
disable dynamic selection. When disabled, the static heuristic from
lws_sector_rel_mode/lws_section_rel_mode is used.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
2ee1319268 Refactor levelwise: change m_todo from pointer to member
- Change m_todo from todo_set* to todo_set
- Initialize m_todo in constructor initializer list
- Use m_todo.reset() in single_cell_work instead of creating local todo_set
- Replace pointer access (m_todo->) with member access (m_todo.)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
a63a36dff6 Refactor levelwise: use member variables for per-level state
Replace local variables and function parameters with member variables:
- m_level_ps: polynomials at current level (owned)
- m_level_tags: tags for each polynomial (owned)
- m_witnesses: non-zero coefficient witnesses
- m_poly_has_roots: which polynomials have roots
- m_todo: pointer to todo_set

Functions now use these member variables directly:
- extract_max_tagged() fills m_level_ps/m_level_tags and sets m_level
- process_level() and process_top_level() are now parameterless
- All helper functions use member variables instead of parameters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
4234d6ad8c Refactor levelwise: consolidate partition indices into m_l_rf/m_u_rf
Replace scattered local l_index/u_index parameters and m_partition_boundary
with two impl members:
- m_l_rf: position of lower bound in m_rel.m_rfunc
- m_u_rf: position of upper bound in m_rel.m_rfunc (UINT_MAX in section case)

This simplifies the code by:
- Removing parameter passing through multiple function calls
- Removing redundant m_partition_boundary from relation_E
- Making the partition state explicit in impl

Also clean up nlsat_explain.cpp to trust root_function_interval invariants:
- Section case: assert l and l_index are valid instead of defensive check
- Sector bounds: !l_inf()/!u_inf() implies valid polynomial and index

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
3e52fbb33d Cache partition boundary to avoid repeated algebraic number comparisons
Store the partition boundary (index of first root > sample) in
relation_E after sorting root functions. Use this cached value
in compute_omit_lc_sector_chain() and compute_omit_lc_section_chain()
instead of recomputing via algebraic number comparisons.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
6b7576c3e0 Restrict noDisc optimization to section_lowest_degree only
Match SMT-RAT behavior: noDisc (discriminant omission for leaves
connected only to section polynomial) is only applied for
sectionHeuristic == 3 (lowest_degree), not for biggest_cell or chain.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
aafc29d2fc Implement chain noLdcf optimization matching SMT-RAT
Add find_partition_boundary() helper to locate the boundary between
lower and upper root partitions in m_rfunc.

Implement compute_omit_lc_sector_chain() and compute_omit_lc_section_chain()
following SMT-RAT's OneCellCAD.h logic:
- Omit ldcf for extreme of lower chain (index 0) if it appears on upper side
- Omit ldcf for extreme of upper chain (last index) if it appears on lower side

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
3a08ee7433 disables some heuristics in section
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
f0b939cbd4 t
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
a5abf0c72a align with SMT-RAT
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
3a84067075 toward more like SMT-RAT split
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:43 -10:00
Lev Nachmanson
e4976ef0a3 ignore const non-null witnesses
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:42 -10:00
Lev Nachmanson
0b20411fba Revert "cache the polynomial roots"
This reverts commit aefcd16aaa.
2026-01-31 15:56:42 -10:00
Lev Nachmanson
13e3b64068 cache the polynomial roots
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:42 -10:00
Lev Nachmanson
00595d7a6a refactor
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:42 -10:00
Lev Nachmanson
f534c15205 refactor 2026-01-31 15:56:42 -10:00
Lev Nachmanson
13ef7cc6f4 refactor
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:42 -10:00
Lev Nachmanson
5bc7ad0c6c discard a discriminant only in the section case
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:42 -10:00
Lev Nachmanson
895f7d5fde try optimizing build_interval_and_relation
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2026-01-31 15:56:42 -10:00