aima.core.logic.propositional.visitors.ConvertToCNF Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
package aima.core.logic.propositional.visitors;
import aima.core.logic.propositional.parsing.ast.Sentence;
/**
* Convert a Sentence into an equivalent Conjunctive Normal Form (CNF) Sentence.
* A Sentence is in CNF if it is a conjunction of disjunction of literals.
*
* @author Ciaran O'Reilly
*/
public class ConvertToCNF {
/**
* 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;
}
}