3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-19 15:16:29 +00:00
z3/src
Copilot 206569c0d6
fix: negate offset on swap in seq_offset_eq::find (#9722)
`seq_offset_eq::find` returned the stored offset with the wrong sign
whenever the enode arguments were reordered to match the canonical key
ordering (`r1.id ≤ r2.id`), causing `len_based_split` to silently skip
~50% of eligible length-based splits.

### Root cause

`m_offset_equalities` stores `(rA, rB) → v` meaning `len(rA) − len(rB) =
v` with `rA.id ≤ rB.id`. `len_offset()` correctly negates `val` when
inserting with swapped keys. `find()` performed the same swap for the
lookup but never negated the returned value, so callers received
`len(n2) − len(n1)` instead of `len(n1) − len(n2)`.

### Fix

```cpp
// BEFORE
if (n1->get_owner_id() > n2->get_owner_id())
    std::swap(n1, n2);
if (m_offset_equalities.find(n1, n2, offset))
    return offset;  // wrong sign when swapped

// AFTER
bool swapped = n1->get_owner_id() > n2->get_owner_id();
if (swapped)
    std::swap(n1, n2);
if (m_offset_equalities.find(n1, n2, offset))
    return swapped ? -offset : offset;
```

This makes `find` consistent with the documented contract (`r1 = r2 +
offset`) and symmetric with the insertion logic in `len_offset()`.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-06-06 13:25:16 -07:00
..
ackermannization Fix off-by-one vulnerabilities: use range-based for on goals; cache loop bound 2026-02-19 22:37:22 +00:00
api fix(make-ts-wrapper): correct out buffer size for WASM (#9644) 2026-05-27 10:03:39 -07:00
ast Corrected string extraction 2026-06-05 19:57:00 +02:00
cmd_context update tptp front-end 2026-05-25 09:31:25 -07:00
math Fix mpz_manager leak in algebraic root comparison (#9654) 2026-05-28 09:06:05 -07:00
model disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
muz ensure engine is datalog for dl_table and dl_util tests 2026-05-31 15:32:23 -07:00
nlsat making try-for tactic exception resilient on cancelation 2026-04-26 15:58:24 -07:00
opt fix box mode: reset bounds before each objective 2026-03-19 17:07:21 -10:00
params First attempt for monadic decomposition 2026-06-05 18:40:36 +02:00
parsers Add SMT-LIB choice support via array OP_CHOICE and instantiate choice axioms in array solvers (#9649) 2026-05-27 10:05:06 -07:00
qe Fix MBP QEL soundness bug in datatype accessor elimination (#9571) (#9692) 2026-06-03 07:23:21 -07:00
sat Add SMT-LIB choice support via array OP_CHOICE and instantiate choice axioms in array solvers (#9649) 2026-05-27 10:05:06 -07:00
shell benchmark patching 2026-05-20 13:32:23 -07:00
smt fix: negate offset on swap in seq_offset_eq::find (#9722) 2026-06-06 13:25:16 -07:00
solver SMT2 front-end: accept HO_ALL and normalize curried expression-head applications (#9636) 2026-05-26 18:39:38 -07:00
tactic build warnings 2026-05-29 10:17:46 -07:00
test Merge branch 'master' into c3 2026-06-03 17:33:26 +02:00
util Merge branch 'master' into c3 2026-06-03 17:33:26 +02:00
CMakeLists.txt Move seq_nielsen from src/ast/rewriter to src/smt/seq with new smt_seq component 2026-03-03 00:17:10 +00:00