mirror of
https://github.com/Z3Prover/z3
synced 2025-06-20 04:43:39 +00:00
support indexed relations
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
81b1338af6
commit
f55e4ccc41
7 changed files with 45 additions and 63 deletions
|
@ -1056,7 +1056,6 @@ extern "C" {
|
|||
switch(_d->get_decl_kind()) {
|
||||
case OP_SPECIAL_RELATION_LO : return Z3_OP_SPECIAL_RELATION_LO;
|
||||
case OP_SPECIAL_RELATION_PO : return Z3_OP_SPECIAL_RELATION_PO;
|
||||
case OP_SPECIAL_RELATION_PO_AO : return Z3_OP_SPECIAL_RELATION_PO_AO;
|
||||
case OP_SPECIAL_RELATION_PLO: return Z3_OP_SPECIAL_RELATION_PLO;
|
||||
case OP_SPECIAL_RELATION_TO : return Z3_OP_SPECIAL_RELATION_TO;
|
||||
default: UNREACHABLE();
|
||||
|
|
|
@ -68,11 +68,21 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(false);
|
||||
}
|
||||
#endif
|
||||
#define MK_TERN(NAME, FID) \
|
||||
Z3_ast Z3_API NAME(Z3_context c, unsigned index, Z3_ast a, Z3_ast b) { \
|
||||
LOG_ ##NAME(c, index, a, b); \
|
||||
Z3_TRY; \
|
||||
expr* args[2] = { to_expr(a), to_expr(b) }; \
|
||||
parameter p(index); \
|
||||
ast* a = mk_c(c)->m().mk_app(mk_c(c)->get_special_relations_fid(), FID, 1, &p, 2, args); \
|
||||
mk_c(c)->save_ast_trail(a); \
|
||||
RETURN_Z3(of_ast(a)); \
|
||||
Z3_CATCH_RETURN(nullptr); \
|
||||
}
|
||||
|
||||
MK_BINARY(Z3_mk_sr_lo , mk_c(c)->get_special_relations_fid(), OP_SPECIAL_RELATION_LO, SKIP);
|
||||
MK_BINARY(Z3_mk_sr_po , mk_c(c)->get_special_relations_fid(), OP_SPECIAL_RELATION_PO, SKIP);
|
||||
MK_BINARY(Z3_mk_sr_po_ao,mk_c(c)->get_special_relations_fid(), OP_SPECIAL_RELATION_PO_AO,SKIP);
|
||||
MK_BINARY(Z3_mk_sr_plo, mk_c(c)->get_special_relations_fid(), OP_SPECIAL_RELATION_PLO, SKIP);
|
||||
MK_BINARY(Z3_mk_sr_to , mk_c(c)->get_special_relations_fid(), OP_SPECIAL_RELATION_TO, SKIP);
|
||||
MK_TERN(Z3_mk_linear_order, OP_SPECIAL_RELATION_LO);
|
||||
MK_TERN(Z3_mk_partial_order, OP_SPECIAL_RELATION_PO);
|
||||
MK_TERN(Z3_mk_piecewise_linear_order, OP_SPECIAL_RELATION_PLO);
|
||||
MK_TERN(Z3_mk_tree_order, OP_SPECIAL_RELATION_TO);
|
||||
|
||||
};
|
||||
|
|
|
@ -1707,42 +1707,27 @@ namespace z3 {
|
|||
*/
|
||||
inline expr sext(expr const & a, unsigned i) { return to_expr(a.ctx(), Z3_mk_sign_ext(a.ctx(), i, a)); }
|
||||
|
||||
inline expr sr_lo(expr const& a, expr const& b) {
|
||||
typedef Z3_ast Z3_apply_order(Z3_context, unsigned, Z3_ast, Z3_ast);
|
||||
|
||||
inline expr apply_order(Z3_apply_order app, unsigned index, expr const& a, expr const& b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r = Z3_mk_sr_lo(a.ctx(), a, b);
|
||||
Z3_ast r = app(a.ctx(), index, a, b);
|
||||
a.check_error();
|
||||
return expr(a.ctx(), r);
|
||||
}
|
||||
|
||||
inline expr sr_po(expr const& a, expr const& b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r = Z3_mk_sr_po(a.ctx(), a, b);
|
||||
a.check_error();
|
||||
return expr(a.ctx(), r);
|
||||
inline expr linear_order(unsigned index, expr const& a, expr const& b) {
|
||||
return apply_order(Z3_mk_linear_order, index, a, b);
|
||||
}
|
||||
|
||||
inline expr sr_po_ao(expr const& a, expr const& b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r = Z3_mk_sr_po_ao(a.ctx(), a, b);
|
||||
a.check_error();
|
||||
return expr(a.ctx(), r);
|
||||
inline expr partial_order(unsigned index, expr const& a, expr const& b) {
|
||||
return apply_order(Z3_mk_partial_order, index, a, b);
|
||||
}
|
||||
|
||||
inline expr sr_plo(expr const& a, expr const& b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r = Z3_mk_sr_plo(a.ctx(), a, b);
|
||||
a.check_error();
|
||||
return expr(a.ctx(), r);
|
||||
inline expr piecewise_linear_order(unsigned index, expr const& a, expr const& b) {
|
||||
return apply_order(Z3_mk_piecewise_linear_order, index, a, b);
|
||||
}
|
||||
|
||||
inline expr sr_to(expr const& a, expr const& b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r = Z3_mk_sr_to(a.ctx(), a, b);
|
||||
a.check_error();
|
||||
return expr(a.ctx(), r);
|
||||
inline expr tree_order(unsigned index, expr const& a, expr const& b) {
|
||||
return apply_order(Z3_mk_tree_order, index, a, b);
|
||||
}
|
||||
|
||||
|
||||
template<typename T> class cast_ast;
|
||||
|
||||
template<> class cast_ast<ast> {
|
||||
|
|
|
@ -3608,49 +3608,41 @@ extern "C" {
|
|||
/** @name Special relations */
|
||||
/*@{*/
|
||||
/**
|
||||
\brief declare \c a and \c b are in linear order.
|
||||
\brief declare \c a and \c b are in linear order over a relation indexed by \c id.
|
||||
|
||||
\pre a and b are of same type.
|
||||
|
||||
|
||||
def_API('Z3_mk_sr_lo', AST ,(_in(CONTEXT), _in(AST), _in(AST)))
|
||||
def_API('Z3_mk_linear_order', AST ,(_in(CONTEXT), _in(UINT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_sr_lo(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
Z3_ast Z3_API Z3_mk_linear_order(Z3_context c, unsigned id, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief declare \c a and \c b are in partial order.
|
||||
\brief declare \c a and \c b are in partial order over a relation indexed by \c id.
|
||||
|
||||
\pre a and b are of same type.
|
||||
|
||||
def_API('Z3_mk_sr_po', AST ,(_in(CONTEXT), _in(AST), _in(AST)))
|
||||
def_API('Z3_mk_partial_order', AST ,(_in(CONTEXT), _in(UINT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_sr_po(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
Z3_ast Z3_API Z3_mk_partial_order(Z3_context c, unsigned id, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief declare \c a and \c b are already partial ordered.
|
||||
\brief declare \c a and \c b are in piecewise linear order indexed by relation \c id.
|
||||
|
||||
\pre a and b are of same type.
|
||||
|
||||
def_API('Z3_mk_sr_po_ao', AST ,(_in(CONTEXT), _in(AST), _in(AST)))
|
||||
def_API('Z3_mk_piecewise_linear_order', AST ,(_in(CONTEXT), _in(UINT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_sr_po_ao(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
Z3_ast Z3_API Z3_mk_piecewise_linear_order(Z3_context c, unsigned id, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief declare \c a and \c b are in piecewise linear order.
|
||||
\brief declare \c a and \c b are in tree order indexed by \c id.
|
||||
|
||||
\pre a and b are of same type.
|
||||
|
||||
def_API('Z3_mk_sr_plo', AST ,(_in(CONTEXT), _in(AST), _in(AST)))
|
||||
def_API('Z3_mk_tree_order', AST ,(_in(CONTEXT), _in(UINT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_sr_plo(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief declare \c a and \c b are in total order.
|
||||
|
||||
\pre a and b are of same type.
|
||||
|
||||
def_API('Z3_mk_sr_to', AST ,(_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_sr_to(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
Z3_ast Z3_API Z3_mk_tree_order(Z3_context c, unsigned id, Z3_ast a, Z3_ast b);
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue