Class OrdinaryLiteral
-
Constructor Summary
ConstructorDescriptionOrdinaryLiteral
(Atom atom) Creates an ordinary literal with a positive signOrdinaryLiteral
(Atom atom, boolean isPositive) -
Method Summary
Modifier and TypeMethodDescription<T> T
accept
(LogicSchemaVisitor<T> visitor) applySubstitution
(Substitution substitution) This method builds a new literal that is the negation of this one.getAtom()
getTerms()
boolean
isBase()
boolean
boolean
boolean
boolean
toString()
unfold()
Unfolding a positive ordinary literal returns a list of literals' list, one for each derivation rule of this ordinary literal.unfold
(boolean unfoldNegatedLiterals) protected ImmutableLiteralsList
unfold
(int derivationRuleIndex) This is an extension of the unfold method that also applies an unfolding for negated literals whose derivation rules does not contain existential variables.Methods inherited from class edu.upc.fib.inlab.imp.kse.logics.logicschema.domain.Literal
canBeNegated, getArity, getUsedVariables, isGround
-
Constructor Details
-
OrdinaryLiteral
-
OrdinaryLiteral
Creates an ordinary literal with a positive sign- Parameters:
atom
- non-null
-
-
Method Details
-
isPositive
public boolean isPositive() -
isNegative
public boolean isNegative() -
getAtom
-
getPredicate
-
getPredicateName
-
getTerms
-
applySubstitution
- Specified by:
applySubstitution
in classLiteral
- 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
-
accept
-
buildNegatedLiteral
Description copied from class:Literal
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.
- Overrides:
buildNegatedLiteral
in classLiteral
- Returns:
- a new literal that is the negation of this literal, if this is possible
-
isDerived
public boolean isDerived() -
isBase
public boolean isBase() -
unfold
Unfolding a positive ordinary literal returns a list of literals' list, one for each derivation rule of this ordinary literal. In particular, for each derivation rule, it returns a literalsList replacing the variables of the derivation rule's head for the terms appearing in this literal.
For instance, if we have the ordinary literal "P(1)", with derivation rules "P(x) :- R(x), S(x)" and "P(y) :- T(y), U(y)", unfolding "P(1)" will return two literals' list: "R(1), S(1)" and "T(1), U(1)".
This unfolding avoids clashing the variables inside the derivation rule's body with the variables appearing in this literal. For instance, if we have the ordinary literal "P(a, b)" with a derivation rule "P(x, y) :- R(x, y, a, b)" it will return "R(a, b, a', b')"
If the ordinary literal is base, or it is negated, it returns the very same literal.
- Returns:
- a list of ImmutableLiteralsList representing the result of unfolding this literal
-
unfoldWithNegationExtension
This is an extension of the unfold method that also applies an unfolding for negated literals whose derivation rules does not contain existential variables. E.g.: Suppose the literal "not(Derived(x))" with derivation rule "Derived(x) :- A(x), not(B(x))"Unfolding not(Derived()) will return two literals list: "not(A(x))" and "B(x)".
- Returns:
- a list of ImmutableLiteralsList representing the result of unfolding the index-th literal
-
unfold
-
isRecursive
public boolean isRecursive()- Returns:
- whether the Atom of this literal is recursive, or not
-
unfold
- Parameters:
derivationRuleIndex
- derivation rule to use for the unfolding- Returns:
- the corresponding derivation rule applying a substitution that unifies the rule head with this terms
-
toString
-