mirror of
https://github.com/Z3Prover/z3
synced 2026-07-01 21:08:55 +00:00
Fix derivative instability and recursion bugs
- Add top-level cache (m_top_cache) to ensure stable AST node identity across repeated derivative calls, preventing state graph divergence - Add get_head_tail helper for derive_to_re with str.is_unit/str.is_concat - Add ITE hoisting in mk_union/mk_inter to keep ITEs at top level - Add De Morgan rule in mk_complement: ~(A∪B) → ~A ∩ ~B - Add ~ε → .+ simplification in mk_complement - Add prefix factoring: a·x ∪ a·y = a·(x∪y) and a·x ∩ a·y = a·(x∩y) - Add r* ∩ .+ = r+ special case in mk_inter - Enhance is_subset with union/intersection distributivity and complement - Remove De Morgan from mk_inter to prevent infinite recursion loop Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
07cea49e4b
commit
6aea54fdad
2 changed files with 149 additions and 0 deletions
|
|
@ -56,6 +56,7 @@ namespace seq {
|
|||
|
||||
// Cache: maps (ele, regex) pair to its derivative
|
||||
obj_pair_map<expr, expr, expr*> m_cache;
|
||||
obj_pair_map<expr, expr, expr*> m_top_cache; // post-simplify cache
|
||||
expr_ref_vector m_trail; // pin cached results
|
||||
|
||||
// Depth limiting
|
||||
|
|
@ -104,6 +105,9 @@ namespace seq {
|
|||
// Distribute concatenation through ITE/union in derivative
|
||||
expr_ref mk_deriv_concat(expr* d, expr* tail);
|
||||
|
||||
// Extract head character and tail from a sequence expression
|
||||
bool get_head_tail(expr* s1, expr* s2, expr_ref& hd, expr_ref& tl);
|
||||
|
||||
// Lightweight subsumption check: returns true if L(a) ⊆ L(b)
|
||||
bool is_subset(expr* a, expr* b);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue