ai.krr.propositions
Class Atom

java.lang.Object
  extended by ai.krr.propositions.Sentence
      extended by ai.krr.propositions.Atom
All Implemented Interfaces:
inf.compilers.SyntaxAdaptable, java.lang.Cloneable, java.lang.Comparable<Sentence>

public class Atom
extends Sentence

An Atom is one of the most basic building blocks for a Sentence. It simply consists of a proposition that can be either true or false.

Author:
Gerhard Wickler

Field Summary
protected  NamedSymbol theSy
          the proposition symbol
 
Constructor Summary
Atom(NamedSymbol prop)
           This constructor for an Atom takes a NamedSymbol for the proposition.
 
Method Summary
 void addPropositions(java.util.Set<NamedSymbol> props)
           This function adds the propositions contained in this Sentence to the given Set.
 Atom clone()
           Cloning an Atom returns this Atom.
 int compareTo(Atom other)
           This function compares this Atom to the given Atom.
 int compareTo(Sentence stmt)
           This function compares this Sentence to the given Sentence.
 boolean equals(Atom other)
           An Atom is equal to another Atom that consists of an equal proposition symbol.
 boolean equals(java.lang.Object obj)
           An Atom is equal to another Atom that consists of an equal proposition symbol.
 BooleanSymbol evaluate(Interpretation ipt)
           This function evaluates this Sentence under the given Interpretation.
 int getClassOrderIndex()
           This function returns the index used for ordering Sentences across different classes.
 NamedSymbol getSymbol()
           This function returns the NamedSymbol that represents this proposition.
 int hashCode()
           This function returns the hash code of this Atom.
 boolean isAtom()
           This function tests whether this Sentence is an Atom.
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()
           An Atom is printed as the proposition symbol.
 
Methods inherited from class ai.krr.propositions.Sentence
addSubSentences, allSubSentences, exceedsDepth, getDepth, getPropositions, isLiteral, prettyPrint, read, toClauseForm, toCNF, toDNF, write
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

theSy

protected final NamedSymbol theSy
the proposition symbol

Constructor Detail

Atom

public Atom(NamedSymbol prop)

This constructor for an Atom takes a NamedSymbol for the proposition. The given Symbol must not be null.

Parameters:
prop - the proposition symbol
Method Detail

clone

public Atom clone()

Cloning an Atom returns this Atom.

Specified by:
clone in class Sentence
Returns:
an equal copy of this Atom

isAtom

public final boolean isAtom()

This function tests whether this Sentence is an Atom.

Overrides:
isAtom in class Sentence
Returns:
always true

addPropositions

public void addPropositions(java.util.Set<NamedSymbol> props)

This function adds the propositions contained in this Sentence to the given Set. Of course, the given Set must not be null.

Specified by:
addPropositions in class Sentence
Parameters:
props - the Set to which the NamedSymbols are added

evaluate

public BooleanSymbol evaluate(Interpretation ipt)

This function evaluates this Sentence under the given Interpretation. If all propositions occurring in the Sentence have a truth value assigned by the Interpretation the result will be either BooleanSymbol.TRUE or BooleanSymbol.FALSE. Otherwise the result will be null, indicating the truth value of this Sentence is undefined under the given Interpretation. For an Atom the returned truth value is simply the one assigned by the Interpretation.

Specified by:
evaluate in class Sentence
Parameters:
ipt - the Interpretation giving truth values for propositions
Returns:
the truth value of this Sentence under the given Interpretation

getClassOrderIndex

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.

Specified by:
getClassOrderIndex in class Sentence
Returns:
an integer indicating how this type of Sentence is to be ordered with respect to different types of Sentence

compareTo

public int compareTo(Sentence stmt)

This function compares this Sentence to the given Sentence. The order between different kinds of Sentence is arbitrarily defined as (ascending): TruthValue, Atom, Literal, NegatedSentence, ConnectedSentence, BinaryConnectedSentence.

Specified by:
compareTo in interface java.lang.Comparable<Sentence>
Specified by:
compareTo in class Sentence
Parameters:
stmt - the Sentence to which this Sentence is to be compared
Returns:
0 if the two Sentences are identical; -1 if the given Sentence should come after this Sentence; and +1 if the given Sentence should come before this Sentence

getSymbol

public final NamedSymbol getSymbol()

This function returns the NamedSymbol that represents this proposition.

Returns:
the Symbol that makes up this Atom

compareTo

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 NamedSymbols they contain.

Parameters:
other - the Atom to which this Atom is to be compared
Returns:
0 if the two Atoms are identical; -1 if the given Atom should come after this Atom; and +1 if the given Atom should come before this Atom

toCNF

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.

Specified by:
toCNF in class Sentence
Parameters:
isNegated - whether the Literal has to be negated
Returns:
a new Literal, possibly negative

toDNF

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.

Specified by:
toDNF in class Sentence
Parameters:
isNegated - whether the Literal has to be negated
Returns:
a new Literal, possibly negative

equals

public boolean equals(java.lang.Object obj)

An Atom is equal to another Atom that consists of an equal proposition symbol.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the Object this Atom is compared to
Returns:
whether the given Object equals this Atom

equals

public boolean equals(Atom other)

An Atom is equal to another Atom that consists of an equal proposition symbol.

Parameters:
other - the Atom this Atom is compared to
Returns:
whether the given Atom equals this Atom

hashCode

public final int hashCode()

This function returns the hash code of this Atom.

Overrides:
hashCode in class java.lang.Object
Returns:
a positive integer that may be used for hashing

toString

public java.lang.String toString()

An Atom is printed as the proposition symbol.

Overrides:
toString in class java.lang.Object
Returns:
the String that represents this Atom