Package net.sf.tweety.arg.aba.syntax
Class AbaElement<T extends Formula>
- java.lang.Object
-
- net.sf.tweety.arg.aba.syntax.AbaElement<T>
-
- Type Parameters:
T
- the type of formula
- All Implemented Interfaces:
Formula
,ComplexLogicalFormula
,LogicStructure
,SimpleLogicalFormula
public abstract class AbaElement<T extends Formula> extends java.lang.Object implements ComplexLogicalFormula
Abstract class that models common properties of aba syntax elements.- Author:
- Anna Gessler
-
-
Constructor Summary
Constructors Constructor Description AbaElement()
-
Method Summary
Modifier and Type Method Description java.util.Set<? extends AbaElement<T>>
allGroundInstances(java.util.Set<Constant> constants)
Computes all ground instances of all inner fol formulas wrt.java.util.Set<java.util.Map<Variable,Term<?>>>
allSubstitutions(java.util.Collection<? extends Term<?>> terms)
Computes all possible substitutions, i.e.abstract AbaElement<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.AbaElement<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 formulajava.lang.Class<? extends Predicate>
getPredicateCls()
java.util.Set<Variable>
getUnboundVariables()
boolean
isGround()
Checks whether this formula is ground, i.e.boolean
isLiteral()
boolean
isWellFormed()
Checks if this formula is well formed in the logical langauge.AbaElement<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 AbaElement<T>
substitute(Term<?> v, Term<?> t)
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.tweety.commons.Formula
getSignature
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.LogicStructure
getTerms, getTerms
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
equals, getPredicates, hashCode
-
-
-
-
Method Detail
-
clone
public abstract AbaElement<T> 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
-
containsTermsOfType
public <C extends Term<?>> boolean containsTermsOfType(java.lang.Class<C> cls)
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.
-
substitute
public abstract AbaElement<T> substitute(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException
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:
java.lang.IllegalArgumentException
- if "v" and "t" are of different sorts
-
substitute
public AbaElement<T> substitute(java.util.Map<? extends Term<?>,? extends Term<?>> map) throws java.lang.IllegalArgumentException
Description 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:
java.lang.IllegalArgumentException
- if any term and its mapping are of different sorts
-
exchange
public AbaElement<T> exchange(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException
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:
java.lang.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
-
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.
-
allGroundInstances
public java.util.Set<? extends AbaElement<T>> allGroundInstances(java.util.Set<Constant> constants)
Computes all ground instances of all inner fol formulas wrt. the given set of constants, i.e. every formula where each occurrence of some unbound variable is replaced by some constant.- Parameters:
constants
- a set of constants- Returns:
- a set of ground instances of this formula
- Throws:
java.lang.IllegalArgumentException
- if there is an unbound variable in this formula for which there is no constant in "constants" with the same sort.
-
getUnboundVariables
public java.util.Set<Variable> getUnboundVariables()
-
isLiteral
public boolean isLiteral()
- Specified by:
isLiteral
in interfaceSimpleLogicalFormula
- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getAtoms
public java.util.Set<? extends Atom> 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
public java.lang.Class<? extends Predicate> getPredicateCls()
- Specified by:
getPredicateCls
in interfaceSimpleLogicalFormula
- Returns:
- The class description of the predicate used by this formula.
-
-