|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectai.krr.propositions.Sentence
ai.krr.propositions.Literal
public class Literal
A Literal is one of the most basic building blocks for a Sentence. It simply consists of a signed proposition.
Field Summary | |
---|---|
protected boolean |
sign
indicates whether this Literal is positive (true) or negative (false) |
protected NamedSymbol |
theSy
the proposition symbol |
Constructor Summary | |
---|---|
Literal(boolean sign,
NamedSymbol prop)
This constructor for a Literal takes a NamedSymbol for the proposition and a sign. |
Method Summary | |
---|---|
void |
addPropositions(java.util.Set<NamedSymbol> props)
This function adds the propositions contained in this Sentence to the given Set. |
Literal |
clone()
Cloning a Literal returns a new Literal consisting of the same proposition with the same sign. |
int |
compareTo(Literal other)
This function compares this Literal to the given Literal. |
int |
compareTo(Sentence stmt)
This function compares this Sentence to the given Sentence. |
boolean |
complements(Literal other)
This function tests whether this and the given Literal complementary. |
boolean |
equals(Literal other)
A Literal is equal to another Literal that consists of an equal sign and proposition symbol. |
boolean |
equals(java.lang.Object obj)
A Literal is equal to another Literal that consists of an equal sign and 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 Symbol that is the proposition contained in this Literal. |
int |
hashCode()
This function returns the hash code of this Literal. |
boolean |
isLiteral()
This function tests whether this Sentence is a Literal. |
boolean |
isPositive()
This function tests whether this is a positive Literal. |
void |
negate()
This function can be used to change the sign of this Literal. |
protected Sentence |
toCNF(boolean isNegated)
This function returns a new Literal which is a copy of this Literal. |
protected Sentence |
toDNF(boolean isNegated)
This function returns a new Literal which is a copy of this Literal. |
java.lang.String |
toString()
A Literal is printed as the sign ('+' or '-') followed by the proposition symbol. |
Methods inherited from class ai.krr.propositions.Sentence |
---|
addSubSentences, allSubSentences, exceedsDepth, getDepth, getPropositions, isAtom, prettyPrint, read, toClauseForm, toCNF, toDNF, write |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean sign
protected final NamedSymbol theSy
Constructor Detail |
---|
public Literal(boolean sign, NamedSymbol prop)
This constructor for a Literal takes a NamedSymbol for the proposition and a sign. The given Symbol must not be null.
prop
- the proposition symbolsign
- true if and only if this is a positive LiteralMethod Detail |
---|
public Literal clone()
Cloning a Literal returns a new Literal consisting of the same proposition with the same sign.
clone
in class Sentence
public final boolean isLiteral()
This function tests whether this Sentence is a Literal.
isLiteral
in class Sentence
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.
addPropositions
in class Sentence
props
- the Set to which the NamedSymbols are addedpublic 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 a Literal the returned truth value is the value of the contained NamedSymbol combined with the sign of this Literal.
evaluate
in class Sentence
ipt
- the Interpretation giving truth values for propositions
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 2.
getClassOrderIndex
in class Sentence
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.
compareTo
in interface java.lang.Comparable<Sentence>
compareTo
in class Sentence
stmt
- the Sentence to which this Sentence is to be compared
public boolean isPositive()
This function tests whether this is a positive Literal.
public final NamedSymbol getSymbol()
This function returns the Symbol that is the proposition contained in this Literal.
public void negate()
This function can be used to change the sign of this Literal.
public boolean complements(Literal other)
This function tests whether this and the given Literal complementary. This will be the case if they have the same proposition symbol, but the signs are different.
other
- the Literal this one is to be compared to
public int compareTo(Literal other)
This function compares this Literal to the given Literal. The order between Literals is primarily defined by the order of the contained propositions. If the Literals are complementary the negative one comes first.
other
- the Literal to which this Literal is to be compared
protected Sentence toCNF(boolean isNegated)
This function returns a new Literal which is a copy of this Literal. The given boolean indicates whether the Literal is to be negated, i.e. its sign to be reversed.
toCNF
in class Sentence
isNegated
- whether the Literal has to be negated
protected Sentence toDNF(boolean isNegated)
This function returns a new Literal which is a copy of this Literal. The given boolean indicates whether the Literal is to be negated, i.e. its sign to be reversed.
toDNF
in class Sentence
isNegated
- whether the Literal has to be negated
public java.lang.String toString()
A Literal is printed as the sign ('+' or '-') followed by the proposition symbol.
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
A Literal is equal to another Literal that consists of an equal sign and proposition symbol.
equals
in class java.lang.Object
obj
- the Object this Literal is compared to
public boolean equals(Literal other)
A Literal is equal to another Literal that consists of an equal sign and proposition symbol.
other
- the Literal this Literal is compared to
public int hashCode()
This function returns the hash code of this Literal.
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |