eyemind 0.5.32 → 0.6.1

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
@@ -7,7 +7,7 @@ eyemind is a **JavaScript rule language** with forward and backward reasoning an
7
7
 
8
8
  [Playground](https://eyereasoner.github.io/eyemind/playground/) · [Specification](https://eyereasoner.github.io/eyemind/SPEC) · [Conformance](https://eyereasoner.github.io/eyemind/conformance/) · [Examples](https://eyereasoner.github.io/eyemind/examples/)
9
9
 
10
- The playground runs programs in your browser; the specification defines the language, its canonical text, the proof format and the C1–C10 checks. The examples are 135 runnable programs, each with a card deck and saved conclusions, proofs and check reports. The conformance suite has 1390 cases that test language and proof behavior through a command adapter, together with implementation interface checks; run it [in your browser](https://eyereasoner.github.io/eyemind/playground/conformance).
10
+ The playground runs programs in your browser; the specification defines the language, its canonical text, the proof format and how a proof is checked. The examples are 135 runnable programs, each with a card deck and saved conclusions, proofs and check reports. The conformance suite has 1246 cases that test language and proof behavior through a command adapter, together with implementation interface checks; run it [in your browser](https://eyereasoner.github.io/eyemind/playground/conformance).
11
11
 
12
12
  ## Contents
13
13
 
@@ -45,9 +45,9 @@ Prolog, Datalog, N3 and SRL already exist, and eyemind adds no new logic: rules
45
45
  1. **The proof covers everything that went into the answer.**
46
46
  - Most engines show an answer, or at best a trace you have to trust.
47
47
  - eyemind proofs include the hard parts:
48
- - "nothing matched" (negation and collections), backed by a search certificate whose listings must be closed (C9);
49
- - what a rule says exists, as the Skolem term of that rule firing (C8);
50
- - whether each answer really answers the question asked, and whether every answer of the question is there (C10).
48
+ - "nothing matched" (negation and collections), decided from complete answer tables whose listings of derived facts must be closed;
49
+ - what a rule says exists, as the Skolem term of that rule firing;
50
+ - whether each answer really answers the question asked, and whether every answer of the question is there.
51
51
  - A forged proof must never pass the check, so a result is something you can hand to someone who does not trust your engine.
52
52
  2. **Programs are plain JavaScript.**
53
53
  - There is no syntax to learn, no parser to install and no dependency.
@@ -275,8 +275,7 @@ Examples run directly from their N3 source in the playground and on the command
275
275
  [invoice collection](https://eyereasoner.github.io/eyemind/examples/deck/invoice-n3),
276
276
  [French cities](https://eyereasoner.github.io/eyemind/examples/deck/french-cities-n3), and
277
277
  [Skolem IRI witnesses](https://eyereasoner.github.io/eyemind/examples/deck/witnesses-n3).
278
- Each deck shows the N3 result and what its saved proof establishes, including
279
- any remaining obligations.
278
+ Each deck shows the N3 result and what its saved proof establishes.
280
279
 
281
280
  ### RDF Messages
282
281
 
@@ -330,7 +329,7 @@ text with the same boundaries. Whole-log replay supports proofs;
330
329
  unused-clause modes. The [message-boundaries](https://eyereasoner.github.io/eyemind/examples/deck/message-boundaries-n3),
331
330
  [message-alerts](https://eyereasoner.github.io/eyemind/examples/deck/message-alerts-n3)
332
331
  and [message-provenance](https://eyereasoner.github.io/eyemind/examples/deck/message-provenance-n3)
333
- decks show the outputs and remaining proof obligations.
332
+ decks show the outputs and what their proofs establish.
334
333
 
335
334
  Library hosts can import `RdfMessageReader` and `parseRdfMessages` from
336
335
  `eyemind`. The former accepts text chunks through `write(text)` and
@@ -401,9 +400,9 @@ The two work together: a forward rule's premise can call a backward definition,
401
400
 
402
401
  ## Proofs, and what checking one means
403
402
 
404
- A proof holds the claims, the source clauses it cites, and each recorded
405
- inference as `step(...)` records. Every input writes the same JavaScript
406
- proof: an N3 document or SRL rule set is compiled to an eyemind program, and
403
+ A proof holds the claims, the certificate that answers the program's
404
+ questions, and the recorded firings behind derived facts as `step(...)`
405
+ records. Every input writes the same JavaScript proof: an N3 document or SRL rule set is compiled to an eyemind program, and
407
406
  its proof cites that program's clauses, with triples as `rdf(S, P, O)` (an
408
407
  SRL inference as `inf(S, P, O)`) over `iri(...)` and `literal(...)` terms:
409
408
 
@@ -416,69 +415,74 @@ eyemind --check-proof /tmp/socrates-proof.js examples/socrates-srl.srl
416
415
 
417
416
  Check reports are JavaScript term documents too, or JSON with `--json`.
418
417
 
419
- Checking applies ten conditions:
418
+ The proof of `examples/socrates.js` shows its parts:
420
419
 
421
- | | Condition | What it establishes |
422
- | --- | --- | --- |
423
- | **C1** | resolution | Every step is an instance of a program clause |
424
- | **C2** | well-foundedness | The derivation has no cycles |
425
- | **C3** | justification | Every step's justification is known, well-formed and unique |
426
- | **C4** | coverage | Every claim and premise is accounted for |
427
- | **C5** | re-decision | Built-in calculations are recomputed, not trusted (math-library floats within 4 units in the last place) |
428
- | **C6** | boundary consistency | No unsettled absence or collection is contradicted by the evidence |
429
- | **C7** | relevance | Every claim answers the question, and every step serves a claim |
430
- | **C8** | witness integrity | Every "something exists" uses the Skolem term of its own firing |
431
- | **C9** | search closure | Every absence and collection the search certificate settles holds |
432
- | **C10** | call fidelity | Each answer is an actual answer of the original question, and every answer of each question is claimed |
433
-
434
- **The checker follows the certificate:** it never calls the reasoner, so a missing step fails rather than being quietly re-derived. **The source is the authority:** clauses a proof displays cannot override the program. Proofs are read as data, so checking someone else's proof runs none of their code, and every proof eyemind generates is checked before it is returned. The report is a document too:
420
+ ```js
421
+ // Answers: each instance of a query() that holds.
422
+ type('socrates', 'mortal')
423
+ type('socrates', 'human')
424
+
425
+ // Steps: each derived fact and what it rests on: the clause or control that
426
+ // justifies it, the bindings and the goals it uses.
427
+ step(type('socrates', 'mortal'), clause(3), {S: 'socrates', A: 'human', B: 'mortal'}, [type('socrates', 'human'), subclass_of('human', 'mortal')])
428
+ step(type('socrates', 'human'), clause(1), {}, [])
429
+
430
+ // Certificate: the derived facts and every answer of each call the questions make.
431
+ derived(type(A, B), [type('socrates', 'mortal')])
432
+ called(type(A, B), [type('socrates', 'mortal'), type('socrates', 'human')])
433
+ ```
434
+
435
+ - **The claims** are the run's conclusions.
436
+ - **The call tables**, `called(Call, Answers)`, list every answer of each call
437
+ the original questions make: here the query `type(X, Y)`.
438
+ - **The listings**, `derived(Pattern, Facts)`, list every fact forward rules
439
+ derived for a relation those searches consult.
440
+ - **The steps** record the firing behind each listed fact: the rule, its
441
+ bindings and the goals it used; and, for a goal whose call rests on derived
442
+ facts, how that goal was derived. `type(_, _)` is a relation the rule
443
+ derives, so the stated fact `type('socrates', 'human')` has a step citing
444
+ clause 1.
445
+
446
+ Checking is one procedure. The checker answers each original question by
447
+ searching it against the program, one level at a time, with every inner call
448
+ answered from its call table, and checks each table the same way, so a wrong
449
+ table shows up as a disagreement. Each listing must be closed under the
450
+ forward rules, and each listed fact must **replay** its recorded firing: the
451
+ checker re-runs the rule from no bindings, with primitives computed and
452
+ negations, collections and first answers taken from the tables at the
453
+ bindings they had when they ran, and each witness bound to the Skolem term of
454
+ its firing. The claims must then be exactly the answers: a claim the question
455
+ does not return fails, and so does an answer the proof leaves out. A step,
456
+ table or listing the check does not use fails it too, so nothing in a proof
457
+ goes unchecked.
458
+
459
+ **The checker follows the certificate:** it never calls the reasoner, so missing evidence fails rather than being quietly re-derived. **The source is the authority:** the proof cites clauses by number, read from the program. Proofs are read as data, so checking someone else's proof runs none of their code, and every proof eyemind generates is checked before it is returned. The report is a document too:
435
460
 
436
461
  ```js
437
- // Checked answers: these follow from the input program.
462
+ // Checked answers: these follow from the input program and are every answer of its questions.
438
463
  type('socrates', 'mortal')
439
464
  type('socrates', 'human')
440
465
 
441
- // C1-C10: resolution, acyclicity, justification, coverage, re-decision,
442
- // boundary consistency, relevance, witness integrity, search closure and call fidelity.
443
- condition('C1', 'resolution', 'ok', 3)
444
- condition('C2', 'well_founded', 'ok', 3)
445
- condition('C3', 'justification', 'ok', 3)
446
- condition('C4', 'coverage', 'ok', 4)
447
- condition('C5', 're_decision', 'ok', 0)
448
- condition('C6', 'boundary_consistency', 'ok', 0)
449
- condition('C7', 'relevance', 'ok', 5)
450
- condition('C8', 'witness_integrity', 'ok', 0)
451
- condition('C9', 'search_closure', 'ok', 0)
452
- condition('C10', 'call_fidelity', 'ok', 3)
453
-
454
- // Proof statistics: recorded steps and how they were checked.
455
- steps(3)
456
- verified(3)
457
- recomputed(0)
458
- composed(0)
459
- trusted(0)
460
- claims(2)
461
-
462
- // This verdict also establishes that the claims above are every answer of the original questions.
463
466
  verdict('checked')
464
467
  ```
465
468
 
466
- A `checked` verdict thus establishes two things: every claim follows from the program, and the claims are every answer of the original questions. The `called/2` table of each question lists all its answers and is checked against the program, so a proof that omits one fails C10, and a question with no claims is shown to have no answers. A failed check gives `failure(Condition, Conclusion, Detail)` facts, `verdict(failed(N))` and exit code 2. What a certificate cannot settle stays an `obligation(...)` with the verdict `checked_with_obligations`, among them `obligation('call_fidelity', 'all_answers', Question)` for a question whose answers it cannot show complete; `--strict-proof` rejects those. To check answers to `--goal` questions, pass the same goals when checking. [SPEC §11](https://eyereasoner.github.io/eyemind/SPEC#11-proof-checking) defines every condition.
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.
470
+
471
+ Some results cannot be certified by this format, and `--proof` then reports an error while a plain run still gives the answers:
472
+
473
+ - a first answer or a collection whose order rests on derived facts with more than one answer, since a listing does not show the order facts were derived in (a `findall_sorted` of ground items does not depend on it);
474
+ - a firing of a `restricted` rule whose guard is a negation, which held before the firing but no longer does after it;
475
+ - `compare/3` on terms that are not ground, and rules appended by templates whose generators consult derived facts or introduce witnesses;
476
+ - a call table larger than the bound of [Resource limits](#resource-limits).
467
477
 
468
478
  ### JSON check reports
469
479
 
470
- With `--json`, checking modes write a JSON report instead of a term document.
471
- The JSON form includes `answers`, an array of the initial claims' canonical
472
- texts, including unverified claims when `valid` is false. It also has `valid` (boolean), `steps`,
473
- `claims`, `verified`, `redecided` (the count `recomputed`), `composed`,
474
- `uses` (the number of uses of all steps, integers), `trusted`
475
- (a list of `{kind, conclusion, reason?}`, with `reason: 'original_call'`
476
- for a claim's call-fidelity obligation and `reason: 'all_answers'` for a
477
- question's answer-completeness obligation), `failures` (a list of
478
- `{condition, detail, conclusion?}`) and `conditions` (a list of
479
- `{id, name, covered, failed}`), where `conclusion` is a canonical text.
480
- Its variables keep the names the document gives them, rather than being
481
- renamed for each report fact as in the text form.
480
+ With `--json`, checking modes write a JSON report instead of a term document:
481
+ `valid` (boolean), `claims` and `steps` (the numbers read), `answers` (the
482
+ claims' canonical texts, including unverified claims when `valid` is false),
483
+ `halted` (whether the claims contain `'false'`) and `failures` (a list of
484
+ `{detail, subject?}`, where `subject` is the canonical text of the term
485
+ concerned). Its variables keep the names the document gives them.
482
486
 
483
487
  ### Why negation and collection are safe
484
488
 
@@ -486,9 +490,8 @@ A negation `not(G)` concludes from what is *absent* and a collection `findall(T,
486
490
 
487
491
  - **Ask only once the answer is final.** Rules are ranked so that everything a negation or collection inspects reaches its fixpoint first; a program with no such ranking, such as `implies(not(q), p)` with `implies(p, q)`, is rejected.
488
492
  - **Negate only what is bound.** The variables of `not(G)` must be bound when it runs; write `not(q(X, _))` for "no value at all".
489
- - **Check the search, not just its result.** A proof ends with a search certificate: `searched(Call, Answers)` lists each call's answers and `derived(Pattern, Facts)` each consulted relation. The checker expands each call one level against the program, so a wrong table shows up as a disagreement.
490
- - **Say what was taken on trust.** Anything the certificate cannot settle becomes an obligation, and evidence in the proof can still refute it (C6).
491
- - **Certify the original questions.** Closed listings establish the original calls and all their answers when every listed fact's recorded firing replays. The checker follows the source rule and the recorded premise evidence in order, starting with no bindings, so a state test sees the bindings of its actual call and `once` takes the actual first answer. It does not call the reasoner or supply missing evidence. Rules generated by templates are checked through their instances, and source rule inspection through the program's catalogue. A proof within these bounds can be `checked` with no obligation, even under `--strict-proof`. A `findall_sorted` of ground items is certified from the set of derived facts alone. `findall` and first answers over derived facts, whose order a listing cannot show, and `restricted` rules with new witnesses keep an obligation.
493
+ - **Check the search, not just its result.** A proof ends with its certificate: `called(Call, Answers)` lists each call's answers and `derived(Pattern, Facts)` each consulted relation. The checker expands each call one level against the program, so a wrong table shows up as a disagreement, and requires each listing to be closed under the rules, so an omitted fact shows up too.
494
+ - **Decide at the actual call.** Replay runs each recorded firing from its source rule with the bindings of each point of the search, so a negation sees the goal as it was called, a state test sees the bindings of its actual call, and `once` takes the actual first answer.
492
495
 
493
496
  ## Checking the translation
494
497
 
@@ -531,7 +534,6 @@ eyemind [OPTION ...] [FILE ...]
531
534
  | `--check-proof FILE` | Check a saved proof (`-` for standard input) against the program. |
532
535
  | `--json` | With a checking mode, print the report as JSON. |
533
536
  | `--goal GOAL` | Ask `GOAL` after forward reasoning; may be repeated. |
534
- | `--strict-proof` | With a checking mode, reject proofs with any obligation. |
535
537
  | `--unused` | List the clauses that make no difference to the conclusions. |
536
538
  | `--stream-messages` | Read an RDF Message Log and run the rules independently per message; Node reads files, stdin and HTTP(S) incrementally. |
537
539
  | `--stats` | Print reasoning statistics as JSON to standard error. |
@@ -543,9 +545,13 @@ eyemind [OPTION ...] [FILE ...]
543
545
  | `-v`, `--version`, `-h`, `--help` | Print the version or the usage. |
544
546
 
545
547
  `--proof`, `--prove-and-check`, `--check-proof` and `--unused` are mutually
546
- exclusive. `--json` and `--strict-proof` need a checking mode. `--goal` reads
548
+ exclusive. `--json` needs a checking mode. `--goal` reads
547
549
  each goal as a data document, with an array denoting conjunction. With
548
550
  `--check-proof`, supply the original goals the proof answers.
551
+ An option that takes a value requires it immediately afterward; another
552
+ option, including a short alias such as `-v`, is reported as a missing value.
553
+ With `--goal`, answers default to eyemind terms even for N3 and SRL inputs;
554
+ use `--to` to request another output format.
549
555
 
550
556
  With `--prove-and-check`, reasoning bounds and `--stats` apply to proof
551
557
  generation; an invalid check returns 2, otherwise the run's halt code is
@@ -582,10 +588,10 @@ Arithmetic also limits integer growth: `pow(A, B)` with integer `B > 0` and
582
588
  2^26. An integer left shift `shl(A, B)` raises an error when `B` exceeds
583
589
  2^26. These limits protect the process from excessively large allocations.
584
590
 
585
- Auxiliary C10 certification is bounded per question by the smaller of the
591
+ Making a proof's call tables is bounded per question by the smaller of the
586
592
  run's inference limit and 500,000 calls plus answers, and by 8,388,608 UTF-16
587
- code units of answer text. Hitting these limits leaves an obligation and
588
- does not change the run's answers.
593
+ code units of answer text. Exceeding these bounds makes `--proof` report an
594
+ error; it does not change the answers of a plain run.
589
595
 
590
596
  ### Unused clauses
591
597
 
@@ -645,7 +651,7 @@ console.log(result.bindings);
645
651
  console.log(checkProof(socrates, result.proof, { goals }).valid);
646
652
  ```
647
653
 
648
- `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, allowTrusted })` checks C1–C10, and `allowTrusted: false` rejects every obligation. `checkReport`, `readTerm`, `readTerms` and `write` format reports and read and write the canonical text.
654
+ `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.
649
655
 
650
656
  ## What is deliberately absent
651
657
 
@@ -662,7 +668,7 @@ npm test -- unit examples # these sections, plus W3C
662
668
  npm test -- -k skolem # only tests whose line contains "skolem"
663
669
  EYEMIND_PROPERTY_SCALE=20 npm test -- -k properties # deeper generated tests
664
670
  node tools/update-examples.js # regenerate example artifacts after an intended change
665
- node tools/report.js # the table npm test ends with, into REPORT.md
671
+ node tools/report.js # run the full suite and write REPORT.md
666
672
  node tools/notation3tests.js # the cached Notation3 suite
667
673
  npm run sync # refresh all three upstream test suites
668
674
  node conformance/run.js --command "my-eyemind" # run the conformance suite against another implementation