Beispiel #1
0
    def get_value(self, item):
        self._assert_no_function_type(item)

        titem = self.converter.convert(item)
        ty = self.environment.stc.get_type(item)
        if ty.is_bool_type():
            status, res = yicespy.yices_get_bool_value(self.model, titem)
            self._check_error(status)
            return self.mgr.Bool(bool(res))
        elif ty.is_int_type():
            res = yicespy.yices_get_integer_value(self.model, titem)
            return self.mgr.Int(res)
        elif ty.is_real_type():
            status, val = yicespy.yices_get_rational_value(self.model, titem)
            self._check_error(status)
            return self.mgr.Real(Fraction(val))
        elif ty.is_bv_type():
            status, res = yicespy.yices_get_bv_value(self.model, titem,  ty.width)
            self._check_error(status)
            str_val = "".join(str(x) for x in reversed(res))
            return self.mgr.BV("#b" + str_val)
        else:
            raise NotImplementedError()
Beispiel #2
0
    def get_value(self, item):
        self._assert_no_function_type(item)

        titem = self.converter.convert(item)
        ty = self.environment.stc.get_type(item)
        if ty.is_bool_type():
            status, res = yicespy.yices_get_bool_value(self.model, titem)
            self._check_error(status)
            return self.mgr.Bool(bool(res))
        elif ty.is_int_type():
            res = yicespy.yices_get_integer_value(self.model, titem)
            return self.mgr.Int(res)
        elif ty.is_real_type():
            status, val = yicespy.yices_get_rational_value(self.model, titem)
            self._check_error(status)
            return self.mgr.Real(Fraction(val))
        elif ty.is_bv_type():
            status, res = yicespy.yices_get_bv_value(self.model, titem,
                                                     ty.width)
            self._check_error(status)
            str_val = "".join(str(x) for x in reversed(res))
            return self.mgr.BV("#b" + str_val)
        else:
            raise NotImplementedError()