Beispiel #1
0
    def test_basic2(self):
        model_source = """\
(model
  ;; universe for U:
  ;;   (as @val1 U) (as @val0 U)
  (define-fun b () U
    (as @val0 U))
  (define-fun a () U
    (as @val1 U))
  (define-fun f ((x!0 U)) U
    (ite (= x!0 (as @val1 U)) (as @val0 U)
      (as @val1 U)))
)
"""
        model_buf = StringIO(model_source)

        parser = SmtLibParser()
        simplifier = SmtLibModelValidationSimplifier(self.env)

        U = self.tm.Type('U', 0)

        # We construct the model even befor symbols are constructed in pysmt
        model, interpretations = parser.parse_model(model_buf)

        a = self.fm.Symbol('a', U)
        b = self.fm.Symbol('b', U)
        f = self.fm.Symbol('f', FunctionType(U, [U]))
        formula = self.fm.And(self.fm.Not(self.fm.Equals(a, b)),
                              self.fm.Equals(self.fm.Function(f, [a]), b))

        simp = simplifier.simplify(formula.substitute(model, interpretations))
        self.assertEqual(simp, self.fm.TRUE())