def test_imply_noloop(self):
        with tests.Configure(self, __file__, "/example.smv"):
            expr = ast.Imply(ast.Proposition("a"), ast.Proposition("b"))
            self.assertEqual(
                (ast.Proposition("a").semantic_no_loop(self.enc, 2, 3).imply(
                    ast.Proposition("b").semantic_no_loop(self.enc, 2, 3))),
                expr.semantic_no_loop(self.enc, 2, 3))

            expr = ast.Imply(ast.Globally(ast.Proposition("a")),
                             ast.Eventually(ast.Proposition("b")))
            self.assertEqual(
                (-ast.Globally(ast.Proposition("a")).semantic_no_loop(
                    self.enc, 2, 3)
                 | ast.Eventually(ast.Proposition("b")).semantic_no_loop(
                     self.enc, 2, 3)), expr.semantic_no_loop(self.enc, 2, 3))
    def test_xor_with_loop(self):
        with tests.Configure(self, __file__, "/example.smv"):
            expr = ast.Xor(ast.Proposition("a"), ast.Proposition("b"))
            self.assertEqual(
                (ast.Proposition("a").semantic_with_loop(self.enc, 2, 3, 1)
                 ^ ast.Proposition("b").semantic_with_loop(self.enc, 2, 3, 1)),
                expr.semantic_with_loop(self.enc, 2, 3, 1))

            expr = ast.Xor(ast.Globally(ast.Proposition("a")),
                           ast.Eventually(ast.Proposition("b")))
            self.assertEqual(
                (ast.Globally(ast.Proposition("a")).semantic_with_loop(
                    self.enc, 2, 3, 1)
                 ^ ast.Eventually(ast.Proposition("b")).semantic_with_loop(
                     self.enc, 2, 3, 1)),
                expr.semantic_with_loop(self.enc, 2, 3, 1))
    def test_globally_no_loop(self):
        with tests.Configure(self, __file__, "/example.smv"):
            i, k = 0, 2
            enc = self.enc
            mgr = enc.manager
            a = ast.Proposition("a")
            formula = ast.Globally(a)

            tool = formula.semantic_no_loop(enc, i, k)
            self.assertEqual(Be.false(mgr), tool)
    def test_globally_with_loop(self):
        with tests.Configure(self, __file__, "/example.smv"):
            i, k, l = 0, 2, 0
            enc = self.enc
            a = ast.Proposition("a")
            formula = ast.Globally(a)
            tool    = formula.semantic_with_loop(enc, i, k, l) &\
                        bmcutils.loop_condition(enc, k, l)

            nusmv = ltlspec.bounded_semantics(
                self.befsm, Node.from_ptr(parse_ltl_spec("G a")), k, l)

            manual  = a.semantic_with_loop(enc, i, k, l)   &\
                      a.semantic_with_loop(enc, i+1, k, l) &\
                      bmcutils.loop_condition(enc, k, l)

            # normalized string representation of the BE's (make them comparable)
            s_tool = tests.canonical_cnf(tool)
            s_nusmv = tests.canonical_cnf(nusmv)
            s_manual = tests.canonical_cnf(manual)

            self.assertEqual(s_nusmv, s_tool)
            self.assertEqual(s_manual, s_tool)