예제 #1
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)
예제 #2
0
파일: z3printer.py 프로젝트: simudream/z3
 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_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 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 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)
예제 #3
0
    def pp_fp(self, a, d, xs):
        _z3_assert(isinstance(a, z3.FPRef), "type mismatch")
        k = a.decl().kind()
        op = '?'
        if (self.fpa_pretty and k in _z3_op_to_fpa_pretty_str):
            op = _z3_op_to_fpa_pretty_str[k]
        elif k in _z3_op_to_fpa_normal_str:
            op = _z3_op_to_fpa_normal_str[k]
        elif k in _z3_op_to_str:
            op = _z3_op_to_str[k]

        n = a.num_args()

        if self.fpa_pretty:
            if self.is_infix(k) and n >= 3:
                rm = a.arg(0)
                if z3.is_fprm_value(rm) and z3._dflt_rm(a.ctx).eq(rm):
                    arg1 = to_format(self.pp_expr(a.arg(1), d + 1, xs))
                    arg2 = to_format(self.pp_expr(a.arg(2), d + 1, xs))
                    r = []
                    r.append(arg1)
                    r.append(to_format(' '))
                    r.append(to_format(op))
                    r.append(to_format(' '))
                    r.append(arg2)
                    return compose(r)
            elif k == Z3_OP_FPA_NEG:
                return compose([
                    to_format('-'),
                    to_format(self.pp_expr(a.arg(0), d + 1, xs))
                ])

        if k in _z3_op_to_fpa_normal_str:
            op = _z3_op_to_fpa_normal_str[k]

        r = []
        r.append(to_format(op))
        if not z3.is_const(a):
            r.append(to_format('('))
            first = True
            for c in a.children():
                if first:
                    first = False
                else:
                    r.append(to_format(', '))
                r.append(self.pp_expr(c, d + 1, xs))
            r.append(to_format(')'))
            return compose(r)
        else:
            return to_format(a.as_string())
예제 #4
0
파일: z3printer.py 프로젝트: 4tXJ7f/z3
    def pp_fp(self, a, d, xs):
        z3._z3_assert(isinstance(a, z3.FPRef), "type mismatch")
        k = a.decl().kind()
        op = '?'
        if (self.fpa_pretty and k in _z3_op_to_fpa_pretty_str):
            op = _z3_op_to_fpa_pretty_str[k]
        elif k in _z3_op_to_fpa_normal_str:
            op = _z3_op_to_fpa_normal_str[k]
        elif k in _z3_op_to_str:
            op = _z3_op_to_str[k]        

        n = a.num_args()

        if self.fpa_pretty:
            if self.is_infix(k) and n >= 3:            
                rm = a.arg(0)
                if z3.is_fprm_value(rm) and z3._dflt_rm(a.ctx).eq(rm):
                    arg1 = to_format(self.pp_expr(a.arg(1), d+1, xs))
                    arg2 = to_format(self.pp_expr(a.arg(2), d+1, xs))
                    r = []
                    r.append(arg1)
                    r.append(to_format(' '))
                    r.append(to_format(op))
                    r.append(to_format(' '))
                    r.append(arg2)
                    return compose(r)
            elif k == Z3_OP_FPA_NEG:
                return compose([to_format('-') , to_format(self.pp_expr(a.arg(0), d+1, xs))])

        if k in _z3_op_to_fpa_normal_str:
            op = _z3_op_to_fpa_normal_str[k]
        
        r = []        
        r.append(to_format(op))
        if not z3.is_const(a):
            r.append(to_format('('))                        
            first = True
            for c in a.children():                
                if first:
                    first = False
                else:
                    r.append(to_format(', '))
                r.append(self.pp_expr(c, d+1, xs))
            r.append(to_format(')'))
            return compose(r)
        else:
            return to_format(a.as_string())
예제 #5
0
 def pp_fprm_value(self, a):
     _z3_assert(z3.is_fprm_value(a), "expected FPRMNumRef")
     if self.fpa_pretty and (a.decl().kind() in _z3_op_to_fpa_pretty_str):
         return to_format(_z3_op_to_fpa_pretty_str.get(a.decl().kind()))
     else:
         return to_format(_z3_op_to_fpa_normal_str.get(a.decl().kind()))
예제 #6
0
파일: z3printer.py 프로젝트: 4tXJ7f/z3
 def pp_fprm_value(self, a):
     z3._z3_assert(z3.is_fprm_value(a), 'expected FPRMNumRef')
     if self.fpa_pretty and (a.decl().kind() in _z3_op_to_fpa_pretty_str):
         return to_format(_z3_op_to_fpa_pretty_str.get(a.decl().kind()))
     else:
         return to_format(_z3_op_to_fpa_normal_str.get(a.decl().kind()))