Exemplo n.º 1
0
        public object visitConnectedSentence(ConnectedSentence sentence, object arg)
        {
            ArgData  ad     = (ArgData)arg;
            Sentence first  = sentence.getFirst();
            Sentence second = sentence.getSecond();

            first.accept(this, arg);
            if (Connectors.isAND(sentence.getConnector()))
            {
                ad.clauses.Add(new Clause());
            }
            second.accept(this, arg);

            return(sentence);
        }
Exemplo n.º 2
0
        public object visitConnectedSentence(ConnectedSentence sentence, object arg)
        {
            // Distribute V over ^:

            // This will cause flattening out of nested ^s and Vs
            Sentence alpha = (Sentence)sentence.getFirst().accept(this, arg);
            Sentence beta  = (Sentence)sentence.getSecond().accept(this, arg);

            // (alpha V (beta ^ gamma)) equivalent to
            // ((alpha V beta) ^ (alpha V gamma))
            if (Connectors.isOR(sentence.getConnector()) &&
                beta is ConnectedSentence)
            {
                ConnectedSentence betaAndGamma = (ConnectedSentence)beta;
                if (Connectors.isAND(betaAndGamma.getConnector()))
                {
                    beta = betaAndGamma.getFirst();
                    Sentence gamma = betaAndGamma.getSecond();
                    return(new ConnectedSentence(Connectors.AND,
                                                 (Sentence)(new ConnectedSentence(Connectors.OR, alpha, beta)).accept(this, arg),
                                                 (Sentence)(new ConnectedSentence(Connectors.OR, alpha, gamma)).accept(this, arg)));
                }
            }

            // ((alpha ^ gamma) V beta) equivalent to
            // ((alpha V beta) ^ (gamma V beta))
            if (Connectors.isOR(sentence.getConnector()) &&
                alpha is ConnectedSentence)
            {
                ConnectedSentence alphaAndGamma = (ConnectedSentence)alpha;
                if (Connectors.isAND(alphaAndGamma.getConnector()))
                {
                    alpha = alphaAndGamma.getFirst();
                    Sentence gamma = alphaAndGamma.getSecond();
                    return(new ConnectedSentence(Connectors.AND,
                                                 (Sentence)(new ConnectedSentence(Connectors.OR, alpha,
                                                                                  beta)).accept(this, arg),
                                                 (Sentence)(new ConnectedSentence(Connectors.OR, gamma,
                                                                                  beta)).accept(this, arg)));
                }
            }

            return(new ConnectedSentence(sentence.getConnector(), alpha, beta));
        }
Exemplo n.º 3
0
        public object visitConnectedSentence(ConnectedSentence sentence, object arg)
        {
            Sentence alpha = (Sentence)sentence.getFirst().accept(this, arg);
            Sentence beta  = (Sentence)sentence.getSecond().accept(this, arg);

            // Eliminate <=>, bi-conditional elimination,
            // replace (alpha <=> beta) with (~alpha V beta) ^ (alpha V ~beta).
            if (Connectors.isBICOND(sentence.getConnector()))
            {
                Sentence first  = new ConnectedSentence(Connectors.OR, new NotSentence(alpha), beta);
                Sentence second = new ConnectedSentence(Connectors.OR, alpha, new NotSentence(beta));

                return(new ConnectedSentence(Connectors.AND, first, second));
            }

            // Eliminate =>, implication elimination,
            // replacing (alpha => beta) with (~alpha V beta)
            if (Connectors.isIMPLIES(sentence.getConnector()))
            {
                return(new ConnectedSentence(Connectors.OR, new NotSentence(alpha), beta));
            }

            return(new ConnectedSentence(sentence.getConnector(), alpha, beta));
        }