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

aima.core.logic.fol.inference.otter.defaultimpl.DefaultClauseSimplifier 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.fol.inference.otter.defaultimpl;

import java.util.ArrayList;
import java.util.List;

import aima.core.logic.fol.inference.Demodulation;
import aima.core.logic.fol.inference.otter.ClauseSimplifier;
import aima.core.logic.fol.kb.data.Clause;
import aima.core.logic.fol.parsing.ast.TermEquality;

/**
 * @author Ciaran O'Reilly
 * 
 */
public class DefaultClauseSimplifier implements ClauseSimplifier {

	private Demodulation demodulation = new Demodulation();
	private List rewrites = new ArrayList();

	public DefaultClauseSimplifier() {

	}

	public DefaultClauseSimplifier(List rewrites) {
		this.rewrites.addAll(rewrites);
	}

	//
	// START-ClauseSimplifier
	public Clause simplify(Clause c) {
		Clause simplified = c;

		// Apply each of the rewrite rules to
		// the clause
		for (TermEquality te : rewrites) {
			Clause dc = simplified;
			// Keep applying the rewrite as many times as it
			// can be applied before moving on to the next one.
			while (null != (dc = demodulation.apply(te, dc))) {
				simplified = dc;
			}
		}

		return simplified;
	}

	// END-ClauseSimplifier
	//
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy