Class InferenceRule<T extends Invertable>
java.lang.Object
org.tweetyproject.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 Object
implements Rule<T,T>, ComplexLogicalFormula
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.
- Author:
- Nils Geilen
-
Constructor Summary
ConstructorDescriptionCreates an empty instanceInferenceRule
(T conclusion, Collection<T> premise) Constructs a new inference rule of rule p -> c if strict or p => c else -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPremise
(T premise) Add the given premise to this rule.void
addPremises
(Collection<? extends T> premises) Add the given premises to this rule.allGroundInstances
(Set<Constant> constants) allSubstitutions
(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
(Class<C> cls) Checks if this logical structure contains at least one term of type C.boolean
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.getAtoms()
Processes the set of all atoms which appear in this formulaReturns the conclusion of this rule.Returns the name if it has one, else it returns the hashcodegetName()
Returns the nameProcesses the set of all predicates which appear in this formulaCollection<? extends T>
Returns the premise of this rule.Returns the signature of the language of this formula.getTerms()
Processes the set containing all terms of type C.int
hashCode()
boolean
isConstraintabstract boolean
boolean
isFact()
isFactboolean
isGround()
Checks whether this formula is ground, i.e.boolean
boolean
Checks if this formula is well formed in the logical langauge.void
setConclusion
(T conclusion) Set the conclusion of this rule.void
Sets the namesubstitute
(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.toStrict()
toString()
-
Constructor Details
-
InferenceRule
public InferenceRule()Creates an empty instance -
InferenceRule
Constructs a new inference rule of rule p -> c if strict or p => c else- Parameters:
conclusion
- ^= ppremise
- ^= c
-
-
Method Details
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceSimpleLogicalFormula
- Overrides:
hashCode
in classObject
-
equals
- Specified by:
equals
in interfaceSimpleLogicalFormula
- Overrides:
equals
in classObject
-
isDefeasible
public abstract boolean isDefeasible()- Returns:
- true iff this rule is defeasible
-
toString
-
toStrict
- Returns:
- a strict instance of this rule
-
toDefeasible
- Returns:
- a defeasible instance of this rule
-
getIdentifier
Returns the name if it has one, else it returns the hashcode- Returns:
- an identifier for this rule
-
getName
Returns the name- Returns:
- this rul's name
-
setName
Sets the name- Parameters:
name
- new name
-
isFact
public boolean isFact()Description copied from interface:Rule
isFact- Specified by:
isFact
in interfaceRule<T extends Invertable,
T extends Invertable> - Returns:
- whether the rule is a fact
-
isConstraint
public boolean isConstraint()Description copied from interface:Rule
isConstraint- Specified by:
isConstraint
in interfaceRule<T extends Invertable,
T extends Invertable> - Returns:
- whether the rule is a constraint
-
setConclusion
Description copied from interface:Rule
Set the conclusion of this rule.- Specified by:
setConclusion
in interfaceRule<T extends Invertable,
T extends Invertable> - Parameters:
conclusion
- some formula
-
addPremise
Description copied from interface:Rule
Add the given premise to this rule.- Specified by:
addPremise
in interfaceRule<T extends Invertable,
T extends Invertable> - Parameters:
premise
- some formula
-
addPremises
Description copied from interface:Rule
Add the given premises to this rule.- Specified by:
addPremises
in interfaceRule<T extends Invertable,
T extends Invertable> - Parameters:
premises
- some formulas
-
getSignature
Description copied from interface:Formula
Returns the signature of the language of this formula.- Specified by:
getSignature
in interfaceFormula
- Specified by:
getSignature
in interfaceRule<T extends Invertable,
T extends Invertable> - Returns:
- the signature of the language of this formula.
-
getPremise
Description copied from interface:Rule
Returns the premise of this rule.- Specified by:
getPremise
in interfaceRule<T extends Invertable,
T extends Invertable> - Returns:
- the premise of this rule.
-
getConclusion
Description copied from interface:Rule
Returns the conclusion of this rule.- Specified by:
getConclusion
in interfaceRule<T extends Invertable,
T extends Invertable> - Returns:
- the conclusion of this rule.
-
allGroundInstances
- Parameters:
constants
- constans- Returns:
- all ground instances
-
substitute
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 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:
IllegalArgumentException
- if "v" and "t" are of different sorts
-
substitute
public InferenceRule<T> substitute(Map<? extends Term<?>, ? extends Term<?>> map) throws IllegalArgumentExceptionDescription copied from interface:ComplexLogicalFormula
Substitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.- Specified by:
substitute
in 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:
IllegalArgumentException
- if any term and its mapping are of different sorts
-
clone
Description copied from interface:SimpleLogicalFormula
Creates a deep copy of this formula- Specified by:
clone
in interfaceComplexLogicalFormula
- Specified by:
clone
in interfaceSimpleLogicalFormula
- Returns:
- the cloned formula
-
allSubstitutions
public Set<Map<Variable,Term<?>>> allSubstitutions(Collection<? extends Term<?>> terms) throws 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:
IllegalArgumentException
- if there is an unbound variable in this formula for which there is no term in "terms" with the same sort.
-
getUnboundVariables
- Returns:
- the unbound variables
-
exchange
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 interfaceComplexLogicalFormula
- Parameters:
v
- a term.t
- a term.- Returns:
- a new logical formula with both "v" and "t" exchanged.
- Throws:
IllegalArgumentException
- if "v" and "t" are of different sorts
-
isGround
public boolean isGround()Description copied from interface:ComplexLogicalFormula
Checks whether this formula is ground, i.e. whether there appears no variable in this formula.- Specified by:
isGround
in interfaceComplexLogicalFormula
- Returns:
- "true" if this formula is ground.
-
isWellFormed
public boolean isWellFormed()Description copied from interface:ComplexLogicalFormula
Checks 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:
isWellFormed
in interfaceComplexLogicalFormula
- Returns:
- true if the formula is well-formed, false otherwise
-
getAtoms
Description copied from interface:SimpleLogicalFormula
Processes the set of all atoms which appear in this formula- Specified by:
getAtoms
in interfaceSimpleLogicalFormula
- Returns:
- The set of all atoms
-
getPredicateCls
- Specified by:
getPredicateCls
in interfaceSimpleLogicalFormula
- Returns:
- The class description of the predicate used by this formula.
-
isLiteral
public boolean isLiteral()- Specified by:
isLiteral
in interfaceSimpleLogicalFormula
- Returns:
- true if the formula represents a literal in the language or false otherwise
-
containsTermsOfType
Description copied from interface:LogicStructure
Checks if this logical structure contains at least one term of type C. This method is a shortcut for !getTerms(TermImplementation.class).isEmpty().- Specified by:
containsTermsOfType
in 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
Description copied from interface:SimpleLogicalFormula
Processes the set of all predicates which appear in this formula- Specified by:
getPredicates
in interfaceSimpleLogicalFormula
- Returns:
- all predicates that appear in this formula
-
getTerms
- Specified by:
getTerms
in interfaceLogicStructure
- Returns:
- a set containing all terms of this logical structure
-
getTerms
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 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
-