Beispiel #1
0
        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.");
        }
Beispiel #2
0
        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");
        }
Beispiel #3
0
        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.");
        }
Beispiel #4
0
        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.");
        }
Beispiel #5
0
        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.");
        }
Beispiel #6
0
        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.");
        }
Beispiel #7
0
        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.");
        }
Beispiel #8
0
        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.");
        }
Beispiel #9
0
        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.");
        }
Beispiel #10
0
        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");
        }
Beispiel #11
0
        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");
        }