001 package aima.logic.fol.inference.proof; 002 003 import java.util.ArrayList; 004 import java.util.Collections; 005 import java.util.List; 006 import java.util.Map; 007 008 import aima.logic.fol.kb.data.Clause; 009 import aima.logic.fol.parsing.ast.Term; 010 import aima.logic.fol.parsing.ast.Variable; 011 012 /** 013 * @author Ciaran O'Reilly 014 * 015 */ 016 public class ProofStepClauseBinaryResolvent extends AbstractProofStep { 017 private List<ProofStep> predecessors = new ArrayList<ProofStep>(); 018 private Clause resolvent = null; 019 private Clause parent1, parent2 = null; 020 private Map<Variable, Term> subst = null; 021 private Map<Variable, Term> renameSubst = null; 022 023 public ProofStepClauseBinaryResolvent(Clause resolvent, Clause parent1, 024 Clause parent2, Map<Variable, Term> subst, 025 Map<Variable, Term> renameSubst) { 026 this.resolvent = resolvent; 027 this.parent1 = parent1; 028 this.parent2 = parent2; 029 this.subst = subst; 030 this.renameSubst = renameSubst; 031 this.predecessors.add(parent1.getProofStep()); 032 this.predecessors.add(parent2.getProofStep()); 033 } 034 035 // 036 // START-ProofStep 037 public List<ProofStep> getPredecessorSteps() { 038 return Collections.unmodifiableList(predecessors); 039 } 040 041 public String getProof() { 042 return resolvent.toString(); 043 } 044 045 public String getJustification() { 046 int lowStep = parent1.getProofStep().getStepNumber(); 047 int highStep = parent2.getProofStep().getStepNumber(); 048 049 if (lowStep > highStep) { 050 lowStep = highStep; 051 highStep = parent1.getProofStep().getStepNumber(); 052 } 053 054 return "Resolution: " + lowStep + "," + highStep + " " + subst + ", " 055 + renameSubst; 056 } 057 // END-ProofStep 058 // 059 }