static void Main(string[] args)
        {
            uint[]           outputIntegers = KaterynaBodnarchukTask.KateBodnarchukCase;
            bool[]           output         = BitTools.GetOutputBool(outputIntegers);
            List <Implicant> constituents   = PositiveMcCluskeyMethod.GetConstituents(output);
            string           constituentsDisjunctionFormString =
                Implicant.GetDisjunctionFormString(constituents);

            Console.WriteLine("Original Function: " + constituentsDisjunctionFormString);

            var minimalDisjunctionalNormalFunction =
                PositiveMcCluskeyMethod.GetImplicantDisjunctionNormalForm(output);

            Console.WriteLine(
                "Optimized Function: "
                +
                Implicant.GetDisjunctionFormString(minimalDisjunctionalNormalFunction)
                );

            uint input = uint.Parse(Console.ReadLine());

            Console.WriteLine(
                "Output: "
                +
                ImplicantDisjunctionNormalForm.Evaluate(
                    minimalDisjunctionalNormalFunction,
                    input
                    )
                );
            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            bool[] output = BitTools.GetOutputBool(KaterynaBodnarchukTask.KateBodnarchukCase);

            PrintWithTitle("Original Function", LogicConvert.ToOrFunction(PositiveMcCluskeyMethod.GetConstituents(output)));

            IList <Implicant> minimalDisjunctionalNormalForm =
                PositiveMcCluskeyMethod.GetImplicantDisjunctionNormalForm(output);

            PrintWithTitle("Optimized Function", LogicConvert.ToOrFunction(minimalDisjunctionalNormalForm));
            Console.WriteLine();

            bool[] outputInversed = output.Select(i => !i).ToArray();
            PrintWithTitle(
                "Original Inversed Function",
                LogicConvert.ToOrFunction(PositiveMcCluskeyMethod.GetConstituents(outputInversed)));

            IBooleanFunction minimalDisjunctionalNormalFormInversed =
                LogicConvert.ToOrFunction(PositiveMcCluskeyMethod.GetImplicantDisjunctionNormalForm(outputInversed));

            PrintWithTitle("Optimized Inversed Function", minimalDisjunctionalNormalFormInversed);
            Console.WriteLine();

            IBooleanFunction minimalDisjunctionalNormalFormDobleInversed = new NotFunction(minimalDisjunctionalNormalFormInversed);

            PrintWithTitle("Optimized Inversed Function Inversed", minimalDisjunctionalNormalFormDobleInversed);
            Console.WriteLine();

            IBooleanFunction andOfNotAndForm = RecursiveTransform.ExecuteRecursive(
                minimalDisjunctionalNormalFormDobleInversed, DeMorgansLaw.TryConvertNotOfOrToAndOfNot);

            PrintWithTitle("Not of not and", andOfNotAndForm);

            IBooleanFunction andOfOrForm = RecursiveTransform.ExecuteRecursive(
                andOfNotAndForm, DeMorgansLaw.TryConvertNotOfAndToOrOfNot);

            PrintWithTitle("And of or", andOfOrForm);

            IBooleanFunction doubleNotOfAndOfOrForm = NotFunction.DobleNot(andOfOrForm);
            IBooleanFunction notOfOrNotOfOrForm     = RecursiveTransform.ExecuteRecursive(
                doubleNotOfAndOfOrForm, DeMorgansLaw.TryConvertNotOfAndToOrOfNot);

            PrintWithTitle("NotOfOr/NotOfOr", notOfOrNotOfOrForm);

            uint input = uint.Parse(Console.ReadLine());

            Console.WriteLine("Output: " + notOfOrNotOfOrForm.Evaluate(new UInt32EvaluationContext(input)));
            Console.ReadKey();
        }