示例#1
0
 def walk_symbol(self, formula, **kwargs):
     symbol_type = formula.symbol_type()
     if symbol_type.is_function_type():
         res = self._z3_func_decl(formula)
     else:
         sname = formula.symbol_name()
         z3_sname = z3.Z3_mk_string_symbol(self.ctx.ref(), sname)
         if symbol_type.is_bool_type():
             sort_ast = self.z3BoolSort.ast
         elif symbol_type.is_real_type():
             sort_ast = self.z3RealSort.ast
         elif symbol_type.is_int_type():
             sort_ast = self.z3IntSort.ast
         elif symbol_type.is_array_type():
             sort_ast = self._type_to_z3(symbol_type).ast
         elif symbol_type.is_string_type():
             raise ConvertExpressionError(message=("Unsupported string symbol: %s" %
                                                   str(formula)),
                                          expression=formula)
         elif symbol_type.is_enum_type():
             sort_ast = self._type_to_z3(symbol_type).ast
         elif symbol_type.is_custom_type():
             sort_ast = self._type_to_z3(symbol_type).ast
         else:
             sort_ast = self._type_to_z3(symbol_type).ast
         # Create const with given sort
         res = z3.Z3_mk_const(self.ctx.ref(), z3_sname, sort_ast)
         z3.Z3_inc_ref(self.ctx.ref(), res)
     return res
示例#2
0
文件: dpda.py 项目: fnordomat/dPDA
def Sequence(name, ctx=None):
    """Return a sequence constant named `name`. If `ctx=None`, then the global context is used.
    >>> x = Sequence('x')
    """
    ctx = z3.get_ctx(ctx)
    int_sort = z3.IntSort(ctx)
    return z3.SeqRef(
        z3.Z3_mk_const(
            ctx.ref(), z3.to_symbol(name, ctx),
            z3.SeqSortRef(z3.Z3_mk_seq_sort(int_sort.ctx_ref(),
                                            int_sort.ast)).ast), ctx)
示例#3
0
 def walk_symbol(self, formula, **kwargs):
     symbol_type = formula.symbol_type()
     sname = formula.symbol_name()
     z3_sname = z3.Z3_mk_string_symbol(self.ctx.ref(), sname)
     if symbol_type.is_bool_type():
         sort_ast = self.z3BoolSort.ast
     elif symbol_type.is_real_type():
         sort_ast = self.z3RealSort.ast
     elif symbol_type.is_int_type():
         sort_ast = self.z3IntSort.ast
     else:
         sort_ast = self._type_to_z3(symbol_type).ast
     # Create const with given sort
     res = z3.Z3_mk_const(self.ctx.ref(), z3_sname, sort_ast)
     z3.Z3_inc_ref(self.ctx.ref(), res)
     return res