public BasicOperation(TruthTable truthTable, string opName, bool[] truthValues) //Ctor used to insert the statement truth table input args { OpName = opName; this.truthTtable = truthTable; TruthValues = truthValues; Type = "Letter"; }
private void Solve(string subOperation) { if (subOperation.Split(PL.sysOperators, StringSplitOptions.RemoveEmptyEntries).Length <= 2) { BasicOperation basicOp = new BasicOperation(TruthTable, subOperation); if (basicOp.Label == '\0') { InputStatement = InputStatement.Replace("(" + subOperation + ")", subOperation); return; } InputStatement = InputStatement.Replace("(" + subOperation + ")", basicOp.Label.ToString()); InputStatement = InputStatement.Replace(subOperation, basicOp.Label.ToString()); while (InputStatement.Contains("(" + basicOp.Label + ")")) { InputStatement = InputStatement.Replace("(" + basicOp.Label + ")", basicOp.Label.ToString()); } InputStatement = InputStatement.Replace("¬" + basicOp.Label.ToString(), "(¬" + basicOp.Label.ToString() + ")"); if (InputStatement.Length > 1 && !InputStatement.Contains('(')) { InputStatement = "(" + InputStatement + ")"; } TruthTable.InsertOpIntoTruthTable(basicOp); } else { RefineSubOp(subOperation); } }
private LinkedList <Parenthsis> priorityList = new LinkedList <Parenthsis>(); //List of parentheses to calculate priority public QueuingSolve(string statement, TruthTable truthTable) { InputStatement = statement; TruthTable = truthTable; DefinePriorityList(); GenerateTruthTable(); }
//If the equation is WFF then evaluate it. public void GenerateTruthTable() { try { if (IsWFF) { TruthTable.GenerateTruthTable(); } } catch (MalFormedException) { throw; } }
//Constructor public PL_Dash1(string statement) : base() { sysOperators = new char[] { '¬', '→' }; StringBuilder sb = new StringBuilder("("); sb.Append(statement.Trim()); sb.Replace(" ", ""); //Remove all white spaces. sb.Append(")"); PL_Statement = sb.ToString(); Letters = PL_Statement.Split(new char[] { '¬', '→', '(', ')' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray(); //Extract operands from the equation. if (Letters.Length == 0) { throw new MalFormedException("Empty statement"); } Array.Sort(Letters); isWFF = IsWFF; TruthTable = new TruthTable(this); }
public BasicOperation(TruthTable truthTable, string opName) { OpName = opName; this.truthTtable = truthTable; Evaluate(); }