eyelang 4.0.6 → 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.
Files changed (72) hide show
  1. package/README.md +4 -0
  2. package/bin/eyelang.js +1 -1
  3. package/conformance-report.md +3 -3
  4. package/docs/guide.md +12 -11
  5. package/docs/language-reference.md +16 -14
  6. package/examples/abstract-interpretation.pl +0 -1
  7. package/examples/bayes-therapy.pl +1 -4
  8. package/examples/binomial-vandermonde.pl +1 -2
  9. package/examples/catalan-convolution.pl +1 -2
  10. package/examples/chart-parser.pl +1 -2
  11. package/examples/collatz-1000.pl +1 -2
  12. package/examples/continued-fraction-sqrt2.pl +1 -2
  13. package/examples/critical-path-schedule.pl +0 -2
  14. package/examples/dijkstra-risk-path.pl +0 -1
  15. package/examples/drone-corridor-planner.pl +0 -1
  16. package/examples/equality-saturation.pl +0 -2
  17. package/examples/family-cousins.pl +0 -3
  18. package/examples/fibonacci.pl +0 -1
  19. package/examples/gd-step-certified.pl +0 -7
  20. package/examples/gps.pl +0 -2
  21. package/examples/hamiltonian-path.pl +0 -1
  22. package/examples/hanoi.pl +0 -1
  23. package/examples/integer-partitions.pl +0 -1
  24. package/examples/intuitionistic-logic-kripke.pl +0 -2
  25. package/examples/knuth-bendix-completion.pl +0 -1
  26. package/examples/language.pl +1 -2
  27. package/examples/matrix-chain-order.pl +1 -2
  28. package/examples/modular-exponentiation.pl +0 -1
  29. package/examples/monkey-bananas.pl +0 -1
  30. package/examples/n-queens-8.pl +0 -1
  31. package/examples/partial-evaluator.pl +0 -1
  32. package/examples/peano-calculus.pl +0 -3
  33. package/examples/pell-equation.pl +1 -2
  34. package/examples/pointer-analysis.pl +0 -2
  35. package/examples/prime-range.pl +0 -1
  36. package/examples/proof/chart-parser.pl +71 -71
  37. package/examples/proof/hanoi.pl +16 -16
  38. package/examples/proof/intuitionistic-logic-kripke.pl +16 -16
  39. package/examples/route-planning.pl +0 -1
  40. package/examples/stirling-bell-numbers.pl +0 -4
  41. package/examples/totient-summatory.pl +1 -3
  42. package/examples/truth-maintenance-system.pl +0 -1
  43. package/examples/type-inference.pl +0 -1
  44. package/examples/web-names.pl +0 -1
  45. package/examples/weighted-interval-scheduling.pl +2 -3
  46. package/examples/wolf-goat-cabbage.pl +0 -1
  47. package/package.json +1 -1
  48. package/src/explain.js +3 -1
  49. package/src/program.js +24 -9
  50. package/test/conformance/cases/{table/038_table_declaration.pl → automatic-tabling/038_automatic_tabling.pl} +1 -2
  51. package/test/conformance/cases/{table/102_table_declaration.pl → automatic-tabling/102_recursive_inference.pl} +1 -2
  52. package/test/conformance/cases/{table/tabled_left_recursion_path.pl → automatic-tabling/automatic_left_recursion_path.pl} +0 -1
  53. package/test/conformance/cases/{table/table_does_not_change_answers.pl → automatic-tabling/automatic_tabling_preserves_answers.pl} +1 -2
  54. package/test/conformance/cases/{table/extra_table_bound_cycle.pl → automatic-tabling/extra_automatic_bound_cycle.pl} +0 -1
  55. package/test/conformance/cases/{table/extra_table_open_call_fallback.pl → automatic-tabling/extra_automatic_open_call_fallback.pl} +0 -1
  56. package/test/conformance/cases/rules/transitive_rule_three_edges.pl +0 -1
  57. package/test/conformance/expected-proofs/proofs/{table_recursive.pl → automatic_recursive.pl} +8 -8
  58. package/test/conformance/expected-proofs/proofs/{extra_table_path_bound.pl → extra_automatic_path_bound.pl} +8 -8
  59. package/test/conformance/proofs/proofs/{table_recursive.pl → automatic_recursive.pl} +1 -2
  60. package/test/conformance/proofs/proofs/{extra_table_path_bound.pl → extra_automatic_path_bound.pl} +0 -1
  61. package/test/conformance/warnings/negation/{extra_stratified_negation_with_table_quiet.pl → extra_stratified_negation_with_recursion_quiet.pl} +0 -1
  62. package/test/run-regression.mjs +11 -11
  63. package/test/conformance/cases/declarations/table_is_also_fact.pl +0 -4
  64. package/test/conformance/expected/declarations/table_is_also_fact.pl +0 -1
  65. /package/test/conformance/expected/{table/038_table_declaration.pl → automatic-tabling/038_automatic_tabling.pl} +0 -0
  66. /package/test/conformance/expected/{table/102_table_declaration.pl → automatic-tabling/102_recursive_inference.pl} +0 -0
  67. /package/test/conformance/expected/{table/tabled_left_recursion_path.pl → automatic-tabling/automatic_left_recursion_path.pl} +0 -0
  68. /package/test/conformance/expected/{table/table_does_not_change_answers.pl → automatic-tabling/automatic_tabling_preserves_answers.pl} +0 -0
  69. /package/test/conformance/expected/{table/extra_table_bound_cycle.pl → automatic-tabling/extra_automatic_bound_cycle.pl} +0 -0
  70. /package/test/conformance/expected/{table/extra_table_open_call_fallback.pl → automatic-tabling/extra_automatic_open_call_fallback.pl} +0 -0
  71. /package/test/conformance/expected-warnings/negation/{extra_stratified_negation_with_table_quiet.pl → extra_stratified_negation_with_recursion_quiet.pl} +0 -0
  72. /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:
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
  });
