Esempio n. 1
0
 def rec(e):
     if not z3.is_ast(e):
         return
     if z3.is_const(e) and e.decl().kind() == z3.Z3_OP_UNINTERPRETED:
         res.add(e)
         return
     for child in e.children():
         rec(child)
Esempio n. 2
0
 def __init__(self, ast):
     self.ast = ast
     if z3.is_ast(ast):
         self.__type = "z3"
     elif isinstance(ast, simsym.Symbolic):
         self.__type = "simsym"
     else:
         self.__type = "value"
Esempio n. 3
0
 def rec(e):
     if not z3.is_ast(e):
         return
     if z3.is_const(e) and e.decl().kind() == z3.Z3_OP_UNINTERPRETED:
         res.add(e)
         return
     for child in e.children():
         rec(child)
Esempio n. 4
0
    def visit(self, e):
        assert z3.is_ast(e)
        if not z3.is_app(e):
            raise Z3ExprDispatcherException('expr was not an application')

        # Call the appropriate function application handler
        app_kind = e.decl().kind()

        if app_kind == z3.Z3_OP_UNINTERPRETED and e.num_args() == 0:
            self.visit_variable(e)
            return

        try:
            handler = self._z3_app_dispatcher_map[app_kind]
            handler(e)
        except KeyError as e:
            msg = 'Handler for {} is missing from dispatch dictionary'.format(
                app_kind)
            raise NotImplementedError(msg)
Esempio n. 5
0
def unveil(solver, item, phase=0):
    if type(item) == list:
        for i in item:
            indent = lambda n: ''.join(['\t'] * (n))
            if type(i) != list: i = ["else", i]
            if is_bool(i[1]):
                print(indent(phase), i[0], '->', evaluate(solver, i[1]))
            else:
                print(indent(phase), i[0], '->')
                unveil(solver, i[1], phase + 1)
    else:
        if is_bool(item):
            return item
        elif is_as_array(item):
            return unveil(solver, as_list(solver, item), phase)
        elif item.decl().name() == 'if':
            return unveil(solver, [list(i) for i in zip(ITE, item.children())],
                          phase)
        elif is_ast(item):
            return unveil(solver, evaluate(solver, item), phase)
        else:
            return "#unspecified"