eyeling 1.16.3 → 1.16.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 (61) hide show
  1. package/HANDBOOK.md +153 -0
  2. package/README.md +0 -1
  3. package/examples/auroracare.n3 +528 -0
  4. package/examples/control-system.n3 +223 -47
  5. package/examples/delfour.n3 +409 -0
  6. package/examples/gps.n3 +144 -53
  7. package/examples/ill-formed-literals.n3 +195 -0
  8. package/examples/output/auroracare.n3 +118 -0
  9. package/examples/output/control-system.n3 +24 -1
  10. package/examples/output/delfour.n3 +40 -0
  11. package/examples/output/gps.n3 +14 -2
  12. package/examples/output/ill-formed-literals.n3 +27 -0
  13. package/examples/output/parcellocker.n3 +15 -0
  14. package/examples/parcellocker.n3 +164 -0
  15. package/eyeling.js +16 -1
  16. package/lib/engine.js +14 -1
  17. package/lib/prelude.js +2 -0
  18. package/package.json +2 -3
  19. package/arctifacts/README.md +0 -59
  20. package/arctifacts/ackermann.html +0 -678
  21. package/arctifacts/auroracare.html +0 -1297
  22. package/arctifacts/bike-trip.html +0 -752
  23. package/arctifacts/binomial-theorem.html +0 -631
  24. package/arctifacts/bmi.html +0 -511
  25. package/arctifacts/building-performance.html +0 -750
  26. package/arctifacts/clinical-care.html +0 -726
  27. package/arctifacts/collatz.html +0 -403
  28. package/arctifacts/complex.html +0 -321
  29. package/arctifacts/control-system.html +0 -482
  30. package/arctifacts/delfour.html +0 -849
  31. package/arctifacts/earthquake-epicenter.html +0 -982
  32. package/arctifacts/eco-route.html +0 -662
  33. package/arctifacts/euclid-infinitude.html +0 -564
  34. package/arctifacts/euler-identity.html +0 -667
  35. package/arctifacts/exoplanet-transit.html +0 -1000
  36. package/arctifacts/faltings-theorem.html +0 -1046
  37. package/arctifacts/fibonacci.html +0 -299
  38. package/arctifacts/fundamental-theorem-arithmetic.html +0 -398
  39. package/arctifacts/godel-numbering.html +0 -743
  40. package/arctifacts/gps-bike.html +0 -759
  41. package/arctifacts/gps-clinical-bench.html +0 -792
  42. package/arctifacts/graph-french.html +0 -449
  43. package/arctifacts/grass-molecular.html +0 -592
  44. package/arctifacts/group-theory.html +0 -740
  45. package/arctifacts/health-info.html +0 -833
  46. package/arctifacts/kaprekar-constant.html +0 -576
  47. package/arctifacts/lee.html +0 -805
  48. package/arctifacts/linked-lists.html +0 -502
  49. package/arctifacts/lldm.html +0 -612
  50. package/arctifacts/matrix-multiplication.html +0 -502
  51. package/arctifacts/matrix.html +0 -651
  52. package/arctifacts/newton-raphson.html +0 -944
  53. package/arctifacts/peano-factorial.html +0 -456
  54. package/arctifacts/pi.html +0 -363
  55. package/arctifacts/polynomial.html +0 -646
  56. package/arctifacts/prime.html +0 -366
  57. package/arctifacts/pythagorean-theorem.html +0 -468
  58. package/arctifacts/rest-path.html +0 -469
  59. package/arctifacts/roots-of-unity.html +0 -363
  60. package/arctifacts/turing.html +0 -409
  61. package/arctifacts/wind-turbines.html +0 -726
