@tuprolog/arg2p-core 0.6.3 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,7 @@
28
28
  }
29
29
  }(this, function (_, Kotlin, $module$_2p_solve, $module$_2p_dsl_theory, $module$_2p_dsl_core, $module$_2p_unify, $module$_2p_core, $module$_2p_theory, $module$_2p_parser_theory, $module$_2p_solve_classic, $module$_2p_parser_core) {
30
30
  'use strict';
31
+ var $$importsForInline$$ = _.$$importsForInline$$ || (_.$$importsForInline$$ = {});
31
32
  var Libraries = $module$_2p_solve.it.unibo.tuprolog.solve.library.Libraries;
32
33
  var listOf = Kotlin.kotlin.collections.listOf_i5x0yv$;
33
34
  var plus = Kotlin.kotlin.collections.plus_mydzjv$;
@@ -61,9 +62,11 @@
61
62
  var mapCapacity = Kotlin.kotlin.collections.mapCapacity_za3lpa$;
62
63
  var coerceAtLeast = Kotlin.kotlin.ranges.coerceAtLeast_dqglrj$;
63
64
  var LinkedHashMap_init = Kotlin.kotlin.collections.LinkedHashMap_init_bwtc7$;
65
+ var classicWithDefaultBuiltins = $module$_2p_solve_classic.it.unibo.tuprolog.solve.classic.classicMutableSolverWithDefaultBuiltins;
64
66
  var Substitution = $module$_2p_core.it.unibo.tuprolog.core.Substitution;
65
67
  var Numeric = $module$_2p_core.it.unibo.tuprolog.core.Numeric;
66
68
  var ensureNotNull = Kotlin.ensureNotNull;
69
+ var first = Kotlin.kotlin.sequences.first_veqyi0$;
67
70
  var to = Kotlin.kotlin.to_ujzrz7$;
68
71
  var mutableMapOf = Kotlin.kotlin.collections.mutableMapOf_qfcya0$;
69
72
  var Atom = $module$_2p_core.it.unibo.tuprolog.core.Atom;
@@ -76,7 +79,6 @@
76
79
  var DomainError$Expected = $module$_2p_solve.it.unibo.tuprolog.solve.exception.error.DomainError.Expected;
77
80
  var Unit = Kotlin.kotlin.Unit;
78
81
  var filter = Kotlin.kotlin.sequences.filter_euau3h$;
79
- var first = Kotlin.kotlin.sequences.first_veqyi0$;
80
82
  var prolog = $module$_2p_dsl_core.it.unibo.tuprolog.dsl.prolog;
81
83
  var Specifier = $module$_2p_core.it.unibo.tuprolog.core.operators.Specifier;
82
84
  var Operator = $module$_2p_core.it.unibo.tuprolog.core.operators.Operator;
@@ -109,7 +111,9 @@
109
111
  var toTerm = $module$_2p_core.it.unibo.tuprolog.core.listToTerm;
110
112
  var UnaryPredicate$WithoutSideEffects = $module$_2p_solve.it.unibo.tuprolog.solve.primitive.UnaryPredicate.WithoutSideEffects;
111
113
  var BinaryRelation$WithoutSideEffects = $module$_2p_solve.it.unibo.tuprolog.solve.primitive.BinaryRelation.WithoutSideEffects;
114
+ var IllegalArgumentException_init = Kotlin.kotlin.IllegalArgumentException_init;
112
115
  var copyToArray = Kotlin.kotlin.collections.copyToArray;
116
+ var hashCode = Kotlin.hashCode;
113
117
  var AliasedLibrary = $module$_2p_solve.it.unibo.tuprolog.solve.library.AliasedLibrary;
114
118
  var compareBy = Kotlin.kotlin.comparisons.compareBy_bvgy4j$;
115
119
  var sortedWith = Kotlin.kotlin.sequences.sortedWith_vjgqpk$;
@@ -152,6 +156,8 @@
152
156
  CompleteLabellerBase.prototype.constructor = CompleteLabellerBase;
153
157
  GroundedLabellerBase.prototype = Object.create(LazyRawPrologContent.prototype);
154
158
  GroundedLabellerBase.prototype.constructor = GroundedLabellerBase;
159
+ GroundedLabellerOptimizedBase.prototype = Object.create(LazyRawPrologContent.prototype);
160
+ GroundedLabellerOptimizedBase.prototype.constructor = GroundedLabellerOptimizedBase;
155
161
  Labelling.prototype = Object.create(RuleWrapper.prototype);
156
162
  Labelling.prototype.constructor = Labelling;
157
163
  StatementLabellerBase.prototype = Object.create(LazyRawPrologContent.prototype);
@@ -170,6 +176,8 @@
170
176
  Bps.prototype.constructor = Bps;
171
177
  ExtractStrictIds.prototype = Object.create(BinaryRelation$WithoutSideEffects.prototype);
172
178
  ExtractStrictIds.prototype.constructor = ExtractStrictIds;
179
+ RuleToClause.prototype = Object.create(BinaryRelation$WithoutSideEffects.prototype);
180
+ RuleToClause.prototype.constructor = RuleToClause;
173
181
  StructuredModeBase.prototype = Object.create(LazyRawPrologContent.prototype);
174
182
  StructuredModeBase.prototype.constructor = StructuredModeBase;
175
183
  DebugBase.prototype = Object.create(LazyRawPrologContent.prototype);
@@ -178,6 +186,8 @@
178
186
  SuperiorityRelationBase.prototype.constructor = SuperiorityRelationBase;
179
187
  UtilsBase.prototype = Object.create(LazyRawPrologContent.prototype);
180
188
  UtilsBase.prototype.constructor = UtilsBase;
189
+ ArgumentHash.prototype = Object.create(BinaryRelation$WithoutSideEffects.prototype);
190
+ ArgumentHash.prototype.constructor = ArgumentHash;
181
191
  EngineInterface.prototype = Object.create(EngineInterfaceBase.prototype);
182
192
  EngineInterface.prototype.constructor = EngineInterface;
183
193
  AbstractMode.prototype = Object.create(AbstractModeBase.prototype);
@@ -204,6 +214,8 @@
204
214
  CompleteLabeller.prototype.constructor = CompleteLabeller;
205
215
  GroundedLabeller.prototype = Object.create(GroundedLabellerBase.prototype);
206
216
  GroundedLabeller.prototype.constructor = GroundedLabeller;
217
+ GroundedLabellerOptimized.prototype = Object.create(GroundedLabellerOptimizedBase.prototype);
218
+ GroundedLabellerOptimized.prototype.constructor = GroundedLabellerOptimized;
207
219
  StatementLabeller.prototype = Object.create(StatementLabellerBase.prototype);
208
220
  StatementLabeller.prototype.constructor = StatementLabeller;
209
221
  RuleParser.prototype = Object.create(RuleParserBase.prototype);
@@ -288,7 +300,7 @@
288
300
  staticLibs = emptyList();
289
301
  if (dynamicLibs === void 0)
290
302
  dynamicLibs = emptyList();
291
- return this.of_gdqvf0$(plus(listOf([EngineInterface_getInstance(), new Cache()]), staticLibs), plus(listOf([Utils_getInstance_0(), Debug_getInstance_0(), RuleParser_getInstance(), MetaInterpreter_getInstance(), ModuleCalls_getInstance(), ArgumentationGraphBuilder_getInstance(), AttackRestrictionHandler_getInstance(), BpMetaGraphHandler_getInstance(), DefeasiblePreferencesHandler_getInstance(), GenericDefeasiblePreferencesHandler_getInstance(), StrictPreferencesHandler_getInstance(), BpLabeller_getInstance(), CompleteLabeller_getInstance(), GroundedLabeller_getInstance(), StatementLabeller_getInstance(), AbstractMode_getInstance(), StructuredMode_getInstance(), SuperiorityRelation_getInstance_0(), BpPartialLabeller_getInstance(), BpCompleteLabeller_getInstance(), PassThroughStatementLabeller_getInstance(), BinaryStatementLabeller_getInstance()]), dynamicLibs));
303
+ return this.of_gdqvf0$(plus(listOf([EngineInterface_getInstance(), new Cache()]), staticLibs), plus(listOf([Utils_getInstance_0(), Debug_getInstance_0(), RuleParser_getInstance(), MetaInterpreter_getInstance(), ModuleCalls_getInstance(), ArgumentationGraphBuilder_getInstance(), AttackRestrictionHandler_getInstance(), BpMetaGraphHandler_getInstance(), DefeasiblePreferencesHandler_getInstance(), GenericDefeasiblePreferencesHandler_getInstance(), StrictPreferencesHandler_getInstance(), BpLabeller_getInstance(), CompleteLabeller_getInstance(), GroundedLabeller_getInstance(), StatementLabeller_getInstance(), AbstractMode_getInstance(), StructuredMode_getInstance(), SuperiorityRelation_getInstance_0(), BpPartialLabeller_getInstance(), BpCompleteLabeller_getInstance(), PassThroughStatementLabeller_getInstance(), BinaryStatementLabeller_getInstance(), GroundedLabellerOptimized_getInstance()]), dynamicLibs));
292
304
  };
293
305
  Arg2pSolver$Companion.$metadata$ = {
294
306
  kind: Kind_OBJECT,
@@ -1334,7 +1346,7 @@
1334
1346
  function Context() {
1335
1347
  this.nextSolver_0 = 1;
1336
1348
  this.selectedSolver_0 = 0;
1337
- var $receiver = classic(MutableSolver.Companion, void 0, void 0, Theory.Companion.empty(), MutableTheory.Companion.empty());
1349
+ var $receiver = classicWithDefaultBuiltins(MutableSolver.Companion, void 0, void 0, Theory.Companion.empty(), MutableTheory.Companion.empty());
1338
1350
  $receiver.setFlag(flags.Unknown.name, flags.Unknown.FAIL);
1339
1351
  this.dynamicSolver_0 = mutableMapOf([to(0, $receiver)]);
1340
1352
  this.alias_476cz2$_0 = 'prolog.argumentation.context';
@@ -1354,7 +1366,7 @@
1354
1366
  this.$outer.nextSolver_0 = 1;
1355
1367
  this.$outer.dynamicSolver_0.clear();
1356
1368
  var tmp$ = this.$outer.dynamicSolver_0;
1357
- var $receiver = classic(MutableSolver.Companion, void 0, void 0, Theory.Companion.empty(), MutableTheory.Companion.empty());
1369
+ var $receiver = classicWithDefaultBuiltins(MutableSolver.Companion, void 0, void 0, Theory.Companion.empty(), MutableTheory.Companion.empty());
1358
1370
  $receiver.setFlag(flags.Unknown.name, flags.Unknown.FAIL);
1359
1371
  tmp$.put_xwzc9p$(0, $receiver);
1360
1372
  return sequenceOf([request.replyWithCondition(true, void 0, [])]);
@@ -1420,7 +1432,7 @@
1420
1432
  var result = request.arguments.get_za3lpa$(1);
1421
1433
  var tmp$_1 = this.$outer.dynamicSolver_0;
1422
1434
  var tmp$_2 = this.$outer.nextSolver_0;
1423
- var $receiver = classic(MutableSolver.Companion, void 0, void 0, Theory.Companion.empty(), MutableTheory.Companion.ofIterable(ensureNotNull(this.$outer.dynamicSolver_0.get_11rb$(target)).dynamicKb));
1435
+ var $receiver = classicWithDefaultBuiltins(MutableSolver.Companion, void 0, void 0, Theory.Companion.empty(), MutableTheory.Companion.ofIterable(ensureNotNull(this.$outer.dynamicSolver_0.get_11rb$(target)).dynamicKb));
1424
1436
  $receiver.setFlag(flags.Unknown.name, flags.Unknown.FAIL);
1425
1437
  tmp$_1.put_xwzc9p$(tmp$_2, $receiver);
1426
1438
  tmp$_0 = this.$outer;
@@ -1446,9 +1458,14 @@
1446
1458
  return this.signature_t5avxd$_0;
1447
1459
  }
1448
1460
  });
1461
+ function Context$DynamicCacheAssert$solve$lambda(this$Context, closure$term) {
1462
+ return function ($receiver) {
1463
+ return ensureNotNull(this$Context.dynamicSolver_0.get_11rb$(this$Context.selectedSolver_0)).solve($receiver.stringInvoke('asserta', closure$term, []));
1464
+ };
1465
+ }
1449
1466
  Context$DynamicCacheAssert.prototype.solve = function (request) {
1450
1467
  var term = request.arguments.get_za3lpa$(0);
1451
- ensureNotNull(this.$outer.dynamicSolver_0.get_11rb$(this.$outer.selectedSolver_0)).assertAFact(term.castToStruct());
1468
+ first(arg2pScope(Context$DynamicCacheAssert$solve$lambda(this.$outer, term)));
1452
1469
  return sequenceOf([request.replyWithCondition(true, void 0, [])]);
1453
1470
  };
1454
1471
  Context$DynamicCacheAssert.$metadata$ = {
@@ -1466,9 +1483,14 @@
1466
1483
  return this.signature_5o25xi$_0;
1467
1484
  }
1468
1485
  });
1486
+ function Context$DynamicCacheRetract$solve$lambda(this$Context, closure$term) {
1487
+ return function ($receiver) {
1488
+ return ensureNotNull(this$Context.dynamicSolver_0.get_11rb$(this$Context.selectedSolver_0)).solve($receiver.stringInvoke('retractall', closure$term, []));
1489
+ };
1490
+ }
1469
1491
  Context$DynamicCacheRetract.prototype.solve = function (request) {
1470
1492
  var term = request.arguments.get_za3lpa$(0);
1471
- ensureNotNull(this.$outer.dynamicSolver_0.get_11rb$(this.$outer.selectedSolver_0)).retractAllBeHead(term.castToStruct());
1493
+ first(arg2pScope(Context$DynamicCacheRetract$solve$lambda(this.$outer, term)));
1472
1494
  return sequenceOf([request.replyWithCondition(true, void 0, [])]);
1473
1495
  };
1474
1496
  Context$DynamicCacheRetract.$metadata$ = {
@@ -2424,7 +2446,7 @@
2424
2446
  return 'grounded';
2425
2447
  };
2426
2448
  ArgumentLabellingMode.prototype.values = function () {
2427
- return listOf(['grounded', 'complete', 'bp_grounded', 'bp_grounded_partial', 'bp_grounded_complete']);
2449
+ return listOf(['grounded', 'grounded_hash', 'complete', 'bp_grounded', 'bp_grounded_partial', 'bp_grounded_complete']);
2428
2450
  };
2429
2451
  ArgumentLabellingMode.$metadata$ = {
2430
2452
  kind: Kind_OBJECT,
@@ -2954,6 +2976,43 @@
2954
2976
  simpleName: 'GroundedLabellerBase',
2955
2977
  interfaces: [Loadable, LazyRawPrologContent, ArgLibrary]
2956
2978
  };
2979
+ function GroundedLabellerOptimizedBase() {
2980
+ LazyRawPrologContent.call(this);
2981
+ this.alias_9fhn2g$_0 = 'prolog.argumentation.graph.labelling.grounded.optimized';
2982
+ this.theoryOperators_8xcsny$_0 = DynamicLoader$Companion_getInstance().operators().plusOperatorSet(OperatorSet.Companion.DEFAULT);
2983
+ }
2984
+ Object.defineProperty(GroundedLabellerOptimizedBase.prototype, 'alias', {
2985
+ configurable: true,
2986
+ get: function () {
2987
+ return this.alias_9fhn2g$_0;
2988
+ }
2989
+ });
2990
+ Object.defineProperty(GroundedLabellerOptimizedBase.prototype, 'baseContent', {
2991
+ configurable: true,
2992
+ get: function () {
2993
+ return Library.Companion.aliased(this.alias, void 0, this.prologTheory);
2994
+ }
2995
+ });
2996
+ Object.defineProperty(GroundedLabellerOptimizedBase.prototype, 'baseFlags', {
2997
+ configurable: true,
2998
+ get: function () {
2999
+ return emptyList();
3000
+ }
3001
+ });
3002
+ GroundedLabellerOptimizedBase.prototype.identifier = function () {
3003
+ return 'grounded_hash';
3004
+ };
3005
+ Object.defineProperty(GroundedLabellerOptimizedBase.prototype, 'theoryOperators', {
3006
+ configurable: true,
3007
+ get: function () {
3008
+ return this.theoryOperators_8xcsny$_0;
3009
+ }
3010
+ });
3011
+ GroundedLabellerOptimizedBase.$metadata$ = {
3012
+ kind: Kind_CLASS,
3013
+ simpleName: 'GroundedLabellerOptimizedBase',
3014
+ interfaces: [Loadable, LazyRawPrologContent, ArgLibrary]
3015
+ };
2957
3016
  function PassThroughStatementLabeller() {
2958
3017
  PassThroughStatementLabeller_instance = this;
2959
3018
  this.alias_as0zmd$_0 = 'prolog.argumentation.graph.labelling.statement.pt';
@@ -3082,7 +3141,9 @@
3082
3141
  return $receiver.descriptionPair;
3083
3142
  }.bind(null, DefeasibleRules_getInstance())).get(), getPropertyCallableRef('descriptionPair', 0, function ($receiver) {
3084
3143
  return $receiver.descriptionPair;
3085
- }.bind(null, ExtractStrictIds_getInstance())).get()]), this.prologTheory, RuleParserBase$Companion_getInstance().operators());
3144
+ }.bind(null, ExtractStrictIds_getInstance())).get(), getPropertyCallableRef('descriptionPair', 0, function ($receiver) {
3145
+ return $receiver.descriptionPair;
3146
+ }.bind(null, RuleToClause_getInstance())).get()]), this.prologTheory, RuleParserBase$Companion_getInstance().operators());
3086
3147
  }
3087
3148
  });
3088
3149
  Object.defineProperty(RuleParserBase.prototype, 'baseFlags', {
@@ -3401,7 +3462,7 @@
3401
3462
  tmp$_1 = destination.iterator();
3402
3463
  while (tmp$_1.hasNext()) {
3403
3464
  var item = tmp$_1.next();
3404
- destination_0.add_11rb$(prologScope.listOfAny(['bps', ensureNotNull(item.head)]));
3465
+ destination_0.add_11rb$(Struct.Companion.of('abstractBp', [prologScope.listOfIterable(ensureNotNull(item.head).argsList)]));
3405
3466
  }
3406
3467
  return toTerm(destination_0);
3407
3468
  }
@@ -3448,6 +3509,50 @@
3448
3509
  new ExtractStrictIds();
3449
3510
  }return ExtractStrictIds_instance;
3450
3511
  }
3512
+ function RuleToClause() {
3513
+ RuleToClause_instance = this;
3514
+ BinaryRelation$WithoutSideEffects.call(this, 'rule_to_clause');
3515
+ }
3516
+ RuleToClause.prototype.computeAllSubstitutions_2j1e5m$ = function ($receiver, first, second) {
3517
+ var tmp$ = Substitution.Companion;
3518
+ var tmp$_0 = ensureNotNull(second.asVar());
3519
+ var tmp$_1 = List.Companion;
3520
+ var $receiver_0 = ensureNotNull(first.asList()).toList();
3521
+ var destination = ArrayList_init(collectionSizeOrDefault($receiver_0, 10));
3522
+ var tmp$_2;
3523
+ tmp$_2 = $receiver_0.iterator();
3524
+ loop_label: while (tmp$_2.hasNext()) {
3525
+ var item = tmp$_2.next();
3526
+ var tmp$_3 = destination.add_11rb$;
3527
+ var it = ensureNotNull(item.asList()).toList();
3528
+ var block$result;
3529
+ block$break: do {
3530
+ switch (it.size) {
3531
+ case 2:
3532
+ block$result = Clause.Companion.of(Struct.Companion.of('rl', [it.get_za3lpa$(1)]), [item]);
3533
+ break block$break;
3534
+ case 3:
3535
+ block$result = Clause.Companion.of(Struct.Companion.of('rl', [it.get_za3lpa$(2)]), [item]);
3536
+ break block$break;
3537
+ default:throw IllegalArgumentException_init();
3538
+ }
3539
+ }
3540
+ while (false);
3541
+ tmp$_3.call(destination, block$result);
3542
+ }
3543
+ return sequenceOf([tmp$.of(tmp$_0, tmp$_1.ofList(destination))]);
3544
+ };
3545
+ RuleToClause.$metadata$ = {
3546
+ kind: Kind_OBJECT,
3547
+ simpleName: 'RuleToClause',
3548
+ interfaces: [BinaryRelation$WithoutSideEffects]
3549
+ };
3550
+ var RuleToClause_instance = null;
3551
+ function RuleToClause_getInstance() {
3552
+ if (RuleToClause_instance === null) {
3553
+ new RuleToClause();
3554
+ }return RuleToClause_instance;
3555
+ }
3451
3556
  function StructuredModeBase() {
3452
3557
  LazyRawPrologContent.call(this);
3453
3558
  this.alias_k0m5up$_0 = 'prolog.argumentation.structured';
@@ -3669,7 +3774,10 @@
3669
3774
  tmp$_1 = Library.Companion;
3670
3775
  tmp$ = this.alias;
3671
3776
  tmp$_0 = this.prologTheory;
3672
- return tmp$_1.aliased(tmp$, mapOf_0([to(AppendOptimized_getInstance().signature, AppendOptimized_getInstance()), to(AssertAll_getInstance().signature, AssertAll_getInstance())]), tmp$_0);
3777
+ var tmp$_2 = to(AppendOptimized_getInstance().signature, AppendOptimized_getInstance());
3778
+ var tmp$_3 = to(AssertAll_getInstance().signature, AssertAll_getInstance());
3779
+ var $this = ArgumentHash_getInstance();
3780
+ return tmp$_1.aliased(tmp$, mapOf_0([tmp$_2, tmp$_3, to($this.signature, $this.wrappedImplementation)]), tmp$_0);
3673
3781
  }
3674
3782
  });
3675
3783
  Object.defineProperty(UtilsBase.prototype, 'baseFlags', {
@@ -3779,7 +3887,7 @@
3779
3887
  }
3780
3888
  function AssertAll$solve$lambda(closure$list, closure$request) {
3781
3889
  return function ($receiver) {
3782
- var $receiver_0 = closure$list.toSequence();
3890
+ var $receiver_0 = closure$list.toList();
3783
3891
  var tmp$;
3784
3892
  tmp$ = $receiver_0.iterator();
3785
3893
  while (tmp$.hasNext()) {
@@ -3858,6 +3966,24 @@
3858
3966
  new AssertAll();
3859
3967
  }return AssertAll_instance;
3860
3968
  }
3969
+ function ArgumentHash() {
3970
+ ArgumentHash_instance = this;
3971
+ BinaryRelation$WithoutSideEffects.call(this, 'hash');
3972
+ }
3973
+ ArgumentHash.prototype.computeAllSubstitutions_2j1e5m$ = function ($receiver, first, second) {
3974
+ return sequenceOf([Substitution.Companion.of(ensureNotNull(second.asVar()), Numeric.Companion.ofInteger(hashCode(first.toString())))]);
3975
+ };
3976
+ ArgumentHash.$metadata$ = {
3977
+ kind: Kind_OBJECT,
3978
+ simpleName: 'ArgumentHash',
3979
+ interfaces: [BinaryRelation$WithoutSideEffects]
3980
+ };
3981
+ var ArgumentHash_instance = null;
3982
+ function ArgumentHash_getInstance() {
3983
+ if (ArgumentHash_instance === null) {
3984
+ new ArgumentHash();
3985
+ }return ArgumentHash_instance;
3986
+ }
3861
3987
  function MetaInterpreterLib() {
3862
3988
  MetaInterpreterLib_instance = this;
3863
3989
  this.$delegate_3wovwi$_0 = Library.Companion.aliased('prolog.argumentation.meta', void 0, parse_2(Theory.Companion, trimIndent('\n % with_facts_and_length/3\n with_facts_and_length(X, Y, L) :-\n solve(X, R),\n recover_facts(R, Y),\n length(Y, L).\n\n % lenght/2\n\n length([], 0).\n length([_|T], X) :- length(T, Y), X is Y + 1.\n\n % recover_facts/2\n\n recover_facts([], []) :- !.\n recover_facts([H|T], C) :-\n is_list(H), !,\n recover_facts(T, TC),\n recover_facts(H, HC),\n append(TC, HC, C).\n recover_facts([H|T], C) :-\n \\+ is_list(H),\n recover_facts(T, TC),\n evaluate(H, HC),\n append(TC, HC, C).\n\n evaluate(user_fact(X), [X]) :- !.\n evaluate(_, []) :- !.\n\n % solve/2\n\n solve((A,B), Result) :- !,\n solve(A, ARes),\n solve(B, BRes),\n append(ARes, BRes, Result).\n\n solve((A;B), Result) :- !,\n solve(A, Result);\n solve(B, Result).\n\n solve(member(A, B), [system_predicate]) :- !,\n call(member(A, B)).\n\n solve(\\+(A), [not(A)]) :- !,\n call(\\+(A)).\n\n solve((A)\\=(B), [doNotUnify(A, B)]) :- !,\n call((A)\\=(B)).\n\n solve(A, [system_predicate]) :-\n catch(clause(A, _), B, true),\n \\+ var(B), !,\n call(A).\n\n solve(A, [A]) :-\n \\+ clause(A, B), !,\n call(A).\n\n solve(A, [A|[Res]]) :-\n clause(A, B),\n solve(B, Res).\n\n % is_list/1\n\n is_list(X) :- var(X), !, fail.\n is_list([]).\n is_list([_|T]) :- is_list(T).\n \n % fetch_argument_facts/2\n \n fetch_argument_facts(Conclusion, Facts) :-\n argument([R, TR, [Conclusion]]),\n findall(user_fact(Fact), \n support([_, _, [user_fact(Fact)]], [R, TR, [Conclusion]]),\n Facts).\n ')));
@@ -4127,7 +4253,7 @@
4127
4253
  }
4128
4254
  });
4129
4255
  Argument.prototype.termRepresentation = function () {
4130
- return parse_1(Struct.Companion, '[' + this.rules + ', ' + this.topRule + ', ' + this.conclusion + ', ' + this.groundings + ', [' + this.lastDefeasibleRules + ', ' + this.defeasibleRules + ', ' + this.defeasiblePremises + ']]');
4256
+ return parse_1(Struct.Companion, '[' + this.rules + ', ' + this.topRule + ', [' + this.conclusion + '], ' + this.groundings + ', [' + this.lastDefeasibleRules + ', ' + this.defeasibleRules + ', ' + this.defeasiblePremises + ']]');
4131
4257
  };
4132
4258
  Argument.prototype.toString = function () {
4133
4259
  return 'argument(' + this.termRepresentation() + ')';
@@ -4163,7 +4289,7 @@
4163
4289
  return argument.get_za3lpa$(1).toString();
4164
4290
  }
4165
4291
  function Argument$Companion$of$argConclusion(argument) {
4166
- return argument.get_za3lpa$(2).toString();
4292
+ return ensureNotNull(argument.get_za3lpa$(2).asList()).get(0).toString();
4167
4293
  }
4168
4294
  function Argument$Companion$of$argGroundings(closure$toStringList) {
4169
4295
  return function (argument) {
@@ -4424,7 +4550,7 @@
4424
4550
  }
4425
4551
  });
4426
4552
  Premise.prototype.toString = function () {
4427
- return 'premise([' + this.identifier + ', ' + this.conclusion + '])';
4553
+ return 'rl(' + this.conclusion + ') :- ([' + this.identifier + ', ' + this.conclusion + '])';
4428
4554
  };
4429
4555
  Premise.$metadata$ = {
4430
4556
  kind: Kind_CLASS,
@@ -4472,7 +4598,7 @@
4472
4598
  }
4473
4599
  });
4474
4600
  Rule.prototype.toString = function () {
4475
- return 'rule([' + this.identifier + ', ' + this.premises + ', ' + this.conclusion + '])';
4601
+ return 'rl(' + this.conclusion + ') :- [' + this.identifier + ', ' + this.premises + ', ' + this.conclusion + ']';
4476
4602
  };
4477
4603
  Rule.$metadata$ = {
4478
4604
  kind: Kind_CLASS,
@@ -4811,6 +4937,27 @@
4811
4937
  new GroundedLabeller();
4812
4938
  }return GroundedLabeller_instance;
4813
4939
  }
4940
+ function GroundedLabellerOptimized() {
4941
+ GroundedLabellerOptimized_instance = this;
4942
+ GroundedLabellerOptimizedBase.call(this);
4943
+ }
4944
+ Object.defineProperty(GroundedLabellerOptimized.prototype, 'prologRawTheory', {
4945
+ configurable: true,
4946
+ get: function () {
4947
+ return GroundedOptimized_getInstance().theoryCode;
4948
+ }
4949
+ });
4950
+ GroundedLabellerOptimized.$metadata$ = {
4951
+ kind: Kind_OBJECT,
4952
+ simpleName: 'GroundedLabellerOptimized',
4953
+ interfaces: [GroundedLabellerOptimizedBase]
4954
+ };
4955
+ var GroundedLabellerOptimized_instance = null;
4956
+ function GroundedLabellerOptimized_getInstance() {
4957
+ if (GroundedLabellerOptimized_instance === null) {
4958
+ new GroundedLabellerOptimized();
4959
+ }return GroundedLabellerOptimized_instance;
4960
+ }
4814
4961
  function StatementLabeller() {
4815
4962
  StatementLabeller_instance = this;
4816
4963
  StatementLabellerBase.call(this);
@@ -4870,7 +5017,7 @@
4870
5017
  }
4871
5018
  function ArgumentationEngineInterface() {
4872
5019
  ArgumentationEngineInterface_instance = this;
4873
- this.theoryCode = trimIndent('\n argTuProlog.\n buildLabelSets([StatIn, StatOut, StatUnd], [ArgsIn, ArgsOut, ArgsUnd]) :-\n context_reset,\n parser:::convertAllRules(_),\n abstract::computeGlobalAcceptance(_, [ArgsIn, ArgsOut, ArgsUnd], [StatIn, StatOut, StatUnd]).\n buildLabelSets(StatIn, StatOut, StatUnd) :-\n buildLabelSets([StatIn, StatOut, StatUnd], _).\n buildLabelSets :-\n context_reset,\n parser:::convertAllRules(ArgRules),\n debug::printTheory(ArgRules),\n abstract::computeGlobalAcceptance([Arguments, Attacks, Supports], [ArgsIn, ArgsOut, ArgsUnd], [StatIn, StatOut, StatUnd]),\n debug::printArgumentationGraph(Arguments, Attacks, Supports),\n debug::printArgumentLabelling([ArgsIn, ArgsOut, ArgsUnd]),\n debug::printStatementLabelling([StatIn, StatOut, StatUnd]).\n answerQuery(Goal, Yes, No, Und) :-\n context_reset,\n parser:::convertAllRules(_),\n structured:::computeStatementAcceptance(Goal, Yes, No, Und).\n ');
5020
+ this.theoryCode = trimIndent('\n argTuProlog.\n buildLabelSets([StatIn, StatOut, StatUnd], [ArgsIn, ArgsOut, ArgsUnd]) :-\n context_reset,\n parser:::convertAllRules(_),\n abstract::computeGlobalAcceptance(_, [ArgsIn, ArgsOut, ArgsUnd], [StatIn, StatOut, StatUnd]).\n buildLabelSets(StatIn, StatOut, StatUnd) :-\n buildLabelSets([StatIn, StatOut, StatUnd], _).\n buildLabelSets :-\n context_reset,\n parser:::convertAllRules(ArgRules),\n abstract::computeGlobalAcceptance([Arguments, Attacks, Supports], [ArgsIn, ArgsOut, ArgsUnd], [StatIn, StatOut, StatUnd]),\n debug::printArgumentationGraph(Arguments, Attacks, Supports),\n debug::printArgumentLabelling([ArgsIn, ArgsOut, ArgsUnd]),\n debug::printStatementLabelling([StatIn, StatOut, StatUnd]).\n answerQuery(Goal, Yes, No, Und) :-\n context_reset,\n parser:::convertAllRules(_),\n structured:::computeStatementAcceptance(Goal, Yes, No, Und).\n answerQuery(Goal, Res) :-\n context_reset,\n parser:::convertAllRules(_),\n structured:::query(Goal, Res).\n buildLabelSetsSilent :-\n context_reset,\n parser:::convertAllRules(ArgRules),\n abstract::computeGlobalAcceptance.\n ');
4874
5021
  }
4875
5022
  ArgumentationEngineInterface.$metadata$ = {
4876
5023
  kind: Kind_OBJECT,
@@ -4885,7 +5032,7 @@
4885
5032
  }
4886
5033
  function ArgumentationGraph() {
4887
5034
  ArgumentationGraph_instance = this;
4888
- this.theoryCode = trimIndent('\n buildArgumentationGraph :-\n buildArguments,\n buildAttacks.\n buildArguments :-\n \tbuildArgumentsFromPremises,\n \tbuildArgumentsFromEmptyRules,\n \tfindall([RuleID, RuleBody, RuleHead], (\n \t context_check(rule([RuleID, RuleBody, RuleHead])),\n \t \\+ emptyRule([RuleID, RuleBody, RuleHead])\n ), Rules),\n \tbuildArgumentsFromRules(Rules, Rules, n).\n buildArgumentsFromPremises :-\n findall(\n _,\n (\n context_check(premise([PremiseID, Premise])),\n checkStrict(PremiseID, DefPrem),\n ground(Premise),\n context_assert(argument([[PremiseID], none, Premise, [], [[], [], DefPrem]]))\n ),\n _\n ).\n buildArgumentsFromEmptyRules :-\n findall(\n _,\n (\n emptyRule([RuleID, RulePrem, RuleHead]),\n checkStrict(RuleID, DefRule),\n ground(RuleHead),\n context_assert(argument([[RuleID], RuleID, RuleHead, RulePrem, [DefRule, DefRule, []]]))\n ),\n _\n ).\n emptyRule([RuleID, [], RuleHead]) :-\n context_check(rule([RuleID, [], RuleHead])).\n emptyRule([RuleID, [[unless, X]], RuleHead]) :-\n context_check(rule([RuleID, [[unless, X]], RuleHead])).\n emptyRule([RuleID, [[prolog(Check)]], RuleHead]) :-\n context_check(rule([RuleID, [[prolog(Check)]], RuleHead])),\n (callable(Check) -> call(Check); Check).\n buildArgumentsFromRules(Rules, [], n).\n buildArgumentsFromRules(Rules, [], y) :- buildArgumentsFromRules(Rules, Rules, n).\n buildArgumentsFromRules(Rules, [H|T], _) :-\n copy_term(H, HH),\n buildArgumentsFromRule(HH),\n buildArgumentsFromRules(Rules, T, y), !.\n buildArgumentsFromRules(Rules, [_|T], X) :-\n buildArgumentsFromRules(Rules, T, X).\n buildArgumentsFromRule([RuleID, RuleBody, RuleHead]) :-\n \truleBodyIsSupported(RuleBody, [], [], SupportRules, ArgSupports),\n \t\\+ member(RuleID, SupportRules),\n \tground(RuleHead),\n \tutils::sort([RuleID|SupportRules], SortedPremises),\n \t\\+ context_check(argument([SortedPremises, RuleID, RuleHead, RuleBody, _])),\n \tbuildArgumentInfo(ArgSupports, RuleID, Info),\n NewArgument = [SortedPremises, RuleID, RuleHead, RuleBody, Info],\n \tcontext_assert(argument(NewArgument)),\n \tsupports(NewArgument, ArgSupports).\n supports(Argument, Supports) :-\n findall(_, (\n member(S, Supports),\n context_assert(support(S, Argument))\n ), _).\n checkStrict(Id, [Id]) :- \\+ context_check(strict(Id)).\n checkStrict(Id, []) :- context_check(strict(Id)).\n buildArgumentInfo(Supports, RuleId, [LastDefRules, DefRules, DefPrem]) :-\n defeasibleRules(RuleId, Supports, DefRules),\n ordinaryPremises(Supports, DefPrem),\n lastDefeasibleRules(Supports, RuleId, LastDefRules).\n ordinaryPremises(Supports, DefPrem) :-\n findall(Def, member([_, _, _, _, [_, _, Def]], Supports), Prem),\n utils::appendLists(Prem, TempPrem),\n utils::sortDistinct(TempPrem, DefPrem).\n defeasibleRules(RuleId, Supports, DefRules) :-\n \tfindall(Def, member([_, _, _, _, [_, Def, _]], Supports), UnsortedRules),\n \tcheckStrict(RuleId, DefRule),\n \tutils::appendLists([DefRule|UnsortedRules], TempRules),\n \tutils::sortDistinct(TempRules, DefRules).\n lastDefeasibleRules(_, TopRule, [TopRule]) :-\n TopRule \\== none, \\+ context_check(strict(TopRule)).\n lastDefeasibleRules(Supports, TopRule, LastRules) :-\n \tcontext_check(strict(TopRule)),\n \tfindall(Def, member([_, _, _, _, [Def, _, _]], Supports), Res),\n \tutils::appendLists(Res, TempLastRules),\n \tutils::sortDistinct(TempLastRules, LastRules).\n ruleBodyIsSupported([], ResultPremises, ResultSupports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([ [unless, _] | Others], Premises, Supports, ResultPremises, ResultSupports) :-\n \truleBodyIsSupported(Others, Premises, Supports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([ [prolog(Check)] | Others], Premises, Supports, ResultPremises, ResultSupports) :-\n \t(callable(Check) -> call(Check); Check),\n \truleBodyIsSupported(Others, Premises, Supports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([Statement|Others], Premises, Supports, ResultPremises, ResultSupports) :-\n context_check(argument([ArgumentID, RuleID, Statement, Body, Info])),\n \tappend(ArgumentID, Premises, NewPremises),\n \truleBodyIsSupported(Others, NewPremises, [[ArgumentID, RuleID, Statement, Body, Info]|Supports], ResultPremises, ResultSupports).\n findPossibleAttackers([_, _, Head, _, _], [_, _, Conf, _, _]) :-\n conflict(Head, Conf).\n findPossibleAttackers([_, _, _, Prem, _], [_, _, Conf, _, _]) :-\n member([unless, Conf], Prem).\n findPossibleAttackers([_, RuleID, _, _, _], [_, _, [undercut(RuleID)], _, _]).\n buildAttacks :-\n findall(X, context_check(argument(X)), Args),\n \tbuildDirectAttacks(Args),\n \tbuildTransitiveAttacks.\n buildDirectAttacks([]).\n buildDirectAttacks([H|T]) :-\n findall(_, buildDirectAttack(H), _),\n buildDirectAttacks(T).\n buildDirectAttack(A) :-\n \tcontext_check(argument(B)),\n \tA \\== B,\n attacks(T, B, A),\n \t\\+ context_check(attack(T, B, A, A)),\n \tcontext_assert(attack(T, B, A, A)).\n buildTransitiveAttacks :-\n \tcontext_check(attack(T, A, B, D)),\n \tcontext_check(support(B, C)),\n \t\\+ context_check(attack(T, A, C, D)), !,\n \tcontext_assert(attack(T, A, C, D)),\n buildTransitiveAttacks.\n buildTransitiveAttacks.\n attacks(rebut, A, B) :- rebuts(A, B), !.\n attacks(contrary_rebut, A, B) :- contraryRebuts(A, B), !.\n attacks(undermine, A, B) :- undermines(A, B), !.\n attacks(contrary_undermine, A, B) :- contraryUndermines(A, B), !.\n attacks(undercut, A, B) :- undercuts(A, B), !.\n rebuts([IDPremisesA, RuleA, RuleHeadA, _, _], [IDPremisesB, RuleB, RuleHeadB, _, Info]) :-\n \tRuleB \\== none,\n Info \\== [[], [], []],\n \tconflict(RuleHeadA, RuleHeadB).\n contraryRebuts([IDPremisesA, RuleA, RuleHeadA, _, _], [IDPremisesB, RuleB, RuleHeadB, Body, Info]) :-\n \tRuleA \\== none,\n \tRuleB \\== none,\n \tmember([unless, RuleHeadA], Body).\n undermines([IDPremisesA, RuleA, RuleHeadA, _, _], [[IDPremiseB], none, RuleHeadB, _, Info]) :-\n \tInfo \\== [[], [], []],\n \tconflict(RuleHeadA, RuleHeadB).\n contraryUndermines([IDPremisesA, none, RuleHeadA, _, _], [IDPremisesB, RuleB, RuleHeadB, Body, Info]) :-\n \tRuleB \\== none,\n \tmember([unless, RuleHeadA], Body).\n undercuts([_, _, [undercut(RuleB)], _, _], [_, RuleB, _, _, [[RuleB], _, _]]).\n conflict( [Atom], [neg, Atom]).\n conflict( [neg, Atom], [Atom]).\n conflict( [obl, [Atom]], [obl, [neg, Atom]]).\n conflict( [obl, [neg, Atom]], [obl, [Atom]]).\n conflict( [obl, Lit], [neg, obl, Lit]).\n conflict( [neg, obl, Lit], [obl, Lit]).\n conflict( [perm, [Atom]], [obl, [neg, Atom]]).\n conflict( [obl, [neg, Atom]], [perm, [Atom]]).\n conflict( [perm, [neg, Atom]], [obl, [Atom]]).\n conflict( [obl, [Atom]], [perm, [neg, Atom]]).\n conflict([bp, Atom], [neg, bp, Atom]).\n conflict([neg, bp, Atom], [bp, Atom]).\n conflict([sup(X, Y)], [sup(Y, X)]).\n ');
5035
+ this.theoryCode = trimIndent('\n buildArgumentationGraph :-\n buildArguments,\n buildAttacks.\n buildArguments :-\n \tbuildArgumentsFromPremises,\n \tbuildArgumentsFromEmptyRules,\n \tfindall([RuleID, RuleBody, RuleHead], (\n \t parser::classic_rule(RuleID, RuleBody, RuleHead),\n \t \\+ emptyRule([RuleID, RuleBody, RuleHead])\n ), Rules),\n \tbuildArgumentsFromRules(b, Rules, Rules, n).\n buildArgumentsFromPremises :-\n findall(\n _,\n (\n parser::classic_rule(PremiseID, Premise),\n checkStrict(PremiseID, DefPrem),\n ground(Premise),\n context_assert(argument([[PremiseID], none, Premise, [], [[], [], DefPrem]])),\n context_assert(conc(Premise) :- argument([[PremiseID], none, Premise, [], [[], [], DefPrem]])),\n context_assert(newConc(a, Premise)),\n utils::hash(argument([[PremiseID], none, Premise, [], [[], [], DefPrem]]), Id),\n context_assert(arg(Id) :- argument([[PremiseID], none, Premise, [], [[], [], DefPrem]]))\n ),\n _\n ).\n buildArgumentsFromEmptyRules :-\n findall(\n _,\n (\n emptyRule([RuleID, RulePrem, RuleHead]),\n checkStrict(RuleID, DefRule),\n ground(RuleHead),\n context_assert(argument([[RuleID], RuleID, RuleHead, RulePrem, [DefRule, DefRule, []]])),\n context_assert(conc(Premise) :- argument([[RuleID], RuleID, RuleHead, RulePrem, [DefRule, DefRule, []]])),\n context_assert(newConc(a, Premise)),\n utils::hash(argument([[RuleID], RuleID, RuleHead, RulePrem, [DefRule, DefRule, []]]), Id),\n context_assert(arg(Id) :- argument([[RuleID], RuleID, RuleHead, RulePrem, [DefRule, DefRule, []]]))\n ),\n _\n ).\n emptyRule([RuleID, Body, RuleHead]) :-\n parser::classic_rule(RuleID, Body, RuleHead),\n \\+ (member(X, Body), X \\= ~(_), X \\= prolog(_)),\n checkPrologClauses(Body).\n checkPrologClauses([]) :- !.\n checkPrologClauses([~(_)|T]) :- checkPrologClauses(T), !.\n checkPrologClauses([prolog(Check)|T]) :-\n (callable(Check) -> call(Check); Check),\n checkPrologClauses(T).\n clean(Tn, Rules) :-\n invert(Tn, Tx),\n context_retract(newConc(Tx, _)),\n buildArgumentsFromRules(Tx, Rules, Rules, n).\n check_new(Tn, H) :-\n copy_term(H, [_, RuleBody, _]),\n member(X, RuleBody),\n invert(Tn, Tx),\n context_check(newConc(Tx, [X])).\n invert(a, b).\n invert(b, a).\n buildArgumentsFromRules(_, Rules, [], n).\n buildArgumentsFromRules(Tn, Rules, [], y) :- clean(Tn, Rules).\n buildArgumentsFromRules(Tn, Rules, [H|T], _) :-\n once(check_new(Tn, H)),\n copy_term(H, HH),\n findall(true, buildArgumentsFromRule(Tn, HH), R),\n R \\== [],\n buildArgumentsFromRules(Tn, Rules, T, y), !.\n buildArgumentsFromRules(Tn, Rules, [_|T], X) :-\n buildArgumentsFromRules(Tn, Rules, T, X).\n buildArgumentsFromRule(Tn, [RuleID, RuleBody, RuleHead]) :-\n \truleBodyIsSupported(RuleBody, [], [], SupportRules, ArgSupports),\n \t\\+ member(RuleID, SupportRules),\n \tground(RuleHead),\n \tutils::sort([RuleID|SupportRules], SortedPremises),\n \t\\+ context_check(argument([SortedPremises, RuleID, RuleHead, RuleBody, _])),\n \tbuildArgumentInfo(ArgSupports, RuleID, Info),\n NewArgument = [SortedPremises, RuleID, RuleHead, RuleBody, Info],\n context_assert(conc(RuleHead) :- argument(NewArgument)),\n context_assert(newConc(Tn, RuleHead)),\n \tcontext_assert(argument(NewArgument)),\n \tutils::hash(argument(NewArgument), Id),\n \tcontext_assert(arg(Id) :- argument(NewArgument)),\n \tsupports(NewArgument, ArgSupports).\n supports(Argument, Supports) :-\n findall(_, (\n member(S, Supports),\n context_assert(support(S, Argument))\n ), _).\n checkStrict(Id, [Id]) :- \\+ parser::check_strict(Id).\n checkStrict(Id, []) :- parser::check_strict(Id).\n buildArgumentInfo(Supports, RuleId, [LastDefRules, DefRules, DefPrem]) :-\n defeasibleRules(RuleId, Supports, DefRules),\n ordinaryPremises(Supports, DefPrem),\n lastDefeasibleRules(Supports, RuleId, LastDefRules).\n ordinaryPremises(Supports, DefPrem) :-\n findall(Def, member([_, _, _, _, [_, _, Def]], Supports), Prem),\n utils::appendLists(Prem, TempPrem),\n utils::sortDistinct(TempPrem, DefPrem).\n defeasibleRules(RuleId, Supports, DefRules) :-\n \tfindall(Def, member([_, _, _, _, [_, Def, _]], Supports), UnsortedRules),\n \tcheckStrict(RuleId, DefRule),\n \tutils::appendLists([DefRule|UnsortedRules], TempRules),\n \tutils::sortDistinct(TempRules, DefRules).\n lastDefeasibleRules(_, TopRule, [TopRule]) :-\n TopRule \\== none, \\+ parser::check_strict(TopRule).\n lastDefeasibleRules(Supports, TopRule, LastRules) :-\n \tparser::check_strict(TopRule),\n \tfindall(Def, member([_, _, _, _, [Def, _, _]], Supports), Res),\n \tutils::appendLists(Res, TempLastRules),\n \tutils::sortDistinct(TempLastRules, LastRules).\n ruleBodyIsSupported([], ResultPremises, ResultSupports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([~(_)|Others], Premises, Supports, ResultPremises, ResultSupports) :-\n \truleBodyIsSupported(Others, Premises, Supports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([prolog(Check)|Others], Premises, Supports, ResultPremises, ResultSupports) :-\n \t(callable(Check) -> call(Check); Check),\n \truleBodyIsSupported(Others, Premises, Supports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([Statement|Others], Premises, Supports, ResultPremises, ResultSupports) :-\n context_check(clause(conc([Statement]), argument([ArgumentID, RuleID, [Statement], Body, Info]))),\n \tappend(ArgumentID, Premises, NewPremises),\n \truleBodyIsSupported(Others, NewPremises, [[ArgumentID, RuleID, [Statement], Body, Info]|Supports], ResultPremises, ResultSupports).\n findPossibleAttackers([_, _, Head, _, _], Conf) :-\n conflict(Head, Conf).\n findPossibleAttackers([_, _, _, Prem, _], [Conf]) :-\n member(~(Conf), Prem).\n findPossibleAttackers([_, RuleID, _, _, _], [undercut(RuleID)]).\n buildAttacks :-\n \tbuildDirectAttacks,\n \tbuildTransitiveAttacks.\n buildDirectAttacks :-\n findall(_, buildDirectAttack, _).\n buildDirectAttack :-\n context_check(argument(A)),\n findPossibleAttackers(A, BB),\n \tcontext_check(clause(conc(BB), argument(B))),\n \tA \\== B,\n attacks(T, B, A),\n \t\\+ context_check(attack(T, B, A, A)),\n \tcontext_assert(attack(T, B, A, A)),\n \tutils::hash(argument(A), IdA),\n \tutils::hash(argument(B), IdB),\n \tcontext_assert(att(IdB, IdA) :- attack(T, B, A, A)),\n \tfail.\n buildDirectAttack.\n buildTransitiveAttacks :-\n \tcontext_check(attack(T, A, B, D)),\n \tcontext_check(support(B, C)),\n \t\\+ context_check(attack(T, A, C, D)), !,\n \tcontext_assert(attack(T, A, C, D)),\n utils::hash(argument(A), IdA),\n utils::hash(argument(C), IdC),\n context_assert(att(IdA, IdC) :- attack(T, B, C, D)),\n buildTransitiveAttacks.\n buildTransitiveAttacks.\n attacks(rebut, A, B) :- rebuts(A, B), !.\n attacks(contrary_rebut, A, B) :- contraryRebuts(A, B), !.\n attacks(undermine, A, B) :- undermines(A, B), !.\n attacks(contrary_undermine, A, B) :- contraryUndermines(A, B), !.\n attacks(undercut, A, B) :- undercuts(A, B), !.\n rebuts([IDPremisesA, RuleA, RuleHeadA, _, _], [IDPremisesB, RuleB, RuleHeadB, _, Info]) :-\n \tRuleB \\== none,\n Info \\== [[], [], []],\n \tconflict(RuleHeadA, RuleHeadB).\n contraryRebuts([IDPremisesA, RuleA, [RuleHeadA], _, _], [IDPremisesB, RuleB, RuleHeadB, Body, Info]) :-\n \tRuleA \\== none,\n \tRuleB \\== none,\n \tmember(~(RuleHeadA), Body).\n undermines([IDPremisesA, RuleA, RuleHeadA, _, _], [[IDPremiseB], none, RuleHeadB, _, Info]) :-\n \tInfo \\== [[], [], []],\n \tconflict(RuleHeadA, RuleHeadB).\n contraryUndermines([IDPremisesA, none, [RuleHeadA], _, _], [IDPremisesB, RuleB, RuleHeadB, Body, Info]) :-\n \tRuleB \\== none,\n \tmember(~(RuleHeadA), Body).\n undercuts([_, _, [undercut(RuleB)], _, _], [_, RuleB, _, _, [[RuleB], _, _]]).\n check(-Atom).\n conflict([Atom], [-Atom]) :- \\+ check(Atom).\n conflict([-Atom], [Atom]).\n conflict([o(Atom)], [o(-Atom)]).\n conflict([o(-Atom)], [o(Atom)]).\n conflict([o(Lit)], [-o(Lit)]).\n conflict([-o(Lit)], [o(Lit)]).\n conflict([p(Atom)], [o(-Atom)]).\n conflict([o(-Atom)], [p(Atom)]).\n conflict([p(-Atom)], [o(Atom)]).\n conflict([o(Atom)], [p(-Atom)]).\n conflict([sup(X, Y)], [sup(Y, X)]).\n ');
4889
5036
  }
4890
5037
  ArgumentationGraph.$metadata$ = {
4891
5038
  kind: Kind_OBJECT,
@@ -4930,7 +5077,7 @@
4930
5077
  }
4931
5078
  function BpGrounded() {
4932
5079
  BpGrounded_instance = this;
4933
- this.theoryCode = trimIndent('\n argumentLabelling :-\n reifyBurdenOfProofs,\n filterBpDefeats,\n findall(X, context_check(argument(X)), Arguments),\n bpLabelling(Arguments).\n bpLabelling(Arguments) :-\n member(A, Arguments),\n grounded::allAttacksOUT(A), !,\n context_assert(in(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Arguments) :-\n member(A, Arguments),\n \\+ isArgumentInBurdenOfProof(A),\n grounded::oneAttackIN(A), !,\n context_assert(out(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Arguments) :-\n context_active(Branch),\n mostGroundedBpUnd(Arguments, A),\n context_branch(Branch, _),\n context_assert(out(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Args) :-\n notLabelled(Args),\n findall(_, (member(A, Args), context_assert(und(A))), _).\n notLabelled(Args) :-\n \\+ (\n member(A, Args),\n (\n context_check(in(A));\n context_check(out(A));\n context_check(und(A))\n )\n ).\n isInBurdenOfProof(Conclusion) :-\n context_check(reifiedBp(Literals)),\n member(Conclusion, Literals), !.\n isArgumentInBurdenOfProof([_, _, Conclusion, _, _]) :-\n isInBurdenOfProof(Conclusion).\n filterBpDefeats :-\n findall(_, (\n context_check(attack(T, A, B, C)),\n filterBpDefeat(T, A, B, C)\n ), _).\n filterBpDefeat(T, B, A, C) :-\n (T = rebut; T = undermine),\n isArgumentInBurdenOfProof(B),\n \\+ superiority::superiorArgument(B, C),\n context_retract(attack(T, B, A, C)).\n mostGroundedBpUnd(Arguments, Arg) :-\n member(Arg, Arguments),\n isArgumentInBurdenOfProof(Arg),\n \\+ (\n member(A, Arguments), Arg \\= A,\n isArgumentInBurdenOfProof(A),\n argumentChain(A, Arg)\n ).\n argumentChain(A, A) :- !.\n argumentChain(A, B) :-\n A \\== B,\n context_check(attack(_, A, C, _)),\n argumentChain(C, B).\n reifyBurdenOfProofs :-\n findall(_, (\n context_check(abstractBp(AbstractBp)),\n fillTemplate(AbstractBp, R),\n \\+ context_check(reifiedBp(R)),\n context_assert(reifiedBp(R))\n ), _).\n /*\n Fill the template (first parameter) using arguments conclusions\n */\n fillTemplate([], []).\n fillTemplate([H|T], [H|R]) :-\n context_check(argument([_, _, Conclusion, _, _])),\n fillTemplate(T, R).\n ');
5080
+ this.theoryCode = trimIndent('\n argumentLabelling :-\n reifyBurdenOfProofs,\n filterBpDefeats,\n findall(X, context_check(argument(X)), Arguments),\n bpLabelling(Arguments).\n bpLabelling(Arguments) :-\n member(A, Arguments),\n grounded::allAttacksOUT(A), !,\n context_assert(in(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Arguments) :-\n member(A, Arguments),\n \\+ isArgumentInBurdenOfProof(A),\n grounded::oneAttackIN(A), !,\n context_assert(out(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Arguments) :-\n context_active(Branch),\n mostGroundedBpUnd(Arguments, A),\n context_branch(Branch, _),\n context_assert(out(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Args) :-\n notLabelled(Args),\n findall(_, (member(A, Args), context_assert(und(A))), _).\n notLabelled(Args) :-\n \\+ (\n member(A, Args),\n (\n context_check(in(A));\n context_check(out(A));\n context_check(und(A))\n )\n ).\n isInBurdenOfProof(Conclusion) :-\n context_check(reifiedBp(Literals)),\n member(Conclusion, Literals), !.\n isArgumentInBurdenOfProof([_, _, Conclusion, _, _]) :-\n isInBurdenOfProof(Conclusion).\n filterBpDefeats :-\n findall(_, (\n context_check(attack(T, A, B, C)),\n filterBpDefeat(T, A, B, C)\n ), _).\n filterBpDefeat(T, B, A, C) :-\n (T = rebut; T = undermine),\n isArgumentInBurdenOfProof(B),\n \\+ superiority::superiorArgument(B, C),\n context_retract(attack(T, B, A, C)).\n mostGroundedBpUnd(Arguments, Arg) :-\n member(Arg, Arguments),\n isArgumentInBurdenOfProof(Arg),\n \\+ (\n member(A, Arguments), Arg \\= A,\n isArgumentInBurdenOfProof(A),\n argumentChain(A, Arg)\n ).\n argumentChain(A, A) :- !.\n argumentChain(A, B) :-\n A \\== B,\n context_check(attack(_, A, C, _)),\n argumentChain(C, B).\n reifyBurdenOfProofs :-\n findall(_, (\n context_check(abstractBp(AbstractBp)),\n fillTemplate(AbstractBp, R),\n \\+ context_check(reifiedBp(R)),\n context_assert(reifiedBp(R))\n ), _).\n /*\n Fill the template (first parameter) using arguments conclusions\n */\n fillTemplate([], []).\n fillTemplate([H|T], [[H]|R]) :-\n context_check(argument([_ , _, [P], _, _])),\n fillTemplate(T, R).\n ');
4934
5081
  }
4935
5082
  BpGrounded.$metadata$ = {
4936
5083
  kind: Kind_OBJECT,
@@ -5035,7 +5182,7 @@
5035
5182
  }
5036
5183
  function Grounded() {
5037
5184
  Grounded_instance = this;
5038
- this.theoryCode = trimIndent('\n argumentLabelling :-\n findall(X, context_check(argument(X)), Arguments),\n groundedLabelling(Arguments).\n groundedLabelling(UND) :-\n member(A, UND), \n allAttacksOUT(A), !,\n utils::subtract(UND, [A], NewUND),\n context_assert(in(A)),\n groundedLabelling(NewUND).\n groundedLabelling(UND) :-\n member(A, UND),\n oneAttackIN(A), !,\n utils::subtract(UND, [A], NewUND),\n context_assert(out(A)),\n groundedLabelling(NewUND).\n groundedLabelling(Args) :- findall(_, (member(A, Args), context_assert(und(A))), _).\n allAttacksOUT(A) :-\n \\+ ( context_check(attack(_, B, A, _)), \\+ (context_check(out(B)))).\n oneAttackIN(A) :-\n context_check(attack(_, B, A, _)),\n context_check(in(B)), !.\n oneAttackIN(A) :-\n context_check(attack(_, A, B, _)),\n context_check(in(B)), !.\n ');
5185
+ this.theoryCode = trimIndent('\n argumentLabelling :-\n findall(X, context_check(argument(X)), Arguments),\n groundedLabelling(Arguments).\n groundedLabelling(UND) :-\n member(A, UND),\n allAttacksOUT(A), !,\n utils::subtract(UND, [A], NewUND),\n context_assert(in(A)),\n groundedLabelling(NewUND).\n groundedLabelling(UND) :-\n member(A, UND),\n oneAttackIN(A), !,\n utils::subtract(UND, [A], NewUND),\n context_assert(out(A)),\n groundedLabelling(NewUND).\n groundedLabelling(Args) :- findall(_, (member(A, Args), context_assert(und(A))), _).\n allAttacksOUT(A) :-\n \\+ ( context_check(attack(_, B, A, _)), \\+ (context_check(out(B)))).\n oneAttackIN(A) :-\n context_check(attack(_, B, A, _)),\n context_check(in(B)), !.\n oneAttackIN(A) :-\n context_check(attack(_, A, B, _)),\n context_check(in(B)), !.\n ');
5039
5186
  }
5040
5187
  Grounded.$metadata$ = {
5041
5188
  kind: Kind_OBJECT,
@@ -5048,9 +5195,24 @@
5048
5195
  new Grounded();
5049
5196
  }return Grounded_instance;
5050
5197
  }
5198
+ function GroundedOptimized() {
5199
+ GroundedOptimized_instance = this;
5200
+ this.theoryCode = trimIndent('\n argumentLabelling :-\n groundedLabelling.\n groundedLabelling :-\n findall(t, evaluateIn, I),\n findall(t, evaluateOut, O),\n finalize(I, O).\n evaluateIn :-\n argument_to_evaluate(A, IdA),\n allAttacksOUT(IdA),\n context_assert(in(A)),\n context_assert(inId(IdA)).\n evaluateOut :-\n argument_to_evaluate(A, IdA),\n oneAttackIN(IdA),\n context_assert(out(A)),\n context_assert(outId(IdA)).\n finalize(I, O) :- I \\= [], !, groundedLabelling.\n finalize(I, O) :- O \\= [], !, groundedLabelling.\n finalize([], []) :-\n argument_to_evaluate(A, _),\n context_assert(und(A)),\n fail.\n finalize(_, _).\n argument_to_evaluate(X, IdX) :-\n context_check(clause(arg(IdX), argument(X))),\n \\+ context_check(outId(IdX)),\n \\+ context_check(inId(IdX)).\n allAttacksOUT(A) :-\n \\+ ( context_check(clause(att(B, A), _)), \\+ (context_check(outId(B)))).\n oneAttackIN(A) :-\n context_check(clause(att(B, A), _)),\n context_check(inId(B)), !.\n oneAttackIN(A) :-\n context_check(clause(att(A, B), _)),\n context_check(inId(B)), !.\n ');
5201
+ }
5202
+ GroundedOptimized.$metadata$ = {
5203
+ kind: Kind_OBJECT,
5204
+ simpleName: 'GroundedOptimized',
5205
+ interfaces: []
5206
+ };
5207
+ var GroundedOptimized_instance = null;
5208
+ function GroundedOptimized_getInstance() {
5209
+ if (GroundedOptimized_instance === null) {
5210
+ new GroundedOptimized();
5211
+ }return GroundedOptimized_instance;
5212
+ }
5051
5213
  function Preferences() {
5052
5214
  Preferences_instance = this;
5053
- this.theoryCode = trimIndent('\n modifyArgumentationGraph :-\n findall(_, (\n context_check(attack(T, A, B, C)),\n checkStandardPreference(T, A, B, C)\n ), _).\n checkStandardPreference(T, A, B, C) :-\n \\+ standardPreferences(T, A, B, C),\n context_retract(attack(T, A, B, C)).\n standardPreferences(rebut, A, _, C) :- \\+ superiority::superiorArgument(C, A).\n standardPreferences(undermine, A, _, C) :- \\+ superiority::superiorArgument(C, A).\n standardPreferences(contrary_rebut, _, _, _).\n standardPreferences(contrary_undermine, _, _, _).\n standardPreferences(undercut, _, _, _).\n ');
5215
+ this.theoryCode = trimIndent('\n modifyArgumentationGraph :-\n findall(_, (\n context_check(attack(T, A, B, C)),\n checkStandardPreference(T, A, B, C)\n ), _).\n checkStandardPreference(T, A, B, C) :-\n \\+ standardPreferences(T, A, B, C),\n context_retract(attack(T, A, B, C)),\n hashed_attack(attack(T, A, B, C), Y),\n context_retract(Y).\n standardPreferences(rebut, A, _, C) :- \\+ superiority::superiorArgument(C, A).\n standardPreferences(undermine, A, _, C) :- \\+ superiority::superiorArgument(C, A).\n standardPreferences(contrary_rebut, _, _, _).\n standardPreferences(contrary_undermine, _, _, _).\n standardPreferences(undercut, _, _, _).\n hashed_attack(attack(T, A, B, C), att(IdA, IdB) :- attack(T, A, B, C)) :-\n utils::hash(argument(A), IdA),\n utils::hash(argument(B), IdB).\n ');
5054
5216
  }
5055
5217
  Preferences.$metadata$ = {
5056
5218
  kind: Kind_OBJECT,
@@ -5065,7 +5227,7 @@
5065
5227
  }
5066
5228
  function QueryMode_0() {
5067
5229
  QueryMode_instance_0 = this;
5068
- this.theoryCode = trimIndent('\n computeStatementAcceptance(Goal, YesResult, NoResult, UndResult) :-\n \\+ queryMode,\n abstract:::computeGlobalAcceptance,\n mineResults(Goal, YesResult, NoResult, UndResult).\n computeStatementAcceptance(Goal, YesResult, NoResult, UndResult) :-\n queryMode,\n argumentLabellingMode(grounded),\n parser::check_modifiers_in_list(effects, [Goal], [X]),\n findall(_, query(X, _), _),\n (ambiguityBlocking ->\n statement_binary:::statementLabelling;\n statementLabellingMode(Y),\n Y:::statementLabelling\n ),\n mineResults(Goal, YesResult, NoResult, UndResult).\n mineResults(Goal, YesResult, NoResult, UndResult) :-\n parser::check_modifiers_in_list(effects, [Goal], [X]),\n findall(Goal, context_check(statIn(X)), In),\n findall(Goal, context_check(statOut(X)), Out),\n findall(Goal, context_check(statUnd(X)), Und),\n utils::sort(In, YesResult),\n utils::sort(Out, NoResult),\n utils::sort(Und, UndResult).\n query(Query, Res) :-\n buildArgument(Query, Argument),\n once(defend(Argument, [], Res)).\n query(Query, und) :- \\+ buildArgument(Query, _).\n defend(Argument, _, no) :- context_check(out(Argument)).\n defend(Argument, _, und) :- context_check(und(Argument)).\n defend(Argument, _, yes) :- context_check(in(Argument)).\n defend(Argument, QueryChain, no) :-\n findAttacker(Argument, QueryChain, Attacker, yes),\n once(defend(Attacker, [Argument|QueryChain], X)),\n X == yes,\n bufferResult(Argument, no), !.\n defend(Argument, QueryChain, Res) :-\n findAttacker(Argument, QueryChain, Attacker, yes),\n once(defend(Attacker, [Argument|QueryChain], X)),\n X == und,\n ambiguityCheck(Argument, Attacker, Res),\n bufferResult(Argument, Res), !.\n complementary([_, _, ConclusionA, _, _], [_, _, ConclusionB, _, _]) :-\n standard_af::conflict(ConclusionA, ConclusionB).\n ambiguityCheck(A, B, no) :- ambiguityBlocking,\n \\+ complementary(A, B),\n context_check(attack(direct, B, A, _)), !.\n ambiguityCheck(_, _, und).\n defend(Argument, QueryChain, und) :-\n findAttacker(Argument, QueryChain, Attacker, no),\n bufferResult(Argument, und), !.\n defend(Argument, QueryChain, yes) :- bufferResult(Argument, yes).\n bufferResult(Argument, no) :- \\+ context_check(out(Argument)), context_assert(out(Argument)), !.\n bufferResult(Argument, yes) :- \\+ context_check(in(Argument)), context_assert(in(Argument)), !.\n bufferResult(Argument, und) :- \\+ context_check(und(Argument)), context_assert(und(Argument)), !.\n bufferResult(_, _).\n findAttacker(Target, QueryChain, Attacker, IsValid) :-\n attacker(Target, Attacker, Type),\n bufferAttacker(Attacker, Target, Type),\n detectCycle(Attacker, QueryChain, IsValid).\n bufferAttacker(Attacker, Target, Type) :-\n \\+ context_check(attack(Type, Attacker, Target, none)),\n context_assert(attack(Type, Attacker, Target, none)), !.\n bufferAttacker(_, _, _).\n detectCycle(Attacker, QueryChain, yes) :- \\+ member(Attacker, QueryChain).\n detectCycle(Attacker, QueryChain, no) :- member(Attacker, QueryChain).\n attacker([Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type) :-\n member(X, Rules),\n \\+ context_check(strict(X)),\n attackerOnRule(X, [Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type).\n attacker([Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type) :-\n member(X, Groundings),\n attackerOnTerm(X, [Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type).\n attackerOnRule(Rule, _, Argument, undercut) :-\n buildArgument([undercut(Rule)], Argument).\n attackerOnTerm(Term, [TargetRules, TopRule, Conclusion, Groundings, ArgInfo], Attacker, direct) :-\n Term \\= [unless, _],\n \\+ strict([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]),\n (graphExtension(rebutRestriction) ->\n (\n buildSubArgument(Term, TargetRules, SubArgument),\n rebutRestriction(SubArgument)\n );\n true\n ),\n standard_af::conflict(Term, X),\n buildArgument(X, Attacker),\n (graphExtension(standardPref) ->\n (ground(SubArgument) ->\n true;\n buildSubArgument(Term, TargetRules, SubArgument)\n ),\n \\+ superiorArgument(SubArgument, Attacker);\n true\n ).\n attackerOnTerm([unless, X], _, Attacker, contrary) :-\n buildArgument(X, Attacker).\n strict([_, _, _, _, [_, [], []]]).\n rebutRestriction([TargetRules, none, Conclusion, Groundings, ArgInfo]) :-\n graphExtension(rebutRestriction).\n rebutRestriction([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]) :-\n graphExtension(rebutRestriction),\n TopRule \\= none,\n rebutRestriction::restrict([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]).\n rebutRestriction(_) :- \\+ graphExtension(rebutRestriction).\n superiorArgument(SubArgument, Attacker) :-\n superiority::superiorArgument(SubArgument, Attacker).\n buildSubArgument(Term, Rules, [SubRules, SubTopRule, SubConclusion, SubGrounds, Info]) :-\n buildArgument(Term, [SubRules, SubTopRule, SubConclusion, SubGrounds, Info]),\n contained(SubRules, Rules).\n contained([], _).\n contained([H|T], Target) :- member(H, Target), contained(T, Target).\n buildArgument(Query, Argument) :-\n \\+ context_check(explored(Query)),\n findall(_, (\n buildSingleArgument(Query, Argument),\n context_assert(argument(Argument))\n ), _),\n context_assert(explored(Query)),\n fail.\n buildArgument(Query, [R, T, Query, B, I]) :- context_check(argument([R, T, Query, B, I])).\n buildSingleArgument(Query, Argument) :-\n build(Query, [], Groundings, [AllRules, TopRule, LastDefRules, DefRules, DefPremises]),\n utils::deduplicate(DefRules, CDefRules),\n utils::deduplicate(DefPremises, CDefPremises),\n utils::deduplicate(Groundings, CGroundings),\n Argument = [AllRules, TopRule, Query, CGroundings, [LastDefRules, CDefRules, CDefPremises]].\n build(Conclusion, _, [Conclusion], Rules) :-\n context_check(premise([Id, Conclusion])),\n premiseRules(Id, Rules).\n build(Conclusion, Ids, [Conclusion|Conclusions], Rules) :-\n context_check(rule([Id, Premises, Conclusion])),\n \\+ member(Id, Ids),\n buildPremises(Premises, [Id|Ids], Conclusions, ResRules),\n ruleRules(Id, ResRules, Rules).\n build([prolog(Check)], _, [], []) :- (callable(Check) -> call(Check); Check).\n build([unless, Atom], _, [[unless, Atom]], []).\n buildPremises([], _, [], [[], [], [], []]).\n buildPremises([H|T], Ids, Conclusions, Rules) :-\n build(H, Ids, HConclusions, HRules),\n buildPremises(T, Ids, TConclusions, TRules),\n utils::appendLists([HConclusions, TConclusions], Conclusions),\n mergeRules(HRules, TRules, Rules).\n premiseRules(Id, [[Id], none, [], [], [Id]]) :- \\+ context_check(strict(Id)).\n premiseRules(Id, [[Id], none, [], [], []]) :- context_check(strict(Id)).\n ruleRules(Id, [AllRules, _, DefRules, DefPremises], \n [[Id|AllRules], Id, [Id], [Id|DefRules], DefPremises]) :- \\+ context_check(strict(Id)).\n ruleRules(Id, [AllRules, LastDefRules, DefRules, DefPremises], \n [[Id|AllRules], Id, LastDefRules, DefRules, DefPremises]) :- context_check(strict(Id)).\n mergeRules([], [AllRules, LastDefRules, DefRules, DefPremises], [AllRules, LastDefRules, DefRules, DefPremises]).\n mergeRules([HAR, _, HLDR, HDR, HDP], [TAR, TLDR, TDR, TDP], [AR, LDR, DR, DP]) :-\n utils::appendLists([HAR, TAR], AR),\n utils::appendLists([HLDR, TLDR], LDR),\n utils::appendLists([HDR, TDR], DR),\n utils::appendLists([HDP, TDP], DP).\n ');
5230
+ this.theoryCode = trimIndent('\n computeStatementAcceptance(Goal, YesResult, NoResult, UndResult) :-\n \\+ queryMode,\n abstract:::computeGlobalAcceptance,\n mineResults(Goal, YesResult, NoResult, UndResult).\n computeStatementAcceptance(Goal, YesResult, NoResult, UndResult) :-\n queryMode,\n argumentLabellingMode(grounded),\n findall(_, query(Goal, _), _),\n (ambiguityBlocking ->\n statement_binary:::statementLabelling;\n statementLabellingMode(Y),\n Y:::statementLabelling\n ),\n mineResults(Goal, YesResult, NoResult, UndResult).\n mineResults(Goal, YesResult, NoResult, UndResult) :-\n findall(Goal, context_check(statIn([Goal])), In),\n findall(Goal, context_check(statOut([Goal])), Out),\n findall(Goal, context_check(statUnd([Goal])), Und),\n utils::sort(In, YesResult),\n utils::sort(Out, NoResult),\n utils::sort(Und, UndResult).\n query(Query, Res) :-\n buildArgument(Query, Argument),\n once(defend(Argument, [], Res)).\n query(Query, und) :- \\+ buildArgument(Query, _).\n defend(Argument, _, no) :- context_check(out(Argument)).\n defend(Argument, _, und) :- context_check(und(Argument)).\n defend(Argument, _, yes) :- context_check(in(Argument)).\n defend(Argument, QueryChain, no) :-\n findAttacker(Argument, QueryChain, Attacker, yes),\n once(defend(Attacker, [Argument|QueryChain], X)),\n X == yes,\n bufferResult(Argument, no), !.\n defend(Argument, QueryChain, Res) :-\n findAttacker(Argument, QueryChain, Attacker, yes),\n once(defend(Attacker, [Argument|QueryChain], X)),\n X == und,\n ambiguityCheck(Argument, Attacker, Res),\n bufferResult(Argument, Res), !.\n complementary([_, _, ConclusionA, _, _], [_, _, ConclusionB, _, _]) :-\n standard_af::conflict(ConclusionA, ConclusionB).\n ambiguityCheck(A, B, no) :- ambiguityBlocking,\n \\+ complementary(A, B),\n context_check(attack(direct, B, A, _)), !.\n ambiguityCheck(_, _, und).\n defend(Argument, QueryChain, und) :-\n findAttacker(Argument, QueryChain, Attacker, no),\n bufferResult(Argument, und), !.\n defend(Argument, QueryChain, yes) :- bufferResult(Argument, yes).\n bufferResult(Argument, no) :- \\+ context_check(out(Argument)), context_assert(out(Argument)), !.\n bufferResult(Argument, yes) :- \\+ context_check(in(Argument)), context_assert(in(Argument)), !.\n bufferResult(Argument, und) :- \\+ context_check(und(Argument)), context_assert(und(Argument)), !.\n bufferResult(_, _).\n findAttacker(Target, QueryChain, Attacker, IsValid) :-\n attacker(Target, Attacker, Type),\n bufferAttacker(Attacker, Target, Type),\n detectCycle(Attacker, QueryChain, IsValid).\n bufferAttacker(Attacker, Target, Type) :-\n \\+ context_check(attack(Type, Attacker, Target, none)),\n context_assert(attack(Type, Attacker, Target, none)), !.\n bufferAttacker(_, _, _).\n detectCycle(Attacker, QueryChain, yes) :- \\+ member(Attacker, QueryChain).\n detectCycle(Attacker, QueryChain, no) :- member(Attacker, QueryChain).\n attacker([Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type) :-\n member(X, Rules),\n \\+ parser::strict(X),\n attackerOnRule(X, [Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type).\n attacker([Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type) :-\n member(X, Groundings),\n attackerOnTerm(X, [Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type).\n attackerOnRule(Rule, _, Argument, undercut) :-\n parser::undercut(Undercut, Rule),\n buildArgument(Undercut, Argument).\n attackerOnTerm(Term, [TargetRules, TopRule, Conclusion, Groundings, ArgInfo], Attacker, direct) :-\n \\+ parser::contrary(Term, _),\n \\+ strict([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]),\n (graphExtension(rebutRestriction) ->\n (\n getSubArgument(Term, TargetRules, SubArgument),\n rebutRestriction(SubArgument)\n );\n true\n ),\n standard_af::conflict(Term, [X]),\n buildArgument(X, Attacker),\n (graphExtension(standardPref) ->\n (\n once(getSubArgument(Term, TargetRules, SubArgument)),\n \\+ superiorArgument(SubArgument, Attacker)\n );\n true\n ).\n attackerOnTerm(Unless, _, Attacker, contrary) :-\n parser::contrary(Unless, X),\n buildArgument(X, Attacker).\n strict([_, _, _, _, [_, [], []]]).\n rebutRestriction([TargetRules, none, Conclusion, Groundings, ArgInfo]) :-\n graphExtension(rebutRestriction).\n rebutRestriction([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]) :-\n graphExtension(rebutRestriction),\n TopRule \\= none,\n rebutRestriction::restrict([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]).\n rebutRestriction(_) :- \\+ graphExtension(rebutRestriction).\n superiorArgument(SubArgument, Attacker) :-\n superiority::superiorArgument(SubArgument, Attacker).\n getSubArgument(Term, Rules, [SubRules, SubTopRule, SubConclusion, SubGrounds, Info]) :-\n context_check(clause(support(Term), argument([SubRules, SubTopRule, SubConclusion, SubGrounds, Info]))),\n contained(SubRules, Rules).\n contained([], _).\n contained([H|T], Target) :- member(H, Target), contained(T, Target).\n buildArgument(Query, Argument) :-\n \\+ context_check(explored(Query)),\n findall(_, (\n buildSingleArgument([Query], Argument),\n context_assert(argument(Argument))\n ), _),\n context_assert(explored(Query)),\n fail.\n buildArgument(Query, [R, T, [Query], B, I]) :- context_check(argument([R, T, [Query], B, I])).\n buildSingleArgument(Query, Argument) :-\n build(Query, [], Groundings, [AllRules, TopRule, LastDefRules, DefRules, DefPremises]),\n utils::deduplicate(DefRules, CDefRules),\n utils::deduplicate(DefPremises, CDefPremises),\n utils::deduplicate(Groundings, CGroundings),\n Argument = [AllRules, TopRule, Query, CGroundings, [LastDefRules, CDefRules, CDefPremises]].\n build(Check, _, [], []) :- parser::prolog(Check, Term), (callable(Term) -> call(Term); Term), !.\n build(Unless, _, [Unless], []) :- parser::contrary(Unless, _), !.\n build(Conclusion, _, [Conclusion], [AllRules, TopRule, LastDefRules, DefRules, DefPremises]) :-\n parser::premise(Id, Conclusion),\n premiseRules(Id, [AllRules, TopRule, LastDefRules, DefRules, DefPremises]),\n context_assert(support(Conclusion) :- argument([AllRules, TopRule, Conclusion, [Conclusion], [LastDefRules, DefRules, DefPremises]])).\n build(Conclusion, Ids, [Conclusion|Conclusions], [AllRules, TopRule, LastDefRules, DefRules, DefPremises]) :-\n parser::rule(Id, Premises, Conclusion),\n \\+ member(Id, Ids),\n buildPremises(Premises, [Id|Ids], Conclusions, ResRules),\n ruleRules(Id, ResRules, [AllRules, TopRule, LastDefRules, DefRules, DefPremises]),\n context_assert(support(Conclusion) :- argument([AllRules, TopRule, Conclusion, [Conclusion|Conclusions], [LastDefRules, DefRules, DefPremises]])).\n buildPremises([], _, [], [[], [], [], []]).\n buildPremises([H|T], Ids, Conclusions, Rules) :-\n build([H], Ids, HConclusions, HRules),\n buildPremises(T, Ids, TConclusions, TRules),\n utils::appendLists([HConclusions, TConclusions], Conclusions),\n mergeRules(HRules, TRules, Rules).\n premiseRules(Id, [[Id], none, [], [], [Id]]) :- \\+ parser::check_strict(Id), !.\n premiseRules(Id, [[Id], none, [], [], []]) :- parser::check_strict(Id).\n ruleRules(Id, [AllRules, _, DefRules, DefPremises],\n [[Id|AllRules], Id, [Id], [Id|DefRules], DefPremises]) :- \\+ parser::check_strict(Id), !.\n ruleRules(Id, [AllRules, LastDefRules, DefRules, DefPremises],\n [[Id|AllRules], Id, LastDefRules, DefRules, DefPremises]) :- parser::check_strict(Id).\n mergeRules([], [AllRules, LastDefRules, DefRules, DefPremises], [AllRules, LastDefRules, DefRules, DefPremises]) :- !.\n mergeRules([HAR, _, HLDR, HDR, HDP], [TAR, TLDR, TDR, TDP], [AR, LDR, DR, DP]) :-\n utils::appendLists([HAR, TAR], AR),\n utils::appendLists([HLDR, TLDR], LDR),\n utils::appendLists([HDR, TDR], DR),\n utils::appendLists([HDP, TDP], DP).\n ');
5069
5231
  }
5070
5232
  QueryMode_0.$metadata$ = {
5071
5233
  kind: Kind_OBJECT,
@@ -5080,7 +5242,7 @@
5080
5242
  }
