Class Literal<P>
- Type Parameters:
P- the type of propositional variables
- All Implemented Interfaces:
Proposition<P>
Propositional variables are paired with a logical sign:
true for positive and false for negative literals.
Propositional variables are represented by arbitrary objects, up to Object.equals(java.lang.Object). A null reference as a propositional variable is not
supported.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleangetSign()Returns the logical sign of this literal.Returns the propositional variable of this literal.inthashCode()static <P> booleanisConsistent(Collection<Literal<P>> literals) Checks whether the given literals are consistent.booleanChecks whether this proposition is free of disjunctions.booleanisFalse()Check whether this proposition is evidently false.booleanisSatisfiedBy(Set<Literal<P>> solution) Checks whether this proposition is satisfied by a given solution.booleanisTrue()Check whether this proposition is evidently true.negate()Return the negation of this literal.static <P> Literal<P> negative(P variable) Creates a new negative instance.static <P> Literal<P> positive(P variable) Creates a new positive instance.Finds the propositional variables occurring purely in some literals.intscore()Returns a nonnegative measure of the syntactic complexity of this proposition.toString()
-
Constructor Details
-
Literal
Creates a new instance.- Parameters:
sign- the logical sign of the literalvariable- the propositional variable- Throws:
NullPointerException- ifvariableis null
-
-
Method Details
-
positive
Creates a new positive instance.- Type Parameters:
P- the type of propositional variables- Parameters:
variable- the propositional variable- Returns:
- a positive literal with the given
variable - Throws:
NullPointerException- ifvariableis null
-
negative
Creates a new negative instance.- Type Parameters:
P- the type of propositional variables- Parameters:
variable- the propositional variable- Returns:
- a negative literal with the given
variable - Throws:
NullPointerException- ifvariableis null
-
isTrue
public boolean isTrue()Check whether this proposition is evidently true.This implementation always returns
false.- Specified by:
isTruein interfaceProposition<P>- Returns:
trueif this proposition is immediately seen to be true;falseotherwise.
-
isFalse
public boolean isFalse()Check whether this proposition is evidently false.This implementation always returns
false.- Specified by:
isFalsein interfaceProposition<P>- Returns:
trueif this proposition is immediately seen to be false;falseotherwise.
-
score
public int score()Returns a nonnegative measure of the syntactic complexity of this proposition.This implementation always returns
1.- Specified by:
scorein interfaceProposition<P>- Returns:
- the number of literal occurrences in this proposition
-
isSatisfiedBy
Checks whether this proposition is satisfied by a given solution.This implementation is equivalent to
solution.contains(this).- Specified by:
isSatisfiedByin interfaceProposition<P>- Parameters:
solution- the solution to check for satisfaction- Returns:
trueif assuming that all literals insolutionare true entails that this proposition is true;falseotherwise.
-
isDisjunctionFree
public boolean isDisjunctionFree()Checks whether this proposition is free of disjunctions.A disjunction-free proposition is satisfied by at most one solution that uses the same propositional variables.
This implementation always returns
false.- Specified by:
isDisjunctionFreein interfaceProposition<P>- Returns:
trueif this proposition is free of disjunctions
-
negate
Return the negation of this literal.This operation is a guaranteed involution:
l.negate().negate() == lalways succeeds.- Returns:
- a literal with opposite sign and identical variable.
-
equals
-
hashCode
public int hashCode() -
toString
-
getSign
public boolean getSign()Returns the logical sign of this literal.- Returns:
truefor a positive,falsefor a negative literal
-
getVariable
Returns the propositional variable of this literal.- Returns:
- the propositional variable of this literal
-
isConsistent
Checks whether the given literals are consistent.A collection of literals is consistent if and only if it does not contain both a positive and a negative occurrence of the same propositional variable.
- Type Parameters:
P- the type of propositional variables- Parameters:
literals- some literals- Returns:
trueif there is some propositional variablepsuch that bothpositive(p)andnegative(p)are contained inliterals;falseotherwise- Throws:
NullPointerException- isliteralsis null; behavior is unspecified ifliteralscontains a null reference
-
pure
Finds the propositional variables occurring purely in some literals.A propositional variable occurs purely if there is either a positive or a negative occurrence, but not both.
- Type Parameters:
P- the type of propositional variables- Parameters:
literals- some literals- Returns:
- a set containing all propositional variables
psuch that eitherpositive(p)ornegative(p), but not both, are contained inliterals - Throws:
NullPointerException- isliteralsis null; behavior is unspecified ifliteralscontains a null reference
-