eyelang 1.5.2 → 1.5.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.
Files changed (139) hide show
  1. package/README.md +2 -0
  2. package/examples/access-control-policy.pl +3 -0
  3. package/examples/ackermann.pl +3 -0
  4. package/examples/age.pl +3 -0
  5. package/examples/aliases-and-namespaces.pl +7 -0
  6. package/examples/alignment-demo.pl +3 -0
  7. package/examples/allen-interval-calculus.pl +3 -0
  8. package/examples/ancestor.pl +7 -0
  9. package/examples/animal.pl +3 -0
  10. package/examples/annotation.pl +3 -0
  11. package/examples/auroracare.pl +309 -0
  12. package/examples/backward.pl +3 -0
  13. package/examples/basic-monadic.pl +3 -1
  14. package/examples/bayes-diagnosis.pl +3 -0
  15. package/examples/bayes-therapy.pl +3 -0
  16. package/examples/beam-deflection.pl +3 -0
  17. package/examples/blocks-world-planning.pl +3 -0
  18. package/examples/bmi.pl +3 -0
  19. package/examples/braking-safety-worlds.pl +3 -0
  20. package/examples/buck-converter-design.pl +3 -0
  21. package/examples/cache-performance.pl +3 -0
  22. package/examples/canary-release.pl +3 -0
  23. package/examples/cat-koko.pl +3 -0
  24. package/examples/clinical-trial-screening.pl +3 -0
  25. package/examples/collatz-1000.pl +3 -0
  26. package/examples/combinatorics-findall-sort.pl +6 -0
  27. package/examples/competitive-enzyme-kinetics.pl +3 -0
  28. package/examples/complex-matrix-stability.pl +3 -0
  29. package/examples/complex.pl +3 -0
  30. package/examples/composition-of-injective-functions-is-injective.pl +3 -0
  31. package/examples/context-association.pl +3 -0
  32. package/examples/control-system.pl +3 -0
  33. package/examples/cryptarithmetic-send-more-money.pl +3 -0
  34. package/examples/cyclic-path.pl +3 -1
  35. package/examples/d3-group.pl +8 -0
  36. package/examples/dairy-energy-balance.pl +3 -0
  37. package/examples/data-negotiation.pl +6 -0
  38. package/examples/deep-taxonomy-10.pl +3 -0
  39. package/examples/deep-taxonomy-100.pl +3 -0
  40. package/examples/deep-taxonomy-1000.pl +3 -0
  41. package/examples/deep-taxonomy-10000.pl +3 -0
  42. package/examples/deep-taxonomy-100000.pl +3 -0
  43. package/examples/delfour.pl +18 -1
  44. package/examples/dense-hamiltonian-cycle.pl +3 -0
  45. package/examples/deontic-logic.pl +6 -0
  46. package/examples/derived-backward-rule.pl +3 -0
  47. package/examples/derived-rule.pl +3 -0
  48. package/examples/diamond-property.pl +3 -0
  49. package/examples/dijkstra-findall-sort.pl +6 -0
  50. package/examples/dijkstra-risk-path.pl +3 -0
  51. package/examples/dijkstra.pl +3 -0
  52. package/examples/dining-philosophers.pl +3 -0
  53. package/examples/dog.pl +5 -0
  54. package/examples/drone-corridor-planner.pl +3 -0
  55. package/examples/easter-computus.pl +6 -0
  56. package/examples/electrical-rc-filter.pl +3 -0
  57. package/examples/epidemic-policy.pl +6 -0
  58. package/examples/equivalence-classes-overlap-implies-same-class.pl +3 -0
  59. package/examples/eulerian-path.pl +6 -0
  60. package/examples/ev-range-worlds.pl +3 -0
  61. package/examples/exact-cover-sudoku.pl +3 -0
  62. package/examples/existential-rule.pl +3 -0
  63. package/examples/exoplanet-validation-worlds.pl +3 -0
  64. package/examples/expression-eval.pl +5 -0
  65. package/examples/family-cousins.pl +3 -0
  66. package/examples/fastpow.pl +5 -0
  67. package/examples/fft8-numeric.pl +6 -0
  68. package/examples/fibonacci.pl +3 -0
  69. package/examples/field-nitrogen-balance.pl +3 -0
  70. package/examples/flandor.pl +296 -0
  71. package/examples/floating-point.pl +5 -0
  72. package/examples/four-color-map.pl +3 -0
  73. package/examples/fundamental-theorem-arithmetic.pl +3 -0
  74. package/examples/gcd-bezout-identity.pl +3 -0
  75. package/examples/gd-step-certified.pl +3 -0
  76. package/examples/gdpr-compliance.pl +6 -0
  77. package/examples/goldbach-1000.pl +3 -0
  78. package/examples/good-cobbler.pl +3 -0
  79. package/examples/gps.pl +3 -0
  80. package/examples/graph-reachability.pl +3 -0
  81. package/examples/gray-code-counter.pl +6 -0
  82. package/examples/greatest-lower-bound-uniqueness.pl +3 -0
  83. package/examples/group-inverse-uniqueness.pl +3 -0
  84. package/examples/hamiltonian-cycle.pl +3 -0
  85. package/examples/hamiltonian-path.pl +3 -0
  86. package/examples/hamming-code.pl +3 -0
  87. package/examples/hanoi.pl +3 -0
  88. package/examples/heat-loss.pl +3 -0
  89. package/examples/heron-theorem.pl +5 -0
  90. package/examples/ideal-gas-law.pl +3 -0
  91. package/examples/illegitimate-reasoning.pl +3 -0
  92. package/examples/kaprekar.pl +3 -0
  93. package/examples/law-of-cosines.pl +5 -0
  94. package/examples/least-squares-regression.pl +3 -0
  95. package/examples/list-collection.pl +5 -0
  96. package/examples/lldm.pl +3 -0
  97. package/examples/manufacturing-quality-control.pl +3 -0
  98. package/examples/matrix.pl +3 -0
  99. package/examples/microgrid-dispatch.pl +3 -0
  100. package/examples/monkey-bananas.pl +3 -0
  101. package/examples/n-queens.pl +3 -0
  102. package/examples/network-sla.pl +3 -0
  103. package/examples/newton-raphson.pl +3 -0
  104. package/examples/nixon-diamond.pl +3 -0
  105. package/examples/odrl-dpv-healthcare-risk-ranked.pl +3 -0
  106. package/examples/odrl-dpv-risk-ranked.pl +3 -0
  107. package/examples/orbital-transfer-design.pl +3 -0
  108. package/examples/output/auroracare.pl +117 -0
  109. package/examples/output/delfour.pl +7 -1
  110. package/examples/output/flandor.pl +43 -0
  111. package/examples/path-discovery.pl +3 -0
  112. package/examples/peano-arithmetic.pl +3 -0
  113. package/examples/peasant.pl +5 -0
  114. package/examples/pendulum-period.pl +3 -0
  115. package/examples/polynomial.pl +3 -0
  116. package/examples/project-portfolio-optimization.pl +3 -0
  117. package/examples/proof-contrapositive.pl +3 -0
  118. package/examples/quadratic-formula.pl +3 -0
  119. package/examples/quine-mccluskey.pl +3 -0
  120. package/examples/radioactive-decay.pl +3 -0
  121. package/examples/sat-dpll.pl +3 -0
  122. package/examples/security-incident-correlation.pl +3 -0
  123. package/examples/service-impact.pl +3 -0
  124. package/examples/sieve.pl +3 -0
  125. package/examples/skolem-functions.pl +3 -0
  126. package/examples/socket-age.pl +3 -0
  127. package/examples/socket-family.pl +3 -0
  128. package/examples/socrates.pl +3 -0
  129. package/examples/statistics-summary.pl +3 -0
  130. package/examples/sudoku.pl +3 -0
  131. package/examples/superdense-coding.pl +3 -0
  132. package/examples/traveling-salesman.pl +6 -0
  133. package/examples/turing.pl +3 -0
  134. package/examples/vector-similarity.pl +6 -0
  135. package/examples/witch.pl +3 -0
  136. package/examples/wolf-goat-cabbage.pl +3 -0
  137. package/examples/zebra.pl +3 -0
  138. package/package.json +1 -1
  139. package/playground.html +2 -0
@@ -2,18 +2,21 @@
2
2
  %
3
3
  % Thermal resistance is L/(k*A), and heat loss is DeltaT/R.
4
4
 
5
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
5
6
  materialize(type, 2).
6
7
  materialize(temperatureDifference_K, 2).
7
8
  materialize(thermalResistance_K_W, 2).
8
9
  materialize(heatLoss_W, 2).
9
10
  materialize(status, 2).
10
11
 
12
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
11
13
  wall(wall1, conductivity_W_mK, 0.8).
12
14
  wall(wall1, area_m2, 12.0).
13
15
  wall(wall1, thickness_m, 0.2).
14
16
  wall(wall1, indoor_C, 21.0).
15
17
  wall(wall1, outdoor_C, -4.0).
16
18
 
19
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
17
20
  temperature_difference(Wall, DeltaT) :-
18
21
  wall(Wall, indoor_C, Indoor),
19
22
  wall(Wall, outdoor_C, Outdoor),
@@ -1,18 +1,23 @@
1
1
  % Heron's theorem: area = sqrt(s(s-a)(s-b)(s-c)).
2
2
 
3
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
3
4
  materialize(semiperimeter, 2).
4
5
  materialize(heronProduct, 2).
5
6
  materialize(area, 2).
6
7
  materialize(status, 2).
7
8
 
9
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
10
+ % 13-14-15 is a classic integer-sided triangle with area 84.
8
11
  triangle(field_plot, 13, 14, 15).
9
12
 
13
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
10
14
  semiperimeter(Triangle, S) :-
11
15
  triangle(Triangle, A, B, C),
12
16
  add(A, B, AB),
13
17
  add(AB, C, Sum),
14
18
  div(Sum, 2, S).
15
19
 
20
+ % Area is obtained by taking the square root of this Heron product.
16
21
  heron_product(Triangle, Product) :-
17
22
  triangle(Triangle, A, B, C),
18
23
  semiperimeter(Triangle, S),
@@ -3,14 +3,17 @@
3
3
  % A simple gas cell uses P*V = n*R*T. The constants are chosen so that the
4
4
  % computed pressure is exactly near one atmosphere in this small example.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(pressure_Pa, 2).
7
8
  materialize(status, 2).
8
9
  materialize(reason, 2).
9
10
 
11
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
10
12
  gas_cell(cell1, 1.0, 8.0, 300.0, 0.024).
11
13
  pressure_limit(cell1, low_Pa, 95000.0).
12
14
  pressure_limit(cell1, high_Pa, 105000.0).
13
15
 
16
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
14
17
  pressure(Cell, Pressure) :-
15
18
  gas_cell(Cell, Moles, GasConstant, Temperature, Volume),
16
19
  mul(Moles, GasConstant, NR),
@@ -7,6 +7,7 @@
7
7
 
8
8
  % Affirming the consequent:
9
9
  % If it rained, the street is wet. The street is wet. Therefore it rained.
10
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
10
11
  materialize(type, 2).
11
12
  materialize(fallacy, 2).
12
13
  materialize(conclusion, 2).
@@ -15,6 +16,7 @@ materialize(sampleSize, 2).
15
16
  materialize(requiredSampleSize, 2).
16
17
  materialize(omittedAlternative, 2).
17
18
 
19
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
18
20
  argument(arg_affirming_consequent).
19
21
  implication(arg_affirming_consequent, rain, street_wet).
20
22
  observed(arg_affirming_consequent, street_wet).
@@ -47,6 +49,7 @@ implication(arg_modus_ponens, subscription_paid, access_allowed).
47
49
  observed(arg_modus_ponens, subscription_paid).
48
50
  concludes(arg_modus_ponens, access_allowed).
49
51
 
52
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
50
53
  fallacy(A, affirming_consequent) :-
51
54
  argument(A),
52
55
  implication(A, Antecedent, Consequent),
@@ -5,12 +5,15 @@
5
5
  % until Kaprekar's constant 6174 is reached. The sample set is small so the
6
6
  % example remains a millisecond-scale demo in the normal test suite.
7
7
 
8
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
8
9
  materialize(constant, 2).
9
10
  materialize(kaprekarSteps, 2).
10
11
  materialize(reachesConstant, 2).
11
12
 
13
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
12
14
  memoize(kaprekar, 3).
13
15
 
16
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
14
17
  recursion_count(N, Count) :-
15
18
  kaprekar_steps(N, Count).
16
19
 
@@ -1,12 +1,17 @@
1
1
  % Law of cosines: c^2 = a^2 + b^2 - 2ab cos(C).
2
2
  % The example uses a 60-degree included angle, so cos(C) is represented as 0.5.
3
3
 
4
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
4
5
  materialize(sideCSquared, 2).
5
6
  materialize(sideC, 2).
6
7
  materialize(status, 2).
7
8
 
9
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
10
+ % Stored tuple is triangle(Name, sideA, sideB, cosIncludedAngle).
8
11
  triangle(tri60, 7, 9, 0.5).
9
12
 
13
+ % Compute c^2 first so both squared and square-rooted outputs can be shown.
14
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
10
15
  side_c_squared(Triangle, C2) :-
11
16
  triangle(Triangle, A, B, CosC),
12
17
  mul(A, A, A2),
@@ -3,16 +3,19 @@
3
3
  % The rules reduce a list of points to sufficient statistics, then derive the
4
4
  % fitted slope, intercept, and coefficient of determination R^2.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(slope, 2).
7
8
  materialize(intercept, 2).
8
9
  materialize(rSquared, 2).
9
10
  materialize(status, 2).
10
11
  materialize(reason, 2).
11
12
 
13
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
12
14
  dataset(regression1, [point(1.0, 2.0), point(2.0, 3.0), point(3.0, 5.0), point(4.0, 4.0)]).
13
15
  threshold(regression1, minimum_r_squared, 0.60).
14
16
 
15
17
  stats([], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0).
18
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
16
19
  stats([point(X, Y)|Rest], N, SumX, SumY, SumXX, SumXY, SumYY) :-
17
20
  stats(Rest, N0, SumX0, SumY0, SumXX0, SumXY0, SumYY0),
18
21
  add(N0, 1.0, N),
@@ -1,14 +1,19 @@
1
1
  % List collections inspired by the Eyeling collection example.
2
2
  % Demonstrates list literals, member/2, length/2, append/3, and [Head|Tail].
3
+ % Each materialized relation demonstrates one list operation.
4
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
3
5
  materialize(length, 2).
4
6
  materialize(member, 2).
5
7
  materialize(append, 2).
6
8
  materialize(head, 2).
7
9
  materialize(tail, 2).
8
10
 
11
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
12
+ % Lists are first-class terms in facts and rule heads/bodies.
9
13
  collection(numbers, [1, 2, 3]).
10
14
  collection(letters, [a, b]).
11
15
 
16
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
12
17
  length(numbers, N) :-
13
18
  collection(numbers, List),
14
19
  length(List, N).
package/examples/lldm.pl CHANGED
@@ -4,6 +4,7 @@
4
4
  % the default relation materialization stays concise. The visible output is
5
5
  % the alarm plus the small set of relations explaining why the alarm fired.
6
6
 
7
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
7
8
  materialize(type, 2).
8
9
  materialize(lld_left_length_cm, 2).
9
10
  materialize(lld_right_length_cm, 2).
@@ -11,6 +12,7 @@ materialize(lld_discrepancy_cm, 2).
11
12
  materialize(lld_threshold_cm, 2).
12
13
  materialize(lld_reason, 2).
13
14
 
15
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
14
16
  measurement(meas47).
15
17
 
16
18
  % measured landmark coordinates, in centimetres
@@ -27,6 +29,7 @@ val(meas47, p4yCm, 28.5).
27
29
  threshold(meas47, lld_alarm_threshold_cm, 1.25).
28
30
 
29
31
  % geometric intermediate values
32
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
30
33
  val(M, dx12Cm, Z) :- measurement(M), val(M, p1xCm, X), val(M, p2xCm, Y), sub(X, Y, Z).
31
34
  val(M, dx51Cm, Z) :- measurement(M), val(M, p5xCm, X), val(M, p1xCm, Y), sub(X, Y, Z).
32
35
  val(M, dx53Cm, Z) :- measurement(M), val(M, p5xCm, X), val(M, p3xCm, Y), sub(X, Y, Z).
@@ -3,10 +3,12 @@
3
3
  % The rules compute process capability indices from measurement summaries and
4
4
  % classify production lines using a practical Cpk threshold.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(cpk, 2).
7
8
  materialize(status, 2).
8
9
  materialize(reason, 2).
9
10
 
11
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
10
12
  run(line7_shift_a).
11
13
  run(line8_shift_b).
12
14
 
@@ -22,6 +24,7 @@ summary(line8_shift_b, sigma_mm, 0.02).
22
24
 
23
25
  capability_threshold(cpk, 1.33).
24
26
 
27
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
25
28
  upper_margin_mm(Run, Margin) :-
26
29
  spec(Run, upper_mm, Upper),
27
30
  summary(Run, mean_mm, Mean),
@@ -7,10 +7,13 @@
7
7
 
8
8
  % --- small list helpers -----------------------------------------------------
9
9
 
10
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
10
11
  materialize(result, 2).
11
12
  materialize(checksConsistentWithTreallaReference, 2).
12
13
 
14
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
13
15
  nth0(0, [H|_T], H).
16
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
14
17
  nth0(N, [_H|T], V) :-
15
18
  gt(N, 0),
16
19
  sub(N, 1, N1),
@@ -3,6 +3,7 @@
3
3
  % The rules compute renewable supply, reserve-aware battery dispatch, remaining
4
4
  % grid import, and a concise feasibility report for a campus microgrid interval.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(renewablePower_kW, 2).
7
8
  materialize(batteryDispatch_kW, 2).
8
9
  materialize(gridImport_kW, 2).
@@ -10,6 +11,7 @@ materialize(reserveAfterDispatch_kW, 2).
10
11
  materialize(status, 2).
11
12
  materialize(reason, 2).
12
13
 
14
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
13
15
  site(campus_interval_17).
14
16
 
15
17
  load_kW(campus_interval_17, 620.0).
@@ -19,6 +21,7 @@ battery_max_discharge_kW(campus_interval_17, 320.0).
19
21
  required_battery_reserve_kW(campus_interval_17, 80.0).
20
22
  grid_contract_limit_kW(campus_interval_17, 150.0).
21
23
 
24
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
22
25
  renewable_kW(Site, Renewable) :-
23
26
  solar_kW(Site, Solar),
24
27
  wind_kW(Site, Wind),
@@ -5,11 +5,14 @@
5
5
  % has_bananas]. The selected output searches bounded move lists and derives successful
6
6
  % plans.
7
7
 
8
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
8
9
  materialize(plan, 2).
9
10
  materialize(solved, 2).
10
11
 
12
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
11
13
  memoize(reachable, 3).
12
14
 
15
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
13
16
  plan(Moves) :-
14
17
  candidate_plan(Moves),
15
18
  initial_state(I),
@@ -10,9 +10,12 @@
10
10
  % Row - Q. Rejecting repeats in those two lists enforces the remaining
11
11
  % N-queens constraints declaratively, without cut or destructive update.
12
12
 
13
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
13
14
  materialize(solution, 2).
14
15
  materialize(solved, 2).
15
16
 
17
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
18
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
16
19
  queens(N, Qs) :-
17
20
  n_queens(N, Qs).
18
21
 
@@ -3,11 +3,13 @@
3
3
  % The path latency is the sum of link delays plus jitter. The path is compliant
4
4
  % when the resulting end-to-end latency stays below the SLA limit.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(endToEndLatency_ms, 2).
7
8
  materialize(slaLimit_ms, 2).
8
9
  materialize(status, 2).
9
10
  materialize(reason, 2).
10
11
 
12
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
11
13
  path(edge_path, [link_a, link_b, link_c]).
12
14
  link_latency(link_a, 12.0).
13
15
  link_latency(link_b, 18.0).
@@ -16,6 +18,7 @@ jitter(edge_path, 8.0).
16
18
  sla(edge_path, maximum_latency_ms, 50.0).
17
19
 
18
20
  latency_sum([], 0.0).
21
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
19
22
  latency_sum([Link|Links], Total) :-
20
23
  link_latency(Link, LinkLatency),
21
24
  latency_sum(Links, Rest),
@@ -1,12 +1,15 @@
1
1
  % Newton-Raphson root finding, adapted from Eyelet input/newton-raphson.pl.
2
2
  % The selected roots match Eyelet output-swipl/newton-raphson.pl.
3
3
 
4
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
4
5
  materialize(findRoot, 2).
5
6
 
7
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
6
8
  want_root([1, 1.0, 1.0e-15]).
7
9
  want_root([2, 2.0, 1.0e-15]).
8
10
  want_root([3, 3.0, 1.0e-15]).
9
11
 
12
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
10
13
  findRoot(Input, Root) :-
11
14
  want_root(Input),
12
15
  find_root(Input, Root).
@@ -3,13 +3,16 @@
3
3
  % a subject with both defaults is reported as conflicted rather than forced to
4
4
  % choose one extension.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(defaultSupports, 2).
7
8
  materialize(conflict, 2).
8
9
  materialize(status, 2).
9
10
 
11
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
10
12
  kind(nixon, quaker).
11
13
  kind(nixon, republican).
12
14
 
15
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
13
16
  supports_default(Person, pacifist) :-
14
17
  kind(Person, quaker).
15
18
 
@@ -2,6 +2,7 @@
2
2
  % odrl-dpv-healthcare-risk-ranked.n3.
3
3
  % The agreement policy and mitigation suggestions are formula-valued terms.
4
4
 
5
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
5
6
  materialize(policyGraph, 2).
6
7
  materialize(contains, 2).
7
8
  materialize(dpv_hasRisk, 2).
@@ -20,6 +21,7 @@ materialize(suggestAddGraph, 2).
20
21
  materialize(firstRisk, 2).
21
22
  materialize(retentionRiskScore, 2).
22
23
 
24
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
23
25
  party(hospital).
24
26
  party(researchUnit).
25
27
  party(pharmaPartner).
@@ -110,6 +112,7 @@ policy_graph(policyGraphHC1, (
110
112
  clause(permRetention10y, clauseH4)
111
113
  )).
112
114
 
115
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
113
116
  policy_statement(GraphName, Subject, Predicate, Object) :-
114
117
  policy_graph(GraphName, Formula),
115
118
  formula_binary(Formula, Subject, Predicate, Object).
@@ -5,6 +5,7 @@
5
5
  % reasoning, and materializes the derived DPV risks as relation output.
6
6
 
7
7
  % Consumer profile and needs.
8
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
8
9
  materialize(dct_title, 2).
9
10
  materialize(dpv_hasRisk, 2).
10
11
  materialize(type, 2).
@@ -31,6 +32,7 @@ materialize(dpv_mitigatesRisk, 2).
31
32
  materialize(clauseId, 2).
32
33
  materialize(text, 2).
33
34
 
35
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
34
36
  consumer(consumerExample).
35
37
  title(consumerExample, "Example consumer profile").
36
38
  has_need(consumerExample, need_DataCannotBeRemoved).
@@ -94,6 +96,7 @@ policy_graph(policyGraph1, (
94
96
  clause(prohibitExportData, clauseC4)
95
97
  )).
96
98
 
99
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
97
100
  policy_statement(Subject, Predicate, Object) :-
98
101
  policy_graph(_Graph, Formula),
99
102
  formula_binary(Formula, Subject, Predicate, Object).
@@ -4,6 +4,7 @@
4
4
  % mission constraints. Distances are in kilometres, speeds in kilometres per
5
5
  % second, and time in days.
6
6
 
7
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
7
8
  materialize(transferSemiMajorAxis_km, 2).
8
9
  materialize(departureDeltaV_km_s, 2).
9
10
  materialize(arrivalDeltaV_km_s, 2).
@@ -12,6 +13,7 @@ materialize(transferTime_days, 2).
12
13
  materialize(status, 2).
13
14
  materialize(reason, 2).
14
15
 
16
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
15
17
  mission(mars_hohmann, centralBodyMu_km3_s2, 132712440018.0).
16
18
  mission(mars_hohmann, departureOrbitRadius_km, 149597870.7).
17
19
  mission(mars_hohmann, arrivalOrbitRadius_km, 227939200.0).
@@ -19,6 +21,7 @@ mission(mars_hohmann, deltaVBudget_km_s, 6.0).
19
21
  mission(mars_hohmann, pi, 3.141592653589793).
20
22
  mission(mars_hohmann, secondsPerDay, 86400.0).
21
23
 
24
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
22
25
  semi_major_axis(Mission, Axis) :-
23
26
  mission(Mission, departureOrbitRadius_km, R1),
24
27
  mission(Mission, arrivalOrbitRadius_km, R2),
@@ -0,0 +1,117 @@
1
+ label(scenarioA, "A – Primary care visit").
2
+ label(scenarioB, "B – Quality improvement (in scope)").
3
+ label(scenarioC, "C – Quality improvement (out of scope)").
4
+ label(scenarioD, "D – Insurance management").
5
+ label(scenarioE, "E – GP checks labs").
6
+ label(scenarioF, "F – Research on anonymised dataset").
7
+ label(scenarioG, "G – AI training (opt-out)").
8
+ description(scenarioA, "Clinician in the patient's care team accessing the patient summary for primary care management.").
9
+ description(scenarioB, "QI analyst using lab results + summary in a secure environment.").
10
+ description(scenarioC, "QI analyst with only lab results; policy expects labs + summary.").
11
+ description(scenarioD, "Insurance bot attempting to use health data for insurance management (prohibited purpose).").
12
+ description(scenarioE, "GP for the same patient checking lab results via the API gateway.").
13
+ description(scenarioF, "Researcher using anonymised labs + summary in a secure environment, with opt-in.").
14
+ description(scenarioG, "Data user wants to train AI, but the subject opted out of AI training.").
15
+ careTeamLinked(scenarioA, true).
16
+ careTeamLinked(scenarioE, true).
17
+ subjectOptIn(scenarioF, true).
18
+ subjectOptOut(scenarioG, true).
19
+ decision(scenarioA, "PERMIT").
20
+ decision(scenarioE, "PERMIT").
21
+ decision(scenarioB, "PERMIT").
22
+ decision(scenarioF, "PERMIT").
23
+ decision(scenarioD, "DENY").
24
+ decision(scenarioG, "DENY").
25
+ decision(scenarioC, "DENY").
26
+ matchedPolicyUid(scenarioA, "urn:policy:primary-care-001").
27
+ matchedPolicyUid(scenarioE, "urn:policy:primary-care-001").
28
+ matchedPolicyUid(scenarioB, "urn:policy:qi-2025-aurora").
29
+ matchedPolicyUid(scenarioF, "urn:policy:research-aurora-diabetes").
30
+ matchedProhibition(scenarioD, policyDenyInsurance).
31
+ reason(scenarioA, "Permitted: clinician in the patient's care team, and the primary-care policy matched.").
32
+ reason(scenarioE, "Permitted: clinician in the patient's care team, and the primary-care policy matched.").
33
+ reason(scenarioB, "Permitted: ODRL/DPV policy matched for secondary use.").
34
+ reason(scenarioF, "Permitted: subject opted in and an ODRL/DPV policy matched (anonymised dataset in secure environment).").
35
+ reason(scenarioD, "Denied: the requested purpose (insurance management) is prohibited by policy.").
36
+ reason(scenarioG, "Denied: you opted out of your data being used to train AI systems.").
37
+ reason(scenarioC, "Denied: no policy matched (purpose, environment, TOMs, or categories out of scope).").
38
+ trace(scenarioA, "permit:primary_care_allowed").
39
+ trace(scenarioE, "permit:primary_care_allowed").
40
+ trace(scenarioA, "urn:policy:primary-care-001:permit:odrl:permission_matched").
41
+ trace(scenarioE, "urn:policy:primary-care-001:permit:odrl:permission_matched").
42
+ trace(scenarioB, "urn:policy:qi-2025-aurora:permit:odrl:permission_matched").
43
+ trace(scenarioF, "urn:policy:research-aurora-diabetes:permit:odrl:permission_matched").
44
+ trace(scenarioD, "deny:prohibited_purpose").
45
+ trace(scenarioD, "urn:policy:deny-insurance:deny:odrl:prohibition_matched").
46
+ trace(scenarioG, "deny:subject_opted_out_ai_training").
47
+ trace(scenarioC, "urn:policy:qi-2025-aurora:deny:odrl:no_permission_matched").
48
+ checkC1(scenarioA, "SKIPPED - not a prohibited purpose").
49
+ checkC1(scenarioB, "SKIPPED - not a prohibited purpose").
50
+ checkC1(scenarioC, "SKIPPED - not a prohibited purpose").
51
+ checkC1(scenarioD, "OK - denied prohibited purpose").
52
+ checkC1(scenarioE, "SKIPPED - not a prohibited purpose").
53
+ checkC1(scenarioF, "SKIPPED - not a prohibited purpose").
54
+ checkC1(scenarioG, "SKIPPED - not a prohibited purpose").
55
+ checkC2(scenarioA, "OK - clinician").
56
+ checkC2(scenarioB, "SKIPPED").
57
+ checkC2(scenarioC, "SKIPPED").
58
+ checkC2(scenarioD, "SKIPPED").
59
+ checkC2(scenarioE, "OK - clinician").
60
+ checkC2(scenarioF, "SKIPPED").
61
+ checkC2(scenarioG, "SKIPPED").
62
+ checkC3(scenarioA, "OK - care-team linked").
63
+ checkC3(scenarioB, "SKIPPED").
64
+ checkC3(scenarioC, "SKIPPED").
65
+ checkC3(scenarioD, "SKIPPED").
66
+ checkC3(scenarioE, "OK - care-team linked").
67
+ checkC3(scenarioF, "SKIPPED").
68
+ checkC3(scenarioG, "SKIPPED").
69
+ checkC4(scenarioA, "SKIPPED").
70
+ checkC4(scenarioB, "OK - opt-in present and policy matched").
71
+ checkC4(scenarioC, "OK - denied because opt-in missing or no policy match").
72
+ checkC4(scenarioD, "SKIPPED").
73
+ checkC4(scenarioE, "SKIPPED").
74
+ checkC4(scenarioF, "OK - opt-in present and policy matched").
75
+ checkC4(scenarioG, "OK - denied because opt-in missing or no policy match").
76
+ checkC5(scenarioA, "OK - operator=isAnyOf, allowed=[\"https://example.org/health#PATIENT_SUMMARY\", \"https://example.org/health#LAB_RESULTS\"], requested=[\"https://example.org/health#PATIENT_SUMMARY\"]").
77
+ checkC5(scenarioB, "OK - operator=isAllOf, allowed=[\"https://example.org/health#LAB_RESULTS\", \"https://example.org/health#PATIENT_SUMMARY\"], requested=[\"https://example.org/health#LAB_RESULTS\", \"https://example.org/health#PATIENT_SUMMARY\"]").
78
+ checkC5(scenarioC, "SKIPPED").
79
+ checkC5(scenarioD, "SKIPPED").
80
+ checkC5(scenarioE, "OK - operator=isAnyOf, allowed=[\"https://example.org/health#PATIENT_SUMMARY\", \"https://example.org/health#LAB_RESULTS\"], requested=[\"https://example.org/health#LAB_RESULTS\"]").
81
+ checkC5(scenarioF, "OK - operator=isAnyOf, allowed=[\"https://example.org/health#LAB_RESULTS\", \"https://example.org/health#PATIENT_SUMMARY\", \"https://example.org/health#IMAGING_REPORT\"], requested=[\"https://example.org/health#PATIENT_SUMMARY\", \"https://example.org/health#LAB_RESULTS\"]").
82
+ checkC5(scenarioG, "SKIPPED").
83
+ checkC6(scenarioA, "SKIPPED - no prohibition matched").
84
+ checkC6(scenarioB, "SKIPPED - no prohibition matched").
85
+ checkC6(scenarioC, "SKIPPED - no prohibition matched").
86
+ checkC6(scenarioD, "OK - denied due to prohibition").
87
+ checkC6(scenarioE, "SKIPPED - no prohibition matched").
88
+ checkC6(scenarioF, "SKIPPED - no prohibition matched").
89
+ checkC6(scenarioG, "SKIPPED - no prohibition matched").
90
+ checkC7(scenarioA, "OK - trace shows matching permission").
91
+ checkC7(scenarioB, "OK - trace shows matching permission").
92
+ checkC7(scenarioC, "SKIPPED").
93
+ checkC7(scenarioD, "SKIPPED").
94
+ checkC7(scenarioE, "OK - trace shows matching permission").
95
+ checkC7(scenarioF, "OK - trace shows matching permission").
96
+ checkC7(scenarioG, "SKIPPED").
97
+ checkC8(scenarioA, "SKIPPED - no matched policy or no duties").
98
+ checkC8(scenarioB, "INFO - duties attached: duty:https://w3id.org/dpv/legal/eu/ehds#requireConsent, duty:https://w3id.org/dpv/legal/eu/ehds#noExfiltration").
99
+ checkC8(scenarioC, "SKIPPED - no matched policy or no duties").
100
+ checkC8(scenarioD, "SKIPPED - no matched policy or no duties").
101
+ checkC8(scenarioE, "SKIPPED - no matched policy or no duties").
102
+ checkC8(scenarioF, "INFO - duties attached: duty:https://w3id.org/dpv/legal/eu/ehds#annualOutcomeReport, duty:https://w3id.org/dpv/legal/eu/ehds#noReidentification, duty:https://w3id.org/dpv/legal/eu/ehds#noExfiltration").
103
+ checkC8(scenarioG, "SKIPPED - no matched policy or no duties").
104
+ checkC9(scenarioA, "SKIPPED - policy has no environment constraint").
105
+ checkC9(scenarioB, "OK - operator=eq, allowed=\"secure_env\", requested=\"secure_env\"").
106
+ checkC9(scenarioC, "SKIPPED").
107
+ checkC9(scenarioD, "SKIPPED").
108
+ checkC9(scenarioE, "SKIPPED - policy has no environment constraint").
109
+ checkC9(scenarioF, "OK - operator=eq, allowed=\"secure_env\", requested=\"secure_env\"").
110
+ checkC9(scenarioG, "SKIPPED").
111
+ checkC10Text(scenarioA, "INFO - matched policy: urn:policy:primary-care-001").
112
+ checkC10Text(scenarioB, "INFO - matched policy: urn:policy:qi-2025-aurora").
113
+ checkC10Text(scenarioC, "SKIPPED - no matched policy").
114
+ checkC10Text(scenarioD, "SKIPPED - no matched policy").
115
+ checkC10Text(scenarioE, "INFO - matched policy: urn:policy:primary-care-001").
116
+ checkC10Text(scenarioF, "INFO - matched policy: urn:policy:research-aurora-diabetes").
117
+ checkC10Text(scenarioG, "SKIPPED - no matched policy").
@@ -1,11 +1,17 @@
1
+ metric(insight, "sugar_g_per_serving").
2
+ retailer(insight, "Delfour").
1
3
  caseName(case, "delfour").
2
4
  needsLowSugar(case, true).
3
5
  derivedFromNeed(insight, "low_sugar").
4
6
  outcome(decision, "Allowed").
5
7
  target(decision, insight).
6
8
  scannedProduct(scan, "Classic Tea Biscuits").
7
- suggestedAlternative(case, prod_BIS_101).
9
+ suggestedAlternative(case, "Low-Sugar Tea Biscuits").
8
10
  suggestedAlternative(banner, "Low-Sugar Tea Biscuits").
11
+ threshold(insight, "10.0").
12
+ scope(insight, "self-scanner @ pick_up_scanner").
13
+ expiresAt(insight, "2025-10-05T22:33:48.907185+00:00").
14
+ reason(why, "The phone desensitizes a diabetes-related household condition into a scoped low-sugar need, wraps it in an expiring Insight + Policy envelope, signs it, and the scanner consumes that envelope for shopping assistance.").
9
15
  headline(banner, "Track sugar per serving while you scan").
10
16
  note(banner, "High sugar").
11
17
  value(reasonText, "Household requires low-sugar guidance (diabetes in POD). A neutral Insight is scoped to device 'self-scanner', event 'pick_up_scanner', retailer 'Delfour', and expires soon; the policy confines use to shopping assistance.").
@@ -0,0 +1,43 @@
1
+ caseName(case, "flandor").
2
+ regionName(flanders, "Flanders").
3
+ metric(macroInsight, "regional_retooling_priority").
4
+ alg(signature, "HMAC-SHA256").
5
+ payloadHashSHA256(signature, "718f5b17d07ab6a95503bc04a1000ddb132409f600659c03d21def81914b780b").
6
+ signatureHMAC(signature, "955968ca99a191783bc00cba068128ccb9ff40a5e6114fda13a52c74ee27329e").
7
+ auditEntries(case, 1).
8
+ filesWritten(case, 6).
9
+ exportWeakness(case, true).
10
+ skillsStrain(case, true).
11
+ gridStress(case, true).
12
+ needsRetoolingPulse(case, true).
13
+ derivedFromNeed(case, "regional_retooling_and_flexibility").
14
+ activeNeedCount(answer, 3).
15
+ activeNeedThreshold(answer, 3).
16
+ recommendedPackageName(answer, "Flandor Retooling Pulse").
17
+ budgetCapMEUR(answer, 140).
18
+ packageCostMEUR(answer, 120).
19
+ envelopeExpiresAt(answer, "2026-04-08T19:00:00+00:00").
20
+ workerCoverage(why, 1200).
21
+ gridReliefMW(why, 85).
22
+ outcome(decision, "Allowed").
23
+ target(decision, macroInsight).
24
+ allChecksPass(result, true).
25
+ signatureVerifies(check, true).
26
+ payloadHashMatches(check, true).
27
+ hmacMatches(check, true).
28
+ minimizationStripsSensitiveTerms(check, true).
29
+ scopeComplete(check, true).
30
+ authorizationAllowed(check, true).
31
+ thresholdReached(check, true).
32
+ packageWithinBudget(check, true).
33
+ packageCoversAllNeeds(check, true).
34
+ dutyTimingConsistent(check, true).
35
+ surveillanceReuseProhibited(check, true).
36
+ filesWrittenExpected(check, true).
37
+ lowestCostEligiblePackageChosen(check, true).
38
+ reason(whyExportWeakness, "Export weakness is active because at least one cluster has exportOrdersIndex < 90 (Antwerp chemicals=84, Ghent manufacturing=87).").
39
+ reason(whySkillsStrain, "Skills strain is active because technical vacancy rate is 4.6% (threshold > 3.9%).").
40
+ reason(whyGridStress, "Grid stress is active because congestion hours = 19 (threshold > 11).").
41
+ reason(whyRecommendationPolicy, "The recommendation policy is \"lowest_cost_package_covering_all_active_needs\", so the cheapest package that covers all active needs within budget is selected.").
42
+ reason(whySelectedPackage, "Selected package \"Flandor Retooling Pulse\" covers export=true, skills=true, grid=true, cost=€120M.").
43
+ reason(whyUsage, "Usage is permitted only for purpose \"regional_stabilization\" and the envelope expires at 2026-04-08T19:00:00+00:00.").
@@ -1,9 +1,12 @@
1
1
  % Generic path discovery over the air-routes graph.
2
2
  % Change or add route_request(FromLabel, ToLabel, MaxStopOvers) to answer other routes.
3
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
3
4
  materialize(airroute, 2).
4
5
 
6
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
5
7
  route_request("Ostend-Bruges International Airport", "Václav Havel Airport Prague", 2).
6
8
 
9
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
7
10
  airroute(discovered, RouteText) :-
8
11
  route_request(From, To, MaxStopOvers),
9
12
  airport(Source, From),
@@ -3,9 +3,12 @@
3
3
  % The EYE example defines add, multiply and factorial over Peano numerals.
4
4
  % Its selected output computes (1 * 2 + 3)! and emits the factorial of 5.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(factorial, 2).
7
8
 
9
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
8
10
  peano_add(A, 0, A).
11
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
9
12
  peano_add(A, s(B), s(C)) :-
10
13
  peano_add(A, B, C).
11
14
 
@@ -1,9 +1,12 @@
1
1
  % Peasant multiplication and exponentiation cases, adapted from Eyelet
2
2
  % input/peasant.pl. The selected answers match Eyelet output-swipl/peasant.pl.
3
3
 
4
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
4
5
  materialize(prod, 2).
5
6
  materialize(pow, 2).
6
7
 
8
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
9
+ % Inputs are explicit so the example does not enumerate an unbounded domain.
7
10
  want_prod([3, 0]).
8
11
  want_prod([5, 6]).
9
12
  want_prod([238, 13]).
@@ -16,6 +19,8 @@ want_pow([5, 6]).
16
19
  want_pow([238, 13]).
17
20
  want_pow([8367238, 2713]).
18
21
 
22
+ % The arithmetic itself is delegated to the native numeric built-ins.
23
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
19
24
  prod([A, B], C) :-
20
25
  want_prod([A, B]),
21
26
  mul(A, B, C).