5081
5243
  function RuleTranslator() {
5082
5244
  RuleTranslator_instance = this;
5083
- this.theoryCode = trimIndent("\n /*\n * Main directive. Find all the rules in the theory in the format (Name : Preconditions => Conclusion)\n * or (Name : Effects) and then if:\n * - It is a standard rule, translate it in the standard format (rule([Name, Preconditions, Conclusions]));\n * - It is a bp rule, translate it to (abstractBp([Effects]))\n * During the process, clean them from the unallowed symbols (-, o, p).\n */\n convertAllRules(ArgRules) :-\n defeasibleRules(DefeasibleRules),\n strictRules(StrictRules, RulesIds),\n ordinaryPremises(Premises),\n axiomPremises(Axioms, AxiomsIds),\n specialRules(SpecialRules),\n utils::appendLists([DefeasibleRules, StrictRules, Premises, Axioms, SpecialRules], L),\n convertAllRules(L, Rules),\n findall(sup(X, Y), sup(X, Y), Sup),\n utils::appendLists([Rules, AxiomsIds, RulesIds, Sup], ArgRules),\n utils::assert_all(ArgRules), !.\n defeasibleRules(DefeasibleRules) :-\n findall([RuleName, Preconditions, Effect], (RuleName : Preconditions => Effect), DefeasibleRulesOld),\n prologDefeasibleRules(DefeasibleRulesNew),\n utils::append_fast(DefeasibleRulesOld, DefeasibleRulesNew, DefeasibleRules).\n strictRules(CtrRules, Ids) :-\n findall([RuleName, Preconditions, Effect], (RuleName : Preconditions -> Effect), StrictRulesOld),\n prologStrictRules(StrictRulesNew),\n utils::append_fast(StrictRulesOld, StrictRulesNew, StrictRules),\n transpose(StrictRules, StrictRules, CtrRules),\n extract_id(CtrRules, Ids).\n ordinaryPremises(Premises) :-\n findall([RuleName, Effect], ((RuleName :=> Effect), atom(RuleName)), PremisesOld),\n prologPremises(PremisesNew),\n utils::append_fast(PremisesOld, PremisesNew, Premises).\n axiomPremises(Axioms, Ids) :-\n findall([RuleName, Effect], ((RuleName :-> Effect), atom(RuleName)), AxiomsOld),\n prologAxioms(AxiomsNew),\n utils::append_fast(AxiomsOld, AxiomsNew, Axioms),\n extract_id(Axioms, Ids).\n specialRules(SpecialRules) :-\n bpsNew(SpecialRules).\n transpose(_, CtrRules, CtrRules) :- \\+ autoTransposition, !.\n transpose([], CtrRules, CtrRules).\n transpose([H|T], TempCtrRules, CtrRules) :-\n transpose(T, TempCtrRules, CR),\n findall(TrH, transposition(H, TrH), Tran),\n mergeCtrRules(CR, Tran, CtrRules).\n mergeCtrRules(All, ToMerge, X) :-\n utils::append_fast(All, ToMerge, XT),\n deduplicate(XT, X).\n deduplicate([], []).\n deduplicate([[RN,A,B]|T], X) :- deduplicate(T, TT), (member([RN,_,_], TT) -> X = TT; X = [[RN,A,B]|TT]). \n transposition([Id, Prec, Effect], [Id, Prec, Effect]).\n transposition([Id, Prec, Effect], [NewId, NewPrec ,XNegated]) :-\n compound(Prec),\n tuple_to_list(Prec, LPrec),!,\n transposition_sequential(LPrec, LPrec, Effect, Id, [], NewPrec, XNegated, NewId).\n transposition([Id, Prec, Effect], [NewId, EffectNegated ,XNegated]) :-\n \\+ compound(Prec),\n Prec \\== [],\n prologEscape(Prec),\n negate(Prec, XNegated),\n negate(Effect, EffectNegated),\n atom_concat(Id, '_i', NewId).\n transposition_sequential(LPrec, [H|T], Effect, Id, Skipped, NewPrec, XNegated, NewId) :-\n transposition_sequential(LPrec, T, Effect, Id, [H|Skipped], NewPrec, XNegated, NewId).\n transposition_sequential(LPrec, [X|T], Effect, Id, Skipped, NewPrec, XNegated, NewId) :-\n prologEscape(X),\n utils::append_fast(Skipped, T, CleanedPrec),\n negate(X, XNegated),\n negate(Effect, EffectNegated),\n list_to_tuple([EffectNegated|CleanedPrec], NewPrec),\n newIdentifier(Skipped, Id, NewId).\n newIdentifier(List, OldId, NewId) :-\n modifier(List, Mod),\n atom_concat(OldId, Mod, NewId).\n modifier([], '_i').\n modifier([_|Tail], Index):-\n modifier(Tail, Index1),\n atom_concat(Index1, 'i', Index).\n negate(X, Arg) :-\n functor(X, '-', _) -> (\n arg(1, X, Arg));\n functor(X, 'p', _) -> (\n arg(1, X, PX),\n (functor(PX, '-', _) -> (\n arg(1, PX, PNX),\n Arg = o(PNX)\n );\n Arg = o(-(PX))));\n Arg = -(X).\n prologEscape(X) :- \\+ functor(X, 'prolog', _), \\+ functor(X, '~', _).\n /*\n * Standard rules (RuleName : Preconditions => Effects)\n * Special rules (RuleName : Effects)\n */\n convertAllRules([], []).\n convertAllRules([[H,P,E]|T], [R|Rules]) :- convertRule(H, P, E, R), convertAllRules(T, Rules).\n convertAllRules([[H,E]|T], [R|Rules]) :- convertRule(H, E, R), convertAllRules(T, Rules).\n /*\n * Convert the given rule to the standard format\n * Example:\n * r2: followedGuidelines(X), doctor(X) => -liable(X)\n * rule([r2,[[followedGuidelines(X_e4149)],[doctor(X_e4149)]],[neg,liable(X_e4149)]]).\n */\n convertRule(RuleName, Preconditions, Effects, rule(List)) :-\n tuple_to_list(Preconditions, Lprecond),\n tuple_to_list(Effects, Leffects),\n check_modifiers_in_list(preconditions, Lprecond, LprecondChecked),\n check_modifiers_in_list(effects, Leffects, LeffectsChecked),\n flatten_first_level(LeffectsChecked, LeffectsCheckedFlattened),\n List = [RuleName, LprecondChecked, LeffectsCheckedFlattened], !.\n /*\n * Convert the given special rule\n * Example:\n * bp(-liable(X)).\n * abastractBp([[neg, liable(X_e4149)]]).\n */\n convertRule(bps, Effects, abstractBp(Checked)) :-\n functor(Effects, 'bp', _),\n Effects =.. L,\n removehead(L, LC),\n check_modifiers_in_list(effects, LC, Checked), !.\n convertRule(Name, Effects, premise([Name, LeffectsCheckedFlattened])) :-\n tuple_to_list(Effects, Leffects),\n check_modifiers_in_list(effects, Leffects, LeffectsChecked),\n flatten_first_level(LeffectsChecked, LeffectsCheckedFlattened).\n /*\n * Find negations(-), obligations(o), permissions(p) on a list of preconditions/effects and\n * raplace them with the assigned literal (neg, obl, perm)\n */\n check_modifiers_in_list(MODE, [], []) :- !.\n check_modifiers_in_list(MODE, [H|T], L) :- H == [], L = [], !.\n check_modifiers_in_list(MODE, [H|T], R) :- H \\== [],\n check_modifiers_once(H, LH),\n check_modifiers_in_list(MODE, T, LT),\n utils::append_fast([LH], LT, L),\n R = L.\n check_modifiers_once(H, List) :- once(check_modifiers(H, List)).\n check_modifiers([], []).\n check_modifiers(H, List) :-\n functor(H, '-', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lobl),\n utils::append_fast([neg], Lobl, Lf),\n List = Lf);\n functor(H, 'o', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lobl),\n List = [obl|[Lobl]]);\n functor(H, 'p', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lper),\n List = [perm|[Lper]]);\n functor(H, '~', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lper),\n List = [unless|[Lper]]);\n functor(H, 'bp', _) -> (\n H =.. [_|Arg],\n check_modifiers_in_list(effects, Arg, Lper),\n List = [bp|[Lper]]);\n List = [H].\n /*\n * Convert the given tuple to list\n */\n tuple_to_list(A,[A]) :- nonvar(A), A \\= (_ , _), !.\n tuple_to_list((A,B),L) :-\n tuple_to_list(A, La),\n tuple_to_list(B, Lb),\n utils::append_fast(La, Lb,L).\n list_to_tuple([H], (H)) :- !.\n list_to_tuple([H|T], (H,TT)) :- list_to_tuple(T,TT).\n /*\n * Replace all the occurences of a given element with the given argument\n */\n replace(_, _, [],[]) :- !.\n replace(O, R, [O|T], [R|T2]) :- replace(O, R, T, T2), !.\n replace(O, R, [H|T], [H|T2]) :- H \\= O, replace(O, R, T, T2).\n flatten_first_level([X], X) :- !.\n flatten_first_level.\n removehead([_|Tail], Tail).\n in(A, A) :- nonvar(A), A \\= (_ , _), !.\n in(A, (A, _)) :- !.\n in(A, (_ , Cs)) :- in(A, Cs).\n check_admissibility(preconditions, H, LH) :-\n \\+ defeasible_admissible(LH),\n throw(['Premise ', H, ' is not a well formed member of the argumentation language.']).\n check_admissibility(effects, H, LH) :-\n \\+ admissible(LH),\n throw(['Conclusion ', H, ' is not a well formed member of the argumentation language.']).\n check_admissibility(_, _, _).\n defeasible_admissible([unless, Term]) :- admissible(Term).\n defeasible_admissible(Term) :- admissible(Term).\n admissible([neg, bp, Term]) :- admissible_terms_complete(Term).\n admissible([bp, Term]) :- admissible_terms_complete(Term).\n admissible([neg, Term]) :- admissible_term(Term).\n admissible([obl, [Term]]) :- admissible_term(Term).\n admissible([obl, [neg, Term]]) :- admissible_term(Term).\n admissible([neg, obl, [Term]]) :- admissible_term(Term).\n admissible([neg, obl, [neg, Term]]) :- admissible_term(Term).\n admissible([perm, [Term]]) :- admissible_term(Term).\n admissible([perm, [neg, Term]]) :- admissible_term(Term).\n admissible([Term]) :- admissible_term(Term).\n admissible_term(Term) :-\n atomic(Term),\n Term \\== neg,\n Term \\== obl,\n Term \\== perm,\n Term \\== unless,\n Term \\== bp.\n admissible_term(Term) :- var(Term).\n admissible_term(Term) :-\n compound(Term),\n \\+ functor(Term, 'o', _),\n \\+ functor(Term, 'p', _),\n \\+ functor(Term, '-', _),\n \\+ functor(Term, '~', _),\n \\+ functor(Term, 'bp', _),\n Term =.. [_|Args],\n admissible_terms(Args).\n admissible_terms([]).\n admissible_terms([H|T]) :-\n admissible_term(H),\n admissible_terms(T).\n admissible_terms_complete([]).\n admissible_terms_complete([H|T]) :-\n admissible(H),\n admissible_terms_complete(T).\n ");
5245
+ this.theoryCode = trimIndent("\n /*\n * Main directive. Find all the rules in the theory in the format (Name : Preconditions => Conclusion)\n * or (Name : Effects) and then if:\n * - It is a standard rule, translate it in the standard format (rule([Name, Preconditions, Conclusions]));\n * - It is a bp rule, translate it to (abstractBp([Effects]))\n * During the process, clean them from the unallowed symbols (-, o, p).\n */\n convertAllRules(ArgRules) :-\n defeasibleRules(DefeasibleRules),\n strictRules(StrictRules, RulesIds),\n ordinaryPremises(Premises),\n axiomPremises(Axioms, AxiomsIds),\n specialRules(SpecialRules),\n utils::appendLists([DefeasibleRules, StrictRules, Premises, Axioms], Rules),\n rule_to_clause(Rules, Clauses),\n findall(sup(X, Y), sup(X, Y), Sup),\n utils::appendLists([Clauses, AxiomsIds, RulesIds, Sup, SpecialRules], ArgRules),\n utils::assert_all(ArgRules), !.\n defeasibleRules(DefeasibleRules) :-\n findall([RuleName, Preconditions, Effect], (RuleName : Preconditions => Effect), DefeasibleRulesOld),\n prologDefeasibleRules(DefeasibleRulesNew),\n utils::append_fast(DefeasibleRulesOld, DefeasibleRulesNew, DefeasibleRules).\n strictRules(CtrRules, Ids) :-\n findall([RuleName, Preconditions, Effect], (RuleName : Preconditions -> Effect), StrictRulesOld),\n prologStrictRules(StrictRulesNew),\n utils::append_fast(StrictRulesOld, StrictRulesNew, StrictRules),\n transpose(StrictRules, StrictRules, CtrRules),\n extract_id(CtrRules, Ids).\n ordinaryPremises(Premises) :-\n findall([RuleName, Effect], ((RuleName :=> Effect), atom(RuleName)), PremisesOld),\n prologPremises(PremisesNew),\n utils::append_fast(PremisesOld, PremisesNew, Premises).\n axiomPremises(Axioms, Ids) :-\n findall([RuleName, Effect], ((RuleName :-> Effect), atom(RuleName)), AxiomsOld),\n prologAxioms(AxiomsNew),\n utils::append_fast(AxiomsOld, AxiomsNew, Axioms),\n extract_id(Axioms, Ids).\n specialRules(SpecialRules) :-\n bpsNew(SpecialRules).\n transpose(_, CtrRules, CtrRules) :- \\+ autoTransposition, !.\n transpose([], CtrRules, CtrRules).\n transpose([H|T], TempCtrRules, CtrRules) :-\n transpose(T, TempCtrRules, CR),\n findall(TrH, transposition(H, TrH), Tran),\n mergeCtrRules(CR, Tran, CtrRules).\n mergeCtrRules(All, ToMerge, X) :-\n utils::append_fast(All, ToMerge, XT),\n deduplicate(XT, X).\n deduplicate([], []).\n deduplicate([[RN,A,B]|T], X) :- deduplicate(T, TT), (member([RN,_,_], TT) -> X = TT; X = [[RN,A,B]|TT]). \n transposition([Id, Prec, Effect], [Id, Prec, Effect]).\n transposition([Id, Prec, Effect], [NewId, NewPrec ,XNegated]) :-\n compound(Prec),\n tuple_to_list(Prec, LPrec),!,\n transposition_sequential(LPrec, LPrec, Effect, Id, [], NewPrec, XNegated, NewId).\n transposition([Id, Prec, Effect], [NewId, EffectNegated ,XNegated]) :-\n \\+ compound(Prec),\n Prec \\== [],\n prologEscape(Prec),\n negate(Prec, XNegated),\n negate(Effect, EffectNegated),\n atom_concat(Id, '_i', NewId).\n transposition_sequential(LPrec, [H|T], Effect, Id, Skipped, NewPrec, XNegated, NewId) :-\n transposition_sequential(LPrec, T, Effect, Id, [H|Skipped], NewPrec, XNegated, NewId).\n transposition_sequential(LPrec, [X|T], Effect, Id, Skipped, NewPrec, XNegated, NewId) :-\n prologEscape(X),\n utils::append_fast(Skipped, T, CleanedPrec),\n negate(X, XNegated),\n negate(Effect, EffectNegated),\n list_to_tuple([EffectNegated|CleanedPrec], NewPrec),\n newIdentifier(Skipped, Id, NewId).\n newIdentifier(List, OldId, NewId) :-\n modifier(List, Mod),\n atom_concat(OldId, Mod, NewId).\n modifier([], '_i').\n modifier([_|Tail], Index):-\n modifier(Tail, Index1),\n atom_concat(Index1, 'i', Index).\n negate(X, Arg) :-\n functor(X, '-', _) -> (\n arg(1, X, Arg));\n functor(X, 'p', _) -> (\n arg(1, X, PX),\n (functor(PX, '-', _) -> (\n arg(1, PX, PNX),\n Arg = o(PNX)\n );\n Arg = o(-(PX))));\n Arg = -(X).\n prologEscape(X) :- \\+ functor(X, 'prolog', _), \\+ functor(X, '~', _).\n /*\n * Standard rules (RuleName : Preconditions => Effects)\n * Special rules (RuleName : Effects)\n */\n convertAllRules([], []).\n convertAllRules([[H,P,E]|T], [R|Rules]) :- convertRule(H, P, E, R), convertAllRules(T, Rules).\n convertAllRules([[H,E]|T], [R|Rules]) :- convertRule(H, E, R), convertAllRules(T, Rules).\n /*\n * Convert the given rule to the standard format\n * Example:\n * r2: followedGuidelines(X), doctor(X) => -liable(X)\n * rule([r2,[[followedGuidelines(X_e4149)],[doctor(X_e4149)]],[neg,liable(X_e4149)]]).\n */\n convertRule(RuleName, Preconditions, Effects, rule(List)) :-\n tuple_to_list(Preconditions, Lprecond),\n tuple_to_list(Effects, Leffects),\n check_modifiers_in_list(preconditions, Lprecond, LprecondChecked),\n check_modifiers_in_list(effects, Leffects, LeffectsChecked),\n flatten_first_level(LeffectsChecked, LeffectsCheckedFlattened),\n List = [RuleName, LprecondChecked, LeffectsCheckedFlattened], !.\n /*\n * Convert the given special rule\n * Example:\n * bp(-liable(X)).\n * abastractBp([[neg, liable(X_e4149)]]).\n */\n convertRule(bps, Effects, abstractBp(Checked)) :-\n functor(Effects, 'bp', _),\n Effects =.. L,\n removehead(L, LC),\n check_modifiers_in_list(effects, LC, Checked), !.\n convertRule(Name, Effects, premise([Name, LeffectsCheckedFlattened])) :-\n tuple_to_list(Effects, Leffects),\n check_modifiers_in_list(effects, Leffects, LeffectsChecked),\n flatten_first_level(LeffectsChecked, LeffectsCheckedFlattened).\n /*\n * Find negations(-), obligations(o), permissions(p) on a list of preconditions/effects and\n * raplace them with the assigned literal (neg, obl, perm)\n */\n check_modifiers_in_list(MODE, [], []) :- !.\n check_modifiers_in_list(MODE, [H|T], L) :- H == [], L = [], !.\n check_modifiers_in_list(MODE, [H|T], R) :- H \\== [],\n check_modifiers_once(H, LH),\n check_modifiers_in_list(MODE, T, LT),\n utils::append_fast([LH], LT, L),\n R = L.\n check_modifiers_once(H, List) :- once(check_modifiers(H, List)).\n check_modifiers([], []).\n check_modifiers(H, List) :-\n functor(H, '-', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lobl),\n utils::append_fast([neg], Lobl, Lf),\n List = Lf);\n functor(H, 'o', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lobl),\n List = [obl|[Lobl]]);\n functor(H, 'p', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lper),\n List = [perm|[Lper]]);\n functor(H, '~', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lper),\n List = [unless|[Lper]]);\n functor(H, 'bp', _) -> (\n H =.. [_|Arg],\n check_modifiers_in_list(effects, Arg, Lper),\n List = [bp|[Lper]]);\n List = [H].\n list_to_tuple([H], (H)) :- !.\n list_to_tuple([H|T], (H,TT)) :- list_to_tuple(T,TT).\n /*\n * Replace all the occurences of a given element with the given argument\n */\n replace(_, _, [],[]) :- !.\n replace(O, R, [O|T], [R|T2]) :- replace(O, R, T, T2), !.\n replace(O, R, [H|T], [H|T2]) :- H \\= O, replace(O, R, T, T2).\n flatten_first_level([X], X) :- !.\n flatten_first_level.\n removehead([_|Tail], Tail).\n in(A, A) :- nonvar(A), A \\= (_ , _), !.\n in(A, (A, _)) :- !.\n in(A, (_ , Cs)) :- in(A, Cs).\n check_admissibility(preconditions, H, LH) :-\n \\+ defeasible_admissible(LH),\n throw(['Premise ', H, ' is not a well formed member of the argumentation language.']).\n check_admissibility(effects, H, LH) :-\n \\+ admissible(LH),\n throw(['Conclusion ', H, ' is not a well formed member of the argumentation language.']).\n check_admissibility(_, _, _).\n defeasible_admissible([unless, Term]) :- admissible(Term).\n defeasible_admissible(Term) :- admissible(Term).\n admissible([neg, bp, Term]) :- admissible_terms_complete(Term).\n admissible([bp, Term]) :- admissible_terms_complete(Term).\n admissible([neg, Term]) :- admissible_term(Term).\n admissible([obl, [Term]]) :- admissible_term(Term).\n admissible([obl, [neg, Term]]) :- admissible_term(Term).\n admissible([neg, obl, [Term]]) :- admissible_term(Term).\n admissible([neg, obl, [neg, Term]]) :- admissible_term(Term).\n admissible([perm, [Term]]) :- admissible_term(Term).\n admissible([perm, [neg, Term]]) :- admissible_term(Term).\n admissible([Term]) :- admissible_term(Term).\n admissible_term(Term) :-\n atomic(Term),\n Term \\== neg,\n Term \\== obl,\n Term \\== perm,\n Term \\== unless,\n Term \\== bp.\n admissible_term(Term) :- var(Term).\n admissible_term(Term) :-\n compound(Term),\n \\+ functor(Term, 'o', _),\n \\+ functor(Term, 'p', _),\n \\+ functor(Term, '-', _),\n \\+ functor(Term, '~', _),\n \\+ functor(Term, 'bp', _),\n Term =.. [_|Args],\n admissible_terms(Args).\n admissible_terms([]).\n admissible_terms([H|T]) :-\n admissible_term(H),\n admissible_terms(T).\n admissible_terms_complete([]).\n admissible_terms_complete([H|T]) :-\n admissible(H),\n admissible_terms_complete(T).\n rule(Id, PP, [Conclusion]) :- context_check(clause(rl(Conclusion), [Id, Premises, Conclusion])), tuple_to_list(Premises, P), ff(P, PP).\n premise(Id, [Conclusion]) :- context_check(clause(rl(Conclusion), [Id, Conclusion])).\n check_strict(Id) :- context_check(strict(Id)).\n prolog([prolog(Term)], Term).\n contrary([~(Term)], Term).\n undercut(undercut(Rule), Rule).\n superiority(sup(Id1, Id2), Id1, Id2).\n /*\n * Convert the given tuple to list\n */\n tuple_to_list(A,[A]) :- nonvar(A), A \\= (_ , _), !.\n tuple_to_list((A,B),L) :-\n tuple_to_list(A, La),\n tuple_to_list(B, Lb),\n utils::append_fast(La, Lb,L).\n ff([[]], []) :- !.\n ff([[X]], [X]) :- !.\n ff(X, X).\n classic_rule(X, Y, Z) :- rule(X, Y, Z).\n classic_rule(X, Y) :- premise(X, Y).\n ");
5084
5246
  }
5085
5247
  RuleTranslator.$metadata$ = {
5086
5248
  kind: Kind_OBJECT,
@@ -5315,6 +5477,7 @@
5315
5477
  package$labelling.BpPartialLabellerBase = BpPartialLabellerBase;
5316
5478
  package$labelling.CompleteLabellerBase = CompleteLabellerBase;
5317
5479
  package$labelling.GroundedLabellerBase = GroundedLabellerBase;
5480
+ package$labelling.GroundedLabellerOptimizedBase = GroundedLabellerOptimizedBase;
5318
5481
  Object.defineProperty(package$labelling, 'PassThroughStatementLabeller', {
5319
5482
  get: PassThroughStatementLabeller_getInstance
5320
5483
  });
@@ -5351,6 +5514,9 @@
5351
5514
  Object.defineProperty(package$language, 'ExtractStrictIds', {
5352
5515
  get: ExtractStrictIds_getInstance
5353
5516
  });
5517
+ Object.defineProperty(package$language, 'RuleToClause', {
5518
+ get: RuleToClause_getInstance
5519
+ });
5354
5520
  var package$structured = package$libs.structured || (package$libs.structured = {});
5355
5521
  package$structured.StructuredModeBase = StructuredModeBase;
5356
5522
  Object.defineProperty(package$structured, 'QueryMode', {
@@ -5368,6 +5534,7 @@
5368
5534
  Object.defineProperty(package$utils, 'OrderingComparator', {
5369
5535
  get: OrderingComparator_getInstance
5370
5536
  });
5537
+ $$importsForInline$$['@tuprolog/2p-solve'] = $module$_2p_solve;
5371
5538
  package$utils.UtilsBase = UtilsBase;
5372
5539
  Object.defineProperty(package$utils, 'AppendOptimized', {
5373
5540
  get: AppendOptimized_getInstance
@@ -5375,6 +5542,9 @@
5375
5542
  Object.defineProperty(package$utils, 'AssertAll', {
5376
5543
  get: AssertAll_getInstance
5377
5544
  });
5545
+ Object.defineProperty(package$utils, 'ArgumentHash', {
5546
+ get: ArgumentHash_getInstance
5547
+ });
5378
5548
  var package$meta = package$core.meta || (package$core.meta = {});
5379
5549
  Object.defineProperty(package$meta, 'MetaInterpreterLib', {
5380
5550
  get: MetaInterpreterLib_getInstance
@@ -5439,6 +5609,9 @@
5439
5609
  Object.defineProperty(package$labelling, 'GroundedLabeller', {
5440
5610
  get: GroundedLabeller_getInstance
5441
5611
  });
5612
+ Object.defineProperty(package$labelling, 'GroundedLabellerOptimized', {
5613
+ get: GroundedLabellerOptimized_getInstance
5614
+ });
5442
5615
  Object.defineProperty(package$labelling, 'StatementLabeller', {
5443
5616
  get: StatementLabeller_getInstance
5444
5617
  });
@@ -5485,6 +5658,9 @@
5485
5658
  Object.defineProperty(package$sources, 'Grounded', {
5486
5659
  get: Grounded_getInstance
5487
5660
  });
5661
+ Object.defineProperty(package$sources, 'GroundedOptimized', {
5662
+ get: GroundedOptimized_getInstance
5663
+ });
5488
5664
  Object.defineProperty(package$sources, 'Preferences', {
5489
5665
  get: Preferences_getInstance
5490
5666
  });
@@ -5693,8 +5869,8 @@
5693
5869
  PrologWithArgumentationImpl.prototype.anyMguWith = PrologWithArgumentation.prototype.anyMguWith;
5694
5870
  PrologWithArgumentationImpl.prototype.anyUnifyWith = PrologWithArgumentation.prototype.anyUnifyWith;
5695
5871
  PrologWithArgumentationImpl.prototype.list = PrologWithArgumentation.prototype.list;
5696
- PrologWithArgumentationImpl.prototype.listFromSequence = PrologWithArgumentation.prototype.listFromSequence;
5697
5872
  PrologWithArgumentationImpl.prototype.listFrom = PrologWithArgumentation.prototype.listFrom;
5873
+ PrologWithArgumentationImpl.prototype.listFromSequence = PrologWithArgumentation.prototype.listFromSequence;
5698
5874
  PrologWithArgumentationImpl.prototype.listFromIterable = PrologWithArgumentation.prototype.listFromIterable;
5699
5875
  PrologWithArgumentationImpl.prototype.matchAny = PrologWithArgumentation.prototype.matchAny;
5700
5876
  PrologWithArgumentationImpl.prototype.mguWithOccurCheck = PrologWithArgumentation.prototype.mguWithOccurCheck;
@@ -5755,6 +5931,8 @@
5755
5931
  CompleteLabellerBase.prototype.content = ArgLibrary.prototype.content;
5756
5932
  GroundedLabellerBase.prototype.flags = ArgLibrary.prototype.flags;
5757
5933
  GroundedLabellerBase.prototype.content = ArgLibrary.prototype.content;
5934
+ GroundedLabellerOptimizedBase.prototype.flags = ArgLibrary.prototype.flags;
5935
+ GroundedLabellerOptimizedBase.prototype.content = ArgLibrary.prototype.content;
5758
5936
  PassThroughStatementLabeller.prototype.flags = ArgLibrary.prototype.flags;
5759
5937
  PassThroughStatementLabeller.prototype.content = ArgLibrary.prototype.content;
5760
5938
  StatementLabellerBase.prototype.flags = ArgLibrary.prototype.flags;