// By dumb luck this could fail if it generated two identical successors for the disjunction! public void Constructor_CreateAlphaRuleFromNegationOfDisjunctionOfLiterals_SetOfLengthTwoReturnedWithTwoNegatedLiterals() { // Arrange Disjunction disjunction = (Disjunction)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Disjunction.SYMBOL); Negation negatedDisjunction = new Negation(); negatedDisjunction.LeftSuccessor = disjunction; HashSet <Proposition> propositions = new HashSet <Proposition>() { negatedDisjunction }; SemanticTableauxElement alphaRuleElement = new SemanticTableauxElement(propositions); SemanticTableauxElement child = alphaRuleElement.LeftChild; // Act HashSet <Proposition> childPropositions = child.Propositions; int actualNumberOfLiterals = childPropositions.Count; int expectedNumberOfLiterals = 2; // Assert actualNumberOfLiterals.Should().Be(expectedNumberOfLiterals, "Because a disjunction of two literals was given"); foreach (Proposition p in childPropositions) { p.Should().BeOfType <Negation>("Because for this alpha rule, the negation of both literals is returned"); } }
public void Constructor_CreateUniversalQuantifierNoReplacementVariablesPresent_GammaRuleShouldNotBeAppliedNoChildrenGenerated() { // Arrange char boundVariable = PropositionGenerator.GenerateBoundVariable(); List <char> boundVariables = new List <char>() { boundVariable }; Predicate predicate = new Predicate(PropositionGenerator.GetRandomVariableLetter(), boundVariables); UniversalQuantifier universalQuantifier = new UniversalQuantifier(boundVariable); universalQuantifier.LeftSuccessor = predicate; HashSet <Proposition> propositions = new HashSet <Proposition>() { universalQuantifier }; // Act SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); bool isReplaced = predicate.IsReplaced(boundVariable); // Assert isReplaced.Should().BeFalse("Because no replacement variables are available"); semanticTableauxElement.LeftChild.Should().BeNull("Because no replacement variables are available and thus no child was created"); }
public void Constructor_CreateDoubleNegationOfLiteral_LeftChildCreatedWithNegationRemoved() { // Arrange Negation negation = (Negation)PropositionGenerator.CreateUnaryConnectiveWithRandomSymbol(Negation.SYMBOL); Negation doubleNegation = new Negation(); doubleNegation.LeftSuccessor = negation; HashSet <Proposition> propositions = new HashSet <Proposition>() { doubleNegation }; // Act SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); HashSet <Proposition> propositionSetOfChild = semanticTableauxElement.LeftChild.Propositions; int actualNumberOfPropositionsInSet = propositionSetOfChild.Count; int expectedNumberOfPropositionsInSet = 1; Proposition expectedPropositionInSet = negation.LeftSuccessor; // Assert actualNumberOfPropositionsInSet.Should().Be(expectedNumberOfPropositionsInSet, "Because after removing the negation of one proposition we are left with one proposition"); foreach (Proposition p in propositionSetOfChild) { p.Should().Be(expectedPropositionInSet, "Because the inner most child will be left over after removing it's encapsulating negations"); } }
public void NodeLabel_CreateNodeLabelWithBothChildrenAndNotClosed_ExpectedLabelWithChildrenIncluded() { // Arrange Disjunction disjunction = new Disjunction(); disjunction.LeftSuccessor = new Proposition('B'); disjunction.RightSuccessor = new Proposition('R'); HashSet <Proposition> propositions = new HashSet <Proposition>() { disjunction }; SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); semanticTableauxElement.NodeNumber = 1; semanticTableauxElement.LeftChild.NodeNumber = 2; semanticTableauxElement.RightChild.NodeNumber = 3; // Act string actualNodeLabel = semanticTableauxElement.NodeLabel(); string expectedNodeLabel = $"node{semanticTableauxElement.NodeNumber}[ label = \"(B | R)\" ]\n"; expectedNodeLabel += $"node1 -- node2\n"; expectedNodeLabel += $"node{semanticTableauxElement.NodeNumber + 1}[ label = \"B\" ]\n"; expectedNodeLabel += $"node1 -- node3\n"; expectedNodeLabel += $"node{semanticTableauxElement.NodeNumber + 2}[ label = \"R\" ]\n"; // Assert actualNodeLabel.Should().Be(expectedNodeLabel, "Because that's the format required for graphviz plus our own choice of display"); }
public void Constructor_CreateDoubleNegationOfLiteralWithAlphaRuleInSet_DoubleNegationShouldHavePrecedence() { // Arrange Negation negation = (Negation)PropositionGenerator.CreateUnaryConnectiveWithRandomSymbol(Negation.SYMBOL); Negation doubleNegation = new Negation(); doubleNegation.LeftSuccessor = negation; Conjunction conjunction = (Conjunction)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Conjunction.SYMBOL); HashSet <Proposition> propositions = new HashSet <Proposition>() { conjunction, doubleNegation }; // Act SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); HashSet <Proposition> propositionSetOfChild = semanticTableauxElement.LeftChild.Propositions; int actualNumberOfPropositionsInSet = propositionSetOfChild.Count; int expectedNumberOfPropositionsInSet = 2; // Assert semanticTableauxElement.RightChild.Should().BeNull("Because the double negation is applied first, and thus only the left child is assigned"); actualNumberOfPropositionsInSet.Should().Be(expectedNumberOfPropositionsInSet, "Because double negation would be removed first, and thus the number of propositions in the set of the first child should be " + expectedNumberOfPropositionsInSet); }
public void Constructor_CreateAlphaRuleFromNegatedNandOfLiterals_SetOfLengthTwoReturnedWithTwoLiterals() { // Arrange Nand nand = (Nand)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Nand.SYMBOL); Negation negatedNand = new Negation(); negatedNand.LeftSuccessor = nand; HashSet <Proposition> propositions = new HashSet <Proposition>() { negatedNand }; SemanticTableauxElement alphaRuleElement = new SemanticTableauxElement(propositions); SemanticTableauxElement child = alphaRuleElement.LeftChild; // Act HashSet <Proposition> childPropositions = child.Propositions; int actualNumberOfLiterals = childPropositions.Count; int expectedNumberOfLiterals = 2; // Assert actualNumberOfLiterals.Should().Be(expectedNumberOfLiterals, "Because a conjunction of two literals was given"); }
public void IsClosed_ContradictionByConjunction_AfterCreatingChildElementContainsContradictionClosedShouldReturnTrue() { // Arrange Conjunction contradiction = new Conjunction(); Proposition child = new Proposition('Z'); contradiction.LeftSuccessor = child; Negation negatedChild = new Negation(); negatedChild.LeftSuccessor = child; contradiction.RightSuccessor = negatedChild; Proposition p = new Proposition('G'); HashSet <Proposition> propositionSet = new HashSet <Proposition>() { contradiction, p }; // Act SemanticTableauxElement alphaRuleElement = new SemanticTableauxElement(propositionSet); bool alphaRuleClosedByChild = alphaRuleElement.IsClosed(); // Assert alphaRuleClosedByChild.Should().BeTrue("Because the child alpha rule element should close the branch by contradiction."); }
public void Constructor_CreateNegatedBiImplicationOfLiterals_BetaRuleShouldBeAppliedBothChildrenShouldHaveSetsOfTwoElementsOneLiteralAndOneNegatedLiteralInEachSet() { // Arrange Negation negatedBiImplication = new Negation(); BiImplication biImplication = (BiImplication)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(BiImplication.SYMBOL); negatedBiImplication.LeftSuccessor = biImplication; HashSet <Proposition> propositions = new HashSet <Proposition>() { negatedBiImplication }; // Act SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); HashSet <Proposition> propositionSetOfLeftChild = semanticTableauxElement.LeftChild.Propositions; HashSet <Proposition> propositionSetOfRightChild = semanticTableauxElement.RightChild.Propositions; int actualNumberOfPropositionsInLeftSet = propositionSetOfLeftChild.Count; int actualNumberOfPropositionsInRightSet = propositionSetOfRightChild.Count; int expectedNumberOfPropositionsInSet = 2; // Assert string message = "Because both the left and right set should have two children in their set after applying beta rule for negated bi-implication."; actualNumberOfPropositionsInLeftSet.Should().Be(expectedNumberOfPropositionsInSet, message); actualNumberOfPropositionsInRightSet.Should().Be(expectedNumberOfPropositionsInSet, message); TestSetToHaveOneLiteralAndOneNegatedLiteral(propositionSetOfLeftChild); TestSetToHaveOneLiteralAndOneNegatedLiteral(propositionSetOfRightChild); }
public void NodeLabel_CreateNodeLabelWithReplacementVariablePResent_ExpectedLabelToIncludeReplacementVariables() { // Arrange Predicate predicate = new Predicate('P', new List <char>() { 'x', 'y' }); HashSet <Proposition> propositions = new HashSet <Proposition>() { predicate }; SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); semanticTableauxElement.ReplacementVariables = new HashSet <char>() { 'a', 'b' }; semanticTableauxElement.NodeNumber = 1; // Act string actualNodeLabel = semanticTableauxElement.NodeLabel(); string expectedNodeLabel = $"node1[ label = \"< a, b >\nP(x, y)\" ]\n"; // Assert actualNodeLabel.Should().Be(expectedNodeLabel, "Because that's the format required for graphviz plus our own choice of display"); }
public void IsClosed_CreateBetaRuleFromDisjunctionWithAdditionalLiteralsContradictingBothBranches_ExpectedParentClosed() { // Arrange Disjunction disjunction = (Disjunction)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Disjunction.SYMBOL); Negation negatedLeftLiteral = new Negation(); negatedLeftLiteral.LeftSuccessor = disjunction.LeftSuccessor; Negation negatedRightLiteral = new Negation(); negatedRightLiteral.LeftSuccessor = disjunction.RightSuccessor; HashSet <Proposition> propositions = new HashSet <Proposition>() { negatedLeftLiteral, disjunction, negatedRightLiteral }; // Act SemanticTableauxElement betaRuleElement = new SemanticTableauxElement(propositions); bool parentClosed = betaRuleElement.IsClosed(); // Assert parentClosed.Should().BeTrue("Because the beta rule contains two contradictions, each of which should close one of the branches"); }
public void IsClosed_TestIsClosedWhenContradictionInSet_ExpectedTrueReturned(bool leftNegated) { // Arrange Disjunction fillerProposition = new Disjunction(); Proposition child = new Proposition('Z'); fillerProposition.LeftSuccessor = child; fillerProposition.RightSuccessor = child; Proposition p = new Proposition('G'); Negation pNegated = new Negation(); pNegated.LeftSuccessor = p; HashSet <Proposition> propositionSet = null; if (leftNegated) { propositionSet = new HashSet <Proposition>() { pNegated, fillerProposition, fillerProposition, p, fillerProposition }; } else { propositionSet = new HashSet <Proposition>() { p, fillerProposition, fillerProposition, pNegated, fillerProposition }; } SemanticTableauxElement alphaRuleElement = new SemanticTableauxElement(propositionSet); // Act bool isBranchClosed = alphaRuleElement.IsClosed(); // Assert isBranchClosed.Should().BeTrue("Because the tableaux element has a contradiction in its set."); }
public void IsClosed_TestIsClosedWhenChildNullAndNoContradictionInSet_ExpectedFalseReturned() { // Arrange HashSet <Proposition> propositionSet = new HashSet <Proposition>() { PropositionGenerator.GetRandomProposition(), PropositionGenerator.GetRandomProposition() }; SemanticTableauxElement alphaRuleElement = new SemanticTableauxElement(propositionSet); // Act bool isBranchClosed = alphaRuleElement.IsClosed(); // Assert isBranchClosed.Should().BeFalse("Because the tableaux element has no contradiction and no children, thus was not closed."); }
public void IsClosed_ConstantTrue_ExpectedFalseReturned() { // Arrange Proposition proposition = new True(); HashSet <Proposition> propositionSet = new HashSet <Proposition>() { proposition }; SemanticTableauxElement element = new SemanticTableauxElement(propositionSet); // Act bool isBranchClosed = element.IsClosed(); // Assert isBranchClosed.Should().BeFalse("Because the tableaux element has true in its set, which does not contradict."); }
public void IsClosed_ContradictionByConstantFalse_ExpectedTrueReturned() { // Arrange Proposition proposition = new False(); HashSet <Proposition> propositionSet = new HashSet <Proposition>() { proposition }; SemanticTableauxElement element = new SemanticTableauxElement(propositionSet); // Act bool isBranchClosed = element.IsClosed(); // Assert isBranchClosed.Should().BeTrue("Because the tableaux element has false in its set which is a contradiction."); }
public void Constructor_CreateNegatedExistentialQuantifierWithReplacementVariablePresent_GammaRuleShouldBeAppliedAndNewChildrenCreated() { // Arrange char boundVariable = PropositionGenerator.GenerateBoundVariable(); List <char> boundVariables = new List <char>() { boundVariable }; Predicate predicate = new Predicate(PropositionGenerator.GetRandomVariableLetter(), boundVariables); ExistentialQuantifier existentialQuantifier = new ExistentialQuantifier(boundVariable); existentialQuantifier.LeftSuccessor = predicate; Negation negatedExistentialQuantifier = new Negation(); negatedExistentialQuantifier.LeftSuccessor = existentialQuantifier; HashSet <Proposition> propositions = new HashSet <Proposition>() { negatedExistentialQuantifier }; // Act char availableReplacementVariable = 'd'; SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions, new HashSet <char>() { availableReplacementVariable }); // Assert semanticTableauxElement.LeftChild.Should().NotBeNull("Because children should be created now that a replacement variable is present"); foreach (Proposition proposition in semanticTableauxElement.LeftChild.Propositions) { if (proposition is Predicate) { Predicate pred = (Predicate)proposition; bool isReplaced = pred.IsReplaced(boundVariable); isReplaced.Should().BeTrue($"Because the replacement variable {availableReplacementVariable} is available"); } } }
public void Constructor_CreateNegatedUniversalQuantifier_DeltaRuleShouldBeAppliedChildShouldBePredicateAndVariableShouldBeIntroduced() { // Arrange char boundVariable = PropositionGenerator.GenerateBoundVariable(); List <char> boundVariables = new List <char>() { boundVariable }; Predicate predicate = new Predicate(PropositionGenerator.GetRandomVariableLetter(), boundVariables); UniversalQuantifier universalQuantifier = new UniversalQuantifier(boundVariable); universalQuantifier.LeftSuccessor = predicate; Negation negatedUniversalQuantifier = new Negation(); negatedUniversalQuantifier.LeftSuccessor = universalQuantifier; HashSet <Proposition> propositions = new HashSet <Proposition>() { negatedUniversalQuantifier }; // Act SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); List <char> replacementVariables = semanticTableauxElement.LeftChild.ReplacementVariables.ToList(); int expectedNumberOfReplacementVariables = 1; int actualNumberOfReplacementVariables = replacementVariables.Count; // Assert actualNumberOfReplacementVariables.Should().Be(expectedNumberOfReplacementVariables, "Because the only bound variable should be replaced based on the rules"); foreach (Proposition proposition in semanticTableauxElement.LeftChild.Propositions) { if (proposition is Predicate) { predicate = (Predicate)proposition; bool isReplaced = predicate.IsReplaced(boundVariable); isReplaced.Should().BeTrue("Because after applying a delta rule, the only bound variable in the predicate should be replaced"); } } }
public void Constructor_BetaRuleGiven_ExpectedLeftAndRightChildToNotBeNullAndASemanticTableauxElement() { // Arrange Disjunction disjunction = (Disjunction)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Disjunction.SYMBOL); HashSet <Proposition> propositions = new HashSet <Proposition>() { disjunction }; // Act SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); // Assert string message = "Because on a beta rule both children are created"; semanticTableauxElement.LeftChild.Should().BeOfType <SemanticTableauxElement>(message); semanticTableauxElement.RightChild.Should().BeOfType <SemanticTableauxElement>(message); }
public void Constructor_AlphaRuleGiven_ExpectedLeftChildToNotBeNullAndASemanticTableauxElement() { // Arrange Conjunction conjunction = (Conjunction)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Conjunction.SYMBOL); HashSet <Proposition> propositions = new HashSet <Proposition>() { conjunction }; // Act SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); // Assert string message = "Because on an alpha rule only one child is created"; semanticTableauxElement.LeftChild.Should().BeOfType <SemanticTableauxElement>(message); semanticTableauxElement.RightChild.Should().BeNull(message); }
public void NodeLabel_CreateNodeLabelWithoutChildrenAndNotClosed_ExpectedLabelWithOnlyPropositions() { // Arrange HashSet <Proposition> propositions = new HashSet <Proposition>() { new Proposition('P') }; SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); semanticTableauxElement.NodeNumber = 1; // Act string actualNodeLabel = semanticTableauxElement.NodeLabel(); string expectedNodeLabel = $"node{semanticTableauxElement.NodeNumber}[ label = \"P\" ]\n"; // Assert actualNodeLabel.Should().Be(expectedNodeLabel, "Because that's the format required for graphviz plus our own choice of display"); }
public void IsClosed_ContradictionByNegatedTrue_ExpectedTrueReturned() { // Arrange Negation negatedTrue = new Negation(); Proposition proposition = new True(); negatedTrue.LeftSuccessor = proposition; HashSet <Proposition> propositionSet = new HashSet <Proposition>() { negatedTrue }; SemanticTableauxElement element = new SemanticTableauxElement(propositionSet); // Act bool isBranchClosed = element.IsClosed(); // Assert isBranchClosed.Should().BeTrue("Because the tableaux element has a negated true in its set, which DOES contradict as it is equivalent to False."); }
public void IsClosed_NegatedFalse_ExpectedFalseReturned() { // Arrange Negation negatedFalse = new Negation(); Proposition proposition = new False(); negatedFalse.LeftSuccessor = proposition; HashSet <Proposition> propositionSet = new HashSet <Proposition>() { negatedFalse }; SemanticTableauxElement element = new SemanticTableauxElement(propositionSet); // Act bool isBranchClosed = element.IsClosed(); // Assert isBranchClosed.Should().BeFalse("Because the tableaux element has a negated false (aka true) in its set."); }
public void IsClosed_NoContradictionInSetWithConjunctionAsAlphaRuleChild_AfterCreatingChildContainsIsClosedShouldReturnFalse() { // Arrange Conjunction conjunction = new Conjunction(); Proposition child = new Proposition('Z'); conjunction.LeftSuccessor = child; conjunction.RightSuccessor = child; HashSet <Proposition> propositionSet = new HashSet <Proposition>() { conjunction }; // Act SemanticTableauxElement alphaRuleElement = new SemanticTableauxElement(propositionSet); bool alphaRuleClosedByChild = alphaRuleElement.IsClosed(); // Assert alphaRuleClosedByChild.Should().BeFalse("Because the child alpha rule element does not contain a contradiction."); }
public void Constructor_CreateAlphaRuleFromConjunctionOfLiteralsWhenBetaRuleInPropositionSetAsWell_ChildrenShouldBeCreatedBasedOnAlphaRule() { // Arrange Conjunction conjunction = (Conjunction)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Conjunction.SYMBOL); Disjunction disjunction = (Disjunction)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Disjunction.SYMBOL); HashSet <Proposition> propositions = new HashSet <Proposition>() { disjunction, conjunction }; // Act SemanticTableauxElement betaRuleElement = new SemanticTableauxElement(propositions); SemanticTableauxElement leftChild = betaRuleElement.LeftChild; SemanticTableauxElement rightChild = betaRuleElement.RightChild; // Assert leftChild.Should().BeOfType <SemanticTableauxElement>("Because the alpha rule should be applied"); rightChild.Should().BeNull("Because when applying the alpha rule the right child would not be assigned"); }
public void Constructor_CreateBetaRuleFromImplicationOfLiterals_SetOfLengthOneForEachChildWithOneNegatedLiteral() { // Arrange Implication implication = (Implication)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Implication.SYMBOL); HashSet <Proposition> propositions = new HashSet <Proposition>() { implication }; SemanticTableauxElement betaRuleElement = new SemanticTableauxElement(propositions); SemanticTableauxElement leftChild = betaRuleElement.LeftChild; SemanticTableauxElement rightChild = betaRuleElement.RightChild; // Act HashSet <Proposition> leftChildPropositions = leftChild.Propositions; HashSet <Proposition> rightChildPropositions = rightChild.Propositions; int actualNumberOfLiteralsInLeftChild = leftChildPropositions.Count; int actualNumberOfLiteralsInRightChild = rightChildPropositions.Count; int expectedNumberOfLiterals = 1; // Assert string message = "Because both proposition literals have been separated into two different sets"; actualNumberOfLiteralsInLeftChild.Should().Be(expectedNumberOfLiterals, message); actualNumberOfLiteralsInRightChild.Should().Be(expectedNumberOfLiterals, message); message = "Because based on the rule, the left child should be negated only."; foreach (Proposition proposition in leftChildPropositions) { proposition.Should().BeOfType <Negation>(message); } foreach (Proposition proposition in rightChildPropositions) { proposition.Should().Be(implication.RightSuccessor, message); } }
public void NodeLabel_CreateNodeLabelWithConstantContradictionToClose_ExpectedLabelWithColorRed() { // Arrange False contradiction = new False(); HashSet <Proposition> propositions = new HashSet <Proposition>() { contradiction }; SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); semanticTableauxElement.NodeNumber = 1; // Act string actualNodeLabel = semanticTableauxElement.NodeLabel(); string expectedNodeLabel = $"node{semanticTableauxElement.NodeNumber}[ label = \"0\", color = red ]\n"; // Assert actualNodeLabel.Should().Be(expectedNodeLabel, "Because that's the format required for graphviz plus our own choice of display"); }
public void IsClosed_CreateNegatedBiImplicationOfLiteralsWithLiteralsInParentSetToCloseBranches_ParentElementShouldBeClosed() { // Arrange BiImplication biImplication = (BiImplication)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(BiImplication.SYMBOL); Proposition literal = biImplication.LeftSuccessor; Negation negatedLiteral = new Negation(); negatedLiteral.LeftSuccessor = biImplication.LeftSuccessor; HashSet <Proposition> propositions = new HashSet <Proposition>() { literal, biImplication, negatedLiteral }; // Act SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); // Assert semanticTableauxElement.IsClosed().Should().BeTrue("Because it should be possible to close branches when there is at least any of the literals in the parent set as well as any negated literal"); }
public void Constructor_CreateAlphaRuleFromNegationOfImplicationOfLiterals_SetOfLengthTwoReturnedWithRightSuccessorNegated() { // Arrange Implication implication = (Implication)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Implication.SYMBOL); Negation negatedImplication = new Negation(); negatedImplication.LeftSuccessor = implication; HashSet <Proposition> propositions = new HashSet <Proposition>() { negatedImplication }; SemanticTableauxElement alphaRuleElement = new SemanticTableauxElement(propositions); SemanticTableauxElement child = alphaRuleElement.LeftChild; // Act HashSet <Proposition> childPropositions = child.Propositions; int actualNumberOfLiterals = childPropositions.Count; int expectedNumberOfLiterals = 2; // Assert actualNumberOfLiterals.Should().Be(expectedNumberOfLiterals, "Because an implication of two literals was given"); foreach (Proposition proposition in childPropositions) { if (proposition.GetType() == typeof(Negation)) { Negation negatedLiteral = (Negation)proposition; negatedLiteral.LeftSuccessor.CompareTo(implication.RightSuccessor).Should().Be(0, "Because it is right negated successor of the implication."); } else { proposition.CompareTo(implication.LeftSuccessor).Should().Be(0, "Because it is the left not negated successor of the implication."); } } }
private void TestConstructorForNotAndEquivalent(UnaryConnective connective) { // Arrange HashSet <Proposition> propositions = new HashSet <Proposition>() { connective }; SemanticTableauxElement betaRuleElement = new SemanticTableauxElement(propositions); SemanticTableauxElement leftChild = betaRuleElement.LeftChild; SemanticTableauxElement rightChild = betaRuleElement.RightChild; // Act HashSet <Proposition> leftChildPropositions = leftChild.Propositions; HashSet <Proposition> rightChildPropositions = rightChild.Propositions; int actualNumberOfLiteralsInLeftChild = leftChildPropositions.Count; int actualNumberOfLiteralsInRightChild = rightChildPropositions.Count; int expectedNumberOfLiterals = 1; // Assert string message = "Because both proposition literals have been separated into two different sets"; actualNumberOfLiteralsInLeftChild.Should().Be(expectedNumberOfLiterals, message); actualNumberOfLiteralsInRightChild.Should().Be(expectedNumberOfLiterals, message); message = "Because based on the rule, both children should be negated."; foreach (Proposition proposition in leftChildPropositions) { proposition.Should().BeOfType <Negation>(message); } foreach (Proposition proposition in rightChildPropositions) { proposition.Should().BeOfType <Negation>(message); } }
public void IsClosed_CreateBetaRuleFromDisjunctionWithAdditionalLiteralContradictingRightBranch_ExpectedRightBranchClosedButNotTheParent() { // Arrange Disjunction disjunction = (Disjunction)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Disjunction.SYMBOL); Negation negatedRightLiteral = new Negation(); negatedRightLiteral.LeftSuccessor = disjunction.RightSuccessor; HashSet <Proposition> propositions = new HashSet <Proposition>() { disjunction, negatedRightLiteral }; // Act SemanticTableauxElement betaRuleElement = new SemanticTableauxElement(propositions); bool parentClosed = betaRuleElement.IsClosed(); bool rightClosed = betaRuleElement.RightChild.IsClosed(); // Assert parentClosed.Should().BeFalse("Because only the right branch is closed off by a contradiction."); rightClosed.Should().BeTrue("Because the beta rule contains a contradiction for the right branch"); }