Exemplo n.º 1
0
    def apply(self, body):
        ctx = body.ctx
        qid = z3.to_symbol("", ctx)
        skid = qid

        res = z3core.Z3_mk_quantifier_const_ex(ctx.ref(), False, 1, qid, skid,
                                               self._num_vars, self._vs,
                                               self._num_pats, self._pats,
                                               self._num_no_pats,
                                               self._no_pats, body.as_ast())
        return z3.QuantifierRef(res, ctx)
Exemplo n.º 2
0
    def convert(self, formula):
        z3term = self.walk(formula)

        if formula.node_type in op.QUANTIFIERS:
            return z3.QuantifierRef(z3term, self.ctx)
        elif formula.node_type() in BOOLREF_SET:
            return z3.BoolRef(z3term, self.ctx)
        elif formula.node_type() in ARITHREF_SET:
            return z3.ArithRef(z3term, self.ctx)
        elif formula.node_type() in BITVECREF_SET:
            return z3.BitVecRef(z3term, self.ctx)
        elif formula.is_symbol() or formula.is_function_application():
            if formula.is_function_application():
                type_ = formula.function_name().symbol_type()
                type_ = type_.return_type
            else:
                type_ = formula.symbol_type()

            if type_.is_bool_type():
                return z3.BoolRef(z3term, self.ctx)
            elif type_.is_real_type() or type_.is_int_type():
                return z3.ArithRef(z3term, self.ctx)
            elif type_.is_array_type():
                return z3.ArrayRef(z3term, self.ctx)
            elif type_.is_bv_type():
                return z3.BitVecRef(z3term, self.ctx)
            else:
                raise NotImplementedError(formula)
        elif formula.node_type() in op.ARRAY_OPERATORS:
            return z3.ArrayRef(z3term, self.ctx)
        else:
            assert formula.is_constant(), formula
            type_ = formula.constant_type()
            if type_.is_bool_type():
                return z3.BoolRef(z3term, self.ctx)
            elif type_.is_real_type() or type_.is_int_type():
                return z3.ArithRef(z3term, self.ctx)
            elif type_.is_array_type():
                return z3.ArrayRef(z3term, self.ctx)
            elif type_.is_bv_type():
                return z3.BitVecRef(z3term, self.ctx)
            else:
                raise NotImplementedError(formula)