All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aima.core.logic.propositional.visitors.ConvertToCNF Maven / Gradle / Ivy

Go to download

AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.

The newest version!
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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy