3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-10 19:27:06 +00:00

add tc and trc functionals for binary relations

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2019-04-09 22:58:43 +02:00
parent ae982c5225
commit 182039eb44
3 changed files with 30 additions and 8 deletions

View file

@ -633,6 +633,14 @@ namespace z3 {
symbol name() const { Z3_symbol s = Z3_get_decl_name(ctx(), *this); check_error(); return symbol(ctx(), s); }
Z3_decl_kind decl_kind() const { return Z3_get_decl_kind(ctx(), *this); }
func_decl transitive_closure(func_decl const& f) {
Z3_func_decl tc = Z3_mk_transitive_closure(ctx(), *this); check_error(); return func_decl(ctx(), tc);
}
func_decl transitive_reflexive_closure(func_decl const& f) {
Z3_func_decl tc = Z3_mk_transitive_reflexive_closure(ctx(), *this); check_error(); return func_decl(ctx(), tc);
}
bool is_const() const { return arity() == 0; }
expr operator()() const;

View file

@ -10379,10 +10379,16 @@ def Range(lo, hi, ctx = None):
# Special Relations
def PartialOrder(n, s):
ctx = s.ctx
return FuncDeclRef(Z3_mk_partial_order(ctx, n, s.ast), ctx)
def TransitiveClosure(f):
"""Given a binary relation R, such that the two arguments have the same sort
create the transitive closure relation R+.
The transitive closure R+ is a new relation.
"""
return FuncDeclRef(Z3_mk_transitive_closure(f.ctx_ref(), f.ast), f.ctx)
def TreeOrder(n, s):
ctx = s.ctx
return FuncDeclRef(Z3_mk_tree_order(ctx, n, s.ast), ctx)
def TransitiveReflexiveClosure(f):
"""Given a binary relation R, such that the two arguments have the same sort
create the transitive reflexive closure relation R*.
The transitive reflexive closure R* is a new relation.
"""
return FuncDeclRef(Z3_mk_transitive_reflexive_closure(f.ctx_ref(), f.ast), f.ctx)

View file

@ -3661,16 +3661,24 @@ extern "C" {
/**
\brief create transitive closure of binary relation.
\pre f is a binary relation, such that the two arguments have the same sorts.
The resulting relation f+ represents the transitive closure of f.
def_API('Z3_mk_transitive_closure', FUNC_DECL ,(_in(CONTEXT), _in(FUNC_DECL)))
*/
Z3_func_decl Z3_API Z3_mk_transitive_closure(Z3_context c,Z3_func_decl f);
Z3_func_decl Z3_API Z3_mk_transitive_closure(Z3_context c, Z3_func_decl f);
/**
\brief create transitive reflexive closure of binary relation.
\pre f is a binary relation, such that the two arguments have the same sorts.
The resulting relation f* represents the transitive-reflexive closure of f.
def_API('Z3_mk_transitive_reflexive_closure', FUNC_DECL ,(_in(CONTEXT), _in(FUNC_DECL)))
*/
Z3_func_decl Z3_API Z3_mk_transitive_reflexive_closure(Z3_context c,Z3_func_decl f);
Z3_func_decl Z3_API Z3_mk_transitive_reflexive_closure(Z3_context c, Z3_func_decl f);
/*@}*/