eyemind 0.6.2 → 0.6.4

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/README.md CHANGED
@@ -463,10 +463,24 @@ goes unchecked.
463
463
  type('socrates', 'mortal')
464
464
  type('socrates', 'human')
465
465
 
466
+ // Proof check (SPEC 11.2-11.6):
467
+ // Questions: every claim is an answer, and every required answer is claimed.
468
+ // Call tables: every consulted table matches its one-level expansion against the program.
469
+ // Derived listings: every consulted listing is closed under the forward rules.
470
+ // Replay: every required firing replays from no bindings; primitives, controls and
471
+ // Skolem witnesses are checked at the bindings where they run.
472
+ // Evidence: every recorded step, call table and listing is used by the check.
473
+
466
474
  verdict('checked')
467
475
  ```
468
476
 
469
- A `checked` verdict thus establishes two things: every claim follows from the program, and the claims are every answer of the original questions. A question with no claims is shown to have no answers by its table. A failed check lists `failure(Detail)` facts, ends with `verdict(failed(N))` and exits with code 2. A halted run's proof establishes that its claims follow, not that they are every answer. To check answers to `--goal` questions, pass the same goals when checking. [SPEC §11](https://eyereasoner.github.io/eyemind/SPEC#11-proof-checking) defines the check.
477
+ A `checked` verdict establishes that every claim follows from the program and every required answer of the original questions is claimed. When the run reports only derived facts, source facts and backward-only answers are not required conclusions. A failed check lists `failure(Detail)` facts, ends with `verdict(failed(N))` and exits with code 2. A halted run's proof establishes that its claims follow, without establishing answer completeness. To check answers to `--goal` questions, pass the same goals when checking. [SPEC §11](https://eyereasoner.github.io/eyemind/SPEC#11-proof-checking) defines the check.
478
+
479
+ The report's comments explain which checks succeeded, with references to
480
+ SPEC Sections 11.2–11.6. They distinguish complete answers from a halted
481
+ proof's replayed claims. A failed report keeps its claims unverified and
482
+ lists the failures. These explanations are JavaScript comments: reading the
483
+ report with `facts_from` still gives just its claims, failures and verdict.
470
484
 
471
485
  Some results cannot be certified by this format, and `--proof` then reports an error while a plain run still gives the answers:
472
486
 
package/SPEC.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ```text
4
4
  Title: The Logic Script (LS) Language and Proof Format
