3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-07-15 11:35:42 +00:00
z3/src/test
Copilot 26ad30bb76
Fix invalid sequence models for seq.foldl results observed through seq.nth (#10111)
`seq.foldl` could produce a concrete sequence model while related
`seq.nth` constraints were still validated against stale or
underconstrained length information, leading to invalid models. In the
reported case, `all` was modeled as `(seq.++ (seq.unit 7) (seq.unit 0))`
while `final = (seq.nth all 0)` remained inconsistent with `final = 6`.

- **Root cause**
- Sequence solutions were propagated as equalities, but parent `seq.len`
terms were not updated when a sequence term was solved.
- As a result, `seq.nth` guard reasoning could miss that a solved
sequence had known in-bounds length.

- **Solver change**
- Extend `theory_seq::add_solution` to collect parent `seq.len`
expressions of a solved term when the solved result is sequence-typed.
- After propagating the solved sequence equality, also propagate the
rewritten length equality for those parent length terms.
- Keep this propagation guarded to sequence results so scalar
`seq.foldl`/`seq.foldli` solutions do not regress from `sat` to
`unknown` under model validation.

- **Regression coverage**
  - Add a focused test for the reported SMT-LIB pattern:
    - `all = seq.foldl(...)`
    - `final = seq.nth all 0`
    - `initial = 0`
    - `final = 6`
- Add focused scalar `seq.foldl`/`seq.foldli` model-validation coverage
for the existing benchmark shapes that must continue returning `sat`.
- The regressions check both that model validation no longer reports an
invalid model for the `seq.nth` case and that scalar fold/foldi cases do
not regress to `unknown`.

- **Effect**
- Solved sequence terms now push enough derived length information for
dependent `seq.nth` constraints to validate against the actual modeled
sequence.
  - Existing scalar fold/foldi solving behavior is preserved.

```smt2
(define-fun all_sums ((prev_sums (Seq Int)) (elem Int)) (Seq Int)
  (seq.++ (seq.unit (+ (seq.nth prev_sums 0) elem)) prev_sums)
)

(assert (= all (seq.foldl all_sums (seq.unit initial) elements)))
(assert (= final (seq.nth all 0)))
(assert (= initial 0))
(assert (= final 6))
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-07-13 17:33:39 -07:00
..
fuzzing test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
lp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
ackermannize.cpp fix build warnings 2026-06-22 18:20:23 -07:00
algebraic.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
algebraic_numbers.cpp fix edge case in algebraic number comparison (#9498) 2026-05-27 05:01:47 -07:00
api.cpp Fix GMP bit-vector modulo semantics causing signed BV unsoundness and invalid SMT2 numerals (#9899) 2026-06-19 10:08:51 -06:00
api_algebraic.cpp Add tests for ackermannization module and Z3_algebraic_eval 2026-02-19 18:18:19 +00:00
api_ast_map.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
api_bug.cpp make include paths uniformly use path relative to src. #534 2017-07-31 13:24:11 -07:00
api_datalog.cpp Fix api_datalog test: reuse of Z3_context across set-logic calls (#10101) 2026-07-12 20:32:02 -07:00
api_pb.cpp Daily Test Coverage Improver: Add comprehensive API pseudo-boolean constraint tests (#7898) 2025-09-17 20:45:43 -07:00
api_polynomial.cpp preserve the initial state of the solver with push/pop for multiple objectives (#8264) 2026-02-18 20:57:53 -08:00
api_special_relations.cpp Daily Test Coverage Improver: Add comprehensive API special relations tests (#7925) 2025-09-18 09:20:14 -07:00
arith_rewriter.cpp Fix non-termination in mod rewriter for symbolic modulus (#10105) 2026-07-13 09:20:03 -07:00
arith_simplifier_plugin.cpp move smt params to params directory, update release.yml 2025-06-09 10:47:22 -07:00
ast.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
bdd.cpp Additional BDD operations; BDD vectors and finite domain abstraction 2022-08-01 18:37:11 +03:00
bit_blaster.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
bit_vector.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
bits.cpp [WIP] Update code base to use std::span (#8269) 2026-02-18 20:57:51 -08:00
buffer.cpp make include paths uniformly use path relative to src. #534 2017-07-31 13:24:11 -07:00
chashtable.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
check_assumptions.cpp move smt params to params directory, update release.yml 2025-06-09 10:47:22 -07:00
CMakeLists.txt Porting seq_split to master (#9840) 2026-06-30 10:18:28 -07:00
cnf_backbones.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
cube_clause.cpp fix build of tests 2022-06-17 17:11:18 +01:00
datalog_parser.cpp move smt params to params directory, update release.yml 2025-06-09 10:47:22 -07:00
ddnf.cpp disable tracing in test code 2025-06-08 08:08:10 -07:00
deep_api_bugs.cpp fix build warnings 2026-06-22 18:20:23 -07:00
diff_logic.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
distribution.cpp add tests for distribution utility and fix loose ends 2023-04-13 11:19:06 -07:00
dl_context.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
dl_product_relation.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
dl_query.cpp Adopt std::optional for try_get_value and try_get_size functions (#8268) 2026-02-18 20:57:50 -08:00
dl_relation.cpp fix: fix memory leaks detected by ASan in test code 2026-03-09 16:48:17 +00:00
dl_table.cpp ensure engine is datalog for dl_table and dl_util tests 2026-05-31 15:32:23 -07:00
dl_util.cpp add include directive 2026-06-01 11:39:18 -07:00
dlist.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
doc.cpp fix build warnings 2026-06-22 18:20:23 -07:00
egraph.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
escaped.cpp fix build of tests 2022-06-17 17:11:18 +01:00
euf_arith_plugin.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
euf_bv_plugin.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
ex.cpp add noexcept for signature compatibility 2024-11-04 11:13:49 -08:00
expr_rand.cpp fix a couple hundred deref-after-free bugs due to .c_str() on a temporary string 2020-07-11 20:24:45 +01:00
expr_substitution.cpp Add std::initializer_list overloads for BV and arith operations (#8467) 2026-02-18 20:58:02 -08:00
ext_numeral.cpp fixes 2017-08-27 11:01:45 -07:00
f2n.cpp fix build of tests 2022-06-17 17:11:18 +01:00
factor_rewriter.cpp fix build of tests 2022-06-17 17:11:18 +01:00
finder.cpp consolidate literals 2021-05-20 12:58:27 -07:00
finite_set.cpp Fix finite_set sort cardinality computation for finite base sorts (#7997) 2025-10-23 17:30:17 +02:00
finite_set_rewriter.cpp fix test 2025-10-15 20:55:27 +02:00
fixed_bit_vector.cpp make include paths uniformly use path relative to src. #534 2017-07-31 13:24:11 -07:00
for_each_file.cpp remove dependency on ARRAYSIZE for issue #1616 2018-08-15 22:26:14 -07:00
for_each_file.h booyah 2020-07-04 15:56:30 -07:00
fpa.cpp Fix soundness bug in fpa2bv mk_to_real: wrong exponent power for negative exponents (#9513) 2026-05-13 06:11:36 -04:00
get_consequences.cpp fix build of tests 2022-06-17 17:11:18 +01:00
get_implied_equalities.cpp tune for unit test, delay initialize re-solver 2018-05-13 11:49:33 -07:00
hashtable.cpp fix build warnings 2026-06-22 18:20:23 -07:00
heap.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
heap_trie.cpp fix build of tests 2022-06-17 17:11:18 +01:00
hilbert_basis.cpp fix build warnings 2026-06-22 18:20:23 -07:00
ho_matcher.cpp bugfixes to front-end and matcher 2026-07-06 17:14:41 -07:00
horn_subsume_model_converter.cpp fixing build 2022-11-03 22:08:21 -07:00
horner.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
hwf.cpp fix #7143: type punning in test 2024-03-04 14:34:02 +00:00
im_float_config.h booyah 2020-07-04 15:56:30 -07:00
inf_rational.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
interval.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
karr.cpp fix build of tests 2022-06-17 17:11:18 +01:00
lcube.cpp Lcube (#9858) 2026-06-14 16:25:21 -07:00
list.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
main.cpp Porting seq_split to master (#9840) 2026-06-30 10:18:28 -07:00
map.cpp make include paths uniformly use path relative to src. #534 2017-07-31 13:24:11 -07:00
matcher.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
mbp_qel.cpp Cleanup thanks to Copilot (#9709) 2026-06-04 10:46:33 -07:00
memory.cpp fix build warnings 2026-06-22 18:20:23 -07:00
mod_factor.cpp Fix unsound array equality rewrite for const-array store chains (#9572) 2026-05-21 11:15:42 -07:00
model2expr.cpp fix build of tests 2022-06-17 17:11:18 +01:00
model_based_opt.cpp fix unit test 2025-02-17 20:36:38 -08:00
model_evaluator.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
model_retrieval.cpp move smt params to params directory, update release.yml 2025-06-09 10:47:22 -07:00
monomial_bounds.cpp Add comprehensive test coverage for math/lp and math/polynomial modules (#7877) 2025-09-14 14:57:21 -07:00
mpbq.cpp fix build of tests 2022-06-17 17:11:18 +01:00
mpf.cpp disable tracing in test code 2025-06-08 08:08:10 -07:00
mpff.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
mpfx.cpp fix build of tests 2022-06-17 17:11:18 +01:00
mpq.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
mpz.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
nla_intervals.cpp Fixes for lar_term== operator (#9284) 2026-04-12 14:31:18 -07:00
nlarith_util.cpp fix build of tests 2022-06-17 17:11:18 +01:00
nlsat.cpp Strengthen historical nlsat regression tests (#9857) 2026-06-16 11:36:13 -06:00
no_overflow.cpp Modernize C++ patterns: range-based for loops and nullptr (#8167) 2026-02-18 20:57:10 -08:00
object_allocator.cpp fix build warnings 2026-06-22 18:20:23 -07:00
old_interval.cpp fix build of tests 2022-06-17 17:11:18 +01:00
optional.cpp Adopt std::optional for try_get_value and try_get_size functions (#8268) 2026-02-18 20:57:50 -08:00
parametric_datatype.cpp fix build warnings 2026-06-22 18:20:23 -07:00
parray.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
pb2bv.cpp move smt params to params directory, update release.yml 2025-06-09 10:47:22 -07:00
pdd.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
pdd_solver.cpp Refactor mk_and/mk_or call sites to use vector overloads (#8286) 2026-02-18 20:57:52 -08:00
permutation.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
polynomial.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
polynomial_factorization.cpp Implement multivariate polynomial factorization via Hensel lifting 2026-03-24 06:25:29 -10:00
polynorm.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
prime_generator.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
proof_checker.cpp Improve test validation for mk_transitivity 2026-02-18 21:02:26 -08:00
psmt.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
qe_arith.cpp Refactor mk_and and mk_app to use std::span API (#8285) 2026-02-18 20:57:52 -08:00
quant_elim.cpp move smt params to params directory, update release.yml 2025-06-09 10:47:22 -07:00
quant_solve.cpp Add QE regression for unsound check-sat-using qe result on quantified reals (#10097) 2026-07-12 18:53:15 -07:00
random.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
range_predicate.cpp Derive with ranges (#9965) 2026-06-26 08:44:13 -06:00
rational.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
rcf.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
regex_range_collapse.cpp Derive with ranges (#9965) 2026-06-26 08:44:13 -06:00
region.cpp make include paths uniformly use path relative to src. #534 2017-07-31 13:24:11 -07:00
sat_local_search.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
sat_lookahead.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
sat_user_scope.cpp fix build of tests 2022-06-17 17:11:18 +01:00
scoped_timer.cpp fix build of tests 2022-06-17 17:11:18 +01:00
scoped_vector.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
seq_regex_bisim.cpp Derive with ranges (#9965) 2026-06-26 08:44:13 -06:00
seq_rewriter.cpp Fix invalid sequence models for seq.foldl results observed through seq.nth (#10111) 2026-07-13 17:33:39 -07:00
seq_split.cpp Porting seq_split to master (#9840) 2026-06-30 10:18:28 -07:00
simple_parser.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
simplex.cpp Spacer Global Guidance (#6026) 2022-08-30 15:47:00 -07:00
simplifier.cpp Fix sat.smt=true model reconstruction for QF_UFBV with Bool-valued UF predicates (#9519) 2026-05-14 04:19:37 -04:00
sls_seq_plugin.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
sls_test.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
small_object_allocator.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
smt2print_parse.cpp re-enable unit tests 2026-06-02 10:39:41 -07:00
smt_context.cpp Fix qe-lite de Bruijn reindexing after bounded quantifier expansion (#9996) 2026-06-29 09:53:02 -07:00
solver_pool.cpp fix build of tests 2022-06-17 17:11:18 +01:00
sorting_network.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
stack.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
string_buffer.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
substitution.cpp move smt params to params directory, update release.yml 2025-06-09 10:47:22 -07:00
symbol.cpp make include paths uniformly use path relative to src. #534 2017-07-31 13:24:11 -07:00
symbol_table.cpp make include paths uniformly use path relative to src. #534 2017-07-31 13:24:11 -07:00
tbv.cpp test: replace SASSERT with ENSURE, remove Windows-only guards (#10086) 2026-07-11 21:14:59 -07:00
term_enumeration.cpp Term enumeration (#9908) 2026-06-20 18:14:44 -06:00
test_util.h make include paths uniformly use path relative to src. #534 2017-07-31 13:24:11 -07:00
theory_dl.cpp fix build of tests 2022-06-17 17:11:18 +01:00
theory_pb.cpp disable tracing in test code 2025-06-08 08:08:10 -07:00
timeout.cpp make include paths uniformly use path relative to src. #534 2017-07-31 13:24:11 -07:00
total_order.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
totalizer.cpp add totalizer version of rc2 2022-06-29 23:10:42 -07:00
tptp.cpp Fix TPTP front-end precedence and Int/Real coercion bugs 2026-06-29 15:00:56 -07:00
trigo.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
udoc_relation.cpp set up udoc relation to use datalog engine 2026-06-01 19:06:25 -07:00
uint_set.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
upolynomial.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
value_generator.cpp fix build of tests 2022-06-17 17:11:18 +01:00
value_sweep.cpp fix build of tests 2022-06-17 17:11:18 +01:00
var_subst.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
vector.cpp Add vector::resize tests including vector<rational> 2026-03-11 23:54:01 +00:00
zstring.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00