public void RunMain() { Proposition expr; string result; //string s = "( p -> ( q & r ) ) <-> y"; //string s = "(A ->( B -> C )) <-> ( C -> D ) & ( D -> E) "; //string s = "p<->p"; //string s = "p <-> a & b"; //string s = "((p | q) & (~p | r)) -> (q | r)"; //string s = "(P|(S&T))|R"; //string s = "(A&B)|(~A)|(~B)"; //string s = "(~p)<->(p->F)"; //string s = "(~((a&b)|c)&d)|(((a&b)|c)&(~d))"; string s = "(a&b)|(c&d)|(e&f)"; ParseEngine parseEngine = new ParseEngine(); parseEngine.TryParse(out expr, out result, s); LogicEngine logicEng = new LogicEngine(); Proposition nnfExpr = logicEng.ConvertToNNF(expr); Proposition cnfExpr = logicEng.ConvertToCNF(nnfExpr); bool b = logicEng.IsTautology(cnfExpr); WriteFile(cnfExpr.ToString()); }
public void PropositionTestErrorWhenWrongOperator() { string input = "+(A,B)"; string output = "Ups, you did something wrong!"; Proposition check = new Proposition(input); Assert.AreEqual(output, check.ToString()); }
public void PropositionTestWithSpaces() { string input = "=( | (A ,B), &(C ,D))"; string output = "((A|B)=(C&D))"; Proposition check = new Proposition(input); Assert.AreEqual(output, check.ToString()); }
public void PropositionTestBigProposition() { string input = "=(&(~(B), A),|(=(C,D),>(E,F)))"; string output = "((~(B)&A)=((C=D)|(E>F)))"; Proposition check = new Proposition(input); Assert.AreEqual(output, check.ToString()); }
public void PropositionTestNormalProposition() { string input = "=(A,|(C,B))"; string output = "(A=(C|B))"; Proposition check = new Proposition(input); Assert.AreEqual(output, check.ToString()); }
public void PropositionTestBiimplication() { string input = "=(A,B)"; string output = "(A=B)"; Proposition check = new Proposition(input); Assert.AreEqual(output, check.ToString()); }
public void PropositionTestDisjunction() { string input = "|(A,B)"; string output = "(A|B)"; Proposition check = new Proposition(input); Assert.AreEqual(output, check.ToString()); }
public void PropositionTestNegation() { string input = "~(A)"; string output = "~(A)"; Proposition check = new Proposition(input); Assert.AreEqual(output, check.ToString()); }
public void ToString_ValidPropositionWithSpecificSymbol_ExpectedDataAsString(char symbol, string expectedToString) { // Arrange Proposition proposition = new Proposition(symbol); // Act string actualToString = proposition.ToString(); // Assert actualToString.Should().Be(expectedToString, "Because for a proposition only the symbol itself is returned."); }
public void ToString_CallToStringOnValidVariable_ExpectedTheVariableDataReturned() { // Arrange string expectedResultString = "A"; // Act string actualResultString = VALID_PROPOSITION.ToString(); // Assert actualResultString.Should().BeEquivalentTo(expectedResultString, "because the proposition returns its data as string"); }
private string[] GenerateTruthTable() { if (Rows == null) { throw new Exception("Table does not exist."); } string[] temp = new string[CombinationsCount + 1]; temp[0] = string.Join(" ", Variables) + " " + Proposition.ToString(); for (int k = 0; k < Rows.Length; k++) { temp[k + 1] = SplitString(Rows[k]); } CalculateHash(); return(temp); }
//private void GenerateRows() //{ // for (int i = 1; i < RowsString.Length; i++) // { // Rows.Add(new Row(row) // } //} private string[] GenerateNewTruthTable() { if (Rows != null) { throw new Exception("Not a new truth table."); } string[] temp = new string[CombinationsCount + 1]; string[] lines = GenerateTruthTableValues(); truthValues = CalculateTruthTableChar(); temp[0] = string.Join(" ", Variables) + " " + Proposition.ToString(); for (int k = 0; k < lines.Length; k++) { temp[k + 1] = lines[k] + truthValues[k]; } CalculateHash(); return(temp); }
public override string ToString() { return(Proposition.ToString()); }
public override string ToString() { return(m_prop.ToString()); }