Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ testBuild

gurobi-9.1.0.jar
isula-1.1.1.jar
logs/server.log.lck
/org-tweetyproject-web/logs/server.log.lck
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.tweetyproject.arg.bipolar.syntax.BipolarArgumentationFramework;
import org.tweetyproject.arg.dung.semantics.Extension;
import org.tweetyproject.arg.dung.syntax.Argument;
import org.tweetyproject.arg.dung.syntax.DungTheory;
import org.tweetyproject.commons.InferenceMode;
import org.tweetyproject.commons.ModelProvider;
import org.tweetyproject.commons.QualitativeReasoner;
Expand Down Expand Up @@ -56,6 +55,11 @@ public static AbstractBipolarExtensionReasoner getSimpleReasonerForSemantics(Sem
case BCF -> new SimpleStronglyConflictFreeReasoner();
case BCOH -> new SimpleCoherentReasoner();
case BAD -> new SimpleCoherentAdmissibleReasoner();
case CAD -> new SimpleCoalitionReasoner(org.tweetyproject.arg.dung.semantics.Semantics.ADM);
case CCO -> new SimpleCoalitionReasoner(org.tweetyproject.arg.dung.semantics.Semantics.CO);
case CGR -> new SimpleCoalitionReasoner(org.tweetyproject.arg.dung.semantics.Semantics.GR);
case CPR -> new SimpleCoalitionReasoner(org.tweetyproject.arg.dung.semantics.Semantics.PR);
case CST -> new SimpleCoalitionReasoner(org.tweetyproject.arg.dung.semantics.Semantics.ST);
default -> throw new IllegalArgumentException("Unknown semantics.");
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.tweetyproject.arg.bipolar.semantics;

import java.util.NoSuchElementException;

/**
* Enum of semantics for bipolar argumentation
*
Expand All @@ -27,30 +29,29 @@ public enum Semantics {
/**
* CF
*/
BCF("conflict-free semantics", "B-CF"),
BCF("conflict-free semantics", "BCF"),
/**
* COH
*/
BCOH("coherent semantics", "B-COH"),
BCOH("coherent semantics", "BCOH"),
/**
* ADM
*/
BAD("admissible semantics", "B-AD"),
BAD("admissible semantics", "BAD"),
/** coalition-admissible semantics */
CAD("Coalition-Admissible", "CAD"),
/** coalition-complete semantics */
CCO("Coalition-Complete", "CCO"),
/** coalition-grounded semantics */
CGR("Coalition-Grounded", "CGR"),
/** coalition-preferred semantics */
CPR("Coalition-Preferred", "CPR"),
/** coalition-stable semantics */
CST("Coalition-Stable", "CST"),
/**
* diverse
*/
diverse("diverse semantics", "div");
/**
* all semantics
*/
@SuppressWarnings("javadoc")
public static final Semantics
/** CONFLICT_FREE SEMANTICS*/
B_CONFLICT_FREE_SEMANTICS = BCF,
/** COHERENT SEMANTICS*/
B_COHERENT_SEMANTICS = BCOH,
/** COHERENT_ADMISSIBLE SEMANTICS */
B_ADMISSIBLE_SEMANTICS = BAD;

/**
* The description of the semantics.
Expand Down Expand Up @@ -89,5 +90,19 @@ public String description() {
public String abbreviation() {
return this.abbreviation;
}

/**
* Returns the semantics whose abbreviation matched the given string.
* @param abbreviation Abbreviation of the semantics to return.
* @return Semantics with the specified abbreviation.
*/
public static Semantics getSemantics(String abbreviation) {
for (Semantics element : Semantics.values()) {
if (element.abbreviation().equals(abbreviation)) {
return element;
}
}
throw new NoSuchElementException();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
*/
package org.tweetyproject.arg.bipolar.syntax;

import org.tweetyproject.arg.dung.ldo.syntax.LdoFormula;
import org.tweetyproject.arg.dung.ldo.syntax.LdoRelation;
import org.tweetyproject.arg.dung.syntax.Argument;
import org.tweetyproject.arg.dung.syntax.DungSignature;
import org.tweetyproject.commons.Signature;
import org.tweetyproject.graphs.DirectedEdge;

/**
Expand Down Expand Up @@ -108,6 +104,22 @@ public enum Type {
/** inverse of simple deductive */
SIMPLE_NECESSITY,
/** arguments must be supported by evidence*/
EVIDENTIAL
EVIDENTIAL;

public static Type getType(String type) {
switch (type) {
case "none", "default", "coalition" -> {
return DEFAULT;
} case "ded_simple" -> {
return SIMPLE_DEDUCTIVE;
} case "ded" -> {
return DEDUCTIVE;
} case "nec_simple" -> {
return SIMPLE_NECESSITY;
} case "nec" -> {
return NECESSITY;
} default -> throw new IllegalArgumentException("unknown support type " + type);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.tweetyproject.arg.setaf.reasoners;

import java.util.Collection;
import java.util.HashSet;

import org.tweetyproject.arg.dung.semantics.Extension;
import org.tweetyproject.arg.dung.semantics.Semantics;
Expand All @@ -29,17 +30,17 @@
import org.tweetyproject.commons.postulates.PostulateEvaluatable;

/**
* Ancestor class for all SetAf-extension-based reasoners.
* Ancestor class for all SetAF-extension-based reasoners.
*
* @author Sebastian Franke
*/
public abstract class AbstractExtensionSetAfReasoner extends AbstractSetAfReasoner
public abstract class AbstractSetAfExtensionReasoner extends AbstractSetAfReasoner
implements ModelProvider<Argument, SetAf, Extension<SetAf>>, PostulateEvaluatable<Argument> {

/**
* Default constructor for {@code AbstractExtensionSetAfReasoner}.
*/
public AbstractExtensionSetAfReasoner() {
public AbstractSetAfExtensionReasoner() {
// No specific initialization required
}

Expand All @@ -56,10 +57,29 @@ public Boolean query(SetAf beliefbase, Argument formula) {
}

/**
* Queries the given AAF for the given argument using the given
* Determine the set of acceptable arguments wrt. the given inference mode
* @param bbase some SetAF
* @param inferenceMode the inference mode
* @return the set of acceptable arguments
*/
public Collection<Argument> queryAll(SetAf bbase, InferenceMode inferenceMode) {
Collection<Argument> result = new HashSet<>();
if(inferenceMode.equals(InferenceMode.CREDULOUS))
for(Collection<Argument> extension: this.getModels(bbase))
result.addAll(extension);
else {
result.addAll(bbase);
for(Collection<Argument> extension: this.getModels(bbase))
result.retainAll(extension);
}
return result;
}

/**
* Queries the given SetAf for the given argument using the given
* inference type.
*
* @param beliefbase an AAF
* @param beliefbase an SetAF
* @param formula a single argument
* @param inferenceMode either InferenceMode.SKEPTICAL or
* InferenceMode.CREDULOUS
Expand All @@ -85,9 +105,9 @@ public Boolean query(SetAf beliefbase, Argument formula, InferenceMode inference
* Creates a reasoner for the given semantics.
*
* @param semantics a semantics
* @return a reasoner for the given Dung theory, inference type, and semantics
* @return a reasoner for the given SetAF, inference type, and semantics
*/
public static AbstractExtensionSetAfReasoner getSimpleReasonerForSemantics(Semantics semantics) {
public static AbstractSetAfExtensionReasoner getSimpleReasonerForSemantics(Semantics semantics) {
switch (semantics) {
case CO:
return new SimpleCompleteSetAfReasoner();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* This file is part of "TweetyProject", a collection of Java libraries for
* logical aspects of artificial intelligence and knowledge representation.
*
* TweetyProject is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2026 The TweetyProject Team <http://tweetyproject.org/contact/>
*/
package org.tweetyproject.arg.setaf.reasoners;

import org.tweetyproject.arg.dung.reasoner.AbstractExtensionReasoner;
import org.tweetyproject.arg.dung.semantics.Extension;
import org.tweetyproject.arg.dung.semantics.Semantics;
import org.tweetyproject.arg.dung.syntax.Argument;
import org.tweetyproject.arg.dung.syntax.DungTheory;
import org.tweetyproject.arg.setaf.syntax.SetAf;
import org.tweetyproject.arg.setaf.syntax.SetAttack;

import java.util.Collection;
import java.util.HashSet;

/**
* Reasoner for SetAfs that reduces the SetAf to a dung theory via a polynomial reduction
*
* @see "Modgil and Bench-Capon (2011), 'Metalevel argumentation', J. Log. Comput."
*
* @author Lars Bengel
*/
public class ReductionBasedSetAfReasoner extends AbstractSetAfExtensionReasoner {

/** the underlying semantics reasoner */
private final AbstractExtensionReasoner reasoner;

/**
* Initializes new SetAf reasoner with the given dung reasoner
* @param reasoner some dung reasoner
*/
public ReductionBasedSetAfReasoner(AbstractExtensionReasoner reasoner) {
this.reasoner = reasoner;
}

/**
* Initializes new SetAf reasoner with the given dung semantics
* @param semantics some semantics
*/
public ReductionBasedSetAfReasoner(Semantics semantics) {
this(AbstractExtensionReasoner.getSimpleReasonerForSemantics(semantics));
}

@Override
public Collection<Extension<SetAf>> getModels(SetAf bbase) {
DungTheory theory = getDungTheory(bbase);
Collection<Extension<SetAf>> result = new HashSet<>();
for (Extension<DungTheory> ext : reasoner.getModels(theory)) {
Extension<SetAf> new_ext = new Extension<>();
for (Argument arg : ext) {
if (bbase.contains(arg)) {
new_ext.add(arg);
}
}
result.add(new_ext);
}
return result;
}

@Override
public Extension<SetAf> getModel(SetAf bbase) {
return getModels(bbase).iterator().next();
}

/**
* Computes a dung theory for the given SetAf
* @param bbase some SetAf
* @return the corresponding dung theory
*/
public DungTheory getDungTheory(SetAf bbase) {
DungTheory theory = new DungTheory();
theory.addAll(bbase);
for (SetAttack att : bbase.getAttacks()) {
Argument arg1 = new Argument(String.format("_att(%s,%s)", att.getAttackers(), att.getAttacked()));
theory.add(arg1);
theory.addAttack(arg1, att.getAttacked());
for (Argument x : att.getAttackers()) {
Argument arg2 = new Argument(String.format("_att(%s,%s,%s)", att.getAttackers(), att.getAttacked(), x));
theory.add(arg2);
theory.addAttack(x, arg2);
theory.addAttack(arg2, arg1);
}
}
return theory;
}

@Override
public boolean isInstalled() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @author Matthias Thimm, Sebastian Franke
*
*/
public class SimpleAdmissibleSetAfReasoner extends AbstractExtensionSetAfReasoner {
public class SimpleAdmissibleSetAfReasoner extends AbstractSetAfExtensionReasoner {
/** Default */
public SimpleAdmissibleSetAfReasoner(){
// Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import org.tweetyproject.arg.dung.syntax.*;


/**
* This reasoner for SetAf theories performs inference on the complete extensions.
* Computes the set of all complete extensions, i.e., all admissible sets that contain all their acceptable arguments.
* @author Matthias Thimm, Sebastian Franke
*
*/
public class SimpleCompleteSetAfReasoner extends AbstractExtensionSetAfReasoner {
/**
* This reasoner for SetAf theories performs inference on the complete extensions.
* Computes the set of all complete extensions, i.e., all admissible sets that contain all their acceptable arguments.
* @author Matthias Thimm, Sebastian Franke
*
*/
public class SimpleCompleteSetAfReasoner extends AbstractSetAfExtensionReasoner {

/**
* Default constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Matthias Thimm, Sebastian Franke
*
*/
public class SimpleConflictFreeSetAfReasoner extends AbstractExtensionSetAfReasoner {
public class SimpleConflictFreeSetAfReasoner extends AbstractSetAfExtensionReasoner {


/** Default */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
* @author Lars Bengel, Sebastian Franke
*/
public class SimpleEagerSetAfReasoner extends AbstractExtensionSetAfReasoner {
public class SimpleEagerSetAfReasoner extends AbstractSetAfExtensionReasoner {


/** Default */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Matthias Thimm, Sebastian Franke
*
*/
public class SimpleGroundedSetAfReasoner extends AbstractExtensionSetAfReasoner {
public class SimpleGroundedSetAfReasoner extends AbstractSetAfExtensionReasoner {

/** Default */
public SimpleGroundedSetAfReasoner(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Matthias Thimm, Sebastian Franke
*
*/
public class SimpleIdealSetAfReasoner extends AbstractExtensionSetAfReasoner {
public class SimpleIdealSetAfReasoner extends AbstractSetAfExtensionReasoner {



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @author Matthias Thimm, Sebastian Franke
*
*/
public class SimplePreferredSetAfReasoner extends AbstractExtensionSetAfReasoner {
public class SimplePreferredSetAfReasoner extends AbstractSetAfExtensionReasoner {



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @author Matthias Thimm, Sebastian Franke
*
*/
public class SimpleSemiStableSetAfReasoner extends AbstractExtensionSetAfReasoner {
public class SimpleSemiStableSetAfReasoner extends AbstractSetAfExtensionReasoner {


/** Default */
Expand Down
Loading
Loading