00001 package edu.tum.cs.logic; 00002 00003 import java.util.Map; 00004 00005 import edu.tum.cs.srl.Database; 00006 00007 public class Literal extends UngroundedFormula { 00008 public boolean isPositive; 00009 public Atom atom; 00010 00011 public Literal(boolean isPositive, Atom atom) { 00012 this.atom = atom; 00013 this.isPositive = isPositive; 00014 } 00015 00016 public String toString() { 00017 return isPositive ? atom.toString() : "!" + atom; 00018 } 00019 00020 @Override 00021 public void getVariables(Database db, Map<String, String> ret) throws Exception { 00022 atom.getVariables(db, ret); 00023 } 00024 00025 @Override 00026 public Formula ground(Map<String, String> binding, WorldVariables vars, Database db) throws Exception { 00027 return new GroundLiteral(isPositive, (GroundAtom)atom.ground(binding, vars, db)); 00028 } 00029 00030 @Override 00031 public Formula toCNF() { 00032 return this; 00033 } 00034 00035 @Override 00036 public Formula toNNF() { 00037 return this; 00038 } 00039 }