eyelang 1.5.3 → 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 (134) hide show
  1. package/examples/access-control-policy.pl +3 -0
  2. package/examples/ackermann.pl +3 -0
  3. package/examples/age.pl +3 -0
  4. package/examples/aliases-and-namespaces.pl +7 -0
  5. package/examples/alignment-demo.pl +3 -0
  6. package/examples/allen-interval-calculus.pl +3 -0
  7. package/examples/ancestor.pl +7 -0
  8. package/examples/animal.pl +3 -0
  9. package/examples/annotation.pl +3 -0
  10. package/examples/auroracare.pl +8 -0
  11. package/examples/backward.pl +3 -0
  12. package/examples/basic-monadic.pl +3 -1
  13. package/examples/bayes-diagnosis.pl +3 -0
  14. package/examples/bayes-therapy.pl +3 -0
  15. package/examples/beam-deflection.pl +3 -0
  16. package/examples/blocks-world-planning.pl +3 -0
  17. package/examples/bmi.pl +3 -0
  18. package/examples/braking-safety-worlds.pl +3 -0
  19. package/examples/buck-converter-design.pl +3 -0
  20. package/examples/cache-performance.pl +3 -0
  21. package/examples/canary-release.pl +3 -0
  22. package/examples/cat-koko.pl +3 -0
  23. package/examples/clinical-trial-screening.pl +3 -0
  24. package/examples/collatz-1000.pl +3 -0
  25. package/examples/combinatorics-findall-sort.pl +6 -0
  26. package/examples/competitive-enzyme-kinetics.pl +3 -0
  27. package/examples/complex-matrix-stability.pl +3 -0
  28. package/examples/complex.pl +3 -0
  29. package/examples/composition-of-injective-functions-is-injective.pl +3 -0
  30. package/examples/context-association.pl +3 -0
  31. package/examples/control-system.pl +3 -0
  32. package/examples/cryptarithmetic-send-more-money.pl +3 -0
  33. package/examples/cyclic-path.pl +3 -1
  34. package/examples/d3-group.pl +8 -0
  35. package/examples/dairy-energy-balance.pl +3 -0
  36. package/examples/data-negotiation.pl +6 -0
  37. package/examples/deep-taxonomy-10.pl +3 -0
  38. package/examples/deep-taxonomy-100.pl +3 -0
  39. package/examples/deep-taxonomy-1000.pl +3 -0
  40. package/examples/deep-taxonomy-10000.pl +3 -0
  41. package/examples/deep-taxonomy-100000.pl +3 -0
  42. package/examples/delfour.pl +7 -0
  43. package/examples/dense-hamiltonian-cycle.pl +3 -0
  44. package/examples/deontic-logic.pl +6 -0
  45. package/examples/derived-backward-rule.pl +3 -0
  46. package/examples/derived-rule.pl +3 -0
  47. package/examples/diamond-property.pl +3 -0
  48. package/examples/dijkstra-findall-sort.pl +6 -0
  49. package/examples/dijkstra-risk-path.pl +3 -0
  50. package/examples/dijkstra.pl +3 -0
  51. package/examples/dining-philosophers.pl +3 -0
  52. package/examples/dog.pl +5 -0
  53. package/examples/drone-corridor-planner.pl +3 -0
  54. package/examples/easter-computus.pl +6 -0
  55. package/examples/electrical-rc-filter.pl +3 -0
  56. package/examples/epidemic-policy.pl +6 -0
  57. package/examples/equivalence-classes-overlap-implies-same-class.pl +3 -0
  58. package/examples/eulerian-path.pl +6 -0
  59. package/examples/ev-range-worlds.pl +3 -0
  60. package/examples/exact-cover-sudoku.pl +3 -0
  61. package/examples/existential-rule.pl +3 -0
  62. package/examples/exoplanet-validation-worlds.pl +3 -0
  63. package/examples/expression-eval.pl +5 -0
  64. package/examples/family-cousins.pl +3 -0
  65. package/examples/fastpow.pl +5 -0
  66. package/examples/fft8-numeric.pl +6 -0
  67. package/examples/fibonacci.pl +3 -0
  68. package/examples/field-nitrogen-balance.pl +3 -0
  69. package/examples/flandor.pl +9 -0
  70. package/examples/floating-point.pl +5 -0
  71. package/examples/four-color-map.pl +3 -0
  72. package/examples/fundamental-theorem-arithmetic.pl +3 -0
  73. package/examples/gcd-bezout-identity.pl +3 -0
  74. package/examples/gd-step-certified.pl +3 -0
  75. package/examples/gdpr-compliance.pl +6 -0
  76. package/examples/goldbach-1000.pl +3 -0
  77. package/examples/good-cobbler.pl +3 -0
  78. package/examples/gps.pl +3 -0
  79. package/examples/graph-reachability.pl +3 -0
  80. package/examples/gray-code-counter.pl +6 -0
  81. package/examples/greatest-lower-bound-uniqueness.pl +3 -0
  82. package/examples/group-inverse-uniqueness.pl +3 -0
  83. package/examples/hamiltonian-cycle.pl +3 -0
  84. package/examples/hamiltonian-path.pl +3 -0
  85. package/examples/hamming-code.pl +3 -0
  86. package/examples/hanoi.pl +3 -0
  87. package/examples/heat-loss.pl +3 -0
  88. package/examples/heron-theorem.pl +5 -0
  89. package/examples/ideal-gas-law.pl +3 -0
  90. package/examples/illegitimate-reasoning.pl +3 -0
  91. package/examples/kaprekar.pl +3 -0
  92. package/examples/law-of-cosines.pl +5 -0
  93. package/examples/least-squares-regression.pl +3 -0
  94. package/examples/list-collection.pl +5 -0
  95. package/examples/lldm.pl +3 -0
  96. package/examples/manufacturing-quality-control.pl +3 -0
  97. package/examples/matrix.pl +3 -0
  98. package/examples/microgrid-dispatch.pl +3 -0
  99. package/examples/monkey-bananas.pl +3 -0
  100. package/examples/n-queens.pl +3 -0
  101. package/examples/network-sla.pl +3 -0
  102. package/examples/newton-raphson.pl +3 -0
  103. package/examples/nixon-diamond.pl +3 -0
  104. package/examples/odrl-dpv-healthcare-risk-ranked.pl +3 -0
  105. package/examples/odrl-dpv-risk-ranked.pl +3 -0
  106. package/examples/orbital-transfer-design.pl +3 -0
  107. package/examples/path-discovery.pl +3 -0
  108. package/examples/peano-arithmetic.pl +3 -0
  109. package/examples/peasant.pl +5 -0
  110. package/examples/pendulum-period.pl +3 -0
  111. package/examples/polynomial.pl +3 -0
  112. package/examples/project-portfolio-optimization.pl +3 -0
  113. package/examples/proof-contrapositive.pl +3 -0
  114. package/examples/quadratic-formula.pl +3 -0
  115. package/examples/quine-mccluskey.pl +3 -0
  116. package/examples/radioactive-decay.pl +3 -0
  117. package/examples/sat-dpll.pl +3 -0
  118. package/examples/security-incident-correlation.pl +3 -0
  119. package/examples/service-impact.pl +3 -0
  120. package/examples/sieve.pl +3 -0
  121. package/examples/skolem-functions.pl +3 -0
  122. package/examples/socket-age.pl +3 -0
  123. package/examples/socket-family.pl +3 -0
  124. package/examples/socrates.pl +3 -0
  125. package/examples/statistics-summary.pl +3 -0
  126. package/examples/sudoku.pl +3 -0
  127. package/examples/superdense-coding.pl +3 -0
  128. package/examples/traveling-salesman.pl +6 -0
  129. package/examples/turing.pl +3 -0
  130. package/examples/vector-similarity.pl +6 -0
  131. package/examples/witch.pl +3 -0
  132. package/examples/wolf-goat-cabbage.pl +3 -0
  133. package/examples/zebra.pl +3 -0
  134. package/package.json +1 -1
@@ -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),
@@ -3,6 +3,7 @@
3
3
  % A simplified continuous-conduction buck converter model computes duty cycle,
4
4
  % inductor ripple current, capacitor ripple voltage, and checks design limits.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(dutyCycle, 2).
7
8
  materialize(inductorRipple_A, 2).
8
9
  materialize(rippleRatio, 2).
@@ -10,6 +11,7 @@ materialize(capacitorRipple_V, 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
  converter(regulator1, inputVoltage_V, 24.0).
14
16
  converter(regulator1, outputVoltage_V, 5.0).
15
17
  converter(regulator1, loadCurrent_A, 2.0).
@@ -19,6 +21,7 @@ converter(regulator1, capacitance_F, 0.000047).
19
21
  limit(regulator1, maxRippleRatio, 0.30).
20
22
  limit(regulator1, maxOutputRipple_V, 0.05).
21
23
 
24
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
22
25
  duty_cycle(Converter, Duty) :-
23
26
  converter(Converter, outputVoltage_V, OutputVoltage),
24
27
  converter(Converter, inputVoltage_V, InputVoltage),
@@ -4,15 +4,18 @@
4
4
  % rules compute hit rate and weighted average latency, then classify whether
5
5
  % the cache is effective.
6
6
 
7
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
7
8
  materialize(hitRate, 2).
8
9
  materialize(averageLatency_ms, 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
  cache_sample(api_cache, 8600.0, 1400.0, 5.0, 80.0).
13
15
  threshold(api_cache, minimum_hit_rate, 0.80).
14
16
  threshold(api_cache, maximum_average_latency_ms, 20.0).
15
17
 
18
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
16
19
  total_requests(Cache, Total) :-
17
20
  cache_sample(Cache, Hits, Misses, _HitLatency, _MissLatency),
18
21
  add(Hits, Misses, Total).
@@ -3,16 +3,19 @@
3
3
  % A canary deployment is rolled back when its measured error rate exceeds the
4
4
  % allowed budget, even when latency is still acceptable.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(errorRate, 2).
7
8
  materialize(p95Latency_ms, 2).
8
9
  materialize(latencyCheck, 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
  canary(canary42, 5000.0, 75.0, 180.0).
13
15
  threshold(canary42, maximum_error_rate, 0.01).
14
16
  threshold(canary42, maximum_p95_latency_ms, 200.0).
15
17
 
18
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
16
19
  error_rate(Release, Rate) :-
17
20
  canary(Release, Requests, Errors, _P95Latency),
18
21
  div(Errors, Requests, Rate).
@@ -4,14 +4,17 @@
4
4
  % node constructor in the portable core, so this adaptation names those
5
5
  % witnesses sk_0 and sk_1.
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(is, 2).
9
10
 
11
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
10
12
  animal(koko).
11
13
 
12
14
  witness(cat, sk_0).
13
15
  witness(british_short_hair, sk_1).
14
16
 
17
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
15
18
  type(X, cat) :- animal(koko), witness(cat, X).
16
19
  type(X, british_short_hair) :- animal(koko), witness(british_short_hair, X).
17
20
 
@@ -4,10 +4,12 @@
4
4
  % predicates keep the inclusion/exclusion logic separate from the concise
5
5
  % public relation report.
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(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
  patient(p001).
12
14
  patient(p002).
13
15
  patient(p003).
@@ -35,6 +37,7 @@ lab(p004, egfr_ml_min, 72.0).
35
37
 
36
38
  condition(p003, pregnant).
37
39
 
40
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
38
41
  inclusion_adult(Patient) :-
39
42
  patient(Patient),
40
43
  age(Patient, Age),
@@ -1,11 +1,14 @@
1
1
  % Memoize trajectories because different start values quickly merge into
2
2
  % shared Collatz tails.
3
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
3
4
  materialize(collatzTrajectory, 2).
4
5
 
6
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
5
7
  % Collatz trajectory benchmark adapted from Eyeling collatz-1000.n3.
6
8
  % The reusable builtin keeps this large output example focused on data volume
7
9
  % rather than recursive integer arithmetic overhead.
8
10
 
11
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
9
12
  collatzTrajectory(N, Trajectory) :-
10
13
  between(1, 1000, N),
11
14
  collatz_trajectory(N, Trajectory).
@@ -1,14 +1,19 @@
1
1
  % Eyelet-inspired combinations example using findall/3 and sort/2.
2
2
  % The source-level select/3 relation remains an ordinary eyelang rule.
3
3
 
4
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
4
5
  materialize(combinations, 2).
5
6
  materialize(count, 2).
6
7
  materialize(reason, 2).
7
8
 
9
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
10
+ % select/3 nondeterministically removes one item from a list.
8
11
  select(Item, [Item | Rest], Rest).
12
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
9
13
  select(Item, [Head | Tail], [Head | Rest]) :-
10
14
  select(Item, Tail, Rest).
11
15
 
16
+ % combination/3 builds an unordered K-combination by repeated selection.
12
17
  combination(0, _Items, []).
13
18
  combination(I, Items, Combination) :-
14
19
  gt(I, 0),
@@ -17,6 +22,7 @@ combination(I, Items, Combination) :-
17
22
  combination(J, Remaining, Partial),
18
23
  sort([Item | Partial], Combination).
19
24
 
25
+ % findall collects all generation orders; sort canonicalizes and deduplicates.
20
26
  unique_combinations(K, Items, Unique) :-
21
27
  findall(C, combination(K, Items, C), All),
22
28
  sort(All, Unique).
@@ -4,6 +4,7 @@
4
4
  % Km_effective = Km * (1 + Inhibitor / Ki)
5
5
  % rate = Vmax * Substrate / (Km_effective + Substrate)
6
6
 
7
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
7
8
  materialize(effectiveKm_uM, 2).
8
9
  materialize(uninhibitedRate_uM_s, 2).
9
10
  materialize(inhibitedRate_uM_s, 2).
@@ -11,6 +12,7 @@ materialize(inhibitionFraction, 2).
11
12
  materialize(status, 2).
12
13
  materialize(reason, 2).
13
14
 
15
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
14
16
  assay(assay1, vmax_uM_s, 120.0).
15
17
  assay(assay1, substrate_uM, 50.0).
16
18
  assay(assay1, km_uM, 30.0).
@@ -18,6 +20,7 @@ assay(assay1, inhibitor_uM, 10.0).
18
20
  assay(assay1, ki_uM, 5.0).
19
21
  threshold(assay1, significant_inhibition_fraction, 0.25).
20
22
 
23
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
21
24
  competitive_multiplier(Assay, Multiplier) :-
22
25
  assay(Assay, inhibitor_uM, Inhibitor),
23
26
  assay(Assay, ki_uM, Ki),
@@ -3,14 +3,17 @@
3
3
  % trace < 0 and determinant > 0. A negative discriminant indicates a
4
4
  % complex-conjugate eigenvalue pair.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(trace, 2).
7
8
  materialize(determinant, 2).
8
9
  materialize(discriminant, 2).
9
10
  materialize(eigenShape, 2).
10
11
  materialize(status, 2).
11
12
 
13
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
12
14
  matrix(controller_loop, -0.7, 1.2, -0.4, -0.5).
13
15
 
16
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
14
17
  trace(Matrix, Trace) :-
15
18
  matrix(Matrix, A, _B, _C, D),
16
19
  add(A, D, Trace).
@@ -3,11 +3,14 @@
3
3
  % Complex values are represented as two-item lists [Real, Imaginary], matching
4
4
  % the pair-shaped pair lists used by the Eyeling source.
5
5
 
6
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
6
7
  materialize(is, 2).
7
8
 
9
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
8
10
  pi(3.141592653589793).
9
11
  e(2.718281828459045).
10
12
 
13
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
11
14
  complex_exponentiation([A, B], [C, D], [E, F]) :-
12
15
  complex_polar([A, B], [R, T]),
13
16
  pow(R, C, Z1),
@@ -4,14 +4,17 @@
4
4
  % The output mirrors the Eyeling golden result shape:
5
5
  % sameInputByCompositeInjectivity(h, a, b) and the symmetric counterpart.
6
6
 
7
+ % Output declarations: materialize/2 selects the relations written to this example's golden output.
7
8
  materialize(sameInputByCompositeInjectivity, 3).
8
9
 
10
+ % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
9
11
  inX(a).
10
12
  inX(b).
11
13
  inY(c).
12
14
  inY(d).
13
15
  inZ(e).
14
16
 
17
+ % Derivation rules: each rule below contributes one logical step toward the displayed results.
15
18
  sameTerm(X, X) :- inX(X).
16
19
  sameTerm(X, X) :- inY(X).
17
20
  sameTerm(X, X) :- inZ(X).