eyeprolog 1.3.89 → 1.3.90

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 (2) hide show
  1. package/package.json +1 -1
  2. package/why-eyeprolog.md +217 -125
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.3.89",
6
+ "version": "1.3.90",
7
7
  "description": "EyeProlog turns facts and rules into answers and proofs.",
8
8
  "type": "module",
9
9
  "main": "./index.js",
package/why-eyeprolog.md CHANGED
@@ -1,146 +1,238 @@
1
1
  # Why EyeProlog?
2
2
 
3
- EyeProlog is a small, inspectable ISO Prolog implementation for JavaScript.
4
- It turns facts and rules into answers and can show the derivation behind each
5
- answer.
3
+ Many systems can apply rules to data. The harder questions are whether people
4
+ can understand those rules, whether another implementation can run them, and
5
+ whether a conclusion can be traced back to the facts and rules that produced
6
+ it.
7
+
8
+ EyeProlog is a small, inspectable ISO Prolog implementation for JavaScript. It
9
+ turns facts and rules into answers, and it can show a proof for each answer. Its
10
+ aim is not to invent a new reasoning language, but to make a mature standard
11
+ practical in command-line tools, applications, and browsers.
6
12
 
7
13
  Its design rule is simple:
8
14
 
9
- > **Keep the ISO language core explicit and auditable, keep extensions small and
10
- > explicit, and implement portable conveniences as ordinary Prolog whenever possible.**
11
-
12
- ## Why ISO Prolog?
13
-
14
- [ISO/IEC 13211-1](https://www.iso.org/standard/21413.html) defines a mature
15
- logic-programming core: terms, variables, unification, clauses, recursion,
16
- arithmetic, control, streams, errors, and processor behavior. Reusing that
17
- language gives programs recognizable semantics without inventing another rule
18
- syntax.
19
-
20
- EyeProlog targets the Part 1 core together with Technical Corrigenda 1, 2,
21
- and 3, and provides documented module and definite-clause-grammar compatibility
22
- profiles for normal-mode programs. The post-N289 WG17/STC working draft is
23
- tracked as audit input rather than silently treated as another published
24
- Corrigendum; the conformance ledger records where draft wording differs from
25
- the published strict baseline. The processor character model is explicitly
26
- implementation defined: EyeProlog uses Unicode scalar values as the PCS and as
27
- collating-sequence integers in both normal and strict profiles. Strict mode
28
- therefore rejects implementation-specific language extensions without changing
29
- that processor choice. Its executable conformance matrix records explicit
30
- dispositions for the Part 1 processor, syntax, semantic, built-in, and arithmetic
31
- requirements, including the complete vendored WG17 syntax cases and cross-profile
32
- preservation of strict-success syntax outcomes. Implementation-defined choices
33
- such as mixed-type `max/2`/`min/2` and signed bitwise/shift operations are pinned
34
- by regression tests. This is extensive implementation evidence, not an independent
35
- ISO certification; the Part 2 and Part 3 compatibility profiles also remain
36
- separate from the Part 1 strict-core claim.
37
-
38
- ## Why a small implementation?
39
-
40
- A compact engine is easier to read, embed, test, and audit. EyeProlog therefore
41
- keeps a narrow architecture:
42
-
43
- - one parser and term model;
44
- - one solver with automatic tabling for eligible positive recursion;
45
- - explicit `tnot/1` with well-founded semantics for finite, range-restricted,
46
- function-free Datalog components;
47
- - the ISO built-in registry;
48
- - lean portable library modules using the documented module compatibility profile;
49
- - ISO Part 3-oriented definite clause grammars and `phrase/2-3`;
50
- - lifecycle-aware `call_cleanup/2` and `setup_call_cleanup/3` in normal mode;
51
- - optional proof explanations; and
52
- - the same implementation in Node.js and the browser.
53
-
54
- The modules do not wrap facilities already available in the ISO core. Common
55
- relations such as list processing remain ordinary Prolog clauses imported with
56
- `use_module/1-2`, while
57
- standard sorting, arithmetic, meta-calls, streams, and database operations use
58
- their ISO definitions directly.
59
-
60
- The implementation follows the same compactness rule. JavaScript runtime
61
- modules stay flat under `src/`: `program.js` and `iso.js` remain stable facade
62
- modules, while static program analysis, clause indexing, arithmetic evaluation,
63
- processor error types, and cleanup lifecycle handling are factored into focused
64
- sibling files. `cleanup.js` closes protected builtin iterators when search is
65
- committed, abandoned, or unwound without making `solver.js` depend on the
66
- language registry. The execution fast paths remain direct code in `solver.js`;
67
- source cleanup is not allowed to add dispatch or abstraction overhead merely to
68
- make that file smaller. `src/ARCHITECTURE.md` records these boundaries and an
69
- automated test rejects JavaScript import cycles.
70
-
71
-
72
- ## Why keep well-founded negation explicit?
73
-
74
- Ordinary Prolog `\+/1` is negation-as-failure and remains useful when a closed,
75
- usually stratified relation has already been computed. Non-stratified rule
76
- systems need a different semantic choice. EyeProlog therefore does not silently
77
- change `\+/1`; normal mode provides `tnot/1` for finite Datalog components that
78
- need the three-valued well-founded semantics. This keeps the extension visible
79
- in source code and lets strict ISO mode remove it cleanly.
80
-
81
- The same boundary guides performance work. EyeProlog may evaluate large finite
82
- positive Datalog closures with a shared relation-wide table, but the admission
83
- heuristics are implementation details. Programs should rely on the documented
84
- semantics and finiteness conditions, not on a particular internal threshold.
85
-
86
- DCGs follow the same rule. Their supported semantics follow the ISO Part 3
87
- difference-list model, while finite sequence scans and proven zero-width hand-offs may use
88
- lighter internal control paths so deep grammars do not pay one general solver
89
- frame per token. Relational remainder-producing modes are preserved. The
90
- checked `examples/dcg-expression-language.pl` program shows the declarative side
91
- of that design: one grammar builds precedence-aware syntax trees and another
92
- generates minimally parenthesized token sequences back from them.
93
-
94
- ## Why cleanup follows search lifecycle?
95
-
96
- A Prolog resource lifetime is tied to search, not just to ordinary function
97
- return. A protected goal can finish, fail, be cut, be abandoned at the top
98
- level while alternatives remain, or unwind through an exception. Normal-mode
99
- `call_cleanup/2` and `setup_call_cleanup/3` make those exits explicit and run
100
- Cleanup exactly once. This also preserves demand-driven answer interaction: the
101
- top level need not execute a successor merely to decide whether a choicepoint
102
- exists. Strict ISO mode leaves these predicates out.
103
-
104
- ## Why proofs?
15
+ > **Keep the ISO language core explicit and auditable, keep extensions small
16
+ > and visible, and implement portable conveniences as ordinary Prolog whenever
17
+ > possible.**
18
+
19
+ ## A shared language for facts and rules
20
+
21
+ Prolog describes knowledge through relations. A program can state facts such
22
+ as “Socrates is human,” define a rule saying that every human is mortal, and
23
+ then ask whether Socrates is mortal. Variables, unification, and search let the
24
+ same rule answer more general questions without turning it into a sequence of
25
+ manual data-processing steps.
26
+
27
+ This relational style is useful well beyond textbook examples. It can express
28
+ graph reachability, policy decisions, validation rules, parsers, schedules,
29
+ constraints, and explanations. Because the program says what relationships
30
+ must hold, its logical structure remains visible to readers and tools.
31
+
32
+ ## Why the ISO standard matters
33
+
34
+ [ISO/IEC 13211-1](https://www.iso.org/standard/21413.html) defines Prolog's
35
+ general core: terms, variables, unification, clauses, recursion, arithmetic,
36
+ control, streams, errors, and processor behavior. That published foundation
37
+ gives programmers a common vocabulary and gives implementations an external
38
+ reference against which behavior can be tested.
39
+
40
+ Standards do not make every implementation identical, but they sharply reduce
41
+ the number of hidden choices. A portable Prolog rule is not tied to one product,
42
+ one JavaScript API, or one project-specific syntax. It can be studied in books,
43
+ compared across conforming systems, and preserved independently of the engine
44
+ that happens to run it today. This is especially important for knowledge and
45
+ policy rules, which often need to remain understandable longer than the
46
+ application that first used them.
47
+
48
+ EyeProlog therefore starts with ISO Prolog and labels its additions. Normal
49
+ mode provides practical libraries, modules, definite clause grammars, tabling,
50
+ and embedding facilities. Strict mode removes EyeProlog-specific language
51
+ extensions so the standardized core can be tested on its own. The distinction
52
+ keeps convenience from quietly redefining the language.
53
+
54
+ ## From standardized RDF to standardized rules
55
+
56
+ The standards argument becomes especially concrete for RDF systems. RDF gives
57
+ applications a standardized graph data model, but choosing a rule language for
58
+ those graphs is a separate decision.
59
+
60
+ [Eyeling](https://github.com/eyereasoner/eyeling) takes a compact, web-native
61
+ approach: it reasons directly over Notation3, RDF-JS datasets, and streaming RDF
62
+ messages. N3 is expressive and practically valuable, but it is not an ISO
63
+ standard or a W3C Recommendation. Prolog, by contrast, is defined by the
64
+ ISO/IEC 13211 family of international standards, while RDF belongs to the W3C
65
+ standards ecosystem.
66
+
67
+ EyeProlog and
68
+ [`rdf-prolog-roundtrip`](https://github.com/eyereasoner/rdf-prolog-roundtrip)
69
+ connect those two standardized worlds through a deliberately simple pipeline:
70
+
71
+ ```text
72
+ RDF dataset
73
+ -> ordinary rdf(Subject, Predicate, Object, Graph) facts
74
+ -> portable ISO Prolog rules executed by EyeProlog
75
+ -> ground rdf/4 result facts
76
+ -> RDF dataset
77
+ ```
78
+
79
+ The round-trip package performs the RDF conversion and contains no solver;
80
+ EyeProlog performs the reasoning. This separation makes every boundary
81
+ inspectable. The source graph remains recognizable, the rules are ordinary
82
+ Prolog programs, intermediate results can be saved and tested, and the final
83
+ facts can return to RDF without making the reasoning engine responsible for
84
+ every RDF syntax.
85
+
86
+ This combination is compelling when interoperability, reproducibility,
87
+ long-term maintenance, or independent verification matter. It also opens RDF
88
+ data to relational programming, constraints, recursion, collections, and
89
+ portable Prolog libraries. Eyeling remains the natural choice when an
90
+ application deliberately wants its rules, data, and streaming interfaces to
91
+ stay directly in the evolving N3 and RDF ecosystem. The two approaches serve
92
+ different boundaries rather than pretending that one boundary fits every
93
+ system.
94
+
95
+ ## Small enough to inspect, useful enough to embed
96
+
97
+ A language standard is most valuable when the implementation can be examined
98
+ and tested against it. EyeProlog keeps a narrow architecture: one parser and
99
+ term model, one solver, an explicit built-in registry, portable Prolog library
100
+ modules, and optional proof generation. The same implementation runs in Node.js
101
+ and browser workers.
102
+
103
+ Common relations such as list processing remain Prolog clauses imported with
104
+ `use_module/1-2`. Sorting, arithmetic, meta-calls, streams, and database
105
+ operations use their ISO definitions directly. JavaScript is reserved for the
106
+ engine, host integration, and operations that genuinely belong at the runtime
107
+ boundary.
108
+
109
+ Internally, focused JavaScript modules handle parsing, static analysis, clause
110
+ indexing, arithmetic, errors, and cleanup lifecycles. Performance-critical
111
+ execution paths remain direct rather than being hidden behind layers added only
112
+ for architectural appearance. [`src/ARCHITECTURE.md`](src/ARCHITECTURE.md)
113
+ records these boundaries, and an automated test rejects import cycles.
114
+
115
+ ## Visible choices instead of hidden semantics
116
+
117
+ Some useful reasoning behavior lies outside the ISO Part 1 core. EyeProlog
118
+ keeps those choices explicit in the program or execution profile.
119
+
120
+ Ordinary Prolog `\+/1` is negation-as-failure. It is useful when a closed,
121
+ usually stratified relation has already been computed, but non-stratified rule
122
+ systems need a different semantic choice. Normal mode therefore provides
123
+ `tnot/1` for finite, range-restricted, function-free Datalog components that
124
+ need three-valued well-founded semantics. EyeProlog does not silently change
125
+ the meaning of `\+/1`, and strict ISO mode does not expose `tnot/1`.
126
+
127
+ The engine can use automatic tabling and shared finite-Datalog evaluation to
128
+ make recursive programs practical. Those strategies are optimizations, not a
129
+ new source language: programs should depend on documented semantics and
130
+ finiteness conditions rather than internal thresholds.
131
+
132
+ Definite clause grammars follow the ISO Part 3 difference-list model. Internal
133
+ fast paths make deep finite sequence processing economical while preserving
134
+ relational modes. The checked
135
+ [`dcg-expression-language.pl`](examples/dcg-expression-language.pl) example
136
+ shows both directions: a grammar builds syntax trees from tokens, and another
137
+ generates minimally parenthesized tokens from syntax trees.
138
+
139
+ Resource cleanup follows Prolog search rather than ordinary JavaScript return.
140
+ A protected goal may succeed, fail, be cut, be abandoned while alternatives
141
+ remain, or unwind through an exception. Normal-mode `call_cleanup/2` and
142
+ `setup_call_cleanup/3` run cleanup exactly once across those exits. Keeping this
143
+ behavior tied to the actual search lifecycle also preserves demand-driven
144
+ interaction at the top level.
145
+
146
+ ## Answers that can explain themselves
105
147
 
106
148
  An answer says that a goal succeeded. A proof records one successful route
107
- through the supplied clauses and built-ins. That makes rule behavior easier to
108
- inspect, test, and explain.
149
+ through the supplied clauses and built-ins. That difference matters when rules
150
+ make decisions, combine data from several sources, or need to be reviewed by
151
+ someone who did not write them.
109
152
 
110
- A proof does not authenticate source data or replace host security. Embedders
153
+ Proofs make successful reasoning easier to inspect, test, teach, and discuss.
154
+ They do not authenticate source data or replace application security. Embedders
111
155
  remain responsible for validating inputs and imposing suitable time, memory,
112
156
  depth, and solution limits.
113
157
 
114
- ## Why JavaScript?
115
-
116
- JavaScript makes the same engine usable from a command line, a server, an
117
- application, or a browser worker. Embedders can use the convenience `run`
118
- function or work directly with `Program`, `Solver`, terms, environments, and a
119
- custom built-in registry.
120
-
121
- ## What EyeProlog should become
122
-
123
- EyeProlog should improve by becoming more correct and more economical, not by
124
- accumulating unrelated subsystems. New capabilities should normally be one of:
125
-
126
- 1. required ISO behavior;
127
- 2. a small portable Prolog relation; or
128
- 3. a narrowly documented embedding hook.
158
+ ## One engine across JavaScript environments
159
+
160
+ JavaScript makes EyeProlog available from a command line, server, test suite,
161
+ application, or browser worker. A newcomer can run a `.pl` file or experiment
162
+ in the playground. An application developer can call the convenience `run`
163
+ function. An advanced embedder can work directly with `Program`, `Solver`,
164
+ terms, environments, and a custom built-in registry.
165
+
166
+ This range does not require separate language variants. The same Prolog text
167
+ and the same reasoning engine cross those environments, which makes examples,
168
+ tests, and production behavior easier to compare.
169
+
170
+ ## What the conformance claim means
171
+
172
+ EyeProlog targets the ISO Part 1 core together with Technical Corrigenda 1, 2,
173
+ and 3. It provides separately documented compatibility profiles for Part 2
174
+ modules and Part 3 definite clause grammars in normal mode. The post-N289
175
+ WG17/STC working draft is audit input, not a published Corrigendum silently
176
+ added to the strict baseline.
177
+
178
+ The executable conformance matrix records explicit dispositions for the
179
+ Part 1 processor, syntax, semantic, built-in, and arithmetic requirements. It
180
+ includes the complete vendored WG17 syntax cases and verifies that successful
181
+ strict syntax remains successful across profiles. Implementation-defined
182
+ choices, including mixed-type `max/2` and `min/2` and signed bitwise and shift
183
+ operations, are pinned by regression tests.
184
+
185
+ The character model is also explicit: EyeProlog uses Unicode scalar values as
186
+ its processor character set and as collating-sequence integers in normal and
187
+ strict modes. Strict mode removes implementation-specific language extensions
188
+ without changing that processor choice.
189
+
190
+ This is extensive, executable implementation evidence, not independent ISO
191
+ certification. The Part 2 and Part 3 compatibility profiles likewise remain
192
+ separate from the Part 1 strict-core claim. Stating those limits is part of the
193
+ standards commitment: users should be able to tell which behavior comes from a
194
+ published standard, which comes from a compatibility profile, and which is an
195
+ EyeProlog extension.
196
+
197
+ ## Who is EyeProlog for?
198
+
199
+ EyeProlog is intended for several audiences that benefit from the same visible
200
+ language boundary:
201
+
202
+ - learners who want a runnable logic language whose implementation and proofs
203
+ can be inspected;
204
+ - application developers who need rules in Node.js or the browser without
205
+ inventing an application-specific rule format;
206
+ - RDF practitioners who want standardized graph data to participate in
207
+ portable ISO Prolog reasoning;
208
+ - researchers and implementers who want executable conformance evidence and a
209
+ compact engine suitable for comparison; and
210
+ - teams maintaining policies or knowledge rules that must remain reviewable,
211
+ reproducible, and portable over time.
212
+
213
+ The project is deliberately not a database, a distributed query service, or a
214
+ replacement for host security. Those concerns belong in surrounding systems
215
+ with storage, access control, and operational limits appropriate to the
216
+ application.
217
+
218
+ ## A focused direction
219
+
220
+ EyeProlog should improve by becoming more correct, portable, and economical,
221
+ not by accumulating unrelated subsystems. New capabilities should normally be
222
+ required ISO behavior, a small portable Prolog relation, or a narrowly
223
+ documented embedding hook.
129
224
 
130
225
  It should resist duplicate aliases, hidden execution phases, advisory syntax,
131
- and integrations that can live outside the reasoning engine.
132
-
133
- ## The durable idea
134
-
135
- EyeProlog demonstrates that a useful proof-producing reasoner can be built from
136
- a carefully audited standard-oriented core, small portable modules, and an ordinary JavaScript
137
- API. Its value is not feature count; it is that the language boundary stays
138
- visible enough to understand.
226
+ and integrations that can live outside the reasoning engine. The durable idea
227
+ is that useful, proof-producing reasoning does not require an opaque language
228
+ or an enormous runtime. A carefully audited standard core, portable modules,
229
+ and an ordinary JavaScript API can remain both practical and understandable.
139
230
 
140
231
  ## References
141
232
 
142
233
  - [ISO/IEC 13211-1:1995 — Prolog, Part 1: General core](https://www.iso.org/standard/21413.html)
143
234
  - [ISO/IEC 13211-2:2000 — Prolog, Part 2: Modules](https://www.iso.org/standard/20775.html)
144
235
  - [ISO/IEC TS 13211-3:2025 — Prolog, Part 3: Definite clause grammar rules](https://www.iso.org/standard/83635.html)
236
+ - [RDF 1.2 Concepts and Abstract Syntax](https://www.w3.org/TR/rdf12-concepts/)
145
237
  - [The Art of EyeProlog](the-art-of-eyeprolog.md)
146
238
  - [EyeProlog README](README.md)