mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
add array-ext to externally exposed functions to enable interpolants with arrays to be usable in feedback loops with Z3. Addresses one issue raised in #292
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
8d1fa3ae50
commit
4685a5f8ba
12 changed files with 71 additions and 16 deletions
|
@ -187,7 +187,8 @@ extern "C" {
|
|||
MK_BINARY(Z3_mk_set_difference, mk_c(c)->get_array_fid(), OP_SET_DIFFERENCE, SKIP);
|
||||
MK_UNARY(Z3_mk_set_complement, mk_c(c)->get_array_fid(), OP_SET_COMPLEMENT, SKIP);
|
||||
MK_BINARY(Z3_mk_set_subset, mk_c(c)->get_array_fid(), OP_SET_SUBSET, SKIP);
|
||||
|
||||
MK_BINARY(Z3_mk_array_ext, mk_c(c)->get_array_fid(), OP_ARRAY_EXT, SKIP);
|
||||
|
||||
Z3_ast Z3_mk_set_member(Z3_context c, Z3_ast elem, Z3_ast set) {
|
||||
return Z3_mk_select(c, set, elem);
|
||||
}
|
||||
|
|
|
@ -1012,6 +1012,7 @@ extern "C" {
|
|||
case OP_SET_COMPLEMENT: return Z3_OP_SET_COMPLEMENT;
|
||||
case OP_SET_SUBSET: return Z3_OP_SET_SUBSET;
|
||||
case OP_AS_ARRAY: return Z3_OP_AS_ARRAY;
|
||||
case OP_ARRAY_EXT: return Z3_OP_ARRAY_EXT;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return Z3_OP_UNINTERPRETED;
|
||||
|
|
|
@ -2122,6 +2122,21 @@ namespace Microsoft.Z3
|
|||
CheckContextMatch(array);
|
||||
return Expr.Create(this, Native.Z3_mk_array_default(nCtx, array.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create Extentionality index. Two arrays are equal if and only if they are equal on the index returned by MkArrayExt.
|
||||
/// </summary>
|
||||
public Expr MkArrayExt(ArrayExpr arg1, ArrayExpr arg2)
|
||||
{
|
||||
Contract.Requires(arg1 != null);
|
||||
Contract.Requires(arg2 != null);
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
|
||||
CheckContextMatch(arg1);
|
||||
CheckContextMatch(arg2);
|
||||
return Expr.Create(this, Native.Z3_mk_array_ext(nCtx, arg1.NativeObject, arg2.NativeObject));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Sets
|
||||
|
@ -2268,6 +2283,7 @@ namespace Microsoft.Z3
|
|||
CheckContextMatch(arg2);
|
||||
return (BoolExpr) Expr.Create(this, Native.Z3_mk_set_subset(nCtx, arg1.NativeObject, arg2.NativeObject));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Pseudo-Boolean constraints
|
||||
|
|
|
@ -1717,6 +1717,17 @@ public class Context extends IDisposable
|
|||
Native.mkArrayDefault(nCtx(), array.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Extentionality index. Two arrays are equal if and only if they are equal on the index returned by MkArrayExt.
|
||||
**/
|
||||
public Expr mkArrayExt(ArrayExpr arg1, ArrayExpr arg2)
|
||||
{
|
||||
checkContextMatch(arg1);
|
||||
checkContextMatch(arg2);
|
||||
return Expr.create(this, Native.mkArrayExt(nCtx(), arg1.getNativeObject(), arg2.getNativeObject()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a set type.
|
||||
**/
|
||||
|
|
|
@ -4143,6 +4143,13 @@ def K(dom, v):
|
|||
v = _py2expr(v, ctx)
|
||||
return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
|
||||
|
||||
def Ext(a, b):
|
||||
"""Return extensionality index for arrays.
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_array(a) and is_array(b))
|
||||
return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()));
|
||||
|
||||
def is_select(a):
|
||||
"""Return `True` if `a` is a Z3 array select application.
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ _z3_op_to_str = {
|
|||
Z3_OP_BASHR : '>>', Z3_OP_BSHL : '<<', Z3_OP_BLSHR : 'LShR',
|
||||
Z3_OP_CONCAT : 'Concat', Z3_OP_EXTRACT : 'Extract', Z3_OP_BV2INT : 'BV2Int',
|
||||
Z3_OP_ARRAY_MAP : 'Map', Z3_OP_SELECT : 'Select', Z3_OP_STORE : 'Store',
|
||||
Z3_OP_CONST_ARRAY : 'K',
|
||||
Z3_OP_CONST_ARRAY : 'K', Z3_OP_ARRAY_EXT : 'Ext',
|
||||
Z3_OP_PB_AT_MOST : 'AtMost', Z3_OP_PB_LE : 'PbLe', Z3_OP_PB_GE : 'PbGe'
|
||||
}
|
||||
|
||||
|
|
|
@ -322,6 +322,9 @@ typedef enum
|
|||
- Z3_OP_AS_ARRAY An array value that behaves as the function graph of the
|
||||
function passed as parameter.
|
||||
|
||||
- Z3_OP_ARRAY_EXT Array extensionality function. It takes two arrays as arguments and produces an index, such that the arrays
|
||||
are different if they are different on the index.
|
||||
|
||||
- Z3_OP_BNUM Bit-vector numeral.
|
||||
|
||||
- Z3_OP_BIT1 One bit bit-vector.
|
||||
|
@ -1033,6 +1036,7 @@ typedef enum {
|
|||
Z3_OP_SET_COMPLEMENT,
|
||||
Z3_OP_SET_SUBSET,
|
||||
Z3_OP_AS_ARRAY,
|
||||
Z3_OP_ARRAY_EXT,
|
||||
|
||||
// Bit-vectors
|
||||
Z3_OP_BNUM = 0x400,
|
||||
|
@ -3260,6 +3264,17 @@ END_MLAPI_EXCLUDE
|
|||
Z3_ast Z3_API Z3_mk_set_subset(Z3_context c, Z3_ast arg1, Z3_ast arg2);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
\brief Create array extensionality index given two arrays with the same sort.
|
||||
The meaning is given by the axiom:
|
||||
(=> (= (select A (array-ext A B)) (select B (array-ext A B))) (= A B))
|
||||
|
||||
def_API('Z3_mk_array_ext', AST, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
|
||||
Z3_ast Z3_API Z3_mk_array_ext(Z3_context c, Z3_ast arg1, Z3_ast arg2);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
@name Numerals
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue