class ClassicalPropositionalLogicFormulaFactory_TestCase(unittest.TestCase):
	def setUp(self):
		self.factory = ClassicalPropositionalLogicFormulaFactory()
		self.anAtomicFormula = self.factory.createAtom("A")
		self.anotherAtomicFormula = self.factory.createAtom("B")

	def testCreateAtom_getConnective(self):	
		self.assertEquals(None, self.anAtomicFormula.getConnective())

	def testCreateAtom_toString(self):	
		self.assertEquals("A", str(self.anAtomicFormula))

	def testCreateNegation_getConnective(self):	
		self.assertEquals(self.factory.logic.NOT, self.factory.createNegation(self.anAtomicFormula).getConnective())

	def testCreateNegation_toString(self):	
		self.assertEquals("!A", str(self.factory.createNegation(self.anAtomicFormula)))

	def testCreateConjunction_getConnective(self):	
		self.assertEquals(self.factory.logic.AND, self.factory.createConjunction(self.anAtomicFormula,self.anotherAtomicFormula).getConnective())

	def testCreateConjunction_toString(self):	
		self.assertEquals("(A&B)", str(self.factory.createConjunction(self.anAtomicFormula,self.anotherAtomicFormula)))

	def testCreateDisjunction_getConnective(self):	
		self.assertEquals(self.factory.logic.OR, self.factory.createDisjunction(self.anAtomicFormula,self.anotherAtomicFormula).getConnective())

	def testCreateDisjunction_toString(self):	
		self.assertEquals("(A|B)", str(self.factory.createDisjunction(self.anAtomicFormula,self.anotherAtomicFormula)))

	def testCreateImplication_getConnective(self):	
		self.assertEquals(self.factory.logic.IMPLIES, self.factory.createImplication(self.anAtomicFormula,self.anotherAtomicFormula).getConnective())

	def testCreateImplication_toString(self):	
		self.assertEquals("(A->B)", str(self.factory.createImplication(self.anAtomicFormula,self.anotherAtomicFormula)))
Beispiel #2
0
	def setUp(self):
		self.formulaFactory = ClassicalPropositionalLogicFormulaFactory()
		self.logic = self.formulaFactory.logic
		self.anAtomicFormula = self.formulaFactory.createAtom("A")
		self.anUnaryFormula = self.formulaFactory.createNegation(self.anAtomicFormula)
		self.aSizeThreeUnaryFormula = self.formulaFactory.createNegation(self.anUnaryFormula)
		self.aBinaryFormula = self.formulaFactory.createConjunction(self.anAtomicFormula, self.anAtomicFormula)
		self.anotherAtomicFormula = self.formulaFactory.createAtom("B")
		self.anotherBinaryFormula = self.formulaFactory.createConjunction(self.anAtomicFormula, self.anotherAtomicFormula)
		self.aSizeSixFormula = self.formulaFactory.createImplication(self.anUnaryFormula, self.anotherBinaryFormula)
Beispiel #3
0
class Formula_TestCase(unittest.TestCase):
	def setUp(self):
		self.formulaFactory = ClassicalPropositionalLogicFormulaFactory()
		self.logic = self.formulaFactory.logic
		self.anAtomicFormula = self.formulaFactory.createAtom("A")
		self.anUnaryFormula = self.formulaFactory.createNegation(self.anAtomicFormula)
		self.aSizeThreeUnaryFormula = self.formulaFactory.createNegation(self.anUnaryFormula)
		self.aBinaryFormula = self.formulaFactory.createConjunction(self.anAtomicFormula, self.anAtomicFormula)
		self.anotherAtomicFormula = self.formulaFactory.createAtom("B")
		self.anotherBinaryFormula = self.formulaFactory.createConjunction(self.anAtomicFormula, self.anotherAtomicFormula)
		self.aSizeSixFormula = self.formulaFactory.createImplication(self.anUnaryFormula, self.anotherBinaryFormula)


	def testAtomicFormula_getConnective(self):
		self.assertEquals(None,self.anAtomicFormula.getConnective())

	def testAtomicFormula_toString(self):
		self.assertEquals("A",str(self.anAtomicFormula))

	def testSizeTwoUnaryFormula_getConnective(self):
		self.assertEquals(self.logic.NOT,self.anUnaryFormula.getConnective())

	def testSizeTwoUnaryFormula_toString(self):
		self.assertEquals("!A",str(self.anUnaryFormula))

	def testSizeThreeUnaryFormula_getConnective(self):
		self.assertEquals(self.logic.NOT,self.aSizeThreeUnaryFormula.getConnective())

	def testSizeThreeUnaryFormula_toString(self):
		self.assertEquals("!!A",str(self.aSizeThreeUnaryFormula))

	def testSizeThreeBinaryFormula_getConnective(self):
		self.assertEquals(self.logic.AND,self.aBinaryFormula.getConnective())
		
	def testSizeThreeBinaryFormula_toString(self):
		self.assertEquals("(A&A)",str(self.aBinaryFormula))

	def testSizeSixBinaryFormula_getConnective(self):
		self.assertEquals(self.logic.IMPLIES,self.aSizeSixFormula.getConnective())
		
	def testSizeSixBinaryFormula_toString(self):
		self.assertEquals("(!A->(A&B))",str(self.aSizeSixFormula))
	def setUp(self):
		self.factory = ClassicalPropositionalLogicFormulaFactory()
		self.anAtomicFormula = self.factory.createAtom("A")
		self.anotherAtomicFormula = self.factory.createAtom("B")