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

aima.core.logic.fol.inference.proof.ProofStepClauseBinaryResolvent 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.proof;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import aima.core.logic.fol.kb.data.Clause;
import aima.core.logic.fol.kb.data.Literal;
import aima.core.logic.fol.parsing.ast.Term;
import aima.core.logic.fol.parsing.ast.Variable;

/**
 * @author Ciaran O'Reilly
 * 
 */
public class ProofStepClauseBinaryResolvent extends AbstractProofStep {
	private List predecessors = new ArrayList();
	private Clause resolvent = null;
	private Literal posLiteral = null;
	private Literal negLiteral = null;
	private Clause parent1, parent2 = null;
	private Map subst = new LinkedHashMap();
	private Map renameSubst = new LinkedHashMap();

	public ProofStepClauseBinaryResolvent(Clause resolvent, Literal pl,
			Literal nl, Clause parent1, Clause parent2,
			Map subst, Map renameSubst) {
		this.resolvent = resolvent;
		this.posLiteral = pl;
		this.negLiteral = nl;
		this.parent1 = parent1;
		this.parent2 = parent2;
		this.subst.putAll(subst);
		this.renameSubst.putAll(renameSubst);
		this.predecessors.add(parent1.getProofStep());
		this.predecessors.add(parent2.getProofStep());
	}

	//
	// START-ProofStep
	public List getPredecessorSteps() {
		return Collections.unmodifiableList(predecessors);
	}

	public String getProof() {
		return resolvent.toString();
	}

	public String getJustification() {
		int lowStep = parent1.getProofStep().getStepNumber();
		int highStep = parent2.getProofStep().getStepNumber();

		if (lowStep > highStep) {
			lowStep = highStep;
			highStep = parent1.getProofStep().getStepNumber();
		}

		return "Resolution: " + lowStep + ", " + highStep + "  [" + posLiteral
				+ ", " + negLiteral + "], subst=" + subst + ", renaming="
				+ renameSubst;
	}
	// END-ProofStep
	//
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy