eyeprolog 0.5.12 → 0.5.14

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.
Files changed (68) hide show
  1. package/README.md +5 -3
  2. package/examples/age.pl +1 -1
  3. package/examples/auroracare.pl +26 -0
  4. package/examples/blocks-world-planning.pl +3 -3
  5. package/examples/bmi.pl +20 -1
  6. package/examples/cdcl-sat-solver.pl +6 -6
  7. package/examples/combinatorics-findall-sort.pl +4 -4
  8. package/examples/composition-of-injective-functions-is-injective.pl +4 -1
  9. package/examples/d3-group.pl +3 -3
  10. package/examples/deep-taxonomy-10.pl +2 -0
  11. package/examples/deep-taxonomy-100.pl +2 -0
  12. package/examples/deep-taxonomy-1000.pl +2 -0
  13. package/examples/deep-taxonomy-10000.pl +2 -0
  14. package/examples/dijkstra-findall-sort.pl +3 -3
  15. package/examples/enigma1225.pl +1 -2
  16. package/examples/eulerian-path.pl +4 -4
  17. package/examples/exoplanet-validation-worlds.pl +3 -0
  18. package/examples/family-cousins.pl +2 -0
  19. package/examples/fastpow.pl +6 -6
  20. package/examples/flandor.pl +14 -0
  21. package/examples/four-color-map.pl +2 -2
  22. package/examples/gd-step-certified.pl +3 -0
  23. package/examples/group-inverse-uniqueness.pl +9 -9
  24. package/examples/illegitimate-reasoning.pl +6 -0
  25. package/examples/input/odrl-dpv-fpv-trust-flow-rules.pl +3 -9
  26. package/examples/input/odrl-dpv-healthcare-risk-ranked-rules.pl +1 -1
  27. package/examples/input/odrl-dpv-risk-ranked-rules.pl +1 -1
  28. package/examples/input/rdf12-annotated-claims-rules.pl +1 -1
  29. package/examples/list-collection.pl +6 -6
  30. package/examples/lldm.pl +2 -0
  31. package/examples/odrl-dpv-fpv-trust-flow.pl +3 -9
  32. package/examples/odrl-dpv-healthcare-risk-ranked.pl +1 -1
  33. package/examples/odrl-dpv-risk-ranked.pl +1 -1
  34. package/examples/output/bmi.pl +9 -0
  35. package/examples/output/list-collection.pl +5 -5
  36. package/examples/pointer-analysis.pl +3 -0
  37. package/examples/proof/age.pl +1 -1
  38. package/examples/proof/composition-of-injective-functions-is-injective.pl +80 -97
  39. package/examples/proof/d3-group.pl +4 -4
  40. package/examples/proof/group-inverse-uniqueness.pl +4 -4
  41. package/examples/proof/iso-dynamic-database.pl +1 -1
  42. package/examples/proof/list-collection.pl +63 -19
  43. package/examples/proof/spacecraft-battery-diagnosis.pl +8 -8
  44. package/examples/quine-mccluskey.pl +7 -7
  45. package/examples/rdf12-annotated-claims.pl +1 -1
  46. package/examples/relational-cube-lookup.pl +2002 -2000
  47. package/examples/riemann-hypothesis.pl +5 -0
  48. package/examples/spacecraft-battery-diagnosis.pl +8 -8
  49. package/examples/sudoku.pl +1 -1
  50. package/examples/vulnerability-impact.pl +4 -0
  51. package/package.json +1 -1
  52. package/playground.html +27 -7
  53. package/src/cli.js +1 -1
  54. package/src/explain.js +1 -1
  55. package/src/{eyeprolog-library.js → eyeprolog-autoload.js} +23 -8
  56. package/src/eyeprolog-common-library.pl +44 -0
  57. package/src/eyeprolog-library.pl +49 -76
  58. package/src/index.js +2 -2
  59. package/src/playground-worker.js +2 -2
  60. package/src/solver.js +1 -1
  61. package/test/conformance/cases/lists/031_lists_aggregation_ordering.pl +1 -2
  62. package/test/conformance/cases/lists/045_sort_deduplicates_atoms.pl +2 -3
  63. package/test/conformance/cases/lists/087_sort_reverse_length.pl +2 -2
  64. package/test/conformance/cases/lists/extra_sort_iri_atoms.pl +1 -1
  65. package/test/conformance/cases/lists/sort_structured_terms.pl +1 -1
  66. package/test/run-playground.mjs +5 -1
  67. package/test/run-regression.mjs +6 -3
  68. package/the-art-of-eyeprolog.md +22 -17
package/README.md CHANGED
@@ -32,9 +32,11 @@ Programs may declare their default queries with `%% goal:` comments.
32
32
  ## Portable library
33
33
 
34
34
  EyeProlog adds 50 public library predicates to its 115-predicate ISO profile.
35
- **All 50 are ordinary Prolog clauses** in `src/eyeprolog-library.pl` and are
36
- autoloaded in Node and the browser. None requires host support. Portable text
37
- predicates use ISO atoms or character lists; the
35
+ **All 50 are ordinary Prolog clauses** across `src/eyeprolog-library.pl` and
36
+ `src/eyeprolog-common-library.pl`; both are autoloaded in Node and the
37
+ browser. None requires host support. Other Prolog systems should load only
38
+ `eyeprolog-library.pl`, which avoids redefining their common list predicates.
39
+ Portable text predicates use ISO atoms or character lists; the
38
40
  RDF tools emit lexical values as ISO atoms as well.
39
41
 
40
42
  ## RDF 1.2
package/examples/age.pl CHANGED
@@ -27,4 +27,4 @@ ageAbove(S, A) :-
27
27
 
28
28
  % Test mirroring the Eyeling example.
29
29
  holds_result(test, true) :-
30
- ageAbove(S, 'P80Y').
30
+ ageAbove(_, 'P80Y').
@@ -45,6 +45,32 @@
45
45
  %% goal: checkC10Text(X0, X1)
46
46
 
47
47
 
48
+ :- discontiguous(policyUid/2).
49
+ :- discontiguous(purposeAllowed/2).
50
+ :- discontiguous(requireEnvironment/2).
51
+ :- discontiguous(allowAnyCategory/2).
52
+ :- discontiguous(duty/2).
53
+ :- discontiguous(scenario/1).
54
+ :- discontiguous(outputKey/2).
55
+ :- discontiguous(scenario_label/2).
56
+ :- discontiguous(scenario_description/2).
57
+ :- discontiguous(requester/2).
58
+ :- discontiguous(requesterRole/2).
59
+ :- discontiguous(subject/2).
60
+ :- discontiguous(purpose/2).
61
+ :- discontiguous(environment/2).
62
+ :- discontiguous(category/2).
63
+ :- discontiguous(checkC1/2).
64
+ :- discontiguous(checkC2/2).
65
+ :- discontiguous(checkC3/2).
66
+ :- discontiguous(checkC4/2).
67
+ :- discontiguous(checkC5/2).
68
+ :- discontiguous(checkC6/2).
69
+ :- discontiguous(checkC7/2).
70
+ :- discontiguous(checkC8/2).
71
+ :- discontiguous(checkC9/2).
72
+ :- discontiguous(checkC10Text/2).
73
+
48
74
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
49
75
  caseName(case, "auroracare").
50
76
  question(case, "For each AuroraCare scenario, should the PDP permit or deny the requested use of health data, and why?").
@@ -48,7 +48,7 @@ move(State, move(Block, From, To), Newstate) :-
48
48
  (Block \= To),
49
49
  (From \= To),
50
50
  select(on(Block, From), State, Rest),
51
- sort([on(Block, To)|Rest], Newstate).
51
+ sort_unique([on(Block, To)|Rest], Newstate).
52
52
 
53
53
  plan(State, Goal, 0, _visited, [], State) :-
54
54
  (State = Goal).
@@ -63,8 +63,8 @@ plan(State, Goal, Depth, Visited, [Move|Moves], Final) :-
63
63
  five_move_plan(Moves, Final) :-
64
64
  initial(Start),
65
65
  goal(Goal),
66
- sort(Start, Sortedstart),
67
- sort(Goal, Sortedgoal),
66
+ sort_unique(Start, Sortedstart),
67
+ sort_unique(Goal, Sortedgoal),
68
68
  plan(Sortedstart, Sortedgoal, 5, [Sortedstart], Moves, Final).
69
69
 
70
70
  status(blocks_world, planned) :-
package/examples/bmi.pl CHANGED
@@ -71,6 +71,15 @@
71
71
  %% goal: checkPassed(X0, X1)
72
72
 
73
73
 
74
+ :- discontiguous(weightKg/2).
75
+ :- discontiguous(heightM/2).
76
+ :- discontiguous(units/2).
77
+ :- discontiguous(bmi/2).
78
+ :- discontiguous(category/2).
79
+ :- discontiguous(healthyMinKg/2).
80
+ :- discontiguous(healthyMaxKg/2).
81
+ :- discontiguous(heightCm/2).
82
+
74
83
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
75
84
  unitSystem(input, metric).
76
85
  weight(input, 72.0).
@@ -260,4 +269,14 @@ heightCm(report, Height) :-
260
269
  heightCm(answer, Height).
261
270
 
262
271
  checkPassed(report, Check) :-
263
- statement(check, Check, _message).
272
+ statement(check, Check, _Message).
273
+
274
+ statement(check, c1, Message) :- c1(check, Message).
275
+ statement(check, c2, Message) :- c2(check, Message).
276
+ statement(check, c3, Message) :- c3(check, Message).
277
+ statement(check, c4, Message) :- c4(check, Message).
278
+ statement(check, c5, Message) :- c5(check, Message).
279
+ statement(check, c6, Message) :- c6(check, Message).
280
+ statement(check, c7, Message) :- c7(check, Message).
281
+ statement(check, c8, Message) :- c8(check, Message).
282
+ statement(check, c9, Message) :- c9(check, Message).
@@ -17,9 +17,9 @@
17
17
  %% goal: cdclAnswer(X0, X1)
18
18
 
19
19
 
20
- clause(c1, [neg(a), pos(c)]).
21
- clause(c2, [neg(c)]).
22
- clause(c3, [pos(a), pos(b)]).
20
+ sat_clause(c1, [neg(a), pos(c)]).
21
+ sat_clause(c2, [neg(c)]).
22
+ sat_clause(c3, [pos(a), pos(b)]).
23
23
 
24
24
  % Initial trail before conflict analysis.
25
25
  initial_value(a, true, decision(level1)).
@@ -38,7 +38,7 @@ call_value(final, Var, Value, Reason) :- final_value(Var, Value, Reason).
38
38
 
39
39
  % A clause is conflicting when all of its literals are false under a trail.
40
40
  conflict(Trail, Clause) :-
41
- clause(Clause, Literals),
41
+ sat_clause(Clause, Literals),
42
42
  \+ nonfalse_literal(Trail, Literals).
43
43
  nonfalse_literal(Trail, Literals) :-
44
44
  member(Literal, Literals),
@@ -56,13 +56,13 @@ final_value(c, false, unit(c2)).
56
56
  final_value(b, true, unit(c3)).
57
57
 
58
58
  model_satisfies_clause(Trail, Clause) :-
59
- clause(Clause, Literals),
59
+ sat_clause(Clause, Literals),
60
60
  member(Literal, Literals),
61
61
  lit_true(Literal, Trail).
62
62
 
63
63
  final_model_ok(ok) :- \+ unsatisfied_final_clause.
64
64
  unsatisfied_final_clause :-
65
- clause(Name, _),
65
+ sat_clause(Name, _),
66
66
  \+ model_satisfies_clause(final, Name).
67
67
 
68
68
  cdclAnswer(conflict_clause, Clause) :- conflict(initial, Clause).
@@ -1,7 +1,7 @@
1
- % Eyelet-inspired combinations example using findall/3 and sort/2.
1
+ % Eyelet-inspired combinations example using findall/3 and sort_unique/2.
2
2
  %
3
3
  % combination/3 generates the same subset in several selection orders. findall/3
4
- % collects those candidates, and sort/2 canonicalizes the list so each unordered
4
+ % collects those candidates, and sort_unique/2 canonicalizes the list so each unordered
5
5
  % 3-combination of five items is reported once.
6
6
  %% goal: combinations(X0, X1)
7
7
 
@@ -24,12 +24,12 @@ combination(I, Items, Combination) :-
24
24
  select(Item, Items, Remaining),
25
25
  (J is I - 1),
26
26
  combination(J, Remaining, Partial),
27
- sort([Item | Partial], Combination).
27
+ sort_unique([Item | Partial], Combination).
28
28
 
29
29
  % findall collects all generation orders; sort canonicalizes and deduplicates.
30
30
  unique_combinations(K, Items, Unique) :-
31
31
  findall(C, combination(K, Items, C), All),
32
- sort(All, Unique).
32
+ sort_unique(All, Unique).
33
33
 
34
34
  combinations(combinations_5_choose_3, Unique) :-
35
35
  unique_combinations(3, [1, 2, 3, 4, 5], Unique).
@@ -8,6 +8,9 @@
8
8
  %% goal: sameInputByCompositeInjectivity(X0, X1, X2)
9
9
 
10
10
 
11
+ :- discontiguous(app/3).
12
+ :- discontiguous(sameTerm/2).
13
+
11
14
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
12
15
  inX(a).
13
16
  inX(b).
@@ -19,7 +22,7 @@ inZ(e).
19
22
  sameTerm(X, X) :- inX(X).
20
23
  sameTerm(X, X) :- inY(X).
21
24
  sameTerm(X, X) :- inZ(X).
22
- sameTerm(Y, X) :- sameTerm(X, Y).
25
+ sameTerm(Y, X) :- Y @< X, sameTerm(X, Y).
23
26
 
24
27
  app(f, a, c).
25
28
  app(f, b, d).
@@ -1,4 +1,4 @@
1
- % Eyelet-inspired D3 group example using findall/3 and sort/2.
1
+ % Eyelet-inspired D3 group example using findall/3 and sort_unique/2.
2
2
  % The six facts are the symmetries of an equilateral triangle, with compose/3 as
3
3
  % the Cayley table and inverse/2 as the inverse relation. Candidate subsets are
4
4
  % generated as subsequences, then filtered for subgroup closure.
@@ -72,7 +72,7 @@ subsequence([_head | Tail], Rest) :-
72
72
 
73
73
  all_symmetries(Symmetries) :-
74
74
  findall(X, symmetry(X), Raw),
75
- sort(Raw, Symmetries).
75
+ sort_unique(Raw, Symmetries).
76
76
 
77
77
  % A valid subgroup is closed under both composition and inverse.
78
78
  closed_under_composition(Group) :-
@@ -90,7 +90,7 @@ valid_group(Group) :-
90
90
 
91
91
  all_subgroups(Groups) :-
92
92
  findall(G, valid_group(G), Raw),
93
- sort(Raw, Groups).
93
+ sort_unique(Raw, Groups).
94
94
 
95
95
  subgroups(d3_group, Groups) :-
96
96
  all_subgroups(Groups).
@@ -19,6 +19,8 @@
19
19
  %% goal: arc(X0, X1)
20
20
 
21
21
 
22
+ :- discontiguous(a/2).
23
+
22
24
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
23
25
  % fact
24
26
 
@@ -19,6 +19,8 @@
19
19
  %% goal: arc(X0, X1)
20
20
 
21
21
 
22
+ :- discontiguous(a/2).
23
+
22
24
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
23
25
  % fact
24
26
 
@@ -19,6 +19,8 @@
19
19
  %% goal: arc(X0, X1)
20
20
 
21
21
 
22
+ :- discontiguous(a/2).
23
+
22
24
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
23
25
  % fact
24
26
 
@@ -19,6 +19,8 @@
19
19
  %% goal: arc(X0, X1)
20
20
 
21
21
 
22
+ :- discontiguous(a/2).
23
+
22
24
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
23
25
  % fact
24
26
 
@@ -1,7 +1,7 @@
1
- % Eyelet-inspired Dijkstra example using findall/3 and sort/2.
1
+ % Eyelet-inspired Dijkstra example using findall/3 and sort_unique/2.
2
2
  % The priority queue is represented as sorted list entries [Cost, Node | Path].
3
3
  % Each expansion collects unvisited neighbors with findall/3, appends them to
4
- % the frontier, and uses sort/2 so the cheapest frontier entry is processed next.
4
+ % the frontier, and uses sort_unique/2 so the cheapest frontier entry is processed next.
5
5
 
6
6
  %% goal: shortestPath(X0, X1)
7
7
 
@@ -34,7 +34,7 @@ dijkstra_queue([[Cost, Node | Path] | Queue], Goal, Visited, Resultpath, Resultc
34
34
  (edge(Node, Neighbor, Weight), \+ member(Neighbor, Visited), (Newcost is Cost + Weight)),
35
35
  Neighbors),
36
36
  append(Queue, Neighbors, Newqueue),
37
- sort(Newqueue, Sortedqueue),
37
+ sort_unique(Newqueue, Sortedqueue),
38
38
  dijkstra_queue(Sortedqueue, Goal, [Node | Visited], Resultpath, Resultcost).
39
39
 
40
40
  shortestPath(dijkstra_findall_sort, Path) :-
@@ -89,7 +89,7 @@ eval_matrix(Matrix, FreqSorted) :-
89
89
  setof(E, member(E, Entries), Set),
90
90
  maplist(count_var(Entries), Set, Multiplicities),
91
91
  zip(Multiplicities, Set, Frequencies),
92
- sort(Frequencies, FreqSorted),
92
+ sort_unique(Frequencies, FreqSorted),
93
93
  maplist(snd, FreqSorted, VarsSorted),
94
94
  length(VarsSorted, NVars),
95
95
  from_to(1, NVars, VarsSorted).
@@ -237,4 +237,3 @@ lists_reform([[A|B]|C], [A|D], [B|E]) :-
237
237
 
238
238
  % query
239
239
  %% goal: enigma1225(8, _)
240
-
@@ -1,4 +1,4 @@
1
- % Eyelet-inspired Eulerian path example using findall/3 and sort/2.
1
+ % Eyelet-inspired Eulerian path example using findall/3 and sort_unique/2.
2
2
  %
3
3
  % The graph is undirected; edges have identifiers so the trail consumes each
4
4
  % physical edge exactly once even when vertices are revisited. The remaining
@@ -49,15 +49,15 @@ odd_degree(V) :-
49
49
 
50
50
  odd_vertices(Odds) :-
51
51
  findall(V, odd_degree(V), Raw),
52
- sort(Raw, Odds).
52
+ sort_unique(Raw, Odds).
53
53
 
54
54
  all_edges(Edges) :-
55
55
  findall(E, edge(E, _a, _b), Raw),
56
- sort(Raw, Edges).
56
+ sort_unique(Raw, Edges).
57
57
 
58
58
  vertices(Vertices) :-
59
59
  findall(V, vertex(V), Raw),
60
- sort(Raw, Vertices).
60
+ sort_unique(Raw, Vertices).
61
61
 
62
62
  eulerian_start(Start) :-
63
63
  odd_vertices([Start, _end]).
@@ -18,6 +18,9 @@
18
18
  %% goal: reason(X0, X1)
19
19
 
20
20
 
21
+ :- discontiguous(confirms_in_world/2).
22
+ :- discontiguous(rejects_in_world/2).
23
+
21
24
  % candidate/4 stores occurrence rate, sensitivity, and specificity. world/2
22
25
  % names the alternative validation policies applied to the same signals.
23
26
  candidate(rare_wide_orbit, 0.001, 0.99, 0.99).
@@ -8,6 +8,8 @@
8
8
  %% goal: cousin(X0, X1)
9
9
 
10
10
 
11
+ :- discontiguous(branch/2).
12
+
11
13
  % The family tree is scoped inside family_graph/2. family_statement/3 projects
12
14
  % only the parent and seedBranch facts that the cousin rules need.
13
15
 
@@ -20,20 +20,20 @@
20
20
 
21
21
  % Base case and parity split for exponentiation by squaring. Even exponents
22
22
  % square the half-power; odd exponents peel off one base factor.
23
- (1 is _base ** 0).
23
+ fast_power(_Base, 0, 1).
24
24
  % Recursive even/odd clauses reduce the exponent quickly rather than counting
25
25
  % down one multiplication at a time.
26
- (Value is Base ** Exp) :-
26
+ fast_power(Base, Exp, Value) :-
27
27
  (Exp > 0),
28
28
  (0 is Exp mod 2),
29
29
  (Half is Exp // 2),
30
- (Halfvalue is Base ** Half),
30
+ fast_power(Base, Half, Halfvalue),
31
31
  (Value is Halfvalue * Halfvalue).
32
- (Value is Base ** Exp) :-
32
+ fast_power(Base, Exp, Value) :-
33
33
  (Exp > 0),
34
34
  (1 is Exp mod 2),
35
35
  (Evenexp is Exp - 1),
36
- (Evenvalue is Base ** Evenexp),
36
+ fast_power(Base, Evenexp, Evenvalue),
37
37
  (Value is Base * Evenvalue).
38
38
 
39
39
  % pow_mod/4 applies the modulus at each multiplication to keep values small.
@@ -58,7 +58,7 @@ pow_mod(Base, Exp, Mod, Value) :-
58
58
  tower(2, 4, 65536).
59
59
  tower_mod(2, 5, 1000000, 156736).
60
60
 
61
- pow([2, 10], Value) :- (Value is 2 ** 10).
61
+ pow([2, 10], Value) :- fast_power(2, 10, Power), (Value is Power + 0.0).
62
62
  powSlow([2, 10], Value) :- (Value is 2 ** 10).
63
63
  powMod1e6([2, 10000], Value) :- pow_mod(2, 10000, 1000000, Value).
64
64
  powMod1e6([3, 10000], Value) :- pow_mod(3, 10000, 1000000, Value).
@@ -81,6 +81,20 @@
81
81
  %% goal: lowestCostEligiblePackageChosen(X0, X1)
82
82
 
83
83
 
84
+ :- discontiguous(industrialCluster/1).
85
+ :- discontiguous(clusterName/2).
86
+ :- discontiguous(exportOrdersIndex/2).
87
+ :- discontiguous(energyIntensity/2).
88
+ :- discontiguous(policyPackage/1).
89
+ :- discontiguous(packageId/2).
90
+ :- discontiguous(packageName/2).
91
+ :- discontiguous(costMEUR/2).
92
+ :- discontiguous(worker_coverage/2).
93
+ :- discontiguous(grid_relief_mw/2).
94
+ :- discontiguous(coversExportWeakness/2).
95
+ :- discontiguous(coversSkillsStrain/2).
96
+ :- discontiguous(coversGridStress/2).
97
+
84
98
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
85
99
  % Case metadata describes the request, audit window, and expected file writes.
86
100
  case_name(case, "flandor").
@@ -102,13 +102,13 @@ border_count(36).
102
102
 
103
103
  all_countries_coloured(map_eu) :-
104
104
  findall(Country, valid_assignment(Country), Countries),
105
- sort(Countries, Uniquecountries),
105
+ sort_unique(Countries, Uniquecountries),
106
106
  length(Uniquecountries, Count),
107
107
  country_count(Count).
108
108
 
109
109
  all_borders_checked(map_eu) :-
110
110
  findall([A, B], border_colours_differ(A, B), Borders),
111
- sort(Borders, Uniqueborders),
111
+ sort_unique(Borders, Uniqueborders),
112
112
  length(Uniqueborders, Count),
113
113
  border_count(Count).
114
114
 
@@ -24,6 +24,9 @@
24
24
  %% goal: widthContractsAt(X0, X1)
25
25
 
26
26
 
27
+ :- discontiguous(x_bounds/3).
28
+ :- discontiguous(width/2).
29
+
27
30
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
28
31
 
29
32
  % Adapted from Eyeling's gd-step-certified.n3.
@@ -14,21 +14,21 @@ element(x).
14
14
  element(i).
15
15
  element(j).
16
16
 
17
- % leftInverse/2 and rightInverse/2 are proved from op/3. sameInverse/3
17
+ % leftInverse/2 and rightInverse/2 are proved from group_op/3. sameInverse/3
18
18
  % then derives uniqueness by combining both inverse directions with sameTerm/2.
19
- op(e, X, X) :- element(X).
20
- op(X, e, X) :- element(X).
21
- op(i, x, e).
22
- op(x, j, e).
23
- op(j, x, e).
24
- op(x, i, e).
19
+ group_op(e, X, X) :- element(X).
20
+ group_op(X, e, X) :- element(X).
21
+ group_op(i, x, e).
22
+ group_op(x, j, e).
23
+ group_op(j, x, e).
24
+ group_op(x, i, e).
25
25
 
26
26
  sameTerm(X, X) :- element(X).
27
27
  sameTerm(i, j).
28
28
  sameTerm(j, i).
29
29
 
30
- leftInverse(A, B) :- op(B, A, e).
31
- rightInverse(A, B) :- op(A, B, e).
30
+ leftInverse(A, B) :- group_op(B, A, e).
31
+ rightInverse(A, B) :- group_op(A, B, e).
32
32
 
33
33
  sameInverse(A, B, C) :-
34
34
  leftInverse(A, B),
@@ -23,6 +23,12 @@
23
23
  %% goal: omittedAlternative(X0, X1)
24
24
 
25
25
 
26
+ :- discontiguous(argument/1).
27
+ :- discontiguous(implication/3).
28
+ :- discontiguous(observed/2).
29
+ :- discontiguous(concludes/2).
30
+ :- discontiguous(reason/2).
31
+
26
32
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
27
33
  argument(arg_affirming_consequent).
28
34
  implication(arg_affirming_consequent, rain, street_wet).
@@ -65,16 +65,10 @@ rdf_number(Subject, Predicate, Number) :-
65
65
  iri_term(Subject, SubjectIri),
66
66
  iri_term(Predicate, PredicateIri),
67
67
  rdf(iri(SubjectIri), iri(PredicateIri), literal(Text, datatype(_Datatype)), default_graph),
68
- number_string(Number, Text).
68
+ atom_chars(Text, Chars),
69
+ number_chars(Number, Chars).
69
70
 
70
71
  iri_term(ex(Name), Iri) :- namespace_iri('https://example.org/', Name, Iri).
71
72
  iri_term(odrl(Name), Iri) :- namespace_iri('http://www.w3.org/ns/odrl/2/', Name, Iri).
72
73
 
73
- namespace_iri(Prefix, Name, Iri) :-
74
- atom(Name),
75
- !,
76
- atom_string(Name, Local),
77
- string_concat(Prefix, Local, Iri).
78
- namespace_iri(Prefix, Name, Iri) :-
79
- string_concat(Prefix, Local, Iri),
80
- atom_string(Name, Local).
74
+ namespace_iri(Prefix, Name, Iri) :- atom_concat(Prefix, Name, Iri).
@@ -15,7 +15,7 @@ healthcare_risk_report(Ranked) :-
15
15
  ),
16
16
  Unsorted
17
17
  ),
18
- sort(Unsorted, Sorted),
18
+ sort_unique(Unsorted, Sorted),
19
19
  ranked_values(Sorted, 1, Ranked).
20
20
 
21
21
  risk_report(Risk, Score, Level, Clause, Mitigation) :-
@@ -15,7 +15,7 @@ consumer_risk_report(Ranked) :-
15
15
  ),
16
16
  Unsorted
17
17
  ),
18
- sort(Unsorted, Sorted),
18
+ sort_unique(Unsorted, Sorted),
19
19
  ranked_values(Sorted, 1, Ranked).
20
20
 
21
21
  risk_report(Risk, Score, Level, Clause, Mitigation) :-
@@ -25,7 +25,7 @@ ranked_claims(Claims) :-
25
25
  ),
26
26
  Unsorted
27
27
  ),
28
- sort(Unsorted, Sorted),
28
+ sort_unique(Unsorted, Sorted),
29
29
  pair_values(Sorted, Claims).
30
30
 
31
31
  annotated_status_claim(Status, Source, Score) :-
@@ -2,11 +2,11 @@
2
2
  % Demonstrates list literals, member/2, length/2, append/3, and [Head|Tail].
3
3
  % Each queried relation demonstrates one list operation.
4
4
  % Output declarations: host-supplied goals select the relations written to this example's golden output.
5
- %% goal: length(X0, X1)
5
+ %% goal: collectionLength(X0, X1)
6
6
 
7
- %% goal: member(X0, X1)
7
+ %% goal: collectionMember(X0, X1)
8
8
 
9
- %% goal: append(X0, X1)
9
+ %% goal: collectionAppend(X0, X1)
10
10
 
11
11
  %% goal: head(X0, X1)
12
12
 
@@ -21,15 +21,15 @@ collection(letters, [a, b]).
21
21
 
22
22
  % The derived predicates show list length, membership, append, and pattern
23
23
  % matching with [Head|Tail] in the smallest possible setting.
24
- length(numbers, N) :-
24
+ collectionLength(numbers, N) :-
25
25
  collection(numbers, List),
26
26
  length(List, N).
27
27
 
28
- member(numbers, X) :-
28
+ collectionMember(numbers, X) :-
29
29
  collection(numbers, List),
30
30
  member(X, List).
31
31
 
32
- append(letters, Extended) :-
32
+ collectionAppend(letters, Extended) :-
33
33
  collection(letters, List),
34
34
  append(List, [c], Extended).
35
35
 
package/examples/lldm.pl CHANGED
@@ -18,6 +18,8 @@
18
18
  %% goal: lld_reason(X0, X1)
19
19
 
20
20
 
21
+ :- discontiguous(val/3).
22
+
21
23
  % val/3 stores raw landmark coordinates, derived deltas, line coefficients,
22
24
  % projected landmarks, lengths, and alarm values in one measurement namespace.
23
25
  measurement(meas47).
@@ -100,16 +100,10 @@ rdf_number(Subject, Predicate, Number) :-
100
100
  iri_term(Subject, SubjectIri),
101
101
  iri_term(Predicate, PredicateIri),
102
102
  rdf(iri(SubjectIri), iri(PredicateIri), literal(Text, datatype(_Datatype)), default_graph),
103
- number_string(Number, Text).
103
+ atom_chars(Text, Chars),
104
+ number_chars(Number, Chars).
104
105
 
105
106
  iri_term(ex(Name), Iri) :- namespace_iri('https://example.org/', Name, Iri).
106
107
  iri_term(odrl(Name), Iri) :- namespace_iri('http://www.w3.org/ns/odrl/2/', Name, Iri).
107
108
 
108
- namespace_iri(Prefix, Name, Iri) :-
109
- atom(Name),
110
- !,
111
- atom_string(Name, Local),
112
- string_concat(Prefix, Local, Iri).
113
- namespace_iri(Prefix, Name, Iri) :-
114
- string_concat(Prefix, Local, Iri),
115
- atom_string(Name, Local).
109
+ namespace_iri(Prefix, Name, Iri) :- atom_concat(Prefix, Name, Iri).
@@ -56,7 +56,7 @@ healthcare_risk_report(Ranked) :-
56
56
  ),
57
57
  Unsorted
58
58
  ),
59
- sort(Unsorted, Sorted),
59
+ sort_unique(Unsorted, Sorted),
60
60
  ranked_values(Sorted, 1, Ranked).
61
61
 
62
62
  risk_report(Risk, Score, Level, Clause, Mitigation) :-
@@ -68,7 +68,7 @@ consumer_risk_report(Ranked) :-
68
68
  ),
69
69
  Unsorted
70
70
  ),
71
- sort(Unsorted, Sorted),
71
+ sort_unique(Unsorted, Sorted),
72
72
  ranked_values(Sorted, 1, Ranked).
73
73
 
74
74
  risk_report(Risk, Score, Level, Clause, Mitigation) :-
@@ -30,3 +30,12 @@ c8(check, "OK - classification behavior is monotonic across representative BMI v
30
30
  c9(check, "OK - the healthy-weight band was reconstructed from BMI 18.5 to 24.9 at the same height.").
31
31
  result(report, bmi(22.72, "Normal")).
32
32
  healthyWeightRangeKg(report, range(58.6, 78.9)).
33
+ checkPassed(report, c1).
34
+ checkPassed(report, c2).
35
+ checkPassed(report, c3).
36
+ checkPassed(report, c4).
37
+ checkPassed(report, c5).
38
+ checkPassed(report, c6).
39
+ checkPassed(report, c7).
40
+ checkPassed(report, c8).
41
+ checkPassed(report, c9).
@@ -1,7 +1,7 @@
1
- length(numbers, 3).
2
- member(numbers, 1).
3
- member(numbers, 2).
4
- member(numbers, 3).
5
- append(letters, [a, b, c]).
1
+ collectionLength(numbers, 3).
2
+ collectionMember(numbers, 1).
3
+ collectionMember(numbers, 2).
4
+ collectionMember(numbers, 3).
5
+ collectionAppend(letters, [a, b, c]).
6
6
  head(letters, a).
7
7
  tail(letters, [b]).
@@ -15,6 +15,9 @@
15
15
 
16
16
 
17
17
 
18
+ :- discontiguous(assign/2).
19
+ :- discontiguous(points_to/2).
20
+
18
21
  % Source-program statements:
19
22
  % x = &object_a
20
23
  % z = &object_b
@@ -36,7 +36,7 @@ why(
36
36
  proof(
37
37
  goal(holds_result(test, true)),
38
38
  by(rule("age.pl", clause(5))),
39
- bindings([binding("S", patH)]),
39
+ bindings([binding("__anon0", patH)]),
40
40
  uses([
41
41
  proof(
42
42
  goal(ageAbove(patH, 'P80Y')),