Package org.tweetyproject.lp.asp.syntax
Class ASPElement
java.lang.Object
org.tweetyproject.lp.asp.syntax.ASPElement
- All Implemented Interfaces:
Formula,ComplexLogicalFormula,LogicStructure,SimpleLogicalFormula
- Direct Known Subclasses:
AggregateElement,ASPBodyElement,ASPHead,ASPRule,ChoiceElement,OptimizationElement
This class acts as an abstract base class for elements
of ASP rules.
- Author:
- Anna Gessler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ASPElementclone()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.getAtoms()Processes the set of all atoms which appear in this formulaProcesses the set of all predicates which appear in this formulaabstract FolSignatureReturns the signature of the language of this formula.booleanisGround()Checks whether this formula is ground, i.e.booleanChecks if this formula is well formed in the logical langauge.Returns a representation of this ASP element in clingo (potassco) syntax.Returns a representation of this ASP element in DLV syntax.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.abstract ASPElementsubstitute(Term<?> t, Term<?> v) 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, waitMethods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.LogicStructure
getTerms, getTermsMethods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.SimpleLogicalFormula
equals, hashCode, isLiteral
-
Constructor Details
-
ASPElement
public ASPElement()Default Constructor
-
-
Method Details
-
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
-
substitute
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:
t- the term to be substituted.v- the term to substitute.- Returns:
- a formula where every occurrence of "v" is replaced by "t".
-
getSignature
Description copied from interface:FormulaReturns the signature of the language of this formula.- Specified by:
getSignaturein interfaceFormula- Returns:
- the signature of the language of this formula.
-
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
-
clone
Description copied from interface:SimpleLogicalFormulaCreates a deep copy of this formula- Specified by:
clonein interfaceComplexLogicalFormula- Specified by:
clonein interfaceSimpleLogicalFormula- Returns:
- the cloned formula
-
substitute
public ASPElement substitute(Map<? extends Term<?>, ? extends Term<?>> map) throws IllegalArgumentExceptionDescription 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:
IllegalArgumentException- if any term and its mapping are of different sorts
-
exchange
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:
IllegalArgumentException- if "v" and "t" are of different sorts
-
containsTermsOfType
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.
-
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
-
getPredicateCls
- Specified by:
getPredicateClsin interfaceSimpleLogicalFormula- Returns:
- The class description of the predicate used by this formula.
-
printToClingo
Returns a representation of this ASP element in clingo (potassco) syntax. See https://potassco.org/ for more information.- Returns:
- String representation in clingo syntax
-
printToDLV
Returns a representation of this ASP element in DLV syntax. See http://www.dlvsystem.com/html/DLV_User_Manual.html for more information.- Returns:
- String representation in DLV syntax
-