Esempio n. 1
0
 static void Load()
 {
     stopwatch.Restart();
     truthTable = repository.Resolve(ModelPath).RootElements[0] as TruthTable;
     stopwatch.Stop();
     Report(BenchmarkPhase.Load);
 }
Esempio n. 2
0
        public void TestSimplifiedTruthTableDNF(string formula)
        {
            BinaryTree tree  = new BinaryTree(formula);
            TruthTable table = new TruthTable(tree);
            var        dnf   = table.GetDNF(table.SimplifiedTable);

            if (table.GetHashCode(table.OriginalTable) != 0 && Convert.ToString(table.GetHashCode(table.OriginalTable), 2).Contains('0'))
            {
                BinaryTree treeFromDnf  = new BinaryTree(dnf.PrefixFormat);
                TruthTable tableFromDnf = new TruthTable(treeFromDnf);
                Assert.AreEqual(table.GetHashCode(table.OriginalTable), tableFromDnf.GetHashCode(tableFromDnf.OriginalTable));
                string formulaWithoutBrackets = treeFromDnf.PrintParsedFormula().Replace("(", "");
                formulaWithoutBrackets = formulaWithoutBrackets.Replace(")", "");
                formulaWithoutBrackets = formulaWithoutBrackets.Replace(" ", "");
                string infixWithoutBrackets = dnf.InfixFormat.Replace("(", "");
                infixWithoutBrackets = infixWithoutBrackets.Replace(")", "");
                infixWithoutBrackets = infixWithoutBrackets.Replace(" ", "");
                Assert.AreEqual(formulaWithoutBrackets, infixWithoutBrackets);
            }
            else
            {
                Assert.AreEqual(dnf.PrefixFormat, "");
                string infixWithoutBrackets = dnf.InfixFormat.Replace("(", "");
                infixWithoutBrackets = infixWithoutBrackets.Replace(")", "");
                infixWithoutBrackets = infixWithoutBrackets.Replace(" ", "");
                Assert.AreEqual(infixWithoutBrackets, "");
            }
        }
Esempio n. 3
0
        public void TestMethod1()
        {
            BuildKB    KB = new BuildKB("apple.txt");
            TruthTable TT = new TruthTable(KB.Implies, KB.Vars, KB.TrueVars, "apple");

            Assert.IsTrue(TT.BuildTT() == "Yes 1", "Returns yes with 1 level for apple");
        }
Esempio n. 4
0
 private static Operand GetExpr(TruthTable imm, EmitterContext context, Operand x, Operand y, Operand z)
 {
     return(imm switch
     {
         TruthTable.False => Const(0),
         TruthTable.True => Const(-1),
         TruthTable.In => x,
         TruthTable.And2 => context.BitwiseAnd(x, y),
         TruthTable.Or2 => context.BitwiseOr(x, y),
         TruthTable.Xor2 => context.BitwiseExclusiveOr(x, y),
         TruthTable.And3 => context.BitwiseAnd(x, context.BitwiseAnd(y, z)),
         TruthTable.Or3 => context.BitwiseOr(x, context.BitwiseOr(y, z)),
         TruthTable.XorAnd => context.BitwiseAnd(x, context.BitwiseExclusiveOr(y, z)),
         TruthTable.XorOr => context.BitwiseOr(x, context.BitwiseExclusiveOr(y, z)),
         TruthTable.OrAnd => context.BitwiseAnd(x, context.BitwiseOr(y, z)),
         TruthTable.AndOr => context.BitwiseOr(x, context.BitwiseAnd(y, z)),
         TruthTable.Onehot => context.BitwiseExclusiveOr(context.BitwiseOr(x, y), context.BitwiseOr(z, context.BitwiseAnd(x, y))),
         TruthTable.Majority => context.BitwiseAnd(context.BitwiseOr(x, y), context.BitwiseOr(z, context.BitwiseAnd(x, y))),
         TruthTable.InverseGamble => context.BitwiseOr(context.BitwiseExclusiveOr(x, y), context.BitwiseExclusiveOr(x, z)),
         TruthTable.Dot => context.BitwiseAnd(context.BitwiseExclusiveOr(x, z), context.BitwiseOr(context.BitwiseNot(y), z)),
         TruthTable.Mux => context.BitwiseOr(context.BitwiseAnd(x, y), context.BitwiseAnd(context.BitwiseNot(x), z)),
         TruthTable.AndXor => context.BitwiseExclusiveOr(x, context.BitwiseAnd(y, z)),
         TruthTable.OrXor => context.BitwiseExclusiveOr(x, context.BitwiseOr(y, z)),
         TruthTable.Xor3 => context.BitwiseExclusiveOr(x, context.BitwiseExclusiveOr(y, z)),
         _ => null
     });
Esempio n. 5
0
        public void BuildExpressionTree_Should_Create_ExpressionTree_From_PrefixExpression(List <int> minterms)
        {
            GC.Collect();
            Stopwatch s2 = Stopwatch.StartNew();
            var       externalLibraryResult = QuineMcCluskeySolver.QMC_Solve(minterms, new int[] { });

            s2.Stop();

            TruthTable table = TruthTableHelpers.GenerateTruthTable(minterms);
            Stopwatch  s1    = Stopwatch.StartNew();
            var        customLibraryResult = logic.ExpressionService.Common.QMC.QuineMcCluskey.SimplifyTable(table.Value);

            s1.Stop();

            TestContext.Out.WriteLine(s1.ElapsedTicks);
            TestContext.Out.WriteLine(s2.ElapsedTicks);

            var helperSet = new HashSet <string>();

            foreach (var pr in customLibraryResult)
            {
                helperSet.Add(pr.RowData);
            }

            foreach (var item in externalLibraryResult)
            {
                helperSet.Should().Contain(item.ToString());
            }
        }
Esempio n. 6
0
    private static List <List <LogicState> > getRowsWithTrueOutput(TruthTable input)
    {
        /* picks the rows with output equal to true
         * e.g.:
         * 000|0
         * 001|1
         * 010|1
         * would return
         * 001|1
         * 010|1
         */


        List <List <LogicState> > output = new List <List <LogicState> >();

        for (int i = 0; i < input.OutputStates.Count; i++)
        {
            if (input.OutputStates[i] == LogicState.True)
            {
                output.Add(input.InputStates[i].Clone());
            }
        }

        return(output);
    }
Esempio n. 7
0
        private PL_Base Solve(string statement, out TruthTable truthTable)
        {
            PL_Base PL_Statement;

            try
            {
                switch (currentType)
                {
                case SystemType.PL:
                    PL_Statement = new PL(statement);
                    break;

                case SystemType.PL_DASH1:
                    PL_Statement = new PL_Dash1(statement);
                    break;

                case SystemType.PL_DASH2:
                    PL_Statement = new PL_Dash2(statement);
                    break;

                default:
                    PL_Statement = new PL_Dash3(statement);
                    break;
                }
                PL_Statement.GenerateTruthTable();
                truthTable = PL_Statement.TruthTable;
                return(PL_Statement);
            }
            catch (MalFormedException)
            {
                throw;
            }
        }
Esempio n. 8
0
 // ((A + B)*C)
 // ((A + (B*C)) + D)
 // ABC*+D+
 public Function(string function)
 {
     this.function = function;
     postfix       = toPostfix();
     variables     = identifyVariables();
     truthTable    = new TruthTable(variables, postfix);
 }
Esempio n. 9
0
        public void TestSimplifiedTruthTableCreation(string formula, string expectedHashCode)
        {
            int        hashCodeInBinary = Convert.ToInt32(expectedHashCode, 2);
            BinaryTree tree             = new BinaryTree(formula);
            TruthTable table            = new TruthTable(tree);

            Assert.AreEqual(table.GetHashCode(table.SimplifiedTable), hashCodeInBinary);
        }
        public void CreateTruthTableTest()
        {
            BooleanExpression expression1 = new BooleanExpression("a'b'cd + a'bc'd");
            TruthTable        table1      = new TruthTable(expression1);

            Console.WriteLine(table1.ToString());
            Console.WriteLine(table1.MintermString());
        }
Esempio n. 11
0
        public void TruthTableTest()
        {
            AbstractionSyntaxTree ast = new AbstractionSyntaxTree(">(=(&(p,q),a),b)");
            TruthTable            tb  = new TruthTable(ast);

            Assert.AreEqual(false, tb.isCalulated);
            Assert.AreEqual(ast, tb.AST);
        }
        public void setUpLabel_isLabelValid()
        {
            //Arrange and Act
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Assert
            Assert.AreEqual(truthTableObject.setUpLabel(), "a  b   |   evaluation\n");
        }
        public void setUpLabel_is_not_Null()
        {
            //Arrange and Act
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Assert
            Assert.IsNotNull(truthTableObject.setUpLabel());
        }
Esempio n. 14
0
 public static double[,] test(TruthTable[,] truthTables)
 {
     int numberOfCategories = (int) Math.Sqrt(truthTables.Length);
     var result = new double[numberOfCategories, numberOfCategories];
     for(int i=0; i<numberOfCategories; i++)
         for (int j = 0; j < numberOfCategories; j++)
             result[i,j] = calcTestStatistic(truthTables[i, j].FalsePosetive, truthTables[i, j].FalseNegative);
     return result;
 }
Esempio n. 15
0
        public void Full_Truth_Table_fail()
        {
            FileInput input             = new FileInput("./Semicomplicated_false.txt");
            Model     temp              = new Model();
            PropositionInterpreter test = new PropositionInterpreter(ref temp);
            World      MyWorld          = new World(test.ParseProps(input.ReadFromFile()), temp.Length);
            TruthTable solver           = new TruthTable(temp, MyWorld);

            Assert.AreEqual(solver.solve(), 0);
        }
Esempio n. 16
0
 static void Main(string[] args)
 {
     var testTable = TruthTable.Create<bool, bool, bool, bool>
         (b => b /*Column description*/ , b => b /* Column 2 */ , b => b, b => b, defaultValue: false)
     .Row(false,                          false,                  false,  false, false)
     .Row(false,                          true,                   false,  true,  true)
     .Row(true,                           true,                   true,   false, false)
     .Row(true,                           false,                  true,   true,  true);
     var result = testTable.GetValue(false, true, false, true);
 }
Esempio n. 17
0
        public void TruthTable_CalculateTruthTable_HashCodeBeEqualAsExpected(string prefixInput, string hexaHashCode)
        {
            //Arrange
            var binaryTree = ParsingModule.Parse(prefixInput);

            //Act
            var truthTable = new TruthTable(binaryTree);

            //Assert
            Assert.Equal(truthTable.GetHexadecimalHashCode(), hexaHashCode);
        }
Esempio n. 18
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion


        private void setup()
        {
            model          = new Model();
            propintr       = new PropositionInterpreter(ref model);
            input          = new FileInput(filePath);
            MyWorld        = new World(propintr.ParseProps(input.ReadFromFile()), model.Length);
            Truthsolver    = new TruthTable(model, MyWorld);
            forwardsolver  = new ForwardChain(model, MyWorld);
            backwardsolver = new BackwardsChain(model, MyWorld);
            strWriter      = new StringWriter();
            Console.SetOut(strWriter);
        }
        public void printTable_IsItValid()
        {
            //Arrange
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Act
            var tableString = truthTableObject.printTable();

            //Assert
            Assert.AreEqual(tableString, "0  0              1\n0  1              1\n1  0              0\n1  1              1\n");
        }
        public void getList0and1_is_not_null()
        {
            //Arrange
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Act
            var simplifiedtableString = truthTableObject.getList0and1();

            //Assert
            Assert.IsNotNull(simplifiedtableString);
        }
        public void NoOfDifferentSymbol_does_it_return_right_type()
        {
            //Arrange
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Act
            var valueReturn = truthTableObject.NoOfDifferentSymbol("a", "b");

            //Assert
            Assert.IsInstanceOfType(valueReturn, typeof(int));
        }
        public void returnLabel_is_not_null()
        {
            //Arrange
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Act
            var valueReturn = truthTableObject.returnLabel();

            //Assert
            Assert.IsNotNull(valueReturn);
        }
        public void simplifiedTableString_is_not_null()
        {
            //Arrange
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Act
            var testString = truthTableObject.simplifiedTableString(truthTableObject.returnValuesEachLine());

            //Assert
            Assert.IsNotNull(testString);
        }
        public void getList0and1_is_it_valid()
        {
            //Arrange
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Act
            var simplifiedtableString = truthTableObject.getList0and1();

            //Assert
            Assert.AreEqual(simplifiedtableString, "0  ⋆              1\n⋆  1              1\n");
        }
        public void printTable_is_not_null()
        {
            //Arrange
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Act
            var tableString = truthTableObject.printTable();

            //Assert
            Assert.IsNotNull(tableString);
        }
        public void returnLogicResult_does_it_return_right_type()
        {
            //Arrange
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Act
            var valueReturn = truthTableObject.returnLogicResult();

            //Assert
            Assert.IsInstanceOfType(valueReturn, typeof(List <int>));
        }
		// 初期化
		public QuineMcCluskey (TruthTable table)
		{

			Source = table;
			var trues = table.Columns.Where (x => x.Result);
			var trueCount = trues.Count ();
			trueCols = trues.Select((x, i) => {
				var col = new QMColumn(x, trueCount);
				col.Flags[i] = true;
				return col;
			}).ToArray ();
			combined = new IEnumerable<IEnumerable<QMColumn>>[table.Columns[0].Size + 1];
		}
        public void returnHexHashCode_is_not_null()
        {
            //Arrange
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Act
            var tableString = truthTableObject.printTable();
            var hashCode    = truthTableObject.returnHexHashCode();

            //Assert
            Assert.IsNotNull(hashCode);
        }
Esempio n. 29
0
        /// <summary>
        /// Brings up the truth table window and hooks into truth table events
        /// </summary>
        public void DisplayTruthTable()
        {
            TruthTable truthTable = new TruthTable(sketchPanel.Circuit);

            truthTableWindow         = new TruthTableWindow(truthTable.TruthTableHeader, truthTable.TruthTableOutputs, sketchPanel.Circuit.NumInputs);
            truthTableWindow.Closed += new EventHandler(truthTableWindow_Closed);

            truthTableWindow.Show();
            truthTableWindow.SimulateRow    += new RowHighlightEventHandler(truthTableWindow_SimulateRow);
            truthTableWindow.Highlight      += new HighlightEventHandler(truthTableWindow_HighlightLabel);
            truthTableWindow.UnHighlight    += new UnhighlightEventHandler(truthTableWindow_UnHighlightLabel);
            truthTableWindow.RelabelStrokes += new RelabelStrokesEventHandler(truthTableWindow_RelabelStrokes);
        }
        internal static LogicalNetworEntity Create(
            IEnumerable<LogicalNetworkGene> dominantGeneSequence,
            GateTypeEvolutionMethod evolutionMethod,
            TruthTable truthTableToSolve,
            LogicGateTypes gateTypeRestrictions)
        {
            Contract.Requires(dominantGeneSequence != null);
            Contract.Requires(truthTableToSolve != null);
            Contract.Requires(gateTypeRestrictions != null);

            var dna = new DNA<LogicalNetworkGene>(dominantGeneSequence.ToList());
            return Create(dna, dna.Genes[0], evolutionMethod, truthTableToSolve, gateTypeRestrictions);
        }
        public void returnHexHashCode_isItValid()
        {
            //Arrange
            var processObject    = new ProcessLogicClass(">(a,b)");
            var truthTableObject = new TruthTable(processObject);

            //Act
            var tableString = truthTableObject.printTable();
            var hashCode    = truthTableObject.returnHexHashCode();

            //Assert
            Assert.AreEqual(hashCode, "B");
        }
Esempio n. 32
0
        private void btnGenerateTruthTable_Click(object sender, EventArgs e)
        {
            BuildTree();

            //Create the truth table from the formula
            myTruthTable = new TruthTable(myProcessing.Variables);
            myProcessing.AssignRowValues(myTruthTable.GetRows());

            //Display both truth tables and hash code
            tbTruthTable.Text           = myTruthTable.ToString();
            tbSimplifiedTruthTable.Text = myTruthTable.SimplifiedTableToString();
            tbHashCode.Text             = myTruthTable.GetHashCodeTB();
        }
Esempio n. 33
0
        public void TestBinHash()
        {
            //Arrange
            Parser     p          = new Parser();
            string     input      = ">(A,|(&(D,A),C))";
            Node       n          = p.ParseExpression(input);
            TruthTable truthTable = new TruthTable(new char[] { 'A', 'C', 'D' }, n);

            //Act
            string result = truthTable.BinHashValue;

            //Assert
            Assert.AreEqual("11101111", result);
        }
        internal static LogicalNetworEntity Create(
            DNA<LogicalNetworkGene> dna,
            IEnumerable<LogicalNetworkGene> dominantGeneSequence,
            GateTypeEvolutionMethod evolutionMethod,
            TruthTable truthTableToSolve,
            LogicGateTypes gateTypeRestrictions)
        {
            Contract.Requires(dna != null);
            Contract.Requires(dominantGeneSequence != null);
            Contract.Requires(truthTableToSolve != null);
            Contract.Requires(gateTypeRestrictions != null);
            
            LogicalNetworkFactory factory;
            if (evolutionMethod == GateTypeEvolutionMethod.Restrict)
            {
                factory = new LogicalNetworkFactory(truthTableToSolve.InputInterfaceLength, truthTableToSolve.OutputInterfaceLength, gateTypeRestrictions);
            }
            else // Evolve
            {
                factory = new LogicalNetworkFactory(truthTableToSolve.InputInterfaceLength, truthTableToSolve.OutputInterfaceLength);
            }

            var network = LogicalNetworkDNADecoder.CreateNetwork(factory, dominantGeneSequence);

            int numOfNAGates = 0;
            if (evolutionMethod == GateTypeEvolutionMethod.Evolve && gateTypeRestrictions != null)
            {
                foreach (var entry in network.EntryArray)
                {
                    var gate = entry.NodeEntry.Node as LogicGate;
                    if (gate != null)
                    {
                        var type = new LogicGateType(gate.Operation, entry.UpperConnectionEntryArray.Length);
                        if (!gateTypeRestrictions.Contains(type)) numOfNAGates++;
                    }
                }
            }

            int errors = new TruthTableComputation(network).ComputeError(truthTableToSolve);

            return new LogicalNetworEntity(dna, network, errors, numOfNAGates);
        }
Esempio n. 35
0
        private static void Begin()
        {
/*
0	0	0	0	0
0	1	0	0	1
1	0	0	0	1
1	1	0	1	0
0	0	1	0	1
0	1	1	1	0
1	0	1	1	0
1	1	1	1	1
*/

            var table = new TruthTable(
                3, 2,
                new[] 
                { 
                    new TruthTableEntry(new[] { false, false, false }, new[] { false, false }),
                    new TruthTableEntry(new[] { false, true, false }, new[] { false, true }),
                    new TruthTableEntry(new[] { true, false, false }, new[] { false, true }),
                    new TruthTableEntry(new[] { true, true, false }, new[] { true, false }),
                    new TruthTableEntry(new[] { false, false, true }, new[] { false, true }),
                    new TruthTableEntry(new[] { false, true, true }, new[] { true, false }),
                    new TruthTableEntry(new[] { true, false, true }, new[] { true, false }),
                    new TruthTableEntry(new[] { true, true, true }, new[] { true, true }),
                });

            var restrict = new LogicGateTypes(new[] { LogicGateType.NAND(2), LogicGateType.NOT() });

            var factory = new LNGAEntityFactory(table, restrict);

            factory.MaxIndex = 20;
            factory.ValidDNALenghtRange = IntRange.CreateInclusive(200, 250);
            factory.CrossoverChunkSize = IntRange.CreateExclusive(1, factory.ValidDNALenghtRange.MaxValue);
            factory.StoreParentSequences = false;
            factory.GateTypeEvolutionMethod = GateTypeEvolutionMethod.Restrict;

            factory.MutationParameters.MutationChunkSize = IntRange.CreateExclusive(1, factory.ValidDNALenghtRange.MaxValue);

            factory.MutationParameters.PointMutationChance = 0.01;

            factory.MutationParameters.DeletionMutationChance = 0.01;
            factory.MutationParameters.DuplicationMutationChance = 0.01;
            factory.MutationParameters.InsertionMutationChance = 0.01;
            factory.MutationParameters.TranslocationMutationChance = 0.01;
            factory.MutationParameters.InversionMutationChance = 0.01;

            var epoch = new LogicalGAEpoch(factory, 50, 25);

            epoch.NumberOfParentsRange = IntRange.CreateFixed(4);
            epoch.OffspringMovingChance = 0.1;
            epoch.BestSelectStdDev = 0.7;
            epoch.WorstSelectStdDev = 0.01;

            //var factory = new LNStatisticalEntityFactory(
            //    table,
            //    180,
            //    40,
            //    10,
            //    0.00,
            //    0.25,
            //    GateTypeEvolutionMethod.Evolve,
            //    restrict);

            //var epoch = new LogicalSAEpoch(factory, 50, 25, 5);

            bool done = false;

            LogicalNetworEntity best = null;

            while (!done)
            {
                epoch.Step();

                var cbest = (LogicalNetworEntity)epoch.BestEntity;

                if (cbest != null)
                {
                    if (best == null || cbest.CompareTo(best) < 0)
                    {
                        best = cbest;
                        Dump(epoch, best);
                    }
                    else if (epoch.CurrentIteration % 100 == 0)
                    {
                        Dump(epoch, best);
                    }
                }

                //if (Console.KeyAvailable)
                //{
                //    Console.ReadKey();
                //    done = true;
                //}
            }
        }
Esempio n. 36
0
		public static void Main (string[] args)
		{
			string line;
			noCaption = args.Contains("-n");
			while((line = Console.ReadLine ()) != null) {
				var parser = Parser.Parse (line);

				if (parser.Expression != null) {
					var table = new TruthTable (parser.Parameters.Values.ToArray (), parser.Expression);
					// 真理値表
					if (args.Contains("-T")) {
						caption ("[Truth Table]");
						echo (table.ToString());
					}
					// 主加法標準形
					if (args.Contains("-D")) {
						caption ("[Disjunctive]");
						echo (table.ToDisjunctiveCanonicalExpression ().ToSimpleString ());
					}
					// 主乗法標準形
					if (args.Contains("-C")) {
						caption ("[Conjunctive]");
						echo (table.ToConjunctiveCanonicalExpression ().ToSimpleString ());
					}

					// 省力化
					if (!args.Any (s => s.StartsWith("-q") || s.StartsWith("-c"))) {
						Console.WriteLine ();
						continue;
					}

					// QM法
					var qmc = new QuineMcCluskey (table);
					foreach (IEnumerable<TruthTableColumn> result in qmc.Compressed) {
						var newTable = new TruthTable (table.Parameters, result);
						// QM法 真理値
						if (args.Contains("-qT")) {
							caption ("[QM'ed Truth Table]");
							echo (newTable.ToString ());
						}
						// QM法 主加法標準形
						if (args.Contains("-qD")) {
							caption ("[QM'ed Disjunctive]");
							echo (newTable.ToDisjunctiveCanonicalExpression ().ToSimpleString ());
						}

						var checkTable = new TruthTable (table.Parameters, newTable.ToDisjunctiveCanonicalExpression ());
						// 確認用 真理値表
						if (args.Contains("-cT")) {
							caption ("[Check Truth Table]");
							echo (checkTable.ToString ());
						}
						// 確認用 主乗法標準形
						if (args.Contains("-cC")) {
							caption ("[Check Conjunctive]");
							echo (checkTable.ToConjunctiveCanonicalExpression ().ToSimpleString ());
						}
						// 確認用 主加法標準形
						if (args.Contains("-cD")) {
							caption ("[Check Disjunctive]");
							echo (checkTable.ToDisjunctiveCanonicalExpression ().ToSimpleString ());
						}
					}
					Console.WriteLine ();
				} else {
					Console.Error.WriteLine("Parse Error.");
				}
			}
		}
Esempio n. 37
0
        public void ValidateFormula_FormulaWithJustOneArgument_ValidFormula()
        {
            TruthTable table = new TruthTable("");

            Assert.AreEqual(true, table.ValidateFormula("d"));
        }
Esempio n. 38
0
 public void Arguments_NotCalculated_TableNotCalculatedExceptionThrown()
 {
     TruthTable table = new TruthTable("a.b");
     Int32 hellhound = table.Arguments.Count;
 }
Esempio n. 39
0
 public void ArgumentsValues_NotCalculated_TableNotCalculatedExceptionThrown()
 {
     TruthTable table = new TruthTable("a.b");
     Int32 on = table.ArgumentsValues.Length;
 }
Esempio n. 40
0
 public void ExpressionsValues_NotCalculated_TableNotCalculatedExceptionThrown()
 {
     TruthTable table = new TruthTable("a.b");
     Int32 trail = table.ExpressionsValues.Count;
 }