Package net.sf.tweety.arg.dung.syntax
Class DungTheory
- java.lang.Object
-
- net.sf.tweety.commons.BeliefSet<Argument,DungSignature>
-
- net.sf.tweety.arg.dung.syntax.DungTheory
-
- All Implemented Interfaces:
Comparable<DungTheory>,Iterable<Argument>,Collection<Argument>,net.sf.tweety.commons.BeliefBase,net.sf.tweety.graphs.Graph<Argument>
public class DungTheory extends net.sf.tweety.commons.BeliefSet<Argument,DungSignature> implements net.sf.tweety.graphs.Graph<Argument>, Comparable<DungTheory>
This class implements an abstract argumentation theory in the sense of Dung.
See
Phan Minh Dung. On the Acceptability of Arguments and its Fundamental Role in Nonmonotonic Reasoning, Logic Programming and n-Person Games. In Artificial Intelligence, Volume 77(2):321-358. 1995- Author:
- Matthias Thimm, Tjitze Rienstra
-
-
Constructor Summary
Constructors Constructor Description DungTheory()Default constructor; initializes empty sets of arguments and attacksDungTheory(net.sf.tweety.graphs.Graph<Argument> graph)Creates a new theory from the given graph.
-
Method Summary
Modifier and Type Method Description booleanadd(Argument argument)booleanadd(Attack attack)Adds the given attack to this dung theory.booleanadd(DungTheory theory)Adds all arguments and attacks of the given theory to this theorybooleanadd(net.sf.tweety.graphs.Edge<Argument> edge)booleanaddAllAttacks(Collection<? extends Attack> c)Adds the set of attacks to this Dung theory.booleanaddAttack(Argument attacker, Argument attacked)Adds an attack from the first argument to the second to thisDdung theory.booleanareAdjacent(Argument a, Argument b)intcompareTo(DungTheory o)booleancontains(Object o)booleancontainsAll(Collection<?> c)booleancontainsAttack(Attack att)Checks whether this theory contains the given attack.<S extends net.sf.tweety.graphs.Node>
booleancontainsCycle()Checks whether there is at least one cycle in this DungTheory.booleanequals(Object obj)booleanexistsDirectedPath(Argument node1, Argument node2)Extensionfaf(Extension extension)The characteristic function of an abstract argumentation framework: F_AF(S) = {A|A is acceptable wrt.net.sf.tweety.math.matrix.MatrixgetAdjacencyMatrix()Set<Argument>getAttacked(Argument argument)Computes the set {A | (argument,A) in attacks}.Set<Argument>getAttackers(Argument argument)Computes the set {A | (A,argument) in attacks}.Set<Attack>getAttacks()Returns all attacks of this theory.Collection<Argument>getChildren(net.sf.tweety.graphs.Node node)DungTheorygetComplementGraph(int selfloops)Collection<net.sf.tweety.graphs.Graph<Argument>>getComponents()Returns the (connected) components of the theorynet.sf.tweety.graphs.Edge<Argument>getEdge(Argument a, Argument b)Collection<? extends net.sf.tweety.graphs.Edge<? extends Argument>>getEdges()net.sf.tweety.commons.SignaturegetMinimalSignature()Collection<Argument>getNeighbors(Argument node)Collection<Argument>getNodes()intgetNumberOfNodes()Collection<Argument>getParents(net.sf.tweety.graphs.Node node)net.sf.tweety.graphs.Graph<Argument>getRestriction(Collection<Argument> arguments)Collection<Collection<Argument>>getStronglyConnectedComponents()Collection<net.sf.tweety.graphs.Graph<Argument>>getSubgraphs()booleanhasAttackBranch(Argument a)If this graph is acyclic, this method checks if the given argument has an attack branch, i.e.booleanhasDefenseBranch(Argument a)If this graph is acyclic, this method checks if the given argument has a defense branch, i.e.inthashCode()booleanhasSelfLoops()protected DungSignatureinstantiateSignature()booleanisAttackBranch(Argument a, Argument b)Checks whether the path from b to a is an attack branch, i.e.booleanisAttacked(Extension ext1, Extension ext2)returns true if some argument ofext2attacks some argument inext1booleanisAttacked(Argument argument, Extension ext)returns true if some argument ofextattacks argument.booleanisAttackedBy(Argument argument, Collection<Argument> ext)returns true if some argument ofextis attacked by argument.booleanisAttackedBy(Argument arg1, Argument arg2)Checks whether arg1 is attacked by arg2.booleanisAttackingAllOtherArguments(Extension ext)returns true ifargumentsattack all other arguments in the theorybooleanisCoherent()Determines if the theory is coherent, i.e., if each preferred extension is stablebooleanisDefenseBranch(Argument a, Argument b)Checks whether the path from b to a is a defense branch, i.e.booleanisIndirectAttack(Argument arg1, Argument arg2)Checks whether "arg1" indirectly attacks "arg2", i.e.booleanisRelativelyCoherent()Determines if the theory is relatively coherent, i.e., if the grounded extension coincides with the intersection of all preferred extensionsbooleanisStable(Extension e)Checks whether the given extension is stable wrt.booleanisSupport(Argument arg1, Argument arg2)Checks whether "arg1" supports "arg2", i.e.booleanisWeightedGraph()booleanisWellFounded()returns true iff the theory is well-founded, i.e., there is no infinite sequence A1,A2,...StringprettyPrint()Pretty print of the theory.booleanremove(Argument a)Removes the argument and all its attacksbooleanremove(Attack attack)Removes the given attack from this Dung theory.booleanremoveAll(Collection<?> c)StringtoString()-
Methods inherited from class net.sf.tweety.commons.BeliefSet
addAll, clear, getSignature, instantiateSet, isEmpty, iterator, remove, retainAll, setSignature, size, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Constructor Detail
-
DungTheory
public DungTheory()
Default constructor; initializes empty sets of arguments and attacks
-
DungTheory
public DungTheory(net.sf.tweety.graphs.Graph<Argument> graph)
Creates a new theory from the given graph.- Parameters:
graph- some graph
-
-
Method Detail
-
getMinimalSignature
public net.sf.tweety.commons.Signature getMinimalSignature()
- Specified by:
getMinimalSignaturein interfacenet.sf.tweety.commons.BeliefBase
-
isAttackingAllOtherArguments
public boolean isAttackingAllOtherArguments(Extension ext)
returns true ifargumentsattack all other arguments in the theory- Parameters:
ext- An extension contains a set of arguments.- Returns:
- true if
argumentsattack all other arguments in the theory
-
isWellFounded
public boolean isWellFounded()
returns true iff the theory is well-founded, i.e., there is no infinite sequence A1,A2,... of arguments with Ai attacking Ai+1- Returns:
- true iff the theory is well-founded
-
isCoherent
public boolean isCoherent()
Determines if the theory is coherent, i.e., if each preferred extension is stable- Returns:
- true if the theory is coherent
-
isRelativelyCoherent
public boolean isRelativelyCoherent()
Determines if the theory is relatively coherent, i.e., if the grounded extension coincides with the intersection of all preferred extensions- Returns:
- true if the theory is relatively coherent
-
getAttackers
public Set<Argument> getAttackers(Argument argument)
Computes the set {A | (A,argument) in attacks}.- Parameters:
argument- an argument- Returns:
- the set of all arguments that attack
argument.
-
getAttacked
public Set<Argument> getAttacked(Argument argument)
Computes the set {A | (argument,A) in attacks}.- Parameters:
argument- an argument- Returns:
- the set of all arguments that are attacked by
argument.
-
isAttacked
public boolean isAttacked(Argument argument, Extension ext)
returns true if some argument ofextattacks argument.- Parameters:
argument- an argumentext- an extension, ie. a set of arguments- Returns:
- true if some argument of
extattacks argument.
-
isAttackedBy
public boolean isAttackedBy(Argument argument, Collection<Argument> ext)
returns true if some argument ofextis attacked by argument.- Parameters:
argument- an argumentext- an extension, ie. a set of arguments- Returns:
- true if some argument of
extis attacked by argument.
-
isAttacked
public boolean isAttacked(Extension ext1, Extension ext2)
returns true if some argument ofext2attacks some argument inext1- Parameters:
ext1- an extension, ie. a set of argumentsext2- an extension, ie. a set of arguments- Returns:
- true if some argument of
ext2attacks some argument inext1
-
isStable
public boolean isStable(Extension e)
Checks whether the given extension is stable wrt. this theory.- Parameters:
e- some extension- Returns:
- "true" iff the extension is stable.
-
faf
public Extension faf(Extension extension)
The characteristic function of an abstract argumentation framework: F_AF(S) = {A|A is acceptable wrt. S}.- Parameters:
extension- an extension (a set of arguments).- Returns:
- an extension (a set of arguments).
-
isAttackedBy
public boolean isAttackedBy(Argument arg1, Argument arg2)
Checks whether arg1 is attacked by arg2.- Parameters:
arg1- an argument.arg2- an argument.- Returns:
- "true" if arg1 is attacked by arg2
-
isIndirectAttack
public boolean isIndirectAttack(Argument arg1, Argument arg2)
Checks whether "arg1" indirectly attacks "arg2", i.e. whether there is an odd-length path from "arg1" to "arg2".- Parameters:
arg1- an AbstractArgument.arg2- an AbstractArgument.- Returns:
- "true" iff "arg1" indirectly attacks "arg2".
-
isSupport
public boolean isSupport(Argument arg1, Argument arg2)
Checks whether "arg1" supports "arg2", i.e. whether there is an even-length path from "arg1" to "arg2".- Parameters:
arg1- an AbstractArgument.arg2- an AbstractArgument.- Returns:
- "true" iff "arg1" supports "arg2".
-
isAttackBranch
public boolean isAttackBranch(Argument a, Argument b)
Checks whether the path from b to a is an attack branch, i.e. whether b is a non-attacked (indirect) attacker of a.- Parameters:
a- an Argumentb- an Argument- Returns:
- true iff the path from a to b is an attack branch, false otherwise
-
isDefenseBranch
public boolean isDefenseBranch(Argument a, Argument b)
Checks whether the path from b to a is a defense branch, i.e. whether b is a non-attacked (indirect) defender of a.- Parameters:
a- an Argumentb- an Argument- Returns:
- true iff the path from a to b is a defense branch, false otherwise
-
hasAttackBranch
public boolean hasAttackBranch(Argument a)
If this graph is acyclic, this method checks if the given argument has an attack branch, i.e. if it is (indirectly) attacked by a non-attacked argument.- Parameters:
a- an Argument- Returns:
- true iff this graph is acyclic and a has an attack branch, false otherwise
-
hasDefenseBranch
public boolean hasDefenseBranch(Argument a)
If this graph is acyclic, this method checks if the given argument has a defense branch, i.e. if it is supported by a non-attacked argument.- Parameters:
a- an Argument- Returns:
- true iff this graph is acyclic and a has a defense branch, false otherwise
-
prettyPrint
public String prettyPrint()
Pretty print of the theory.- Returns:
- the pretty print of the theory.
-
toString
public String toString()
- Specified by:
toStringin interfacenet.sf.tweety.commons.BeliefBase- Specified by:
toStringin interfacenet.sf.tweety.graphs.Graph<Argument>- Overrides:
toStringin classnet.sf.tweety.commons.BeliefSet<Argument,DungSignature>
-
add
public boolean add(Attack attack)
Adds the given attack to this dung theory.- Parameters:
attack- an attack- Returns:
- "true" if the set of attacks has been modified.
-
addAttack
public boolean addAttack(Argument attacker, Argument attacked)
Adds an attack from the first argument to the second to thisDdung theory.- Parameters:
attacker- some argumentattacked- some argument- Returns:
- "true" if the set of attacks has been modified.
-
remove
public boolean remove(Attack attack)
Removes the given attack from this Dung theory.- Parameters:
attack- an attack- Returns:
- "true" if the set of attacks has been modified.
-
remove
public boolean remove(Argument a)
Removes the argument and all its attacks- Parameters:
a- some argument- Returns:
- true if this structure has been changed
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<Argument>- Overrides:
removeAllin classnet.sf.tweety.commons.BeliefSet<Argument,DungSignature>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<Argument>- Specified by:
containsin interfacenet.sf.tweety.graphs.Graph<Argument>- Overrides:
containsin classnet.sf.tweety.commons.BeliefSet<Argument,DungSignature>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<Argument>- Overrides:
containsAllin classnet.sf.tweety.commons.BeliefSet<Argument,DungSignature>
-
containsAttack
public boolean containsAttack(Attack att)
Checks whether this theory contains the given attack.- Parameters:
att- some attack- Returns:
- "true" iff this theory contains the given attack.
-
addAllAttacks
public boolean addAllAttacks(Collection<? extends Attack> c)
Adds the set of attacks to this Dung theory.- Parameters:
c- a collection of attacks- Returns:
- "true" if this Dung theory has been modified.
-
add
public boolean add(DungTheory theory)
Adds all arguments and attacks of the given theory to this theory- Parameters:
theory- some Dung theory- Returns:
- "true" if this Dung Theory has been modified
-
add
public boolean add(Argument argument)
- Specified by:
addin interfaceCollection<Argument>- Specified by:
addin interfacenet.sf.tweety.graphs.Graph<Argument>- Overrides:
addin classnet.sf.tweety.commons.BeliefSet<Argument,DungSignature>
-
getAttacks
public Set<Attack> getAttacks()
Returns all attacks of this theory.- Returns:
- all attacks of this theory.
-
getRestriction
public net.sf.tweety.graphs.Graph<Argument> getRestriction(Collection<Argument> arguments)
- Specified by:
getRestrictionin interfacenet.sf.tweety.graphs.Graph<Argument>
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceCollection<Argument>- Overrides:
hashCodein classnet.sf.tweety.commons.BeliefSet<Argument,DungSignature>
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin interfaceCollection<Argument>- Overrides:
equalsin classnet.sf.tweety.commons.BeliefSet<Argument,DungSignature>
-
add
public boolean add(net.sf.tweety.graphs.Edge<Argument> edge)
- Specified by:
addin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getNodes
public Collection<Argument> getNodes()
- Specified by:
getNodesin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getNumberOfNodes
public int getNumberOfNodes()
- Specified by:
getNumberOfNodesin interfacenet.sf.tweety.graphs.Graph<Argument>
-
areAdjacent
public boolean areAdjacent(Argument a, Argument b)
- Specified by:
areAdjacentin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getEdges
public Collection<? extends net.sf.tweety.graphs.Edge<? extends Argument>> getEdges()
- Specified by:
getEdgesin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getChildren
public Collection<Argument> getChildren(net.sf.tweety.graphs.Node node)
- Specified by:
getChildrenin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getParents
public Collection<Argument> getParents(net.sf.tweety.graphs.Node node)
- Specified by:
getParentsin interfacenet.sf.tweety.graphs.Graph<Argument>
-
existsDirectedPath
public boolean existsDirectedPath(Argument node1, Argument node2)
- Specified by:
existsDirectedPathin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getNeighbors
public Collection<Argument> getNeighbors(Argument node)
- Specified by:
getNeighborsin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getAdjacencyMatrix
public net.sf.tweety.math.matrix.Matrix getAdjacencyMatrix()
- Specified by:
getAdjacencyMatrixin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getComplementGraph
public DungTheory getComplementGraph(int selfloops)
- Specified by:
getComplementGraphin interfacenet.sf.tweety.graphs.Graph<Argument>
-
hasSelfLoops
public boolean hasSelfLoops()
- Specified by:
hasSelfLoopsin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getEdge
public net.sf.tweety.graphs.Edge<Argument> getEdge(Argument a, Argument b)
- Specified by:
getEdgein interfacenet.sf.tweety.graphs.Graph<Argument>
-
isWeightedGraph
public boolean isWeightedGraph()
- Specified by:
isWeightedGraphin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getStronglyConnectedComponents
public Collection<Collection<Argument>> getStronglyConnectedComponents()
- Specified by:
getStronglyConnectedComponentsin interfacenet.sf.tweety.graphs.Graph<Argument>
-
getSubgraphs
public Collection<net.sf.tweety.graphs.Graph<Argument>> getSubgraphs()
- Specified by:
getSubgraphsin interfacenet.sf.tweety.graphs.Graph<Argument>
-
compareTo
public int compareTo(DungTheory o)
- Specified by:
compareToin interfaceComparable<DungTheory>
-
instantiateSignature
protected DungSignature instantiateSignature()
- Specified by:
instantiateSignaturein classnet.sf.tweety.commons.BeliefSet<Argument,DungSignature>
-
containsCycle
public <S extends net.sf.tweety.graphs.Node> boolean containsCycle()
Checks whether there is at least one cycle in this DungTheory.- Type Parameters:
S- the type of nodes- Returns:
- "true" if there is a cycle in this DungTheory, "false" otherwise
-
getComponents
public Collection<net.sf.tweety.graphs.Graph<Argument>> getComponents()
Returns the (connected) components of the theory- Returns:
- the (connected) components of the theory
-
-