Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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");
                }
            }
        }
Ejemplo n.º 3
0
        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");
                }
            }
        }