00001 package edu.tum.cs.logic; 00002 00003 import java.util.Map; 00004 00005 import edu.tum.cs.srl.Database; 00006 00007 public class Equality extends UngroundedFormula { 00008 public String left, right; 00009 00010 public Equality(String left, String right) { 00011 this.left = left; 00012 this.right = right; 00013 } 00014 00015 public String toString() { 00016 return left + "=" + right; 00017 } 00018 00019 @Override 00020 public void getVariables(Database db, Map<String, String> ret) { 00021 } 00022 00023 @Override 00024 public Formula ground(Map<String, String> binding, WorldVariables vars, Database db) throws Exception { 00025 String a = binding.get(left); 00026 if(a == null) a = left; 00027 String b = binding.get(right); 00028 if(b == null) b = right; 00029 return TrueFalse.getInstance(a == b); 00030 } 00031 00032 @Override 00033 public Formula toCNF() { 00034 throw new RuntimeException("Cannot convert ungrounded formula to CNF."); 00035 } 00036 00037 @Override 00038 public Formula toNNF() { 00039 throw new RuntimeException("Cannot convert ungrounded formula to NNF."); 00040 } 00041 }