eyemind 0.9.0 → 0.9.2
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/LE-SPEC.md +238 -24
- package/LS-SPEC.md +1 -1
- package/README.md +7 -4
- package/package.json +1 -1
- package/src/formats.js +1 -1
- package/src/le.js +1139 -84
- package/src/version.js +1 -1
package/LE-SPEC.md
CHANGED
|
@@ -20,15 +20,48 @@ ends with `:`:
|
|
|
20
20
|
|
|
21
21
|
| Header | Section |
|
|
22
22
|
| --- | --- |
|
|
23
|
-
| `the templates are:`, `the predicates are:` | Templates, separated by commas or
|
|
23
|
+
| `the templates are:`, `the predicates are:` | Templates, separated by full stops, and by commas at the end of a line or before a place. |
|
|
24
|
+
| `the functions are:` | Templates of the form `... is *a value*`, also written without their value. |
|
|
24
25
|
| `the knowledge base NAME includes:`, `the contract NAME states that:` | Facts and rules. |
|
|
25
26
|
| `the ontology is:` | Facts and rules; a fact `a student is a person.` relates the kinds `student` and `person`. |
|
|
27
|
+
| `the constants are:` | Named values, one sentence each: `the fee is 5.` |
|
|
28
|
+
| `the knowledge base NAME includes these resources:` | Other files, separated by commas, whose templates, facts, rules, ontologies and constants join the document. |
|
|
29
|
+
| `the knowledge base NAME includes these scenarios:` | Other files, as resources, whose scenarios and queries join the document too. |
|
|
26
30
|
| `scenario NAME is:` | Facts and rules of one scenario, and its expected answers. |
|
|
27
31
|
| `query NAME is:` | One query. |
|
|
28
32
|
|
|
29
|
-
`the target language is: prolog.` is accepted and ignored
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
`the target language is: prolog.` is accepted and ignored, and so are LE2's
|
|
34
|
+
section markers, `section NAME is:` and `the annexes to the contract are:`,
|
|
35
|
+
and its rule labels, `rule NAME:` before a rule. The sections can come in any
|
|
36
|
+
order, and a template can be used before it is declared. Several `.le` files
|
|
37
|
+
are read as one document.
|
|
38
|
+
|
|
39
|
+
An included file is named as in LE2: a path relative to the file that
|
|
40
|
+
includes it, or a web address, without `.le` if one likes. It is read once,
|
|
41
|
+
and a chain of includes stops at five. The command line reads included files
|
|
42
|
+
and web addresses; the library reads them through `io.readFile` and
|
|
43
|
+
`io.readDocument` when `compileLe(inputs, io)` is given them. A Prolog
|
|
44
|
+
resource, a file ending in `.pl`, gives its facts and rules: Prolog clauses
|
|
45
|
+
`Head.` and `Head :- Body.`, with the goals of an embedded Prolog goal (see
|
|
46
|
+
Embedded Prolog); its directives are left out.
|
|
47
|
+
|
|
48
|
+
`the facts background includes these resources: ...` names the programs that
|
|
49
|
+
help an assistant read facts from a text; as in LE2, the answers do not depend
|
|
50
|
+
on them, and eyemind reads past the section.
|
|
51
|
+
|
|
52
|
+
A fact or a rule's label may carry LE2's provenance, which changes nothing in
|
|
53
|
+
the proof but gives the fact its source:
|
|
54
|
+
|
|
55
|
+
- trailers after a fact, each after a comma: `, according to SOURCE`,
|
|
56
|
+
`, as stated in DOCUMENT at LOCATOR`, `, because "..."` and `, confer "..."`;
|
|
57
|
+
- `scenario NAME is, as stated in DOCUMENT:`, the default document of the
|
|
58
|
+
scenario's facts;
|
|
59
|
+
- `rule NAME with provenance DOCUMENT, confer "...":`;
|
|
60
|
+
- `DOCUMENT is published at "..."` and `the text of DOCUMENT is at "..."`,
|
|
61
|
+
which eyemind reads past.
|
|
62
|
+
|
|
63
|
+
A fact's source is its `according to`, else its document. It matters only to
|
|
64
|
+
source-scoped proof (see Negation).
|
|
32
65
|
|
|
33
66
|
Sentences end with a full stop followed by white space or the end of the file;
|
|
34
67
|
a sentence can span lines. `%` or `#` starts a comment through the end of the
|
|
@@ -43,8 +76,10 @@ space as one and a tab as four, as LE's editor shows it.
|
|
|
43
76
|
## Templates
|
|
44
77
|
|
|
45
78
|
A template is a sentence pattern: words and places. A place is a phrase between
|
|
46
|
-
asterisks, such as `*a person*`; LE1 also writes templates without asterisks
|
|
47
|
-
|
|
79
|
+
asterisks, such as `*a person*`; LE1 also writes templates without asterisks.
|
|
80
|
+
In a document without any, `a` or `an` and the word after it make a place in a
|
|
81
|
+
template that starts with `a` or `an`, such as `a person has a balance`; a
|
|
82
|
+
template such as `the applicant has a good credit score` keeps its words.
|
|
48
83
|
|
|
49
84
|
```text
|
|
50
85
|
the templates are:
|
|
@@ -57,7 +92,20 @@ Each template is a relation whose name joins its words with underscores and
|
|
|
57
92
|
whose arguments are its places in order: `acquires_British_citizenship_on/2`,
|
|
58
93
|
`says_that/2`, `has/2`. A name that is an LS primitive or control, or `date`,
|
|
59
94
|
gets the prefix `le_`. Two templates with different words for one name and
|
|
60
|
-
arity are an error. A place after the word `that` holds a sentence.
|
|
95
|
+
arity are an error. A place after the word `that` holds a sentence. A document
|
|
96
|
+
with an asterisk in any template reads `a` and `an` in its other templates as
|
|
97
|
+
words.
|
|
98
|
+
|
|
99
|
+
LE2's additions follow a template after `;`:
|
|
100
|
+
|
|
101
|
+
| Addition | Meaning in eyemind |
|
|
102
|
+
| --- | --- |
|
|
103
|
+
| `; synonym TEMPLATE` | A second wording of the same relation, with its places in the same order. |
|
|
104
|
+
| `; opposite: TEMPLATE`, `; opposite TEMPLATE` | The wording of a separate relation, concluded only by its own rules and by `only if` rules. |
|
|
105
|
+
| `; assumable`, `; unknown`, `; assumed`, `; judged`, `; open textured`, `; evaluative` | A sentence that the program cannot prove can be assumed; see Abduction. |
|
|
106
|
+
| `; memorable`, `; memoised`, `; memoized`, `; cached`, `; undefined`, `; scenario element`, `; one value`, `; single valued`, `; image ...` | Nothing that eyemind computes changes. |
|
|
107
|
+
|
|
108
|
+
Other additions, such as `; prepositional` and `; via service NAME`, are errors.
|
|
61
109
|
|
|
62
110
|
## Sentences
|
|
63
111
|
|
|
@@ -90,6 +138,11 @@ The tokens in a place are a term:
|
|
|
90
138
|
- A single capital letter with optional digits, such as `L` or `T1`, is a
|
|
91
139
|
variable even when no phrase introduced it. Longer ids need an introducing
|
|
92
140
|
phrase, because LE1 programs use acronyms such as `GST` as names.
|
|
141
|
+
- `*a name*` between asterisks, LE2's explicit variable, is the variable of
|
|
142
|
+
that phrase, introduced or referred to.
|
|
143
|
+
- A lone `which`, `what`, `who`, `when` or `where` introduces a variable.
|
|
144
|
+
- A phrase that names a constant of `the constants are:` is its value, unless a
|
|
145
|
+
variable of the clause has that name.
|
|
93
146
|
- Other words are a name, written as they are, such as `Socrates` or
|
|
94
147
|
`cash at bank`.
|
|
95
148
|
|
|
@@ -103,7 +156,15 @@ In a knowledge base or a scenario, a sentence is a fact, or a rule
|
|
|
103
156
|
type template `*an object* is a *type*` (the relation `is_a/2`, whose type is a
|
|
104
157
|
name). A fact with a variable holds for every value. In an ontology, a fact
|
|
105
158
|
whose subject starts with `a` or `an` is about the kind: `a student is a person.`
|
|
106
|
-
states `is_a('student', 'person')`.
|
|
159
|
+
states `is_a('student', 'person')`. An ontology's kinds are transitive: for
|
|
160
|
+
each such ground fact `b is a c`, whatever is a `b` is a `c`. A fact or rule
|
|
161
|
+
may end with LE2's `; image ...`, which is ignored.
|
|
162
|
+
|
|
163
|
+
`Head only if Body.` makes Body necessary for Head, as in LE2: it concludes the
|
|
164
|
+
opposite of Head, the template's `; opposite` wording or else an internal
|
|
165
|
+
relation, when it is not the case that Body. The other rules of Head's relation
|
|
166
|
+
then conclude a base relation, and Head holds when the base holds and its
|
|
167
|
+
opposite does not.
|
|
107
168
|
|
|
108
169
|
The conditions are joined by `and` and `or`. Each connective has the
|
|
109
170
|
indentation of its line; a connective in the middle of a line has the
|
|
@@ -140,11 +201,50 @@ with a connective at the same or a lesser indentation:
|
|
|
140
201
|
| `R is the list of each X such that C` | `L` itself |
|
|
141
202
|
| `R is a collection of X where C` | `L` itself, as LE1 writes it |
|
|
142
203
|
|
|
204
|
+
LE2 also groups conditions without connectives. `any of`, `either` or
|
|
205
|
+
`at least one of`, and `all of`, each followed by `:` or a line break, join the
|
|
206
|
+
conditions on the lines below them, one per line at the least indentation,
|
|
207
|
+
with `or` or with `and`.
|
|
208
|
+
|
|
209
|
+
A rule whose `if` is followed by `:` has a numbered body, as LE2 writes one
|
|
210
|
+
after a statute:
|
|
211
|
+
|
|
212
|
+
```text
|
|
213
|
+
an entity must register for GST if:
|
|
214
|
+
1. the entity is a not-for-profit; and
|
|
215
|
+
2. either:
|
|
216
|
+
2.1. the entity has a turnover
|
|
217
|
+
2.2. all of:
|
|
218
|
+
2.2.1. the entity projected turnover is a projection; and
|
|
219
|
+
2.2.2. the projection >= 150000.
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
A designator such as `2.2.1.` begins its line. An item's trailing `and` or
|
|
223
|
+
`or`, after an optional `;`, joins it to the next item of its level, and an
|
|
224
|
+
item without one joins with `and`. An item `either:`, `any of:`,
|
|
225
|
+
`at least one of:`, `all of:` or `it is not the case that:` stands for the
|
|
226
|
+
items numbered below it, joined as the group says, or denied.
|
|
227
|
+
|
|
143
228
|
An aggregate collects one value for every solution of its conditions, in the
|
|
144
229
|
order they are found, as Prolog's `findall` does: a value found twice counts
|
|
145
230
|
twice. The result phrase of an aggregate is the phrase before `is the`, after any
|
|
146
231
|
connective.
|
|
147
232
|
|
|
233
|
+
## Functions
|
|
234
|
+
|
|
235
|
+
A template of `the functions are:` is an ordinary template whose last place
|
|
236
|
+
follows `is`, such as `the price of a cup with capacity *a number* ml is *an
|
|
237
|
+
amount*`. Wherever a value is needed (a place of another template, a side of a
|
|
238
|
+
comparison, an operand of a formula or the conclusion of a rule), the template
|
|
239
|
+
can be written without `is` and its last place:
|
|
240
|
+
`the price of a cup with capacity the capacity ml > 10`. That phrase is a
|
|
241
|
+
variable that a call of the function binds, asked before the condition that
|
|
242
|
+
uses it, or after the conditions of a rule for its conclusion; a fact whose
|
|
243
|
+
conclusion calls a function is such a rule. One clause asks one call once. A
|
|
244
|
+
variable or a constant of the same name comes first. In a formula, an operand
|
|
245
|
+
is the words up to the next operator, and a function's last argument may be a
|
|
246
|
+
formula in brackets: `the double of (the fee + 1)`.
|
|
247
|
+
|
|
148
248
|
## Negation
|
|
149
249
|
|
|
150
250
|
Variables that occur only inside a negation stand for any value there; eyemind
|
|
@@ -158,6 +258,40 @@ unbound (`is_var`), the negation stands for any value there; once bound
|
|
|
158
258
|
variable of its conclusion open, no condition surely binds a variable, and
|
|
159
259
|
every negation tests its variables in this way.
|
|
160
260
|
|
|
261
|
+
LE runs a rule top-down, so a negation or a collection may reach the rule's own
|
|
262
|
+
relation, through other rules, as long as the data never closes the cycle. LS
|
|
263
|
+
stratifies statically, so eyemind unfolds such a group of relations into eight
|
|
264
|
+
levels: a negation or collection at level k calls level k + 1, a relation of
|
|
265
|
+
its own, `NAME#k`. The answers are exact up to eight levels; a program that
|
|
266
|
+
needs more stops with an error that says so.
|
|
267
|
+
|
|
268
|
+
`C according to S`, written at the end of a condition or on a line indented
|
|
269
|
+
below it, is LE2's source-scoped proof: C must follow from the knowledge base
|
|
270
|
+
and only the scenario facts whose source is admissible under S. Every relation
|
|
271
|
+
C can reach compiles to a second relation, `NAME:sc`, with the scope as one
|
|
272
|
+
more argument, in which a scenario fact holds when its source is admissible
|
|
273
|
+
under the scope; a scenario fact without a source is never admissible. The
|
|
274
|
+
built-in template `*a source* is admissible under *a scope*` holds for a source
|
|
275
|
+
under itself and as the program's facts and rules say. When a template's own
|
|
276
|
+
words contain `according to`, a condition is read as that template first.
|
|
277
|
+
|
|
278
|
+
## Embedded Prolog
|
|
279
|
+
|
|
280
|
+
A condition `prolog GOAL` runs a Prolog goal, as LE2 writes one: goals joined
|
|
281
|
+
by `,` and `;`, `\+ GOAL` for negation, `Module:GOAL`, and the tests `=`,
|
|
282
|
+
`\=`, `==`, `\==`, `<`, `>`, `=<`, `>=`, `atom/1`, `number/1`, `integer/1`,
|
|
283
|
+
`var/1`, `nonvar/1`, `true` and `fail`. An argument is a Prolog variable, atom,
|
|
284
|
+
number, list or compound, or an LE phrase such as `the person`; a definite
|
|
285
|
+
phrase that refers to no variable starts one. Other goals call the relations of
|
|
286
|
+
Prolog resources. LE2's system predicates are:
|
|
287
|
+
|
|
288
|
+
| Goal | Holds for |
|
|
289
|
+
| --- | --- |
|
|
290
|
+
| `le_my_kb(K)`, `le_kb(K)` | the name of the rule's knowledge base |
|
|
291
|
+
| `le_my_id(L)` | the rule's label |
|
|
292
|
+
| `le_source_element(L, D, G)` | the label of a rule with a numbered body, and each designator `D` of its conditions |
|
|
293
|
+
| `le_source_section(S, L)` | the section of a labelled rule: `main`, `annexes`, or the name of `section NAME is:` |
|
|
294
|
+
|
|
161
295
|
## Arithmetic, comparisons and built-in templates
|
|
162
296
|
|
|
163
297
|
A comparison has `=`, `==`, `!=`, `\=`, `\==`, `<`, `>`, `<=`, `=<` or `>=`
|
|
@@ -204,20 +338,90 @@ scenario alice is:
|
|
|
204
338
|
```
|
|
205
339
|
|
|
206
340
|
`NAME expects answers [...]` and `NAME expects [...]` state the answers the
|
|
207
|
-
query `NAME` gives in the scenario
|
|
208
|
-
|
|
341
|
+
query `NAME` gives in the scenario. The answers may be quoted sentences or, as
|
|
342
|
+
some examples write them, words up to a comma. An expectation with
|
|
343
|
+
`and unknowns [...]` also states the union of the unknowns the answers rest
|
|
344
|
+
on, and one with `and any unknowns` compares only the answers; one without
|
|
345
|
+
`and unknowns` wants answers that rest on none. Each query is answered in each
|
|
346
|
+
scenario, or once when the document has none.
|
|
347
|
+
|
|
348
|
+
## Abduction
|
|
349
|
+
|
|
350
|
+
When the program cannot prove a sentence of an assumable template, an answer
|
|
351
|
+
can rest on the assumption that the sentence holds, as in LE2. The sentence is
|
|
352
|
+
then one of the answer's unknowns. `it is unknown whether SENTENCE.`, in the
|
|
353
|
+
knowledge base or in one scenario, makes the sentences that SENTENCE describes
|
|
354
|
+
assumable there, as in `it is unknown whether a payment is approved.`
|
|
355
|
+
|
|
356
|
+
Every relation that can reach an assumable sentence also compiles to a second
|
|
357
|
+
relation, `NAME:ab`, with one more argument: the list of the sentences it
|
|
358
|
+
assumes. Its rules are those of `NAME`, each condition that can reach an
|
|
359
|
+
assumable sentence called through its own `:ab` relation, and the lists
|
|
360
|
+
appended. An assumable relation also has the rule that assumes its sentence.
|
|
361
|
+
Each answer, `'le:answer'(..., U)`, gets the list `U` of its assumptions,
|
|
362
|
+
without each ground sentence that the facts and rules prove after all, through
|
|
363
|
+
`'le:unknowns'` and `'le:holds'`. An answer that holds with no assumption is
|
|
364
|
+
definite; otherwise each of its sets of assumptions is written after it:
|
|
365
|
+
|
|
366
|
+
```text
|
|
367
|
+
% query explain with scenario observation
|
|
368
|
+
the grass is wet.
|
|
369
|
+
% assuming that it rained
|
|
370
|
+
% or assuming that the sprinkler was on
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
A negation of a sentence that can rest on an assumption follows LE2. It finds
|
|
374
|
+
every way the sentence holds, with its assumptions; it fails when one way needs
|
|
375
|
+
none, and otherwise assumes, for each way, one of its assumptions false,
|
|
376
|
+
leaving out a way that contradicts what the answer assumes already. A
|
|
377
|
+
negative assumption is written `it is not the case that S`. A collection, and
|
|
378
|
+
the conditions of a universal, count every way with all its assumptions, as
|
|
379
|
+
LE2's maximal reading does. An assumption is not made when, at the time it is
|
|
380
|
+
asked, its sentence is proved, or a scenario denies it with
|
|
381
|
+
`it is not the case that S.`
|
|
382
|
+
|
|
383
|
+
An answer is rejected when it assumes a sentence and its negation, or assumes
|
|
384
|
+
false a sentence that the facts and rules prove. `it must not be true that C.`
|
|
385
|
+
is an integrity constraint: with the answer's assumptions as the only ones,
|
|
386
|
+
C must not hold. A violation whose missing piece is a negated assumable
|
|
387
|
+
sentence, as in `... and it is not the case that the second person is married
|
|
388
|
+
to the person`, is repaired by assuming that sentence too; another violation
|
|
389
|
+
rejects the answer. Facts that break a constraint alone leave the scenario
|
|
390
|
+
without answers. The constraints compile to `NAME:w` relations, in which an
|
|
391
|
+
assumable sentence holds when proved or assumed, and `'le:violation'`.
|
|
392
|
+
|
|
393
|
+
## Flip queries
|
|
394
|
+
|
|
395
|
+
`query NAME is: which minimal change to the scenario makes it the case that
|
|
396
|
+
GOAL.` asks, for each scenario, for the smallest sets of changes after which
|
|
397
|
+
GOAL holds without assumptions. A change adds or removes a fact of a template
|
|
398
|
+
marked `; undefined` or `; judged`, or, in a program without such marks, of a
|
|
399
|
+
template that no rule concludes and that is no function. A place is filled with
|
|
400
|
+
the individuals the scenario names as of the place's type, or with all its
|
|
401
|
+
individuals when it names none; a kind is no individual, and a template of more
|
|
402
|
+
than two places is not filled. A set has at most three changes. Each changed
|
|
403
|
+
world `'le:flip'(S, CHANGES)` states its facts as ground facts, so a search
|
|
404
|
+
whose worlds would need more than 200000 facts is refused. An answer is written
|
|
405
|
+
`add: S and remove: T`, or `no change is needed`, and
|
|
406
|
+
`NAME expects changes [["add: S"], ...]` states the expected sets.
|
|
209
407
|
|
|
210
408
|
## Compilation to LS
|
|
211
409
|
|
|
212
410
|
Facts and rules compile to LS facts and backward rules (`implied_by`), as LE's
|
|
213
411
|
Prolog target runs them; a ground fact is `fact(...)`, a fact with a variable a
|
|
214
|
-
backward rule with the body `'true'`.
|
|
412
|
+
backward rule with the body `'true'`. LE1 runs recursive rules with tabling and
|
|
413
|
+
LE2 with a loop check, so a group of relations that depend on themselves
|
|
414
|
+
compiles to forward rules (`implies`), which reach the least fixpoint, when
|
|
415
|
+
each of its rules binds every variable of its conclusion through the relations
|
|
416
|
+
of its conditions; a rule that depends on how it is called, such as a counter
|
|
417
|
+
that goes down, stays backward.
|
|
215
418
|
|
|
216
419
|
When a document has scenarios, every relation gets the scenario as its first
|
|
217
420
|
argument, a scenario's clauses have the scenario's name there, and the
|
|
218
421
|
knowledge base's clauses have a variable there, bound by the facts
|
|
219
|
-
`'le:scenario'(NAME)`. A knowledge-base fact
|
|
220
|
-
`'le:scenario'(S)`. So the
|
|
422
|
+
`'le:scenario'(NAME)`. A ground knowledge-base fact is stated once in each
|
|
423
|
+
scenario, and another becomes a rule whose body is `'le:scenario'(S)`. So the
|
|
424
|
+
knowledge base holds in every scenario and a
|
|
221
425
|
scenario's facts in that one, and one program and one proof answer every query
|
|
222
426
|
in every scenario.
|
|
223
427
|
|
|
@@ -226,6 +430,11 @@ whose body starts with `'le:scenario'(S)` when there are scenarios, and the
|
|
|
226
430
|
statement `query('le:answer'(NAME, S, V1, ...))`. `V1, ...` are the variables of
|
|
227
431
|
the query outside negations and collections, in the order they appear.
|
|
228
432
|
|
|
433
|
+
A sum, count, average, minimum or maximum collects its values with
|
|
434
|
+
`findall_sorted`, since it does not depend on their order, and a proof can
|
|
435
|
+
then certify it even when the values rest on derived facts; `list` and
|
|
436
|
+
`collection` keep the order found, with `findall`.
|
|
437
|
+
|
|
229
438
|
Aggregates, divisions, lists and dates use backward helper rules whose names
|
|
230
439
|
start with `le:` (`le:sum`, `le:count`, `le:days_after`, ...); no template name
|
|
231
440
|
can contain `:`. The helpers follow the document's clauses. `--program` prints
|
|
@@ -254,20 +463,25 @@ compares the answers as a set.
|
|
|
254
463
|
|
|
255
464
|
`--to le` writes the answers of an LE run only; `--to eyemind` writes the
|
|
256
465
|
`'le:answer'` terms. Proofs and check reports are `.js` documents of the
|
|
257
|
-
compiled LS program, and check against it
|
|
466
|
+
compiled LS program, and check against it; with abduction, a checked proof
|
|
467
|
+
establishes each answer with the assumptions it lists. That the program reads the English
|
|
258
468
|
as intended is a matter of the compiler and its tests; a checked proof
|
|
259
469
|
establishes the answers under the compiled rules.
|
|
260
470
|
|
|
261
471
|
## Not supported
|
|
262
472
|
|
|
263
473
|
These belong to Logical English 2, or to the Prolog that LE1 can embed, and
|
|
264
|
-
are errors: template additions
|
|
265
|
-
`
|
|
266
|
-
dynamic and meta sections,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
474
|
+
are errors: the template additions the table above leaves out, such as
|
|
475
|
+
`; prepositional` and `; via service`, `the fluents are:`, `the events are:`
|
|
476
|
+
and the other dynamic and meta sections, Prolog goals other than those of
|
|
477
|
+
Embedded Prolog, `otherwise`, `unless`, decision tables, services, views, LPS
|
|
478
|
+
and s(CASP). eyemind does not check types: the head noun of a place is not a
|
|
479
|
+
type constraint, except that a flip query fills a place with individuals of
|
|
480
|
+
its type.
|
|
481
|
+
|
|
482
|
+
Some of LE2's readings are lenient, and eyemind follows them: a name's
|
|
483
|
+
underscores are spaces (`Sales Associates` refers to `a Sales_Associates`); a
|
|
484
|
+
formula over a name, which Prolog stops with an error, fails; a scenario fact
|
|
485
|
+
`A is B` that no template matches states the relation `le_is`; after a type, a
|
|
486
|
+
short capitalized word is an id, as in `a number MyD`; and an expected number
|
|
487
|
+
with decimals matches an answer rounded to as many decimals.
|
package/LS-SPEC.md
CHANGED
package/README.md
CHANGED
|
@@ -253,9 +253,12 @@ the program reads the English as intended is a matter of the compiler. Several
|
|
|
253
253
|
`.le` files form one document, without other input formats or RDF logic
|
|
254
254
|
switches.
|
|
255
255
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
Of Logical English 2, eyemind also reads constants, functions, included files
|
|
257
|
+
and web addresses, Prolog resources and embedded Prolog goals with LE2's system
|
|
258
|
+
predicates, rule labels, numbered and grouped conditions, `only if` rules, the
|
|
259
|
+
template additions `synonym` and `opposite`, provenance with source-scoped
|
|
260
|
+
proof, abduction with negation and integrity constraints, and flip queries.
|
|
261
|
+
LPS, s(CASP), decision tables and services are reported as unsupported. Every `npm test` scores the
|
|
259
262
|
[Logical English 2 examples](test/UPSTREAM.md) that state their expected
|
|
260
263
|
answers, as coverage: a wrong answer fails the run, a file that uses an
|
|
261
264
|
unsupported feature is counted as not passed.
|
|
@@ -758,7 +761,7 @@ console.log(result.bindings);
|
|
|
758
761
|
console.log(checkProof(socrates, result.proof, { goals }).valid);
|
|
759
762
|
```
|
|
760
763
|
|
|
761
|
-
`run()` returns `conclusions`, `answers`, `bindings`, `inferred`, `stdout`, `proof`, `proofReport`, `stats` and `haltCode`, and takes `goal`, `goals`, `proof`, `maxDepth`, `maxIterations` and `maxInferences`; exceeding a bound throws an `EyemindError`. `conclusions` holds the answer terms; `answers`, `bindings` and `stdout` are rendered when first read. Ground N3 conclusions are written directly from their terms. `loadSources([[text, filename], ...], io)` loads several sources as one program; pass `nodeIO` from `eyemind/node` as `io` to let `facts_from(path)` read files. `checkProof(program, document, { goals })` checks a proof. `checkReport`, `readTerm`, `readTerms` and `write` format reports and read and write the canonical text. `compileLe([[text, filename], ...])` returns the compiled LS `program` and standalone JavaScript `text
|
|
764
|
+
`run()` returns `conclusions`, `answers`, `bindings`, `inferred`, `stdout`, `proof`, `proofReport`, `stats` and `haltCode`, and takes `goal`, `goals`, `proof`, `maxDepth`, `maxIterations` and `maxInferences`; exceeding a bound throws an `EyemindError`. `conclusions` holds the answer terms; `answers`, `bindings` and `stdout` are rendered when first read. Ground N3 conclusions are written directly from their terms. `loadSources([[text, filename], ...], io)` loads several sources as one program; pass `nodeIO` from `eyemind/node` as `io` to let `facts_from(path)` read files. `checkProof(program, document, { goals })` checks a proof. `checkReport`, `readTerm`, `readTerms` and `write` format reports and read and write the canonical text. `compileLe([[text, filename], ...], io)` returns the compiled LS `program` and standalone JavaScript `text`, reading included files with `io.readFile` when given; `writeLe(run(loaded.program), loaded)` writes the answers as LE sentences, given the value `loaded` that `compileLe` returned.
|
|
762
765
|
|
|
763
766
|
Further entry points serve applications built on the formats and profiles:
|
|
764
767
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eyemind",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "A dependency-free Logic Script (LS) reasoner with forward and backward reasoning, checkable proofs, and RDF 1.2, Notation3 (N3), SPARQL 1.2 RL (SRL) and Logical English (LE) interoperability.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/formats.js
CHANGED
|
@@ -124,7 +124,7 @@ function load(inputs, io, { base = null, messageInputs = null, srlContext = null
|
|
|
124
124
|
if (kinds.some((kind) => kind !== 'le') || odrl || profiles.length) {
|
|
125
125
|
throw new EyemindError('a Logical English run takes .le files without RDF logic switches or other input formats');
|
|
126
126
|
}
|
|
127
|
-
return compileLe(inputs);
|
|
127
|
+
return compileLe(inputs, io);
|
|
128
128
|
}
|
|
129
129
|
if (profiles.length && odrl) {
|
|
130
130
|
if (inputs.length !== 1) throw new EyemindError(`--odrl with ${switches} takes one Turtle snapshot containing policies, requests and SOTW`);
|