3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-19 15:16:29 +00:00
z3/src/ast
Margus Veanes c0c826cf5f Stage 3: collapse boolean combinations of char-class regexes
Introduce src/ast/rewriter/regex_range_collapse.{h,cpp}, a translator
between the boolean-combination-of-character-class fragment of regexes
and the range_predicate value type added in Stage 2.

Recognized fragment (translates to range_predicate):
  re.empty, re.full_char, re.range, re.union, re.intersection, re.diff
of operands recursively in the fragment.  Range bounds are accepted in
three encodings: string constant ("a"), seq.unit of a const char
(seq.unit (Char 97)), and length-1 zstring literal.

NOT translated:
  re.complement -- this is sequence-level complement (Sigma* \ L), not
  character-class complement.  Translating it would incorrectly turn
  re.comp(re.range "a" "z") into the character class [^a-z], which would
  drop the empty string and all length>=2 strings.

Hook the translator into seq_rewriter at mk_re_union0, mk_re_union,
mk_re_inter0, mk_re_inter, and mk_re_diff so that boolean combinations
of character classes always reduce to a single canonical range-set
form.  mk_re_complement is intentionally not hooked.

Materialization uses the canonical (seq.unit (Char N)) bound form
(matching the rest of seq_rewriter) and right-associates the union
with operands sorted by expr_id so the result matches the invariant
expected by merge_regex_sets.

Unit tests in src/test/regex_range_collapse.cpp cover the recognized
fragment, the non-translatable cases, and round-trip identity for
multi-range predicates.

Corpus validation on bench/inputs/regex-equivalence (1523 .smt2):
- 0 soundness regressions vs derive baseline.
- Resolves 4 previously-soft-timeout files (now solved correctly).
- Resolves 1 pre-existing wrong answer (mut_0404: master/derive say
  unsat, ground-truth annotation and Stage 3 say sat).
