Example #1
0
        //returns the simplest form of this quine in booleanexpression format as a string
        public String ExpressionString()
        {
            if (!this.fullySimplified)
            {
                this.simplify();
            }

            return(Implicant.ConvertToExpression(this.essentialImplicants));
        }
Example #2
0
        /*
         * Simplifies an expression and makes sure the same previous variables are used again in the new expression that is returned
         */
        public BooleanExpression simplify()
        {
            if (!this.hasTruthTable())
            {
                this.GenerateTruthTable();
            }
            Quine            simplifiedExpression = new Quine(this.truthTable.minterms.ToArray(), this.Variables.Count);
            List <Implicant> essentialImplicants  = simplifiedExpression.simplify();

            StringBuilder newExpression = new StringBuilder(Implicant.ConvertToExpression(essentialImplicants));

            //Console.WriteLine("Intermediate expression: " + newExpression.ToString());

            for (int i = 0; i < this.VariableNodes.Keys.Count; i++)
            {
                newExpression.Replace($"{(char)('A' + i)}", this.VariableNodes.Keys.ElementAt(i).ToLower());
                //Console.WriteLine("Replacing " + $"{(char)('A' + i)}" + " with " + this.VariableNodes.Keys.ElementAt(i));
            }

            return(new BooleanExpression(newExpression.ToString()));
        }
Example #3
0
        //Gets the simplest Expression representing this kmap
        public String getSimpleExpression()
        {
            Quine tempQuine = new Quine(this.minterms);

            return(Implicant.ConvertToExpression(tempQuine.simplify()));
        }