edu.cs.ai.kreator.logic
Class Literal

java.lang.Object
  extended by edu.cs.ai.kreator.logic.Literal
All Implemented Interfaces:
Latexable, java.lang.Comparable<Literal>
Direct Known Subclasses:
SpiritGrammarConform

public abstract class Literal
extends java.lang.Object
implements Latexable, java.lang.Comparable<Literal>

This abstract class models a literal in first-order logic.

Author:
Matthias Thimm, Marc Finthammer, Sebastian Loh

Nested Class Summary
static class Literal.TruthValue
           
 
Constructor Summary
Literal()
           
 
Method Summary
abstract  boolean equals(java.lang.Object obj)
          compares if this literals is equal to the other literal.
 java.util.Set<java.util.Map<Variable,Term>> extendUnifier(java.util.Collection<? extends Literal> data, java.util.Map<Variable,Term> unifier)
          For the given unifier "u" thi method computes all extensions of "u" to a unifier "u2" such that "u2" transforms this literal into one given in data.
abstract  java.util.Map<Variable,Term> extendUnifier(Literal l, java.util.Map<Variable,Term> unifier)
          Extends the given unifier "u" to a unifier "u2" such that "u2" transforms this literal into the one given.
 java.util.Set<java.util.Map<Variable,Term>> extendUnifiers(java.util.Collection<? extends Literal> data, java.util.Collection<java.util.Map<Variable,Term>> unifiers)
          For any unifier "u" in "unifiers" this method computes all extensions of "u" to a unifier "u2" such that "u2" transforms this literal into one given in data.
abstract  GeneralizedAtom getAtom()
          Returns the atom of this literal.
abstract  Literal getComplement()
          Returns the complement (negation) of this literal.
abstract  java.util.Set<Constant> getConstants()
          Returns the set of constants, that appear in this literal.
abstract  java.util.Set<Literal> getInstantiations(LanguageFactory language)
          Computes all ground literals of this literal with the language, i.e.
abstract  java.util.List<Term> getParameters()
          Returns the list of parameters of that literal.
abstract  GeneralizedPredicate getPredicate()
          Returns the predicate of this literal.
 java.util.Map<Variable,Term> getUnifier(Literal l)
          Computes the unifier that is needed in order to transform this literal into the given one or "null" if this is not possible.
 java.util.Set<java.util.Map<Variable,Term>> getUnifiers(java.util.Collection<? extends Literal> data)
          Computes the set of all possible unifiers yielding a transformation from this literal into one given in data.
abstract  java.util.Set<Variable> getVariables()
          Returns the set of variables, that appear in this literal.
static boolean isConsistent(java.util.Collection<? extends Literal> data)
          Checks whether the given set of literals is consistent, i.e.
abstract  Literal substitute(java.util.Map<? extends Variable,? extends Term> substitution)
          This method substitutes in this literal each occurence of a variable that is a key in the given substitution map by its value in the same given substitution map.
 java.util.Set<Literal> substituteAll(java.util.Collection<java.util.Map<Variable,Term>> substitutions)
          For any substitution "s" given this method applies "s" to this literal and returns the set of all substitutions.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.cs.ai.kreator.logic.Latexable
toLatex
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

Literal

public Literal()
Method Detail

getVariables

public abstract java.util.Set<Variable> getVariables()
Returns the set of variables, that appear in this literal.

Returns:
the set of variables, that appear in this literal.

getConstants

public abstract java.util.Set<Constant> getConstants()
Returns the set of constants, that appear in this literal.

Returns:
the set of constants, that appear in this literal.

getParameters

public abstract java.util.List<Term> getParameters()
Returns the list of parameters of that literal.

Returns:
the list of parameters of that literal.

substitute

public abstract Literal substitute(java.util.Map<? extends Variable,? extends Term> substitution)
This method substitutes in this literal each occurence of a variable that is a key in the given substitution map by its value in the same given substitution map.

Parameters:
substitution - a map from variables to constants.
Returns:
a literal.

substituteAll

public java.util.Set<Literal> substituteAll(java.util.Collection<java.util.Map<Variable,Term>> substitutions)
For any substitution "s" given this method applies "s" to this literal and returns the set of all substitutions.

Parameters:
substitutions - a set of substitutions.
Returns:
a set of literals.

getInstantiations

public abstract java.util.Set<Literal> getInstantiations(LanguageFactory language)
Computes all ground literals of this literal with the language, i.e. with all constants appearing in the given language. If the given set of terms is empty and this literal has at least one free variable, the set returned will be empty.

Parameters:
language - a language.
Returns:
a set of ground literals of this literal.

getUnifier

public java.util.Map<Variable,Term> getUnifier(Literal l)
Computes the unifier that is needed in order to transform this literal into the given one or "null" if this is not possible.

Parameters:
l - a literal.
Returns:
a substitution from variables to terms.

getUnifiers

public java.util.Set<java.util.Map<Variable,Term>> getUnifiers(java.util.Collection<? extends Literal> data)
Computes the set of all possible unifiers yielding a transformation from this literal into one given in data.

Parameters:
data - a collection of literals.
Returns:
a set of substitutions from variables to terms.

extendUnifiers

public java.util.Set<java.util.Map<Variable,Term>> extendUnifiers(java.util.Collection<? extends Literal> data,
                                                                  java.util.Collection<java.util.Map<Variable,Term>> unifiers)
For any unifier "u" in "unifiers" this method computes all extensions of "u" to a unifier "u2" such that "u2" transforms this literal into one given in data.

Parameters:
data - a collection of literals.
unifiers - a collection of (partiel) unifiers.
Returns:
a set of (complete) unifiers.

extendUnifier

public java.util.Set<java.util.Map<Variable,Term>> extendUnifier(java.util.Collection<? extends Literal> data,
                                                                 java.util.Map<Variable,Term> unifier)
For the given unifier "u" thi method computes all extensions of "u" to a unifier "u2" such that "u2" transforms this literal into one given in data.

Parameters:
data - a collection of literals.
unifier - a (partial) unifier.
Returns:
a set of (complete) unifiers.

isConsistent

public static boolean isConsistent(java.util.Collection<? extends Literal> data)
Checks whether the given set of literals is consistent, i.e. if there are no two A, !A in data.

Parameters:
data - a collection of literals
Returns:
"true" if the given set is consistent.

extendUnifier

public abstract java.util.Map<Variable,Term> extendUnifier(Literal l,
                                                           java.util.Map<Variable,Term> unifier)
Extends the given unifier "u" to a unifier "u2" such that "u2" transforms this literal into the one given.

Parameters:
l - a literal
unifier - a (partial) unifier.
Returns:
a (complete) unifier.

getComplement

public abstract Literal getComplement()
Returns the complement (negation) of this literal.

Returns:
the complement (negation) of this literal.

getPredicate

public abstract GeneralizedPredicate getPredicate()
Returns the predicate of this literal.

Returns:
a bayesian predicate.

getAtom

public abstract GeneralizedAtom getAtom()
Returns the atom of this literal.

Returns:
the atom of this literal.

equals

public abstract boolean equals(java.lang.Object obj)
compares if this literals is equal to the other literal. Two Literals are equal if they are both positive or negative and have the same predicates incl. the same arguments and sorts.

Overrides:
equals in class java.lang.Object
Parameters:
lit -
Returns: