示例#1
0
        public void CreateGraphOfTableaux_SmallTableauxTreeGiven_ExpectedAllTableauxElementsToBeNumberedAccordingToBFS()
        {
            // Arrange
            BinaryConnective root = new Conjunction();

            BinaryConnective disjunction = new Disjunction();

            root.LeftSuccessor         = disjunction;
            disjunction.LeftSuccessor  = new Proposition('P');
            disjunction.RightSuccessor = new Proposition('Q');

            root.RightSuccessor = new Proposition('X');

            SemanticTableaux semanticTableaux = new SemanticTableaux(root);

            string fileName = "test_case_tableaux";

            // Act
            Grapher.CreateGraphOfTableaux(semanticTableaux, fileName);

            // Assert
            semanticTableaux.Head.NodeNumber.Should().Be(1, "Because it's the first to be labeled");
            // Since beta rule
            semanticTableaux.Head.LeftChild.NodeNumber.Should().Be(2, "Because it's the second to be labeled");
            semanticTableaux.Head.RightChild.NodeNumber.Should().Be(3, "Because it's the third to be labeled");
            // Since alpha rule
            semanticTableaux.Head.LeftChild.LeftChild.NodeNumber.Should().Be(4, "Because it's the third to be labeled");

            File.Exists($"{fileName}.dot").Should().BeTrue("Because a dot file should be created (graphviz related though).");
            File.Exists($"{fileName}.png").Should().BeTrue("Because a png image should be created from the dot file (graphviz related though).");
        }
示例#2
0
        public void CreateGraphOfTableaux_NullGivenForSemanticTableaux_ExpectedArgumentNullException()
        {
            // Arrange
            SemanticTableaux semanticTableaux = null;
            Action           act = () => Grapher.CreateGraphOfTableaux(semanticTableaux, "");

            // Act // Assert
            act.Should().Throw <ArgumentNullException>("Because it can not operate without an object of semantic tableaux");
        }
示例#3
0
        public void Constructor_ParsedPropositionGiven_ShouldResultInNegatedPropositionAsRoot()
        {
            // Arrange
            Proposition      randomValidProposition = PropositionGenerator.GetRandomProposition();
            SemanticTableaux semanticTableaux       = new SemanticTableaux(randomValidProposition);

            // Act
            Proposition root = semanticTableaux.Proposition;

            // Assert
            root.Should().Be(randomValidProposition, "Because the original expression is being evaluated");
        }
示例#4
0
        public void IsClosed_TautologyGiven_ShouldResultInTrue(string tautologyExpression)
        {
            // Arrange
            parser = new Parser(tautologyExpression);

            Proposition      tautology        = parser.Parse();
            SemanticTableaux semanticTableaux = new SemanticTableaux(tautology);

            // Act
            bool closed = semanticTableaux.IsClosed();

            // Assert
            closed.Should().BeTrue("Because the given proposition is a tautology and therefore the tableaux should close all its branches.");
        }
示例#5
0
        public void IsClosed_NonClosablePredicateGiven_ShouldResultInFalse(string nonClosablePredicate)
        {
            // Arrange
            parser = new Parser(nonClosablePredicate);

            Proposition      predicate        = parser.Parse();
            SemanticTableaux semanticTableaux = new SemanticTableaux(predicate);

            // Act
            bool closed = semanticTableaux.IsClosed();

            // Assert
            closed.Should().BeFalse("Because the given predicate can not be closed.");
        }
示例#6
0
        public void IsClosed_ContingentPropositionGiven_ShouldResultInFalse(string contingencyExpression)
        {
            // Arrange
            parser = new Parser(contingencyExpression);

            Proposition      contingency      = parser.Parse();
            SemanticTableaux semanticTableaux = new SemanticTableaux(contingency);

            // Act
            bool closed = semanticTableaux.IsClosed();

            // Assert
            closed.Should().BeFalse("Because the given proposition is a contingency and therefore the tableaux could have some branches closed and some open.");
        }
示例#7
0
        private void btnDrawProofTree_Click(object sender, EventArgs e)
        {
            //declare and draw proof tree
            proofTree = new SemanticTableaux(myTree.GetRoot());
            proofTree.CreateProofTree();
            string content = proofTree.DrawTree();

            File.WriteAllText(@"tree.dot", content);
            Process dot = new Process();

            dot.StartInfo.FileName  = @".\External\dot.exe";
            dot.StartInfo.Arguments = "-Tpng -otree.png tree.dot";
            dot.Start();
            dot.WaitForExit();
            Process.Start(@"tree.png");
        }
示例#8
0
        public void IsClosed_ContradictionGiven_ShouldResultInFalse(string contradictionExpression)
        {
            // Arrange
            parser = new Parser(contradictionExpression);

            Proposition      contradiction    = parser.Parse();
            SemanticTableaux semanticTableaux = new SemanticTableaux(contradiction);

            // Act
            bool closed = semanticTableaux.IsClosed();

            // Assert
            // Even though that is not always the case, since contingencies can also open in all branches.
            // Contradictions could then still be tested by evaluating all truth values and check if the result column is 0s
            closed.Should().BeFalse("Because the given proposition is a contradiction and therefore the tableaux should not be closed, and ALL branches should be open.");
        }