Class AggregateElement

java.lang.Object
org.tweetyproject.lp.asp.syntax.ASPElement
org.tweetyproject.lp.asp.syntax.AggregateElement
All Implemented Interfaces:
Formula, ComplexLogicalFormula, LogicStructure, SimpleLogicalFormula

public class AggregateElement extends ASPElement
This class models an aggregate element, meaning a set of terms and a set of naf literals (= literals or default negated literals). One or more aggregate elements form an aggregate atom.
Author:
Anna Gessler
See Also:
  • Constructor Details

    • AggregateElement

      public AggregateElement(List<Term<?>> terms, List<ASPBodyElement> literals)
      Creates a new Aggregate Element with the given list of terms and the given list of naf literals.
      Parameters:
      terms - a list of terms
      literals - a list of body elements
    • AggregateElement

      public AggregateElement(Term<?> term, ASPBodyElement literal)
      Creates a new Aggregate Element with the given single term and the given single literal.
      Parameters:
      term -
      literal -
    • AggregateElement

      public AggregateElement(Term<?> term, List<ASPBodyElement> literals)
      Creates a new Aggregate Element with the given single term and the given list of naf literals.
      Parameters:
      term -
      literals - a list of body elements
    • AggregateElement

      public AggregateElement(Term<?> term, ASPBodyElement... literals)
      Creates a new Aggregate Element with the given single term and the given naf literals.
      Parameters:
      term -
      literals -
    • AggregateElement

      public AggregateElement(AggregateElement other)
      Copy-Constructor
      Parameters:
      other - another AggregateElement
  • Method Details

    • isLiteral

      public boolean isLiteral()
      Returns:
      true if the formula represents a literal in the language or false otherwise
    • getTerms

      public Set<Term<?>> getTerms()
      Returns:
      a set containing all terms of this logical structure
    • getTerms

      public <C extends Term<?>> Set<C> getTerms(Class<C> cls)
      Description copied from interface: LogicStructure
      Processes the set containing all terms of type C. This method uses the equals method of the given Class and therefore does not add terms which are sub classes of type C to the set.
      Type Parameters:
      C - the type of terms
      Parameters:
      cls - The Class structure containing type information about the searched term
      Returns:
      A set containing all terms of type C of this logical structure
    • getPredicates

      public Set<Predicate> getPredicates()
      Description copied from interface: SimpleLogicalFormula
      Processes the set of all predicates which appear in this formula
      Specified by:
      getPredicates in interface SimpleLogicalFormula
      Specified by:
      getPredicates in class ASPElement
      Returns:
      all predicates that appear in this formula
    • getAtoms

      public Set<ASPAtom> getAtoms()
      Description copied from interface: SimpleLogicalFormula
      Processes the set of all atoms which appear in this formula
      Specified by:
      getAtoms in interface SimpleLogicalFormula
      Specified by:
      getAtoms in class ASPElement
      Returns:
      The set of all atoms
    • substitute

      public AggregateElement substitute(Term<?> t, Term<?> v)
      Description copied from interface: ComplexLogicalFormula
      Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.
      Specified by:
      substitute in interface ComplexLogicalFormula
      Specified by:
      substitute in class ASPElement
      Parameters:
      t - the term to be substituted.
      v - the term to substitute.
      Returns:
      a formula where every occurrence of "v" is replaced by "t".
    • getSignature

      public FolSignature getSignature()
      Description copied from interface: Formula
      Returns the signature of the language of this formula.
      Specified by:
      getSignature in interface Formula
      Specified by:
      getSignature in class ASPElement
      Returns:
      the signature of the language of this formula.
    • clone

      public AggregateElement clone()
      Description copied from interface: SimpleLogicalFormula
      Creates a deep copy of this formula
      Specified by:
      clone in interface ComplexLogicalFormula
      Specified by:
      clone in interface SimpleLogicalFormula
      Specified by:
      clone in class ASPElement
      Returns:
      the cloned formula
    • getLeft

      public List<Term<?>> getLeft()
      Returns:
      the left part (the term tuple) of the Aggregate element.
    • getRight

      public List<ASPBodyElement> getRight()
      Returns the right part (the literals tuple) of the Aggregate element.
      Returns:
      list of naf literals (= literals or default negated literals)
    • setLeft

      public void setLeft(List<Term<?>> terms)
      Sets the term tuple of the aggregate element.
      Parameters:
      terms - the term tuple to set
    • setRight

      public void setRight(List<ASPBodyElement> literals)
      Sets the literal tuple of this aggregate element.
      Parameters:
      literals - the literal tuple to set
    • substitute

      public AggregateElement substitute(Map<? extends Term<?>,? extends Term<?>> map) throws IllegalArgumentException
      Description copied from interface: ComplexLogicalFormula
      Substitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.
      Specified by:
      substitute in interface ComplexLogicalFormula
      Overrides:
      substitute in class ASPElement
      Parameters:
      map - a mapping defining which terms to be substituted.
      Returns:
      a formula where every term in map.keyset() has been replaced by map.get(v).
      Throws:
      IllegalArgumentException - if any term and its mapping are of different sorts
    • exchange

      public AggregateElement exchange(Term<?> v, Term<?> t) throws IllegalArgumentException
      Description copied from interface: ComplexLogicalFormula
      Substitutes all occurrences of term "v" in this formula by term "t" and at the same time replaces all occurrences of term "t" by term "v" and eventually returns the new formula.
      Specified by:
      exchange in interface ComplexLogicalFormula
      Overrides:
      exchange in class ASPElement
      Parameters:
      v - a term.
      t - a term.
      Returns:
      a new logical formula with both "v" and "t" exchanged.
      Throws:
      IllegalArgumentException - if "v" and "t" are of different sorts
    • getLiterals

      public SortedSet<ASPLiteral> getLiterals()
    • toString

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

      public String printToClingo()
      Description copied from class: ASPElement
      Returns a representation of this ASP element in clingo (potassco) syntax. See https://potassco.org/ for more information.
      Overrides:
      printToClingo in class ASPElement
      Returns:
      String representation in clingo syntax
    • printToDLV

      public String printToDLV()
      Description copied from class: ASPElement
      Returns a representation of this ASP element in DLV syntax. See http://www.dlvsystem.com/html/DLV_User_Manual.html for more information.
      Overrides:
      printToDLV in class ASPElement
      Returns:
      String representation in DLV syntax
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface SimpleLogicalFormula
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface SimpleLogicalFormula
      Overrides:
      equals in class Object