ai.krr.fol
Class TruthValue

java.lang.Object
  extended by ai.krr.fol.Sentence
      extended by ai.krr.fol.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

Nested Class Summary
 
Nested classes/interfaces inherited from class ai.krr.fol.Sentence
Sentence.SubSentenceIterator
 
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
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.
 boolean booleanValue()
           This function returns the boolean value of the BooleanSymbol that represents this TruthValue.
 TruthValue clone()
           Cloning a TruthValue returns this Object.
 TruthValue clone(Substitution s)
           Cloning a TruthValue returns this Object.
 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, 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.
 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.
 BooleanSymbol getSymbol()
           This function returns the Symbol that represents this TruthValue.
 int hashCode()
           This function returns the hash code of this TruthValue.
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 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.fol.Sentence
allSubSentences, getBoundVariables, getConstants, getFreeVariables, getFunctions, getPredicates, prettyPrint, read, skolemize, 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()

Cloning a TruthValue returns this Object.

Specified by:
clone in class Sentence
Returns:
this TruthValue

clone

public final TruthValue clone(Substitution s)

Cloning a TruthValue returns this Object. The given Substitution is ignored.

Specified by:
clone in class Sentence
Parameters:
s - the Substitution that tells us how to replace Variables
Returns:
this TruthValue

getDepth

public final int getDepth()

This function returns the nesting depth of this Sentence. The depth of a TruthValue is defined to be 0.

Specified by:
getDepth in class Sentence
Returns:
the depth of this Sentence when seen as a tree

exceedsDepth

public final boolean exceedsDepth(int depth)

This function tests whether this Sentence exceeds the given depth which should be a non-negative integer.

Specified by:
exceedsDepth in class Sentence
Parameters:
depth - the depth value that is tested for
Returns:
true iff this.getDepth() > depth

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 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, QuantifiedSentence.

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

evaluate

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.

Specified by:
evaluate in class Sentence
Parameters:
ipt - the Interpretation giving values for Atoms and Terms
s - the Substitution for Variables occurring in this Term
Returns:
the value of this Term under the given Interpretation

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

addConstants

protected final void addConstants(java.util.Set<Symbol> sys)

This function adds all the constant Symbols used in this Sentence to the given Set.

Specified by:
addConstants in class Sentence
Parameters:
sys - the Set that will contain all the Constants

addFunctions

protected final 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.

Specified by:
addFunctions in class Sentence
Parameters:
sys - the Set that will contain all the function names

addPredicates

protected final 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.

Specified by:
addPredicates in class Sentence
Parameters:
sys - the Set that will contain all the predicate names

addFreeVariables

protected final 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.

Specified by:
addFreeVariables in class Sentence
Parameters:
free - a Set of free Variables that will be extended
bound - a Set of bound Variables

addBoundVariables

protected 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.

Specified by:
addBoundVariables in class Sentence
Parameters:
bound - a Set of bound Variables that will be extended

skolemize

protected Sentence skolemize(boolean isNegated,
                             Term[] uqVars,
                             Substitution s)

This function computes a skolemized version of this Sentence. The given Variables and Substitution will be ignored. Only the negation is worked into this Sentence.

Specified by:
skolemize in class Sentence
Parameters:
isNegated - whether the Sentence is negated
uqVars - the known universally quantified Variables at this point
s - the Substitution for Variable replacements
Returns:
a new Sentence with no quantification (can be converted to CNF/DNF)

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