3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-07-18 13:05:46 +00:00

Fixes for lar_term== operator (#9284)

* Fix broken term_comparer in m_normalized_terms_to_columns lookup

The `m_normalized_terms_to_columns` map in `lar_solver` uses a
`term_comparer` that delegates to `lar_term::operator==`, which
intentionally returns `false` (with comment "take care not to create
identical terms"). This makes `fetch_normalized_term_column` unable to
find any term, rendering the Horner module's `interval_from_term`
bounds-recovery path dead code.

History: `lar_term::operator==` returning `false` has been present since
the original "merge LRA" commit (911b24784, 2018). The
`m_normalized_terms_to_columns` lookup was added later (dfe0e856,
c95f66e0, Aug 2019) as "toward fetching existing terms intervals from
lar_solver". The initial code had `lp_assert(find == end)` on
registration (always true with broken ==) and `lp_assert(find != end)`
on deregister (always false). The very next commit (207c1c50, one day
later) removed both asserts, replacing them with soft checks. The
`term_comparer` struct delegating to `operator==` was introduced during
a later PIMPL refactor (b375faa77).

Fix: Replace the `term_comparer` implementation with a structural
comparison that checks size and then verifies each coefficient-variable
pair via `coeffs().find_core()`. This is localized to the
`m_normalized_terms_to_columns` map and does not change
`lar_term::operator==`, preserving its intentional semantics elsewhere.

Validated: on a QF_UFNIA benchmark, `interval_from_term` lookups go
from 0/573 successful to 34/573 successful. Unit test added for the
`fetch_normalized_term_column` round-trip.

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

* Disable operator== for lar_term

The operator== for lar_term was never intended to be used.
This changes physically disables it to identify what happens to depend
on the operator.

* Work around missing lar_term==

Previous commit disabled lar_term==. This is the only use of the
operator that seems meaningful. Changed it to compare by references
instead.

Compiles, but not sure this is the best solution.

* replace with e

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

* Delete unused ineq::operator==

The operator is unused, so there is no need to figure what is
the best fix for it.

* Remove lp tests that use ineq::operator==

---------

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Arie 2026-04-12 17:31:18 -04:00 committed by GitHub
parent 68e528eaf7
commit 665d4f36ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 94 additions and 21 deletions

View file

@ -1971,28 +1971,28 @@ void test_lp_local(int argn, char **argv) {
if (args_parser.option_is_used("-nla_blfmz_mf")) {
#ifdef Z3DEBUG
nla::test_basic_lemma_for_mon_zero_from_monomial_to_factors();
// nla::test_basic_lemma_for_mon_zero_from_monomial_to_factors();
#endif
return finalize(0);
}
if (args_parser.option_is_used("-nla_blfmz_fm")) {
#ifdef Z3DEBUG
nla::test_basic_lemma_for_mon_zero_from_factors_to_monomial();
//nla::test_basic_lemma_for_mon_zero_from_factors_to_monomial();
#endif
return finalize(0);
}
if (args_parser.option_is_used("-nla_blnt_mf")) {
#ifdef Z3DEBUG
nla::test_basic_lemma_for_mon_neutral_from_monomial_to_factors();
// nla::test_basic_lemma_for_mon_neutral_from_monomial_to_factors();
#endif
return finalize(0);
}
if (args_parser.option_is_used("-nla_blnt_fm")) {
#ifdef Z3DEBUG
nla::test_basic_lemma_for_mon_neutral_from_factors_to_monomial();
// nla::test_basic_lemma_for_mon_neutral_from_factors_to_monomial();
#endif
return finalize(0);
}