예제 #1
0
파일: Conjunction.cs 프로젝트: bludyh/logix
 public Conjunction(Proposition left, Proposition right)
 {
     LeftOperand  = left;
     RightOperand = right;
 }
예제 #2
0
 public Implication(Proposition left, Proposition right)
 {
     LeftOperand  = left;
     RightOperand = right;
 }
예제 #3
0
 public Universal(Proposition predicate, List <Variable> boundVariables) : base(predicate, boundVariables)
 {
 }
예제 #4
0
 public Existential(Proposition predicate, List <Variable> boundVariables) : base(predicate, boundVariables)
 {
 }
예제 #5
0
파일: Quantifier.cs 프로젝트: bludyh/logix
 protected Quantifier(Proposition predicate, List <Variable> boundVariables)
 {
     Predicate      = predicate;
     BoundVariables = boundVariables;
 }
예제 #6
0
파일: Logix.cs 프로젝트: bludyh/logix
        private void ButtonRead_Click(object sender, EventArgs e)
        {
            try {
                // Update form
                textBoxInfix.Text            = "";
                textBoxVariables.Text        = "";
                groupBoxPropositions.Enabled = false;
                listBoxDisjuncNormal.Items.Clear();
                listBoxDisjuncSimple.Items.Clear();
                listBoxNand.Items.Clear();
                textBoxHexCode.Text = "";
                truthTable.Columns.Clear();
                truthTable.Rows.Clear();
                simplifiedTruthTable.Columns.Clear();
                simplifiedTruthTable.Rows.Clear();
                groupBoxPredicates.Enabled = false;
                listBoxBoundVariables.Items.Clear();
                listBoxUnboundVariables.Items.Clear();
                textBoxReplaceVariable.Text = "";
                buttonVisualize.Enabled     = true;
                buttonSTableaux.Enabled     = true;
                buttonClear.Enabled         = true;

                // Create proposition from user input
                proposition = Parser.Parse(input.Text);

                // Show infix formula
                textBoxInfix.Text = proposition.ToString();

                // Show variables
                proposition.Variables.Sort();
                foreach (var variable in proposition.Variables)
                {
                    textBoxVariables.Text += variable + " ";
                }

                if (!proposition.IsPredicate)
                {
                    // Enable propositions panel
                    groupBoxPropositions.Enabled = true;

                    // Show truth table
                    var table = proposition.CreateTruthTable();
                    foreach (var variable in table.Variables)
                    {
                        truthTable.Columns.Add(variable.ToString(), variable.ToString());
                    }
                    truthTable.Columns.Add(proposition.ToString(), proposition.ToString());
                    foreach (var row in table.Data)
                    {
                        truthTable.Rows.Add(row);
                    }
                    foreach (DataGridViewColumn col in truthTable.Columns)
                    {
                        col.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                        col.SortMode     = DataGridViewColumnSortMode.NotSortable;
                    }
                    truthTable.Columns[truthTable.ColumnCount - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                    // Show simplified truth table
                    var smpfdTable = table.Simplify();
                    foreach (var variable in smpfdTable.Variables)
                    {
                        simplifiedTruthTable.Columns.Add(variable.ToString(), variable.ToString());
                    }
                    simplifiedTruthTable.Columns.Add(proposition.ToString(), proposition.ToString());
                    foreach (var row in smpfdTable.Data)
                    {
                        simplifiedTruthTable.Rows.Add(row);
                    }

                    foreach (DataGridViewColumn col in simplifiedTruthTable.Columns)
                    {
                        col.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                        col.SortMode     = DataGridViewColumnSortMode.NotSortable;
                    }
                    simplifiedTruthTable.Columns[simplifiedTruthTable.ColumnCount - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                    // Show disjunctive normal formula
                    var disjuncNormal = table.CreateDisjunctiveFormula();
                    if (disjuncNormal != null)
                    {
                        listBoxDisjuncNormal.Items.Add(disjuncNormal);
                    }

                    // Show disjunctive simple formula
                    var disjuncSimple = smpfdTable.CreateDisjunctiveFormula();
                    if (disjuncSimple != null)
                    {
                        listBoxDisjuncSimple.Items.Add(disjuncSimple);
                    }

                    // Show NAND formula
                    var nand = proposition.Nandify();
                    listBoxNand.Items.Add(nand);

                    // Generate hex code
                    string result = "";
                    for (int i = table.Data.Count - 1; i >= 0; i--)
                    {
                        result += table.Data[i][table.Data[0].Length - 1];
                    }
                    textBoxHexCode.Text = Convert.ToInt32(result, 2).ToString("X");
                }
                else
                {
                    // Enable predicates panel
                    groupBoxPredicates.Enabled = true;

                    // Show bound variables
                    Parser.BoundVariables.Sort();
                    foreach (var variable in Parser.BoundVariables)
                    {
                        listBoxBoundVariables.Items.Add(variable);
                    }

                    // Show unbound variables
                    var unboundVariables = proposition.Variables.Except(Parser.BoundVariables).ToList();
                    unboundVariables.Sort();
                    foreach (var variable in unboundVariables)
                    {
                        listBoxUnboundVariables.Items.Add(variable);
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString());
                ResetForm();
            }
        }
예제 #7
0
파일: NotAnd.cs 프로젝트: bludyh/logix
 public NotAnd(Proposition left, Proposition right)
 {
     LeftOperand  = left;
     RightOperand = right;
 }
예제 #8
0
 public Negation(Proposition operand)
 {
     Operand = operand;
 }