|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectai.krr.propositions.Clause
public class Clause
A Clause consists of a list of Literals that are interpreted as a disjunction. Internally Literals are stored in an array. Note that the list representation means that the order of Literals within a Clause is relevant, e.g. for equality testing.
Field Summary | |
---|---|
protected Literal[] |
literals
the Literals of this Clause |
Constructor Summary | |
---|---|
Clause(java.util.Collection<Literal> lits)
This constructor for a Clause takes a Collection of Literals. |
|
Clause(Literal... lits)
This constructor for a Clause takes an Array of Literals. |
Method Summary | |
---|---|
protected Clause |
clone()
This function generates a shallow copy of this Clause. |
int |
compareTo(Clause other)
This function compares this Clause to the given Clause. |
boolean |
contains(Literal literal)
This function tests whether the given Literal is contained in this Clause. |
boolean |
equals(Clause other)
This function tests whether this and the given Clause 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 Clause under the given Interpretation. |
Literal[] |
getLiterals()
This function returns the the Literals that are joined in this Clause. |
java.util.Set<NamedSymbol> |
getPropositions()
This function returns the set of propositional symbols that occur in this Clause. |
int |
hashCode()
This function returns the hash code of this Clause. |
NamedSymbol |
isTautology()
This function tests whether this clause is a tautology. |
protected Clause |
remove(Literal lit)
This function returns a Clause in which the given Literal has been removed. |
protected Clause |
removeAll(java.util.Set<Literal> lits)
This function returns a Clause in which the given Literals have been removed. |
int |
size()
This function returns the number of Literals in this Clause. |
java.lang.String |
toString()
A Clause is printed as: |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Literal[] literals
Constructor Detail |
---|
public Clause(java.util.Collection<Literal> lits)
This constructor for a Clause takes a Collection of Literals. The given Collection should not contain duplicate Literals.
lits
- the Literals to be connected herepublic Clause(Literal... lits)
This constructor for a Clause takes an Array of Literals. The given Collection should not contain duplicate Literals.
lits
- the Literals to be connected hereMethod Detail |
---|
protected Clause clone()
This function generates a shallow copy of this Clause. The copy will contain the same Literals as the original.
clone
in class java.lang.Object
public int compareTo(Clause other)
This function compares this Clause to the given Clause. The order between Clauses is primarily determined by their length: shorter Clauses come first. The order between Clauses of equal length is a lexical ordering, i.e. first the first Literals are compared. If they are different this determines the overall result, otherwise the second Literals are compared, etc. Note that Literals are not considered in the order given to the constructor, but in their natural order.
compareTo
in interface java.lang.Comparable<Clause>
other
- the Clause to which this Clause is to be compared
public final Literal[] getLiterals()
This function returns the the Literals that are joined in this Clause.
public int size()
This function returns the number of Literals in this Clause.
public boolean contains(Literal literal)
This function tests whether the given Literal is contained in this Clause.
literal
- the Literal to be tested for
public java.util.Set<NamedSymbol> getPropositions()
This function returns the set of propositional symbols that occur in this Clause. The boolean propositions TRUE and FALSE will not be contained in the result.
public NamedSymbol isTautology()
This function tests whether this clause is a tautology. This is the case if it contains a complementary pair of Literals.
public BooleanSymbol evaluate(Interpretation ipt)
This function evaluates this Clause under the given Interpretation. If all propositions occurring in the Clause 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 Clause is undefined under the given Interpretation.
ipt
- the Interpretation giving truth values for propositions
public java.lang.String toString()
A Clause is printed as:
( <literal>+ )
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 Clauses are equal if all the Literals 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(Clause other)
This function tests whether this and the given Clause are equal. In general, two Clauses are equal if they contain equal Literals, where the order of the Literals is only relevant if they are not sorted.
other
- the Clause this one is to be compared to
public final int hashCode()
This function returns the hash code of this Clause.
hashCode
in class java.lang.Object
protected Clause remove(Literal lit)
This function returns a Clause in which the given Literal has been removed. If the given Literal is not contained in this Clause this Clause is returned.
lit
- the Literal to be omitted in the copy
protected Clause removeAll(java.util.Set<Literal> lits)
This function returns a Clause in which the given Literals have been removed. If none of the given Literals is contained in this Clause this Clause is returned.
lits
- the Literals to be omitted in the copy
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |