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"); }
public override Connective GetNandProposition() { ConnectiveNand mainNand = new ConnectiveNand(); ConnectiveNot not = new ConnectiveNot(); mainNand.setLeftConnective(con1.GetNandProposition()); not.setLeftConnective(con2.Copy()); mainNand.setRightConnective(not.GetNandProposition()); return(mainNand); }
public override Connective GetNandProposition() { ConnectiveNand mainNand = new ConnectiveNand(); ConnectiveNand nand1 = new ConnectiveNand(); ConnectiveNand nand2 = new ConnectiveNand(); ConnectiveNot not1 = new ConnectiveNot(); ConnectiveNot not2 = new ConnectiveNot(); not1.setLeftConnective(con1.Copy()); not2.setLeftConnective(con2.Copy()); nand2.setLeftConnective(not1.GetNandProposition()); nand2.setRightConnective(not2.GetNandProposition()); nand1.setLeftConnective(con1.GetNandProposition()); nand1.setRightConnective(con2.GetNandProposition()); mainNand.setLeftConnective(nand1); mainNand.setRightConnective(nand2); return(mainNand); }
private bool calculateIsTautologyWithOwnElements() { Connective adaptedCon; for (int i = 0; i < elements.Count; i++) { if (elements[i].Element is ConnectiveNot) //reference to child (ignore the not parent) OR check if argument == false { ConnectiveNot not = (ConnectiveNot)elements[i].Element; if (not.Con1 is ConnectiveArgument) { if (((ConnectiveArgument)not.Con1).Argument == '1') { return(true); } } adaptedCon = not.Con1; } else //add not as a parent OR check if argument == false { if (elements[i].Element is ConnectiveArgument) { if (((ConnectiveArgument)elements[i].Element).Argument == '0') { return(true); } } adaptedCon = new ConnectiveNot(); ((ConnectiveNot)adaptedCon).setLeftConnective(elements[i].Element); } for (int j = i + 1; j < elements.Count; j++) { if (elements[j].Element.IsTheSameAs(adaptedCon)) { return(true); } } } return(false); }
//SPLITTING OF TABLEAUXSET NEEDED public List <Connective> ApplyBetaTableauxRules() { List <Connective> results = new List <Connective>(); if (element is ConnectiveNot) //FIRST LAYER IS NOT { ConnectiveNot cn = (ConnectiveNot)element; if (cn.Con1 is ConnectiveAnd) //SECOND LAYER IS AND { ConnectiveAnd cn1 = (ConnectiveAnd)cn.Con1; ConnectiveNot not1 = new ConnectiveNot(); ConnectiveNot not2 = new ConnectiveNot(); not1.setLeftConnective(cn1.Con1.Copy()); not2.setLeftConnective(cn1.Con2.Copy()); results.Add(not1); results.Add(not2); } else if (cn.Con1 is ConnectiveBiImplication) //SECOND LAYER IS BI-IMPLICATION { ConnectiveBiImplication cn1 = (ConnectiveBiImplication)cn.Con1; ConnectiveNot not1 = new ConnectiveNot(); ConnectiveNot not2 = new ConnectiveNot(); ConnectiveImplication imp1 = new ConnectiveImplication(); ConnectiveImplication imp2 = new ConnectiveImplication(); not1.setLeftConnective(imp1); not2.setLeftConnective(imp2); imp1.setLeftConnective(cn1.Con1.Copy()); imp1.setRightConnective(cn1.Con2.Copy()); imp2.setLeftConnective(cn1.Con2.Copy()); imp2.setRightConnective(cn1.Con1.Copy()); results.Add(not1); results.Add(not2); } } else if (element is ConnectiveOr) //OR RULE { ConnectiveOr co = (ConnectiveOr)element; results.Add(co.Con1.Copy()); results.Add(co.Con2.Copy()); } else if (element is ConnectiveImplication) //IMPLICATION RULE { ConnectiveImplication ci = (ConnectiveImplication)element; ConnectiveNot not = new ConnectiveNot(); not.setLeftConnective(ci.Con1.Copy()); results.Add(not); results.Add(ci.Con2.Copy()); } else if (element is ConnectiveNand) { ConnectiveNand cn = (ConnectiveNand)element; ConnectiveNot not1 = new ConnectiveNot(); ConnectiveNot not2 = new ConnectiveNot(); not1.setLeftConnective(cn.Con1.Copy()); not2.setLeftConnective(cn.Con2.Copy()); results.Add(not1); results.Add(not2); } return(results); }
//USING USED VARIABLE NEEDED public List <Connective> ApplyGammaTableauxRules(List <char> usedArguments) { List <Connective> results = new List <Connective>(); if (usedArguments.Count > 0) { if (element.IsNormalProposition()) { return(results); } if (element is QuantifierForAll) { QuantifierForAll qfa = (QuantifierForAll)element; char qfaArgument = qfa.Argument; QuantifierForAll qfaCopy; foreach (char c in usedArguments) //try changing arguments { qfaCopy = (QuantifierForAll)qfa.Copy(); if (qfaCopy.Con1.ChangeLocalArgument(qfaArgument, c)) { results.Add(qfaCopy.Con1); } } if (results.Count > 0) //succesfully changed arguments { results.Add(qfa); } } else if (element is ConnectiveNot) { ConnectiveNot cn = (ConnectiveNot)element; if (cn.Con1 is QuantifierExists) { QuantifierExists qe = (QuantifierExists)cn.Con1; char qeArgument = qe.Argument; QuantifierExists qeCopy; foreach (char c in usedArguments) //try changing arguments { qeCopy = (QuantifierExists)qe.Copy(); if (qeCopy.Con1.ChangeLocalArgument(qeArgument, c)) { ConnectiveNot newNot = new ConnectiveNot(); newNot.setLeftConnective(qeCopy.Con1); results.Add(newNot); } } if (results.Count > 0) //succesfully changed arguments { results.Add(cn.Copy()); } } } } return(results); }
//CREATING A NEW VARIABLE NEEDED public List <Connective> ApplyDeltaTableauxRules(List <char> usedArguments, List <char> availableArguments) { List <Connective> results = new List <Connective>(); if (element.IsNormalProposition()) { return(results); } if (element is QuantifierExists) { QuantifierExists qe = (QuantifierExists)element; QuantifierExists qeCopy = (QuantifierExists)element.Copy(); char qeArgument = qe.Argument; if (availableArguments.Count > 0) { if (qeCopy.ChangeLocalArgument(qeArgument, availableArguments[0])) { usedArguments.Add(availableArguments[0]); availableArguments.RemoveAt(0); Connective newElement = qeCopy.Con1; results.Add(newElement); } } else { throw new Exception("Not enough available arguments"); } } else if (element is ConnectiveNot) { ConnectiveNot cn = (ConnectiveNot)element; if (cn.Con1 is QuantifierForAll) { QuantifierForAll qfa = (QuantifierForAll)cn.Con1; QuantifierForAll qfaCopy = (QuantifierForAll)cn.Con1.Copy(); char qfaArgument = qfa.Argument; if (availableArguments.Count > 0) { if (qfaCopy.ChangeLocalArgument(qfaArgument, availableArguments[0])) { usedArguments.Add(availableArguments[0]); availableArguments.RemoveAt(0); ConnectiveNot newNot = new ConnectiveNot(); newNot.setLeftConnective(qfaCopy.Con1); Connective newElement = newNot; results.Add(newElement.Copy()); } } else { throw new Exception("Not enough available arguments"); } } } return(results); }