Skip to content

Commit d792840

Browse files
authored
Add Z3_is_recursive_datatype_sort to the API (#7615)
It does not seem to be possible to test if a datatype sort is recursive.
1 parent 14e2aad commit d792840

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/api/api_datatype.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,16 @@ extern "C" {
443443
Z3_CATCH;
444444
}
445445

446+
bool Z3_API Z3_is_recursive_datatype_sort(Z3_context c, Z3_sort t) {
447+
Z3_TRY;
448+
LOG_Z3_is_recursive_datatype_sort(c, t);
449+
RESET_ERROR_CODE();
450+
sort * s = to_sort(t);
451+
datatype_util& dt_util = mk_c(c)->dtutil();
452+
return dt_util.is_datatype(s) && dt_util.is_recursive(s);
453+
Z3_CATCH_RETURN(false);
454+
}
455+
446456
unsigned Z3_API Z3_get_datatype_sort_num_constructors(Z3_context c, Z3_sort t) {
447457
Z3_TRY;
448458
LOG_Z3_get_datatype_sort_num_constructors(c, t);

src/api/z3_api.h

+7
Original file line numberDiff line numberDiff line change
@@ -4588,6 +4588,13 @@ extern "C" {
45884588
*/
45894589
Z3_func_decl Z3_API Z3_get_tuple_sort_field_decl(Z3_context c, Z3_sort t, unsigned i);
45904590

4591+
/**
4592+
\brief Check if \c s is a recursive datatype sort.
4593+
4594+
def_API('Z3_is_recursive_datatype_sort', BOOL, (_in(CONTEXT), _in(SORT)))
4595+
*/
4596+
bool Z3_API Z3_is_recursive_datatype_sort(Z3_context c, Z3_sort s);
4597+
45914598
/**
45924599
\brief Return number of constructors for datatype.
45934600

0 commit comments

Comments
 (0)