- Wall-time: -2.2% vs Stage-3 starting point, -1.5% vs derive.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-15 03:28:01 -07:00
..
converters Remove redundant explicit default constructors (#8470) 2026-02-18 20:58:01 -08:00
euf Remove redundant min_gen_match search (#9696) 2026-06-03 13:36:51 -07:00
fpa Fix soundness bug in fpa2bv mk_to_real: wrong exponent power for negative exponents (#9513) 2026-05-13 06:11:36 -04:00
macros Add std::initializer_list overloads for update_quantifier and update call sites 2026-02-18 21:02:26 -08:00
normal_forms disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
pattern disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
proofs Refactor mk_and/mk_or call sites to use vector overloads (#8286) 2026-02-18 20:57:52 -08:00
rewriter Stage 3: collapse boolean combinations of char-class regexes 2026-06-15 03:28:01 -07:00
simplifiers disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
sls Add OP_RE_XOR and union-find bisimulation for ground regex equivalence (#9804) 2026-06-10 14:58:20 -07:00
substitution replace some copies with moves 2026-02-18 21:02:17 -08:00
act_cache.cpp Fix static analysis findings: uninitialized vars, bitwise shift UB, garbage values 2026-03-02 00:13:55 +00:00
act_cache.h booyah 2020-07-04 15:56:30 -07:00
arith_decl_plugin.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
arith_decl_plugin.h Fix build warnings: cast size_t to unsigned in arith_decl_plugin.h and bv_decl_plugin.h 2026-02-18 20:58:07 -08:00
array_decl_plugin.cpp 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
array_decl_plugin.h [code-simplifier] Align choice axiom naming in theory_array_full (#9660) 2026-06-01 16:03:42 -07:00
array_peq.cpp code simplification 2025-02-18 19:07:58 -08:00
array_peq.h code simplification 2025-02-18 19:07:58 -08:00
ast.cpp disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
ast.h disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
ast_ll_pp.cpp Fix quoting in low-level pretty printer (#9716) 2026-06-04 15:48:27 -07:00
ast_ll_pp.h remove '#include <iostream>' from headers and from unneeded places 2022-06-17 14:10:19 +01:00
ast_lt.cpp Fix static analysis issues: null dereferences, unsafe casts, branch clones, uninitialized members (#9424) 2026-04-29 13:37:11 -07:00
ast_lt.h booyah 2020-07-04 15:56:30 -07:00
ast_pp.h Reapply PR #8190: Replace std::ostringstream with C++20 std::format (#8204) 2026-02-18 20:57:30 -08:00
ast_pp_dot.cpp Fix static analysis issues: null dereferences, unsafe casts, branch clones, uninitialized members (#9424) 2026-04-29 13:37:11 -07:00
ast_pp_dot.h remove '#include <iostream>' from headers and from unneeded places 2022-06-17 14:10:19 +01:00
ast_pp_util.cpp fixes to mbqi in the new core based on #6575 2023-02-10 16:56:06 -08:00
ast_pp_util.h wip - proof hints 2022-10-08 20:12:57 +02:00
ast_printer.cpp Remove empty leaf destructors. (#6211) 2022-07-30 10:07:03 +01:00
ast_printer.h Use = default for virtual constructors. 2022-08-05 18:11:46 +03:00
ast_smt2_pp.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
ast_smt2_pp.h patch definitions, add pretty print support 2025-10-13 22:39:32 +02:00
ast_smt_pp.cpp Handle choice_k in SMT pretty-printer switch to remove macOS -Wswitch warning (#9734) 2026-06-06 11:37:56 -07:00
ast_smt_pp.h Add and fix a few general compiler warnings. (#5628) 2021-10-29 15:42:32 +02:00
ast_trail.h remove default destructors 2024-10-02 22:20:12 +01:00
ast_translation.cpp disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
ast_translation.h revert my mess with the ast hashtable 2021-02-17 14:29:07 +00:00
ast_util.cpp Fix static analysis issues: null dereferences, unsafe casts, branch clones, uninitialized members (#9424) 2026-04-29 13:37:11 -07:00
ast_util.h Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
bv_decl_plugin.cpp recognize ubv_to_int as part of BV logic 2026-05-27 13:08:54 -07:00
bv_decl_plugin.h delete dead code 2026-02-18 21:02:30 -08:00
char_decl_plugin.cpp Typo Fixes (#6803) 2023-07-09 11:56:10 -07:00
char_decl_plugin.h Typo Fixes (#6803) 2023-07-09 11:56:10 -07:00
CMakeLists.txt move seq_derive and fix include paths, remove antimirov code 2026-06-10 15:23:46 -07:00
cost_evaluator.cpp add priority queue to instantiation 2021-01-31 16:17:52 -08:00
cost_evaluator.h add priority queue to instantiation 2021-01-31 16:17:52 -08:00
datatype_decl_plugin.cpp address #8376 2026-02-18 20:57:58 -08:00
datatype_decl_plugin.h Subterms Theory (#8115) 2026-02-18 20:57:12 -08:00
decl_collector.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
decl_collector.h fixes to mbqi in the new core based on #6575 2023-02-10 16:56:06 -08:00
display_dimacs.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
display_dimacs.h enable wcnf output for weighted maxsat problems 2021-02-28 09:59:36 -08:00
dl_decl_plugin.cpp Adopt std::optional for try_get_value and try_get_size functions (#8268) 2026-02-18 20:57:50 -08:00
dl_decl_plugin.h Adopt std::optional for try_get_value and try_get_size functions (#8268) 2026-02-18 20:57:50 -08:00
expr2polynomial.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
expr2polynomial.h remove default destructors 2024-10-02 22:20:12 +01:00
expr2var.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
expr2var.h booyah 2020-07-04 15:56:30 -07:00
expr_abstract.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
expr_abstract.h wip - throttle AC completion, enable congruences over bound bodies 2025-07-11 12:48:27 +02:00
expr_delta_pair.h Remove redundant default constructors when they're the only constructor (#8461) 2026-02-18 20:58:01 -08:00
expr_functors.cpp call it data instead of c_ptr for approaching C++11 std::vector convention. 2021-04-13 18:17:35 -07:00
expr_functors.h Use = default for virtual constructors. 2022-08-05 18:11:46 +03:00
expr_map.cpp
expr_map.h booyah 2020-07-04 15:56:30 -07:00
expr_stat.cpp Refactor expr_stat to use structured bindings for traversal pairs (#8441) 2026-02-18 20:58:00 -08:00
expr_stat.h Remove redundant default constructors when they're the only constructor (#8461) 2026-02-18 20:58:01 -08:00
expr_substitution.cpp bugfix to elim_uncnstr to ensure nodes are created. Prepare smt_internalizer to replay unit literals 2024-12-04 15:32:15 -08:00
expr_substitution.h wip - testing solve-eqs2, added as tactic 2022-11-05 22:42:59 -07:00
finite_set_decl_plugin.cpp Code simplifications for finite set plugin 2026-02-21 02:08:04 +00:00
finite_set_decl_plugin.h Code simplifications for finite set plugin 2026-02-21 02:08:04 +00:00
for_each_ast.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
for_each_ast.h Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
for_each_expr.cpp remove unneeded iterator functions 2024-09-23 12:59:04 +01:00
for_each_expr.h Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
format.cpp fix #6530 2023-01-10 13:43:17 -08:00
format.h call it data instead of c_ptr for approaching C++11 std::vector convention. 2021-04-13 18:17:35 -07:00
fpa_decl_plugin.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
fpa_decl_plugin.h remove default destructors 2024-10-02 22:20:12 +01:00
func_decl_dependencies.cpp
func_decl_dependencies.h booyah 2020-07-04 15:56:30 -07:00
has_free_vars.cpp fixup std-order / inv-order 2024-10-03 19:35:16 -07:00
has_free_vars.h tune q-eval and q-ematch 2021-09-28 13:41:37 -07:00
is_variable_test.h Add and fix a few general compiler warnings. (#5628) 2021-10-29 15:42:32 +02:00
justified_expr.h move from justified_expr to dependent_expr by aligning datatypes 2025-01-22 11:46:10 -08:00
macro_substitution.cpp remove using insert_if_not_there2 2020-04-25 15:08:51 -07:00
macro_substitution.h booyah 2020-07-04 15:56:30 -07:00
num_occurs.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
num_occurs.h Add and fix a few general compiler warnings. (#5628) 2021-10-29 15:42:32 +02:00
occurs.cpp AIX compat (#8113) 2026-02-18 20:57:04 -08:00
occurs.h #6805 2023-07-11 09:41:29 -07:00
pb_decl_plugin.cpp working on python make for arm 2022-04-07 13:36:23 +02:00
pb_decl_plugin.h Remove empty leaf destructors. (#6211) 2022-07-30 10:07:03 +01:00
polymorphism_inst.cpp Remove copies (#8583) 2026-02-18 21:02:22 -08:00
polymorphism_inst.h wip - alpha support for polymorphism 2023-07-12 18:09:02 -07:00
polymorphism_util.cpp Implement finite_set_decl_plugin with complete operator support and polymorphism infrastructure (#7961) 2025-10-13 10:58:53 +02:00
polymorphism_util.h Implement finite_set_decl_plugin with complete operator support and polymorphism infrastructure (#7961) 2025-10-13 10:58:53 +02:00
pp.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
pp.h booyah 2020-07-04 15:56:30 -07:00
pp_params.pyg print lemmas2console faster 2023-03-20 17:07:04 +01:00
quantifier_stat.cpp move common routines for quantifiers 2021-01-28 13:23:40 -08:00
quantifier_stat.h move common routines for quantifiers 2021-01-28 13:23:40 -08:00
recfun_decl_plugin.cpp fix #9234 2026-04-23 13:54:09 -07:00
recfun_decl_plugin.h remove default destructors 2024-10-02 22:20:12 +01:00
recurse_expr.h booyah 2020-07-04 15:56:30 -07:00
recurse_expr_def.h Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
reg_decl_plugins.cpp Implement finite_set_decl_plugin with complete operator support and polymorphism infrastructure (#7961) 2025-10-13 10:58:53 +02:00
reg_decl_plugins.h booyah 2020-07-04 15:56:30 -07:00
scoped_proof.h overhaul of proof format for new solver 2022-08-28 17:44:33 -07:00
seq_decl_plugin.cpp Add OP_RE_XOR and union-find bisimulation for ground regex equivalence (#9804) 2026-06-10 14:58:20 -07:00
seq_decl_plugin.h Add OP_RE_XOR and union-find bisimulation for ground regex equivalence (#9804) 2026-06-10 14:58:20 -07:00
shared_occs.cpp fix #4112 2020-04-26 21:04:28 -07:00
shared_occs.h cleanup 2022-11-24 22:46:35 +07:00
special_relations_decl_plugin.cpp add EUF plugin framework. 2023-11-30 13:58:30 -08:00
special_relations_decl_plugin.h add EUF plugin framework. 2023-11-30 13:58:30 -08:00
static_features.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
static_features.h disable new code until pre-condition gets fixed 2022-11-30 22:29:59 -08:00
used_symbols.h Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
used_vars.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
used_vars.h #5259 - the Ranjit 2s shave 2021-05-12 10:43:16 -07:00
value_generator.cpp Mark override methods appropriately. (#6207) 2022-07-29 23:29:15 +02:00
value_generator.h Use = default for virtual constructors. 2022-08-05 18:11:46 +03:00
well_sorted.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
well_sorted.h booyah 2020-07-04 15:56:30 -07:00