eyelang 1.5.3 → 1.5.5

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 (171) hide show
  1. package/conformance/README.md +3 -3
  2. package/conformance/cases/core/021_repeated_variable_head.pl +7 -0
  3. package/conformance/cases/core/022_rule_head_structure.pl +5 -0
  4. package/conformance/cases/core/023_quoted_escapes_readback.pl +5 -0
  5. package/conformance/cases/core/024_numeric_literal_readback.pl +6 -0
  6. package/conformance/cases/core/025_body_parentheses_with_formula_data.pl +5 -0
  7. package/conformance/cases/core/026_underscore_named_variable_reuse.pl +5 -0
  8. package/conformance/cases/extension/035_date_difference.pl +4 -0
  9. package/conformance/cases/extension/036_extended_gcd.pl +3 -0
  10. package/conformance/cases/extension/037_collatz_trajectory.pl +3 -0
  11. package/conformance/cases/extension/038_kaprekar_steps.pl +3 -0
  12. package/conformance/cases/extension/039_goldbach_pair.pl +3 -0
  13. package/conformance/cases/extension/040_matrix_operations.pl +5 -0
  14. package/conformance/cases/extension/041_atom_range_generators.pl +5 -0
  15. package/conformance/cases/extension/042_n_queens_small.pl +3 -0
  16. package/conformance/cases/extension/043_cnf_model.pl +3 -0
  17. package/conformance/cases/extension/044_cover9_filter.pl +6 -0
  18. package/conformance/cases/extension/045_alphametic_sum_small.pl +3 -0
  19. package/conformance/cases/extension/046_bounded_subset.pl +4 -0
  20. package/conformance/expected/core/021_repeated_variable_head.out +2 -0
  21. package/conformance/expected/core/022_rule_head_structure.out +2 -0
  22. package/conformance/expected/core/023_quoted_escapes_readback.out +2 -0
  23. package/conformance/expected/core/024_numeric_literal_readback.out +3 -0
  24. package/conformance/expected/core/025_body_parentheses_with_formula_data.out +1 -0
  25. package/conformance/expected/core/026_underscore_named_variable_reuse.out +1 -0
  26. package/conformance/expected/extension/035_date_difference.out +2 -0
  27. package/conformance/expected/extension/036_extended_gcd.out +1 -0
  28. package/conformance/expected/extension/037_collatz_trajectory.out +1 -0
  29. package/conformance/expected/extension/038_kaprekar_steps.out +1 -0
  30. package/conformance/expected/extension/039_goldbach_pair.out +2 -0
  31. package/conformance/expected/extension/040_matrix_operations.out +3 -0
  32. package/conformance/expected/extension/041_atom_range_generators.out +8 -0
  33. package/conformance/expected/extension/042_n_queens_small.out +2 -0
  34. package/conformance/expected/extension/043_cnf_model.out +1 -0
  35. package/conformance/expected/extension/044_cover9_filter.out +2 -0
  36. package/conformance/expected/extension/045_alphametic_sum_small.out +4 -0
  37. package/conformance/expected/extension/046_bounded_subset.out +5 -0
  38. package/examples/access-control-policy.pl +3 -0
  39. package/examples/ackermann.pl +3 -0
  40. package/examples/age.pl +3 -0
  41. package/examples/aliases-and-namespaces.pl +7 -0
  42. package/examples/alignment-demo.pl +3 -0
  43. package/examples/allen-interval-calculus.pl +3 -0
  44. package/examples/ancestor.pl +7 -0
  45. package/examples/animal.pl +3 -0
  46. package/examples/annotation.pl +3 -0
  47. package/examples/auroracare.pl +8 -0
  48. package/examples/backward.pl +3 -0
  49. package/examples/basic-monadic.pl +3 -1
  50. package/examples/bayes-diagnosis.pl +3 -0
  51. package/examples/bayes-therapy.pl +3 -0
  52. package/examples/beam-deflection.pl +3 -0
  53. package/examples/blocks-world-planning.pl +3 -0
  54. package/examples/bmi.pl +3 -0
  55. package/examples/braking-safety-worlds.pl +3 -0
  56. package/examples/buck-converter-design.pl +3 -0
  57. package/examples/cache-performance.pl +3 -0
  58. package/examples/canary-release.pl +3 -0
  59. package/examples/cat-koko.pl +3 -0
  60. package/examples/clinical-trial-screening.pl +3 -0
  61. package/examples/collatz-1000.pl +3 -0
  62. package/examples/combinatorics-findall-sort.pl +6 -0
  63. package/examples/competitive-enzyme-kinetics.pl +3 -0
  64. package/examples/complex-matrix-stability.pl +3 -0
  65. package/examples/complex.pl +3 -0
  66. package/examples/composition-of-injective-functions-is-injective.pl +3 -0
  67. package/examples/context-association.pl +3 -0
  68. package/examples/control-system.pl +3 -0
  69. package/examples/cryptarithmetic-send-more-money.pl +3 -0
  70. package/examples/cyclic-path.pl +3 -1
  71. package/examples/d3-group.pl +8 -0
  72. package/examples/dairy-energy-balance.pl +3 -0
  73. package/examples/data-negotiation.pl +6 -0
  74. package/examples/deep-taxonomy-10.pl +3 -0
  75. package/examples/deep-taxonomy-100.pl +3 -0
  76. package/examples/deep-taxonomy-1000.pl +3 -0
  77. package/examples/deep-taxonomy-10000.pl +3 -0
  78. package/examples/deep-taxonomy-100000.pl +3 -0
  79. package/examples/delfour.pl +7 -0
  80. package/examples/dense-hamiltonian-cycle.pl +3 -0
  81. package/examples/deontic-logic.pl +6 -0
  82. package/examples/derived-backward-rule.pl +3 -0
  83. package/examples/derived-rule.pl +3 -0
  84. package/examples/diamond-property.pl +3 -0
  85. package/examples/dijkstra-findall-sort.pl +6 -0
  86. package/examples/dijkstra-risk-path.pl +3 -0
  87. package/examples/dijkstra.pl +3 -0
  88. package/examples/dining-philosophers.pl +3 -0
  89. package/examples/dog.pl +5 -0
  90. package/examples/drone-corridor-planner.pl +3 -0
  91. package/examples/easter-computus.pl +6 -0
  92. package/examples/electrical-rc-filter.pl +3 -0
  93. package/examples/epidemic-policy.pl +6 -0
  94. package/examples/equivalence-classes-overlap-implies-same-class.pl +3 -0
  95. package/examples/eulerian-path.pl +6 -0
  96. package/examples/ev-range-worlds.pl +3 -0
  97. package/examples/exact-cover-sudoku.pl +3 -0
  98. package/examples/existential-rule.pl +3 -0
  99. package/examples/exoplanet-validation-worlds.pl +3 -0
  100. package/examples/expression-eval.pl +5 -0
  101. package/examples/family-cousins.pl +3 -0
  102. package/examples/fastpow.pl +5 -0
  103. package/examples/fft8-numeric.pl +6 -0
  104. package/examples/fibonacci.pl +3 -0
  105. package/examples/field-nitrogen-balance.pl +3 -0
  106. package/examples/flandor.pl +9 -0
  107. package/examples/floating-point.pl +5 -0
  108. package/examples/four-color-map.pl +3 -0
  109. package/examples/fundamental-theorem-arithmetic.pl +3 -0
  110. package/examples/gcd-bezout-identity.pl +3 -0
  111. package/examples/gd-step-certified.pl +3 -0
  112. package/examples/gdpr-compliance.pl +6 -0
  113. package/examples/goldbach-1000.pl +3 -0
  114. package/examples/good-cobbler.pl +3 -0
  115. package/examples/gps.pl +3 -0
  116. package/examples/graph-reachability.pl +3 -0
  117. package/examples/gray-code-counter.pl +6 -0
  118. package/examples/greatest-lower-bound-uniqueness.pl +3 -0
  119. package/examples/group-inverse-uniqueness.pl +3 -0
  120. package/examples/hamiltonian-cycle.pl +3 -0
  121. package/examples/hamiltonian-path.pl +3 -0
  122. package/examples/hamming-code.pl +3 -0
  123. package/examples/hanoi.pl +3 -0
  124. package/examples/heat-loss.pl +3 -0
  125. package/examples/heron-theorem.pl +5 -0
  126. package/examples/ideal-gas-law.pl +3 -0
  127. package/examples/illegitimate-reasoning.pl +3 -0
  128. package/examples/kaprekar.pl +3 -0
  129. package/examples/law-of-cosines.pl +5 -0
  130. package/examples/least-squares-regression.pl +3 -0
  131. package/examples/list-collection.pl +5 -0
  132. package/examples/lldm.pl +3 -0
  133. package/examples/manufacturing-quality-control.pl +3 -0
  134. package/examples/matrix.pl +3 -0
  135. package/examples/microgrid-dispatch.pl +3 -0
  136. package/examples/monkey-bananas.pl +3 -0
  137. package/examples/n-queens.pl +3 -0
  138. package/examples/network-sla.pl +3 -0
  139. package/examples/newton-raphson.pl +3 -0
  140. package/examples/nixon-diamond.pl +3 -0
  141. package/examples/odrl-dpv-healthcare-risk-ranked.pl +3 -0
  142. package/examples/odrl-dpv-risk-ranked.pl +3 -0
  143. package/examples/orbital-transfer-design.pl +3 -0
  144. package/examples/path-discovery.pl +3 -0
  145. package/examples/peano-arithmetic.pl +3 -0
  146. package/examples/peasant.pl +5 -0
  147. package/examples/pendulum-period.pl +3 -0
  148. package/examples/polynomial.pl +3 -0
  149. package/examples/project-portfolio-optimization.pl +3 -0
  150. package/examples/proof-contrapositive.pl +3 -0
  151. package/examples/quadratic-formula.pl +3 -0
  152. package/examples/quine-mccluskey.pl +3 -0
  153. package/examples/radioactive-decay.pl +3 -0
  154. package/examples/sat-dpll.pl +3 -0
  155. package/examples/security-incident-correlation.pl +3 -0
  156. package/examples/service-impact.pl +3 -0
  157. package/examples/sieve.pl +3 -0
  158. package/examples/skolem-functions.pl +3 -0
  159. package/examples/socket-age.pl +3 -0
  160. package/examples/socket-family.pl +3 -0
  161. package/examples/socrates.pl +3 -0
  162. package/examples/statistics-summary.pl +3 -0
  163. package/examples/sudoku.pl +3 -0
  164. package/examples/superdense-coding.pl +3 -0
  165. package/examples/traveling-salesman.pl +6 -0
  166. package/examples/turing.pl +3 -0
  167. package/examples/vector-similarity.pl +6 -0
  168. package/examples/witch.pl +3 -0
  169. package/examples/wolf-goat-cabbage.pl +3 -0
  170. package/examples/zebra.pl +3 -0
  171. package/package.json +1 -1
@@ -7,7 +7,7 @@ The suite is intentionally file-based so another implementation can run the same
7
7
  - `conformance/cases/<profile>/<name>.pl` — input program;
8
8
  - `conformance/expected/<profile>/<name>.out` — exact expected standard output.
9
9
 
10
- The current runner compares standard output, including answer facts and their `why/2` explanation facts. Standard error, performance, and resource limits are outside this suite.
10
+ The current runner compares standard output from normal execution. Proof explanations are opt-in in the CLI and are not part of these conformance goldens. Standard error, performance, and resource limits are outside this suite.
11
11
 
12
12
  ## Running the suite
13
13
 
@@ -34,9 +34,9 @@ The runner executes materialized programs in-process through the public JavaScri
34
34
 
35
35
  ## Profiles
36
36
 
37
- `core` covers the portable core language profile from `../SPEC.md`: lexical syntax, facts, definite clauses, first-order terms, lists, conjunction, unification through user predicates, left-to-right goal-directed proof search, and answer printing.
37
+ `core` covers the portable core language profile from `../SPEC.md`: lexical syntax, facts, definite clauses, first-order terms, lists, conjunction, structured unification through user predicates, left-to-right goal-directed proof search, materialized output, and read-back printing.
38
38
 
39
- `extension` covers the standard built-in and host behavior exercised by the current reference implementation: arithmetic, comparison, strings, list relations, aggregation, formula-term helpers, `memoize/2`, `materialize/2`, and default derived output.
39
+ `extension` covers the standard built-in and host behavior exercised by the current reference implementation: arithmetic, comparison, strings, list relations, aggregation, formula-term helpers, number-theory helpers, finite-search helpers, matrix helpers, `memoize/2`, `materialize/2`, and default derived output.
40
40
 
41
41
  The profile name `extension` is a test-suite grouping name. It does not mean that these cases are outside the eyelang specification; most of them correspond to the standard built-in profile and standard host profile in `../SPEC.md`.
42
42
 
@@ -0,0 +1,7 @@
1
+ % SPEC 5.1, 7.1: repeated variables in a rule body require the same term.
2
+ pair(a, a).
3
+ pair(a, b).
4
+ pair(c, c).
5
+ diagonal(X) :- pair(X, X).
6
+ answer(diagonal, X) :- diagonal(X).
7
+ materialize(answer, 2).
@@ -0,0 +1,5 @@
1
+ % SPEC 5.3, 6, 7.1: structured rule heads destructure matching goals.
2
+ unpack(pair(X, Y), X, Y).
3
+ answer(first, A) :- unpack(pair(alpha, beta), A, _).
4
+ answer(second, B) :- unpack(pair(alpha, beta), _, B).
5
+ materialize(answer, 2).
@@ -0,0 +1,5 @@
1
+ % SPEC 3.5, 11: quoted strings and atoms preserve escape sequences at read-back.
2
+ raw(string, "line\nnext\t\\slash").
3
+ raw(atom, 'line\nnext\t\\slash').
4
+ answer(K, V) :- raw(K, V).
5
+ materialize(answer, 2).
@@ -0,0 +1,6 @@
1
+ % SPEC 3.3, 11: signed, decimal, and exponent numeric literals retain lexical form.
2
+ raw(negative_decimal, -3.5).
3
+ raw(positive_exp, 6.02e23).
4
+ raw(negative_exp, -1.0e-3).
5
+ answer(K, V) :- raw(K, V).
6
+ materialize(answer, 2).
@@ -0,0 +1,5 @@
1
+ % SPEC 5.5, 7: formula data can be passed through parenthesized conjunctions.
2
+ record((left(a), right(b))).
3
+ accept((left(a), right(b))).
4
+ answer(ok, F) :- (record(F), accept(F)).
5
+ materialize(answer, 2).
@@ -0,0 +1,5 @@
1
+ % SPEC 3.4, 5.1: variables beginning with underscore are named variables unless exactly _.
2
+ pair(a, a).
3
+ pair(a, b).
4
+ answer(shared, _Value) :- pair(_Value, _Value).
5
+ materialize(answer, 2).
@@ -0,0 +1,4 @@
1
+ % SPEC 9.1: difference/3 computes ISO date durations.
2
+ answer(duration, D) :- difference("2024-03-01", "2020-02-29", D).
3
+ answer(month_borrow, D) :- difference("2024-03-01", "2024-01-31", D).
4
+ materialize(answer, 2).
@@ -0,0 +1,3 @@
1
+ % SPEC 9.2: extended_gcd/5 returns gcd and Bezout coefficients.
2
+ answer(gcd, result(G, S, T)) :- extended_gcd(240, 46, G, S, T).
3
+ materialize(answer, 2).
@@ -0,0 +1,3 @@
1
+ % SPEC 9.2: collatz_trajectory/2 returns the full path to 1.
2
+ answer(path, T) :- collatz_trajectory(6, T).
3
+ materialize(answer, 2).
@@ -0,0 +1,3 @@
1
+ % SPEC 9.2: kaprekar_steps/2 counts iterations to 6174.
2
+ answer(steps, N) :- kaprekar_steps(3524, N).
3
+ materialize(answer, 2).
@@ -0,0 +1,3 @@
1
+ % SPEC 9.2: goldbach_pair/3 enumerates prime decompositions in ascending first prime order.
2
+ answer(pair, pair(P, Q)) :- goldbach_pair(28, P, Q).
3
+ materialize(answer, 2).
@@ -0,0 +1,5 @@
1
+ % SPEC 9.2: matrix helpers handle small ground numeric matrices.
2
+ answer(sum, M) :- matrix_sum([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], M).
3
+ answer(product, M) :- matrix_multiply([[[1, 2], [3, 4]], [[2, 0], [1, 2]]], M).
4
+ answer(determinant, D) :- determinant([[4, 2], [2, 3]], D).
5
+ materialize(answer, 2).
@@ -0,0 +1,5 @@
1
+ % SPEC 9.5: atom range helpers generate prefixed atoms deterministically.
2
+ answer(single, X) :- atom_range(n, 2, 4, X).
3
+ answer(multiple, X) :- atom_ranges([a, b], 1, 2, X).
4
+ answer(bound_check, yes) :- atom_range(n, 2, 4, n3).
5
+ materialize(answer, 2).
@@ -0,0 +1,3 @@
1
+ % SPEC 9.5: n_queens/2 enumerates finite board solutions.
2
+ answer(solution, Qs) :- n_queens(4, Qs).
3
+ materialize(answer, 2).
@@ -0,0 +1,3 @@
1
+ % SPEC 9.5: cnf_model/3 enumerates satisfying truth assignments for a CNF.
2
+ answer(model, M) :- cnf_model([a, b], [[pos(a), pos(b)], [neg(a)]], M).
3
+ materialize(answer, 2).
@@ -0,0 +1,6 @@
1
+ % SPEC 9.5: cover9/1 accepts exactly the digits 1 through 9 once.
2
+ answer(ok, yes) :- cover9([1, 2, 3, 4, 5, 6, 7, 8, 9]).
3
+ answer(candidate, X) :- row(X), cover9(X).
4
+ row([1, 2, 3, 4, 5, 6, 7, 8, 9]).
5
+ row([1, 1, 2, 3, 4, 5, 6, 7, 8]).
6
+ materialize(answer, 2).
@@ -0,0 +1,3 @@
1
+ % SPEC 9.5: alphametic_sum/5 enumerates unique digit assignments for column addition.
2
+ answer(solution, result(Digits, Values)) :- alphametic_sum([a, b], [[a], [a]], [b], Digits, Values).
3
+ materialize(answer, 2).
@@ -0,0 +1,4 @@
1
+ % SPEC 9.5: bounded_subset/7 enumerates subsets within budget and risk caps.
2
+ projects([p(a, 5, 3, 1), p(b, 4, 2, 2), p(c, 7, 5, 3)]).
3
+ answer(selection, result(Names, Value, Cost, Risk)) :- projects(Ps), bounded_subset(Ps, 5, 3, Names, Value, Cost, Risk).
4
+ materialize(answer, 2).
@@ -0,0 +1,2 @@
1
+ answer(diagonal, a).
2
+ answer(diagonal, c).
@@ -0,0 +1,2 @@
1
+ answer(first, alpha).
2
+ answer(second, beta).
@@ -0,0 +1,2 @@
1
+ answer(string, "line\nnext \\slash").
2
+ answer(atom, 'line\nnext\t\\slash').
@@ -0,0 +1,3 @@
1
+ answer(negative_decimal, -3.5).
2
+ answer(positive_exp, 6.02e23).
3
+ answer(negative_exp, -1.0e-3).
@@ -0,0 +1 @@
1
+ answer(ok, (left(a), right(b))).
@@ -0,0 +1,2 @@
1
+ answer(duration, "P4Y1D").
2
+ answer(month_borrow, "P1M-1D").
@@ -0,0 +1 @@
1
+ answer(gcd, result(2, -9, 47)).
@@ -0,0 +1 @@
1
+ answer(path, [6, 3, 10, 5, 16, 8, 4, 2, 1]).
@@ -0,0 +1 @@
1
+ answer(steps, 3).
@@ -0,0 +1,2 @@
1
+ answer(pair, pair(5, 23)).
2
+ answer(pair, pair(11, 17)).
@@ -0,0 +1,3 @@
1
+ answer(sum, [[6, 8], [10, 12]]).
2
+ answer(product, [[4, 4], [10, 8]]).
3
+ answer(determinant, 8.0000000000000018).
@@ -0,0 +1,8 @@
1
+ answer(single, n2).
2
+ answer(single, n3).
3
+ answer(single, n4).
4
+ answer(multiple, a1).
5
+ answer(multiple, a2).
6
+ answer(multiple, b1).
7
+ answer(multiple, b2).
8
+ answer(bound_check, yes).
@@ -0,0 +1,2 @@
1
+ answer(solution, [2, 4, 1, 3]).
2
+ answer(solution, [3, 1, 4, 2]).
@@ -0,0 +1 @@
1
+ answer(model, [value(a, false), value(b, true)]).
@@ -0,0 +1,2 @@
1
+ answer(ok, yes).
2
+ answer(candidate, [1, 2, 3, 4, 5, 6, 7, 8, 9]).
@@ -0,0 +1,4 @@
1
+ answer(solution, result([1, 2], [1, 1, 2])).
2
+ answer(solution, result([2, 4], [2, 2, 4])).
3
+ answer(solution, result([3, 6], [3, 3, 6])).
4
+ answer(solution, result([4, 8], [4, 4, 8])).
@@ -0,0 +1,5 @@
1
+ answer(selection, result([a, b], 9, 5, 3)).
2
+ answer(selection, result([a], 5, 3, 1)).
3
+ answer(selection, result([b], 4, 2, 2)).
4
+ answer(selection, result([c], 7, 5, 3)).
5
+ answer(selection, result([], 0, 0, 0)).
@@ -4,10 +4,12 @@
4
4
  % finite logical conditions. The universal allOf/noneOf checks use negation
5
5
  % as failure over bound policy facts.
6
6
 
7
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
7
8
  materialize(policy, 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
  policy_request(test1, policy_x).
12
14
  has(test1, claim_a).
13
15
  has(test1, claim_b).
@@ -19,6 +21,7 @@ allOf(policy_x, claim_b).
19
21
  anyOf(policy_x, claim_c).
20
22
  noneOf(policy_x, claim_d).
21
23
 
24
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
22
25
  passes_all_of(Request, Policy) :-
23
26
  policy_request(Request, Policy),
24
27
  policy(Policy),
@@ -2,8 +2,11 @@
2
2
  % The two-argument entry point follows the Eyeling encoding:
3
3
  % ackermann(X, Y) = hyper(X, Y + 3, 2) - 3.
4
4
 
5
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
5
6
  materialize(ackermann, 2).
6
7
 
8
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
9
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
7
10
  ackermann(X, Y, A) :-
8
11
  add(Y, 3, B),
9
12
  hyper(X, B, 2, C),
package/examples/age.pl CHANGED
@@ -3,16 +3,19 @@
3
3
  % Is the age of a person above some duration?
4
4
 
5
5
  % Person data.
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(birthDay, 2).
7
8
  materialize(duration, 2).
8
9
  materialize(ageAbove, 2).
9
10
  materialize(is, 2).
10
11
 
12
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
11
13
  birthDay(patH, "1944-08-21").
12
14
  duration(check, "P80Y").
13
15
 
14
16
  % A person is above a duration if the local date minus the birthday is greater
15
17
  % than that duration.
18
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
16
19
  ageAbove(S, A) :-
17
20
  birthDay(S, B),
18
21
  duration(check, A),
@@ -1,15 +1,22 @@
1
1
  % Built-ins use one native spelling each.
2
2
  % Vocabulary predicate names remain ordinary user predicates.
3
3
 
4
+ % The materialized relations below show that built-ins can coexist with
5
+ % ordinary vocabulary predicates that happen to look namespace-like.
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
4
7
  materialize(value, 2).
5
8
  materialize(ok, 2).
6
9
  materialize(tail, 2).
7
10
  materialize(label, 2).
8
11
 
12
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
13
+ % Native operations are called through their canonical predicate names.
14
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
9
15
  value(nativeMath, X) :- add(0.125, 0.875, X).
10
16
  ok(nativeCompare, true) :- lt(2, 3).
11
17
  ok(nativeString, true) :- matches("scoped retail insight", "retail|medical").
12
18
  tail(nativeList, Tail) :- rest([a, b, c], Tail).
13
19
 
20
+ % These names are just user data; eyelang does not give them special meaning.
14
21
  example_label(vocabularyExample, "vocabulary names are ordinary predicate names").
15
22
  label(vocabularyExample, Text) :- example_label(vocabularyExample, Text).
@@ -4,6 +4,7 @@
4
4
  % broader/narrower alignments, their transitive closure, the reflexive
5
5
  % narrower-or-equal relation, and the concepts that roll up to ref_car.
6
6
 
7
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
7
8
  materialize(broader, 2).
8
9
  materialize(narrower, 2).
9
10
  materialize(broaderTransitive, 2).
@@ -11,6 +12,7 @@ materialize(narrowerTransitive, 2).
11
12
  materialize(narrowerOrEqualOf, 2).
12
13
  materialize(rollsUpTo, 2).
13
14
 
15
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
14
16
  concept(ref_car).
15
17
  concept(tel_car).
16
18
  concept(tel_heavy_vehicle).
@@ -22,6 +24,7 @@ assertedBroader(tel_heavy_vehicle, ref_car).
22
24
  assertedBroader(anpr_vehicle_with_plate, ref_car).
23
25
  assertedNarrower(anpr_vehicle_with_plate, anpr_passenger_car).
24
26
 
27
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
25
28
  broader(X, Y) :- assertedBroader(X, Y).
26
29
  broader(X, Y) :- assertedNarrower(Y, X).
27
30
 
@@ -4,11 +4,13 @@
4
4
  % The input interval table is a list of records, showing how tabular data can
5
5
  % stay scoped as one term instead of many unrelated global start/end facts.
6
6
 
7
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
7
8
  materialize(start, 2).
8
9
  materialize(end, 2).
9
10
  materialize(duration, 2).
10
11
  materialize(statement, 3).
11
12
 
13
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
12
14
  interval_table([
13
15
  interval(a, 10, 12),
14
16
  interval(b, 13, 15),
@@ -23,6 +25,7 @@ interval_table([
23
25
  interval(k, 13, 14)
24
26
  ]).
25
27
 
28
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
26
29
  interval(I) :- interval_table(Table), member(interval(I, _Start, _End), Table).
27
30
  start(I, Start) :- interval_table(Table), member(interval(I, Start, _End), Table).
28
31
  end(I, End) :- interval_table(Table), member(interval(I, _Start, End), Table).
@@ -1,14 +1,21 @@
1
1
  % Basic recursive relation example.
2
+ % Both input facts and derived recursive answers are printed.
3
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
2
4
  materialize(parent, 2).
3
5
  materialize(ancestor, 2).
4
6
 
7
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
8
+ % Direct parent facts form a simple chain.
5
9
  parent(pat, jan).
6
10
  parent(jan, lies).
7
11
  parent(lies, emma).
8
12
 
13
+ % Base case: every parent is also an ancestor.
14
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
9
15
  ancestor(X, Y) :-
10
16
  parent(X, Y).
11
17
 
18
+ % Recursive case: walk one parent edge and continue through the chain.
12
19
  ancestor(X, Z) :-
13
20
  parent(X, Y),
14
21
  ancestor(Y, Z).
@@ -3,13 +3,16 @@
3
3
  % The Eyelet source uses Unicode predicate names; this eyelang version keeps the
4
4
  % same tiny inheritance idea with plain vocabulary names.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(type, 2).
7
8
  materialize(subclassOf, 2).
8
9
  materialize(succeeds, 2).
9
10
 
11
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
10
12
  human(joe).
11
13
  animal(human).
12
14
 
15
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
13
16
  animal(X) :- human(X).
14
17
 
15
18
  type(joe, human) :- human(joe).
@@ -3,17 +3,20 @@
3
3
  % The program keeps the annotation as data and derives visible relations from it.
4
4
  % Formula members become default output only when explicit rules project them.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(name, 2).
7
8
  materialize(log_nameOf, 2).
8
9
  materialize(statedBy, 2).
9
10
  materialize(recorded, 2).
10
11
 
12
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
11
13
  annotation(t, (
12
14
  name(a, "Alice"),
13
15
  statedBy(t, bob),
14
16
  recorded(t, "2021-07-07")
15
17
  )).
16
18
 
19
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
17
20
  name(S, O) :-
18
21
  annotation(_T, Formula),
19
22
  formula_binary(Formula, S, name, O).
@@ -3,6 +3,7 @@
3
3
  % translation materializes the policy decisions, reasons, traces, and ARC-style
4
4
  % check values as ordinary relation output.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(label, 2).
7
8
  materialize(description, 2).
8
9
  materialize(careTeamLinked, 2).
@@ -24,9 +25,11 @@ materialize(checkC8, 2).
24
25
  materialize(checkC9, 2).
25
26
  materialize(checkC10Text, 2).
26
27
 
28
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
27
29
  caseName(case, "auroracare").
28
30
  question(case, "For each AuroraCare scenario, should the PDP permit or deny the requested use of health data, and why?").
29
31
 
32
+ % Policies: primary care, quality improvement, research, and an explicit denial.
30
33
  policyUid(policyPrimary, "urn:policy:primary-care-001").
31
34
  purposeAllowed(policyPrimary, primaryCareManagement).
32
35
  purposeAllowed(policyPrimary, patientRemoteMonitoring).
@@ -64,6 +67,7 @@ primaryPurpose(auroracare, primaryCareManagement).
64
67
  primaryPurpose(auroracare, patientRemoteMonitoring).
65
68
  prohibitedPurpose(auroracare, insuranceManagement).
66
69
 
70
+ % Scenarios A-G mirror the upstream Markdown report cases.
67
71
  scenario(scenarioA).
68
72
  outputKey(scenarioA, out010A).
69
73
  scenario_label(scenarioA, "A – Primary care visit").
@@ -145,6 +149,7 @@ environment(scenarioG, "secure_env").
145
149
  category(scenarioG, patientSummary).
146
150
  category(scenarioG, labResults).
147
151
 
152
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
148
153
  label(S, Label) :- scenario_label(S, Label).
149
154
  description(S, Description) :- scenario_description(S, Description).
150
155
 
@@ -195,9 +200,11 @@ careTeamLinked(S, true) :- care_team_linked(S).
195
200
  subjectOptIn(S, true) :- subject_opt_in(S).
196
201
  subjectOptOut(S, true) :- subject_opt_out(S).
197
202
 
203
+ % Permit when a scenario satisfies one of the allowed policy branches.
198
204
  decision(S, "PERMIT") :- primary_policy_match(S).
199
205
  decision(S, "PERMIT") :- qi_policy_match(S).
200
206
  decision(S, "PERMIT") :- research_policy_match(S).
207
+ % Deny branches preserve the reason that will be materialized for the report.
201
208
  decision(S, "DENY") :- insurance_prohibition_match(S).
202
209
  decision(S, "DENY") :- ai_training_opt_out_match(S).
203
210
  decision(scenarioC, "DENY") :- purpose(scenarioC, ensureQualitySafetyHealthcare).
@@ -223,6 +230,7 @@ trace(S, "urn:policy:deny-insurance:deny:odrl:prohibition_matched") :- insurance
223
230
  trace(S, "deny:subject_opted_out_ai_training") :- ai_training_opt_out_match(S).
224
231
  trace(scenarioC, "urn:policy:qi-2025-aurora:deny:odrl:no_permission_matched") :- purpose(scenarioC, ensureQualitySafetyHealthcare).
225
232
 
233
+ % C1-C10 below are the ARC-style checklist lines from the upstream output.
226
234
  checkC1(scenarioA, "SKIPPED - not a prohibited purpose") :- decision(scenarioA, "PERMIT").
227
235
  checkC2(scenarioA, "OK - clinician") :- decision(scenarioA, "PERMIT").
228
236
  checkC3(scenarioA, "OK - care-team linked") :- decision(scenarioA, "PERMIT").
@@ -1,9 +1,12 @@
1
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
1
2
  materialize(isIndeedMoreInterestingThan, 2).
2
3
 
4
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
3
5
  % Backward rule example adapted from Eyeling backward.n3.
4
6
  % Eyeling writes the interestingness rule backward; eyelang records the same
5
7
  % relation as an ordinary rule whose body is the numeric comparison.
6
8
 
9
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
7
10
  moreInterestingThan(X, Y) :- gt(X, Y).
8
11
 
9
12
  isIndeedMoreInterestingThan(5, 3) :- moreInterestingThan(5, 3).
@@ -8,8 +8,10 @@
8
8
  % EYE reasoning/basic-monadic/10tt_answer.n3 in cardinality and content
9
9
  % after translating N3 statements to eyelang relation terms.
10
10
 
11
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
11
12
  materialize(cycle, 2).
12
13
 
14
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
13
15
  edge(i30, i12, i33).
14
16
  edge(i61, i29, i42).
15
17
  edge(i57, i46, i87).
@@ -10011,6 +10013,6 @@ edge(i18, i75, i36).
10011
10013
  edge(i48, i89, i48).
10012
10014
  edge(i26, i42, i54).
10013
10015
 
10016
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
10014
10017
  cycle(R, Cycle) :-
10015
10018
  fixed_length_cycle(edge, 10, R, Cycle).
10016
-
@@ -4,6 +4,7 @@
4
4
  % points, so this example is comparable with examples/output/bayes-diagnosis.n3
5
5
  % in the Eyeling repository.
6
6
 
7
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
7
8
  materialize(scores, 2).
8
9
  materialize(evidenceTotal, 2).
9
10
  materialize(result, 2).
@@ -11,6 +12,7 @@ materialize(disease, 2).
11
12
  materialize(unnormalized, 2).
12
13
  materialize(posterior, 2).
13
14
 
15
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
14
16
  disease(covid19).
15
17
  disease(influenza).
16
18
  disease(allergicRhinitis).
@@ -53,6 +55,7 @@ evidence([
53
55
  ev(shortBreath, true)
54
56
  ]).
55
57
 
58
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
56
59
  factor(Disease, Symptom, true, P) :- p_given(Disease, Symptom, P).
57
60
  factor(Disease, Symptom, false, Q) :-
58
61
  p_given(Disease, Symptom, P),
@@ -1,5 +1,6 @@
1
1
  % Memoize shared inference layers: the score vector, disease likelihood tails,
2
2
  % and expected therapy success are reused by several report relations.
3
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
3
4
  materialize(diseases, 2).
4
5
  materialize(therapies, 2).
5
6
  materialize(evidence, 2).
@@ -12,6 +13,7 @@ materialize(expectedAdverse, 2).
12
13
  materialize(utility, 2).
13
14
  materialize(recommendedTherapy, 2).
14
15
 
16
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
15
17
  memoize(scores_for, 2).
16
18
  memoize(likelihood, 3).
17
19
  memoize(expected_success, 2).
@@ -81,6 +83,7 @@ adverse(supportiveCare, 0.01).
81
83
  benefit_weight(10).
82
84
  harm_weight(3).
83
85
 
86
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
84
87
  factor(Disease, ev(Symptom, true), P) :- p_given(Disease, Symptom, P).
85
88
  factor(Disease, ev(Symptom, false), Q) :-
86
89
  p_given(Disease, Symptom, P),
@@ -2,18 +2,21 @@
2
2
  %
3
3
  % The tip deflection for a point load at the free end is F*L^3/(3*E*I).
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(tipDeflection_m, 2).
7
8
  materialize(tipDeflection_mm, 2).
8
9
  materialize(limit_mm, 2).
9
10
  materialize(status, 2).
10
11
 
12
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
11
13
  beam(beam1, force_N, 1200.0).
12
14
  beam(beam1, length_m, 2.5).
13
15
  beam(beam1, elasticModulus_Pa, 200000000000.0).
14
16
  beam(beam1, secondMoment_m4, 0.000008).
15
17
  limit(beam1, maxDeflection_mm, 5.0).
16
18
 
19
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
17
20
  tip_deflection_m(Beam, Deflection) :-
18
21
  beam(Beam, force_N, Force),
19
22
  beam(Beam, length_m, Length),
@@ -4,11 +4,13 @@
4
4
  % are sorted lists of on(Block, Support) facts so equality and visited-state
5
5
  % checks are purely structural.
6
6
 
7
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
7
8
  materialize(status, 2).
8
9
  materialize(plan, 2).
9
10
  materialize(finalState, 2).
10
11
  materialize(blockCount, 2).
11
12
 
13
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
12
14
  initial([on(a, table), on(b, a), on(c, b), on(d, c), on(e, d)]).
13
15
  goal([on(a, table), on(b, a), on(c, table), on(d, c), on(e, d)]).
14
16
 
@@ -19,6 +21,7 @@ block(d).
19
21
  block(e).
20
22
 
21
23
  support(table, _State).
24
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
22
25
  support(Block, State) :-
23
26
  block(Block),
24
27
  member(on(Block, _Below), State).
package/examples/bmi.pl CHANGED
@@ -7,6 +7,7 @@
7
7
  % For reproducibility and documentation only; not medical advice.
8
8
 
9
9
  % Editable metric input.
10
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
10
11
  materialize(unitSystem, 2).
11
12
  materialize(weight, 2).
12
13
  materialize(height, 2).
@@ -39,6 +40,7 @@ materialize(result, 2).
39
40
  materialize(healthyWeightRangeKg, 2).
40
41
  materialize(checkPassed, 2).
41
42
 
43
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
42
44
  unitSystem(input, metric).
43
45
  weight(input, 72.0).
44
46
  height(input, 178.0).
@@ -49,6 +51,7 @@ height(input, 178.0).
49
51
  % height(input, 70.08).
50
52
 
51
53
  % Normalization and BMI calculation.
54
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
52
55
  weightKg(case, W) :-
53
56
  unitSystem(input, metric),
54
57
  weight(input, W).
@@ -3,11 +3,13 @@
3
3
  % Four simplified models classify the same road scenarios. The example is not a
4
4
  % real safety calculator; it demonstrates rule-level model comparison.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(safeInWorld, 2).
7
8
  materialize(riskyInWorld, 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
  scenario(city_dry, 13.9, 0.8, 40.0).
12
14
  scenario(highway_dry_short_gap, 27.8, 0.8, 60.0).
13
15
  scenario(city_wet, 13.9, 0.4, 40.0).
@@ -18,6 +20,7 @@ world(w1, "simplified braking-only rule without reaction time").
18
20
  world(w2, "naive dry-road friction assumption").
19
21
  world(w3, "cautious factor over the physics model").
20
22
 
23
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
21
24
  stop_distance(Scenario, w0, Distance) :-
22
25
  scenario(Scenario, V, Mu, Avail),
23
26
  mul(V, 1.0, Reaction),