Exemplo n.º 1
0
 def test_multiples(self):
     a = pcaparser.PARSER.parse('A and B and C or D or F')
     to_assert = pcaprop.DisjunctionOp(pcaprop.DisjunctionOp(
         pcaprop.ConjunctionOp(pcaprop.ConjunctionOp(pcaprop.Variable('A'), pcaprop.Variable('B')),
                               pcaprop.Variable('C')), pcaprop.Variable('D')), pcaprop.Variable('F'))
     self.assertEqual(a, to_assert)
     a = pcaparser.PARSER.parse('A implies B implies C iff D iff F')
     to_assert = pcaprop.EquivalenceOp(pcaprop.EquivalenceOp(
         pcaprop.ImplicationOp(pcaprop.ImplicationOp(pcaprop.Variable('A'), pcaprop.Variable('B')),
                               pcaprop.Variable('C')), pcaprop.Variable('D')), pcaprop.Variable('F'))
     self.assertEqual(a, to_assert)
Exemplo n.º 2
0
 def test_prop(self):
     a = pcaparser.PARSER.parse('P or B iff C and A implies (P and C)')
     to_assert = pcaprop.EquivalenceOp(pcaprop.DisjunctionOp(pcaprop.Variable('P'), pcaprop.Variable('B')),
                                       pcaprop.ImplicationOp(
                                           pcaprop.ConjunctionOp(pcaprop.Variable('C'), pcaprop.Variable('A')),
                                           pcaprop.ConjunctionOp(pcaprop.Variable('P'), pcaprop.Variable('C'))))
     self.assertEqual(a, to_assert)
     a = pcaparser.PARSER.parse('true or not A implies false and not not not B or A')
     to_assert = pcaprop.ImplicationOp(
         pcaprop.DisjunctionOp(pcaprop.TrueProp(), pcaprop.NegationOp(pcaprop.Variable('A'))),
         pcaprop.DisjunctionOp(
             pcaprop.ConjunctionOp(pcaprop.FalseProp(), pcaprop.NegationOp(
                 pcaprop.NegationOp(pcaprop.NegationOp(pcaprop.Variable('B'))))),
             pcaprop.Variable('A')))
     self.assertEqual(a, to_assert)
Exemplo n.º 3
0
 def test_commutativity(self):
     self.assertTrue(
         pcabuilder.InitProp('A and B').commutativity() == pcaprop.
         ConjunctionOp(pcaprop.Variable('B'), pcaprop.Variable('A')))
     self.assertTrue(
         pcabuilder.InitProp('A and (C and B)').commutativity() ==
         pcaprop.ConjunctionOp(
             pcaprop.ConjunctionOp(pcaprop.Variable(
                 'B'), pcaprop.Variable('C')), pcaprop.Variable('A')))
     self.assertTrue(
         pcabuilder.InitProp('A or (C and ( D or B))').commutativity() ==
         pcaprop.DisjunctionOp(
             pcaprop.ConjunctionOp(
                 pcaprop.DisjunctionOp(pcaprop.Variable('B'),
                                       pcaprop.Variable('D')),
                 pcaprop.Variable('C')), pcaprop.Variable('A')))
     self.assertTrue(
         pcabuilder.InitProp('B implies (A and B)').commutativity() ==
         pcaprop.ImplicationOp(
             pcaprop.Variable('B'),
             pcaprop.ConjunctionOp(pcaprop.Variable('B'),
                                   pcaprop.Variable('A'))))
     self.assertTrue(
         pcabuilder.InitProp('not not (A and B)').commutativity() ==
         pcaprop.NegationOp(
             pcaprop.NegationOp(
                 pcaprop.ConjunctionOp(pcaprop.Variable('B'),
                                       pcaprop.Variable('A')))))
Exemplo n.º 4
0
 def exp_implies(self, value):
     if len(value) == 3:
         return pcaprop.ImplicationOp(value[0], value[2])
     return self._rec_object(value, 'exp_implies')
Exemplo n.º 5
0
 def test_precedence(self):
     a = pcaprop.Variable("A")
     b = pcaprop.Variable("B")
     self.assertEqual((a + b >> ~a * b), pcaprop.ImplicationOp(
       pcaprop.DisjunctionOp(a, b), pcaprop.ConjunctionOp(pcaprop.NegationOp(a), b)))
Exemplo n.º 6
0
 def test_creation(self):
     a = pcaprop.Variable("A")
     b = pcaprop.Variable("B")
     c = pcaprop.Variable("C")
     self.assertEqual(a >> (~(a * b) + c), pcaprop.ImplicationOp(
         a, pcaprop.DisjunctionOp(pcaprop.NegationOp(pcaprop.ConjunctionOp(a, b)), c)))