3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-05-23 18:39:38 +00:00

theory_nseq: remove seq_state, embed tracked entries directly in prop_queue (#9045)

* Remove seq_state: embed tracked_str_eq/tracked_str_mem directly in prop_queue

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

* theory_nseq: use type aliases for eq_item/mem_item instead of wrapper structs

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

* seq_model: validate_regex takes single tracked_str_mem, caller loops

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>
This commit is contained in:
Copilot 2026-03-19 14:45:53 -07:00 committed by GitHub
parent 8795bf06fb
commit 59bc9b17ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 114 additions and 168 deletions

View file

@ -7,9 +7,9 @@ Module Name:
Abstract:
Constraint store bridging the SMT context to the Nielsen graph.
Holds word equations and regex membership constraints with
push/pop support for backtracking.
Tracked constraint types bridging the SMT context to the Nielsen graph.
tracked_str_eq and tracked_str_mem extend the core constraint types with
SMT-layer source information (enodes and literals) for conflict reporting.
Author:
@ -39,71 +39,4 @@ namespace smt {
: seq::str_mem(str, regex, history, id, dep), lit(lit) {}
};
// source info for a string disequality
struct diseq_source {
enode* m_n1;
enode* m_n2;
};
class seq_state {
vector<tracked_str_eq> m_str_eqs;
vector<tracked_str_mem> m_str_mems;
vector<diseq_source> m_diseqs;
unsigned_vector m_str_eq_lim;
unsigned_vector m_str_mem_lim;
unsigned_vector m_diseq_lim;
unsigned m_next_mem_id = 0;
public:
seq_state() = default;
void push() {
m_str_eq_lim.push_back(m_str_eqs.size());
m_str_mem_lim.push_back(m_str_mems.size());
m_diseq_lim.push_back(m_diseqs.size());
}
void pop(unsigned n) {
for (unsigned i = 0; i < n; ++i) {
m_str_eqs.shrink(m_str_eq_lim.back());
m_str_eq_lim.pop_back();
m_str_mems.shrink(m_str_mem_lim.back());
m_str_mem_lim.pop_back();
m_diseqs.shrink(m_diseq_lim.back());
m_diseq_lim.pop_back();
}
}
void add_str_eq(euf::snode* lhs, euf::snode* rhs, enode* n1, enode* n2) {
seq::dep_tracker dep = nullptr;
m_str_eqs.push_back(tracked_str_eq(lhs, rhs, n1, n2, dep));
}
void add_str_mem(euf::snode* str, euf::snode* regex, sat::literal lit) {
seq::dep_tracker dep = nullptr;
m_str_mems.push_back(tracked_str_mem(str, regex, lit, nullptr, m_next_mem_id++, dep));
}
void add_diseq(enode* n1, enode* n2) {
m_diseqs.push_back({n1, n2});
}
vector<tracked_str_eq> const& str_eqs() const { return m_str_eqs; }
vector<tracked_str_mem> const& str_mems() const { return m_str_mems; }
vector<diseq_source> const& diseqs() const { return m_diseqs; }
diseq_source const& get_diseq(unsigned i) const { return m_diseqs[i]; }
bool empty() const { return m_str_eqs.empty() && m_str_mems.empty() && m_diseqs.empty(); }
void reset() {
m_str_eqs.reset();
m_str_mems.reset();
m_diseqs.reset();
m_str_eq_lim.reset();
m_str_mem_lim.reset();
m_diseq_lim.reset();
}
};
}