Class OrdinaryLiteral
-
Constructor Summary
ConstructorsConstructorDescriptionOrdinaryLiteral(Atom atom) Creates an ordinary literal with a positive signOrdinaryLiteral(Atom atom, boolean isPositive) -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(LogicSchemaVisitor<T> visitor) applySubstitution(Substitution substitution) Constructs newLiteralafter applying the substitution to the literal terms.This method constructs a new literal that is the negation of this one.getAtom()getTerms()booleanisBase()booleanbooleanbooleanbooleantoString()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 ImmutableLiteralsListunfold(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
Creates an ordinary literal with a positive sign- Parameters:
atom- non-null
-
OrdinaryLiteral
-
-
Method Details
-
getPredicate
-
getPredicateName
-
isDerived
public boolean isDerived() -
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
-
isBase
public boolean isBase() -
isPositive
public boolean isPositive() -
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
-
toString
-
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
-
isNegative
public boolean isNegative() -
getTerms
-
getAtom
-
applySubstitution
Description copied from class:LiteralConstructs newLiteralafter applying the substitution to the literal terms.- Specified by:
applySubstitutionin classLiteral- 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.
-
accept
-
buildNegatedLiteral
Description copied from class:LiteralThis 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"- Overrides:
buildNegatedLiteralin classLiteral- Returns:
- a new literal that is the negation of this literal, if this is possible.
-