|
||||||||||
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.ConnectedSentence
public class ConnectedSentence
This class represents a Sentence that consists of a Connective that connects a number of (at least two) sub-Sentences. The Connective that may be given to the public constructors must be AND or OR. ConnectedSentences based on IMPLIES, IFF or XOR must be constructed as BinaryConnectedSentences.
Nested Class Summary | |
---|---|
static class |
ConnectedSentence.Connective
This enumeration defines the possible connectives that can connect the sub-Sentences. |
Field Summary | |
---|---|
protected ConnectedSentence.Connective |
connective
the connective for this Sentence |
protected Sentence[] |
sentences
the sub-Sentences connected here |
Constructor Summary | |
---|---|
|
ConnectedSentence(ConnectedSentence.Connective connective,
java.util.Collection<Sentence> sents)
This constructor for a ConnectedSentence takes a Connective and a List of Sentences which are the Sentences that are connected by the given connective. |
|
ConnectedSentence(ConnectedSentence.Connective connective,
Sentence... sentences)
This constructor for a ConnectedSentence takes a Connective and a number of Sentences which are the Sentences that are connected by the given connective. |
protected |
ConnectedSentence(Sentence s1,
ConnectedSentence.Connective connective,
Sentence s2)
This constructor for a ConnectedSentence takes a Connective and two Sentences which are the Sentences that are connected by the given connective. |
Method Summary | |
---|---|
void |
addPropositions(java.util.Set<NamedSymbol> props)
This function adds the propositions contained in this Sentence to the given Set. |
ConnectedSentence |
clone()
This function generates a shallow copy of this ConnectedSentence. |
int |
compareTo(ConnectedSentence other)
This function compares this ConnectedSentence to the given ConnectedSentence. |
int |
compareTo(Sentence stmt)
This function compares this Sentence to the given Sentence. |
boolean |
equals(ConnectedSentence other)
This function tests whether this and the given Object are equal. |
boolean |
equals(java.lang.Object obj)
This function tests whether this and the given Object are equal. |
BooleanSymbol |
evaluate(Interpretation ipt)
This function evaluates this Sentence under the given Interpretation. |
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. |
ConnectedSentence.Connective |
getConnective()
This function returns the Connective that connects the sub-Sentences in this ConnectedSentence. |
int |
getDepth()
This function returns the nesting depth of this Sentence. |
Sentence[] |
getSubSentences()
This function returns the the sub-Sentences that are joined in this ConnectedSentence. |
int |
hashCode()
This function returns the hash code of this ConnectedSentence. |
boolean |
isConjunction()
This function tests whether this Sentence is a conjunction. |
boolean |
isDisjunction()
This function tests whether this Sentence is a disjunction. |
(package private) static java.util.List<java.util.List<Literal>> |
multiplyS(java.util.List<java.util.List<Literal>> nf,
ConnectedSentence lits)
This function multiplies the given List of List of Literals with the given ConnectedSentence. |
protected Sentence |
toCNF(boolean isNegated)
This function returns a new Sentence which is the CNF form of this ConnectedSentence. |
protected Sentence |
toDNF(boolean isNegated)
This function returns a new Sentence which is the CNF form of this AndOrSentence. |
java.lang.String |
toString()
A ConnectedSentence is printed as: |
Methods inherited from class ai.krr.propositions.Sentence |
---|
addSubSentences, allSubSentences, getPropositions, isAtom, isLiteral, prettyPrint, read, toClauseForm, toCNF, toDNF, write |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final ConnectedSentence.Connective connective
protected final Sentence[] sentences
Constructor Detail |
---|
public ConnectedSentence(ConnectedSentence.Connective connective, java.util.Collection<Sentence> sents)
This constructor for a ConnectedSentence takes a Connective and a List of Sentences which are the Sentences that are connected by the given connective. The connective should be AND or OR.
connective
- the connective (e.g. Connective.AND)sents
- the Sentences to be connected herepublic ConnectedSentence(ConnectedSentence.Connective connective, Sentence... sentences)
This constructor for a ConnectedSentence takes a Connective and a number of Sentences which are the Sentences that are connected by the given connective. The connective should be AND or OR.
connective
- the connective (e.g. Connective.AND)sentences
- the Sentences to be connected hereprotected ConnectedSentence(Sentence s1, ConnectedSentence.Connective connective, Sentence s2)
This constructor for a ConnectedSentence takes a Connective and two Sentences which are the Sentences that are connected by the given connective.
connective
- the connective (e.g. Connective.XOR)s1
- the first Sentence to be connected heres2
- the second Sentence to be connected hereMethod Detail |
---|
public ConnectedSentence clone()
This function generates a shallow copy of this ConnectedSentence. The copy will contain the same sub-Sentences as the original.
clone
in class Sentence
public int getDepth()
This function returns the nesting depth of this Sentence. The depth of a conjunction or disjunction is the maximum depth of the sub-Sentences plus 1.
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 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 may be null, indicating the truth value of this Sentence is undefined under the given Interpretation. For a ConnectedSentence the returned truth value depends on the connective. It will be BooleanSymbol.TRUE iff:
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 4.
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 final ConnectedSentence.Connective getConnective()
This function returns the Connective that connects the sub-Sentences in this ConnectedSentence.
public final Sentence[] getSubSentences()
This function returns the the sub-Sentences that are joined in this ConnectedSentence.
public boolean isConjunction()
This function tests whether this Sentence is a conjunction.
public boolean isDisjunction()
This function tests whether this Sentence is a disjunction.
public int compareTo(ConnectedSentence other)
This function compares this ConnectedSentence to the given ConnectedSentence. The order between ConnectedSentence is primarily defined by the order of the Connectives they contain. If they use the same connective a lexical ordering is used, i.e. first the first sub-Sentences are compared. If they are different this determines the overall result, otherwise the second sub-Sentences are compared, etc.
other
- the ConnectedSentence to which this ConnectedSentence is to
be compared
protected Sentence toCNF(boolean isNegated)
This function returns a new Sentence which is the CNF form of this ConnectedSentence. The given boolean indicates whether the Sentence is to be treated as negated at this point.
toCNF
in class Sentence
isNegated
- whether the Sentence is negated
protected Sentence toDNF(boolean isNegated)
This function returns a new Sentence which is the CNF form of this AndOrSentence. The given boolean indicates whether the Sentence is to be treated as negated at this point.
toDNF
in class Sentence
isNegated
- whether the Sentence is negated
public java.lang.String toString()
A ConnectedSentence is printed as:
( <connective> <formula>+ )
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
This function tests whether this and the given Object are equal. In general, two ConnectedSentences are equal if they have the same connective and all the sub-Sentences are in the same order and equal.
equals
in class java.lang.Object
obj
- the Sentence this one is to be compared to
public boolean equals(ConnectedSentence other)
This function tests whether this and the given Object are equal. In general, two ConnectedSentences are equal if they have the same connective and all the sub-Sentences are in the same order and equal.
other
- the Sentence this one is to be compared to
public int hashCode()
This function returns the hash code of this ConnectedSentence.
hashCode
in class java.lang.Object
static java.util.List<java.util.List<Literal>> multiplyS(java.util.List<java.util.List<Literal>> nf, ConnectedSentence lits)
This function multiplies the given List of List of Literals with the given ConnectedSentence.
Multiplication here is defined as follows: Given a ConnectedSentence of n Literals, the result will contain n times the number of sub-Lists it contained previously, and each copy will be extended with a different Literal from the given ConnectedSentence. For example, multiplying
((+A1 +A2) (+B1 +B2))
with (AND +C, +D)
will result in:
((+A1 +A2 +C) (+A1 +A2 +D) (+B1 +B2 +C) (+B1 +B2 +D))
lits
- a Collection of Literals to multiply this AndOrSentence with
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |