Class DelpRule

All Implemented Interfaces:
Formula, Rule<FolFormula,FolFormula>, ClassicalFormula, ComplexLogicalFormula, Conjunctable, Disjunctable, Invertable, LogicStructure, ProbabilityAware, QuantifiedFormula, SimpleLogicalFormula
Direct Known Subclasses:
DefeasibleRule, DelpFact, StrictRule

public abstract class DelpRule extends RelationalFormula implements Rule<FolFormula,FolFormula>
This method is the superclass for both a strict rule and a defeasible rule in defeasible logic programming and captures their common attributes and methods.
Author:
Matthias Thimm, Tim Janus
  • Method Details

    • isApplicable

      public boolean isApplicable(Collection<? extends FolFormula> literals)
      Checks whether this rule is applicaple in the given context literals,
      Parameters:
      literals - a set of literals
      Returns:
      true iff this rule is applicaple, i.e., if the body of the rule is a subset of the given set of literals
    • isGround

      public boolean isGround()
      Checks whether there appear any variables in this rule
      Specified by:
      isGround in interface ComplexLogicalFormula
      Overrides:
      isGround in class RelationalFormula
      Returns:
      true iff there appears no variable in this rule
    • getPremise

      public Collection<? extends FolFormula> getPremise()
      Description copied from interface: Rule
      Returns the premise of this rule.
      Specified by:
      getPremise in interface Rule<FolFormula,FolFormula>
      Returns:
      the premise of this rule.
    • getConclusion

      public FolFormula getConclusion()
      Description copied from interface: Rule
      Returns the conclusion of this rule.
      Specified by:
      getConclusion in interface Rule<FolFormula,FolFormula>
      Returns:
      the conclusion of this rule.
    • combineWithAnd

      public Conjunction combineWithAnd(Conjunctable f)
      Description copied from interface: Conjunctable
      Returns a conjunction of this and the given formula.
      Specified by:
      combineWithAnd in interface Conjunctable
      Specified by:
      combineWithAnd in class RelationalFormula
      Parameters:
      f - a formula to be combined with AND and this.
      Returns:
      a conjunction of this and the given formula.
    • combineWithOr

      public Disjunction combineWithOr(Disjunctable f)
      Specified by:
      combineWithOr in interface Disjunctable
      Specified by:
      combineWithOr in class RelationalFormula
      Parameters:
      f - a formula to be combined with OR and this.
      Returns:
      a disjunction of this and the given formula.
    • complement

      public RelationalFormula complement()
      Specified by:
      complement in interface Invertable
      Specified by:
      complement in class RelationalFormula
      Returns:
      the complement of this formula.
    • 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
      Returns:
      all predicates that appear in this formula
    • getAtoms

      public Set<FolAtom> 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 RelationalFormula
      Returns:
      all atoms that appear in this formula.
    • 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 Set<Term<?>> getTerms()
      Specified by:
      getTerms in interface LogicStructure
      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.
      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
    • getQuantifierVariables

      public Set<Variable> getQuantifierVariables()
      Specified by:
      getQuantifierVariables in interface QuantifiedFormula
      Returns:
      a set containing all quantified variables
    • isFact

      public boolean isFact()
      Description copied from interface: Rule
      isFact
      Specified by:
      isFact in interface Rule<FolFormula,FolFormula>
      Returns:
      whether the rule is a fact
    • isConstraint

      public boolean isConstraint()
      Description copied from interface: Rule
      isConstraint
      Specified by:
      isConstraint in interface Rule<FolFormula,FolFormula>
      Returns:
      whether the rule is a constraint
    • setConclusion

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

      public void addPremise(FolFormula premise)
      Description copied from interface: Rule
      Add the given premise to this rule.
      Specified by:
      addPremise in interface Rule<FolFormula,FolFormula>
      Parameters:
      premise - some formula
    • addPremises

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

      public boolean containsQuantifier()
      Description copied from interface: QuantifiedFormula
      Checks whether this formula contains any quantification.
      Specified by:
      containsQuantifier in interface QuantifiedFormula
      Returns:
      "true" if this formula contains a quantification.
    • substitute

      public abstract RelationalFormula substitute(Term<?> v, Term<?> t) throws IllegalArgumentException
      Description copied from class: RelationalFormula
      Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula. NOTE: if "v" is a variable and bound to a quantifier then "v" is not substituted in that quantifiers inner formula.
      Specified by:
      substitute in interface ComplexLogicalFormula
      Specified by:
      substitute in class RelationalFormula
      Parameters:
      v - the term to be substituted.
      t - the term to substitute.
      Returns:
      a formula where every occurrence of "v" is replaced by "t".
      Throws:
      IllegalArgumentException - if "v" and "t" are of different sorts (NOTE: this exception is only thrown when "v" actually appears in this formula).
    • getUnboundVariables

      public Set<Variable> getUnboundVariables()
      Specified by:
      getUnboundVariables in interface QuantifiedFormula
      Returns:
      a set of of unbound variables
    • isClosed

      public boolean isClosed()
      Description copied from interface: QuantifiedFormula
      Checks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier.
      Specified by:
      isClosed in interface QuantifiedFormula
      Returns:
      "true" if this formula is closed, "false" otherwise.
    • isClosed

      public boolean isClosed(Set<Variable> boundVariables)
      Description copied from interface: QuantifiedFormula
      Checks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier. Every variable in "boundVariables" is already assumed to be bound.
      Specified by:
      isClosed in interface QuantifiedFormula
      Parameters:
      boundVariables - the variables assumed to be bound.
      Returns:
      "true" if this formula is closed wrt. "boundVariables", "false" otherwise.
    • isWellBound

      public boolean isWellBound()
      Description copied from interface: QuantifiedFormula
      Checks whether this formula is well-bound, i.e. whether no variable bound by a quantifier is again bound by another quantifier within the first quantifier's range.
      Specified by:
      isWellBound in interface QuantifiedFormula
      Returns:
      "true" if this formula is well-bound, "false" otherwise.
    • isWellBound

      public boolean isWellBound(Set<Variable> boundVariables)
      Description copied from interface: QuantifiedFormula
      Checks whether this formula is well-bound, i.e. whether no variable bound by a quantifier is again bound by another quantifier within the first quantifier range. Every variable in "boundVariables" is assumed to be bound already.
      Specified by:
      isWellBound in interface QuantifiedFormula
      Parameters:
      boundVariables - the variables assumed to be bound.
      Returns:
      "true" if this formula is well-bound, "false" otherwise.
    • getFunctors

      public Set<Functor> getFunctors()
      Specified by:
      getFunctors in class RelationalFormula
      Returns:
      all functors that appear in this formula.
    • getUniformProbability

      public Probability getUniformProbability()
      Specified by:
      getUniformProbability in interface ProbabilityAware
      Specified by:
      getUniformProbability in class RelationalFormula
      Returns:
      this formula's probability in the uniform distribution.
    • toString

      public String toString()
      Specified by:
      toString in class RelationalFormula
    • equals

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

      public int hashCode()
      Specified by:
      hashCode in interface SimpleLogicalFormula
      Overrides:
      hashCode in class Object
    • 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 interface Rule<FolFormula,FolFormula>
      Returns:
      the signature of the language of this formula.