eyeling 1.15.13 → 1.16.0
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.
- package/HANDBOOK.md +25 -5
- package/README.md +78 -1
- package/arctifacts/README.md +57 -0
- package/eyeling.js +894 -9
- package/index.d.ts +184 -1
- package/index.js +17 -7
- package/lib/engine.js +92 -8
- package/lib/entry.js +3 -0
- package/lib/rdfjs.js +795 -0
- package/package.json +2 -2
- package/test/api.test.js +263 -0
- package/tools/bundle.js +1 -1
- package/follows-from/index.html +0 -549
- package/follows-from/library/index.md +0 -22
- package/follows-from/logo.svg +0 -12
- package/follows-from/manifesto.md +0 -48
- package/follows-from/method/index.md +0 -30
- package/follows-from/path/index.md +0 -20
- /package/{follows-from/artifacts → arctifacts}/ackermann.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/auroracare.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/bike-trip.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/binomial-theorem.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/bmi.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/building-performance.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/clinical-care.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/collatz.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/complex.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/control-system.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/delfour.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/earthquake-epicenter.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/eco-route.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/euclid-infinitude.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/euler-identity.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/exoplanet-transit.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/faltings-theorem.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/fibonacci.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/fundamental-theorem-arithmetic.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/godel-numbering.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/gps-bike.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/gps-clinical-bench.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/graph-french.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/grass-molecular.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/group-theory.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/health-info.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/kaprekar-constant.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/lee.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/linked-lists.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/lldm.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/matrix-multiplication.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/matrix.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/newton-raphson.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/peano-factorial.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/pi.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/polynomial.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/prime.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/pythagorean-theorem.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/rest-path.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/roots-of-unity.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/turing.html +0 -0
- /package/{follows-from/artifacts → arctifacts}/wind-turbines.html +0 -0
package/HANDBOOK.md
CHANGED
|
@@ -1747,6 +1747,13 @@ The engine’s `reasonStream` API can accept an `onDerived` callback. Each time
|
|
|
1747
1747
|
|
|
1748
1748
|
This is especially useful in interactive demos (and is the basis of the playground streaming tab).
|
|
1749
1749
|
|
|
1750
|
+
The same API can now also emit RDF/JS output. When `rdfjs: true` is passed, every `onDerived(...)` payload includes both:
|
|
1751
|
+
|
|
1752
|
+
- `triple` — Eyeling’s N3 string form
|
|
1753
|
+
- `quad` — the same fact as an RDF/JS default-graph quad
|
|
1754
|
+
|
|
1755
|
+
For fully stream-oriented RDF/JS consumers there is also `reasonRdfJs(...)`, which exposes the derived facts as an async iterable of RDF/JS quads.
|
|
1756
|
+
|
|
1750
1757
|
---
|
|
1751
1758
|
|
|
1752
1759
|
<a id="ch14"></a>
|
|
@@ -1783,22 +1790,35 @@ The current CLI supports a small set of flags (see `lib/cli.js`):
|
|
|
1783
1790
|
|
|
1784
1791
|
`lib/entry.js` exports:
|
|
1785
1792
|
|
|
1786
|
-
- public APIs: `reasonStream`, `main`, `version`
|
|
1793
|
+
- public APIs: `reasonStream`, `reasonRdfJs`, `rdfjs`, `main`, `version`
|
|
1787
1794
|
- plus a curated set of internals used by the demo (`lex`, `Parser`, `forwardChain`, etc.)
|
|
1788
1795
|
|
|
1796
|
+
`rdfjs` is a small built-in RDF/JS `DataFactory`, so browser / worker code can construct quads without pulling in another package first.
|
|
1797
|
+
|
|
1789
1798
|
### 14.3 `index.js`: the npm API wrapper
|
|
1790
1799
|
|
|
1791
1800
|
The npm `reason(...)` function does something intentionally simple and robust:
|
|
1792
1801
|
|
|
1793
|
-
-
|
|
1802
|
+
- normalize the JavaScript input into N3 text
|
|
1803
|
+
- write that N3 input to a temp file
|
|
1794
1804
|
- spawn the bundled CLI (`node eyeling.js ... input.n3`)
|
|
1795
1805
|
- return stdout (and forward stderr)
|
|
1796
1806
|
|
|
1797
|
-
This
|
|
1807
|
+
This keeps the observable output identical to the CLI while still allowing richer JS-side inputs.
|
|
1808
|
+
|
|
1809
|
+
In particular, the npm API now accepts:
|
|
1810
|
+
|
|
1811
|
+
- raw N3 strings
|
|
1812
|
+
- RDF/JS fact inputs (`quads`, `facts`, or `dataset`)
|
|
1813
|
+
- Eyeling rule objects or full AST bundles like `[prefixes, triples, frules, brules]`
|
|
1814
|
+
|
|
1815
|
+
For structured JavaScript input, rules are supplied as current Eyeling `Rule` / `Triple` object graphs or as JSON-serialized `--ast` output with `_type` markers.
|
|
1816
|
+
|
|
1817
|
+
If you want to use N3 source text, pass the whole input as a plain N3 string.
|
|
1798
1818
|
|
|
1799
|
-
One practical implication:
|
|
1819
|
+
One practical implication remains:
|
|
1800
1820
|
|
|
1801
|
-
- if you want _in-process_ access to the engine objects (facts arrays, derived proof objects), use `reasonStream` from the bundle entry rather than the subprocess-based API.
|
|
1821
|
+
- if you want _in-process_ access to the engine objects (facts arrays, derived proof objects), use `reasonStream` / `reasonRdfJs` from the bundle entry rather than the subprocess-based API.
|
|
1802
1822
|
|
|
1803
1823
|
---
|
|
1804
1824
|
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ A compact [Notation3 (N3)](https://notation3.org/) reasoner in **JavaScript**.
|
|
|
15
15
|
- **Semantics:** [https://eyereasoner.github.io/eyeling/SEMANTICS](https://eyereasoner.github.io/eyeling/SEMANTICS)
|
|
16
16
|
- **Playground:** [https://eyereasoner.github.io/eyeling/demo](https://eyereasoner.github.io/eyeling/demo)
|
|
17
17
|
- **Conformance report:** [https://codeberg.org/phochste/notation3tests/src/branch/main/reports/report.md](https://codeberg.org/phochste/notation3tests/src/branch/main/reports/report.md)
|
|
18
|
-
- **
|
|
18
|
+
- **ARCtifacts:** [https://eyereasoner.github.io/eyeling/arctifacts/](https://eyereasoner.github.io/eyeling/arctifacts/)
|
|
19
19
|
|
|
20
20
|
Eyeling is regularly checked against the community Notation3 test suite. If you want implementation details (parser, unifier, proof search, skolemization, scoped closure, builtins), start with the handbook.
|
|
21
21
|
|
|
@@ -99,6 +99,64 @@ Notes:
|
|
|
99
99
|
- By default, the npm helper keeps output machine-friendly (`proofComments: false`).
|
|
100
100
|
- The npm helper shells out to the bundled `eyeling.js` CLI for simplicity and robustness.
|
|
101
101
|
|
|
102
|
+
### RDF/JS and Eyeling rule-object interop
|
|
103
|
+
|
|
104
|
+
The JavaScript APIs now accept three input styles:
|
|
105
|
+
|
|
106
|
+
1. plain N3 text
|
|
107
|
+
2. RDF/JS facts (`quads`, `facts`, or `dataset`)
|
|
108
|
+
3. Eyeling rule objects / AST bundles (the same shapes you get from `eyeling --ast`)
|
|
109
|
+
|
|
110
|
+
If you want to use N3 source text, pass the whole input as a plain N3 string.
|
|
111
|
+
|
|
112
|
+
For RDF/JS facts, the graph must be the default graph. Named-graph quads are rejected.
|
|
113
|
+
|
|
114
|
+
For structured inputs, `rules` is supplied as current Eyeling rule objects:
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
const { reason, rdfjs } = require('eyeling');
|
|
118
|
+
|
|
119
|
+
const ex = 'http://example.org/';
|
|
120
|
+
|
|
121
|
+
const rule = {
|
|
122
|
+
_type: 'Rule',
|
|
123
|
+
premise: [
|
|
124
|
+
{
|
|
125
|
+
_type: 'Triple',
|
|
126
|
+
s: { _type: 'Var', name: 'x' },
|
|
127
|
+
p: { _type: 'Iri', value: ex + 'parent' },
|
|
128
|
+
o: { _type: 'Var', name: 'y' },
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
conclusion: [
|
|
132
|
+
{
|
|
133
|
+
_type: 'Triple',
|
|
134
|
+
s: { _type: 'Var', name: 'x' },
|
|
135
|
+
p: { _type: 'Iri', value: ex + 'ancestor' },
|
|
136
|
+
o: { _type: 'Var', name: 'y' },
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
isForward: true,
|
|
140
|
+
isFuse: false,
|
|
141
|
+
headBlankLabels: [],
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const out = reason(
|
|
145
|
+
{ proofComments: false },
|
|
146
|
+
{
|
|
147
|
+
quads: [rdfjs.quad(rdfjs.namedNode(ex + 'alice'), rdfjs.namedNode(ex + 'parent'), rdfjs.namedNode(ex + 'bob'))],
|
|
148
|
+
rules: [rule],
|
|
149
|
+
},
|
|
150
|
+
);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
You can also pass a full AST bundle directly:
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
const ast = [prefixes, triples, forwardRules, backwardRules];
|
|
157
|
+
const out2 = reason({ proofComments: false }, ast);
|
|
158
|
+
```
|
|
159
|
+
|
|
102
160
|
### Direct bundle / browser-worker API: `reasonStream()`
|
|
103
161
|
|
|
104
162
|
For in-process reasoning (browser, worker, or direct use of `eyeling.js`):
|
|
@@ -113,6 +171,8 @@ const result = eyeling.reasonStream(input, {
|
|
|
113
171
|
console.log(result.closureN3);
|
|
114
172
|
```
|
|
115
173
|
|
|
174
|
+
`eyeling.js` now also exposes `eyeling.rdfjs` and `eyeling.reasonRdfJs(...)` for RDF/JS workflows.
|
|
175
|
+
|
|
116
176
|
#### `reasonStream()` output behavior
|
|
117
177
|
|
|
118
178
|
`closureN3` is also mode-dependent:
|
|
@@ -126,8 +186,25 @@ To exclude input facts from the normal-mode closure, pass:
|
|
|
126
186
|
includeInputFactsInClosure: false;
|
|
127
187
|
```
|
|
128
188
|
|
|
189
|
+
When `rdfjs: true` is passed, `onDerived` also receives a `quad` field and the result may include `closureQuads` / `queryQuads`.
|
|
190
|
+
|
|
129
191
|
The returned object also includes `queryMode`, `queryTriples`, and `queryDerived` (and in normal mode, `onDerived` fires for newly derived facts; in `log:query` mode it fires for the query-selected derived triples).
|
|
130
192
|
|
|
193
|
+
### `reasonRdfJs()`
|
|
194
|
+
|
|
195
|
+
`reasonRdfJs(input, opts)` exposes derived results as an async iterable of RDF/JS quads as they are produced:
|
|
196
|
+
|
|
197
|
+
```js
|
|
198
|
+
const { reasonRdfJs, rdfjs } = require('eyeling');
|
|
199
|
+
|
|
200
|
+
for await (const quad of reasonRdfJs({
|
|
201
|
+
quads: [rdfjs.quad(rdfjs.namedNode(ex + 'alice'), rdfjs.namedNode(ex + 'parent'), rdfjs.namedNode(ex + 'bob'))],
|
|
202
|
+
rules: [rule],
|
|
203
|
+
})) {
|
|
204
|
+
console.log(quad.subject.value, quad.predicate.value, quad.object.value);
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
131
208
|
## Builtins
|
|
132
209
|
|
|
133
210
|
Builtins are defined in [eyeling-builtins.ttl](https://github.com/eyereasoner/eyeling/blob/main/eyeling-builtins.ttl) and described in the [Handbook (Chapter 11)](https://eyereasoner.github.io/eyeling/HANDBOOK#ch11).
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
## Science
|
|
6
|
+
|
|
7
|
+
- [**Body Mass Index**](https://eyereasoner.github.io/eyeling/arctifacts/bmi.html) — Compute BMI categories with explainable thresholds and sanity checks.
|
|
8
|
+
- [**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.
|
|
9
|
+
- [**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.
|
|
10
|
+
- [**Grass Seed Germination**](https://eyereasoner.github.io/eyeling/arctifacts/grass-molecular.html) — Model germination states and transitions with rule checks.
|
|
11
|
+
- [**Leg Length Discrepancy Measurement**](https://eyereasoner.github.io/eyeling/arctifacts/lldm.html) — Leg Length Discrepancy Measurement from four landmarks.
|
|
12
|
+
|
|
13
|
+
## Technology
|
|
14
|
+
|
|
15
|
+
- [**Auroracare**](https://eyereasoner.github.io/eyeling/arctifacts/auroracare.html) — Purpose-based Medical Data Exchange.
|
|
16
|
+
- [**Clinical Care Planning**](https://eyereasoner.github.io/eyeling/arctifacts/clinical-care.html) — Derive care plans from observations, guidelines, and policy constraints.
|
|
17
|
+
- [**Delfour**](https://eyereasoner.github.io/eyeling/arctifacts/delfour.html) — Ruben Verborgh's "Inside the Insight Economy" case.
|
|
18
|
+
- [**GPS Clinical Bench**](https://eyereasoner.github.io/eyeling/arctifacts/gps-clinical-bench.html) — Benchmark clinical decisions with transparent rules and audit trails.
|
|
19
|
+
- [**Graph of French Cities**](https://eyereasoner.github.io/eyeling/arctifacts/graph-french.html) — Shortest paths and connectivity over a city graph with proofs.
|
|
20
|
+
- [**Health Information Processing**](https://eyereasoner.github.io/eyeling/arctifacts/health-info.html) — Transform clinical payloads with typed rules and validation.
|
|
21
|
+
- [**Linked Lists**](https://eyereasoner.github.io/eyeling/arctifacts/linked-lists.html) — Term logic example proved using Resolution.
|
|
22
|
+
- [**REST-Path**](https://eyereasoner.github.io/eyeling/arctifacts/rest-path.html) — Explain link-following over REST resources; verify pre/post conditions.
|
|
23
|
+
- [**Turing Machine**](https://eyereasoner.github.io/eyeling/arctifacts/turing.html) — Run tapes with explicit transitions; verify halting and tape contents.
|
|
24
|
+
|
|
25
|
+
## Engineering
|
|
26
|
+
|
|
27
|
+
- [**Bike Trip Planning**](https://eyereasoner.github.io/eyeling/arctifacts/bike-trip.html) — Route priorities from hazards, preferences, and declarative JSON rules.
|
|
28
|
+
- [**Building Performance**](https://eyereasoner.github.io/eyeling/arctifacts/building-performance.html) — Reason about energy/comfort metrics and verify rule-based outcomes.
|
|
29
|
+
- [**Control System**](https://eyereasoner.github.io/eyeling/arctifacts/control-system.html) — Model simple feedback loops and verify stability/response conditions.
|
|
30
|
+
- [**Eco-Route**](https://eyereasoner.github.io/eyeling/arctifacts/eco-route.html) — Pick lower-emission routes by fusing traffic, grade, and policy goals.
|
|
31
|
+
- [**GPS Bike**](https://eyereasoner.github.io/eyeling/arctifacts/gps-bike.html) — GPS for bike trip Gent → Maasmechelen.
|
|
32
|
+
- [**Lee**](https://eyereasoner.github.io/eyeling/arctifacts/lee.html) — Maze routing with Lee’s algorithm; trace optimal wavefront paths.
|
|
33
|
+
- [**Wind-Turbine Maintenance**](https://eyereasoner.github.io/eyeling/arctifacts/wind-turbines.html) — Plan maintenance from telemetry and policies with auditable outcomes.
|
|
34
|
+
|
|
35
|
+
## Mathematics
|
|
36
|
+
|
|
37
|
+
- [**Ackermann**](https://eyereasoner.github.io/eyeling/arctifacts/ackermann.html) — Compute A₂ with exact hyper-ops; print small, expand huge safely.
|
|
38
|
+
- [**Binomial Theorem**](https://eyereasoner.github.io/eyeling/arctifacts/binomial-theorem.html) — Sum of all binomial coefficients.
|
|
39
|
+
- [**Collatz**](https://eyereasoner.github.io/eyeling/arctifacts/collatz.html) — Generate trajectories and check invariants for the Collatz map.
|
|
40
|
+
- [**Complex Identities**](https://eyereasoner.github.io/eyeling/arctifacts/complex.html) — Symbolic steps for complex-number equalities with auditable reasoning.
|
|
41
|
+
- [**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.
|
|
42
|
+
- [**Euler’s Identity**](https://eyereasoner.github.io/eyeling/arctifacts/euler-identity.html) — The most beautiful equation in mathematics.
|
|
43
|
+
- [**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.
|
|
44
|
+
- [**Fibonacci**](https://eyereasoner.github.io/eyeling/arctifacts/fibonacci.html) — Compute big Fₙ with fast-doubling recurrences and proof-style checks.
|
|
45
|
+
- [**Fundamental Theorem of Arithmetic**](https://eyereasoner.github.io/eyeling/arctifacts/fundamental-theorem-arithmetic.html) — Every integer factors as a product of primes.
|
|
46
|
+
- [**Gödel Numbering**](https://eyereasoner.github.io/eyeling/arctifacts/godel-numbering.html) — A classic Gödel numbering demonstrator.
|
|
47
|
+
- [**Group Theory**](https://eyereasoner.github.io/eyeling/arctifacts/group-theory.html) — Verify closure, identity, inverses, and associativity on examples.
|
|
48
|
+
- [**Kaprekar’s Constant**](https://eyereasoner.github.io/eyeling/arctifacts/kaprekar-constant.html) — Exhaustive sweep of every 4-digit state in Kaprekar’s routine.
|
|
49
|
+
- [**Matrix Basics**](https://eyereasoner.github.io/eyeling/arctifacts/matrix.html) — Add/multiply/invert with dimension/property checks.
|
|
50
|
+
- [**Matrix Multiplication**](https://eyereasoner.github.io/eyeling/arctifacts/matrix-multiplication.html) — Not commutative (AB ≠ BA).
|
|
51
|
+
- [**Newton–Raphson**](https://eyereasoner.github.io/eyeling/arctifacts/newton-raphson.html) — Newton–Raphson method for root-finding.
|
|
52
|
+
- [**Peano Factorial**](https://eyereasoner.github.io/eyeling/arctifacts/peano-factorial.html) — 5! = 120 proved via Resolution.
|
|
53
|
+
- [**Pi**](https://eyereasoner.github.io/eyeling/arctifacts/pi.html) — High-precision π via Chudnovsky series with error-bound checks.
|
|
54
|
+
- [**Polynomial Roots**](https://eyereasoner.github.io/eyeling/arctifacts/polynomial.html) — Find all roots simultaneously; prove convergence on typical cases.
|
|
55
|
+
- [**Primes**](https://eyereasoner.github.io/eyeling/arctifacts/prime.html) — Generate/test primes; log certs (trial factors or proofs) as checks.
|
|
56
|
+
- [**Pythagorean Theorem**](https://eyereasoner.github.io/eyeling/arctifacts/pythagorean-theorem.html) — Compute legs/hypotenuse and confirm with algebraic or area proofs.
|
|
57
|
+
- [**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.
|