コード例 #1
0
        /**
         * Distribute or (|) over and (&).
         *
         * @param sentence
         *            a propositional logic sentence. This sentence should already
         *            have biconditionals, and implications removed and negations
         *            moved inwards.
         * @return an equivalent Sentence to the input with or's distributed over
         *         and's.
         */
        public static Sentence distribute(Sentence sentence)
        {
            Sentence result = null;

            DistributeOrOverAnd distributeOrOverAnd = new DistributeOrOverAnd();

            result = sentence.accept(distributeOrOverAnd, null);

            return(result);
        }
コード例 #2
0
        /**
         * Returns the specified sentence in its logically equivalent conjunctive
         * normal form.
         *
         * @param s
         *            a propositional logic sentence
         *
         * @return the input sentence converted to it logically equivalent
         *         conjunctive normal form.
         */
        public static Sentence convert(Sentence s)
        {
            Sentence result = null;

            Sentence nnfSentence = ConvertToNNF.convert(s);
            Sentence cnfSentence = DistributeOrOverAnd.distribute(nnfSentence);

            result = cnfSentence;

            return(result);
        }