public static void quineTest() { int[] minterms1 = new int[10] { 0, 1, 2, 5, 6, 7, 8, 9, 10, 14 }; Quine quine1 = new Quine(minterms1, 4); System.Console.WriteLine(quine1.ToString()); quine1.simplify(); }
public void quineTest() { //int[] minterms1 = new int[10] {0, 1, 2, 5, 6, 7, 8, 9, 10, 14}; int[] minterms1 = new int[] { 0, 1, 2, 5, 6, 7 }; BooleanAlgebra.Quine quine1 = new BooleanAlgebra.Quine(minterms1, 3); List <Implicant> essential = quine1.simplify(); System.Console.WriteLine(quine1.ToString()); Console.WriteLine("The Expression is"); Console.WriteLine(Implicant.ConvertToExpression(essential)); }
/* * 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())); }
//Gets the simplest Expression representing this kmap public String getSimpleExpression() { Quine tempQuine = new Quine(this.minterms); return(Implicant.ConvertToExpression(tempQuine.simplify())); }