Skip to content

Commit f4b803d

Browse files
expose mk_divides over API. Corresponds to a = b (mod m), #723
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent f8469b6 commit f4b803d

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

scripts/update_api.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
DOUBLE = 12
5656
FLOAT = 13
5757
CHAR = 14
58+
CHAR_PTR = 15
5859

5960
FIRST_OBJ_ID = 100
6061

@@ -63,33 +64,33 @@ def is_obj(ty):
6364

6465
Type2Str = { VOID : 'void', VOID_PTR : 'void*', INT : 'int', UINT : 'unsigned', INT64 : 'int64_t', UINT64 : 'uint64_t', DOUBLE : 'double',
6566
FLOAT : 'float', STRING : 'Z3_string', STRING_PTR : 'Z3_string_ptr', BOOL : 'bool', SYMBOL : 'Z3_symbol',
66-
PRINT_MODE : 'Z3_ast_print_mode', ERROR_CODE : 'Z3_error_code', CHAR: 'char'
67+
PRINT_MODE : 'Z3_ast_print_mode', ERROR_CODE : 'Z3_error_code', CHAR: 'char', CHAR_PTR: 'char*'
6768
}
6869

6970
Type2PyStr = { VOID_PTR : 'ctypes.c_void_p', INT : 'ctypes.c_int', UINT : 'ctypes.c_uint', INT64 : 'ctypes.c_longlong',
7071
UINT64 : 'ctypes.c_ulonglong', DOUBLE : 'ctypes.c_double', FLOAT : 'ctypes.c_float',
7172
STRING : 'ctypes.c_char_p', STRING_PTR : 'ctypes.POINTER(ctypes.c_char_p)', BOOL : 'ctypes.c_bool', SYMBOL : 'Symbol',
72-
PRINT_MODE : 'ctypes.c_uint', ERROR_CODE : 'ctypes.c_uint', CHAR : 'ctypes.c_char'
73+
PRINT_MODE : 'ctypes.c_uint', ERROR_CODE : 'ctypes.c_uint', CHAR : 'ctypes.c_char', CHAR_PTR: 'ctypes.c_char_p'
7374
}
7475

7576
# Mapping to .NET types
7677
Type2Dotnet = { VOID : 'void', VOID_PTR : 'IntPtr', INT : 'int', UINT : 'uint', INT64 : 'Int64', UINT64 : 'UInt64', DOUBLE : 'double',
7778
FLOAT : 'float', STRING : 'string', STRING_PTR : 'byte**', BOOL : 'byte', SYMBOL : 'IntPtr',
78-
PRINT_MODE : 'uint', ERROR_CODE : 'uint', CHAR : 'char' }
79+
PRINT_MODE : 'uint', ERROR_CODE : 'uint', CHAR : 'char', CHAR_PTR : 'char*' }
7980

8081
# Mapping to Java types
8182
Type2Java = { VOID : 'void', VOID_PTR : 'long', INT : 'int', UINT : 'int', INT64 : 'long', UINT64 : 'long', DOUBLE : 'double',
8283
FLOAT : 'float', STRING : 'String', STRING_PTR : 'StringPtr',
83-
BOOL : 'boolean', SYMBOL : 'long', PRINT_MODE : 'int', ERROR_CODE : 'int', CHAR : 'char' }
84+
BOOL : 'boolean', SYMBOL : 'long', PRINT_MODE : 'int', ERROR_CODE : 'int', CHAR : 'char', CHAR_PTR : 'long' }
8485

8586
Type2JavaW = { VOID : 'void', VOID_PTR : 'jlong', INT : 'jint', UINT : 'jint', INT64 : 'jlong', UINT64 : 'jlong', DOUBLE : 'jdouble',
8687
FLOAT : 'jfloat', STRING : 'jstring', STRING_PTR : 'jobject',
87-
BOOL : 'jboolean', SYMBOL : 'jlong', PRINT_MODE : 'jint', ERROR_CODE : 'jint', CHAR : 'jchar'}
88+
BOOL : 'jboolean', SYMBOL : 'jlong', PRINT_MODE : 'jint', ERROR_CODE : 'jint', CHAR : 'jchar', CHAR_PTR : 'jlong'}
8889

8990
# Mapping to ML types
9091
Type2ML = { VOID : 'unit', VOID_PTR : 'VOIDP', INT : 'int', UINT : 'int', INT64 : 'int', UINT64 : 'int', DOUBLE : 'float',
9192
FLOAT : 'float', STRING : 'string', STRING_PTR : 'char**',
92-
BOOL : 'bool', SYMBOL : 'z3_symbol', PRINT_MODE : 'int', ERROR_CODE : 'int', CHAR : 'char' }
93+
BOOL : 'bool', SYMBOL : 'z3_symbol', PRINT_MODE : 'int', ERROR_CODE : 'int', CHAR : 'char', CHAR_PTR : 'char*' }
9394

9495
next_type_id = FIRST_OBJ_ID
9596

src/api/api_arith.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ extern "C" {
8888
MK_ARITH_PRED(Z3_mk_gt, OP_GT);
8989
MK_ARITH_PRED(Z3_mk_le, OP_LE);
9090
MK_ARITH_PRED(Z3_mk_ge, OP_GE);
91+
MK_ARITH_PRED(Z3_mk_divides, OP_IDIVIDES);
9192
MK_UNARY(Z3_mk_int2real, mk_c(c)->get_arith_fid(), OP_TO_REAL, SKIP);
9293
MK_UNARY(Z3_mk_real2int, mk_c(c)->get_arith_fid(), OP_TO_INT, SKIP);
9394
MK_UNARY(Z3_mk_is_int, mk_c(c)->get_arith_fid(), OP_IS_INT, SKIP);

src/api/api_seq.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ extern "C" {
150150
Z3_CATCH_RETURN("");
151151
}
152152

153-
Z3_string Z3_API Z3_get_lstring(Z3_context c, Z3_ast s, unsigned* length) {
153+
Z3_char_ptr Z3_API Z3_get_lstring(Z3_context c, Z3_ast s, unsigned* length) {
154154
Z3_TRY;
155155
LOG_Z3_get_lstring(c, s, length);
156156
RESET_ERROR_CODE();

src/api/z3_api.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ typedef bool Z3_bool;
8080
\brief Z3 string type. It is just an alias for \ccode{const char *}.
8181
*/
8282
typedef const char * Z3_string;
83+
typedef char const* Z3_char_ptr;
8384
typedef Z3_string * Z3_string_ptr;
8485

8586
/**
@@ -2494,6 +2495,17 @@ extern "C" {
24942495
*/
24952496
Z3_ast Z3_API Z3_mk_ge(Z3_context c, Z3_ast t1, Z3_ast t2);
24962497

2498+
/**
2499+
\brief Create division predicate.
2500+
2501+
The nodes \c t1 and \c t2 must be of integer sort.
2502+
The predicate is true when \c t1 divides \c t2. For the predicate to be part of
2503+
linear integer arithmetic, the first argument \c t1 must be a non-zero integer.
2504+
2505+
def_API('Z3_mk_divides', AST, (_in(CONTEXT), _in(AST), _in(AST)))
2506+
*/
2507+
Z3_ast Z3_API Z3_mk_divides(Z3_context c, Z3_ast t1, Z3_ast t2);
2508+
24972509
/**
24982510
\brief Coerce an integer to a real.
24992511
@@ -3454,9 +3466,9 @@ extern "C" {
34543466
34553467
\pre Z3_is_string(c, s)
34563468
3457-
def_API('Z3_get_lstring' ,STRING ,(_in(CONTEXT), _in(AST), _out(UINT)))
3469+
def_API('Z3_get_lstring' ,CHAR_PTR ,(_in(CONTEXT), _in(AST), _out(UINT)))
34583470
*/
3459-
Z3_string Z3_API Z3_get_lstring(Z3_context c, Z3_ast s, unsigned* length);
3471+
Z3_char_ptr Z3_API Z3_get_lstring(Z3_context c, Z3_ast s, unsigned* length);
34603472

34613473
/**
34623474
\brief Create an empty sequence of the sequence sort \c seq.

src/ast/arith_decl_plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ class arith_util : public arith_recognizers {
379379
app * mk_ge(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_GE, arg1, arg2); }
380380
app * mk_lt(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_LT, arg1, arg2); }
381381
app * mk_gt(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_GT, arg1, arg2); }
382+
app * mk_divides(expr* arg1, expr* arg2) { return m_manager.mk_app(m_afid, OP_IDIVIDES, arg1, arg2); }
382383

383384
app * mk_add(unsigned num_args, expr * const * args) const { return num_args == 1 && is_app(args[0]) ? to_app(args[0]) : m_manager.mk_app(m_afid, OP_ADD, num_args, args); }
384385
app * mk_add(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_ADD, arg1, arg2); }

0 commit comments

Comments
 (0)