Class PositiveAtom

java.lang.Object
edu.harvard.seas.pl.abcdatalog.ast.PositiveAtom
All Implemented Interfaces:
Head, Premise

public class PositiveAtom extends Object implements Premise, Head
A non-negated atom; i.e., a predicate symbol, and a sequence of terms.
  • Field Details

    • pred

      protected final PredicateSym pred
      Predicate symbol of this atom.
    • args

      protected final Term[] args
      Arguments of this atom.
    • isGround

      protected volatile Boolean isGround
      Is the atom ground (i.e., all arguments are constants)?
  • Constructor Details

    • PositiveAtom

      protected PositiveAtom(PredicateSym pred, Term[] args)
      Constructs an atom from a predicate symbol and a list of arguments.
      Parameters:
      pred - predicate symbol
      args - arguments
  • Method Details

    • create

      public static PositiveAtom create(PredicateSym pred, Term[] args)
      A static factory method for the creation of atoms. Returns an atom with the provided predicate symbol and arguments. The argument array becomes "owned" by this atom and should not be modified.
      Parameters:
      pred - the predicate symbol
      args - the arguments
      Returns:
      an atom with the provided predicate symbol and arguments
    • getArgs

      public Term[] getArgs()
    • getPred

      public PredicateSym getPred()
    • isGround

      public boolean isGround()
    • unify

      public Substitution unify(PositiveAtom fact)
      Attempts to unify this atom with a fact (i.e., a ground atom).
      Parameters:
      fact - the fact
      Returns:
      a substitution, or null if the atoms do not unify
    • applySubst

      public PositiveAtom applySubst(Substitution subst)
      Apply a substitution to the terms in this atom.
      Specified by:
      applySubst in interface Head
      Specified by:
      applySubst in interface Premise
      Parameters:
      subst - the substitution
      Returns:
      a new atom with the substitution applied
    • toString

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • accept

      public <I, O> O accept(PremiseVisitor<I,O> visitor, I state)
      Specified by:
      accept in interface Premise
    • accept

      public <I, O> O accept(HeadVisitor<I,O> visitor, I state)
      Specified by:
      accept in interface Head