Class ASPHead

    • Constructor Detail

      • ASPHead

        public ASPHead()
        Empty Constructor.
      • ASPHead

        public ASPHead​(java.util.List<ASPLiteral> head_elements)
        Creates a new head with the given elements.
        Parameters:
        head_elements - list of literals
      • ASPHead

        public ASPHead​(ASPLiteral head)
        Creates a new head with a single element.
        Parameters:
        head - an ASP literal
      • ASPHead

        public ASPHead​(ASPHead other)
        Copy-Constructor
        Parameters:
        other - another ASPHead
    • Method Detail

      • isWellFormed

        public boolean isWellFormed()
        Description copied from interface: ComplexLogicalFormula
        Checks if this formula is well formed in the logical langauge. What well- formed means is highly language dependent and the documentation of implementing sub classes shall describe the well formed term for the language they model.
        Specified by:
        isWellFormed in interface ComplexLogicalFormula
        Overrides:
        isWellFormed in class ASPElement
        Returns:
        true if the formula is well-formed, false otherwise
      • isLiteral

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

        public java.util.Set<Term<?>> getTerms()
        Specified by:
        getTerms in interface LogicStructure
        Returns:
        a set containing all terms of this logical structure
      • getTerms

        public <C extends Term<?>> java.util.Set<C> getTerms​(java.lang.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.
        Specified by:
        getTerms in interface LogicStructure
        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
      • containsTermsOfType

        public <C extends Term<?>> boolean containsTermsOfType​(java.lang.Class<C> cls)
        Description copied from interface: LogicStructure
        Checks if this logical structure contains at least one term of type C. This method is a shortcut for !getTerms(TermImplementation.class).isEmpty().
        Specified by:
        containsTermsOfType in interface LogicStructure
        Overrides:
        containsTermsOfType in class ASPElement
        Type Parameters:
        C - the type of terms
        Parameters:
        cls - The class structure representing the type C of the term.
        Returns:
        True if this logical structure contains at least one term of type C or false otherwise.
      • substitute

        public ASPHead 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.
      • add

        public boolean add​(ASPLiteral e)
        Specified by:
        add in interface java.util.Collection<ASPLiteral>
        Specified by:
        add in interface java.util.List<ASPLiteral>
      • add

        public void add​(int index,
                        ASPLiteral element)
        Specified by:
        add in interface java.util.List<ASPLiteral>
      • addAll

        public boolean addAll​(java.util.Collection<? extends ASPLiteral> c)
        Specified by:
        addAll in interface java.util.Collection<ASPLiteral>
        Specified by:
        addAll in interface java.util.List<ASPLiteral>
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends ASPLiteral> c)
        Specified by:
        addAll in interface java.util.List<ASPLiteral>
      • add

        public boolean add​(ASPLiteral... formulas)
        Adds the specified elements to the end of this collection (optional operation).
        Parameters:
        formulas - to be appended to collection
        Returns:
        true if all elements were added, false otherwise
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<ASPLiteral>
        Specified by:
        clear in interface java.util.List<ASPLiteral>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<ASPLiteral>
        Specified by:
        contains in interface java.util.List<ASPLiteral>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<ASPLiteral>
        Specified by:
        containsAll in interface java.util.List<ASPLiteral>
      • get

        public ASPLiteral get​(int index)
        Specified by:
        get in interface java.util.List<ASPLiteral>
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List<ASPLiteral>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<ASPLiteral>
        Specified by:
        isEmpty in interface java.util.List<ASPLiteral>
      • iterator

        public java.util.Iterator<ASPLiteral> iterator()
        Specified by:
        iterator in interface java.util.Collection<ASPLiteral>
        Specified by:
        iterator in interface java.lang.Iterable<ASPLiteral>
        Specified by:
        iterator in interface java.util.List<ASPLiteral>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<ASPLiteral>
      • listIterator

        public java.util.ListIterator<ASPLiteral> listIterator()
        Specified by:
        listIterator in interface java.util.List<ASPLiteral>
      • listIterator

        public java.util.ListIterator<ASPLiteral> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<ASPLiteral>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<ASPLiteral>
        Specified by:
        remove in interface java.util.List<ASPLiteral>
      • remove

        public ASPLiteral remove​(int index)
        Specified by:
        remove in interface java.util.List<ASPLiteral>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<ASPLiteral>
        Specified by:
        removeAll in interface java.util.List<ASPLiteral>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<ASPLiteral>
        Specified by:
        retainAll in interface java.util.List<ASPLiteral>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<ASPLiteral>
        Specified by:
        size in interface java.util.List<ASPLiteral>
      • subList

        public java.util.List<ASPLiteral> subList​(int fromIndex,
                                                  int toIndex)
        Specified by:
        subList in interface java.util.List<ASPLiteral>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<ASPLiteral>
        Specified by:
        toArray in interface java.util.List<ASPLiteral>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<ASPLiteral>
        Specified by:
        toArray in interface java.util.List<ASPLiteral>
      • getFormulas

        public <C extends SimpleLogicalFormula> java.util.Set<C> getFormulas​(java.lang.Class<C> cls)
        Description copied from interface: AssociativeFormula
        Process the formulas of type C that are children of this associative formula
        Specified by:
        getFormulas in interface AssociativeFormula<ASPLiteral>
        Type Parameters:
        C - the type of formulas
        Parameters:
        cls - the class structure defining the type of formulas which are searched.
        Returns:
        A set of formulas of type C which are members of the associative formula
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • substitute

        public ASPHead substitute​(java.util.Map<? extends Term<?>,​? extends Term<?>> map)
                           throws java.lang.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:
        java.lang.IllegalArgumentException - if any term and its mapping are of different sorts
      • exchange

        public ASPHead exchange​(Term<?> v,
                                Term<?> t)
                         throws java.lang.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:
        java.lang.IllegalArgumentException - if "v" and "t" are of different sorts
      • getLiterals

        public java.util.SortedSet<ASPLiteral> getLiterals()
        Returns all literals in this element in form of a SortedSet. Literals are atoms or strict negations of atoms.
        Returns:
        all the literals used in the rule element
      • equals

        public boolean equals​(java.lang.Object other)
        Specified by:
        equals in interface java.util.Collection<ASPLiteral>
        Specified by:
        equals in interface java.util.List<ASPLiteral>
        Specified by:
        equals in interface SimpleLogicalFormula
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<ASPLiteral>
        Specified by:
        hashCode in interface java.util.List<ASPLiteral>
        Specified by:
        hashCode in interface SimpleLogicalFormula
        Overrides:
        hashCode in class java.lang.Object