3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-08 00:05:46 +00:00
This commit is contained in:
Nikolaj Bjorner 2023-07-11 09:40:09 -07:00
parent 9ae6c88e3f
commit d6f2c23627
4 changed files with 128 additions and 27 deletions

View file

@ -19,6 +19,7 @@ Revision History:
#include "ast/occurs.h"
#include "ast/for_each_expr.h"
#include "ast/for_each_ast.h"
// -----------------------------------
//
@ -49,6 +50,15 @@ namespace {
void operator()(quantifier const * n) { }
};
struct sort_proc {
sort* m_s;
sort_proc(sort* s) :m_s(s) {}
void operator()(sort const* s2) { if (m_s == s2) throw found(); }
void operator()(ast*) {}
};
}
// Return true if n1 occurs in n2
@ -74,6 +84,17 @@ bool occurs(func_decl * d, expr * n) {
return false;
}
bool occurs(sort* s1, sort* s2) {
sort_proc p(s1);
try {
for_each_ast(p, s2);
}
catch (const found&) {
return true;
}
return false;
}
void mark_occurs(ptr_vector<expr>& to_check, expr* v, expr_mark& occ) {
expr_fast_mark2 visited;
occ.mark(v, true);
@ -116,4 +137,4 @@ void mark_occurs(ptr_vector<expr>& to_check, expr* v, expr_mark& occ) {
to_check.pop_back();
}
}
}
}