eyelang 4.0.5 → 4.0.7
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 +5 -1
- package/bin/eyelang.js +1 -1
- package/conformance-report.md +3 -3
- package/docs/guide.md +15 -14
- package/docs/language-reference.md +16 -14
- package/examples/abstract-interpretation.pl +0 -1
- package/examples/bayes-therapy.pl +1 -4
- package/examples/binomial-vandermonde.pl +1 -2
- package/examples/catalan-convolution.pl +1 -2
- package/examples/chart-parser.pl +1 -2
- package/examples/collatz-1000.pl +1 -2
- package/examples/continued-fraction-sqrt2.pl +1 -2
- package/examples/critical-path-schedule.pl +0 -2
- package/examples/dijkstra-risk-path.pl +0 -1
- package/examples/drone-corridor-planner.pl +0 -1
- package/examples/equality-saturation.pl +0 -2
- package/examples/family-cousins.pl +0 -3
- package/examples/fibonacci.pl +0 -1
- package/examples/gd-step-certified.pl +0 -7
- package/examples/gps.pl +0 -2
- package/examples/hamiltonian-path.pl +0 -1
- package/examples/hanoi.pl +0 -1
- package/examples/integer-partitions.pl +0 -1
- package/examples/intuitionistic-logic-kripke.pl +0 -2
- package/examples/knuth-bendix-completion.pl +0 -1
- package/examples/language.pl +1 -2
- package/examples/matrix-chain-order.pl +1 -2
- package/examples/modular-exponentiation.pl +0 -1
- package/examples/monkey-bananas.pl +0 -1
- package/examples/n-queens-8.pl +0 -1
- package/examples/partial-evaluator.pl +0 -1
- package/examples/peano-calculus.pl +0 -3
- package/examples/pell-equation.pl +1 -2
- package/examples/pointer-analysis.pl +0 -2
- package/examples/prime-range.pl +0 -1
- package/examples/proof/chart-parser.pl +71 -71
- package/examples/proof/hanoi.pl +16 -16
- package/examples/proof/intuitionistic-logic-kripke.pl +16 -16
- package/examples/route-planning.pl +0 -1
- package/examples/stirling-bell-numbers.pl +0 -4
- package/examples/totient-summatory.pl +1 -3
- package/examples/truth-maintenance-system.pl +0 -1
- package/examples/type-inference.pl +0 -1
- package/examples/web-names.pl +0 -1
- package/examples/weighted-interval-scheduling.pl +2 -3
- package/examples/wolf-goat-cabbage.pl +0 -1
- package/package.json +3 -4
- package/src/explain.js +3 -1
- package/src/program.js +24 -9
- package/test/conformance/README.md +2 -2
- package/test/conformance/cases/{table/038_table_declaration.pl → automatic-tabling/038_automatic_tabling.pl} +1 -2
- package/test/conformance/cases/{table/102_table_declaration.pl → automatic-tabling/102_recursive_inference.pl} +1 -2
- package/test/conformance/cases/{table/tabled_left_recursion_path.pl → automatic-tabling/automatic_left_recursion_path.pl} +0 -1
- package/test/conformance/cases/{table/table_does_not_change_answers.pl → automatic-tabling/automatic_tabling_preserves_answers.pl} +1 -2
- package/test/conformance/cases/{table/extra_table_bound_cycle.pl → automatic-tabling/extra_automatic_bound_cycle.pl} +0 -1
- package/test/conformance/cases/{table/extra_table_open_call_fallback.pl → automatic-tabling/extra_automatic_open_call_fallback.pl} +0 -1
- package/test/conformance/cases/rules/transitive_rule_three_edges.pl +0 -1
- package/test/conformance/expected-proofs/proofs/{table_recursive.pl → automatic_recursive.pl} +8 -8
- package/test/conformance/expected-proofs/proofs/{extra_table_path_bound.pl → extra_automatic_path_bound.pl} +8 -8
- package/test/conformance/proofs/proofs/{table_recursive.pl → automatic_recursive.pl} +1 -2
- package/test/conformance/proofs/proofs/{extra_table_path_bound.pl → extra_automatic_path_bound.pl} +0 -1
- package/test/conformance/warnings/negation/{extra_stratified_negation_with_table_quiet.pl → extra_stratified_negation_with_recursion_quiet.pl} +0 -1
- package/test/run-regression.mjs +11 -11
- package/test/conformance/cases/declarations/table_is_also_fact.pl +0 -4
- package/test/conformance/expected/declarations/table_is_also_fact.pl +0 -1
- /package/test/conformance/expected/{table/038_table_declaration.pl → automatic-tabling/038_automatic_tabling.pl} +0 -0
- /package/test/conformance/expected/{table/102_table_declaration.pl → automatic-tabling/102_recursive_inference.pl} +0 -0
- /package/test/conformance/expected/{table/tabled_left_recursion_path.pl → automatic-tabling/automatic_left_recursion_path.pl} +0 -0
- /package/test/conformance/expected/{table/table_does_not_change_answers.pl → automatic-tabling/automatic_tabling_preserves_answers.pl} +0 -0
- /package/test/conformance/expected/{table/extra_table_bound_cycle.pl → automatic-tabling/extra_automatic_bound_cycle.pl} +0 -0
- /package/test/conformance/expected/{table/extra_table_open_call_fallback.pl → automatic-tabling/extra_automatic_open_call_fallback.pl} +0 -0
- /package/test/conformance/expected-warnings/negation/{extra_stratified_negation_with_table_quiet.pl → extra_stratified_negation_with_recursion_quiet.pl} +0 -0
- /package/test/conformance/expected-warnings/negation/{extra_stratified_negation_with_table_quiet.txt → extra_stratified_negation_with_recursion_quiet.txt} +0 -0
package/README.md
CHANGED
|
@@ -7,6 +7,10 @@ Eyelang is a small reasoning language for turning facts and rules into answers a
|
|
|
7
7
|
|
|
8
8
|
Prolog-like syntax. Small core. Inspectable results.
|
|
9
9
|
|
|
10
|
+
Its default execution is automatically hybrid: ordinary goals use indexed
|
|
11
|
+
depth-first resolution, while recursive helper predicate groups are detected
|
|
12
|
+
and tabled automatically.
|
|
13
|
+
|
|
10
14
|
## Install and run
|
|
11
15
|
|
|
12
16
|
Eyelang has no runtime npm dependencies and no build step. From a source checkout, run the CLI directly with Node.js 18 or newer:
|
|
@@ -63,7 +67,7 @@ python3 -m http.server
|
|
|
63
67
|
```bash
|
|
64
68
|
npm test
|
|
65
69
|
npm run test:conformance
|
|
66
|
-
|
|
70
|
+
node test/run-conformance-report.mjs
|
|
67
71
|
# release preparation writes conformance-report.md via the preversion script
|
|
68
72
|
npm run test:examples
|
|
69
73
|
npm run test:regression
|
package/bin/eyelang.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { main } from '../src/cli.js';
|
|
3
3
|
|
|
4
|
-
main(process.argv.slice(2)).catch((error) => {
|
|
4
|
+
await main(process.argv.slice(2)).catch((error) => {
|
|
5
5
|
console.error(`eyelang: ${error && error.message ? error.message : String(error)}`);
|
|
6
6
|
process.exit(1);
|
|
7
7
|
});
|
package/conformance-report.md
CHANGED
|
@@ -7,10 +7,11 @@ This report summarizes the file-based conformance corpus under `test/conformance
|
|
|
7
7
|
| aggregation | 17 | 0 | 0 | 0 | 17 |
|
|
8
8
|
| arithmetic | 40 | 0 | 0 | 0 | 40 |
|
|
9
9
|
| atoms | 22 | 8 | 0 | 0 | 30 |
|
|
10
|
+
| automatic-tabling | 6 | 0 | 0 | 0 | 6 |
|
|
10
11
|
| builtins | 10 | 0 | 0 | 0 | 10 |
|
|
11
12
|
| context | 11 | 0 | 0 | 0 | 11 |
|
|
12
13
|
| control | 15 | 0 | 0 | 0 | 15 |
|
|
13
|
-
| declarations |
|
|
14
|
+
| declarations | 5 | 0 | 0 | 0 | 5 |
|
|
14
15
|
| lists | 54 | 3 | 0 | 0 | 57 |
|
|
15
16
|
| materialize | 8 | 0 | 0 | 0 | 8 |
|
|
16
17
|
| negation | 8 | 0 | 19 | 0 | 27 |
|
|
@@ -18,8 +19,7 @@ This report summarizes the file-based conformance corpus under `test/conformance
|
|
|
18
19
|
| rules | 12 | 3 | 0 | 0 | 15 |
|
|
19
20
|
| strings | 40 | 0 | 0 | 0 | 40 |
|
|
20
21
|
| syntax | 11 | 28 | 0 | 0 | 39 |
|
|
21
|
-
| table | 6 | 0 | 0 | 0 | 6 |
|
|
22
22
|
| terms | 29 | 3 | 0 | 0 | 32 |
|
|
23
23
|
| unification | 16 | 0 | 0 | 0 | 16 |
|
|
24
24
|
| variables | 16 | 11 | 0 | 0 | 27 |
|
|
25
|
-
| **Total** | **
|
|
25
|
+
| **Total** | **320** | **56** | **19** | **21** | **416** |
|
package/docs/guide.md
CHANGED
|
@@ -4,8 +4,13 @@ This guide introduces Eyelang, a small Horn-clause language and engine whose sou
|
|
|
4
4
|
|
|
5
5
|
Programs write relations directly, for example `ancestor(pat, emma)` or `status(case1, accepted)`. Web identifiers can be written as ordinary quoted atoms that include angle brackets, for example `'<https://schema.org/name>'`, when a program needs explicit IRI-shaped names without prefix declarations. Eyelang output is ordinary Eyelang syntax: by default, the CLI materializes selected answer facts and prints those facts only. Pass `--proof` (or `-p`) when you also want each answer followed by a `why/2` explanation fact that records the proof. Programs may add `materialize/2` declarations such as `materialize(answer, 2).` to focus output on selected predicates.
|
|
6
6
|
|
|
7
|
+
Execution is automatically hybrid. Ordinary predicates use indexed
|
|
8
|
+
goal-directed resolution, while dependency analysis detects recursive groups
|
|
9
|
+
and tables their bound calls. Programs describe relations without choosing the
|
|
10
|
+
engine's search strategy.
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
|
|
13
|
+
For the normative language definition, including lexical syntax, terms, clauses, goals, built-ins, automatic hybrid reasoning, `materialize/2`, and conformance boundaries, read the [Eyelang language reference](language-reference.md).
|
|
9
14
|
|
|
10
15
|
## Contents
|
|
11
16
|
|
|
@@ -197,7 +202,7 @@ The default output is then:
|
|
|
197
202
|
answer(case1, accepted).
|
|
198
203
|
```
|
|
199
204
|
|
|
200
|
-
`materialize/2` is a declaration, not a logical rule to prove. It affects which predicates the CLI prints, not the meaning of the rules themselves. Materialized output facts are not inserted back into the running program for later goals
|
|
205
|
+
`materialize/2` is a declaration, not a logical rule to prove. It affects which predicates the CLI prints, not the meaning of the rules themselves. Materialized output facts are not inserted back into the running program for later goals. Source facts are indexed and reused normally, and answers for automatically tabled recursive predicates are reused inside the same solver run.
|
|
201
206
|
|
|
202
207
|
## Writing programs
|
|
203
208
|
|
|
@@ -334,9 +339,9 @@ Use `holds/2` when you want to match the member term directly, for example `name
|
|
|
334
339
|
| [`cache-performance.pl`](../examples/cache-performance.pl) | Summarizes cache latency performance. | [`output/cache-performance.pl`](../examples/output/cache-performance.pl) |
|
|
335
340
|
| [`canary-release.pl`](../examples/canary-release.pl) | Decides canary rollout or rollback. | [`output/canary-release.pl`](../examples/output/canary-release.pl) |
|
|
336
341
|
| [`cat-koko.pl`](../examples/cat-koko.pl) | Demonstrates named existential witnesses from a Cat Koko rule pattern. | [`output/cat-koko.pl`](../examples/output/cat-koko.pl) |
|
|
337
|
-
| [`catalan-convolution.pl`](../examples/catalan-convolution.pl) | Computes Catalan numbers by tabled convolution. | [`output/catalan-convolution.pl`](../examples/output/catalan-convolution.pl) |
|
|
342
|
+
| [`catalan-convolution.pl`](../examples/catalan-convolution.pl) | Computes Catalan numbers by automatically tabled convolution. | [`output/catalan-convolution.pl`](../examples/output/catalan-convolution.pl) |
|
|
338
343
|
| [`cdcl-sat-solver.pl`](../examples/cdcl-sat-solver.pl) | Simulates one CDCL conflict-analysis step with a learned clause and backjumped model. | [`output/cdcl-sat-solver.pl`](../examples/output/cdcl-sat-solver.pl) |
|
|
339
|
-
| [`chart-parser.pl`](../examples/chart-parser.pl) | Parses small sentences with
|
|
344
|
+
| [`chart-parser.pl`](../examples/chart-parser.pl) | Parses small sentences with an automatically tabled chart parser. | [`output/chart-parser.pl`](../examples/output/chart-parser.pl) |
|
|
340
345
|
| [`clinical-trial-screening.pl`](../examples/clinical-trial-screening.pl) | Screens candidates for a trial. | [`output/clinical-trial-screening.pl`](../examples/output/clinical-trial-screening.pl) |
|
|
341
346
|
| [`collatz-1000.pl`](../examples/collatz-1000.pl) | Materializes Collatz trajectories for starts 1000 down to 1. | [`output/collatz-1000.pl`](../examples/output/collatz-1000.pl) |
|
|
342
347
|
| [`combinatorics-findall-sort.pl`](../examples/combinatorics-findall-sort.pl) | Collects and sorts finite combinations. | [`output/combinatorics-findall-sort.pl`](../examples/output/combinatorics-findall-sort.pl) |
|
|
@@ -405,7 +410,7 @@ Use `holds/2` when you want to match the member term directly, for example `name
|
|
|
405
410
|
| [`heron-theorem.pl`](../examples/heron-theorem.pl) | Computes triangle area by Heron's theorem. | [`output/heron-theorem.pl`](../examples/output/heron-theorem.pl) |
|
|
406
411
|
| [`ideal-gas-law.pl`](../examples/ideal-gas-law.pl) | Applies the ideal gas law. | [`output/ideal-gas-law.pl`](../examples/output/ideal-gas-law.pl) |
|
|
407
412
|
| [`illegitimate-reasoning.pl`](../examples/illegitimate-reasoning.pl) | Detects suspect reasoning patterns. | [`output/illegitimate-reasoning.pl`](../examples/output/illegitimate-reasoning.pl) |
|
|
408
|
-
| [`integer-partitions.pl`](../examples/integer-partitions.pl) | Counts integer partitions with
|
|
413
|
+
| [`integer-partitions.pl`](../examples/integer-partitions.pl) | Counts integer partitions with automatic tabling. | [`output/integer-partitions.pl`](../examples/output/integer-partitions.pl) |
|
|
409
414
|
| [`intuitionistic-logic-kripke.pl`](../examples/intuitionistic-logic-kripke.pl) | Emulates intuitionistic Kripke forcing and constructive implication. | [`output/intuitionistic-logic-kripke.pl`](../examples/output/intuitionistic-logic-kripke.pl) |
|
|
410
415
|
| [`job-shop-scheduling.pl`](../examples/job-shop-scheduling.pl) | Searches a small job-shop schedule and minimizes makespan. | [`output/job-shop-scheduling.pl`](../examples/output/job-shop-scheduling.pl) |
|
|
411
416
|
| [`knapsack-optimization.pl`](../examples/knapsack-optimization.pl) | Optimizes a finite 0/1 knapsack pack with aggregation. | [`output/knapsack-optimization.pl`](../examples/output/knapsack-optimization.pl) |
|
|
@@ -478,7 +483,7 @@ Use `holds/2` when you want to match the member term directly, for example `name
|
|
|
478
483
|
| [`vector-similarity.pl`](../examples/vector-similarity.pl) | Computes dot product, norm, and cosine similarity. | [`output/vector-similarity.pl`](../examples/output/vector-similarity.pl) |
|
|
479
484
|
| [`vulnerability-impact.pl`](../examples/vulnerability-impact.pl) | Analyzes vulnerable transitive dependencies and urgent patch impact. | [`output/vulnerability-impact.pl`](../examples/output/vulnerability-impact.pl) |
|
|
480
485
|
| [`web-names.pl`](../examples/web-names.pl) | Uses quoted IRI-shaped atoms as first-class web names and joins them across a tiny graph. | [`output/web-names.pl`](../examples/output/web-names.pl) |
|
|
481
|
-
| [`weighted-interval-scheduling.pl`](../examples/weighted-interval-scheduling.pl) | Selects the best non-overlapping weighted intervals with
|
|
486
|
+
| [`weighted-interval-scheduling.pl`](../examples/weighted-interval-scheduling.pl) | Selects the best non-overlapping weighted intervals with automatic tabling. | [`output/weighted-interval-scheduling.pl`](../examples/output/weighted-interval-scheduling.pl) |
|
|
482
487
|
| [`witch.pl`](../examples/witch.pl) | Derives the classic “burn the witch” rule chain. | [`output/witch.pl`](../examples/output/witch.pl) |
|
|
483
488
|
| [`wolf-goat-cabbage.pl`](../examples/wolf-goat-cabbage.pl) | Solves the wolf-goat-cabbage river crossing. | [`output/wolf-goat-cabbage.pl`](../examples/output/wolf-goat-cabbage.pl) |
|
|
484
489
|
| [`workplace-compliance.pl`](../examples/workplace-compliance.pl) | Classifies workplace compliance from explicit action facts. | [`output/workplace-compliance.pl`](../examples/output/workplace-compliance.pl) |
|
|
@@ -520,7 +525,7 @@ node test/run-examples.mjs
|
|
|
520
525
|
Summarize the conformance corpus by category:
|
|
521
526
|
|
|
522
527
|
```sh
|
|
523
|
-
|
|
528
|
+
node test/run-conformance-report.mjs
|
|
524
529
|
```
|
|
525
530
|
|
|
526
531
|
Release preparation runs the same report and writes [`conformance-report.md`](../conformance-report.md), so each published package carries a current conformance summary.
|
|
@@ -534,7 +539,7 @@ Common commands:
|
|
|
534
539
|
```sh
|
|
535
540
|
npm run test:eyelang # alias for npm test
|
|
536
541
|
npm test # full conformance, regression/API/white-box, examples, and proof examples
|
|
537
|
-
|
|
542
|
+
node test/run-conformance-report.mjs # conformance coverage summary by category
|
|
538
543
|
node test/run-conformance.mjs
|
|
539
544
|
node test/run-regression.mjs
|
|
540
545
|
node test/run-examples.mjs
|
|
@@ -553,7 +558,7 @@ For a release:
|
|
|
553
558
|
2. update `README.md` and the language reference;
|
|
554
559
|
3. regenerate golden outputs if behavior changed;
|
|
555
560
|
4. run `npm run test:eyelang`;
|
|
556
|
-
5. run `
|
|
561
|
+
5. run `node test/run-conformance-report.mjs conformance-report.md`;
|
|
557
562
|
6. publish the repository with the browser playground assets if publishing the playground. The playground includes controls equivalent to CLI `--stats` and `--proof`.
|
|
558
563
|
|
|
559
564
|
## Relationship to Eyeling
|
|
@@ -599,11 +604,7 @@ path(a, Y).
|
|
|
599
604
|
status(Case, accepted).
|
|
600
605
|
```
|
|
601
606
|
|
|
602
|
-
Ground facts use a fast path that avoids freshening and copying a rule body. Recursive-predicate detection uses an explicit work stack, which keeps large predicate chains safer in the browser.
|
|
603
|
-
|
|
604
|
-
```eyelang
|
|
605
|
-
table(path, 2).
|
|
606
|
-
```
|
|
607
|
+
Ground facts use a fast path that avoids freshening and copying a rule body. Recursive-predicate detection uses an explicit work stack, which keeps large predicate chains safer in the browser. eyelang automatically tables recursive helper groups, including dependencies reached through supported meta-goals. Directly materialized recursive relations and other goals use ordinary depth-first resolution; this preserves cyclic open-relation traversal. Fully open calls retain the ordinary path rather than materializing an entire relation. Authors do not need a search-control declaration.
|
|
607
608
|
|
|
608
609
|
Predicates can also carry advisory mode and determinism declarations for documentation and host tooling:
|
|
609
610
|
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
- [9.10 Search control](#910-search-control)
|
|
47
47
|
- [10. Implementation-specific built-ins](#10-implementation-specific-built-ins)
|
|
48
48
|
- [11. Declarations](#11-declarations)
|
|
49
|
-
- [11.1
|
|
49
|
+
- [11.1 Automatic hybrid reasoning](#111-automatic-hybrid-reasoning)
|
|
50
50
|
- [11.2 Default-output materialization](#112-default-output-materialization)
|
|
51
51
|
- [12. eyelang Sockets](#12-eyelang-sockets)
|
|
52
52
|
- [12.1 Socket vocabulary](#121-socket-vocabulary)
|
|
@@ -634,19 +634,21 @@ An implementation that provides explanation output SHOULD make implementation-sp
|
|
|
634
634
|
|
|
635
635
|
Declarations are written as ordinary facts, but the host treats them specially.
|
|
636
636
|
|
|
637
|
-
### 11.1
|
|
637
|
+
### 11.1 Automatic hybrid reasoning
|
|
638
638
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
639
|
+
eyelang automatically combines ordinary goal-directed resolution with tabled
|
|
640
|
+
resolution. Predicate dependency cycles are detected when a program is loaded,
|
|
641
|
+
including dependencies inside conjunctions, negation, `once/1`, `forall/2`, and
|
|
642
|
+
aggregation goals. Recursive helper predicate groups are tabled automatically;
|
|
643
|
+
directly materialized recursive relations and other groups use ordinary
|
|
644
|
+
depth-first resolution and indexed fact lookup. This conservative boundary
|
|
645
|
+
avoids prematurely completing bound subcalls when an open output relation walks
|
|
646
|
+
cyclic data. Authors do not select an execution strategy in source code.
|
|
642
647
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
```eyelang
|
|
648
|
-
table(path, 2).
|
|
649
|
-
```
|
|
648
|
+
For a tabled call with at least one bound argument, answers may be cached and
|
|
649
|
+
reused within a solver run. Fully open calls continue with ordinary resolution
|
|
650
|
+
so that tabling does not force the whole relation to be materialized. This is a
|
|
651
|
+
search-control strategy and does not change the logical meaning of a program.
|
|
650
652
|
|
|
651
653
|
### 11.2 Default-output materialization
|
|
652
654
|
|
|
@@ -663,7 +665,7 @@ materialize(status, 2).
|
|
|
663
665
|
materialize(reason, 2).
|
|
664
666
|
```
|
|
665
667
|
|
|
666
|
-
`materialize/2` affects host output selection only; it does not change the logical meaning of the program. Materialized output facts are not asserted as new source facts for subsequent output goals. A host MAY solve several materialized predicates in one solver run, and tabled predicate answers MAY be reused within that run
|
|
668
|
+
`materialize/2` affects host output selection only; it does not change the logical meaning of the program. Materialized output facts are not asserted as new source facts for subsequent output goals. A host MAY solve several materialized predicates in one solver run, and automatically tabled predicate answers MAY be reused within that run.
|
|
667
669
|
|
|
668
670
|
### 11.3 Advisory modes and determinism
|
|
669
671
|
|
|
@@ -788,7 +790,7 @@ A conforming eyelang implementation supports the standard language described abo
|
|
|
788
790
|
- lists and comma conjunctions;
|
|
789
791
|
- answer printing and read-back formatting;
|
|
790
792
|
- the standard built-ins listed in section 9;
|
|
791
|
-
-
|
|
793
|
+
- automatic hybrid goal-directed and tabled execution;
|
|
792
794
|
- `materialize/2` declarations;
|
|
793
795
|
- advisory `mode/3`, `det/2`, and `semidet/2` declarations;
|
|
794
796
|
- default derived output;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
%
|
|
5
5
|
% Read this as two stacked inference problems: first infer disease posterior
|
|
6
6
|
% probabilities from symptoms, then score each therapy by averaging outcomes
|
|
7
|
-
% over that posterior distribution. The
|
|
7
|
+
% over that posterior distribution. The recursive predicates are
|
|
8
8
|
% shared layers used by several materialized reports.
|
|
9
9
|
materialize(diseases, 2).
|
|
10
10
|
materialize(therapies, 2).
|
|
@@ -19,9 +19,6 @@ materialize(utility, 2).
|
|
|
19
19
|
materialize(recommendedTherapy, 2).
|
|
20
20
|
|
|
21
21
|
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
22
|
-
table(scores_for, 2).
|
|
23
|
-
table(likelihood, 3).
|
|
24
|
-
table(expected_success, 2).
|
|
25
22
|
|
|
26
23
|
% Bayes therapy decision support adapted from Eyeling bayes-therapy.n3.
|
|
27
24
|
% Probabilities are illustrative and are not medical advice.
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
% the binomial-row prefixes shared across both sides of the identity.
|
|
6
6
|
% choose_step/5 uses the multiplicative recurrence
|
|
7
7
|
% C(N, I+1) = C(N, I) * (N-I) / (I+1)
|
|
8
|
-
% and is
|
|
8
|
+
% and is cached automatically because row sums and identities reuse prefixes.
|
|
9
9
|
materialize(binomial_answer, 2).
|
|
10
10
|
|
|
11
|
-
table(choose_step, 5).
|
|
12
11
|
|
|
13
12
|
choose(N, K, C) :-
|
|
14
13
|
ge(K, 0),
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
% Catalan numbers by tabled convolution.
|
|
1
|
+
% Catalan numbers by automatically tabled convolution.
|
|
2
2
|
%
|
|
3
3
|
% catalan(N,C) sums all splits of N-1 into left and right substructures. The same
|
|
4
4
|
% Catalan values appear in binary tree shapes, parenthesizations, and polygon
|
|
5
5
|
% triangulations, shown here with small wrapper predicates.
|
|
6
6
|
materialize(catalan_answer, 2).
|
|
7
7
|
|
|
8
|
-
table(catalan, 2).
|
|
9
8
|
|
|
10
9
|
% C_0 = 1; higher values are computed by the convolution sum.
|
|
11
10
|
catalan(0, 1).
|
package/examples/chart-parser.pl
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
% A tiny tabled chart parser for a context-free grammar.
|
|
1
|
+
% A tiny automatically tabled chart parser for a context-free grammar.
|
|
2
2
|
%
|
|
3
3
|
% span(Sentence, Category, Start, End) is the dynamic-programming chart item:
|
|
4
4
|
% Category covers a half-open token interval. Memoizing span/4 turns recursive
|
|
5
5
|
% grammar recognition into chart parsing, so ambiguous phrases share subparses.
|
|
6
6
|
materialize(chart_parser_answer, 2).
|
|
7
7
|
|
|
8
|
-
table(span, 4).
|
|
9
8
|
|
|
10
9
|
% Two sample sentences share the same tiny grammar but have different parse counts.
|
|
11
10
|
|
package/examples/collatz-1000.pl
CHANGED
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
% https://raw.githubusercontent.com/eyereasoner/eyeling/refs/heads/main/examples/collatz-1000.n3
|
|
7
7
|
|
|
8
8
|
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
9
|
-
%
|
|
9
|
+
% Automatic tabling caches shared suffix trajectories so the 1000 starts do not recompute
|
|
10
10
|
% the same Collatz tails hundreds of times.
|
|
11
11
|
materialize(collatzTrajectory, 2).
|
|
12
|
-
table(collatz, 2).
|
|
13
12
|
|
|
14
13
|
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
14
|
% The N3 source defines repeat/2 recursively; this Eyelang version uses the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
% Convergents of sqrt(2) by tabled recurrence.
|
|
1
|
+
% Convergents of sqrt(2) by automatically tabled recurrence.
|
|
2
2
|
%
|
|
3
3
|
% conv(N, P, Q) gives the Nth numerator/denominator pair for [1; 2, 2, ...].
|
|
4
4
|
% Because each convergent depends on the previous two, memoization avoids the
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
% pell_error/2 connects the approximation sequence with P^2 - 2Q^2 = +/-1.
|
|
7
7
|
materialize(convergent_answer, 2).
|
|
8
8
|
|
|
9
|
-
table(conv, 3).
|
|
10
9
|
|
|
11
10
|
% Base convergents are 1/1 and 3/2.
|
|
12
11
|
conv(0, 1, 1).
|
|
@@ -15,7 +15,6 @@ materialize(notes, 2).
|
|
|
15
15
|
materialize(selects, 2).
|
|
16
16
|
|
|
17
17
|
% Cache route-list reductions because several materialized reports ask for the same metrics.
|
|
18
|
-
table(route_cost, 4).
|
|
19
18
|
|
|
20
19
|
% Segments live in a quoted formula term, while candidate paths remain ordinary lists.
|
|
21
20
|
route_network(riskNetwork, (
|
|
@@ -7,9 +7,6 @@ materialize(cousin, 2).
|
|
|
7
7
|
|
|
8
8
|
% The family tree is scoped inside family_graph/2. family_statement/3 projects
|
|
9
9
|
% only the parent and seedBranch facts that the cousin rules need.
|
|
10
|
-
table(family_statement, 3).
|
|
11
|
-
table(generation, 2).
|
|
12
|
-
table(branch, 2).
|
|
13
10
|
|
|
14
11
|
% Family-cousins derivation adapted from Eyeling family-cousins.n3.
|
|
15
12
|
% Generation numbers are derived from parent links; branch labels distinguish
|
package/examples/fibonacci.pl
CHANGED
|
@@ -10,7 +10,6 @@ materialize(fibonacci, 2).
|
|
|
10
10
|
|
|
11
11
|
% fib_case/1 bounds the public queries, while fib_pair/3 implements the
|
|
12
12
|
% fast-doubling recurrence F(2n), F(2n+1) over arbitrary-size integers.
|
|
13
|
-
table(fib_pair, 3).
|
|
14
13
|
|
|
15
14
|
% BigInt Fibonacci via fast doubling, implemented in Prolog using generic
|
|
16
15
|
% decimal add/sub/mul built-ins. The result predicate follows Eyeling's
|
|
@@ -16,13 +16,6 @@ materialize(objectiveBounds, 2).
|
|
|
16
16
|
materialize(widthContractsAt, 2).
|
|
17
17
|
|
|
18
18
|
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
19
|
-
table(x_bounds, 3).
|
|
20
|
-
table(width, 2).
|
|
21
|
-
table(g_bounds, 3).
|
|
22
|
-
table(p_bounds, 3).
|
|
23
|
-
table(midpoint, 3).
|
|
24
|
-
table(f_lower, 2).
|
|
25
|
-
table(f_upper, 2).
|
|
26
19
|
|
|
27
20
|
% Adapted from Eyeling's gd-step-certified.n3.
|
|
28
21
|
% One-dimensional gradient descent over certified interval bounds.
|
package/examples/gps.pl
CHANGED
package/examples/hanoi.pl
CHANGED
package/examples/language.pl
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
% This file intentionally uses the modern Eyelang surface syntax:
|
|
4
4
|
% - `.pl` source files instead of Prolog `.pl` files
|
|
5
5
|
% - ISO Prolog-style uppercase variables
|
|
6
|
-
% -
|
|
6
|
+
% - automatic tabling for recursive predicates
|
|
7
7
|
% - advisory `mode/3` and `semidet/2` declarations
|
|
8
8
|
% - quoted angle-bracket atoms for web-shaped identifiers
|
|
9
9
|
%
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
materialize(path, 2).
|
|
14
14
|
|
|
15
|
-
table(path, 2).
|
|
16
15
|
mode(edge, 2, [in, out]).
|
|
17
16
|
mode(path, 2, [in, out]).
|
|
18
17
|
semidet(edge, 2).
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
% Matrix-chain multiplication order by tabled interval dynamic programming.
|
|
1
|
+
% Matrix-chain multiplication order by automatically tabled interval dynamic programming.
|
|
2
2
|
%
|
|
3
3
|
% cost(I, J, Cost) is the minimum scalar multiplication cost for matrices I..J.
|
|
4
4
|
% best_split/3 records which split obtains that cost, and parenthesization/3
|
|
5
5
|
% reconstructs one optimal multiplication tree.
|
|
6
6
|
materialize(matrix_chain_answer, 2).
|
|
7
7
|
|
|
8
|
-
table(cost, 3).
|
|
9
8
|
|
|
10
9
|
% Matrix dimensions are stored as adjacent p-values: matrix I has dimensions P_{I-1} x P_I.
|
|
11
10
|
|
|
@@ -10,7 +10,6 @@ materialize(plan, 2).
|
|
|
10
10
|
materialize(solved, 2).
|
|
11
11
|
|
|
12
12
|
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
|
-
table(reachable, 3).
|
|
14
13
|
|
|
15
14
|
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
15
|
plan(Moves) :-
|
package/examples/n-queens-8.pl
CHANGED
|
@@ -8,7 +8,6 @@ materialize(n_queens_answer, 2).
|
|
|
8
8
|
% Cache diagonal checks; the same row/distance/suffix states recur across many
|
|
9
9
|
% candidate permutations during the 8-queens search. The example asks only for
|
|
10
10
|
% the first solution with once/1, keeping it playground-friendly.
|
|
11
|
-
table(no_diagonal_attack, 3).
|
|
12
11
|
|
|
13
12
|
perm([], []).
|
|
14
13
|
perm(Items, [X|Rest]) :-
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
% Pell equation x^2 - 2y^2 = 1 by tabled recurrence.
|
|
1
|
+
% Pell equation x^2 - 2y^2 = 1 by automatically tabled recurrence.
|
|
2
2
|
%
|
|
3
3
|
% The fundamental solution (3,2) induces a linear recurrence for all positive
|
|
4
4
|
% solutions of x^2 - 2y^2 = 1. The example materializes later solutions and also
|
|
5
5
|
% rechecks the Diophantine identity so the generated sequence is auditable.
|
|
6
6
|
materialize(pell_answer, 2).
|
|
7
7
|
|
|
8
|
-
table(pell, 3).
|
|
9
8
|
|
|
10
9
|
% N=0 is the neutral solution; each recursive step multiplies by 3 + 2*sqrt(2).
|
|
11
10
|
pell(0, 1, 0).
|