@@ -0,0 +1,15 @@
1
+ @prefix : <https://example.org/parcellocker#> .
2
+ @prefix log: <http://www.w3.org/2000/10/swap/log#> .
3
+
4
+ :case :checkC8 :Passed .
5
+ :case :checkC6 :Passed .
6
+ :case :checkC7 :Passed .
7
+ :case :checkC9 :Passed .
8
+ :case :checkC10 :Passed .
9
+ :case :checkC1 :Passed .
10
+ :case :checkC2 :Passed .
11
+ :case :checkC3 :Passed .
12
+ :case :checkC4 :Passed .
13
+ :case :checkC5 :Passed .
14
+ :case :decision :Permit .
15
+ :out log:outputString "ParcelLocker — One-time parcel pickup by a friend\n\nAnswer\nPERMIT\nNoah may collect Maya's parcel from locker B17.\n\nReason Why\nMaya created a one-time authorization for Noah only, for this parcel only, at this locker only, and for pickup only. The token is active, the parcel is ready, and the same authorization does not reveal billing details or allow redirection.\n\nCheck\nC1 OK - requester matches the named delegate\nC2 OK - requested parcel matches the authorized parcel\nC3 OK - requested locker matches the authorized locker\nC4 OK - requested action is parcel collection\nC5 OK - requested purpose is pickup only\nC6 OK - authorization is active\nC7 OK - authorization is single-use\nC8 OK - parcel is ready for pickup\nC9 OK - billing details stay hidden\nC10 OK - parcel redirection is not allowed\n" .
@@ -0,0 +1,164 @@
1
+ # ===========================================================================
2
+ # ParcelLocker — One-time parcel pickup by a friend.
3
+ #
4
+ # This example shows how a person can let someone else collect a parcel without
5
+ # handing over their full shopping account. A one-time authorization is limited
6
+ # to one named person, one parcel, one locker, and one purpose: pickup. The
7
+ # locker may release the parcel, but the same authorization cannot be used to
8
+ # view billing details or redirect the parcel somewhere else.
9
+ # ===========================================================================
10
+
11
+ @prefix : <https://example.org/parcellocker#> .
12
+ @prefix log: <http://www.w3.org/2000/10/swap/log#> .
13
+
14
+ # -----
15
+ # Facts
16
+ # -----
17
+
18
+ :maya a :Person; :name "Maya" .
19
+ :noah a :Person; :name "Noah" .
20
+
21
+ :parcel123 a :Parcel;
22
+ :owner :maya;
23
+ :status :ReadyForPickup .
24
+
25
+ :lockerB17 a :Locker;
26
+ :site "Station West" .
27
+
28
+ :pickupToken a :PickupAuthorization;
29
+ :issuedBy :maya;
30
+ :delegate :noah;
31
+ :parcel :parcel123;
32
+ :locker :lockerB17;
33
+ :action :CollectParcel;
34
+ :purpose :PickupOnly;
35
+ :state :Active;
36
+ :reuse :SingleUse;
37
+ :billingAccess :None;
38
+ :redirectAllowed :No .
39
+
40
+ :pickupRequest a :Request;
41
+ :requester :noah;
42
+ :parcel :parcel123;
43
+ :locker :lockerB17;
44
+ :action :CollectParcel;
45
+ :purpose :PickupOnly .
46
+
47
+ # -----
48
+ # Logic
49
+ # -----
50
+
51
+ { :pickupToken :delegate ?who .
52
+ :pickupRequest :requester ?who . }
53
+ => { :case :checkC1 :Passed . } .
54
+
55
+ { :pickupToken :parcel ?parcel .
56
+ :pickupRequest :parcel ?parcel . }
57
+ => { :case :checkC2 :Passed . } .
58
+
59
+ { :pickupToken :locker ?locker .
60
+ :pickupRequest :locker ?locker . }
61
+ => { :case :checkC3 :Passed . } .
62
+
63
+ { :pickupToken :action ?action .
64
+ :pickupRequest :action ?action . }
65
+ => { :case :checkC4 :Passed . } .
66
+
67
+ { :pickupToken :purpose ?purpose .
68
+ :pickupRequest :purpose ?purpose . }
69
+ => { :case :checkC5 :Passed . } .
70
+
71
+ { :pickupToken :state :Active . }
72
+ => { :case :checkC6 :Passed . } .
73
+
74
+ { :pickupToken :reuse :SingleUse . }
75
+ => { :case :checkC7 :Passed . } .
76
+
77
+ { :parcel123 :status :ReadyForPickup . }
78
+ => { :case :checkC8 :Passed . } .
79
+
80
+ { :pickupToken :billingAccess :None . }
81
+ => { :case :checkC9 :Passed . } .
82
+
83
+ { :pickupToken :redirectAllowed :No . }
84
+ => { :case :checkC10 :Passed . } .
85
+
86
+ { :case :checkC1 :Passed .
87
+ :case :checkC2 :Passed .
88
+ :case :checkC3 :Passed .
89
+ :case :checkC4 :Passed .
90
+ :case :checkC5 :Passed .
91
+ :case :checkC6 :Passed .
92
+ :case :checkC7 :Passed .
93
+ :case :checkC8 :Passed .
94
+ :case :checkC9 :Passed .
95
+ :case :checkC10 :Passed . }
96
+ => { :case :decision :Permit . } .
97
+
98
+ # ------------------
99
+ # Presentation (ARC)
100
+ # ------------------
101
+
102
+ { :case :decision :Permit . }
103
+ => {
104
+ :out log:outputString "ParcelLocker — One-time parcel pickup by a friend\n\nAnswer\nPERMIT\nNoah may collect Maya's parcel from locker B17.\n\nReason Why\nMaya created a one-time authorization for Noah only, for this parcel only, at this locker only, and for pickup only. The token is active, the parcel is ready, and the same authorization does not reveal billing details or allow redirection.\n\nCheck\nC1 OK - requester matches the named delegate\nC2 OK - requested parcel matches the authorized parcel\nC3 OK - requested locker matches the authorized locker\nC4 OK - requested action is parcel collection\nC5 OK - requested purpose is pickup only\nC6 OK - authorization is active\nC7 OK - authorization is single-use\nC8 OK - parcel is ready for pickup\nC9 OK - billing details stay hidden\nC10 OK - parcel redirection is not allowed\n" .
105
+ } .
106
+
107
+ # ----------------
108
+ # Fail-loud checks
109
+ # ----------------
110
+
111
+ { :case :decision :Permit .
112
+ :pickupRequest :requester ?r .
113
+ :pickupToken :delegate ?d .
114
+ ?r log:notEqualTo ?d . }
115
+ => false .
116
+
117
+ { :case :decision :Permit .
118
+ :pickupRequest :parcel ?requested .
119
+ :pickupToken :parcel ?authorized .
120
+ ?requested log:notEqualTo ?authorized . }
121
+ => false .
122
+
123
+ { :case :decision :Permit .
124
+ :pickupRequest :locker ?requested .
125
+ :pickupToken :locker ?authorized .
126
+ ?requested log:notEqualTo ?authorized . }
127
+ => false .
128
+
129
+ { :case :decision :Permit .
130
+ :pickupRequest :action ?requested .
131
+ :pickupToken :action ?authorized .
132
+ ?requested log:notEqualTo ?authorized . }
133
+ => false .
134
+
135
+ { :case :decision :Permit .
136
+ :pickupRequest :purpose ?requested .
137
+ :pickupToken :purpose ?authorized .
138
+ ?requested log:notEqualTo ?authorized . }
139
+ => false .
140
+
141
+ { :case :decision :Permit .
142
+ :pickupToken :state ?state .
143
+ ?state log:notEqualTo :Active . }
144
+ => false .
145
+
146
+ { :case :decision :Permit .
147
+ :pickupToken :reuse ?reuse .
148
+ ?reuse log:notEqualTo :SingleUse . }
149
+ => false .
150
+
151
+ { :case :decision :Permit .
152
+ :parcel123 :status ?status .
153
+ ?status log:notEqualTo :ReadyForPickup . }
154
+ => false .
155
+
156
+ { :case :decision :Permit .
157
+ :pickupToken :billingAccess ?access .
158
+ ?access log:notEqualTo :None . }
159
+ => false .
160
+
161
+ { :case :decision :Permit .
162
+ :pickupToken :redirectAllowed ?redirect .
163
+ ?redirect log:notEqualTo :No . }
164
+ => false .
package/eyeling.js CHANGED
@@ -4719,6 +4719,8 @@ const {
4719
4719
  MATH_NS,
4720
4720
  LOG_NS,
4721
4721
  SKOLEM_NS,
4722
+ MAX_LITERAL_TID_LEN,
4723
+ normalizeLiteralForTid,
4722
4724
  Literal,
4723
4725
  Iri,
4724
4726
  Var,
@@ -5627,7 +5629,18 @@ function __internCompoundTid(key) {
5627
5629
 
5628
5630
  function termFastKey(t) {
5629
5631
  // Atomic terms that already have a stable id.
5630
- if (t instanceof Iri || t instanceof Blank || t instanceof Literal) return t.__tid;
5632
+ if (t instanceof Iri || t instanceof Blank) return t.__tid;
5633
+
5634
+ if (t instanceof Literal) {
5635
+ // Very large literals intentionally skip global interning in prelude.js to
5636
+ // avoid retaining huge strings forever. Their per-object __tid is therefore
5637
+ // not value-stable, so using it here breaks duplicate detection for facts
5638
+ // such as long log:outputString blocks that are re-derived during forward
5639
+ // chaining. Fall back to a value-based key in that case.
5640
+ const norm = normalizeLiteralForTid(t.value);
5641
+ if (typeof norm === 'string' && norm.length > MAX_LITERAL_TID_LEN) return 'L:' + norm;
5642
+ return t.__tid;
5643
+ }
5631
5644
 
5632
5645
  // Structural fast key for strict-ground list terms.
5633
5646
  // We only index when every element has a fast key; otherwise return null.
@@ -10389,6 +10402,8 @@ module.exports = {
10389
10402
  RDF_JSON_DT,
10390
10403
  resolveIriRef,
10391
10404
  literalParts,
10405
+ normalizeLiteralForTid,
10406
+ MAX_LITERAL_TID_LEN,
10392
10407
  Term,
10393
10408
  Iri,
10394
10409
  Literal,
package/lib/engine.js CHANGED
@@ -13,6 +13,8 @@ const {
13
13
  MATH_NS,
14
14
  LOG_NS,
15
15
  SKOLEM_NS,
16
+ MAX_LITERAL_TID_LEN,
17
+ normalizeLiteralForTid,
16
18
  Literal,
17
19
  Iri,
18
20
  Var,
@@ -921,7 +923,18 @@ function __internCompoundTid(key) {
921
923
 
922
924
  function termFastKey(t) {
923
925
  // Atomic terms that already have a stable id.
924
- if (t instanceof Iri || t instanceof Blank || t instanceof Literal) return t.__tid;
926
+ if (t instanceof Iri || t instanceof Blank) return t.__tid;
927
+
928
+ if (t instanceof Literal) {
929
+ // Very large literals intentionally skip global interning in prelude.js to
930
+ // avoid retaining huge strings forever. Their per-object __tid is therefore
931
+ // not value-stable, so using it here breaks duplicate detection for facts
932
+ // such as long log:outputString blocks that are re-derived during forward
933
+ // chaining. Fall back to a value-based key in that case.
934
+ const norm = normalizeLiteralForTid(t.value);
935
+ if (typeof norm === 'string' && norm.length > MAX_LITERAL_TID_LEN) return 'L:' + norm;
936
+ return t.__tid;
937
+ }
925
938
 
926
939
  // Structural fast key for strict-ground list terms.
927
940
  // We only index when every element has a fast key; otherwise return null.
package/lib/prelude.js CHANGED
@@ -515,6 +515,8 @@ module.exports = {
515
515
  RDF_JSON_DT,
516
516
  resolveIriRef,
517
517
  literalParts,
518
+ normalizeLiteralForTid,
519
+ MAX_LITERAL_TID_LEN,
518
520
  Term,
519
521
  Iri,
520
522
  Literal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeling",
3
- "version": "1.16.3",
3
+ "version": "1.16.5",
4
4
  "description": "A minimal Notation3 (N3) reasoner in JavaScript.",
5
5
  "main": "./index.js",
6
6
  "keywords": [
@@ -30,8 +30,7 @@
30
30
  "lib",
31
31
  "test",
32
32
  "tools",
33
- "examples",
34
- "arctifacts"
33
+ "examples"
35
34
  ],
36
35
  "engines": {
37
36
  "node": ">=18"
@@ -1,59 +0,0 @@
1
- # ARCtifacts
2
-
3
- ARCtifacts are trustworthy programs telling a concise story in three parts. First comes the **Answer** to a specific question. This is followed by the **Reason Why** that answer is correct, articulated in everyday language and supported by the relevant identities, rules, or ideas. Finally, every case includes a **Check**—a concrete test designed to fail loudly if an assumption doesn't hold or an edge case bites. The result is a computation with a complete, auditable trail: you can see precisely what was done, why it was valid, and how the page verifies its own work.
4
-
5
- At the core of this approach are three familiar ingredients: **Data**, **Logic**, and a **Question**. We summarize the workflow as **P3 — Prompt → Program → Proof**: the prompt supplies the task and materials, the program turns them into a concrete, repeatable procedure, and the proof is practical rather than ceremonial, consisting of the **Reason Why** together with the **Check**. This is what makes each ARCtifact not just a result, but a portable, auditable, and trustworthy computational artifact.
6
-
7
- ## Science
8
-
9
- - [**Body Mass Index**](https://eyereasoner.github.io/eyeling/arctifacts/bmi.html) — Compute BMI categories with explainable thresholds and sanity checks.
10
- - [**Earthquake Epicenter**](https://eyereasoner.github.io/eyeling/arctifacts/earthquake-epicenter.html) — Infer an earthquake’s epicenter from P- and S-wave arrivals and verify with distance and timing checks.
11
- - [**Exoplanet Transit**](https://eyereasoner.github.io/eyeling/arctifacts/exoplanet-transit.html) — Infer a planet’s size and orbit from a transit light curve, with explainable formulas and consistency checks.
12
- - [**Grass Seed Germination**](https://eyereasoner.github.io/eyeling/arctifacts/grass-molecular.html) — Model germination states and transitions with rule checks.
13
- - [**Leg Length Discrepancy Measurement**](https://eyereasoner.github.io/eyeling/arctifacts/lldm.html) — Leg Length Discrepancy Measurement from four landmarks.
14
-
15
- ## Technology
16
-
17
- - [**Auroracare**](https://eyereasoner.github.io/eyeling/arctifacts/auroracare.html) — Purpose-based Medical Data Exchange.
18
- - [**Clinical Care Planning**](https://eyereasoner.github.io/eyeling/arctifacts/clinical-care.html) — Derive care plans from observations, guidelines, and policy constraints.
19
- - [**Delfour**](https://eyereasoner.github.io/eyeling/arctifacts/delfour.html) — Ruben Verborgh's "Inside the Insight Economy" case.
20
- - [**GPS Clinical Bench**](https://eyereasoner.github.io/eyeling/arctifacts/gps-clinical-bench.html) — Benchmark clinical decisions with transparent rules and audit trails.
21
- - [**Graph of French Cities**](https://eyereasoner.github.io/eyeling/arctifacts/graph-french.html) — Shortest paths and connectivity over a city graph with proofs.
22
- - [**Health Information Processing**](https://eyereasoner.github.io/eyeling/arctifacts/health-info.html) — Transform clinical payloads with typed rules and validation.
23
- - [**Linked Lists**](https://eyereasoner.github.io/eyeling/arctifacts/linked-lists.html) — Term logic example proved using Resolution.
24
- - [**REST-Path**](https://eyereasoner.github.io/eyeling/arctifacts/rest-path.html) — Explain link-following over REST resources; verify pre/post conditions.
25
- - [**Turing Machine**](https://eyereasoner.github.io/eyeling/arctifacts/turing.html) — Run tapes with explicit transitions; verify halting and tape contents.
26
-
27
- ## Engineering
28
-
29
- - [**Bike Trip Planning**](https://eyereasoner.github.io/eyeling/arctifacts/bike-trip.html) — Route priorities from hazards, preferences, and declarative JSON rules.
30
- - [**Building Performance**](https://eyereasoner.github.io/eyeling/arctifacts/building-performance.html) — Reason about energy/comfort metrics and verify rule-based outcomes.
31
- - [**Control System**](https://eyereasoner.github.io/eyeling/arctifacts/control-system.html) — Model simple feedback loops and verify stability/response conditions.
32
- - [**Eco-Route**](https://eyereasoner.github.io/eyeling/arctifacts/eco-route.html) — Pick lower-emission routes by fusing traffic, grade, and policy goals.
33
- - [**GPS Bike**](https://eyereasoner.github.io/eyeling/arctifacts/gps-bike.html) — GPS for bike trip Gent → Maasmechelen.
34
- - [**Lee**](https://eyereasoner.github.io/eyeling/arctifacts/lee.html) — Maze routing with Lee’s algorithm; trace optimal wavefront paths.
35
- - [**Wind-Turbine Maintenance**](https://eyereasoner.github.io/eyeling/arctifacts/wind-turbines.html) — Plan maintenance from telemetry and policies with auditable outcomes.
36
-
37
- ## Mathematics
38
-
39
- - [**Ackermann**](https://eyereasoner.github.io/eyeling/arctifacts/ackermann.html) — Compute A₂ with exact hyper-ops; print small, expand huge safely.
40
- - [**Binomial Theorem**](https://eyereasoner.github.io/eyeling/arctifacts/binomial-theorem.html) — Sum of all binomial coefficients.
41
- - [**Collatz**](https://eyereasoner.github.io/eyeling/arctifacts/collatz.html) — Generate trajectories and check invariants for the Collatz map.
42
- - [**Complex Identities**](https://eyereasoner.github.io/eyeling/arctifacts/complex.html) — Symbolic steps for complex-number equalities with auditable reasoning.
43
- - [**Euclid’s Infinitude of Primes**](https://eyereasoner.github.io/eyeling/arctifacts/euclid-infinitude.html) — Restate the theorem, explain Euclid’s one-line proof, and run computational checks.
44
- - [**Euler’s Identity**](https://eyereasoner.github.io/eyeling/arctifacts/euler-identity.html) — The most beautiful equation in mathematics.
45
- - [**Faltings' Theorem**](https://eyereasoner.github.io/eyeling/arctifacts/faltings-theorem.html) — Explore genus 0, 1, and 2 curves, and see why genus ≥ 2 leads to only finitely many rational points.
46
- - [**Fibonacci**](https://eyereasoner.github.io/eyeling/arctifacts/fibonacci.html) — Compute big Fₙ with fast-doubling recurrences and proof-style checks.
47
- - [**Fundamental Theorem of Arithmetic**](https://eyereasoner.github.io/eyeling/arctifacts/fundamental-theorem-arithmetic.html) — Every integer factors as a product of primes.
48
- - [**Gödel Numbering**](https://eyereasoner.github.io/eyeling/arctifacts/godel-numbering.html) — A classic Gödel numbering demonstrator.
49
- - [**Group Theory**](https://eyereasoner.github.io/eyeling/arctifacts/group-theory.html) — Verify closure, identity, inverses, and associativity on examples.
50
- - [**Kaprekar’s Constant**](https://eyereasoner.github.io/eyeling/arctifacts/kaprekar-constant.html) — Exhaustive sweep of every 4-digit state in Kaprekar’s routine.
51
- - [**Matrix Basics**](https://eyereasoner.github.io/eyeling/arctifacts/matrix.html) — Add/multiply/invert with dimension/property checks.
52
- - [**Matrix Multiplication**](https://eyereasoner.github.io/eyeling/arctifacts/matrix-multiplication.html) — Not commutative (AB ≠ BA).
53
- - [**Newton–Raphson**](https://eyereasoner.github.io/eyeling/arctifacts/newton-raphson.html) — Newton–Raphson method for root-finding.
54
- - [**Peano Factorial**](https://eyereasoner.github.io/eyeling/arctifacts/peano-factorial.html) — 5! = 120 proved via Resolution.
55
- - [**Pi**](https://eyereasoner.github.io/eyeling/arctifacts/pi.html) — High-precision π via Chudnovsky series with error-bound checks.
56
- - [**Polynomial Roots**](https://eyereasoner.github.io/eyeling/arctifacts/polynomial.html) — Find all roots simultaneously; prove convergence on typical cases.
57
- - [**Primes**](https://eyereasoner.github.io/eyeling/arctifacts/prime.html) — Generate/test primes; log certs (trial factors or proofs) as checks.
58
- - [**Pythagorean Theorem**](https://eyereasoner.github.io/eyeling/arctifacts/pythagorean-theorem.html) — Compute legs/hypotenuse and confirm with algebraic or area proofs.
59
- - [**Roots of Unity**](https://eyereasoner.github.io/eyeling/arctifacts/roots-of-unity.html) — Place complex n-th roots on the unit circle; check spacing and sums/products.