|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectai.krr.fol.Sentence
ai.krr.fol.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. |
Nested classes/interfaces inherited from class ai.krr.fol.Sentence |
---|
Sentence.SubSentenceIterator |
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.List<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 | |
---|---|
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. |
ConnectedSentence |
clone()
This function generates a shallow copy of this ConnectedSentence. |
ConnectedSentence |
clone(Substitution s)
Returns a copy of this Sentence with Variables replaced according to the given Substitution. |
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,
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. |
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 |
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 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.fol.Sentence |
---|
allSubSentences, getBoundVariables, getConstants, getFreeVariables, getFunctions, getPredicates, prettyPrint, read, skolemize, 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.List<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 ConnectedSentence clone(Substitution s)
Returns a copy of this Sentence with Variables replaced according to the given Substitution. Symbols in the copy will be the same as the original ones but Variables will be replaced by the respective Terms in the given Substitution. A Variable not occurring in the Substitution will be replaced by a new (different) Variable with the same name. The given Substitution will be extended to include the mappings of old Variables to new ones.
clone
in class Sentence
s
- the Substitution that tells us how to replace Variables
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 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 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.
evaluate
in class Sentence
ipt
- the Interpretation giving values for Atoms and Termss
- the Substitution for Variables occurring in this Term
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 void addConstants(java.util.Set<Symbol> sys)
This function adds all the constant Symbols used in this Sentence to the given Set.
addConstants
in class Sentence
sys
- the Set that will contain all the Constantsprotected 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.
addFunctions
in class Sentence
sys
- the Set that will contain all the function namesprotected 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.
addPredicates
in class Sentence
sys
- the Set that will contain all the predicate namesprotected 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. Newly bound Variables will also be added to the second Set.
addFreeVariables
in class Sentence
free
- a Set of free Variables that will be extendedbound
- a Set of bound Variablesprotected void addBoundVariables(java.util.Set<Variable> bound)
This function adds the bound Variables in this Sentence to the given Set.
addBoundVariables
in class Sentence
bound
- a Set of bound Variables that will be extendedprotected Sentence skolemize(boolean isNegated, Term[] uqVars, Substitution s)
This function computes a skolemized version of this Sentence. It replaces all the existentially quantified variables in this Sentence by appropriate Skolem constants and functions. It all so removes all quantification from this sentence meaning that all remaining Variables are implicitly universally quantified. The given boolean determines whether this sub-Sentence is negated, which is necessary to determine the effective type of quantifier in a QuantifiedSentence. The given Term must all be Variables and represent all the universally quantified Variables at this point. These will be arguments to a potentially introduced Skolem function. Finally, the given Substitution must store mappings from existentially quantified Variables to Skolem Terms.
skolemize
in class Sentence
isNegated
- whether the Sentence is negateduqVars
- the known universally quantified Variables at this points
- the Substitution for Variable replacements
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 Object 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 |