ai.krr.propositions
Class TruthValue

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

public final class TruthValue
extends Sentence

A TruthValue is one of the most basic building blocks for a Sentence. It simply consists of a BooleanSymbol.

Author:
Gerhard Wickler

Field Summary
static TruthValue FALSE
          the TruthValue for FALSE
protected  BooleanSymbol theSy
          the BooleanSymbol representing the TruthValue
static TruthValue TRUE
          the TruthValue for TRUE
 
Method Summary
 void addPropositions(java.util.Set<NamedSymbol> props)
           This function adds the propositions contained in this Sentence to the given Set.
 boolean booleanValue()
           This function returns the boolean value of the BooleanSymbol that represents this TruthValue.
 TruthValue clone()
           This class does not really support cloning and this object will be returned.
 int compareTo(Sentence stmt)
           This function compares this Sentence to the given Sentence.
 int compareTo(TruthValue other)
           This function compares this TruthValue to the given TruthValue.
 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.
 BooleanSymbol getSymbol()
           This function returns the Symbol that represents this TruthValue.
 int hashCode()
           This function returns the hash code of this TruthValue.
protected  Sentence toCNF(boolean isNegated)
           This function returns a new TruthValue which contains the same BooleanSymbol or its negation, depending on the given boolean.
protected  Sentence toDNF(boolean isNegated)
           This function returns a new TruthValue which contains the same BooleanSymbol or its negation, depending on the given boolean.
 java.lang.String toString()
           A TruthValue is printed as the contained symbol.
 
Methods inherited from class ai.krr.propositions.Sentence
addSubSentences, allSubSentences, exceedsDepth, getDepth, getPropositions, isAtom, isLiteral, prettyPrint, read, toClauseForm, toCNF, toDNF, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FALSE

public static final TruthValue FALSE
the TruthValue for FALSE


TRUE

public static final TruthValue TRUE
the TruthValue for TRUE


theSy

protected final BooleanSymbol theSy
the BooleanSymbol representing the TruthValue

Method Detail

clone

public final TruthValue clone()

This class does not really support cloning and this object will be returned.

Specified by:
clone in class Sentence
Returns:
this TruthValue

addPropositions

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

This function adds the propositions contained in this Sentence to the given Set. In the case of a TruthValue the Set remains unchanged.

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. For a TruthValue the returned truth value is the BooleanSymbol that makes up this TruthValue.

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 int getClassOrderIndex()

This function returns the index used for ordering Sentences across different classes. This index of this class is defined to be 0.

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): 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 BooleanSymbol getSymbol()

This function returns the Symbol that represents this TruthValue.

Returns:
the Symbol that makes up this TruthValue

compareTo

public int compareTo(TruthValue other)

This function compares this TruthValue to the given TruthValue. The order between TruthValues is defined by the order of the BooleanSymbols they contain.

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

booleanValue

public final boolean booleanValue()

This function returns the boolean value of the BooleanSymbol that represents this TruthValue.

Returns:
whether this TruthValue is TRUE

toCNF

protected Sentence toCNF(boolean isNegated)

This function returns a new TruthValue which contains the same BooleanSymbol or its negation, depending on the given boolean.

Specified by:
toCNF in class Sentence
Parameters:
isNegated - whether the TruthValue has to be negated
Returns:
a new TruthValue

toDNF

protected Sentence toDNF(boolean isNegated)

This function returns a new TruthValue which contains the same BooleanSymbol or its negation, depending on the given boolean.

Specified by:
toDNF in class Sentence
Parameters:
isNegated - whether the TruthValue has to be negated
Returns:
a new TruthValue

toString

public java.lang.String toString()

A TruthValue is printed as the contained symbol.

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

hashCode

public final int hashCode()

This function returns the hash code of this TruthValue.

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