Example #1
0
        public LogicForm()
        {
            InitializeComponent();

            logicApp             = new LogicApp(new Parser());
            semanticTableauxApp  = new SemanticTableauxApp(new Parser());
            propositionGenerator = new PropositionGenerator();
        }
Example #2
0
        public Proposition CreateDisjunctiveNormalForm()
        {
            List <Proposition> propositionList = GenerateDisjunctiveNormalFormEquivalentPropositions();

            // Check for missing variables.
            HashSet <Proposition> missingVariables = GetMissingVariables(propositionList);

            if (missingVariables.Count == propositionVariablesSet.Count)
            {
                if (propositionList.Count > 0)
                {
                    Proposition p = propositionList[0];
                    propositionList.Remove(p);

                    if (p.GetType() == typeof(True))
                    {
                        // Create tautologies.
                        foreach (Proposition variable in missingVariables)
                        {
                            propositionList.Add(PropositionGenerator.CreateTautologyFromProposition(variable));
                        }
                    }
                }
                else
                {
                    // Create contradictions.
                    foreach (Proposition variable in missingVariables)
                    {
                        propositionList.Add(PropositionGenerator.CreateContradictionFromProposition(variable));
                    }
                }
            }

            // If we miss one or more variables but not all, this indicates that those variables
            // had no meaning in the original expression. Thus by logical equivalence we can say that
            // the expression would be equivalent to for ex: A & (B | ~(B)), the truth value of B
            // does not matter thus we can restate this as A | 0 which means we are totally reliant
            // on the truth value of A which can be obtained by creating a contradiction of
            // the variable that does not matter (B) in this case to keep the result column of equal
            // length, this would result in A | (B & ~(B)) which IS in DNF
            if (missingVariables.Count > 0 && missingVariables.Count < propositionVariablesSet.Count)
            {
                foreach (Proposition missingVariable in missingVariables)
                {
                    propositionList.Add(PropositionGenerator.CreateContradictionFromProposition(missingVariable));
                }
            }

            propositionList = CreateCorrespondingDisjuncts(propositionList);

            return(propositionList[0]);
        }