Class Literal
java.lang.Object
edu.upc.fib.inlab.imp.kse.logics.logicschema.domain.Literal
- Direct Known Subclasses:
BuiltInLiteral
,OrdinaryLiteral
Implementation of the logic literal. Literals might be Ordinary (e.g. "Emp(x)"), or built-in (e.g.
"x < 4"
)
A literal should appear, at most, inside the body of one NormalClause.
That is, literals should not be reused among several NormalClauses.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract <T> T
accept
(LogicSchemaVisitor<T> visitor) abstract Literal
applySubstitution
(Substitution substitution) This method builds a new literal that is the negation of this one.boolean
int
getArity()
abstract ImmutableTermList
getTerms()
boolean
isGround()
-
Constructor Details
-
Literal
public Literal()
-
-
Method Details
-
getTerms
-
getArity
public int getArity() -
applySubstitution
- Parameters:
substitution
- not null- Returns:
- a literal after applying the given substitution. The literal will be new if some term has changed, otherwise it will be the same
-
getUsedVariables
-
accept
-
buildNegatedLiteral
This method builds a new literal that is the negation of this one. E.g.: given an ordinary literal "P(x)" it will return a new literal "not(P(x))", or given a built-in literal"x < y" it will return "x >= y"
Not all built-in literals can be negated. Thus, this function might throw an Exception.
- Returns:
- a new literal that is the negation of this literal, if this is possible
- Throws:
NoNegatableLiteral
- in case the literal cannot be negated
-
canBeNegated
public boolean canBeNegated()- Returns:
- whether this literal can be negated.
- See Also:
-
isGround
public boolean isGround()- Returns:
- true if all its terms of literal are constants, false otherwise
-