mirror of
https://github.com/Z3Prover/z3
synced 2025-06-09 23:53:25 +00:00
add method for accessing i'th domain sort in array #6344
This commit is contained in:
parent
c47ca341b7
commit
af258d1720
2 changed files with 24 additions and 11 deletions
|
@ -294,14 +294,19 @@ extern "C" {
|
||||||
return Z3_mk_store(c, set, elem, Z3_mk_false(c));
|
return Z3_mk_store(c, set, elem, Z3_mk_false(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_array_sort(Z3_context c, Z3_sort t) {
|
||||||
|
return
|
||||||
|
to_sort(t)->get_family_id() == mk_c(c)->get_array_fid() &&
|
||||||
|
to_sort(t)->get_decl_kind() == ARRAY_SORT;
|
||||||
|
}
|
||||||
|
|
||||||
Z3_sort Z3_API Z3_get_array_sort_domain(Z3_context c, Z3_sort t) {
|
Z3_sort Z3_API Z3_get_array_sort_domain(Z3_context c, Z3_sort t) {
|
||||||
Z3_TRY;
|
Z3_TRY;
|
||||||
LOG_Z3_get_array_sort_domain(c, t);
|
LOG_Z3_get_array_sort_domain(c, t);
|
||||||
RESET_ERROR_CODE();
|
RESET_ERROR_CODE();
|
||||||
CHECK_VALID_AST(t, nullptr);
|
CHECK_VALID_AST(t, nullptr);
|
||||||
if (to_sort(t)->get_family_id() == mk_c(c)->get_array_fid() &&
|
if (is_array_sort(c, t)) {
|
||||||
to_sort(t)->get_decl_kind() == ARRAY_SORT) {
|
Z3_sort r = of_sort(get_array_domain(to_sort(t), 0));
|
||||||
Z3_sort r = reinterpret_cast<Z3_sort>(to_sort(t)->get_parameter(0).get_ast());
|
|
||||||
RETURN_Z3(r);
|
RETURN_Z3(r);
|
||||||
}
|
}
|
||||||
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
|
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
|
||||||
|
@ -314,10 +319,8 @@ extern "C" {
|
||||||
LOG_Z3_get_array_sort_domain_n(c, t, idx);
|
LOG_Z3_get_array_sort_domain_n(c, t, idx);
|
||||||
RESET_ERROR_CODE();
|
RESET_ERROR_CODE();
|
||||||
CHECK_VALID_AST(t, nullptr);
|
CHECK_VALID_AST(t, nullptr);
|
||||||
if (to_sort(t)->get_family_id() == mk_c(c)->get_array_fid() &&
|
if (is_array_sort(c, t) && get_array_arity(to_sort(t)) > idx) {
|
||||||
to_sort(t)->get_decl_kind() == ARRAY_SORT &&
|
Z3_sort r = of_sort(get_array_domain(to_sort(t), idx));
|
||||||
get_array_arity(to_sort(t)) > idx) {
|
|
||||||
Z3_sort r = reinterpret_cast<Z3_sort>(get_array_domain(to_sort(t), idx));
|
|
||||||
RETURN_Z3(r);
|
RETURN_Z3(r);
|
||||||
}
|
}
|
||||||
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
|
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
|
||||||
|
@ -330,10 +333,8 @@ extern "C" {
|
||||||
LOG_Z3_get_array_sort_range(c, t);
|
LOG_Z3_get_array_sort_range(c, t);
|
||||||
RESET_ERROR_CODE();
|
RESET_ERROR_CODE();
|
||||||
CHECK_VALID_AST(t, nullptr);
|
CHECK_VALID_AST(t, nullptr);
|
||||||
if (to_sort(t)->get_family_id() == mk_c(c)->get_array_fid() &&
|
if (is_array_sort(c, t)) {
|
||||||
to_sort(t)->get_decl_kind() == ARRAY_SORT) {
|
Z3_sort r = of_sort(get_array_range(to_sort(t)));
|
||||||
unsigned n = to_sort(t)->get_num_parameters();
|
|
||||||
Z3_sort r = reinterpret_cast<Z3_sort>(to_sort(t)->get_parameter(n-1).get_ast());
|
|
||||||
RETURN_Z3(r);
|
RETURN_Z3(r);
|
||||||
}
|
}
|
||||||
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
|
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
|
||||||
|
|
|
@ -35,6 +35,18 @@ public class ArraySort<D extends Sort, R extends Sort> extends Sort
|
||||||
Native.getArraySortDomain(getContext().nCtx(), getNativeObject()));
|
Native.getArraySortDomain(getContext().nCtx(), getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The domain of a multi-dimensional array sort.
|
||||||
|
* @throws Z3Exception
|
||||||
|
* @throws Z3Exception on error
|
||||||
|
* @return a sort
|
||||||
|
**/
|
||||||
|
public D getDomain(int idx)
|
||||||
|
{
|
||||||
|
return (D) Sort.create(getContext(),
|
||||||
|
Native.getArraySortDomainN(getContext().nCtx(), getNativeObject(), idx));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The range of the array sort.
|
* The range of the array sort.
|
||||||
* @throws Z3Exception
|
* @throws Z3Exception
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue