Пример #1
0
        public TableauxHolder(string Proposition)
        {
            Connective proposition = PropositionReader.ReadPropositionString(Proposition);

            infixString = proposition.GetInfix();

            ConnectiveNot notPorposition = new ConnectiveNot();

            notPorposition.setLeftConnective(proposition);

            TableauxSetElement tse = new TableauxSetElement(notPorposition);

            this.startTableaux = new TableauxSet(new List <TableauxSetElement>()
            {
                tse
            });
            isNormalProposition = notPorposition.IsNormalProposition();
            if (!notPorposition.AreLocalArgumentsMatching(new List <char>(), new List <char>()))
            {
                throw new Exception("Local Arguments are mismatching or there are quantifiers with the same Local Argument");
            }
            calculateFreeArguments(notPorposition);
            Console.WriteLine("Succesfully parsed proposition: " + Proposition);
            Console.WriteLine("Creating tableaux nodes...   (In-Progress Feedback: " + TableauxSet.provideFeedback + ")");
            this.startTableaux.CreateNextSets(new List <char>(), availableArguments, true); //Can be (!isNormalProposition) OR (true)
            this.startTableaux.CalculateIsTautology();
            Console.WriteLine("Succesfully created all teableaux nodes");
        }
Пример #2
0
        public static string CreateStructurePicture(TableauxSet startSet)
        {
            if (startSet == null)
            {
                throw new NullReferenceException();
            }
            //Console.WriteLine("PropositionReader: creating structure picture");
            List <TableauxSet> allSets = startSet.GetAllSets();

            FileStream   fs;
            StreamWriter sw;
            string       fileName = "abc.dot";

            try
            {
                fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
                sw = new StreamWriter(fs);
                sw.WriteLine("graph calculus {");
                sw.WriteLine("node [ fontname = \"Arial\" ]");

                for (int i = 0; i < allSets.Count; i++)
                {
                    if (allSets[i].IsTautology)
                    {
                        sw.WriteLine("node" + (allSets[i].ID) + " [shape=box,color=red,label = \"" + allSets[i].GetElementsAsString() + "\"];");
                    }
                    else
                    {
                        sw.WriteLine("node" + (allSets[i].ID) + " [shape=box,label = \"" + allSets[i].GetElementsAsString() + "\"];");
                    }

                    foreach (TableauxSet ts in allSets[i].Sets)
                    {
                        sw.WriteLine("node" + (allSets[i].ID) + " -- node" + ts.ID);
                    }
                }
                sw.WriteLine("}");
                sw.Close();
            }
            catch (IOException)
            {
                throw new Exception("Structure picture failed");
            }
            return(CreateDotPNG(fileName));
        }
Пример #3
0
        private bool addNewSet(List <Connective> Connectives, TableauxSetElement SourceElement)
        {
            //copy elements except SourceElement
            List <TableauxSetElement> tempElements = new List <TableauxSetElement>();

            foreach (TableauxSetElement tse in elements)
            {
                if (tse != SourceElement)
                {
                    tempElements.Add(tse);
                }
            }

            //add new Elements created from SourceElement if such an element does not exist yet
            bool addedAtLeastOne = false;

            foreach (Connective con in Connectives)
            {
                bool sameFound = false;
                foreach (TableauxSetElement tse in tempElements)
                {
                    if (tse.Element.IsTheSameAs(con))
                    {
                        sameFound = true;
                        break;
                    }
                }
                if (!sameFound)
                {
                    TableauxSetElement newElement = new TableauxSetElement(con);
                    tempElements.Add(newElement);
                    addedAtLeastOne = true;
                }
            }

            //add set
            if (addedAtLeastOne || SourceElement != null) //added one or removed one
            {
                TableauxSet newSet = new TableauxSet(tempElements);
                sets.Add(newSet);
            }
            return(addedAtLeastOne || SourceElement != null);
        }