public static BinaryConnective CreateBinaryConnectiveWithRandomSymbols(char binaryConnectiveSymbol)
        {
            BinaryConnective binaryConnective;

            switch (binaryConnectiveSymbol)
            {
            case Conjunction.SYMBOL:
                binaryConnective = new Conjunction();
                break;

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

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

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

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

            default:
                throw new ArgumentNullException("Could not convert symbol into a connective!");
            }

            binaryConnective.LeftSuccessor  = GetRandomPropositionSymbol();
            binaryConnective.RightSuccessor = GetRandomPropositionSymbol();

            return(binaryConnective);
        }
Exemple #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);
        }
Exemple #3
0
        public override Proposition Copy()
        {
            Nand copy = new Nand();

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

            return(copy);
        }
Exemple #4
0
        public override Proposition Nandify()
        {
            // ~(A) == ~(A & A) == A % A
            Nand        nand          = new Nand();
            Proposition nandifiedLeft = LeftSuccessor;

            if (LeftSuccessor.GetType() != typeof(Proposition))
            {
                nandifiedLeft = LeftSuccessor.Nandify();
            }

            nand.LeftSuccessor  = nandifiedLeft;
            nand.RightSuccessor = nandifiedLeft;

            return(nand);
        }
Exemple #5
0
        public override Proposition Nandify()
        {
            // P & Q == ~(~(P & Q))
            // Now ~(P & Q) == (P % Q)
            // And finally ~(P % Q) == (P % Q) % (P % Q)
            // Create the double negation equivalent of the conjunction.
            Nand nand = new Nand();

            nand.LeftSuccessor  = LeftSuccessor;
            nand.RightSuccessor = RightSuccessor;

            Negation negation = new Negation();

            negation.LeftSuccessor = nand;

            return(negation.Nandify());
        }
Exemple #6
0
        public override Proposition Nandify()
        {
            // P | Q == ~(~(P)) | ~(~(Q))
            // == ~(~(P) & ~(Q)) == ~(P) % ~(Q)
            Nand nand = new Nand();

            Negation negationOfLeftSuccessor = new Negation();

            negationOfLeftSuccessor.LeftSuccessor = LeftSuccessor;

            Negation negationOfRightSuccessor = new Negation();

            negationOfRightSuccessor.LeftSuccessor = RightSuccessor;

            nand.LeftSuccessor  = negationOfLeftSuccessor;
            nand.RightSuccessor = negationOfRightSuccessor;

            return(nand.Nandify());
        }
Exemple #7
0
        public virtual Proposition Nandify()
        {
            // A == ~(~(A))
            // ~(A) == ~(A ^ A) == A % A
            // ~(~(A ^ A)) == ~(A % A)
            // == (A % A) % (A % A)
            Nand nand1 = new Nand();
            Nand nand2 = new Nand();
            Nand nand3 = new Nand();

            nand2.LeftSuccessor  = this;
            nand2.RightSuccessor = this;

            nand3.LeftSuccessor  = this;
            nand3.RightSuccessor = this;

            nand1.LeftSuccessor  = nand2;
            nand1.RightSuccessor = nand3;

            return(nand1);
        }