Exemplo n.º 1
0
    def test_normalization(self):
        from pysmt.environment import Environment

        env2 = Environment()
        mgr2 = env2.formula_manager

        ty = ArrayType(BOOL, REAL)
        x = FreshSymbol(ty)
        fty = FunctionType(BOOL, (ty, ))
        f = FreshSymbol(fty)
        g = Function(f, (x, ))
        self.assertIsNotNone(g)
        self.assertNotIn(g, mgr2)
        g2 = mgr2.normalize(g)
        self.assertIn(g2, mgr2)
        # Since the types are from two different environments, they
        # should be different.
        x2 = g2.arg(0)
        ty2 = x2.symbol_type()
        self.assertFalse(ty2 is ty, ty)
        fname = g2.function_name()
        fty2 = fname.symbol_type()
        self.assertFalse(fty2 is fty, fty)

        # Test ArrayValue
        h = Array(BVType(4), BV(0, 4))
        h2 = mgr2.normalize(h)
        self.assertEqual(h.array_value_index_type(),
                         h2.array_value_index_type())
        self.assertFalse(h.array_value_index_type() is \
                         h2.array_value_index_type())