Example #1
0
def apply_z3_func(pred, tup):
    if not isinstance(pred, z3.FuncDeclRef):
        return pred(*tup)
    _args, sz = z3._to_ast_array(tup)
    fact = z3._to_expr_ref(z3.Z3_mk_app(pred.ctx_ref(), pred.ast, sz, _args),
                           pred.ctx)
    return fact
Example #2
0
def substitute(t, *m):
    """Apply substitution m on t, m is a list of pairs of the form (from, to). Every occurrence in t of from is replaced with to. """
    num = len(m)
    _from = (z3.Ast * num)()
    _to = (z3.Ast * num)()
    for i in range(num):
        _from[i] = m[i][0].as_ast()
        _to[i] = m[i][1].as_ast()
    return z3._to_expr_ref(z3.Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
Example #3
0
def apply_z3_func(pred, tup):
    if isinstance(pred, z3.BoolRef):
        assert not tup
        return pred
    if not isinstance(pred, z3.FuncDeclRef):
        return pred(*tup)
    _args, sz = z3._to_ast_array(tup)
    fact = z3._to_expr_ref(z3.Z3_mk_app(pred.ctx_ref(), pred.ast, sz, _args), pred.ctx)
    return fact
Example #4
0
def substitute(t, *m):
    """Apply substitution m on t, m is a list of pairs of the form (from, to). Every occurrence in t of from is replaced with to. """
    num = len(m)
    _from = (z3.Ast * num)()
    _to   = (z3.Ast * num)()
    for i in range(num):
        _from[i] = m[i][0].as_ast()
        _to[i]   = m[i][1].as_ast()
    return z3._to_expr_ref(z3.Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)