Example #1
0
        public void IsReplaced_ReplacingExistingBoundVariableInUnaryConnectiveComposedOfAPredicate_ChildShouldReturnTrue(char connectiveSymbol)
        {
            // Arrange
            char existingVariable = 'w';

            List <char> variables = new List <char>()
            {
                existingVariable
            };

            Predicate predicate = new Predicate(PREDICATE_SYMBOL, variables);

            UnaryConnective unaryConnective = PropositionGenerator.CreateUnaryConnectiveWithRandomSymbol(connectiveSymbol);

            unaryConnective.LeftSuccessor = predicate;

            char replacementVariable = 'c';

            // Act
            unaryConnective.Replace(existingVariable, replacementVariable);

            bool leftIsReplaced = predicate.IsReplaced(existingVariable);

            // Assert
            leftIsReplaced.Should().BeTrue($"Since the bound variable {existingVariable} should be repalced replaced by {replacementVariable}");
        }
Example #2
0
        public void GetBoundVariables_UnaryConnectiveWithPropositionAsSuccessor_ExpectedNotImplementedExceptionThrown()
        {
            // Arrange
            UnaryConnective negation = PropositionGenerator.CreateUnaryConnectiveWithRandomSymbol(Negation.SYMBOL);
            Action          act      = () => negation.GetBoundVariables();

            // Act // Assert
            act.Should().Throw <NotImplementedException>("Because an abstract proposition does not have bound variables related to it.");
        }
Example #3
0
        private void AddChildrenToStack(ref Stack <Proposition> propositionStack, Proposition proposition)
        {
            if (proposition is UnaryConnective)
            {
                UnaryConnective unaryConnective = (UnaryConnective)proposition;
                propositionStack.Push(unaryConnective.LeftSuccessor);
            }

            if (proposition is BinaryConnective)
            {
                BinaryConnective binaryConnective = (BinaryConnective)proposition;
                propositionStack.Push(binaryConnective.RightSuccessor);
            }
        }
Example #4
0
        public void GetBoundVariables_UnaryConnectiveWithPredicateAsSuccessor_NonEmptyListOfVariablesReturned()
        {
            // Arrange
            UnaryConnective negation = PropositionGenerator.CreateUnaryConnectiveWithRandomSymbol(Negation.SYMBOL);

            negation.LeftSuccessor = new Predicate('T', new List <char>()
            {
                'r', 't'
            });

            // Act
            List <char> boundVariables = negation.GetBoundVariables();
            int         expectedNumberOfBoundVariables = 2;
            int         actualNumberOfBoundVariables   = boundVariables.Count;

            // Assert
            actualNumberOfBoundVariables.Should().Be(expectedNumberOfBoundVariables, $"Because a predicate is assigned as successor with {expectedNumberOfBoundVariables} variables assigned");
        }
Example #5
0
        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);
            }
        }