3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-19 23:26:30 +00:00
z3/src/ast/euf
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
..
CMakeLists.txt Add euf_seq_plugin: string plugin for egraph with concat associativity and ZIPT simplifications 2026-03-01 21:50:06 +00:00
euf_ac_plugin.cpp Convert internal class enums to enum class for type safety (#8158) 2026-01-11 17:44:59 -08:00
euf_ac_plugin.h Convert internal class enums to enum class for type safety (#8158) 2026-01-11 17:44:59 -08:00
euf_arith_plugin.cpp fix build warnings 2025-11-26 09:43:52 -08:00
euf_arith_plugin.h Fix unused parameter warnings in empty override functions by omitting parameter names (#8174) 2026-01-12 21:27:33 -08:00
euf_bv_plugin.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
euf_bv_plugin.h Fix unused parameter warnings in empty override functions by omitting parameter names (#8174) 2026-01-12 21:27:33 -08:00
euf_egraph.cpp Replace manual pair unpacking with structured bindings (#8197) 2026-01-14 19:52:01 -08:00
euf_egraph.h Convert internal class enums to enum class for type safety (#8158) 2026-01-11 17:44:59 -08:00
euf_enode.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
euf_enode.h remove unneeded iterator functions 2024-09-23 12:59:04 +01:00
euf_etable.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-01-14 19:55:31 -08:00
euf_etable.h #5417 - revise q_eval based on bug based on non-chronological dependencies with post-hoc explain function 2021-07-19 07:40:46 -07:00
euf_justification.cpp add EUF plugin framework. 2023-11-30 13:58:30 -08:00
euf_justification.h port updates to egraph from poly 2024-02-03 12:48:58 -08:00
euf_mam.cpp Remove redundant min_gen_match search (#9696) 2026-06-03 13:36:51 -07:00
euf_mam.h update namespace, hoist exported functions outside of embedded namespace 2025-05-07 15:57:47 -07:00
euf_plugin.cpp revamp ac plugin and plugin propagation 2025-07-21 07:35:06 -07:00
euf_plugin.h Replace empty destructors with = default for compiler optimization (#8189) 2026-01-13 10:50:10 -08:00
euf_seq_plugin.cpp euf_seq_plugin: root-canonical simplification fixes + loop bound overflow guard (#9744) 2026-06-08 15:38:55 -07:00
euf_seq_plugin.h euf_seq_plugin: fix identity elimination after merge, activate loop merging, integrate sgraph improvements (#9414) 2026-04-29 11:12:00 -07:00
euf_sgraph.cpp euf_sgraph: make drop_left/drop_right depth-linear and simplify string classification (#9771) 2026-06-10 14:46:03 +02:00
euf_sgraph.h Potentially fixed termination problem with projection operators 2026-06-02 17:04:31 +02:00
euf_snode.h Flatten concat when deciding if it is constant 2026-06-09 16:39:09 +02:00
euf_specrel_plugin.cpp add EUF plugin framework. 2023-11-30 13:58:30 -08:00
euf_specrel_plugin.h remove default destructors & some default constructors 2024-09-04 22:30:23 +01:00
ho_matcher.cpp disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
ho_matcher.h disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00