mirror of
https://github.com/Z3Prover/z3
synced 2026-02-20 15:34:41 +00:00
Implement finite_set_decl_plugin with complete operator support and polymorphism infrastructure (#7961)
* Initial plan * Implement finite_sets_decl_plugin with all specified operations Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Add tests for finite_sets_decl_plugin Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Add set.singleton operator to finite_sets_decl_plugin Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Refactor finite_sets_decl_plugin to use polymorphic signatures and Array sorts Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Rename finite_sets to finite_set everywhere including file names Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Rename set.filter to set.select Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Refactor finite_set_decl_plugin to use polymorphism_util Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Move psig and match method to polymorphism_util Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Add MATCH macros and fix is_fully_interp return value Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Add is_finite_set helper and parameter count validation 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:
parent
7356b5ff88
commit
df4052ec69
9 changed files with 572 additions and 0 deletions
|
|
@ -350,4 +350,31 @@ namespace polymorphism {
|
|||
proc proc(m, tvs);
|
||||
for_each_ast(proc, e, true);
|
||||
}
|
||||
|
||||
void util::match(psig& sig, unsigned dsz, sort* const* dom, sort* range, sort_ref& range_out) {
|
||||
if (dsz != sig.m_dom.size()) {
|
||||
std::ostringstream strm;
|
||||
strm << "Incorrect number of arguments to '" << sig.m_name << "' ";
|
||||
strm << "expected " << sig.m_dom.size() << " given " << dsz;
|
||||
m.raise_exception(strm.str());
|
||||
}
|
||||
|
||||
substitution sub(m);
|
||||
bool is_match = true;
|
||||
for (unsigned i = 0; is_match && i < dsz; ++i) {
|
||||
SASSERT(dom[i]);
|
||||
is_match = sub.match(sig.m_dom.get(i), dom[i]);
|
||||
}
|
||||
if (range && is_match) {
|
||||
is_match = sub.match(sig.m_range, range);
|
||||
}
|
||||
if (!is_match) {
|
||||
std::ostringstream strm;
|
||||
strm << "Sort mismatch for function '" << sig.m_name << "'";
|
||||
m.raise_exception(strm.str());
|
||||
}
|
||||
|
||||
// Apply substitution to get the range
|
||||
range_out = sub(sig.m_range);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue