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​(ASPHead head,
                       ASPBodyElement b)
        Creates a rule with the given head and a single-element body.
        Parameters:
        head - an ASPHead
        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 weak 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 weak constraint with the given weight, level (priority) and terms.
        Parameters:
        body - a list of ASPBodyElement
        weight - a term
        level - a term
        terms - a list of terms
      • ASPRule

        public ASPRule​(OptimizationStatement opt)
        Creates a new rule with the given optimization statement.
        Parameters:
        opt - OptimizationStatement
      • ASPRule

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

      • addPremises

        public void addPremises​(java.util.Collection<? extends ASPBodyElement> premises)
        Description copied from interface: Rule
        Add the given premises to this rule.
        Specified by:
        addPremises in interface Rule<ASPHead,​ASPBodyElement>
        Parameters:
        premises - some formulas
      • addBody

        public void addBody​(ASPBodyElement premise)
        Add the given body element to this rule.
        Parameters:
        premise -
      • getBody

        public java.util.List<ASPBodyElement> getBody()
        Returns:
        the body of this rule
      • addBodyElements

        public void addBodyElements​(java.util.Collection<? extends ASPBodyElement> premises)
        Add the given body elements to this rule.
        Parameters:
        premises -
      • setBody

        public void setBody​(ASPBodyElement... aspBodyElements)
        Set this rule's body to the given ASPBodyElements.
        Parameters:
        aspBodyElements -
      • setConclusion

        public void setConclusion​(ASPHead conclusion)
        Description copied from interface: Rule
        Set the conclusion of this rule.
        Specified by:
        setConclusion in interface Rule<ASPHead,​ASPBodyElement>
        Parameters:
        conclusion - some formula
      • setConclusion

        public void setConclusion​(ASPLiteral head)
        Set the conclusion of this rule.
        Parameters:
        head -
      • addToHead

        public void addToHead​(ASPLiteral literal)
        Add the given literal to the head of the rule.
        Parameters:
        literal - ASPLiteral
      • getHead

        public ASPHead getHead()
        Returns:
        head of this rule
      • setHead

        public void setHead​(ASPHead head)
        Set the head of this rule.
        Parameters:
        head -
      • setHead

        public void setHead​(ASPLiteral head)
        Set the head of this rule.
        Parameters:
        head -
      • getWeight

        public Term<?> getWeight()
        Returns:
        the weight of this constraint.
      • setWeight

        public void setWeight​(Term<?> weight)
        Set the weight attribute of this constraint.
        Parameters:
        weight - a term
      • getLevel

        public Term<?> getLevel()
        Returns:
        the level attribute of this constraint.
      • setLevel

        public void setLevel​(Term<?> level)
        Set the level attribute of this constraint.
        Parameters:
        level - a term
      • getConstraintTerms

        public java.util.List<Term<?>> getConstraintTerms()
        Returns:
        the constraint terms of this rule.
      • isOptimizationStatement

        public boolean isOptimizationStatement()
      • isEmpty

        public boolean isEmpty()
        Returns:
        true if the rule's head and body are both empty, false otherwise.
      • 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
      • 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
      • 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.
      • compareTo

        public int compareTo​(ASPRule arg0)
        Specified by:
        compareTo in interface java.lang.Comparable<ASPRule>
      • 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
      • toString

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

        public java.lang.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