public Proposition(string input_string) { this.input_string = input_string; if (input_string[0].Equals(not_sign)) { input_string = parseNegativeProposition(input_string); this.negative__ = true; } input_string = signHandler(input_string); input_string = bracketHandler(input_string); child_propositions = new List <Proposition>(); predicates = new List <Predicate>(); string first_proposition_string = parseInputString(input_string); if (first_proposition_string[0].Equals(not_sign) && first_proposition_string.Contains(',')) { first_proposition_string = parseNegativeProposition(first_proposition_string); first_negative = true; } if (first_proposition_string[0].Equals(and_sign) || first_proposition_string[0].Equals(equation_sign) || first_proposition_string[0].Equals(implication_sign) || first_proposition_string[0].Equals(or_sign)) { proposition_palce = 0; Proposition new_prop = new Proposition(first_proposition_string); if (first_negative) { new_prop.negative__ = true; } this.child_propositions.Add(new_prop); } else { predicates.Add(new Predicate(first_proposition_string)); } input_string = removeStringFromInputString(input_string, first_proposition_string); string second_proposition_string = parseInputString(input_string); if (second_proposition_string[0].Equals(not_sign) && second_proposition_string.Contains(',')) { second_proposition_string = parseNegativeProposition(second_proposition_string); second_negative = true; } if (second_proposition_string[0].Equals(and_sign) || second_proposition_string[0].Equals(equation_sign) || second_proposition_string[0].Equals(implication_sign) || second_proposition_string[0].Equals(or_sign)) { proposition_palce = 1; Proposition new_prop = new Proposition(second_proposition_string); if (second_negative) { new_prop.negative__ = true; } this.child_propositions.Add(new_prop); } else { predicates.Add(new Predicate(second_proposition_string)); } }
private void button1_Click(object sender, EventArgs e) { Reader reader = new Reader(text_box_input.Text); //cleaning the input string cleaned_string = reader.ProcessedInput; string binnary = ""; //generating the truth table string[,] table = reader.generateTruthTableWithUniqueChars(); //creating the array list for the simplifing string[,] new_table_for_simplification = new string[table.GetLength(0), table.GetLength(1) + 1]; //creating a data grid for (int row = 0; row < table.GetLength(0); row++) { string[] asd = new string[table.GetLength(1)]; for (int i = 0; i < table.GetLength(1); i++) { if (row != 0) { asd[i] = table[row, i]; } new_table_for_simplification[row, i] = table[row, i]; if (i == table.GetLength(1) - 1) { new_table_for_simplification[row, new_table_for_simplification.GetLength(1) - 1] = cleaned_string; } } if (row != 0) { string new_proposition = reader.replaceUniquePredicates(cleaned_string, asd); string value = Convert.ToInt16(new Proposition(new_proposition).calculate()).ToString(); binnary = value + binnary; new_table_for_simplification[row, table.GetLength(1)] = value; } } generateTableInForm(new_table_for_simplification); try { string strHex = Convert.ToInt32(binnary, 2).ToString("X"); text_box_output_hex.Text = strHex; } catch (Exception exception) { MessageBox.Show("string too big to convert it to hex"); } Console.WriteLine("staring simplifing"); Simplifyer simm = new Simplifyer(); string[,] simplifyed_table = simm.getSimplifyedTruthTable(new_table_for_simplification); generateFormSimplifiedTable(simplifyed_table); Console.WriteLine("staring normalizator"); //creating normalizer class Normalizator norm = new Normalizator(new_table_for_simplification, simplifyed_table); string norm_prop = norm.getDNFFromTruthTable(); text_box_output_dnf.Text = norm_prop; Proposition prop1 = new Proposition(cleaned_string); text_box_output_nand.Text = prop1.getPropositionNANDFormat(); string norm_prop_simplified = norm.getDNFFromSimplifiedTruthTable(); text_box_output_dnf_simplified.Text = norm_prop_simplified; cleaned_string = norm_prop; table = reader.generateTruthTableWithUniqueChars(); new_table_for_simplification = new string[table.GetLength(0), table.GetLength(1) + 1]; Console.WriteLine("starting truth table from dnf"); for (int row = 0; row < table.GetLength(0); row++) { string[] asd = new string[table.GetLength(1)]; for (int i = 0; i < table.GetLength(1); i++) { if (row != 0) { asd[i] = table[row, i]; } new_table_for_simplification[row, i] = table[row, i]; if (i == table.GetLength(1) - 1) { new_table_for_simplification[row, new_table_for_simplification.GetLength(1) - 1] = cleaned_string; } } if (row != 0) { string new_proposition = reader.replaceUniquePredicates(cleaned_string, asd); string value = Convert.ToInt16(new Proposition(new_proposition).calculate()).ToString(); new_table_for_simplification[row, table.GetLength(1)] = value; } } generateFormDNFTable(new_table_for_simplification); }