Package org.tweetyproject.lp.asp.syntax
Class DefaultNegation
java.lang.Object
org.tweetyproject.lp.asp.syntax.ASPElement
org.tweetyproject.lp.asp.syntax.ASPBodyElement
org.tweetyproject.lp.asp.syntax.DefaultNegation
- All Implemented Interfaces:
Formula,ComplexLogicalFormula,LogicStructure,SimpleLogicalFormula
This class represents a default negated literal, i.e. "not a", where a is a
classical atom or an aggregate atom.
Note: In answer set programming, the body of a rule is usually composed of a set of positive and negative literals, where this valuation refers to default negation or negation as failure. When implementing a rule, there are two options:
- implement the rule with two distinct lists, representing the sets of positive and negative literals
- implement the rule with one set containing super literals, where a super literal can be positive or strictly negated, with or without default negation.
This library takes the second approach, which allows more flexibility, but comes at the cost that malformed constructs like "not not a" are not intercepted by the library.
- Author:
- Tim Janus, Thomas Vengels, Anna Gessler
-
Constructor Summary
ConstructorsConstructorDescriptionCreates new default negation with the given literal. -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a deep copy of this formulabooleangetAtoms()Processes the set of all atoms which appear in this formulaReturns all literals in this element in form of a SortedSet.Processes the set of all predicates which appear in this formulaReturns the signature of the language of this formula.getTerms()Processes the set containing all terms of type C.inthashCode()booleanbooleanChecks 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.voidsetLiteral(ASPBodyElement literal) Set the default negated literal.substitute(Term<?> t, Term<?> v) Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.toString()Methods inherited from class org.tweetyproject.lp.asp.syntax.ASPElement
containsTermsOfType, exchange, getPredicateCls, isGround, substitute
-
Constructor Details
-
DefaultNegation
Creates new default negation with the given literal.- Parameters:
at- a classical atom or an aggregate atom
-
-
Method Details
-
getLiterals
Description copied from class:ASPBodyElementReturns all literals in this element in form of a SortedSet. Literals are atoms or strict negations of atoms.- Specified by:
getLiteralsin classASPBodyElement- Returns:
- all the literals used in the rule element
-
getPredicates
Description copied from interface:SimpleLogicalFormulaProcesses the set of all predicates which appear in this formula- Specified by:
getPredicatesin interfaceSimpleLogicalFormula- Specified by:
getPredicatesin classASPElement- Returns:
- all predicates that appear in this formula
-
getAtoms
Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
getAtomsin interfaceSimpleLogicalFormula- Specified by:
getAtomsin classASPElement- Returns:
- The set of all atoms
-
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- Specified by:
substitutein classASPBodyElement- 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- Specified by:
getSignaturein classASPElement- Returns:
- the signature of the language of this formula.
-
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- Overrides:
isWellFormedin classASPElement- Returns:
- true if the formula is well-formed, false otherwise
-
isLiteral
public boolean isLiteral()- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getTerms
- Returns:
- a set containing all terms of this logical structure
-
getTerms
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.- 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
-
clone
Description copied from interface:SimpleLogicalFormulaCreates a deep copy of this formula- Specified by:
clonein interfaceComplexLogicalFormula- Specified by:
clonein interfaceSimpleLogicalFormula- Specified by:
clonein classASPElement- Returns:
- the cloned formula
-
getLiteral
- Returns:
- the default negated literal
-
setLiteral
Set the default negated literal.- Parameters:
literal-
-
toString
-
printToClingo
Description copied from class:ASPElementReturns a representation of this ASP element in clingo (potassco) syntax. See https://potassco.org/ for more information.- Overrides:
printToClingoin classASPElement- Returns:
- String representation in clingo syntax
-
printToDLV
Description copied from class:ASPElementReturns a representation of this ASP element in DLV syntax. See http://www.dlvsystem.com/html/DLV_User_Manual.html for more information.- Overrides:
printToDLVin classASPElement- Returns:
- String representation in DLV syntax
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceSimpleLogicalFormula- Overrides:
hashCodein classObject
-
equals
- Specified by:
equalsin interfaceSimpleLogicalFormula- Overrides:
equalsin classObject
-