|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectai.krr.fol.Sentence
ai.krr.fol.QuantifiedSentence
public class QuantifiedSentence
Nested Class Summary | |
---|---|
static class |
QuantifiedSentence.Quantifier
This enumeration defines the possible quantifiers that bind variables in the content Sentence. |
Nested classes/interfaces inherited from class ai.krr.fol.Sentence |
---|
Sentence.SubSentenceIterator |
Field Summary | |
---|---|
protected Sentence |
contained
the content Sentence |
protected QuantifiedSentence.Quantifier |
quantifier
the Quantifier for the Variables |
protected Variable[] |
variables
the Variables that are bound |
Constructor Summary | |
---|---|
QuantifiedSentence(QuantifiedSentence.Quantifier q,
Variable[] vars,
Sentence content)
This constructor for a QuantifiedSentence takes a Quantifier, a List of Variables, and a Sentence. |
|
QuantifiedSentence(QuantifiedSentence.Quantifier q,
Variable var,
Sentence content)
This constructor for a QuantifiedSentence takes a Quantifier, a single Variable, and a Sentence. |
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. |
QuantifiedSentence |
clone()
This function generates a shallow copy of this QuantifiedSentence. |
QuantifiedSentence |
clone(Substitution s)
Returns a copy of this Sentence with Variables replaced according to the given Substitution. |
int |
compareTo(QuantifiedSentence stmt)
This function compares this QuantifiedSentence to the given QuantifiedSentence. |
int |
compareTo(Sentence stmt)
This function compares this Sentence to the given Sentence. |
boolean |
equals(java.lang.Object obj)
This function tests whether this and the given Object are equal. |
boolean |
equals(QuantifiedSentence other)
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. |
Sentence |
getContent()
This function returns the contained Sentence. |
int |
getDepth()
This function returns the nesting depth of this Sentence. |
QuantifiedSentence.Quantifier |
getQuantifier()
This function returns the Quantifier used for the Variables. |
Variable[] |
getVariables()
This function returns the Variables that are bound here. |
int |
hashCode()
This function returns the hash code of this QuantifiedSentence. |
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 of this Sentence. |
protected Sentence |
toDNF(boolean isNegated)
This function returns a new Sentence which is the CNF of this Sentence. |
java.lang.String |
toString()
A QuantifiedSentence 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 QuantifiedSentence.Quantifier quantifier
protected final Variable[] variables
protected final Sentence contained
Constructor Detail |
---|
public QuantifiedSentence(QuantifiedSentence.Quantifier q, Variable var, Sentence content)
This constructor for a QuantifiedSentence takes a Quantifier, a single Variable, and a Sentence.
q
- the Quantifier for the Variablesvars
- the Variables to which the Quantifier appliescontent
- the Sentence that should contain the bound Variablespublic QuantifiedSentence(QuantifiedSentence.Quantifier q, Variable[] vars, Sentence content)
This constructor for a QuantifiedSentence takes a Quantifier, a List of Variables, and a Sentence.
q
- the Quantifier for the Variablesvar
- the Variable to which the Quantifier appliescontent
- the Sentence that should contain the bound VariablesMethod Detail |
---|
public QuantifiedSentence clone()
This function generates a shallow copy of this QuantifiedSentence. The copy will contain the same Symbols and Variables as the original.
clone
in class Sentence
public QuantifiedSentence 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 that is bound here must not occur in the Substitution. It 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 quantified Sentence is the depth of the contained Sentences plus the number of quantified variables.
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 6.
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, QuantifiedSentence.
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 QuantifiedSentence.Quantifier getQuantifier()
This function returns the Quantifier used for the Variables.
public final Variable[] getVariables()
This function returns the Variables that are bound here.
public final Sentence getContent()
This function returns the contained Sentence.
public int compareTo(QuantifiedSentence stmt)
This function compares this QuantifiedSentence to the given QuantifiedSentence. The order between QuantifiedSentences is primarily defined by the order of the Quantifiers. If they use the same Quantifier the Variables and contained Sentences are compared.
other
- the QuantifiedSentence to which this QuantifiedSentence 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 addBoundVariables(java.util.Set<Variable> bound)
This function adds the bound Variables in this Sentence to the given Set. These are exactly those Variables that are quantified here.
addBoundVariables
in class Sentence
bound
- a Set of bound Variables that will be extendedprotected 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.
addFreeVariables
in class Sentence
free
- a Set of free Variables that will be extendedbound
- a Set of bound Variablesprotected 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 of this Sentence. However, quantifiers must not occur in CNF and hence this calling this function will cause an IllegalStateException.
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 of this Sentence. However, quantifiers must not occur in CNF and hence this calling this function will cause an IllegalStateException.
toDNF
in class Sentence
isNegated
- whether the Sentence is negated
public java.lang.String toString()
A QuantifiedSentence is printed as:
(( <quantifier> <variable>+ ) <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 QuantifiedSentences are equal if they have the same quantifier, all the variables in the same order and equal, and the contained Sentences are equal.
equals
in class java.lang.Object
other
- the Sentence this one is to be compared to
public boolean equals(QuantifiedSentence other)
This function tests whether this and the given Object are equal. In general, two QuantifiedSentences are equal if they have the same quantifier, all the variables in the same order and equal, and the contained Sentences are equal.
other
- the Sentence this one is to be compared to
public int hashCode()
This function returns the hash code of this QuantifiedSentence.
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |