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

aima.core.logic.propositional.visitors.ConvertToNNF 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 Negation Normal Form (NNF) Sentence. A
 * Sentence is in NNF if negation is allowed only over atoms, and conjunction,
 * disjunction, and negation are the only allowed boolean connectives
 * 
 * @author Ciaran O'Reilly
 * 
 */
public class ConvertToNNF {

	/**
	 * Returns the specified sentence in its logically equivalent negation
	 * normal form.
	 * 
	 * @param s
	 *            a propositional logic sentence
	 * 
	 * @return the input sentence converted to it logically equivalent
	 *         negation normal form.
	 */
	public static Sentence convert(Sentence s) {
		Sentence result = null;

		Sentence biconditionalsRemoved = BiconditionalElimination.eliminate(s);
		Sentence implicationsRemoved = ImplicationElimination
				.eliminate(biconditionalsRemoved);
		Sentence notsMovedIn = MoveNotInwards
				.moveNotsInward(implicationsRemoved);

		result = notsMovedIn;

		return result;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy