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.
- package/package.json +1 -1
- package/why-eyeprolog.md +217 -125
package/package.json
CHANGED
package/why-eyeprolog.md
CHANGED
|
@@ -1,146 +1,238 @@
|
|
|
1
1
|
# Why EyeProlog?
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
10
|
-
>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
standard
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
|
108
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
115
|
-
|
|
116
|
-
JavaScript makes
|
|
117
|
-
application, or
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
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)
|