private void btnCreateRandomProposition_Click(object sender, EventArgs e) { string proposition = PropositionReader.CreateRandomPropositionString(); tbProposition.Text = proposition; createAllConHoldersAndTruthtables(proposition); }
private bool createAllConHoldersAndTruthtables(string proposition) { try { //CREATING PROPOSITION Connective con = PropositionReader.ReadPropositionString(proposition); if (con.IsNormalProposition()) { conHolder = new ConnectiveHolder(con); table = new Truthtable(conHolder); printDisjunctive(); conHolderDisjunctive = new ConnectiveHolder(tbDisjunctiveParse.Text); tableDisjunctive = new Truthtable(conHolderDisjunctive); conHolderDisjunctiveSimple = new ConnectiveHolder(tbDisjunctiveSimpleParse.Text); tableDisjunctiveSimple = new Truthtable(conHolderDisjunctiveSimple); conHolderNand = conHolder.GetNandHolder(); tableNand = new Truthtable(conHolderNand); conHolderNandSimple = conHolderDisjunctiveSimple.GetNandHolder(); tableNandSimple = new Truthtable(conHolderNandSimple); tbInfix.Text = conHolder.GetInfixString(); tbNand.Text = conHolderNand.GetParseString(); tbNandSimple.Text = conHolderNandSimple.GetParseString(); showTableauxTree = false; //DRAWING AND PRINTING TABLE INFORMATION printVisualTruthtables(table); printTablesInformation(); } else { if (!con.AreLocalArgumentsMatching(new List <char>(), new List <char>())) { throw new Exception("Local Arguments are mismatching or there are quantifiers with the same Local Argument"); } conHolder = new ConnectiveHolder(con); tbInfix.Text = conHolder.GetInfixString(); showTableauxTree = false; } Console.WriteLine("Succesfully parsed proposition: " + proposition); } catch (NullReferenceException) { MessageBox.Show("Parsing failed: please make sure that you wrote a proposition"); Console.WriteLine("Failed to parse proposition: " + proposition); return(false); } catch (Exception ex) { MessageBox.Show("Parsing failed: " + ex.Message); Console.WriteLine("Failed to parse proposition: " + proposition); return(false); } return(true); }
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"); }
private void printDisjunctive() { //GETTING DISJUNCTIVE AND IT'S PARSE string[] disjunctAndParse = PropositionReader.readDisjunctiveForm(table.Rows); tbDisjunctive.Text = disjunctAndParse[0]; tbDisjunctiveParse.Text = disjunctAndParse[1]; disjunctAndParse = PropositionReader.readDisjunctiveForm(table.GetSimpleTable()); tbDisjunctiveSimple.Text = disjunctAndParse[0]; tbDisjunctiveSimpleParse.Text = disjunctAndParse[1]; }
public ConnectiveHolder(string proposition) { if (proposition != null) { Connective con = PropositionReader.ReadPropositionString(proposition); if (con != null) { startConnective = con; } else { throw new NullReferenceException(); } } else { throw new NullReferenceException(); } }
private void timer1_Tick(object sender, EventArgs e) { string hashCode; string proposition; //GENEARTE ALL TABLES AND CONHOLDERS AND TABLEAUX proposition = PropositionReader.CreateRandomPropositionString(); tbProposition.Text = proposition; if (createAllConHoldersAndTruthtables(proposition)) { printVisualTruthtables(table); printTablesInformation(); } CreateTableaux(); //GET HASH CODE OF MAIN TABLE hashCode = table.GetHashCodeHexadecimal(); //COMPARE HASH CODE WITH OTHER TABLES if (hashCode != tableDisjunctive.GetHashCodeHexadecimal()) { testFailed("Disjunctive hashcode does not match", proposition); return; } if (hashCode != tableDisjunctiveSimple.GetHashCodeHexadecimal()) { testFailed("DisjunctiveSimple hashcode does not match", proposition); return; } if (hashCode != tableNand.GetHashCodeHexadecimal()) { testFailed("Nand hashcode does not match", proposition); return; } if (hashCode != tableNandSimple.GetHashCodeHexadecimal()) { testFailed("NandSimple hashcode does not match", proposition); return; } //COMPARE TABLEAUX WITH SIMPLE TRUTHTABLE bool simpleTableResult; if (dgvSimpleTable.Rows.Count > 2) { simpleTableResult = false; } //contains 1 empty row at the bottom, should ignore! else { if (dgvSimpleTable.Rows.Count == 2) { string rowResult = dgvSimpleTable.Rows[0].Cells[dgvSimpleTable.Columns.Count - 1].Value.ToString(); if (rowResult == "1") { simpleTableResult = true; } else if (rowResult == "0") { simpleTableResult = false; } else { throw new Exception("Unknown character"); } } else { throw new Exception("Not possible scenario"); } } if (simpleTableResult != tabHolder.IsTautology) { testFailed("Tautology result from SimpleTable does not match tautology result from Tableaux", proposition); return; } testCounter++; }
//DISPLAY CONNECTIVE TREE STRUCTURE public void ShowTreeStructure() { string path = PropositionReader.CreateStructurePicture(startConnective); Process.Start(@path); }