Esempio n. 1
0
 def to_smtlib(self):
     """Return a SMT_LIB string representation of the formula."""
     sc.reset_env()
     i_f = sc.And(*[bv2pysmt(a) for a in self.inner_problem.assertions])
     o_f = sc.And(*[bv2pysmt(a) for a in self.outer_problem.assertions])
     pysmt_formula = sc.And(i_f, o_f)
     return sc.to_smtlib(pysmt_formula, daggify=False)
Esempio n. 2
0
    def to_smtlib(self):
        """Return a SMT_LIB string representation of the formula.

            >>> from arxpy.bitvector.function import Function
            >>> from arxpy.diffcrypt.difference import XorDiff, DiffVar
            >>> from arxpy.diffcrypt.characteristic import Characteristic
            >>> from arxpy.diffcrypt.smt import SmtProblem
            >>> class MyFunction(Function):
            ...     input_widths = [8, 8, 8]
            ...     output_widths = [8, 8]
            ...     @classmethod
            ...     def eval(cls, x, y, k):
            ...         return (y + k, (y + k) ^ x)
            >>> x, y, k = DiffVar("x", 8), DiffVar("y", 8), DiffVar("k", 8)
            >>> ch = Characteristic(MyFunction, XorDiff, [x, y, k])
            >>> smt_problem = SmtProblem(ch, 0)
            >>> print(smt_problem.to_smtlib())  # doctest:+ELLIPSIS
            (and (not (= #b000000000000000000000000 (concat (concat x y) k))) ...

        Note that a more human-readable from can be obtained by
        printing the SmtProblem directly (print(smt_problem)).
        """
        sc.reset_env()
        pysmt_formula = sc.And(*[bv2pysmt(a) for a in self.assertions])
        return sc.to_smtlib(pysmt_formula, daggify=False)
Esempio n. 3
0
 def test_function_smtlib_print(self):
     f_t = FunctionType(BOOL, [BOOL])
     f0 = Symbol('f 0', f_t)
     f0_of_false = Function(f0, [Bool(False)])
     s = to_smtlib(f0_of_false, False)
     self.assertEqual(s, '(|f 0| false)')