java.lang.Object
edu.upc.fib.inlab.imp.kse.logics.logicschema.domain.Atom

public class Atom extends Object
Implementation of a logic Atom. An Atom consists of a Predicate (e.g. "Employee") together with a list of Terms (e.g. "x", "y"). An atom should belong, at most, to one NormalClause, or one literal. That is, atoms should not be reused several times.
  • Constructor Details

  • Method Details

    • getPredicate

      public Predicate getPredicate()
    • getTerms

      public ImmutableTermList getTerms()
    • unfold

      public List<ImmutableLiteralsList> unfold()

      Unfolding an atom returns a list of literals' list, one for each derivation rule of (the predicate of) this atom. In particular, for each derivation rule, it returns a literals' list replacing the variables of the derivation rule's head for the terms appearing in this atom.

      For instance, if we have the atom "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 atom. 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 the derivation rules of such atom contains constants, or repeated variables in the head, they are treated as new built-in literals. E.g. if we have the rule "R(a, 1) :- S(a)", and we unfold "R(x, y)", we obtain "R(x, y), y = 1"; similarly, if we have the rule "R(a,a) :- S(a)", and we unfold "R(x,y)" we obtain "R(x,y), x=y"

      Returns:
      a list of ImmutableLiteralsList representing the result of unfolding this atom
    • unfold

      protected ImmutableLiteralsList unfold(int derivationRuleIndex)
    • getPredicateName

      public String getPredicateName()
    • isDerived

      public boolean isDerived()
    • isBase

      public boolean isBase()
    • applySubstitution

      public Atom applySubstitution(Substitution substitution)
      Parameters:
      substitution - not null
      Returns:
      an atom after applying the given substitution. The atom will be new if some term has changed. Otherwise, it will be the same
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • accept

      public <T> T accept(LogicSchemaVisitor<T> visitor)
    • isGround

      public boolean isGround()
      Returns:
      true if all the terms of this atom are constants, false otherwise
    • getVariables

      public Set<Variable> getVariables()
    • isRecursive

      public boolean isRecursive()
      Returns:
      whether the Predicate of this atom is recursive, or not