Example #1
0
        /**
         * Collect a set of clauses from a list of given sentences.
         *
         * @param cnfSentences
         *            a list of CNF sentences from which to collect clauses.
         * @return a set of all contained clauses.
         * @throws IllegalArgumentException
         *             if any of the given sentences are not in CNF.
         */
        public static ISet <Clause> getClausesFrom(params Sentence[] cnfSentences)
        {
            ISet <Clause> result = CollectionFactory.CreateSet <Clause>();

            ClauseCollector clauseCollector = new ClauseCollector();

            foreach (Sentence cnfSentence in cnfSentences)
            {
                result = cnfSentence.accept(clauseCollector, result);
            }

            return(result);
        }
Example #2
0
        /**
         * Returns the specified sentence in its logically equivalent conjunction of
         * clauses.
         *
         * @param s
         *            a propositional logic sentence
         *
         * @return the input sentence converted to it logically equivalent
         *         conjunction of clauses.
         */
        public static ConjunctionOfClauses convert(Sentence s)
        {
            ConjunctionOfClauses result = null;

            Sentence cnfSentence = ConvertToCNF.convert(s);

            ICollection <Clause> clauses = CollectionFactory.CreateQueue <Clause>();

            clauses.AddAll(ClauseCollector.getClausesFrom(cnfSentence));

            result = new ConjunctionOfClauses(clauses);

            return(result);
        }