java.lang.Object
edu.upc.fib.inlab.imp.kse.logics.logicschema.domain.Predicate
Direct Known Subclasses:
MutablePredicate

public class Predicate extends Object
Representation of a logic predicate. E.g. Predicate "Emp" with arity 2. A Predicate is a weak entity w.r.t. LogicSchema. That is:
  • One Predicate can only belong to one LogicSchema
  • A LogicSchema cannot contain two predicates with the same name

To instantiate a derived predicate, we use Queries, that is, a list of terms together a body For instance, if we have a mutable Predicate P, we can include some Queries to make it derived:

(x, y) :- R(x, y)

(x, w) :- S(x, w), T(w)

Do note that the queries do not require to include the predicate "P" on the head, since it would be redundant.

  • Field Details

    • derivationRules

      protected final List<DerivationRule> derivationRules
      Invariants: - name cannot be null - name cannot be empty - arity >= 0 - the list of derivationRules is not null - the list of derivationRules it not empty - derivationRules head terms size matches with arity - derivationRules are immutable when retrieved
  • Constructor Details

    • Predicate

      public Predicate(String name, int arity)
    • Predicate

      public Predicate(String name, int arity, List<Query> definitionQueries)
  • Method Details

    • isRecursive

      public boolean isRecursive()
      A predicate is recursive if it is derived and it appears in the body of its derivation rules, or in the body of some derivation rule it depends on. E.g.:

      R(x, y) :- R(x, z), R(z, y)

      R(x, y) :- T(x, y)

      P(x, y) :- R(x, z)

      Q(x, y) :- S(x, y)

      S(x, y) :- Q(x, y)

      In this example, R, Q and S are recurisve predicate, but P and T are not.

      Returns:
      whether this predicate is recursive
    • getArity

      public int getArity()
    • getName

      public String getName()
    • getDerivationRules

      public List<DerivationRule> getDerivationRules()
    • getFirstDerivationRule

      public DerivationRule getFirstDerivationRule()
    • isDerived

      public boolean isDerived()
    • isBase

      public boolean isBase()
    • accept

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