3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-03-07 22:04:53 +00:00

Remove sgraph dependency from seq_plugin, let sgraph register nodes via on_make callback

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-01 23:50:48 +00:00
parent b8656d4fbe
commit 6ef3be4e5e
3 changed files with 44 additions and 27 deletions

View file

@ -21,16 +21,14 @@ Author:
--*/
#include "ast/euf/euf_seq_plugin.h"
#include "ast/euf/euf_sgraph.h"
#include "ast/euf/euf_egraph.h"
#include "ast/ast_pp.h"
namespace euf {
seq_plugin::seq_plugin(egraph& g, sgraph& sg):
seq_plugin::seq_plugin(egraph& g):
plugin(g),
m_seq(g.get_manager()),
m_sg(sg) {
m_seq(g.get_manager()) {
}
void seq_plugin::register_node(enode* n) {
@ -71,9 +69,6 @@ namespace euf {
TRACE(seq, tout << "seq register " << g.bpp(n) << "\n");
// register in sgraph
m_sg.mk(n->get_expr());
if (is_concat(n)) {
m_concats.push_back(n);
propagate_assoc(n);
@ -178,13 +173,34 @@ namespace euf {
}
}
bool seq_plugin::is_nullable(enode* n) {
snode* s = m_sg.find(n->get_expr());
if (s)
return s->is_nullable();
// empty string is nullable
if (is_empty(n))
bool seq_plugin::is_nullable(expr* e) {
// compute nullable from expression structure without sgraph dependency
if (m_seq.str.is_empty(e))
return true;
if (m_seq.re.is_full_seq(e))
return true;
if (m_seq.re.is_star(e))
return true;
if (m_seq.str.is_concat(e)) {
SASSERT(to_app(e)->get_num_args() == 2);
return is_nullable(to_app(e)->get_arg(0)) && is_nullable(to_app(e)->get_arg(1));
}
if (m_seq.re.is_union(e)) {
SASSERT(to_app(e)->get_num_args() == 2);
return is_nullable(to_app(e)->get_arg(0)) || is_nullable(to_app(e)->get_arg(1));
}
if (m_seq.re.is_intersection(e)) {
SASSERT(to_app(e)->get_num_args() == 2);
return is_nullable(to_app(e)->get_arg(0)) && is_nullable(to_app(e)->get_arg(1));
}
if (m_seq.re.is_complement(e)) {
SASSERT(to_app(e)->get_num_args() == 1);
return !is_nullable(to_app(e)->get_arg(0));
}
if (m_seq.re.is_to_re(e)) {
SASSERT(to_app(e)->get_num_args() == 1);
return is_nullable(to_app(e)->get_arg(0));
}
return false;
}
@ -237,8 +253,6 @@ namespace euf {
}
std::ostream& seq_plugin::display(std::ostream& out) const {
// sgraph contents are displayed by sgraph::display, not here,
// since sgraph owns the seq_plugin (not the other way around)
out << "seq-plugin\n";
return out;
}