public TruthTable Simplify() { TruthTable simplifiedTt = new TruthTable(propositionRoot, propositionVariablesSet, SimplifyRowsIteratively(Rows)); simplifiedTt.OriginalResultColumn = GetConvertedResultColumn(); return(simplifiedTt); }
protected override void ExecuteParsingActivities() { if (Root.IsAbstractProposition()) { hashCodes = new List <string>(); // 1 TruthTable = new TruthTable(Root); hashCodeCalculator.GenerateHashCode(TruthTable.GetConvertedResultColumn()); hashCodes.Add(hashCodeCalculator.HashCode); // 2 SimplifiedTruthTable = TruthTable.Simplify(); if (NonConstantExpressionWasParsed()) { // Convert the table to DNF such that we have a proposition to work with. Proposition simplified = SimplifiedTruthTable.CreateDisjunctiveNormalForm(); TruthTable simplifiedTt = new TruthTable(simplified); // Check the hash code for the proposition. hashCodeCalculator.GenerateHashCode(simplifiedTt.GetConvertedResultColumn()); hashCodes.Add(hashCodeCalculator.HashCode); // 3 Nandified = Root.Nandify(); TruthTable nandifiedTruthTable = new TruthTable(Nandified); TruthTable nandifiedSimplified = nandifiedTruthTable.Simplify(); // Same as for simplified truth table. Proposition nandSimpleDnf = nandifiedSimplified.CreateDisjunctiveNormalForm(); TruthTable nandSimpleDnfTt = new TruthTable(nandSimpleDnf); hashCodeCalculator.GenerateHashCode(nandSimpleDnfTt.GetConvertedResultColumn()); hashCodes.Add(hashCodeCalculator.HashCode); // 4 DisjunctiveNormalForm = TruthTable.CreateDisjunctiveNormalForm(); TruthTable disjunctiveTruthTable = new TruthTable(DisjunctiveNormalForm); hashCodeCalculator.GenerateHashCode(disjunctiveTruthTable.GetConvertedResultColumn()); hashCodes.Add(hashCodeCalculator.HashCode); // 5 Proposition simplifiedDisjunctiveNormal = SimplifiedTruthTable.CreateDisjunctiveNormalForm(); TruthTable simplifiedDisjunctiveNormalTruthTable = new TruthTable(simplifiedDisjunctiveNormal); hashCodeCalculator.GenerateHashCode(simplifiedDisjunctiveNormalTruthTable.GetConvertedResultColumn()); hashCodes.Add(hashCodeCalculator.HashCode); // 6 Proposition nandifiedSimplifiedDisjunctiveNormal = simplifiedDisjunctiveNormal.Nandify(); TruthTable nandifiedSimplifiedDisjunctiveNormalTruthTable = new TruthTable(nandifiedSimplifiedDisjunctiveNormal); hashCodeCalculator.GenerateHashCode(nandifiedSimplifiedDisjunctiveNormalTruthTable.GetConvertedResultColumn()); hashCodes.Add(hashCodeCalculator.HashCode); } } }
private void AddTruthTable(ListBox truthTableLbx, TruthTable truthTable) { truthTableLbx.Items.Clear(); if (truthTable != null) { truthTableLbx.Items.Add(truthTable.TableHeader()); foreach (TruthTableRow row in truthTable.Rows) { truthTableLbx.Items.Add(row); } } }
private void DisplayTruthTableInformation() { TruthTable truthTable = logicApp.TruthTable; AddTruthTable(truthTableLbx, truthTable); }