コード例 #1
0
 private void BtnClearAll_Click(object sender, EventArgs e)
 {
     txtOutput.Clear();
     SimplifiedTruthTable.Clear();
     truthTable.Clear();
     txtDNF.Clear();
     txtHashtruthTable.Clear();
     txtOutputPredicate.Clear();
     txtNAND.Clear();
 }
コード例 #2
0
        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);
                }
            }
        }