|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectai.krr.fol.Sentence
ai.krr.fol.Atom
public class Atom
An Atom is one of the most basic building blocks for a Sentence. It simply consists of a predicate over some arguments that can be either true or false.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ai.krr.fol.Sentence |
---|
Sentence.SubSentenceIterator |
Constructor Summary | |
---|---|
Atom(NamedSymbol pSymbol,
java.util.List<Term> someTerms)
This constructor for an Atom takes a predicate Symbol and a List of argument Terms. |
|
Atom(NamedSymbol pSymbol,
Term... someTerms)
This constructor for an Atom takes a predicate Symbol and a number of argument Terms. |
Method Summary | |
---|---|
protected void |
addBoundVariables(java.util.Set<Variable> bound)
This function adds the bound Variables in this Sentence to the given Set. |
protected void |
addConstants(java.util.Set<Symbol> sys)
This function adds all the constant Symbols used in this Sentence to the given Set. |
protected void |
addFreeVariables(java.util.Set<Variable> free,
java.util.Set<Variable> bound)
This function adds the free Variables in this Sentence to the first given Set. |
protected void |
addFunctions(java.util.Map<Symbol,java.lang.Integer> sys)
This function adds all the function Symbols used in this Sentence to the given Set. |
protected void |
addPredicates(java.util.Map<NamedSymbol,java.lang.Integer> sys)
This function adds all the predicate Symbols used in this Sentence to the given Set. |
Atom |
clone()
Returns a shallow copy of this Atom. |
Atom |
clone(Substitution s)
Returns a deep copy of this Atom with Variables replaced according to the given Substitution. |
int |
compareTo(Atom other)
This function compares this Atom to the given Atom. |
int |
compareTo(Sentence other)
This function compares this Atom to the given Sentence. |
boolean |
equals(Atom other)
A Atom is equal to any other Atom that consists of an equal predicate symbol followed by an equal number of equal Terms. |
boolean |
equals(java.lang.Object obj)
A Atom is only equal to another Atom. |
BooleanSymbol |
evaluate(Interpretation ipt,
Substitution s)
This function evaluates this Sentence under the given Interpretation and Substitution for Variables. |
boolean |
exceedsDepth(int depth)
This function tests whether this Sentence exceeds the given depth which should be a non-negative integer. |
Term[] |
getArguments()
This function returns the argument Terms of this Atom. |
int |
getClassOrderIndex()
This function returns the index used for ordering Sentences across different classes. |
int |
getDepth()
This function returns the nesting depth of this Sentence. |
NamedSymbol |
getPredicate()
This function returns the predicate symbol used in this Atom which is a NamedSymbol. |
int |
hashCode()
This function returns the hash code of this Atom. |
boolean |
isFunctionFree()
This function tests whether this Atom contains any FunctionTerms. |
boolean |
isGround()
This function tests whether this Atom contains any Variables. |
protected Sentence |
skolemize(boolean isNegated,
Term[] uqVars,
Substitution s)
This function computes a skolemized version of this Sentence. |
protected Sentence |
toCNF(boolean isNegated)
This function returns a new Literal which contains the proposition contained in this Atom. |
protected Sentence |
toDNF(boolean isNegated)
This function returns a new Literal which contains the proposition contained in this Atom. |
java.lang.String |
toString()
A Atom is printed as <predicate> ( <Term>+ ). |
boolean |
unify(Atom other,
Substitution s)
This function attempts to extend the given Substitution so that this Atom and the given Atom are unified. |
Methods inherited from class ai.krr.fol.Sentence |
---|
allSubSentences, getBoundVariables, getConstants, getFreeVariables, getFunctions, getPredicates, prettyPrint, read, skolemize, toClauseForm, toCNF, toDNF, write |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Atom(NamedSymbol pSymbol, java.util.List<Term> someTerms)
This constructor for an Atom takes a predicate Symbol and a List of argument Terms.
pSymbol
- the predicate symbolsomeTerms
- the List of argument Termspublic Atom(NamedSymbol pSymbol, Term... someTerms)
This constructor for an Atom takes a predicate Symbol and a number of argument Terms.
pSymbol
- the function symbolsomeTerms
- the argument TermsMethod Detail |
---|
public Atom clone()
Returns a shallow copy of this Atom. Argument Terms in the copy will be the same as the original ones.
clone
in class Sentence
public Atom clone(Substitution s)
Returns a deep copy of this Atom with Variables replaced according to the
given Substitution. Symbols in the copy will be the same as the original
ones but Variables will be replaced by the respective Terms in the given
Substitution. The function uses Term.clone(Substitution)
to
generate the copies of all the argument Terms in this Atom.
clone
in class Sentence
s
- the Substitution that tells us how to replace Variables
public int getDepth()
This function returns the nesting depth of this Sentence. The depth of an Atom is the depth of the deepest Term it contains plus one.
getDepth
in class Sentence
public boolean exceedsDepth(int depth)
This function tests whether this Sentence exceeds the given depth which should be a non-negative integer.
exceedsDepth
in class Sentence
depth
- the depth value that is tested for
public final int getClassOrderIndex()
This function returns the index used for ordering Sentences across different classes. This index of this class is defined to be 1.
getClassOrderIndex
in class Sentence
public int compareTo(Sentence other)
This function compares this Atom to the given Sentence. The order between different kinds of Sentence is arbitrarily defined as (ascending): TruthValue, Atom, Literal, NegatedSentence, ConnectedSentence, BinaryConnectedSentence, QuantifiedSentence.
compareTo
in interface java.lang.Comparable<Sentence>
compareTo
in class Sentence
other
- the Sentence to which this Atom is to be compared
public BooleanSymbol evaluate(Interpretation ipt, Substitution s)
This function evaluates this Sentence under the given Interpretation and Substitution for Variables. Note that the given Substitution must ground all the free Variables occurring in this Sentence. If this Sentence is already ground the given Substitution may be null. If all Atoms and Terms occurring in the Sentence have a value assigned by the Interpretation the result will be a BooleanSymbol. Otherwise it will be null.
evaluate
in class Sentence
ipt
- the Interpretation giving values for Atoms and Termss
- the Substitution for Variables occurring in this Term
public final NamedSymbol getPredicate()
This function returns the predicate symbol used in this Atom which is a NamedSymbol.
public final Term[] getArguments()
This function returns the argument Terms of this Atom. These should not be modified as this class cashes the hash value of of the Atom.
public boolean isFunctionFree()
This function tests whether this Atom contains any FunctionTerms. This is true only if none of the arguments is a FunctionTerm.
public boolean isGround()
This function tests whether this Atom contains any Variables. This is true only if one of the arguments contains a Variable.
public boolean unify(Atom other, Substitution s)
This function attempts to extend the given Substitution so that this Atom and the given Atom are unified. It returns true if and only if this is possible. Unification succeeds only if the two predicate symbols are equal and the Substitution can be extended to unify all arguments.
other
- the other Atom this Atom is to be unified withs
- the Substitution to be extended for the unification
public int compareTo(Atom other)
This function compares this Atom to the given Atom. The order between Atoms is defined by the order of the predicate symbols and the argument Terms they contain. First the predicate symbols are compared. Next, the first argument Terms are compared and if they are equal the second argument Terms are compared etc. It is like an alphabetical sorting.
other
- the Atom to which this Atom is to be compared
protected void addConstants(java.util.Set<Symbol> sys)
This function adds all the constant Symbols used in this Sentence to the given Set.
addConstants
in class Sentence
sys
- the Set that will contain all the Constantsprotected void addFunctions(java.util.Map<Symbol,java.lang.Integer> sys)
This function adds all the function Symbols used in this Sentence to the given Set.
addFunctions
in class Sentence
sys
- the Set that will contain all the function namesprotected void addPredicates(java.util.Map<NamedSymbol,java.lang.Integer> sys)
This function adds all the predicate Symbols used in this Sentence to the given Set.
addPredicates
in class Sentence
sys
- the Set that will contain all the predicate namesprotected void addFreeVariables(java.util.Set<Variable> free, java.util.Set<Variable> bound)
This function adds the free Variables in this Sentence to the first given Set. Variables in the second given Set are bound and will not be added.
addFreeVariables
in class Sentence
free
- a Set of free Variables that will be extendedbound
- a Set of bound Variablesprotected final void addBoundVariables(java.util.Set<Variable> bound)
This function adds the bound Variables in this Sentence to the given Set. This implementation does not modify the given Set.
addBoundVariables
in class Sentence
bound
- a Set of bound Variables that will be extendedprotected Sentence skolemize(boolean isNegated, Term[] uqVars, Substitution s)
This function computes a skolemized version of this Sentence. It returns a Literal that has a sign according to the given boolean, the predicate from this Atom, and clones of the arguments under the given Substitution.
skolemize
in class Sentence
isNegated
- whether the Sentence is negateduqVars
- the known universally quantified Variables at this points
- the Substitution for Variable replacements
protected Sentence toCNF(boolean isNegated)
This function returns a new Literal which contains the proposition contained in this Atom. The given boolean indicates whether the new Literal is to be negated.
toCNF
in class Sentence
isNegated
- whether the Literal has to be negated
protected Sentence toDNF(boolean isNegated)
This function returns a new Literal which contains the proposition contained in this Atom. The given boolean indicates whether the new Literal is to be negated.
toDNF
in class Sentence
isNegated
- whether the Literal has to be negated
public java.lang.String toString()
A Atom is printed as <predicate> ( <Term>+ ).
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
A Atom is only equal to another Atom.
equals
in class java.lang.Object
obj
- the Object this Atom is compared to
public boolean equals(Atom other)
A Atom is equal to any other Atom that consists of an equal predicate symbol followed by an equal number of equal Terms.
other
- the Object this Atom is compared to
public final int hashCode()
This function returns the hash code of this Atom.
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |