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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract <T> Taccept(LogicSchemaVisitor<T> visitor) abstract LiteralapplySubstitution(Substitution substitution) Constructs newLiteralafter applying the substitution to the literal terms.This method constructs a new literal that is the negation of this one.booleanReturnstrueif literal can be negated.intgetArity()Returns arity of literal, i.e.abstract ImmutableTermListgetTerms()Returns used variables of literals.booleanisGround()Returns if all its terms of literal are constants,falseotherwise.
-
Constructor Details
-
Literal
public Literal()
-
-
Method Details
-
getArity
public int getArity()Returns arity of literal, i.e. the number of terms.- Returns:
- arity of literal, i.e. the number of terms.
-
getTerms
-
applySubstitution
Constructs newLiteralafter applying the substitution to the literal terms.- Parameters:
substitution- substitution to apply.- 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
Returns used variables of literals.- Returns:
- used variables of literals.
-
accept
-
canBeNegated
public boolean canBeNegated()Returnstrueif literal can be negated.- Returns:
trueif literal can be negated.- See Also:
-
buildNegatedLiteral
This method constructs 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"- Returns:
- a new literal that is the negation of this literal, if this is possible.
- Throws:
NoNegatableLiteralException- in case the literal cannot be negated.
-
isGround
public boolean isGround()Returns if all its terms of literal are constants,falseotherwise.- Returns:
trueif all its terms of literal are constants,falseotherwise.
-