@@ -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 | 6 | 0 | 0 | 0 | 6 |
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** | **321** | **56** | **19** | **21** | **417** |
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
- For the normative language definition, including lexical syntax, terms, clauses, goals, built-ins, `table/2`, `materialize/2`, and conformance boundaries, read the [Eyelang language reference](language-reference.md).
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; if later output predicates reuse the same derived helper relation, eyelang proves it again unless that helper is declared with `table/2`. Source facts are indexed and reused normally, and tabled solved goals are reused inside the same solver run.
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 a tabled chart parser. | [`output/chart-parser.pl`](../examples/output/chart-parser.pl) |
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 tabled dynamic programming. | [`output/integer-partitions.pl`](../examples/output/integer-partitions.pl) |
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 tabled dynamic programming. | [`output/weighted-interval-scheduling.pl`](../examples/output/weighted-interval-scheduling.pl) |
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) |
@@ -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. Recursive examples use an active-call variant guard to prevent common cyclic closures from looping. Selected predicates can be tabled with:
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 Tabling](#111-tabling)
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 Tabling
637
+ ### 11.1 Automatic hybrid reasoning
638
638
 
639
- ```eyelang
640
- table(path, 2).
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
- The first argument MUST be an atom constant and the second argument MUST be a non-negative integer. A `table/2` declaration asks the solver to table answers for the named predicate group when applicable. The old `memoize/2` spelling is not part of the eyelang language.
644
-
645
- Example:
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, but this reuse is controlled by `table/2`, not by materialization.
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
- - `table/2` declarations;
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;
@@ -15,7 +15,6 @@ materialize(absState, 3).
15
15
  materialize(absWarning, 2).
16
16
  materialize(absConclusion, 2).
17
17
 
18
- table(abs_state, 3).
19
18
 
20
19
  % The abstract domain.
21
20
  input_sign(neg).
@@ -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 tabled predicates are exactly 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 tabled because row sums and identities reuse prefixes.
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).
@@ -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
 
@@ -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
- % table/2 caches shared suffix trajectories so the 1000 starts do not recompute
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).
@@ -6,8 +6,6 @@
6
6
  % queries share the same project-network subproblems.
7
7
  materialize(critical_path_answer, 2).
8
8
 
9
- table(earliest_start, 2).
10
- table(finish_time, 2).
11
9
 
12
10
  % Durations are in arbitrary project time units.
13
11
  task(requirements, 2).
@@ -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, (
@@ -5,7 +5,6 @@
5
5
 
6
6
  materialize(gps_plan, 2).
7
7
 
8
- table(path, 9).
9
8
 
10
9
  fuel(fuel7, [t, t, t, t, t, t, t]).
11
10
 
@@ -11,8 +11,6 @@
11
11
 
12
12
  materialize(egraphAnswer, 2).
13
13
 
14
- table(equivalent_at_depth, 3).
15
- table(expr_cost, 2).
16
14
 
17
15
  % Start expression:
18
16
  % ((x + 0) * 1) + 2 * (1 + 2)
@@ -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
@@ -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
@@ -15,8 +15,6 @@ materialize(comfort, 2).
15
15
  materialize(selectedRoute, 2).
16
16
  materialize(comparison, 2).
17
17
 
18
- table(path, 7).
19
- table(traveller_path, 6).
20
18
 
21
19
  case_graph(caseGraph, (
22
20
  location(i1, gent),
@@ -10,7 +10,6 @@ materialize(hamiltonianPath, 2).
10
10
 
11
11
  % The finite six-vertex graph is small enough to search directly. adjacent/2
12
12
  % is tabled because every candidate path repeatedly asks the same edge tests.
13
- table(adjacent, 2).
14
13
 
15
14
  edge(v1, v2).
16
15
  edge(v1, v3).
package/examples/hanoi.pl CHANGED
@@ -5,7 +5,6 @@
5
5
 
6
6
  materialize(answer, 2).
7
7
 
8
- table(hanoi, 5).
9
8
 
10
9
  hanoi(0, _from, _to, _via, []).
11
10
  hanoi(N, From, To, Via, Moves) :-
@@ -5,7 +5,6 @@
5
5
  % memoization the same (N,K) subproblems are reached many times.
6
6
  materialize(partition_answer, 2).
7
7
 
8
- table(partitions, 3).
9
8
 
10
9
  % One empty sum partitions zero; positive N with K=0 is impossible.
11
10
  partitions(0, _k, 1).
@@ -8,8 +8,6 @@
8
8
  materialize(intuitionistic_truth, 3).
9
9
  materialize(intuitionistic_countermodel, 3).
10
10
 
11
- table(leq, 2).
12
- table(forces, 2).
13
11
 
14
12
  world(root).
15
13
  world(left).
@@ -8,7 +8,6 @@
8
8
 
9
9
  materialize(kbAnswer, 2).
10
10
 
11
- table(normal_form, 2).
12
11
 
13
12
  % Oriented equations for a monoid-like append constructor.
14
13
  % append(nil, x) -> x
@@ -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
- % - `table/2` for tabled recursive predicates
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
 
@@ -5,7 +5,6 @@
5
5
  % are reused by Fermat-style congruence checks.
6
6
  materialize(modular_answer, 2).
7
7
 
8
- table(pow_mod, 4).
9
8
 
10
9
  % Base case: any nonzero base to exponent zero is 1 modulo Mod.
11
10
  pow_mod(_base, 0, Mod, Result) :- mod(1, Mod, Result).
@@ -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) :-
@@ -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]) :-
@@ -8,7 +8,6 @@
8
8
 
9
9
  materialize(partialEvalAnswer, 2).
10
10
 
11
- table(pe, 3).
12
11
 
13
12
  % Expression language: const/1, bool/1, var/1, add/2, mul/2, and if/3.
14
13
  % Static environments are lists of bind(Name, ResidualValue) terms.
@@ -6,9 +6,6 @@
6
6
  % a few finite calculations as readable examples.
7
7
 
8
8
  materialize(peano_answer, 2).
9
- table(padd, 3).
10
- table(pmul, 3).
11
- table(pfact, 2).
12
9
 
13
10
  % Addition.
14
11
  padd(A, z, A).
@@ -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).
@@ -10,8 +10,6 @@ materialize(heapField, 2).
10
10
  materialize(pointerFlow, 2).
11
11
  materialize(pointerConclusion, 2).
12
12
 
13
- table(points_to, 2).
14
- table(field_points_to, 2).
15
13
 
16
14
  % Source-program statements:
17
15
  % x = &object_a
@@ -6,7 +6,6 @@
6
6
  % composite, and `totient/2` counts numbers coprime with the input.
7
7
 
8
8
  materialize(prime_result, 2).
9
- table(gcd, 3).
10
9
 
11
10
  candidate(N) :-
12
11
  between(2, 30, N).