Class ASPRule

    • Constructor Detail

      • ASPRule

        public ASPRule()
        Empty constructor
      • ASPRule

        public ASPRule​(ASPHead head)
        Creates a fact with the given ASPHead.
        Parameters:
        head - an ASPHead
      • ASPRule

        public ASPRule​(ASPLiteral literal)
        Creates a fact with the given literal.
        Parameters:
        literal - a literal
      • ASPRule

        public ASPRule​(ASPHead head,
                       java.util.List<ASPBodyElement> body)
        Creates a rule with the given head and body.
        Parameters:
        head - an ASPHead
        body - a list of ASPBodyElement
      • ASPRule

        public ASPRule​(ASPLiteral head,
                       ASPBodyElement b)
        Creates a rule with the given head and a single-element body.
        Parameters:
        head - an ASPLiteral
        b - a body element
      • ASPRule

        public ASPRule​(ASPLiteral head,
                       java.util.List<ASPBodyElement> body)
        Creates a rule with the given head and body.
        Parameters:
        head - an ASPLiteral
        body - a list of ASPBodyElement
      • ASPRule

        public ASPRule​(java.util.List<ASPBodyElement> body)
        Creates a constraint with the given body.
        Parameters:
        body - a list of ASPBodyElement
      • ASPRule

        public ASPRule​(java.util.List<ASPBodyElement> nafliterals,
                       Term<?> weight,
                       java.util.List<Term<?>> terms)
        Creates a constraint with the given weight and terms.
        Parameters:
        nafliterals - the naf literals
        weight - some weight
        terms - a list of terms
      • ASPRule

        public ASPRule​(java.util.List<ASPBodyElement> body,
                       Term<?> weight,
                       Term<?> level,
                       java.util.List<Term<?>> terms)
        Creates a constraint with the given weight, level and terms.
        Parameters:
        body - a list of ASPBodyElement
        weight - a term
        level - a term
        terms - a list of terms
      • ASPRule

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

      • isSafe

        public java.lang.Boolean isSafe()
        This methods tests a rule for safety. Safety is defined as follows in the ASP-Core-2 standard: A rule, weak constraint or query is safe, if the set V of global variables
        Returns:
        true if the rule is safe, false otherwise
      • setConclusion

        public void setConclusion​(ASPLiteral head)
      • toString

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

        public Term<?> getWeight()
      • setWeight

        public void setWeight​(Term<?> weight)
      • getLevel

        public Term<?> getLevel()
      • setLevel

        public void setLevel​(Term<?> level)
      • getHead

        public ASPHead getHead()
      • setHead

        public void setHead​(ASPHead head)
      • addToHead

        public void addToHead​(ASPLiteral h)
      • setBody

        public void setBody​(java.util.List<ASPBodyElement> body)
      • getConstraintTerms

        public java.util.List<Term<?>> getConstraintTerms()
      • compareTo

        public int compareTo​(ASPRule arg0)
        Specified by:
        compareTo in interface java.lang.Comparable<ASPRule>
      • getLiterals

        public java.util.Collection<? extends ASPLiteral> getLiterals()
      • substitute

        public ASPRule substitute​(Term<?> v,
                                  Term<?> t)
        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:
        v - the term to be substituted.
        t - the term to substitute.
        Returns:
        a formula where every occurrence of "v" is replaced by "t".
      • exchange

        public ASPRule exchange​(Term<?> v,
                                Term<?> t)
        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.
      • 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
      • equals

        public boolean equals​(java.lang.Object other)
        Specified by:
        equals in interface SimpleLogicalFormula
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface SimpleLogicalFormula
        Overrides:
        hashCode in class java.lang.Object
      • isEmpty

        public boolean isEmpty()
        Returns:
        true if the rule's head and body are both empty, false otherwise.