Beispiel #1
0
        public override Proposition Nandify()
        {
            Negation negationOfLeftSuccessor = new Negation();

            negationOfLeftSuccessor.LeftSuccessor = LeftSuccessor;

            Negation negationOfRighSuccessor = new Negation();

            negationOfRighSuccessor.LeftSuccessor = RightSuccessor;

            Conjunction leftDisjunctionConjunct = new Conjunction();

            leftDisjunctionConjunct.LeftSuccessor  = negationOfLeftSuccessor;
            leftDisjunctionConjunct.RightSuccessor = negationOfRighSuccessor;

            Conjunction rightDisjunctionConjunct = new Conjunction();

            rightDisjunctionConjunct.LeftSuccessor  = LeftSuccessor;
            rightDisjunctionConjunct.RightSuccessor = RightSuccessor;

            Disjunction disjunction = new Disjunction();

            disjunction.LeftSuccessor  = leftDisjunctionConjunct;
            disjunction.RightSuccessor = rightDisjunctionConjunct;

            return(disjunction.Nandify());
        }
Beispiel #2
0
        private void CreateConnective(char connective)
        {
            Proposition result = null;

            // 'GetCorrespondingConnective'
            switch (connective)
            {
            case Negation.SYMBOL:
                result = new Negation();
                break;

            case Implication.SYMBOL:
                result = new Implication();
                break;

            case BiImplication.SYMBOL:
                result = new BiImplication();
                break;

            case Conjunction.SYMBOL:
                result = new Conjunction();
                break;

            case Disjunction.SYMBOL:
                result = new Disjunction();
                break;

            case Nand.SYMBOL:
                result = new Nand();
                break;

            case UniversalQuantifier.SYMBOL:
                result = new UniversalQuantifier(PopBoundVariable());
                break;

            case ExistentialQuantifier.SYMBOL:
                result = new ExistentialQuantifier(PopBoundVariable());
                break;
            }

            // 'CreateExpression'
            // The symbols[symbols.Count - 1] can always be done. Placement is dependent on Unary or Binary connective.
            if (result is BinaryConnective)
            {
                ((BinaryConnective)result).LeftSuccessor  = symbols[symbols.Count - 2];
                ((BinaryConnective)result).RightSuccessor = symbols[symbols.Count - 1];
                symbols.RemoveAt(symbols.Count - 1);
                symbols.RemoveAt(symbols.Count - 1);
            }
            else
            {
                ((UnaryConnective)result).LeftSuccessor = symbols[symbols.Count - 1];
                symbols.RemoveAt(symbols.Count - 1);
            }

            // Now the expression is a symbol in case a nested connective needs to use it
            // as right or left successor.
            symbols.Add(result);
        }
Beispiel #3
0
        public override Proposition Copy()
        {
            Disjunction copy = new Disjunction();

            copy.LeftSuccessor  = LeftSuccessor.Copy();
            copy.RightSuccessor = RightSuccessor.Copy();

            return(copy);
        }
Beispiel #4
0
        public override Proposition Nandify()
        {
            Negation negation = new Negation();

            negation.LeftSuccessor = LeftSuccessor;
            Disjunction disjunction = new Disjunction();

            disjunction.LeftSuccessor  = negation;
            disjunction.RightSuccessor = RightSuccessor;

            return(disjunction.Nandify());
        }
Beispiel #5
0
        public static Proposition CreateTautologyFromProposition(Proposition variable)
        {
            if (variable == null)
            {
                throw new NullReferenceException("A proposition is required to create a tautology from it!");
            }

            Disjunction tautology = new Disjunction();

            tautology.LeftSuccessor = variable; // A
            Negation negatedVariable = new Negation();

            negatedVariable.LeftSuccessor = variable;
            tautology.RightSuccessor      = negatedVariable; // A | ~(A) == 1

            return(tautology);
        }
Beispiel #6
0
        private List <Proposition> CreateCorrespondingDisjuncts(List <Proposition> propositionList)
        {
            while (propositionList.Count > 1)
            {
                Disjunction disjunct = new Disjunction();

                disjunct.LeftSuccessor  = propositionList[0];
                disjunct.RightSuccessor = propositionList[1];

                propositionList.RemoveAt(1);
                propositionList.RemoveAt(0);

                propositionList.Add(disjunct);
            }

            return(propositionList);
        }