edu.cs.ai.kreator.logic
Class GeneralizedPredicate

java.lang.Object
  extended by edu.cs.ai.kreator.logic.GeneralizedPredicate
All Implemented Interfaces:
java.lang.Comparable<GeneralizedPredicate>

public class GeneralizedPredicate
extends java.lang.Object
implements java.lang.Comparable<GeneralizedPredicate>

This class models a generalized predicate. In contrast to ordinary predicates in first-order logic, this predicate has not necessarily the range space {true,false} but can have an arbitraly state space.

Author:
Matthias Thimm, Marc Finthammer, Sebastian Loh

Field Summary
static org.apache.log4j.Logger LOG
           
 
Method Summary
 int compareTo(GeneralizedPredicate other)
           
static GeneralizedPredicate create(LanguageFactory languageFactory, java.lang.String name)
           
static GeneralizedPredicate create(LanguageFactory languageFactory, java.lang.String name, int arity)
           
static GeneralizedPredicate create(LanguageFactory languageFactory, java.lang.String name, int arity, java.util.List<Sort> argSorts)
           
static GeneralizedPredicate create(LanguageFactory languageFactory, java.lang.String name, int arity, java.util.List<Sort> argSorts, java.util.List<java.lang.String> range)
           
static GeneralizedPredicate create(LanguageFactory languageFactory, java.lang.String name, int arity, java.util.List<Sort> argSorts, java.util.List<java.lang.String> range, CombiningRule combiningRule)
           
static GeneralizedPredicate create(LanguageFactory languageFactory, java.lang.String name, int arity, java.util.List<Sort> argSorts, java.util.List<java.lang.String> range, CombiningRule combiningRule, java.util.List<java.lang.Integer> mutuallyExclusiveExhaustiveArgs)
          Creates the corresponding predicate.
static GeneralizedPredicate create(LanguageFactory languageFactory, java.lang.String name, java.util.List<Sort> argSorts)
           
static GeneralizedPredicate createOrGet(LanguageFactory languageFactory, java.lang.String name)
           
static GeneralizedPredicate createOrGet(LanguageFactory languageFactory, java.lang.String name, int arity)
           
static GeneralizedPredicate createOrGet(LanguageFactory languageFactory, java.lang.String name, int arity, java.util.List<Sort> argSorts)
           
static GeneralizedPredicate createOrGet(LanguageFactory languageFactory, java.lang.String name, int arity, java.util.List<Sort> argSorts, java.util.List<java.lang.String> range)
           
static GeneralizedPredicate createOrGet(LanguageFactory languageFactory, java.lang.String name, int arity, java.util.List<Sort> argSorts, java.util.List<java.lang.String> range, CombiningRule combiningRule, java.util.List<java.lang.Integer> mutuallyExclusiveExhaustiveArgs)
          Returns an already existing predicate or, if necessary, constructs a new predicate with the given name and parameters.
static GeneralizedPredicate createOrGet(LanguageFactory languageFactory, java.lang.String name, java.util.List<Sort> argSorts)
           
 boolean equals(java.lang.Object obj)
           
 Sort getArgSort(int argIndex)
           
 java.util.List<Sort> getArgSorts()
           
 int getArity()
           
 CombiningRule getCombiningRule()
           
 java.util.Set<GeneralizedAtom> getInstantiations(java.util.Collection<? extends Term> terms)
          Computes all atoms of this predicate with the given terms.
 LanguageFactory getLanguageFactory()
          Returns the LanguageFactory this prdicate object belongs to.
 java.lang.Object getMutuallyExclusiveExhaustiveArgs()
           
 java.lang.String getName()
           
 java.util.List<java.lang.String> getRange()
           
 boolean hasBooleanRange()
          Checks whether this predicate is logical, i.e., if its range equals {true,false}.
 int hashCode()
           
 java.lang.String toLatex()
          Returns a Latex grammar conform string to generate variables, rules (conditionals) etc.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
Method Detail

create

public static GeneralizedPredicate create(LanguageFactory languageFactory,
                                          java.lang.String name,
                                          int arity,
                                          java.util.List<Sort> argSorts,
                                          java.util.List<java.lang.String> range,
                                          CombiningRule combiningRule,
                                          java.util.List<java.lang.Integer> mutuallyExclusiveExhaustiveArgs)
                                   throws WriteProtectionException
Creates the corresponding predicate. Set sort to "null" if all arguments should be "thing".

Parameters:
languageFactory - the LanguageFactory the predicate will be registered to
name - a string.
arity - an int.
sorts - a list of sorts (or "null" if all arguments should be "thing").
range - a list of string.
combiningRule - a combining rule.
mutuallyExclusiveExhaustiveArgs - a list with the indices of respective arguments (relevant for MLNs only).
Returns:
a predicate.
Throws:
java.lang.IllegalArgumentException - if a predicate with the same name already exists
WriteProtectionException

create

public static GeneralizedPredicate create(LanguageFactory languageFactory,
                                          java.lang.String name,
                                          int arity,
                                          java.util.List<Sort> argSorts,
                                          java.util.List<java.lang.String> range,
                                          CombiningRule combiningRule)
                                   throws WriteProtectionException
Throws:
WriteProtectionException

create

public static GeneralizedPredicate create(LanguageFactory languageFactory,
                                          java.lang.String name,
                                          int arity,
                                          java.util.List<Sort> argSorts,
                                          java.util.List<java.lang.String> range)
                                   throws WriteProtectionException
Throws:
WriteProtectionException

create

public static GeneralizedPredicate create(LanguageFactory languageFactory,
                                          java.lang.String name,
                                          int arity,
                                          java.util.List<Sort> argSorts)
                                   throws WriteProtectionException
Throws:
WriteProtectionException

create

public static GeneralizedPredicate create(LanguageFactory languageFactory,
                                          java.lang.String name,
                                          java.util.List<Sort> argSorts)
                                   throws WriteProtectionException
Throws:
WriteProtectionException

create

public static GeneralizedPredicate create(LanguageFactory languageFactory,
                                          java.lang.String name,
                                          int arity)
                                   throws WriteProtectionException
Throws:
WriteProtectionException

create

public static GeneralizedPredicate create(LanguageFactory languageFactory,
                                          java.lang.String name)
                                   throws WriteProtectionException
Throws:
WriteProtectionException

createOrGet

public static GeneralizedPredicate createOrGet(LanguageFactory languageFactory,
                                               java.lang.String name,
                                               int arity,
                                               java.util.List<Sort> argSorts,
                                               java.util.List<java.lang.String> range,
                                               CombiningRule combiningRule,
                                               java.util.List<java.lang.Integer> mutuallyExclusiveExhaustiveArgs)
                                        throws WriteProtectionException
Returns an already existing predicate or, if necessary, constructs a new predicate with the given name and parameters. Set sort to "null" if all arguments should be "thing".

Parameters:
name - a string.
arity - an int.
sorts - a list of sorts (or "null" if all arguments should be "thing").
range - a list of string.
combiningRule - a combining rule.
mutuallyExclusiveExhaustiveArgs - a list with the indices of respective arguments (relevant for MLNs only).
Returns:
a predicate.
Throws:
WriteProtectionException

createOrGet

public static GeneralizedPredicate createOrGet(LanguageFactory languageFactory,
                                               java.lang.String name,
                                               int arity,
                                               java.util.List<Sort> argSorts,
                                               java.util.List<java.lang.String> range)
                                        throws WriteProtectionException
Throws:
WriteProtectionException

createOrGet

public static GeneralizedPredicate createOrGet(LanguageFactory languageFactory,
                                               java.lang.String name,
                                               int arity,
                                               java.util.List<Sort> argSorts)
                                        throws WriteProtectionException
Throws:
WriteProtectionException

createOrGet

public static GeneralizedPredicate createOrGet(LanguageFactory languageFactory,
                                               java.lang.String name,
                                               java.util.List<Sort> argSorts)
                                        throws WriteProtectionException
Throws:
WriteProtectionException

createOrGet

public static GeneralizedPredicate createOrGet(LanguageFactory languageFactory,
                                               java.lang.String name,
                                               int arity)
                                        throws WriteProtectionException
Throws:
WriteProtectionException

createOrGet

public static GeneralizedPredicate createOrGet(LanguageFactory languageFactory,
                                               java.lang.String name)
                                        throws WriteProtectionException
Throws:
WriteProtectionException

hasBooleanRange

public boolean hasBooleanRange()
Checks whether this predicate is logical, i.e., if its range equals {true,false}.

Returns:
"true" if this predicate is boolean.

getInstantiations

public java.util.Set<GeneralizedAtom> getInstantiations(java.util.Collection<? extends Term> terms)
Computes all atoms of this predicate with the given terms. If the given set of terms is empty and this predicate has at least one parameter, the set returned will be empty.

Parameters:
terms - a collection of terms.
Returns:
a set of atoms of this predicate.

getCombiningRule

public CombiningRule getCombiningRule()

getName

public java.lang.String getName()

getRange

public java.util.List<java.lang.String> getRange()

getArity

public int getArity()

getMutuallyExclusiveExhaustiveArgs

public java.lang.Object getMutuallyExclusiveExhaustiveArgs()

getArgSorts

public java.util.List<Sort> getArgSorts()
Returns:
the sort

getArgSort

public Sort getArgSort(int argIndex)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toLatex

public java.lang.String toLatex()
Description copied from interface: Latexable
Returns a Latex grammar conform string to generate variables, rules (conditionals) etc.

Returns:
a Latex grammar conform string.

compareTo

public int compareTo(GeneralizedPredicate other)
Specified by:
compareTo in interface java.lang.Comparable<GeneralizedPredicate>

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getLanguageFactory

public LanguageFactory getLanguageFactory()
Returns the LanguageFactory this prdicate object belongs to.

Returns:
the lang