Package net.sf.tweety.arg.aspic.syntax
Class InferenceRule<T extends Invertable>
- java.lang.Object
-
- net.sf.tweety.arg.aspic.syntax.InferenceRule<T>
-
- Type Parameters:
T- is the type of the language that the ASPIC theory's rules range over
- All Implemented Interfaces:
Formula,Rule<T,T>,ComplexLogicalFormula,LogicStructure,SimpleLogicalFormula
- Direct Known Subclasses:
DefeasibleInferenceRule,StrictInferenceRule
public abstract class InferenceRule<T extends Invertable> extends java.lang.Object implements Rule<T,T>, ComplexLogicalFormula
- Author:
- Nils Geilen This stands for an inference rule or for a premise if premises has length 0. If this is a premise and defeasible it is an ordinary premise else it is an axiom.
-
-
Constructor Summary
Constructors Constructor Description InferenceRule()Creates an empty instanceInferenceRule(T conclusion, java.util.Collection<T> premise)Constructs a new inference rule of rule p -> c if strict or p => c else
-
Method Summary
Modifier and Type Method Description voidaddPremise(T premise)voidaddPremises(java.util.Collection<? extends T> premises)java.util.Set<InferenceRule<T>>allGroundInstances(java.util.Set<Constant> constants)java.util.Set<java.util.Map<Variable,Term<?>>>allSubstitutions(java.util.Collection<? extends Term<?>> terms)Computes all possible substitutions, i.e.abstract InferenceRule<T>clone()Creates a deep copy of this formula<C extends Term<?>>
booleancontainsTermsOfType(java.lang.Class<C> cls)Checks if this logical structure contains at least one term of type C.booleanequals(java.lang.Object obj)InferenceRule<T>exchange(Term<?> v, Term<?> t)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.java.util.Set<? extends Atom>getAtoms()Processes the set of all atoms which appear in this formulaTgetConclusion()Returns the conclusion of this rule.java.lang.StringgetIdentifier()Returns the name if it has one, else it returns the hashcodejava.lang.StringgetName()Returns the namejava.lang.Class<? extends Predicate>getPredicateCls()java.util.Set<? extends Predicate>getPredicates()Processes the set of all predicates which appear in this formulajava.util.Collection<? extends T>getPremise()Returns the premise of this rule.SignaturegetSignature()Returns the signature of the language of this formula.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()inthashCode()booleanisConstraint()abstract booleanisDefeasible()booleanisFact()booleanisGround()Checks whether this formula is ground, i.e.booleanisLiteral()booleanisWellFormed()Checks if this formula is well formed in the logical langauge.voidsetConclusion(T conclusion)voidsetName(java.lang.String name)Sets the nameInferenceRule<T>substitute(java.util.Map<? extends Term<?>,? extends Term<?>> map)Substitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.abstract InferenceRule<T>substitute(Term<?> v, Term<?> t)Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.DefeasibleInferenceRule<T>toDefeasible()StrictInferenceRule<T>toStrict()java.lang.StringtoString()
-
-
-
Method Detail
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceSimpleLogicalFormula- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfaceSimpleLogicalFormula- Overrides:
equalsin classjava.lang.Object
-
isDefeasible
public abstract boolean isDefeasible()
- Returns:
- true iff this rule is defeasible
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toStrict
public StrictInferenceRule<T> toStrict()
- Returns:
- a strict instance of this rule
-
toDefeasible
public DefeasibleInferenceRule<T> toDefeasible()
- Returns:
- a defeasible instance of this rule
-
getIdentifier
public java.lang.String getIdentifier()
Returns the name if it has one, else it returns the hashcode- Returns:
- an identifier for this rule
-
getName
public java.lang.String getName()
Returns the name- Returns:
- this rul's name
-
setName
public void setName(java.lang.String name)
Sets the name- Parameters:
name- new name
-
isFact
public boolean isFact()
- Specified by:
isFactin interfaceRule<T extends Invertable,T extends Invertable>
-
isConstraint
public boolean isConstraint()
- Specified by:
isConstraintin interfaceRule<T extends Invertable,T extends Invertable>
-
setConclusion
public void setConclusion(T conclusion)
- Specified by:
setConclusionin interfaceRule<T extends Invertable,T extends Invertable>
-
addPremise
public void addPremise(T premise)
- Specified by:
addPremisein interfaceRule<T extends Invertable,T extends Invertable>
-
addPremises
public void addPremises(java.util.Collection<? extends T> premises)
- Specified by:
addPremisesin interfaceRule<T extends Invertable,T extends Invertable>
-
getSignature
public Signature getSignature()
Description copied from interface:FormulaReturns the signature of the language of this formula.- Specified by:
getSignaturein interfaceFormula- Specified by:
getSignaturein interfaceRule<T extends Invertable,T extends Invertable>- Returns:
- the signature of the language of this formula.
-
getPremise
public java.util.Collection<? extends T> getPremise()
Description copied from interface:RuleReturns the premise of this rule.- Specified by:
getPremisein interfaceRule<T extends Invertable,T extends Invertable>- Returns:
- the premise of this rule.
-
getConclusion
public T getConclusion()
Description copied from interface:RuleReturns the conclusion of this rule.- Specified by:
getConclusionin interfaceRule<T extends Invertable,T extends Invertable>- Returns:
- the conclusion of this rule.
-
allGroundInstances
public java.util.Set<InferenceRule<T>> allGroundInstances(java.util.Set<Constant> constants)
-
substitute
public abstract InferenceRule<T> substitute(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException
Description copied from interface:ComplexLogicalFormulaSubstitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.- Specified by:
substitutein interfaceComplexLogicalFormula- 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
-
substitute
public InferenceRule<T> substitute(java.util.Map<? extends Term<?>,? extends Term<?>> map) throws java.lang.IllegalArgumentException
Description copied from interface:ComplexLogicalFormulaSubstitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.- Specified by:
substitutein interfaceComplexLogicalFormula- 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
-
clone
public abstract InferenceRule<T> clone()
Description copied from interface:SimpleLogicalFormulaCreates a deep copy of this formula- Specified by:
clonein interfaceComplexLogicalFormula- Specified by:
clonein interfaceSimpleLogicalFormula- Returns:
- the cloned formula
-
allSubstitutions
public java.util.Set<java.util.Map<Variable,Term<?>>> allSubstitutions(java.util.Collection<? extends Term<?>> terms) throws java.lang.IllegalArgumentException
Computes all possible substitutions, i.e. maps from variables to terms, of unbound variables of this formula's inner fol formulas to terms in "terms".- Parameters:
terms- a set of terms.- Returns:
- a set of maps from variables to terms.
- Throws:
java.lang.IllegalArgumentException- if there is an unbound variable in this formula for which there is no term in "terms" with the same sort.
-
getUnboundVariables
public java.util.Set<Variable> getUnboundVariables()
-
exchange
public InferenceRule<T> exchange(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException
Description copied from interface:ComplexLogicalFormulaSubstitutes 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:
exchangein interfaceComplexLogicalFormula- 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
-
isGround
public boolean isGround()
Description copied from interface:ComplexLogicalFormulaChecks whether this formula is ground, i.e. whether there appears no variable in this formula.- Specified by:
isGroundin interfaceComplexLogicalFormula- Returns:
- "true" if this formula is ground.
-
isWellFormed
public boolean isWellFormed()
Description copied from interface:ComplexLogicalFormulaChecks 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:
isWellFormedin interfaceComplexLogicalFormula- Returns:
- true if the formula is well-formed, false otherwise
-
getAtoms
public java.util.Set<? extends Atom> getAtoms()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
getAtomsin interfaceSimpleLogicalFormula- Returns:
- The set of all atoms
-
getPredicateCls
public java.lang.Class<? extends Predicate> getPredicateCls()
- Specified by:
getPredicateClsin interfaceSimpleLogicalFormula- Returns:
- The class description of the predicate used by this formula.
-
isLiteral
public boolean isLiteral()
- Specified by:
isLiteralin interfaceSimpleLogicalFormula- Returns:
- true if the formula represents a literal in the language or false otherwise
-
containsTermsOfType
public <C extends Term<?>> boolean containsTermsOfType(java.lang.Class<C> cls)
Description copied from interface:LogicStructureChecks if this logical structure contains at least one term of type C. This method is a shortcut for !getTerms(TermImplementation.class).isEmpty().- Specified by:
containsTermsOfTypein interfaceLogicStructure- 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.
-
getPredicates
public java.util.Set<? extends 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
-
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
-
-