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

aima.core.probability.proposition.NotProposition 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.probability.proposition;

import java.util.Map;

import aima.core.probability.RandomVariable;

public class NotProposition extends AbstractProposition implements
		UnarySentenceProposition {

	private Proposition proposition;
	//
	private String toString = null;

	public NotProposition(Proposition prop) {
		if (null == prop) {
			throw new IllegalArgumentException(
					"Proposition to be negated must be specified.");
		}
		// Track nested scope
		addScope(prop.getScope());
		addUnboundScope(prop.getUnboundScope());

		proposition = prop;
	}

	@Override
	public boolean holds(Map possibleWorld) {
		return !proposition.holds(possibleWorld);
	}

	@Override
	public String toString() {
		if (null == toString) {
			StringBuilder sb = new StringBuilder();
			sb.append("(NOT ");
			sb.append(proposition.toString());
			sb.append(")");

			toString = sb.toString();
		}
		return toString;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy