Ejemplo n.º 1
0
 def pp_fp_value(self, a):
     z3._z3_assert(isinstance(a, z3.FPNumRef), 'type mismatch')
     if not self.fpa_pretty:            
         if (a.isNaN()):
             return to_format('NaN')
         elif (a.isInf()):
             if (a.isNegative()):
                 return to_format('-oo')
             else:
                 return to_format('+oo')
         elif (a.isZero()):
             if (a.isNegative()):
                 return to_format('-zero')
             else:
                 return to_format('+zero')
         else:
             z3._z3_assert(z3.is_fp_value(a), 'expecting FP num ast')
             r = []
             sgn = c_int(0)
             sgnb = Z3_fpa_get_numeral_sign(a.ctx_ref(), a.ast, byref(sgn))
             sig = Z3_fpa_get_numeral_significand_string(a.ctx_ref(), a.ast)
             exp = Z3_fpa_get_numeral_exponent_string(a.ctx_ref(), a.ast)
             r.append(to_format('FPVal('))
             if sgnb and sgn.value != 0:
                 r.append(to_format('-'))
             r.append(to_format(sig))
             r.append(to_format('*(2**'))
             r.append(to_format(exp))
             r.append(to_format(', '))
             r.append(to_format(a.sort()))
             r.append(to_format('))'))
             return compose(r)
     else:
         if (a.isNaN()):
             return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_NAN])
         elif (a.isInf()):
             if (a.isNegative()):
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_MINUS_INF])
             else:
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_PLUS_INF])
         elif (a.isZero()):
             if (a.isNegative()):
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_MINUS_ZERO])
             else:
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_PLUS_ZERO])
         else:
             z3._z3_assert(z3.is_fp_value(a), 'expecting FP num ast')
             r = []
             sgn = (ctypes.c_int)(0)
             sgnb = Z3_fpa_get_numeral_sign(a.ctx_ref(), a.ast, byref(sgn))
             sig = Z3_fpa_get_numeral_significand_string(a.ctx_ref(), a.ast)
             exp = Z3_fpa_get_numeral_exponent_string(a.ctx_ref(), a.ast)
             if sgnb and sgn.value != 0:
                 r.append(to_format('-'))
             r.append(to_format(sig))
             if (exp != '0'):
                 r.append(to_format('*(2**'))
                 r.append(to_format(exp))
                 r.append(to_format(')'))                
             return compose(r)
Ejemplo n.º 2
0
 def pp_fp_value(self, a):
     z3._z3_assert(isinstance(a, z3.FPNumRef), 'type mismatch')
     if not self.fpa_pretty:            
         if (a.isNaN()):
             return to_format('NaN')
         elif (a.isInf()):
             if (a.isNegative()):
                 return to_format('-oo')
             else:
                 return to_format('+oo')
         elif (a.isZero()):
             if (a.isNegative()):
                 return to_format('-zero')
             else:
                 return to_format('+zero')
         else:
             z3._z3_assert(z3.is_fp_value(a), 'expecting FP num ast')
             r = []
             sgn = c_int(0)
             sgnb = Z3_fpa_get_numeral_sign(a.ctx_ref(), a.ast, byref(sgn))
             sig = Z3_fpa_get_numeral_significand_string(a.ctx_ref(), a.ast)
             exp = Z3_fpa_get_numeral_exponent_string(a.ctx_ref(), a.ast)
             r.append(to_format('FPVal('))
             if sgnb and sgn.value != 0:
                 r.append(to_format('-'))
             r.append(to_format(sig))
             r.append(to_format('*(2**'))
             r.append(to_format(exp))
             r.append(to_format(', '))
             r.append(to_format(a.sort()))
             r.append(to_format('))'))
             return compose(r)
     else:
         if (a.isNaN()):
             return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_NAN])
         elif (a.isInf()):
             if (a.isNegative()):
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_MINUS_INF])
             else:
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_PLUS_INF])
         elif (a.isZero()):
             if (a.isNegative()):
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_MINUS_ZERO])
             else:
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_PLUS_ZERO])
         else:
             z3._z3_assert(z3.is_fp_value(a), 'expecting FP num ast')
             r = []
             sgn = (ctypes.c_int)(0)
             sgnb = Z3_fpa_get_numeral_sign(a.ctx_ref(), a.ast, byref(sgn))
             sig = Z3_fpa_get_numeral_significand_string(a.ctx_ref(), a.ast)
             exp = Z3_fpa_get_numeral_exponent_string(a.ctx_ref(), a.ast)
             if sgnb and sgn.value != 0:
                 r.append(to_format('-'))
             r.append(to_format(sig))
             if (exp != '0'):
                 r.append(to_format('*(2**'))
                 r.append(to_format(exp))
                 r.append(to_format(')'))                
             return compose(r)
Ejemplo n.º 3
0
 def pp_fp_value(self, a):
     z3._z3_assert(isinstance(a, z3.FPNumRef), "type mismatch")
     if not self.fpa_pretty:
         if a.isNaN():
             return to_format("NaN")
         elif a.isInf():
             if a.isNegative():
                 return to_format("-oo")
             else:
                 return to_format("+oo")
         elif a.isZero():
             if a.isNegative():
                 return to_format("-zero")
             else:
                 return to_format("+zero")
         else:
             z3._z3_assert(z3.is_fp_value(a), "expecting FP num ast")
             r = []
             sgn = c_int(0)
             sgnb = Z3_fpa_get_numeral_sign(a.ctx_ref(), a.ast, byref(sgn))
             sig = Z3_fpa_get_numeral_significand_string(a.ctx_ref(), a.ast)
             exp = Z3_fpa_get_numeral_exponent_string(a.ctx_ref(), a.ast)
             r.append(to_format("FPVal("))
             if sgnb and sgn.value != 0:
                 r.append(to_format("-"))
             r.append(to_format(sig))
             r.append(to_format("*(2**"))
             r.append(to_format(exp))
             r.append(to_format(", "))
             r.append(to_format(a.sort()))
             r.append(to_format("))"))
             return compose(r)
     else:
         if a.isNaN():
             return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_NAN])
         elif a.isInf():
             if a.isNegative():
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_MINUS_INF])
             else:
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_PLUS_INF])
         elif a.isZero():
             if a.isNegative():
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_MINUS_ZERO])
             else:
                 return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_PLUS_ZERO])
         else:
             z3._z3_assert(z3.is_fp_value(a), "expecting FP num ast")
             r = []
             sgn = (ctypes.c_int)(0)
             sgnb = Z3_fpa_get_numeral_sign(a.ctx_ref(), a.ast, byref(sgn))
             sig = Z3_fpa_get_numeral_significand_string(a.ctx_ref(), a.ast)
             exp = Z3_fpa_get_numeral_exponent_string(a.ctx_ref(), a.ast)
             if sgnb and sgn.value != 0:
                 r.append(to_format("-"))
             r.append(to_format(sig))
             if exp != "0":
                 r.append(to_format("*(2**"))
                 r.append(to_format(exp))
                 r.append(to_format(")"))
             return compose(r)
Ejemplo n.º 4
0
 def pp_app(self, a, d, xs):
     if z3.is_int_value(a):
         return self.pp_int(a)
     elif z3.is_rational_value(a):
         return self.pp_rational(a)
     elif z3.is_algebraic_value(a):
         return self.pp_algebraic(a)
     elif z3.is_bv_value(a):
         return self.pp_bv(a)
     elif z3.is_finite_domain_value(a):
         return self.pp_fd(a)
     elif z3.is_fprm_value(a):
         return self.pp_fprm_value(a)
     elif z3.is_fp_value(a):
         return self.pp_fp_value(a)
     elif z3.is_fp(a):
         return self.pp_fp(a, d, xs)
     elif z3.is_string_value(a):
         return self.pp_string(a)
     elif z3.is_const(a):
         return self.pp_const(a)
     else:
         f = a.decl()
         k = f.kind()
         if k == Z3_OP_POWER:
             return self.pp_power(a, d, xs)
         elif k == Z3_OP_DISTINCT:
             return self.pp_distinct(a, d, xs)
         elif k == Z3_OP_SELECT:
             return self.pp_select(a, d, xs)
         elif k == Z3_OP_SIGN_EXT or k == Z3_OP_ZERO_EXT or k == Z3_OP_REPEAT:
             return self.pp_unary_param(a, d, xs)
         elif k == Z3_OP_EXTRACT:
             return self.pp_extract(a, d, xs)
         elif k == Z3_OP_RE_LOOP:
             return self.pp_loop(a, d, xs)
         elif k == Z3_OP_DT_IS:
             return self.pp_is(a, d, xs)
         elif k == Z3_OP_ARRAY_MAP:
             return self.pp_map(a, d, xs)
         elif k == Z3_OP_CONST_ARRAY:
             return self.pp_K(a, d, xs)
         elif k == Z3_OP_PB_AT_MOST:
             return self.pp_atmost(a, d, f, xs)
         elif k == Z3_OP_PB_LE:
             return self.pp_pbcmp(a, d, f, xs)
         elif k == Z3_OP_PB_GE:
             return self.pp_pbcmp(a, d, f, xs)
         elif k == Z3_OP_PB_EQ:
             return self.pp_pbcmp(a, d, f, xs)
         elif z3.is_pattern(a):
             return self.pp_pattern(a, d, xs)
         elif self.is_infix(k):
             return self.pp_infix(a, d, xs)
         elif self.is_unary(k):
             return self.pp_unary(a, d, xs)
         else:
             return self.pp_prefix(a, d, xs)
Ejemplo n.º 5
0
 def pp_app(self, a, d, xs):
     if z3.is_int_value(a):
         return self.pp_int(a)
     elif z3.is_rational_value(a):
         return self.pp_rational(a)
     elif z3.is_algebraic_value(a):
         return self.pp_algebraic(a)        
     elif z3.is_bv_value(a):
         return self.pp_bv(a)
     elif z3.is_finite_domain_value(a):
         return self.pp_fd(a)
     elif z3.is_fprm_value(a):
         return self.pp_fprm_value(a)
     elif z3.is_fp_value(a):
         return self.pp_fp_value(a)
     elif z3.is_fp(a):
         return self.pp_fp(a, d, xs)
     elif z3.is_string_value(a):
         return self.pp_string(a)
     elif z3.is_const(a):
         return self.pp_const(a)
     else:
         f = a.decl()
         k = f.kind()
         if k == Z3_OP_POWER:
             return self.pp_power(a, d, xs)
         elif k == Z3_OP_DISTINCT:
             return self.pp_distinct(a, d, xs)
         elif k == Z3_OP_SELECT:
             return self.pp_select(a, d, xs)
         elif k == Z3_OP_SIGN_EXT or k == Z3_OP_ZERO_EXT or k == Z3_OP_REPEAT:
             return self.pp_unary_param(a, d, xs)
         elif k == Z3_OP_EXTRACT:
             return self.pp_extract(a, d, xs)
         elif k == Z3_OP_DT_IS:
             return self.pp_is(a, d, xs)
         elif k == Z3_OP_ARRAY_MAP:
             return self.pp_map(a, d, xs)
         elif k == Z3_OP_CONST_ARRAY:
             return self.pp_K(a, d, xs)
         elif k == Z3_OP_PB_AT_MOST:
             return self.pp_atmost(a, d, f, xs)
         elif k == Z3_OP_PB_LE:
             return self.pp_pbcmp(a, d, f, xs)
         elif k == Z3_OP_PB_GE:
             return self.pp_pbcmp(a, d, f, xs)
         elif k == Z3_OP_PB_EQ:
             return self.pp_pbcmp(a, d, f, xs)
         elif z3.is_pattern(a):
             return self.pp_pattern(a, d, xs)
         elif self.is_infix(k):
             return self.pp_infix(a, d, xs)
         elif self.is_unary(k):
             return self.pp_unary(a, d, xs)
         else:
             return self.pp_prefix(a, d, xs)
Ejemplo n.º 6
0
 def pp_app(self, a, d, xs):
     if z3.is_int_value(a):
         return self.pp_int(a)
     elif z3.is_rational_value(a):
         return self.pp_rational(a)
     elif z3.is_algebraic_value(a):
         return self.pp_algebraic(a)
     elif z3.is_bv_value(a):
         return self.pp_bv(a)
     elif z3.is_fprm_value(a):
         return self.pp_fprm_value(a)
     elif z3.is_fp_value(a):
         return self.pp_fp_value(a)
     elif z3.is_fp(a):
         return self.pp_fp(a, d, xs)
     elif z3.is_const(a):
         return self.pp_const(a)
     else:
         f = a.decl()
         k = f.kind()
         if k == Z3_OP_POWER:
             return self.pp_power(a, d, xs)
         elif k == Z3_OP_DISTINCT:
             return self.pp_distinct(a, d, xs)
         elif k == Z3_OP_SELECT:
             return self.pp_select(a, d, xs)
         elif k == Z3_OP_SIGN_EXT or k == Z3_OP_ZERO_EXT or k == Z3_OP_REPEAT:
             return self.pp_unary_param(a, d, xs)
         elif k == Z3_OP_EXTRACT:
             return self.pp_extract(a, d, xs)
         elif k == Z3_OP_ARRAY_MAP:
             return self.pp_map(a, d, xs)
         elif k == Z3_OP_CONST_ARRAY:
             return self.pp_K(a, d, xs)
         elif z3.is_pattern(a):
             return self.pp_pattern(a, d, xs)
         elif self.is_infix(k):
             return self.pp_infix(a, d, xs)
         elif self.is_unary(k):
             return self.pp_unary(a, d, xs)
         else:
             return self.pp_prefix(a, d, xs)
Ejemplo n.º 7
0
    def pp_fp_value(self, a):
        _z3_assert(isinstance(a, z3.FPNumRef), "type mismatch")
        if not self.fpa_pretty:
            r = []
            if (a.isNaN()):
                r.append(to_format(_z3_op_to_fpa_normal_str[Z3_OP_FPA_NAN]))
                r.append(to_format("("))
                r.append(to_format(a.sort()))
                r.append(to_format(")"))
                return compose(r)
            elif (a.isInf()):
                if (a.isNegative()):
                    r.append(to_format(_z3_op_to_fpa_normal_str[Z3_OP_FPA_MINUS_INF]))
                else:
                    r.append(to_format(_z3_op_to_fpa_normal_str[Z3_OP_FPA_PLUS_INF]))
                r.append(to_format("("))
                r.append(to_format(a.sort()))
                r.append(to_format(")"))
                return compose(r)

            elif (a.isZero()):
                if (a.isNegative()):
                    return to_format("-zero")
                else:
                    return to_format("+zero")
            else:
                _z3_assert(z3.is_fp_value(a), "expecting FP num ast")
                r = []
                sgn = c_int(0)
                sgnb = Z3_fpa_get_numeral_sign(a.ctx_ref(), a.ast, byref(sgn))
                exp = Z3_fpa_get_numeral_exponent_string(a.ctx_ref(), a.ast, False)
                sig = Z3_fpa_get_numeral_significand_string(a.ctx_ref(), a.ast)
                r.append(to_format("FPVal("))
                if sgnb and sgn.value != 0:
                    r.append(to_format("-"))
                r.append(to_format(sig))
                r.append(to_format("*(2**"))
                r.append(to_format(exp))
                r.append(to_format(", "))
                r.append(to_format(a.sort()))
                r.append(to_format("))"))
                return compose(r)
        else:
            if (a.isNaN()):
                return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_NAN])
            elif (a.isInf()):
                if (a.isNegative()):
                    return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_MINUS_INF])
                else:
                    return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_PLUS_INF])
            elif (a.isZero()):
                if (a.isNegative()):
                    return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_MINUS_ZERO])
                else:
                    return to_format(_z3_op_to_fpa_pretty_str[Z3_OP_FPA_PLUS_ZERO])
            else:
                _z3_assert(z3.is_fp_value(a), "expecting FP num ast")
                r = []
                sgn = (ctypes.c_int)(0)
                sgnb = Z3_fpa_get_numeral_sign(a.ctx_ref(), a.ast, byref(sgn))
                exp = Z3_fpa_get_numeral_exponent_string(a.ctx_ref(), a.ast, False)
                sig = Z3_fpa_get_numeral_significand_string(a.ctx_ref(), a.ast)
                if sgnb and sgn.value != 0:
                    r.append(to_format("-"))
                r.append(to_format(sig))
                if (exp != "0"):
                    r.append(to_format("*(2**"))
                    r.append(to_format(exp))
                    r.append(to_format(")"))
                return compose(r)