3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-20 04:43:39 +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:47:01 +02:00
parent d3305aac16
commit ae982c5225
13 changed files with 361 additions and 77 deletions

View file

@ -1058,6 +1058,8 @@ extern "C" {
case OP_SPECIAL_RELATION_PO : return Z3_OP_SPECIAL_RELATION_PO;
case OP_SPECIAL_RELATION_PLO: return Z3_OP_SPECIAL_RELATION_PLO;
case OP_SPECIAL_RELATION_TO : return Z3_OP_SPECIAL_RELATION_TO;
case OP_SPECIAL_RELATION_TC : return Z3_OP_SPECIAL_RELATION_TC;
case OP_SPECIAL_RELATION_TRC : return Z3_OP_SPECIAL_RELATION_TRC;
default: UNREACHABLE();
}
}

View file

@ -27,47 +27,7 @@ Revision History:
extern "C" {
#if 0
bool Z3_API Z3_is_sr_lo(Z3_context c, Z3_ast s) {
Z3_TRY;
LOG_Z3_is_sr_lo(c, s);
RESET_ERROR_CODE();
RETURN_Z3(mk_c(c)->sr_util().is_lo( to_expr(s) ));
Z3_CATCH_RETURN(false);
}
bool Z3_API Z3_is_sr_po(Z3_context c, Z3_ast s) {
Z3_TRY;
LOG_Z3_is_sr_po(c, s);
RESET_ERROR_CODE();
RETURN_Z3(mk_c(c)->sr_util().is_po( to_expr(s) ));
Z3_CATCH_RETURN(false);
}
bool Z3_API Z3_is_sr_po_ao(Z3_context c, Z3_ast s) {
Z3_TRY;
LOG_Z3_is_sr_po_ao(c, s);
RESET_ERROR_CODE();
RETURN_Z3(mk_c(c)->sr_util().is_po_ao( to_expr(s) ));
Z3_CATCH_RETURN(false);
}
bool Z3_API Z3_is_sr_plo(Z3_context c, Z3_ast s) {
Z3_TRY;
LOG_Z3_is_sr_plo(c, s);
RESET_ERROR_CODE();
RETURN_Z3(mk_c(c)->sr_util().is_plo( to_expr(s) ));
Z3_CATCH_RETURN(false);
}
bool Z3_API Z3_is_sr_to(Z3_context c, Z3_ast s) {
Z3_TRY;
LOG_Z3_is_sr_to(c, s);
RESET_ERROR_CODE();
RETURN_Z3(mk_c(c)->sr_util().is_to( to_expr(s) ));
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); \
@ -85,4 +45,22 @@ extern "C" {
MK_TERN(Z3_mk_piecewise_linear_order, OP_SPECIAL_RELATION_PLO);
MK_TERN(Z3_mk_tree_order, OP_SPECIAL_RELATION_TO);
#define MK_DECL(NAME, FID) \
Z3_func_decl Z3_API NAME(Z3_context c,Z3_func_decl f) { \
Z3_TRY; \
LOG_ ##NAME(c, f); \
RESET_ERROR_CODE(); \
ast_manager & m = mk_c(c)->m(); \
func_decl* _f = to_func_decl(f); \
parameter param(_f); \
sort* domain[2] = { _f->get_domain(0), _f->get_domain(1) }; \
func_decl * d = m.mk_func_decl(mk_c(c)->get_special_relations_fid(), FID, 1, &param, 2, domain); \
mk_c(c)->save_ast_trail(d); \
RETURN_Z3(of_func_decl(d)); \
Z3_CATCH_RETURN(nullptr); \
}
MK_DECL(Z3_mk_transitive_closure, OP_SPECIAL_RELATION_TC);
MK_DECL(Z3_mk_transitive_reflexive_closure, OP_SPECIAL_RELATION_TRC);
};

View file

@ -875,6 +875,18 @@ typedef enum
- Z3_OP_PB_EQ: Generalized Pseudo-Boolean equality constraint.
Example 2*x + 1*y + 2*z + 1*u = 4
- Z3_OP_SPECIAL_RELATION_LO: A relation that is a total linear order
- Z3_OP_SPECIAL_RELATION_PO: A relation that is a partial order
- Z3_OP_SPECIAL_RELATION_PLO: A relation that is a piecewise linear order
- Z3_OP_SPECIAL_RELATION_TO: A relation that is a tree order
- Z3_OP_SPECIAL_RELATION_TC: Transitive closure of a relation
- Z3_OP_SPECIAL_RELATION_TRC: Transitive reflexive closure of a relation
- Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN: Floating-point rounding mode RNE
- Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY: Floating-point rounding mode RNA
@ -1101,12 +1113,6 @@ typedef enum {
Z3_OP_BUREM_I,
Z3_OP_BSMOD_I,
// Special relations
Z3_OP_SPECIAL_RELATION_LO,
Z3_OP_SPECIAL_RELATION_PO,
Z3_OP_SPECIAL_RELATION_PLO,
Z3_OP_SPECIAL_RELATION_TO,
// Proofs
Z3_OP_PR_UNDEF = 0x500,
Z3_OP_PR_TRUE,
@ -1216,8 +1222,17 @@ typedef enum {
Z3_OP_PB_GE,
Z3_OP_PB_EQ,
// Special relations
Z3_OP_SPECIAL_RELATION_LO = 0xa000,
Z3_OP_SPECIAL_RELATION_PO,
Z3_OP_SPECIAL_RELATION_PLO,
Z3_OP_SPECIAL_RELATION_TO,
Z3_OP_SPECIAL_RELATION_TC,
Z3_OP_SPECIAL_RELATION_TRC,
// Floating-Point Arithmetic
Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN,
Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN = 0xb000,
Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY,
Z3_OP_FPA_RM_TOWARD_POSITIVE,
Z3_OP_FPA_RM_TOWARD_NEGATIVE,
@ -3643,6 +3658,20 @@ extern "C" {
*/
Z3_ast Z3_API Z3_mk_tree_order(Z3_context c, unsigned id, Z3_ast a, Z3_ast b);
/**
\brief create transitive closure of binary relation.
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);
/**
\brief create transitive reflexive closure of binary relation.
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);
/*@}*/
/** @name Quantifiers */