5
- Version: eyemind 0.6.2
5
+ Version: eyemind 0.6.4
6
6
  ```
7
7
 
8
8
  This document specifies Logic Script (LS): the syntax and meaning of its
@@ -202,9 +202,8 @@ Proofs:
202
202
  ([Section 11.2](#112-original-questions)).
203
203
  - **Replay**: re-executing the firing a step records, from its source rule,
204
204
  with the bindings of each point of the search ([Section 11.4](#114-replaying-derived-facts)).
205
- - **Checks**: of a proof, that the checker finds no failure; its claims are
206
- then exactly the answers of the original questions, or for a halted run
207
- follow from the program ([Section 11.1](#111-what-a-checked-proof-establishes)).
205
+ - **Checks**: of a proof, that the checker finds no failure
206
+ ([Section 11.1](#111-what-a-checked-proof-establishes)).
208
207
  - **Check report**: what a checker writes: the claims, any failures and a
209
208
  verdict ([Section 12](#12-check-reports)).
210
209
 
@@ -227,6 +226,7 @@ An atom used as a predicate has arity 0. A compound's name and arity identify
227
226
  its constructor. Integers and floats are distinct: `1` and `1.0` MUST NOT
228
227
  unify. Booleans, `null`, `undefined`, infinities and NaN are not terms.
229
228
  Nonfinite numeric values MUST be rejected.
229
+ Atoms and numbers are **atomic** terms.
230
230
 
231
231
  ### 2.2 Lists
232
232
 
@@ -295,7 +295,7 @@ another script, resolved as [Section 3.2](#32-names) specifies, so scripts share
295
295
  declarations.
296
296
 
297
297
  The supplied names are the statements of [Section 3.4](#34-statements), `forward`, `backward`,
298
- `preds`, `vars`, `struct`, the controls and primitives of [Section 4](#4-goals-and-primitives), the
298
+ `preds`, `vars`, `struct`, `float`, the controls and primitives of [Section 4](#4-goals-and-primitives), the
299
299
  atom `fail`. Other names are resolved as [Section 3.2](#32-names) specifies.
300
300
 
301
301
  An embedding MAY supply additional library names. Their operations and
@@ -696,9 +696,10 @@ an incorrect or partial value. The bounds are implementation-defined.
696
696
  A body goal depends on a clause when the goal, renamed apart, unifies with
697
697
  one of the clause's heads. The dependency is **closed** when the goal occurs
698
698
  inside a negation or as the goal of a collection ([Section 4.2](#42-controls)), and **open**
699
- otherwise. Each clause has a rank: the least assignment such that a clause's
700
- rank is at least the rank of every clause it depends on, plus one for a closed
701
- dependency. Forward rules run in order of rank ([Section 8.2](#82-forward-evaluation-and-witnesses)).
699
+ otherwise. Each clause has a nonnegative integer rank: the least assignment
700
+ such that its rank is at least the rank of every clause it depends on, plus
701
+ one for a closed dependency. Forward rules run in order of rank
702
+ ([Section 8.2](#82-forward-evaluation-and-witnesses)).
702
703
 
703
704
  A program MUST be rejected when:
704
705
 
@@ -1073,9 +1074,8 @@ infinite closure. A finite model does not ensure search termination:
1073
1074
  `implied_by(p(X), p(X))` has an empty least model, but searching `p('a')`
1074
1075
  recurs indefinitely. Exceeding a resource bound raises an error ([Section
1075
1076
  8.3](#83-resource-bounds)). Contradictions halt without completing the closure ([Section 8.5](#85-contradictions)).
1076
- A proof that checks establishes that its claims are every answer of the
1077
- original questions ([Section 11.1](#111-what-a-checked-proof-establishes)); it does not establish termination of the
1078
- whole program.
1077
+ The guarantees and limits of a checked proof are defined in
1078
+ [Section 11.1](#111-what-a-checked-proof-establishes).
1079
1079
 
1080
1080
  ## 8. Evaluation and Conclusions
1081
1081
 
@@ -1115,15 +1115,12 @@ and `p(2)` publishes `a(1)`, `b(1)`, `a(2)`, `b(2)`. For each head:
1115
1115
  program writes it (an anonymous one as `_0`, `_1`, ..., [Section 3.3](#33-term-construction)), and
1116
1116
  `Arguments` the list of
1117
1117
  the ground values the solution gives the heads' other variables, in order
1118
- of their first occurrence in the heads. A Skolem term is thus a function of
1119
- the firing: the rule and the instance of its heads. The same firing
1120
- gives the same terms, in any round and in any run, and different
1121
- firings give different terms; variables shared between heads stay
1122
- shared. When several head variables stand for one term, the first of them
1123
- in the heads names it, whichever way unification bound them. A variable
1124
- that a value of the solution brought in, which no head variable stands
1125
- for, keeps its own name when no other term of the firing has it; the
1126
- others take that name followed by the first of `1`, `2`, ... that is
1118
+ of their first occurrence in the heads. When several head variables stand
1119
+ for one term, the first of them in the heads names it, whichever way
1120
+ unification bound them. A variable that a value of the solution brought
1121
+ in, which no head variable stands for, keeps its own name when no other
1122
+ term of the firing has it; the others take that name followed by the first
1123
+ of `1`, `2`, ... that is
1127
1124
  free, in order of first occurrence in the heads. A rule that keeps meeting new firings does
1128
1125
  not terminate ([Section 8.3](#83-resource-bounds)). Derived facts other than scoped inspection
1129
1126
  patterns ([Section 6.3](#63-source-rule-inspection)) are therefore ground. A
@@ -1212,9 +1209,6 @@ depth, goals started or forward rounds are provided, they count as follows:
1212
1209
  including the final round that adds nothing; a stratum without forward
1213
1210
  rules has no rounds.
1214
1211
 
1215
- A run that exceeds a bound MUST report resource exhaustion. Answers found
1216
- before exhaustion MUST NOT be presented as the complete result of that run.
1217
-
1218
1212
  ### 8.4 External goals
1219
1213
 
1220
1214
  A run MAY be given goals. Each goal is read on its own, so goals share no
@@ -1265,8 +1259,8 @@ rather than return a proof that does not check, as for results the format
1265
1259
  cannot establish ([Section 11.1](#111-what-a-checked-proof-establishes)) or a table that would meet an error. It
1266
1260
  MAY bound the work of making tables; exceeding the bound is such an error
1267
1261
  and MUST NOT change the run's answers. A run without conclusions has a proof
1268
- without claims, whose call tables show that the original questions have no
1269
- answers.
1262
+ without claims, whose certificate establishes that there are no required
1263
+ answers ([Section 11.5](#115-deciding-the-claims)).
1270
1264
 
1271
1265
  ## 9. Document Syntax and Canonical Text
1272
1266
 
@@ -1326,8 +1320,8 @@ conjunction rules of [Section 4.1](#41-goal-syntax).
1326
1320
  String escapes are `\\`, `\'`, `\"`, `\n`, `\r`, `\t`, `\b`, `\f`,
