Class ComplexLogicalFormulaAdapter
java.lang.Object
org.tweetyproject.logics.commons.syntax.ComplexLogicalFormulaAdapter
- All Implemented Interfaces:
Formula
,ComplexLogicalFormula
,LogicStructure
,SimpleLogicalFormula
- Direct Known Subclasses:
AssociativeFormulaSupport
,NLPRule
Abstract base class for ComplexLogicalFormula, that are formulas which
implement substitute(), exchange(), getTerms(), isGround() and isWellFormed()
and therefore use terms to describe themself.
It also implements the isLiteral method and returns false as default behavior
sub classes needing another behavior shall override this method
- Author:
- Tim Janus
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract ComplexLogicalFormula
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.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.Processes the set containing all terms of type C.boolean
isGround()
Checks whether this formula is ground, i.e.boolean
boolean
Checks if this formula is well formed in the logical langauge.substitute
(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.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.ComplexLogicalFormula
substitute
Methods inherited from interface org.tweetyproject.commons.Formula
getSignature
Methods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.LogicStructure
getTerms
Methods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.SimpleLogicalFormula
equals, getAtoms, getPredicateCls, getPredicates, hashCode
-
Constructor Details
-
ComplexLogicalFormulaAdapter
public ComplexLogicalFormulaAdapter()
-
-
Method Details
-
substitute
public ComplexLogicalFormula 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
-
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
-
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
-
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.
-
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
-
isLiteral
public boolean isLiteral()- Specified by:
isLiteral
in interfaceSimpleLogicalFormula
- Returns:
- true if the formula represents a literal in the language or false otherwise
-
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
-