Package net.sf.tweety.arg.delp.syntax
Class DelpRule
- java.lang.Object
-
- net.sf.tweety.logics.commons.syntax.RelationalFormula
-
- net.sf.tweety.arg.delp.syntax.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
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<FolFormula>bodyThe body of the rule (these must be a literals).protected FolFormulaheadThe head of the rule (this must be a literal).
-
Constructor Summary
Constructors Constructor Description DelpRule(FolFormula head, java.util.Collection<? extends FolFormula> body)Default constructor; initializes head and body of the rule
-
Method Summary
Modifier and Type Method Description voidaddPremise(FolFormula premise)voidaddPremises(java.util.Collection<? extends FolFormula> premises)ConjunctioncombineWithAnd(Conjunctable f)Returns a conjunction of this and the given formula.DisjunctioncombineWithOr(Disjunctable f)RelationalFormulacomplement()booleancontainsQuantifier()Checks whether this formula contains any quantification.booleanequals(java.lang.Object o)java.util.Set<FolAtom>getAtoms()Processes the set of all atoms which appear in this formulaFolFormulagetConclusion()Returns the conclusion of this rule.java.util.Set<Functor>getFunctors()java.util.Set<Predicate>getPredicates()Processes the set of all predicates which appear in this formulajava.util.Collection<? extends FolFormula>getPremise()Returns the premise of this rule.java.util.Set<Variable>getQuantifierVariables()FolSignaturegetSignature()Returns the signature of the language of this formula.(package private) abstract java.lang.StringgetSymbol()java.util.Set<Term<?>>getTerms()<C extends Term<?>>
java.util.Set<C>getTerms(java.lang.Class<C> cls)Processes the set containing all terms of type C.java.util.Set<Variable>getUnboundVariables()ProbabilitygetUniformProbability()inthashCode()booleanisApplicable(java.util.Collection<? extends FolFormula> literals)Checks whether this rule is applicaple in the given contextliterals,booleanisClosed()Checks whether this formula is closed, i.e.booleanisClosed(java.util.Set<Variable> boundVariables)Checks whether this formula is closed, i.e.booleanisConstraint()booleanisFact()booleanisGround()Checks whether there appear any variables in this rulebooleanisLiteral()booleanisWellBound()Checks whether this formula is well-bound, i.e.booleanisWellBound(java.util.Set<Variable> boundVariables)Checks whether this formula is well-bound, i.e.voidsetConclusion(FolFormula conclusion)abstract RelationalFormulasubstitute(Term<?> v, Term<?> t)Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.java.lang.StringtoString()-
Methods inherited from class net.sf.tweety.logics.commons.syntax.RelationalFormula
allGroundInstances, allSubstitutions, clone, containsTermsOfType, exchange, getFormula, getPredicateCls, getSatisfactionRatio, isWellFormed, substitute
-
-
-
-
Field Detail
-
head
protected FolFormula head
The head of the rule (this must be a literal).
-
body
protected java.util.Set<FolFormula> body
The body of the rule (these must be a literals).
-
-
Constructor Detail
-
DelpRule
DelpRule(FolFormula head, java.util.Collection<? extends FolFormula> body)
Default constructor; initializes head and body of the rule- Parameters:
head- a literalbody- a set of literals
-
-
Method Detail
-
getSymbol
abstract java.lang.String getSymbol()
-
isApplicable
public boolean isApplicable(java.util.Collection<? extends FolFormula> literals)
Checks whether this rule is applicaple in the given contextliterals,- Parameters:
literals- a set of literals- Returns:
trueiff 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:
isGroundin interfaceComplexLogicalFormula- Overrides:
isGroundin classRelationalFormula- Returns:
trueiff there appears no variable in this rule
-
getPremise
public java.util.Collection<? extends FolFormula> getPremise()
Description copied from interface:RuleReturns the premise of this rule.- Specified by:
getPremisein interfaceRule<FolFormula,FolFormula>- Returns:
- the premise of this rule.
-
getConclusion
public FolFormula getConclusion()
Description copied from interface:RuleReturns the conclusion of this rule.- Specified by:
getConclusionin interfaceRule<FolFormula,FolFormula>- Returns:
- the conclusion of this rule.
-
combineWithAnd
public Conjunction combineWithAnd(Conjunctable f)
Description copied from interface:ConjunctableReturns a conjunction of this and the given formula.- Specified by:
combineWithAndin interfaceConjunctable- Specified by:
combineWithAndin classRelationalFormula- 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:
combineWithOrin interfaceDisjunctable- Specified by:
combineWithOrin classRelationalFormula- 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:
complementin interfaceInvertable- Specified by:
complementin classRelationalFormula- Returns:
- the complement of this formula.
-
getPredicates
public java.util.Set<Predicate> getPredicates()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all predicates which appear in this formula- Specified by:
getPredicatesin interfaceSimpleLogicalFormula- Returns:
- all predicates that appear in this formula
-
getAtoms
public java.util.Set<FolAtom> getAtoms()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
getAtomsin interfaceSimpleLogicalFormula- Specified by:
getAtomsin classRelationalFormula- Returns:
- all atoms that appear in this formula.
-
isLiteral
public boolean isLiteral()
- Specified by:
isLiteralin interfaceSimpleLogicalFormula- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getTerms
public java.util.Set<Term<?>> getTerms()
- Specified by:
getTermsin interfaceLogicStructure- 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:LogicStructureProcesses 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:
getTermsin interfaceLogicStructure- 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 java.util.Set<Variable> getQuantifierVariables()
- Specified by:
getQuantifierVariablesin interfaceQuantifiedFormula- Returns:
- a set containing all quantified variables
-
isFact
public boolean isFact()
- Specified by:
isFactin interfaceRule<FolFormula,FolFormula>
-
isConstraint
public boolean isConstraint()
- Specified by:
isConstraintin interfaceRule<FolFormula,FolFormula>
-
setConclusion
public void setConclusion(FolFormula conclusion)
- Specified by:
setConclusionin interfaceRule<FolFormula,FolFormula>
-
addPremise
public void addPremise(FolFormula premise)
- Specified by:
addPremisein interfaceRule<FolFormula,FolFormula>
-
addPremises
public void addPremises(java.util.Collection<? extends FolFormula> premises)
- Specified by:
addPremisesin interfaceRule<FolFormula,FolFormula>
-
containsQuantifier
public boolean containsQuantifier()
Description copied from interface:QuantifiedFormulaChecks whether this formula contains any quantification.- Specified by:
containsQuantifierin interfaceQuantifiedFormula- Returns:
- "true" if this formula contains a quantification.
-
substitute
public abstract RelationalFormula substitute(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException
Description copied from class:RelationalFormulaSubstitutes 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:
substitutein interfaceComplexLogicalFormula- Specified by:
substitutein classRelationalFormula- 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:
java.lang.IllegalArgumentException- if "v" and "t" are of different sorts (NOTE: this exception is only thrown when "v" actually appears in this formula).
-
getUnboundVariables
public java.util.Set<Variable> getUnboundVariables()
- Specified by:
getUnboundVariablesin interfaceQuantifiedFormula- Returns:
- a set of of unbound variables
-
isClosed
public boolean isClosed()
Description copied from interface:QuantifiedFormulaChecks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier.- Specified by:
isClosedin interfaceQuantifiedFormula- Returns:
- "true" if this formula is closed, "false" otherwise.
-
isClosed
public boolean isClosed(java.util.Set<Variable> boundVariables)
Description copied from interface:QuantifiedFormulaChecks 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:
isClosedin interfaceQuantifiedFormula- 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:QuantifiedFormulaChecks 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:
isWellBoundin interfaceQuantifiedFormula- Returns:
- "true" if this formula is well-bound, "false" otherwise.
-
isWellBound
public boolean isWellBound(java.util.Set<Variable> boundVariables)
Description copied from interface:QuantifiedFormulaChecks 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:
isWellBoundin interfaceQuantifiedFormula- Parameters:
boundVariables- the variables assumed to be bound.- Returns:
- "true" if this formula is well-bound, "false" otherwise.
-
getFunctors
public java.util.Set<Functor> getFunctors()
- Specified by:
getFunctorsin classRelationalFormula- Returns:
- all functors that appear in this formula.
-
getUniformProbability
public Probability getUniformProbability()
- Specified by:
getUniformProbabilityin interfaceProbabilityAware- Specified by:
getUniformProbabilityin classRelationalFormula- Returns:
- this formula's probability in the uniform distribution.
-
toString
public java.lang.String toString()
- Specified by:
toStringin classRelationalFormula
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equalsin interfaceSimpleLogicalFormula- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceSimpleLogicalFormula- Overrides:
hashCodein classjava.lang.Object
-
getSignature
public FolSignature getSignature()
Description copied from interface:FormulaReturns the signature of the language of this formula.- Specified by:
getSignaturein interfaceFormula- Specified by:
getSignaturein interfaceRule<FolFormula,FolFormula>- Returns:
- the signature of the language of this formula.
-
-