1327
1321
  `\v`, `\0` (not followed by a decimal digit), `\xHH`, `\uHHHH` and
1328
1322
  `\u{H...}` with one to six hexadecimal digits denoting a Unicode code point.
1329
- Other escapes and raw line breaks in strings MUST be rejected; a raw line
1330
- break is a line feed or a carriage return, while the characters U+2028 and
1323
+ Other escapes and unescaped characters U+0000–U+001F except tab MUST be
1324
+ rejected. This includes raw line feeds and carriage returns; U+2028 and
1331
1325
  U+2029 are allowed in a string as themselves. Outside
1332
1326
  strings, layout consists of spaces, tabs, carriage returns, line feeds and
1333
1327
  the byte-order-mark character, plus comments. A line feed outside brackets
@@ -1368,7 +1362,7 @@ Object keys may also use these reserved names, since keys denote atom text.
1368
1362
  `hex` is the lowercase hexadecimal code point of `c`. The variable name `A-B`
1369
1363
  is thus written `VAR_A_2d_B`. A reader decodes such a name back
1370
1364
  ([Section 9.1](#91-accepted-document-syntax)).
1371
- - A list is written `[I1, I2, ...]`; an open list ends with `, ...Tail`.
1365
+ - A list is written `[I1, I2, ...]`; an open or improper list ends with `, ...Tail`.
1372
1366
 
1373
1367
  ### 9.3 Canonical compounds
1374
1368
 
@@ -1484,10 +1478,9 @@ called(p(A), [p(_1)])
1484
1478
 
1485
1479
  ## 11. Proof Checking
1486
1480
 
1487
- A checker establishes whether the claims of a proof are exactly the answers
1488
- of the original questions of the source program. Its inputs are the program,
1489
- the proof document and, when the proof answers goals asked from outside the
1490
- program, those goals. The source program is the authority for clauses and
1481
+ A checker verifies a proof's claims against its source program. Its inputs
1482
+ are the program, the proof document and, when the proof answers external
1483
+ goals, those goals. The source program is the authority for clauses and
1491
1484
  questions; the proof supplies evidence to check. The outcome is `checked`
1492
1485
  or a list of failures.
1493
1486
 
@@ -1524,11 +1517,12 @@ two listings coincide ([Section 10.3](#103-certificate)), and when a variable's
1524
1517
 
1525
1518
  ### 11.1 What a checked proof establishes
1526
1519
 
1527
- A proof **checks** when the checker finds no failure. Then its claims follow
1528
- from the source program, and, unless the run halted, they are exactly the
1529
- answers of its original questions, up to the renaming of their variables:
1530
- every claim is an answer and every answer is claimed. A proof without claims
1531
- then establishes that the original questions have none.
1520
+ A proof **checks** when the checker finds no failure. Its claims then follow
1521
+ from the source program. Unless the proof is halted, every claim is an
1522
+ answer of an original question, and every required answer
1523
+ ([Section 11.5](#115-deciding-the-claims)) is claimed, up to variable
1524
+ renaming. A checked proof without claims establishes that there are no
1525
+ required answers.
1532
1526
 
1533
1527
  For a program with negation, "follows" is relative to the facts the
1534
1528
  listings hold: the check establishes that they are supported by replayed
@@ -1546,12 +1540,11 @@ A checked proof does not establish:
1546
1540
  - that the supplied program expresses the author's intended model.
1547
1541
 
1548
1542
  Some results cannot be established by this proof format, and their proofs
1549
- do not check: a first answer or a collection whose order rests on several
1550
- derived facts, whose publication order the format does not show; a firing of a
1551
- restricted rule, whose guard held before the firing but not in the final
1552
- facts ([Section 7.2](#72-variables-and-witnesses)); a comparison `compare/3` of terms that are not ground,
1553
- since renaming a table need not preserve the order of variable names; and a
1554
- search whose table would not close.
1543
+ do not check: a first answer or collection requiring uncertified answer
1544
+ order ([Section 11.3](#113-answering-calls)); a firing of a restricted rule
1545
+ with a guard ([Section 7.2](#72-variables-and-witnesses)); a comparison
1546
+ `compare/3` of terms that are not ground, since renaming a table need not
1547
+ preserve the order of variable names; and a search whose table would not close.
1555
1548
 
1556
1549
  ### 11.2 Original questions
1557
1550
 
@@ -1655,12 +1648,11 @@ starting with no bindings, against the step's corresponding use:
1655
1648
  - A primitive runs on the bindings of that point. Its first solution under
1656
1649
  which the goal can still unify with the use is taken. `compare/3` with a
1657
1650
  compared term that is not ground does not replay.
1658
- - `once/1`, `not/1`, `findall/3` and `findall_sorted/3` take the answers of
1659
- the goal, as it stands at that point, from the certificate, as in
1660
- [Section 11.3](#113-answering-calls). A negation with an unbound named variable does not replay,
1661
- and neither does a first answer or a collection whose order rests on a
1662
- listing. The first answer is taken, and the goal MUST still unify with the
1663
- use.
1651
+ - `once/1`, `not/1`, `findall/3` and `findall_sorted/3` are evaluated from
1652
+ the certificate on the bindings of that point, with the binding and
1653
+ certified-order requirements of [Section 11.3](#113-answering-calls).
1654
+ The control MUST succeed and its resulting goal MUST still unify with
1655
+ the use.
1664
1656
  - Any other goal, as it stands at that point, is answered from the
1665
1657
  certificate as in [Section 11.3](#113-answering-calls), when that search consults no listing:
1666
1658
  the answer identical to the use up to renaming is taken, or else the first
@@ -1689,10 +1681,6 @@ derived pattern's variables are all supplied by an inspection or a listed
1689
1681
  pattern. Each step's bindings MUST name distinct variables of its rule,
1690
1682
  whose values unify with what the replay gave them.
1691
1683
 
1692
- Replay re-executes each recorded firing, so a test of whether a variable is
1693
- bound sees what a search sees, a first answer is the search's first answer,
1694
- and arithmetic is computed rather than accepted.
1695
-
1696
1684
  ### 11.5 Deciding the claims
1697
1685
 
1698
1686
  For a proof that is not halted:
@@ -1740,14 +1728,19 @@ A check report is a document ([Section 9.1](#91-accepted-document-syntax)) holdi
1740
1728
  2. an empty line;
1741
1729
  3. when the check failed, a comment line, then one `failure(Detail)` per
1742
1730
  failure, where `Detail` is an atom, then an empty line;
1743
- 4. `verdict('checked')`, or `verdict(failed(N))` where `N`, at least 1, is
1731
+ 4. optional comment lines explaining the outcome of the check, then an
1732
+ empty line when those comments are present;
1733
+ 5. `verdict('checked')`, or `verdict(failed(N))` where `N`, at least 1, is
1744
1734
  the number of failure lines.
1745
1735
 
1746
1736
  The comment MUST identify the claims as checked answers only when the proof
1747
1737
  checks, as following from a halted program when it checks and is halted, and
1748
1738
  as unverified claims when it fails; a proof without claims that checks MUST
1749
- be said to establish that the original questions have no answers. Comments
1750
- are informative and MAY be worded differently. The wording of `Detail`, and
1739
+ be said to establish that there are no required answers
1740
+ ([Section 11.1](#111-what-a-checked-proof-establishes)). Comments MAY explain
1741
+ the checks of Sections [11.2](#112-original-questions)–[11.6](#116-nothing-unused),
1742
+ but MUST NOT assert guarantees beyond those of the verdict. Their wording
1743
+ is informative and MAY differ. The wording of `Detail`, and
1751
1744
  the number and order of failures, are informative: a conforming checker
1752
1745
  agrees on the verdict `checked` or failed. A report is ordinary data:
1753
1746
  `facts_from` ([Section 3.4](#34-statements)) states it as facts.
@@ -1808,8 +1801,8 @@ object = "{", [ pair, { ",", pair }, [ "," ] ], "}" ;
1808
1801
  pair = ( identifier | string ), ":", expression ;
1809
1802
  number = integer, [ "n" ] | float ;
1810
1803
  integer = "0" | nonzero, { digit } ;
1811
- float = ( digits, ".", { digit } | ".", digits ), [ exponent ]
1812
- | digits, exponent ;
1804
+ float = ( integer, ".", { digit } | ".", digits ), [ exponent ]
1805
+ | integer, exponent ;
1813
1806
  exponent = ( "e" | "E" ), [ "+" | "-" ], digits ;
1814
1807
  digits = digit, { digit } ;
1815
1808
  digit = "0" | nonzero ;
@@ -1864,5 +1857,13 @@ Its check report ([Section 12](#12-check-reports)):
1864
1857
  type('socrates', 'mortal')
1865
1858
  type('socrates', 'human')
1866
1859
 
1860
+ // Proof check (SPEC 11.2-11.6):
1861
+ // Questions: every claim is an answer, and every required answer is claimed.
1862
+ // Call tables: every consulted table matches its one-level expansion against the program.
1863
+ // Derived listings: every consulted listing is closed under the forward rules.
1864
+ // Replay: every required firing replays from no bindings; primitives, controls and
1865
+ // Skolem witnesses are checked at the bindings where they run.
1866
+ // Evidence: every recorded step, call table and listing is used by the check.
1867
+
1867
1868
  verdict('checked')
1868
1869
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyemind",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "A dependency-free Logic Script (LS) reasoner with forward and backward reasoning, checkable proofs, and RDF 1.2, Notation3 (N3) and SPARQL 1.2 RL (SRL) interoperability.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/proof.js CHANGED
@@ -324,8 +324,8 @@ function verdict(report) {
324
324
  return report.valid ? 'checked' : new Struct('failed', [BigInt(report.failures.length)]);
325
325
  }
326
326
 
327
- // The report as JavaScript source: the claims, then a failure(Detail) per
328
- // failure, then the verdict.
327
+ // The report as JavaScript source: the claims, any failures, and the verdict.
328
+ // Explain a successful check only after the whole procedure has passed.
329
329
  export function checkReport(report) {
330
330
  const heading = !report.valid ? '// Unverified claims: proof checking failed.'
331
331
  : report.halted ? '// Checked claims: these follow from the input program, which halted.'
@@ -337,6 +337,23 @@ export function checkReport(report) {
337
337
  for (const { detail } of report.failures) lines.push(text(new Struct('failure', [detail])));
338
338
  lines.push('');
339
339
  }
340
+ if (report.valid) {
341
+ lines.push('// Proof check (SPEC 11.2-11.6):');
342
+ if (report.halted) {
343
+ lines.push("// Halted proof: every claim, including 'false', replays its recorded firing.",
344
+ '// Answer completeness is not established for a halted proof.');
345
+ } else {
346
+ lines.push('// Questions: every claim is an answer, and every required answer is claimed.');
347
+ }
348
+ lines.push('// Call tables: every consulted table matches its one-level expansion against the program.',
349
+ '// Derived listings: every consulted listing is closed under the forward rules.',
350
+ '// Replay: every required firing replays from no bindings; primitives, controls and',
351
+ '// Skolem witnesses are checked at the bindings where they run.',
352
+ '// Evidence: every recorded step, call table and listing is used by the check.');
353
+ } else {
354
+ lines.push('// Proof check (SPEC 11): failed; no claim is certified by this report.');
355
+ }
356
+ lines.push('');
340
357
  lines.push(text(new Struct('verdict', [verdict(report)])));
341
358
  return `${lines.join('\n')}\n`;
342
359
  }
package/src/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // The release this checkout is; ./release keeps it in step with package.json.
2
- export const VERSION = '0.6.2';
2
+ export const VERSION = '0.6.4';