3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-20 07:36:31 +00:00
Commit graph

257 commits

Author SHA1 Message Date
Copilot
03a76c0309
euf_sgraph: make drop_left/drop_right depth-linear and simplify string classification (#9771)
ZIPT review identified two hot-path inefficiencies in `euf_sgraph`:
`drop_left`/`drop_right` were implemented as repeated single-token drops
(`O(count × depth)`), and `classify` performed redundant string checks.
This change aligns behavior with the intended tree-navigation approach
while keeping semantics unchanged.

- **Algorithmic update: `drop_left` / `drop_right`**
- Replaced iterative `drop_first`/`drop_last` loops with direct
recursion over concat children.
- New logic drops across subtree boundaries using child lengths,
reducing work to tree depth (`O(depth)`).

- **Classification cleanup: `classify`**
- Collapsed double `is_string` probing into a single `is_string(e, s)`
call.
- Preserves existing kind mapping (`empty` vs non-empty string constant
handling).

- **Focused test coverage extension**
- Added boundary checks in `test_sgraph_drop` for `drop_left(..., 1)`
and `drop_right(..., 1)` on a 4-token concat tree.

```cpp
snode* sgraph::drop_left(snode* n, unsigned count) {
    if (count == 0 || n->is_empty()) return n;
    if (count >= n->length()) return mk_empty_seq(n->get_sort());
    SASSERT(n->is_concat());
    unsigned left_len = n->arg(0)->length();
    if (count < left_len)
        return mk_concat(drop_left(n->arg(0), count), n->arg(1));
    return drop_left(n->arg(1), count - left_len);
}
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-06-10 14:46:03 +02:00
CEisenhofer
e3b80fc578 Merge branch 'master' into c3 2026-06-10 13:41:31 +02:00
CEisenhofer
9f44a9cce8 Flatten concat when deciding if it is constant 2026-06-09 16:39:09 +02:00
Copilot
ad17fe71b1
euf_seq_plugin: root-canonical simplification fixes + loop bound overflow guard (#9744)
`euf_seq_plugin` was applying several regex concat simplifications
against raw child enodes instead of canonical e-graph roots, so rules
could silently miss after merges. It also merged loop bounds with
unchecked unsigned addition, allowing overflowed bounds.

- **Root-canonical checks in simplification rules**
  - Use `get_root()` for nullable/full-seq absorption checks.
- Update `same_star_body` to test `is_star` on roots and compare rooted
star bodies.
- Evaluate extended star rules (`v*.v*.c` / `c.v*.v*`) against concat
roots, not syntactic children.

- **Safe loop merge arithmetic**
- Gate loop merging on overflow-safe bound addition checks before
constructing merged `re.loop`.

- **Re-simplify concats affected by child merges**
- In `propagate_merge`, re-run `propagate_simplify` for tracked concat
nodes whose left/right child root is in the merged class, not only
concats in the class itself.

- **Regression coverage in `src/test/euf_seq_plugin.cpp`**
  - Added focused tests for:
    - star merge firing after child-to-star merge,
    - extended star rule using root concat shape,
    - nullable absorption via merged roots,
    - loop-merge non-application on overflow.

```cpp
// before: structural check on non-canonical enode
if (is_concat(b, b1, b2) && same_star_body(a, b1))

// after: structural check on canonical representative
if (is_concat(b->get_root(), b1, b2) && same_star_body(a, b1))
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-06-08 15:38:55 -07:00
CEisenhofer
67906da97a Corrected string extraction 2026-06-05 19:57:00 +02:00
CEisenhofer
c20bc0e631 First attempt for monadic decomposition 2026-06-05 18:40:36 +02:00
Can Cebeci
b2401b87db
Remove redundant min_gen_match search (#9696)
While working on https://github.com/Z3Prover/z3/pull/9405, I noticed
that euf_mam.cpp code was slightly out of sync with mam.cpp and did some
redundant work.

Co-authored-by: Can Cebeci <t-cancebeci@microsoft.com>
2026-06-03 13:36:51 -07:00
CEisenhofer
043c6c0ad1 Merge branch 'master' into c3 2026-06-03 17:33:26 +02:00
Nikolaj Bjorner
eaf7562a1d disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
CEisenhofer
3908016651 Potentially fixed termination problem with projection operators 2026-06-02 17:04:31 +02:00
CEisenhofer
5b41c6eb9f Better tracking for debugging 2026-06-01 19:50:34 +02:00
Nikolaj Bjorner
dbe986fdf7 move closure conversion to solver internalization
- only the internalizer performs closure conversion
- theory_array treats propagation of lambdas similar to stores
- ho_matcher treats top-level flex patterns as first-order
- pattern-inference fix to handle quantifiers (lambdas) in patterns that are computed
2026-05-30 18:41:37 -07:00
Nikolaj Bjorner
2cc4422018 use expr based access to enodes to allow for storing first-class lambas 2026-05-30 15:13:08 -07:00
CEisenhofer
70031b674c Added real projection operator 2026-05-29 15:51:35 +02:00
Nikolaj Bjorner
48bcee8e62 add lambda-t case in addition to p-lambda case 2026-05-29 01:18:34 -07:00
Nikolaj Bjorner
0b56db7f07 fix #9657 2026-05-28 09:01:48 -07:00
CEisenhofer
4cd908345a Prevent expressions in partial dfa being freed to early 2026-05-26 13:07:38 +02:00
Nikolaj Bjorner
24bb93c3e4 nit 2026-05-24 15:48:10 -07:00
Nikolaj Bjorner
bb73d5fc8e remove redundant code
theory_array_full.cpp performs a similar unfolding of lambda definitions.
2026-05-24 15:39:54 -07:00
Nikolaj Bjorner
24248b3300 code nits 2026-05-24 13:14:25 -07:00
Nikolaj Bjorner
459629c662 bugfixes to ho_matcher
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-05-23 18:06:04 -07:00
Nikolaj Bjorner
98d0e7f27c updates to ho-matcher for lambdas 2026-05-22 14:16:06 -07:00
Nikolaj Bjorner
19166bd0b5 prepare for lambda unfolding in ho-matcher and selectively enable ho matching
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-05-22 13:25:01 -07:00
CEisenhofer
7ede1b9c3d re.plus is a regex as well 2026-05-22 14:03:22 +02:00
Can Cebeci
286b107d7d
Fix oversized enum (#9590)
Co-authored-by: Can Cebeci <t-cancebeci@microsoft.com>
2026-05-21 15:24:35 -07:00
CEisenhofer
9bb0f7e337 Fix some IDE warnings 2026-05-19 16:03:21 +02:00
CEisenhofer
71d7d70080 Missing dependency bug. Still not fixed, but better now 2026-05-12 14:00:50 +02:00
Can Cebeci
2c7b256db2
Use the minimum generation number among matching enodes (#9405)
* Compute term generations based on minimal match

* Tidy up get_*_f_app

* Update euf_mam to the minimum generation number among matches

* Update euf_mam.cpp

* Move the UNREACHABLE() test to smt_mam.cpp

* Enforce stickiness of max-generation

* Add current generation tracking to bind structure

* Fix build error

---------

Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-05-07 18:32:31 -04:00
Copilot
42582c6835
euf_seq_plugin: fix identity elimination after merge, activate loop merging, integrate sgraph improvements (#9414)
* Initial plan

* Initial plan

* Fix identity elimination after merge and activate loop merging in euf_seq_plugin

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/053b94e4-645a-4cde-ae5d-cf6d61222f92

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Apply three ZIPT code review improvements to euf_seq_plugin

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/da8647c4-ddff-47ce-9364-2eee3810c38d

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Address code review: improve loop-merge defensive code and test variable names

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/053b94e4-645a-4cde-ae5d-cf6d61222f92

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Refactor: extract saturating_add helper, simplify hash-check condition

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/da8647c4-ddff-47ce-9364-2eee3810c38d

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-04-29 11:12:00 -07:00
CEisenhofer
82df1afeaf tentative solution: use existing nullability check (we might want to check in the future which guards of the ITE are actually true) 2026-04-14 18:07:03 +02:00
Nikolaj Bjorner
725b13680e na
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-14 08:39:22 -07:00
Nikolaj Bjorner
acae332b13 add spp for easier pretty printing snode
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-14 00:39:01 -07:00
CEisenhofer
38d725dc5a Deriving by allchar should not crash 2026-04-09 11:48:35 +02:00
CEisenhofer
c7e7b40d40 Fix 2026-04-08 09:27:46 +02:00
Nikolaj Bjorner
b60a44c66b classical
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-03 10:33:28 -07:00
Nikolaj Bjorner
cdccd389e9 revert s_unknown
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-03 10:04:13 -07:00
CEisenhofer
a81ce477f5 Added classical regex factorization 2026-04-02 20:08:00 +02:00
CEisenhofer
34cb0a17fc str.at wants a special treatment... 2026-04-02 18:33:44 +02:00
Nikolaj Bjorner
2245451e96 remove aux function
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-04-01 19:07:37 -07:00
CEisenhofer
e25e93503b First try to do better dependency tracking 2026-04-01 15:23:38 +02:00
Nikolaj Bjorner
6d2321e6fe edits to seq_nielsen
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-03-30 17:36:27 -07:00
CEisenhofer
dcc85cf9ef Bug in power elimination 2026-03-26 17:18:38 +01:00
CEisenhofer
3b5b53126e Bug fixing with unit replacement 2026-03-26 15:56:58 +01:00
Nikolaj Bjorner
6a6f9b1892 Merge remote-tracking branch 'origin/master' into c3
# Conflicts:
#	.github/workflows/qf-s-benchmark.lock.yml
#	.github/workflows/qf-s-benchmark.md
#	.github/workflows/zipt-code-reviewer.lock.yml
#	.github/workflows/zipt-code-reviewer.md
#	.gitignore
#	src/ast/rewriter/seq_rewriter.cpp
#	src/test/main.cpp
2026-03-24 17:44:48 -07:00
Nikolaj Bjorner
1863290b71 add deterministic solving for unit equations
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-03-22 15:34:16 -07:00
Copilot
6b5401ef68
Remove s_other from snode_kind; unify under s_var and is_var() (#9087)
* remove s_other, use s_var and is_var() instead

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/d56594ed-7f7e-436a-a4b2-e6dc986b18a8

* fix build: add reset() override to test dummy solver stubs

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/d437376d-55d8-4087-baf1-e89451d2d597

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-03-22 12:05:24 -07:00
Nikolaj Bjorner
a39ff701c7 remove include of nielsen in sgraph
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-03-21 09:48:34 -07:00
Nikolaj Bjorner
ae12956545 updates based on discussion
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-03-20 11:20:29 -07:00
CEisenhofer
737c5d44ed Simplify regex splits 2026-03-20 13:33:53 +01:00
CEisenhofer
9aaf103ca0 Fix union problem (might not solve all bugs) 2026-03-20 12:17:44 +01:00