public void CreateDisjunctiveNormalForm_NegatedProposition_ExpectedOriginalNegatedPropositionReturned() { // Arrange Proposition originalProposition = PropositionGenerator.CreateUnaryConnectiveWithRandomSymbol(Negation.SYMBOL); TruthTable tt = new TruthTable(originalProposition); TruthTable simplifiedTt = tt.Simplify(); // Act Proposition dnf = tt.CreateDisjunctiveNormalForm(); Proposition simplifiedDnf = simplifiedTt.CreateDisjunctiveNormalForm(); // Assert dnf.Should().BeEquivalentTo(originalProposition, "Because the disjunctive normal of a negated proposition literal is the negated literal itself"); simplifiedDnf.Should().BeEquivalentTo(originalProposition, "Because a negated literal can not be simplified any further and should result in the negated literal itself."); }
public void CreateDisjunctiveNormalForm_IndividualPropositionGiven_ExpectedIndividualPropositionReturned() { // Arrange Proposition originalProposition = PropositionGenerator.GetRandomProposition(); TruthTable tt = new TruthTable(originalProposition); TruthTable simplifiedTt = tt.Simplify(); // Act Proposition dnf = tt.CreateDisjunctiveNormalForm(); Proposition simplifiedDnf = simplifiedTt.CreateDisjunctiveNormalForm(); // Assert dnf.Should().BeEquivalentTo(originalProposition, "Because the disjunctive normal of a proposition literal is the literal itself"); simplifiedDnf.Should().BeEquivalentTo(originalProposition, "Because a literal can not be simplified any further and should result in the literal itself."); }
public void CreateDisjunctiveNormalForm_ExpressionGiven_ExpectedPropositionLiteralsAtTheLeavesAndNoDisjunctionDeeperThanConjunction(char expressionSymbol) { // For the binary connectives, we should check all (both) possible branches if they contain // no disjunction below a conjunction // Arrange BinaryConnective root = PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(expressionSymbol); TruthTable tt = new TruthTable(root); TruthTable simplifiedTt = tt.Simplify(); // Act Proposition dnf = tt.CreateDisjunctiveNormalForm(); Proposition simplifiedDnf = simplifiedTt.CreateDisjunctiveNormalForm(); // Assert Assert.True(IsInDnf(dnf), "Because this expression should be in DNF"); Assert.True(IsInDnf(simplifiedDnf), "Because the simplified expression should also be in DNF"); }