Interface Atom

All Superinterfaces:
FOFormula, fr.inria.rules.dlgpemodel.api.formulas.IAtom, fr.inria.rules.dlgpemodel.api.formulas.IFormula, fr.inria.rules.dlgpemodel.api.formulas.IPredicated, fr.inria.rules.dlgpemodel.api.sentences.IPrintable, fr.inria.rules.dlgpemodel.api.formulas.IStandardAtom, Substitutable<FOFormula>, TermCompound, TermSequenceCompound
All Known Subinterfaces:
ComputedAtom
All Known Implementing Classes:
AtomImpl, ComputedAtomImpl

public non-sealed interface Atom extends FOFormula, TermSequenceCompound, fr.inria.rules.dlgpemodel.api.formulas.IStandardAtom
Interface for Atoms. An atom is an atomic query of the form P(t1, ..., tn) where P is a Predicate of arity n and t1, ..., tn are Terms.
  • Method Details

    • getPredicate

      Predicate getPredicate()
      Returns the predicate associated with this atom.
      Specified by:
      getPredicate in interface fr.inria.rules.dlgpemodel.api.formulas.IPredicated
      Returns:
      the Predicate associated to this atom.
    • contains

      boolean contains(Term term)
      Tests whether a term occurs in this atom.
      Parameters:
      term - the term to check
      Returns:
      true iff the Term term is present in this atom.
    • indexOf

      int indexOf(Term term)
      Returns the first position of a term in this atom.
      Parameters:
      term - the term to find
      Returns:
      the index of the first occurrence of Term term in this atom. Any negative non-zero value is returned if this atom does not contain the term.
    • indexesOf

      int[] indexesOf(Term term)
      Returns every position at which a term occurs in this atom.
      Parameters:
      term - the term to find all occurrences of
      Returns:
      the indexes of all the occurrence of Term term in this atom. An empty array is returned if this atom does not contain the term.
    • isAtomic

      default boolean isAtomic()
      Description copied from interface: FOFormula
      Indicates whether this formula node is atomic.
      Specified by:
      isAtomic in interface FOFormula
      Returns:
      true iff this node of the formula is a leaf
    • asAtomSet

      default Set<Atom> asAtomSet()
      Description copied from interface: FOFormula
      The given set does not represent any meaning on the formula as conjunctions, disjunctions and negations will be merged together.
      This should only be used to prepare some indexes
      Specified by:
      asAtomSet in interface FOFormula
      Returns:
      the set of all the atoms of this formula
    • getPredicates

      default Stream<Predicate> getPredicates()
      Description copied from interface: FOFormula
      Streams the predicates used by this formula.
      Specified by:
      getPredicates in interface FOFormula
      Returns:
      the set of all the predicates of the atoms of this formula
    • isComputedAtom

      default boolean isComputedAtom()
      Indicates whether this atom is a computed atom.
      Returns:
      true when this atom is computed rather than materialized
    • applySubstitution

      default Atom applySubstitution(Substitution substitution)
      Applies a substitution without evaluating nested functions.
      Specified by:
      applySubstitution in interface FOFormula
      Specified by:
      applySubstitution in interface Substitutable<FOFormula>
      Parameters:
      substitution - the substitution to apply
      Returns:
      the substituted atom
    • applySubstitution

      Atom applySubstitution(Substitution substitution, boolean evaluate)
      Applies a substitution to this atom.
      Specified by:
      applySubstitution in interface FOFormula
      Specified by:
      applySubstitution in interface Substitutable<FOFormula>
      Parameters:
      substitution - the substitution to apply
      evaluate - whether evaluable functions should be evaluated
      Returns:
      the substituted atom
    • homomorphism

      default Optional<Substitution> homomorphism(TermSequenceCompound target, Substitution toExtend)
      Allows computing the homomorphism from this atom to a target one if it exists
      Specified by:
      homomorphism in interface TermSequenceCompound
      Parameters:
      target - the atom on which we want to map
      toExtend - a substitution that the homomorphism must extend
      Returns:
      an optional containing a substitution representing the homomorphism if it exists, otherwise empty