Skip to content

Commit

Permalink
Output of rule-based atoms.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daphne Odekerken committed Apr 24, 2024
1 parent ec0e584 commit f7c3ea6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 17 deletions.
28 changes: 14 additions & 14 deletions src/py_arg/aspic/classes/argumentation_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@ def __init__(self,
# Language
self.language = language

# Contradiction function
for literal_str, literal_contraries in \
contraries_and_contradictories.items():
self.language[literal_str].contraries_and_contradictories = \
literal_contraries

# Rules
self.defeasible_rules = defeasible_rules
self.strict_rules = strict_rules
if add_defeasible_rule_literals:
for defeasible_rule in defeasible_rules:
defeasible_rule_literal = \
Literal.from_defeasible_rule(defeasible_rule)
defeasible_rule_literal_negation = \
Literal.from_defeasible_rule_negation(defeasible_rule)
defeasible_rule_literal.contraries_and_contradictories = \
{defeasible_rule_literal_negation}
defeasible_rule_literal_negation.\
contraries_and_contradictories = {defeasible_rule_literal}
# defeasible_rule_literal_negation = \
# Literal.from_defeasible_rule_negation(defeasible_rule)
# defeasible_rule_literal.contraries_and_contradictories = \
# {defeasible_rule_literal_negation}
# defeasible_rule_literal_negation.\
# contraries_and_contradictories = {defeasible_rule_literal}
self.language[str(defeasible_rule_literal)] = \
defeasible_rule_literal
self.language[str(defeasible_rule_literal_negation)] = \
defeasible_rule_literal_negation
# self.language[str(defeasible_rule_literal_negation)] = \
# defeasible_rule_literal_negation

# Contradiction function
for literal_str, literal_contraries in \
contraries_and_contradictories.items():
self.language[literal_str].contraries_and_contradictories = \
literal_contraries

# Rule preferences
if defeasible_rule_preferences:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ contradictory(a,na).
contradictory(b,c).

strict_head(1,na).
strict_body(1,a).
strict_body(1,a).

head(2,q).
body(2,q).
15 changes: 15 additions & 0 deletions src/py_arg_tests/resources/aspic_undercutter.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
axiom(a).
axiom(b).
axiom(c).

head(d1,d).
body(d1,b).

head(d2,-d1).
body(d2,a).

head(d3,-d3).
body(d3,c).

contradictory(d1,-d1).
contradictory(d2,-d2).
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def test_example_file(self):
file_path, 'elitist_last_link', 'Complete', 'skeptical')
self.assertEqual(py_arg_result, ['a', 'b', 'c', 'nx', 'x', 'y', 'z'])

def test_undercutter(self):
file_path = str(RESOURCE_DIR / 'aspic_undercutter.lp')
py_arg_result = get_accepted_formulas_for_file(
file_path, 'democratic_last_link', 'Complete', 'skeptical')
self.assertEqual(py_arg_result, ['-d1', '-d3', 'a', 'b', 'c'])

def test_with_support_cycle(self):
file_path = str(RESOURCE_DIR / 'aspic_support_cycle.lp')
py_arg_result = get_accepted_formulas_for_file(
Expand All @@ -27,10 +33,10 @@ def test_with_support_cycle(self):
def test_no_stable_extensions(self):
# If there are no (stable) extensions, all arguments are skeptically
# accepted.
file_path = str(RESOURCE_DIR / 'no_stable_extensions.lp')
file_path = str(RESOURCE_DIR / 'aspic_no_stable_extensions.lp')
py_arg_result = get_accepted_formulas_for_file(
file_path, 'democratic_last_link', 'Stable', 'skeptical')
self.assertEqual(py_arg_result, ['a', 'b', 'c', 'na'])
self.assertEqual(py_arg_result, ['2', 'a', 'b', 'c', 'na', 'q'])

# For complete semantics, this is no issue.
py_arg_result = get_accepted_formulas_for_file(
Expand Down

0 comments on commit f7c3ea6

Please sign in to comment.