9// Array operations and sorts
11// MkArraySort creates an array sort.
12func (c *Context) MkArraySort(domain, range_ *Sort) *Sort {
13 return newSort(c, C.Z3_mk_array_sort(c.ptr, domain.ptr, range_.ptr))
16// MkSelect creates an array read (select) operation.
17func (c *Context) MkSelect(array, index *Expr) *Expr {
18 return newExpr(c, C.Z3_mk_select(c.ptr, array.ptr, index.ptr))
21// MkStore creates an array write (store) operation.
22func (c *Context) MkStore(array, index, value *Expr) *Expr {
23 return newExpr(c, C.Z3_mk_store(c.ptr, array.ptr, index.ptr, value.ptr))
26// MkConstArray creates a constant array.
27func (c *Context) MkConstArray(sort *Sort, value *Expr) *Expr {
28 return newExpr(c, C.Z3_mk_const_array(c.ptr, sort.ptr, value.ptr))
31// MkSelectN creates a multi-index array read (select) operation.
32func (c *Context) MkSelectN(array *Expr, indices []*Expr) *Expr {
33 idxs := make([]C.Z3_ast, len(indices))
34 for i, idx := range indices {
41 return newExpr(c, C.Z3_mk_select_n(c.ptr, array.ptr, C.uint(len(idxs)), idxsPtr))
44// MkStoreN creates a multi-index array write (store) operation.
45func (c *Context) MkStoreN(array *Expr, indices []*Expr, value *Expr) *Expr {
46 idxs := make([]C.Z3_ast, len(indices))
47 for i, idx := range indices {
54 return newExpr(c, C.Z3_mk_store_n(c.ptr, array.ptr, C.uint(len(idxs)), idxsPtr, value.ptr))
57// MkArrayDefault returns the default value of an array.
58func (c *Context) MkArrayDefault(array *Expr) *Expr {
59 return newExpr(c, C.Z3_mk_array_default(c.ptr, array.ptr))
62// MkArrayExt returns the extensionality witness for two arrays.
63// Two arrays are equal if and only if they are equal on the index returned by MkArrayExt.
64func (c *Context) MkArrayExt(a1, a2 *Expr) *Expr {
65 return newExpr(c, C.Z3_mk_array_ext(c.ptr, a1.ptr, a2.ptr))
68// MkAsArray creates an array from a function declaration.
69// The resulting array maps each input to the output of the function.
70func (c *Context) MkAsArray(f *FuncDecl) *Expr {
71 return newExpr(c, C.Z3_mk_as_array(c.ptr, f.ptr))
74// MkMap applies a function to the elements of one or more arrays, returning a new array.
75// The function f is applied element-wise to the given arrays.
76func (c *Context) MkMap(f *FuncDecl, arrays ...*Expr) *Expr {
77 cArrays := make([]C.Z3_ast, len(arrays))
78 for i, a := range arrays {
81 var cArraysPtr *C.Z3_ast
83 cArraysPtr = &cArrays[0]
85 return newExpr(c, C.Z3_mk_map(c.ptr, f.ptr, C.uint(len(arrays)), cArraysPtr))