001 package aima.logic.fol.kb.data; 002 003 import aima.logic.fol.parsing.ast.AtomicSentence; 004 005 /** 006 * @see http://logic.stanford.edu/classes/cs157/2008/lectures/lecture13.pdf 007 */ 008 009 /** 010 * @author Ciaran O'Reilly 011 * 012 */ 013 public class ReducedLiteral extends Literal { 014 private String strRep = null; 015 016 public ReducedLiteral(AtomicSentence atom) { 017 super(atom); 018 } 019 020 public ReducedLiteral(AtomicSentence atom, boolean negated) { 021 super(atom, negated); 022 } 023 024 public Literal newInstance(AtomicSentence atom) { 025 return new ReducedLiteral(atom, isNegativeLiteral()); 026 } 027 028 public String toString() { 029 if (null == strRep) { 030 StringBuilder sb = new StringBuilder(); 031 sb.append("["); 032 if (isNegativeLiteral()) { 033 sb.append("~"); 034 } 035 sb.append(getAtomicSentence().toString()); 036 sb.append("]"); 037 strRep = sb.toString(); 038 } 039 040 return strRep; 041 } 042 }