3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-19 23:26:30 +00:00
z3/src/test
Copilot 8c2a425e4b
Smart constructors for regex ranges: canonical form at construction time (#9814)
Regex range expressions (`re.range`) and Boolean operations over them
were left in unsimplified form, defeating downstream optimisations
(bisimulation classical fast-path, derivative engine) and producing
semantically-empty terms not syntactically equal to `re.none`.

## Changes

### `seq_decl_plugin.h` / `seq_decl_plugin.cpp`

- **`seq_util::rex::mk_range(sort*, unsigned lo, unsigned hi)`** — new
smart constructor that normalises at call time:
  - `lo > hi` → `re.empty`
  - `lo == hi` → `str.to_re` (singleton string)
  - `lo < hi` → `re.range`
- **`mk_info_rec` `OP_RE_RANGE`** — concrete non-empty ranges (both
bounds are single-char literals with `lo ≤ hi`) now return `classical =
true`, enabling the XOR-bisimulation `classical_distinguishing`
fast-path on character-predicate leaves. Symbolic/unknown ranges retain
`classical = false`.

### `seq_rewriter.cpp`

- **`mk_re_range`** — singleton collapse: `(re.range "a" "a")` →
`(str.to_re "a")`
- **`mk_regex_inter_normalize`** — range × range intersection: `[a,b] ∩
[c,d]` → `[max(a,c), min(b,d)]`, or `re.none` (disjoint), or `str.to_re`
(boundary singleton); now delegates to `re().mk_range(sort*, lo, hi)`
- **`mk_regex_union_normalize`** — range × range union for
overlapping/adjacent ranges: `[a,b] ∪ [c,d]` → `[min(a,c), max(b,d)]`;
disjoint ranges fall through to existing `merge_regex_sets`; now
delegates to `re().mk_range(sort*, lo, hi)`
- **`mk_re_complement`** — range complement expands to one or two
concrete ranges instead of an opaque `re.comp` node; now delegates to
`re().mk_range(sort*, lo, hi)`:
  - `comp([0, b])` → `[b+1, max]`
  - `comp([a, max])` → `[0, a-1]`
  - `comp([a, b])` → `[0, a-1] ∪ [b+1, max]`

```
(simplify (re.range "z" "a"))                              ; → re.none
(simplify (re.range "a" "a"))                              ; → (str.to_re "a")
(simplify (re.inter (re.range "a" "z") (re.range "f" "k"))); → (re.range "f" "k")
(simplify (re.union (re.range "a" "f") (re.range "g" "k"))); → (re.range "a" "k")
(simplify (re.comp  (re.range "b" "y")))                   ; → (re.union [0,a] [z,max])
```

### Tests

New `src/test/seq_rewriter.cpp` with 14 cases covering all the above
reductions plus downstream propagation (star/concat/union/inter
absorbing empty ranges).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-06-16 13:58:56 -06:00
..
fuzzing fix test build 2023-12-22 16:19:28 +00:00
lp Lcube (#9858) 2026-06-14 16:25:21 -07:00
ackermannize.cpp Fix test_ackermannize_bv_model: skip crashing model converter test, keep 4 passing tests 2026-02-19 21:07:30 +00: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 update count to 2 2026-04-09 16:39:51 -07: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 Prevent Spacer segfault on ADT CHCs by hardening datatype model-value construction (#9571) 2026-05-20 16:04:41 -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 #7507: simplify (>= product_of_consecutive_ints 0) to true 2026-02-27 06:37:07 -10: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 Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08: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 Smart constructors for regex ranges: canonical form at construction time (#9814) 2026-06-16 13:58:56 -06: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 add bugs 2026-03-12 15:18:38 -07:00
diff_logic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01: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 fix #6213 2022-07-31 18:40:59 +03: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 Sls (#7439) 2024-11-02 12:32:48 -07:00
doc.cpp ensure engine is datalog for dl_table and dl_util tests 2026-05-31 15:32:23 -07:00
egraph.cpp disable tracing in test code 2025-06-08 08:08:10 -07:00
escaped.cpp fix build of tests 2022-06-17 17:11:18 +01:00
euf_arith_plugin.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
euf_bv_plugin.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08: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 remove a few copies 2026-02-18 21:02:17 -08: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 Refactor mk_and/mk_or call sites to use vector overloads (#8286) 2026-02-18 20:57:52 -08:00
ho_matcher.cpp Refactor mk_and and mk_app to use std::span API (#8285) 2026-02-18 20:57:52 -08: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 Smart constructors for regex ranges: canonical form at construction time (#9814) 2026-06-16 13:58:56 -06: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 Enable more tests on non-Windows. (#6199) 2022-07-29 11:48:27 +02: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 fix build of tests 2022-06-17 17:11:18 +01: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 Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08: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 trim parametric datatype test 2025-10-26 15:32:21 +01: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 Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08: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
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 Refactor mk_and/mk_or call sites to use vector overloads (#8286) 2026-02-18 20:57:52 -08:00
random.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
rational.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
rcf.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08: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 Modernize C++ patterns: range-based for loops and nullptr (#8167) 2026-02-18 20:57:10 -08: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 add scoped_vector invariants and unit tests (#7327) 2024-08-02 19:21:40 -07:00
seq_rewriter.cpp Smart constructors for regex ranges: canonical form at construction time (#9814) 2026-06-16 13:58:56 -06: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 Fix right-side can_add indexing in sls_seq_plugin edit-distance repair (#9773) 2026-06-08 19:36:14 -07:00
sls_test.cpp fix build of test 2026-02-18 21:02:18 -08: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 call it data instead of c_ptr for approaching C++11 std::vector convention. 2021-04-13 18:17:35 -07:00
solver_pool.cpp fix build of tests 2022-06-17 17:11:18 +01:00
sorting_network.cpp Refactor mk_and and mk_app to use std::span API (#8285) 2026-02-18 20:57:52 -08: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 Move tbv to util 2022-08-01 18:37:11 +03: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 disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -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