Interface Literal
public interface Literal
The
Literal interface represents a logical literal, which can be either a positive or negative
proposition. Literals are fundamental components in propositional logic and SAT solvers. They can be
used to construct clauses, represent assumptions, and encode constraints.
- Author:
- Mathias Hofer
-
Method Summary
Modifier and TypeMethodDescriptionstatic Literalcreate()Creates a new unnamed atom literal.static LiteralCreates a new named atom literal with the specified name.static LiteralCreates a new transient atom literal.getAtom()Retrieves the atom of this literal.getName()Returns the name of this literal.booleanChecks if this literal is positive.booleanChecks if this literal is transient.neg()Returns the negation of this literal.
-
Method Details
-
isTransient
boolean isTransient()Checks if this literal is transient. Transient literals are usually temporary and are not used as permanent identifiers.- Returns:
trueif the literal is transient,falseotherwise
-
isPositive
boolean isPositive()Checks if this literal is positive. A positive literal represents a proposition in its original form, whereas a negative literal represents the negation of a proposition.- Returns:
trueif the literal is positive,falseif it is negative
-
getAtom
Literal getAtom()Retrieves the atom of this literal. If the literal is a negation, this method returns the encapsulated atom. If the literal is an atom, it returns itself.- Returns:
- the atom of the literal, or this literal if it is an atom
-
getName
String getName()Returns the name of this literal. The name may benullif the literal does not have a specific name (e.g., in the case of transient literals).- Returns:
- the name of the literal, or
nullif it does not have a name
-
neg
Literal neg()Returns the negation of this literal. The following properties hold for every literall:l.neg().neg() == l: The negation of the negation returns the original literal.l.neg().getAtom() == l.getAtom(): The negation of the literal has the same atom.
l:l.neg() == l.neg(): The negation of a literal might not be equal to itself.
- Returns:
- the negation of this literal
-
create
Creates a new unnamed atom literal. This is a default literal without any specific name.- Returns:
- a new unnamed atom literal
-
create
Creates a new named atom literal with the specified name. If the provided name isnull, an unnamed atom literal is created instead.- Parameters:
name- the name of the literal, ornullfor an unnamed literal- Returns:
- a new named atom literal, or an unnamed atom literal if the name is
null
-
createTransient
Creates a new transient atom literal. Transient literals are typically used for temporary or intermediate purposes and do not have a permanent name.- Returns:
- a new transient atom literal
-