コード例 #1
0
        public static void PrintClosedClasses(int n)
        {
            BooleanFunction f = new BooleanFunction((byte)n);

            PostClosedClasses.CheckConservationZero(f, true);

            PostClosedClasses.CheckConservationOne(f, true);

            PostClosedClasses.CheckSelfDuality(f, true);

            PostClosedClasses.CheckMonotony(f, true);

            PostClosedClasses.CheckLinearity(f, true);

            Console.WriteLine();
        }
コード例 #2
0
        public static void PrintRepresentBinariesInF(int n, bool noLookBack)
        {
            bool[] functionClasses = PostClosedClasses.GetFunctionClasses(new BooleanFunction((byte)n));

            var availableExpressions = new List <BooleanExpression> {
                new VarExpression(BooleanVariable.A),
                new VarExpression(BooleanVariable.B),
            };

            foreach (var t in BinariesAndClasses)
            {
                bool representable = true;

                for (int i = 0; i < 5; i++)
                {
                    if (functionClasses[i] && !t.Item2[i])
                    {
                        representable = false;
                        break;
                    }
                }

                if (!representable)
                {
                    continue;
                }

                try {
                    var targetExpression = new OpExpression(t.Item1, BooleanVariable.A, BooleanVariable.B);

                    Console.WriteLine(targetExpression.ToString() + " = " +
                                      TertiaryOpExpression.FindMininalExpressionForBinary(targetExpression,
                                                                                          new BooleanFunction((byte)n), availableExpressions));

                    if (!noLookBack)
                    {
                        availableExpressions.Add(targetExpression);
                    }
                }
                catch (CouldntFindExpressionException) {
                }
            }
        }