eyeling 1.34.2 → 1.34.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.
Files changed (69) hide show
  1. package/README.md +7 -10
  2. package/docs/eyelang-guide.md +8 -30
  3. package/docs/eyelang-language-reference.md +32 -6
  4. package/examples/eyelang/basic-monadic.pl +16 -2
  5. package/examples/eyelang/bayes-therapy.pl +4 -4
  6. package/examples/eyelang/output/basic-monadic.pl +1314 -1314
  7. package/examples/eyelang/output/path-discovery.pl +3 -3
  8. package/examples/eyelang/output/reusable-builtins.pl +5 -0
  9. package/examples/eyelang/output/term-tools.pl +6 -0
  10. package/examples/eyelang/path-discovery.pl +22 -7
  11. package/examples/eyelang/reusable-builtins.pl +32 -0
  12. package/examples/eyelang/term-tools.pl +23 -0
  13. package/lib/eyelang/builtins/arithmetic.js +19 -6
  14. package/lib/eyelang/builtins/control.js +12 -0
  15. package/lib/eyelang/builtins/lists.js +146 -7
  16. package/lib/eyelang/builtins/registry.js +2 -4
  17. package/lib/eyelang/builtins/strings.js +165 -1
  18. package/lib/eyelang/builtins/terms.js +66 -0
  19. package/package.json +1 -1
  20. package/test/eyelang/conformance/README.md +1 -1
  21. package/test/eyelang/conformance/cases/extension/036_reusable_numeric_builtins.pl +10 -0
  22. package/test/eyelang/conformance/cases/extension/037_reusable_list_builtins.pl +11 -0
  23. package/test/eyelang/conformance/cases/extension/038_reusable_string_builtins.pl +12 -0
  24. package/test/eyelang/conformance/cases/extension/039_reusable_term_control_builtins.pl +11 -0
  25. package/test/eyelang/conformance/expected/extension/036_reusable_numeric_builtins.out +8 -0
  26. package/test/eyelang/conformance/expected/extension/037_reusable_list_builtins.out +9 -0
  27. package/test/eyelang/conformance/expected/extension/038_reusable_string_builtins.out +10 -0
  28. package/test/eyelang/conformance/expected/extension/039_reusable_term_control_builtins.out +6 -0
  29. package/examples/eyelang/collatz-1000.pl +0 -14
  30. package/examples/eyelang/complex-matrix-stability.pl +0 -45
  31. package/examples/eyelang/dense-hamiltonian-cycle.pl +0 -92
  32. package/examples/eyelang/gcd-bezout-identity.pl +0 -48
  33. package/examples/eyelang/goldbach-1000.pl +0 -185
  34. package/examples/eyelang/hamiltonian-cycle.pl +0 -55
  35. package/examples/eyelang/kaprekar.pl +0 -32
  36. package/examples/eyelang/matrix.pl +0 -296
  37. package/examples/eyelang/n-queens.pl +0 -23
  38. package/examples/eyelang/output/collatz-1000.pl +0 -1000
  39. package/examples/eyelang/output/complex-matrix-stability.pl +0 -5
  40. package/examples/eyelang/output/dense-hamiltonian-cycle.pl +0 -4
  41. package/examples/eyelang/output/gcd-bezout-identity.pl +0 -36
  42. package/examples/eyelang/output/goldbach-1000.pl +0 -667
  43. package/examples/eyelang/output/hamiltonian-cycle.pl +0 -4
  44. package/examples/eyelang/output/kaprekar.pl +0 -8
  45. package/examples/eyelang/output/matrix.pl +0 -10
  46. package/examples/eyelang/output/n-queens.pl +0 -93
  47. package/examples/eyelang/output/quine-mccluskey.pl +0 -3
  48. package/examples/eyelang/output/sat-dpll.pl +0 -5
  49. package/examples/eyelang/output/traveling-salesman.pl +0 -1
  50. package/examples/eyelang/quine-mccluskey.pl +0 -143
  51. package/examples/eyelang/sat-dpll.pl +0 -80
  52. package/examples/eyelang/traveling-salesman.pl +0 -64
  53. package/lib/eyelang/builtins/matrix.js +0 -226
  54. package/lib/eyelang/builtins/number-theory.js +0 -114
  55. package/lib/eyelang/builtins/search.js +0 -519
  56. package/test/eyelang/conformance/cases/extension/036_extended_gcd.pl +0 -3
  57. package/test/eyelang/conformance/cases/extension/037_collatz_trajectory.pl +0 -3
  58. package/test/eyelang/conformance/cases/extension/038_kaprekar_steps.pl +0 -3
  59. package/test/eyelang/conformance/cases/extension/039_goldbach_pair.pl +0 -3
  60. package/test/eyelang/conformance/cases/extension/040_matrix_operations.pl +0 -5
  61. package/test/eyelang/conformance/cases/extension/042_n_queens_small.pl +0 -3
  62. package/test/eyelang/conformance/cases/extension/043_cnf_model.pl +0 -3
  63. package/test/eyelang/conformance/expected/extension/036_extended_gcd.out +0 -1
  64. package/test/eyelang/conformance/expected/extension/037_collatz_trajectory.out +0 -1
  65. package/test/eyelang/conformance/expected/extension/038_kaprekar_steps.out +0 -1
  66. package/test/eyelang/conformance/expected/extension/039_goldbach_pair.out +0 -2
  67. package/test/eyelang/conformance/expected/extension/040_matrix_operations.out +0 -3
  68. package/test/eyelang/conformance/expected/extension/042_n_queens_small.out +0 -2
  69. package/test/eyelang/conformance/expected/extension/043_cnf_model.out +0 -1
package/README.md CHANGED
@@ -819,21 +819,18 @@ Formula-aware built-ins make Eyeling useful for meta-reasoning. `log:includes`,
819
819
 
820
820
  ### eyelang built-ins
821
821
 
822
- The eyelang engine has its own built-in registry under `lib/eyelang/builtins/`. These are separate from the N3 namespaces above and are called as ordinary eyelang predicates. See the [eyelang language reference](docs/eyelang-language-reference.md#9-standard-built-in-predicates) for the portable profile. The bundled implementation currently registers 68 name/arity entries across 66 predicate names:
822
+ The eyelang engine has its own built-in registry under `lib/eyelang/builtins/`. These are separate from the N3 namespaces above and are called as ordinary eyelang predicates. See the [eyelang language reference](docs/eyelang-language-reference.md#9-standard-built-in-predicates) for the portable profile. The bundled implementation currently registers 80 name/arity entries across 78 predicate names:
823
823
 
824
824
  | Family | Count | Built-ins |
825
825
  |---|---:|---|
826
826
  | Core and host | 4 | `eq/2`, `neq/2`, `local_time/1`, `difference/3` |
827
- | Arithmetic and comparison | 21 | `neg/2`, `abs/2`, `sin/2`, `cos/2`, `asin/2`, `acos/2`, `rounded/2`, `log/2`, `add/3`, `sub/3`, `mul/3`, `div/3`, `mod/3`, `min/3`, `pow/3`, `lt/2`, `gt/2`, `le/2`, `ge/2`, `between/3`, `smallest_divisor_from/3` |
828
- | Strings | 5 | `str_concat/3`, `contains/2`, `matches/2`, `matches/3`, `not_matches/2` |
829
- | Lists | 10 | `append/3`, `nth0/3`, `set_nth0/4`, `rest/2`, `member/2`, `select/3`, `not_member/2`, `reverse/2`, `length/2`, `sort/2` |
827
+ | Arithmetic, comparison, and generators | 29 | `neg/2`, `abs/2`, `sin/2`, `cos/2`, `tan/2`, `asin/2`, `acos/2`, `sqrt/2`, `floor/2`, `ceiling/2`, `trunc/2`, `rounded/2`, `exp/2`, `log/2`, `add/3`, `sub/3`, `mul/3`, `div/3`, `mod/3`, `min/3`, `max/3`, `pow/3`, `atan2/3`, `lt/2`, `gt/2`, `le/2`, `ge/2`, `between/3`, `smallest_divisor_from/3` |
828
+ | Strings and conversions | 15 | `str_concat/3`, `contains/2`, `matches/2`, `matches/3`, `not_matches/2`, `split/3`, `join/3`, `substring/4`, `replace/4`, `lowercase/2`, `uppercase/2`, `trim/2`, `number_string/2`, `atom_string/2`, `term_string/2` |
829
+ | Lists | 19 | `append/3`, `nth0/3`, `set_nth0/4`, `head/2`, `rest/2`, `last/2`, `take/3`, `drop/3`, `slice/4`, `member/2`, `select/3`, `not_member/2`, `reverse/2`, `length/2`, `sum_list/2`, `min_list/2`, `max_list/2`, `list_to_set/2`, `sort/2` |
830
830
  | Aggregation | 5 | `findall/3`, `countall/2`, `sumall/3`, `aggregate_min/5`, `aggregate_max/5` |
831
- | Control | 2 | `not/1`, `once/1` |
832
- | Context terms | 2 | `holds/2`, `holds/3` |
833
- | Search and optimization helpers | 9 | `n_queens/2`, `weighted_hamiltonian_cycle/4`, `weighted_hamiltonian_path/4`, `hamiltonian_cycle/3`, `fixed_length_cycle/4`, `bounded_path/5`, `cnf_model/3`, `qm_prime_implicants/4`, `qm_minimal_cover/4` |
834
- | Numeric extension helpers | 4 | `extended_gcd/5`, `collatz_trajectory/2`, `kaprekar_steps/2`, `goldbach_pair/3` |
835
- | Matrix helpers | 6 | `matrix_sum/2`, `matrix_multiply/2`, `cholesky_decomposition/2`, `determinant/2`, `matrix_inv_triang/2`, `matrix_inversion/2` |
836
- | **Total** | **68** | |
831
+ | Control | 3 | `not/1`, `once/1`, `forall/2` |
832
+ | Context and terms | 5 | `holds/2`, `holds/3`, `functor/3`, `arg/3`, `compound_name_arguments/3` |
833
+ | **Total** | **80** | |
837
834
 
838
835
  ## Custom built-ins
839
836
 
@@ -240,7 +240,7 @@ The CLI is output-oriented and uses `materialize/2` to decide what to print. Emb
240
240
  Add `-s` or `--stats` when you want lightweight solver counters on stderr without changing stdout:
241
241
 
242
242
  ```sh
243
- eyeling --engine eyelang -s examples/eyelang/n-queens.pl
243
+ eyeling --engine eyelang -s examples/eyelang/observability-log-correlation.pl
244
244
  ```
245
245
 
246
246
  The playground has matching `--stats` and `--proof` checkboxes, so browser runs can show the same counters or explanations like the CLI.
@@ -250,18 +250,7 @@ The playground has matching `--stats` and `--proof` checkboxes, so browser runs
250
250
 
251
251
  eyelang builtins are registered by name and arity in small modules under [`lib/eyelang/builtins`](../lib/eyelang/builtins). This keeps the runtime portable to Node.js and the browser while giving each builtin family a clear boundary. Builtins are enabled by normal predicate calls.
252
252
 
253
- The core builtin families cover unification, arithmetic, comparison, dates, strings, lists, aggregation, context terms, and search control. Additional reusable finite-search helpers are available only where bundled examples need them to avoid large amounts of repetitive generate-and-test code. These helpers are deliberately general relations rather than shortcuts tied to a particular example name. For example:
254
-
255
- ```prolog
256
- answer(Queens) :-
257
- n_queens(8, Queens).
258
-
259
- best(Cycle, Cost) :-
260
- cities(Cities),
261
- weighted_hamiltonian_cycle(edge, Cities, Cycle, Cost).
262
- ```
263
-
264
- The reusable search and numeric helpers include `n_queens/2`, Hamiltonian path/cycle helpers, `bounded_path/5`, `cnf_model/3`, Quine-McCluskey helpers, number-theory helpers such as `extended_gcd/5`, and matrix helpers such as `matrix_multiply/2`. These helpers are extension builtins of this implementation; [the eyelang language reference](eyelang-language-reference.md) defines the portable core and standard builtin profile. The complete bundled implementation list is kept in the top-level [README built-ins section](../README.md#built-ins-1), and the regression suite checks that table against the actual runtime registry.
253
+ The builtin families cover unification, arithmetic, comparison, dates, strings, lists, aggregation, context terms, term inspection, and search control. Domain-specific number-theory and matrix helper modules were removed from the default registry because those predicates were examples/accelerators rather than a reusable portable surface. New reusable helpers cover common numeric functions, list slicing and summaries, string normalization/conversion, term inspection/construction, and `forall/2`. The complete bundled implementation list is kept in the top-level [README built-ins section](../README.md#built-ins-1), and the regression suite checks that table against the actual runtime registry.
265
254
 
266
255
  To add a builtin, create or extend a module with `register(registry)` and call `registry.add(name, arity, handler, options)`. The default registry is assembled in [`lib/eyelang/builtins/registry.js`](../lib/eyelang/builtins/registry.js). Builtins that are only safe for specific argument modes should provide a `ready` predicate and `fallbackWhenNotReady: true`, so user-defined clauses remain visible until the builtin is applicable.
267
256
 
@@ -320,7 +309,7 @@ The repository includes examples for recursion, graph reachability, finite searc
320
309
  | [`annotation.pl`](../examples/eyelang/annotation.pl) | Derives facts from quoted annotation data. | [`output/annotation.pl`](../examples/eyelang/output/annotation.pl) |
321
310
  | [`auroracare.pl`](../examples/eyelang/auroracare.pl) | Evaluates purpose-based medical data access scenarios. | [`output/auroracare.pl`](../examples/eyelang/output/auroracare.pl) |
322
311
  | [`backward.pl`](../examples/eyelang/backward.pl) | Shows a backward-rule pattern as a goal-directed numeric rule. | [`output/backward.pl`](../examples/eyelang/output/backward.pl) |
323
- | [`basic-monadic.pl`](../examples/eyelang/basic-monadic.pl) | Runs a monadic benchmark over generated inputs. | [`output/basic-monadic.pl`](../examples/eyelang/output/basic-monadic.pl) |
312
+ | [`basic-monadic.pl`](../examples/eyelang/basic-monadic.pl) | Runs the basic monadic benchmark with explicit indexed edge joins instead of specialized search builtins. | [`output/basic-monadic.pl`](../examples/eyelang/output/basic-monadic.pl) |
324
313
  | [`bayes-diagnosis.pl`](../examples/eyelang/bayes-diagnosis.pl) | Computes scaled Bayesian diagnosis posteriors. | [`output/bayes-diagnosis.pl`](../examples/eyelang/output/bayes-diagnosis.pl) |
325
314
  | [`bayes-therapy.pl`](../examples/eyelang/bayes-therapy.pl) | Ranks therapies using Bayesian disease likelihoods. | [`output/bayes-therapy.pl`](../examples/eyelang/output/bayes-therapy.pl) |
326
315
  | [`beam-deflection.pl`](../examples/eyelang/beam-deflection.pl) | Computes cantilever beam deflection. | [`output/beam-deflection.pl`](../examples/eyelang/output/beam-deflection.pl) |
@@ -332,10 +321,8 @@ The repository includes examples for recursion, graph reachability, finite searc
332
321
  | [`canary-release.pl`](../examples/eyelang/canary-release.pl) | Decides canary rollout or rollback. | [`output/canary-release.pl`](../examples/eyelang/output/canary-release.pl) |
333
322
  | [`cat-koko.pl`](../examples/eyelang/cat-koko.pl) | Demonstrates named existential witnesses from a Cat Koko rule pattern. | [`output/cat-koko.pl`](../examples/eyelang/output/cat-koko.pl) |
334
323
  | [`clinical-trial-screening.pl`](../examples/eyelang/clinical-trial-screening.pl) | Screens candidates for a trial. | [`output/clinical-trial-screening.pl`](../examples/eyelang/output/clinical-trial-screening.pl) |
335
- | [`collatz-1000.pl`](../examples/eyelang/collatz-1000.pl) | Computes shared Collatz trajectories. | [`output/collatz-1000.pl`](../examples/eyelang/output/collatz-1000.pl) |
336
324
  | [`combinatorics-findall-sort.pl`](../examples/eyelang/combinatorics-findall-sort.pl) | Collects and sorts finite combinations. | [`output/combinatorics-findall-sort.pl`](../examples/eyelang/output/combinatorics-findall-sort.pl) |
337
325
  | [`competitive-enzyme-kinetics.pl`](../examples/eyelang/competitive-enzyme-kinetics.pl) | Computes inhibited enzyme reaction rates. | [`output/competitive-enzyme-kinetics.pl`](../examples/eyelang/output/competitive-enzyme-kinetics.pl) |
338
- | [`complex-matrix-stability.pl`](../examples/eyelang/complex-matrix-stability.pl) | Checks stability of a 2x2 system. | [`output/complex-matrix-stability.pl`](../examples/eyelang/output/complex-matrix-stability.pl) |
339
326
  | [`complex.pl`](../examples/eyelang/complex.pl) | Performs arithmetic on complex pairs. | [`output/complex.pl`](../examples/eyelang/output/complex.pl) |
340
327
  | [`composition-of-injective-functions-is-injective.pl`](../examples/eyelang/composition-of-injective-functions-is-injective.pl) | Encodes composition and injectivity of finite functions. | [`output/composition-of-injective-functions-is-injective.pl`](../examples/eyelang/output/composition-of-injective-functions-is-injective.pl) |
341
328
  | [`context-association.pl`](../examples/eyelang/context-association.pl) | Associates named contexts with their contents. | [`output/context-association.pl`](../examples/eyelang/output/context-association.pl) |
@@ -351,14 +338,13 @@ The repository includes examples for recursion, graph reachability, finite searc
351
338
  | [`deep-taxonomy-10000.pl`](../examples/eyelang/deep-taxonomy-10000.pl) | Stress-tests recursive taxonomy depth 10000. | [`output/deep-taxonomy-10000.pl`](../examples/eyelang/output/deep-taxonomy-10000.pl) |
352
339
  | [`deep-taxonomy-100000.pl`](../examples/eyelang/deep-taxonomy-100000.pl) | Stress-tests recursive taxonomy depth 100000. | [`output/deep-taxonomy-100000.pl`](../examples/eyelang/output/deep-taxonomy-100000.pl) |
353
340
  | [`delfour.pl`](../examples/eyelang/delfour.pl) | Derives shopping and authorization recommendations. | [`output/delfour.pl`](../examples/eyelang/output/delfour.pl) |
354
- | [`dense-hamiltonian-cycle.pl`](../examples/eyelang/dense-hamiltonian-cycle.pl) | Searches a dense Hamiltonian cycle with aggregate minimization. | [`output/dense-hamiltonian-cycle.pl`](../examples/eyelang/output/dense-hamiltonian-cycle.pl) |
355
341
  | [`deontic-logic.pl`](../examples/eyelang/deontic-logic.pl) | Reports obligations, prohibitions, and violations. | [`output/deontic-logic.pl`](../examples/eyelang/output/deontic-logic.pl) |
356
342
  | [`derived-backward-rule.pl`](../examples/eyelang/derived-backward-rule.pl) | Derives an inverse-property backward rule from rule data. | [`output/derived-backward-rule.pl`](../examples/eyelang/output/derived-backward-rule.pl) |
357
343
  | [`derived-rule.pl`](../examples/eyelang/derived-rule.pl) | Derives conclusions from rule data. | [`output/derived-rule.pl`](../examples/eyelang/output/derived-rule.pl) |
358
344
  | [`diamond-property.pl`](../examples/eyelang/diamond-property.pl) | Checks the diamond property of a relation. | [`output/diamond-property.pl`](../examples/eyelang/output/diamond-property.pl) |
345
+ | [`dijkstra.pl`](../examples/eyelang/dijkstra.pl) | Enumerates weighted simple paths. | [`output/dijkstra.pl`](../examples/eyelang/output/dijkstra.pl) |
359
346
  | [`dijkstra-findall-sort.pl`](../examples/eyelang/dijkstra-findall-sort.pl) | Finds shortest paths using collected candidates. | [`output/dijkstra-findall-sort.pl`](../examples/eyelang/output/dijkstra-findall-sort.pl) |
360
347
  | [`dijkstra-risk-path.pl`](../examples/eyelang/dijkstra-risk-path.pl) | Ranks routes by cost and trust. | [`output/dijkstra-risk-path.pl`](../examples/eyelang/output/dijkstra-risk-path.pl) |
361
- | [`dijkstra.pl`](../examples/eyelang/dijkstra.pl) | Enumerates weighted simple paths. | [`output/dijkstra.pl`](../examples/eyelang/output/dijkstra.pl) |
362
348
  | [`dining-philosophers.pl`](../examples/eyelang/dining-philosophers.pl) | Simulates Chandy-Misra fork exchanges. | [`output/dining-philosophers.pl`](../examples/eyelang/output/dining-philosophers.pl) |
363
349
  | [`dog.pl`](../examples/eyelang/dog.pl) | Counts dogs and derives when a license is required. | [`output/dog.pl`](../examples/eyelang/output/dog.pl) |
364
350
  | [`dpv-odrl-purpose-mapping.pl`](../examples/eyelang/dpv-odrl-purpose-mapping.pl) | Maps a DPV process into an ODRL permission view. | [`output/dpv-odrl-purpose-mapping.pl`](../examples/eyelang/output/dpv-odrl-purpose-mapping.pl) |
@@ -377,21 +363,18 @@ The repository includes examples for recursion, graph reachability, finite searc
377
363
  | [`fft8-numeric.pl`](../examples/eyelang/fft8-numeric.pl) | Runs an 8-point FFT over complex pairs. | [`output/fft8-numeric.pl`](../examples/eyelang/output/fft8-numeric.pl) |
378
364
  | [`fibonacci.pl`](../examples/eyelang/fibonacci.pl) | Computes large Fibonacci numbers by fast doubling. | [`output/fibonacci.pl`](../examples/eyelang/output/fibonacci.pl) |
379
365
  | [`field-nitrogen-balance.pl`](../examples/eyelang/field-nitrogen-balance.pl) | Classifies field nitrogen balance. | [`output/field-nitrogen-balance.pl`](../examples/eyelang/output/field-nitrogen-balance.pl) |
380
- | [`floating-point.pl`](../examples/eyelang/floating-point.pl) | Exercises floating-point arithmetic and comparisons. | [`output/floating-point.pl`](../examples/eyelang/output/floating-point.pl) |
381
366
  | [`flandor.pl`](../examples/eyelang/flandor.pl) | Derives a Flanders macro-insight authorization and retooling package. | [`output/flandor.pl`](../examples/eyelang/output/flandor.pl) |
367
+ | [`floating-point.pl`](../examples/eyelang/floating-point.pl) | Exercises floating-point arithmetic and comparisons. | [`output/floating-point.pl`](../examples/eyelang/output/floating-point.pl) |
382
368
  | [`four-color-map.pl`](../examples/eyelang/four-color-map.pl) | Checks a four-colour map assignment. | [`output/four-color-map.pl`](../examples/eyelang/output/four-color-map.pl) |
383
369
  | [`fundamental-theorem-arithmetic.pl`](../examples/eyelang/fundamental-theorem-arithmetic.pl) | Factors integers and reconstructs products. | [`output/fundamental-theorem-arithmetic.pl`](../examples/eyelang/output/fundamental-theorem-arithmetic.pl) |
384
- | [`gcd-bezout-identity.pl`](../examples/eyelang/gcd-bezout-identity.pl) | Computes gcd and Bézout coefficients. | [`output/gcd-bezout-identity.pl`](../examples/eyelang/output/gcd-bezout-identity.pl) |
385
370
  | [`gd-step-certified.pl`](../examples/eyelang/gd-step-certified.pl) | Certifies a gradient-descent step. | [`output/gd-step-certified.pl`](../examples/eyelang/output/gd-step-certified.pl) |
386
371
  | [`gdpr-compliance.pl`](../examples/eyelang/gdpr-compliance.pl) | Checks GDPR-style processing compliance. | [`output/gdpr-compliance.pl`](../examples/eyelang/output/gdpr-compliance.pl) |
387
- | [`goldbach-1000.pl`](../examples/eyelang/goldbach-1000.pl) | Finds Goldbach prime pairs up to 1000. | [`output/goldbach-1000.pl`](../examples/eyelang/output/goldbach-1000.pl) |
388
372
  | [`good-cobbler.pl`](../examples/eyelang/good-cobbler.pl) | Demonstrates term-level structure with a good-cobbler statement. | [`output/good-cobbler.pl`](../examples/eyelang/output/good-cobbler.pl) |
389
373
  | [`gps.pl`](../examples/eyelang/gps.pl) | Finds and verifies route paths. | [`output/gps.pl`](../examples/eyelang/output/gps.pl) |
390
374
  | [`graph-reachability.pl`](../examples/eyelang/graph-reachability.pl) | Derives reachable nodes in a graph. | [`output/graph-reachability.pl`](../examples/eyelang/output/graph-reachability.pl) |
391
375
  | [`gray-code-counter.pl`](../examples/eyelang/gray-code-counter.pl) | Generates Gray-code counter states. | [`output/gray-code-counter.pl`](../examples/eyelang/output/gray-code-counter.pl) |
392
376
  | [`greatest-lower-bound-uniqueness.pl`](../examples/eyelang/greatest-lower-bound-uniqueness.pl) | Shows uniqueness of greatest lower bounds in a finite order instance. | [`output/greatest-lower-bound-uniqueness.pl`](../examples/eyelang/output/greatest-lower-bound-uniqueness.pl) |
393
377
  | [`group-inverse-uniqueness.pl`](../examples/eyelang/group-inverse-uniqueness.pl) | Shows uniqueness of inverses in a finite group instance. | [`output/group-inverse-uniqueness.pl`](../examples/eyelang/output/group-inverse-uniqueness.pl) |
394
- | [`hamiltonian-cycle.pl`](../examples/eyelang/hamiltonian-cycle.pl) | Finds a Hamiltonian cycle. | [`output/hamiltonian-cycle.pl`](../examples/eyelang/output/hamiltonian-cycle.pl) |
395
378
  | [`hamiltonian-path.pl`](../examples/eyelang/hamiltonian-path.pl) | Finds a Hamiltonian path. | [`output/hamiltonian-path.pl`](../examples/eyelang/output/hamiltonian-path.pl) |
396
379
  | [`hamming-code.pl`](../examples/eyelang/hamming-code.pl) | Corrects a single-bit Hamming word. | [`output/hamming-code.pl`](../examples/eyelang/output/hamming-code.pl) |
397
380
  | [`hanoi.pl`](../examples/eyelang/hanoi.pl) | Derives the Towers of Hanoi moves. | [`output/hanoi.pl`](../examples/eyelang/output/hanoi.pl) |
@@ -399,17 +382,14 @@ The repository includes examples for recursion, graph reachability, finite searc
399
382
  | [`heron-theorem.pl`](../examples/eyelang/heron-theorem.pl) | Computes triangle area by Heron's theorem. | [`output/heron-theorem.pl`](../examples/eyelang/output/heron-theorem.pl) |
400
383
  | [`ideal-gas-law.pl`](../examples/eyelang/ideal-gas-law.pl) | Applies the ideal gas law. | [`output/ideal-gas-law.pl`](../examples/eyelang/output/ideal-gas-law.pl) |
401
384
  | [`illegitimate-reasoning.pl`](../examples/eyelang/illegitimate-reasoning.pl) | Detects suspect reasoning patterns. | [`output/illegitimate-reasoning.pl`](../examples/eyelang/output/illegitimate-reasoning.pl) |
402
- | [`kaprekar.pl`](../examples/eyelang/kaprekar.pl) | Iterates toward Kaprekar's constant. | [`output/kaprekar.pl`](../examples/eyelang/output/kaprekar.pl) |
403
385
  | [`knowledge-engineering-alignment-flow.pl`](../examples/eyelang/knowledge-engineering-alignment-flow.pl) | Specializes reusable alignment rules into a target-shaped flow view. | [`output/knowledge-engineering-alignment-flow.pl`](../examples/eyelang/output/knowledge-engineering-alignment-flow.pl) |
404
386
  | [`law-of-cosines.pl`](../examples/eyelang/law-of-cosines.pl) | Computes a triangle side by cosine law. | [`output/law-of-cosines.pl`](../examples/eyelang/output/law-of-cosines.pl) |
405
387
  | [`least-squares-regression.pl`](../examples/eyelang/least-squares-regression.pl) | Fits a least-squares regression line. | [`output/least-squares-regression.pl`](../examples/eyelang/output/least-squares-regression.pl) |
406
388
  | [`list-collection.pl`](../examples/eyelang/list-collection.pl) | Demonstrates list and collection built-ins. | [`output/list-collection.pl`](../examples/eyelang/output/list-collection.pl) |
407
389
  | [`lldm.pl`](../examples/eyelang/lldm.pl) | Calculates leg-length discrepancy measurements. | [`output/lldm.pl`](../examples/eyelang/output/lldm.pl) |
408
390
  | [`manufacturing-quality-control.pl`](../examples/eyelang/manufacturing-quality-control.pl) | Evaluates process capability and quality. | [`output/manufacturing-quality-control.pl`](../examples/eyelang/output/manufacturing-quality-control.pl) |
409
- | [`matrix.pl`](../examples/eyelang/matrix.pl) | Runs matrix operations over sample inputs. | [`output/matrix.pl`](../examples/eyelang/output/matrix.pl) |
410
391
  | [`microgrid-dispatch.pl`](../examples/eyelang/microgrid-dispatch.pl) | Plans microgrid dispatch and reserve. | [`output/microgrid-dispatch.pl`](../examples/eyelang/output/microgrid-dispatch.pl) |
411
392
  | [`monkey-bananas.pl`](../examples/eyelang/monkey-bananas.pl) | Solves the monkey-and-bananas puzzle. | [`output/monkey-bananas.pl`](../examples/eyelang/output/monkey-bananas.pl) |
412
- | [`n-queens.pl`](../examples/eyelang/n-queens.pl) | Searches for N-queens placements. | [`output/n-queens.pl`](../examples/eyelang/output/n-queens.pl) |
413
393
  | [`network-sla.pl`](../examples/eyelang/network-sla.pl) | Checks network path SLA compliance. | [`output/network-sla.pl`](../examples/eyelang/output/network-sla.pl) |
414
394
  | [`newton-raphson.pl`](../examples/eyelang/newton-raphson.pl) | Finds roots by Newton-Raphson iteration. | [`output/newton-raphson.pl`](../examples/eyelang/output/newton-raphson.pl) |
415
395
  | [`nixon-diamond.pl`](../examples/eyelang/nixon-diamond.pl) | Reports the classic Nixon-diamond conflict. | [`output/nixon-diamond.pl`](../examples/eyelang/output/nixon-diamond.pl) |
@@ -425,10 +405,9 @@ The repository includes examples for recursion, graph reachability, finite searc
425
405
  | [`polynomial.pl`](../examples/eyelang/polynomial.pl) | Finds complex integer polynomial roots. | [`output/polynomial.pl`](../examples/eyelang/output/polynomial.pl) |
426
406
  | [`proof-contrapositive.pl`](../examples/eyelang/proof-contrapositive.pl) | Models proof by contrapositive. | [`output/proof-contrapositive.pl`](../examples/eyelang/output/proof-contrapositive.pl) |
427
407
  | [`quadratic-formula.pl`](../examples/eyelang/quadratic-formula.pl) | Solves sample quadratic equations. | [`output/quadratic-formula.pl`](../examples/eyelang/output/quadratic-formula.pl) |
428
- | [`quine-mccluskey.pl`](../examples/eyelang/quine-mccluskey.pl) | Minimizes Boolean terms with Quine-McCluskey. | [`output/quine-mccluskey.pl`](../examples/eyelang/output/quine-mccluskey.pl) |
429
408
  | [`radioactive-decay.pl`](../examples/eyelang/radioactive-decay.pl) | Computes radioactive decay over time. | [`output/radioactive-decay.pl`](../examples/eyelang/output/radioactive-decay.pl) |
409
+ | [`reusable-builtins.pl`](../examples/eyelang/reusable-builtins.pl) | Tours reusable numeric, list, and string builtins. | [`output/reusable-builtins.pl`](../examples/eyelang/output/reusable-builtins.pl) |
430
410
  | [`riemann-hypothesis.pl`](../examples/eyelang/riemann-hypothesis.pl) | Checks a finite catalogue of non-trivial zeta zeros against the Riemann-hypothesis condition. | [`output/riemann-hypothesis.pl`](../examples/eyelang/output/riemann-hypothesis.pl) |
431
- | [`sat-dpll.pl`](../examples/eyelang/sat-dpll.pl) | Solves a finite SAT instance. | [`output/sat-dpll.pl`](../examples/eyelang/output/sat-dpll.pl) |
432
411
  | [`security-incident-correlation.pl`](../examples/eyelang/security-incident-correlation.pl) | Correlates security incidents across signals. | [`output/security-incident-correlation.pl`](../examples/eyelang/output/security-incident-correlation.pl) |
433
412
  | [`service-impact.pl`](../examples/eyelang/service-impact.pl) | Analyzes service impact over cyclic dependencies. | [`output/service-impact.pl`](../examples/eyelang/output/service-impact.pl) |
434
413
  | [`sieve.pl`](../examples/eyelang/sieve.pl) | Enumerates primes with a sieve-style program. | [`output/sieve.pl`](../examples/eyelang/output/sieve.pl) |
@@ -438,7 +417,7 @@ The repository includes examples for recursion, graph reachability, finite searc
438
417
  | [`socrates.pl`](../examples/eyelang/socrates.pl) | Derives that Socrates is mortal. | [`output/socrates.pl`](../examples/eyelang/output/socrates.pl) |
439
418
  | [`statistics-summary.pl`](../examples/eyelang/statistics-summary.pl) | Computes population statistics for a sample. | [`output/statistics-summary.pl`](../examples/eyelang/output/statistics-summary.pl) |
440
419
  | [`superdense-coding.pl`](../examples/eyelang/superdense-coding.pl) | Models superdense-coding bit transmission. | [`output/superdense-coding.pl`](../examples/eyelang/output/superdense-coding.pl) |
441
- | [`traveling-salesman.pl`](../examples/eyelang/traveling-salesman.pl) | Finds an optimal traveling-salesman tour. | [`output/traveling-salesman.pl`](../examples/eyelang/output/traveling-salesman.pl) |
420
+ | [`term-tools.pl`](../examples/eyelang/term-tools.pl) | Inspects, builds, renders, and validates terms with reusable term/control builtins. | [`output/term-tools.pl`](../examples/eyelang/output/term-tools.pl) |
442
421
  | [`trust-flow-provenance-threshold.pl`](../examples/eyelang/trust-flow-provenance-threshold.pl) | Classifies message trust from provenance confidence scores. | [`output/trust-flow-provenance-threshold.pl`](../examples/eyelang/output/trust-flow-provenance-threshold.pl) |
443
422
  | [`turing.pl`](../examples/eyelang/turing.pl) | Simulates a binary-increment Turing machine. | [`output/turing.pl`](../examples/eyelang/output/turing.pl) |
444
423
  | [`vector-similarity.pl`](../examples/eyelang/vector-similarity.pl) | Computes dot product, norm, and cosine similarity. | [`output/vector-similarity.pl`](../examples/eyelang/output/vector-similarity.pl) |
@@ -448,7 +427,6 @@ The repository includes examples for recursion, graph reachability, finite searc
448
427
  | [`zebra.pl`](../examples/eyelang/zebra.pl) | Solves the zebra logic puzzle. | [`output/zebra.pl`](../examples/eyelang/output/zebra.pl) |
449
428
 
450
429
 
451
-
452
430
  ## Golden outputs, tests, and conformance
453
431
 
454
432
  Golden answer outputs live in [`examples/eyelang/output`](../examples/eyelang/output). `npm run test:eyelang` covers the eyelang integration check, conformance cases, regression checks, runnable examples, and proof-output examples. A curated proof-output suite for `.pl` examples lives in [`examples/eyelang/proof`](../examples/eyelang/proof). Example tests pin `local_time/1` to `2026-05-30` so date-dependent examples stay deterministic. Regenerate them after an intentional output or explanation change:
@@ -500,7 +478,7 @@ eyeling --engine eyelang --help
500
478
  Useful profiling smoke test:
501
479
 
502
480
  ```sh
503
- eyeling --engine eyelang -s examples/eyelang/n-queens.pl > /dev/null
481
+ eyeling --engine eyelang -s examples/eyelang/observability-log-correlation.pl > /dev/null
504
482
  ```
505
483
 
506
484
  For a release:
@@ -360,15 +360,18 @@ Implementations MAY provide additional built-ins, but such built-ins are extensi
360
360
  |---|---|
361
361
  | `neg(A, B)` | `B` is the numeric negation of `A`. |
362
362
  | `abs(A, B)` | `B` is the absolute value of `A`. |
363
- | `sin(A, B)`, `cos(A, B)`, `asin(A, B)`, `acos(A, B)`, `log(A, B)` | Floating functions. |
364
- | `rounded(A, B)` | `B` is `A` rounded to the nearest integer. |
363
+ | `sin(A, B)`, `cos(A, B)`, `tan(A, B)` | Trigonometric floating functions. |
364
+ | `asin(A, B)`, `acos(A, B)`, `atan2(Y, X, Angle)` | Inverse trigonometric floating functions. |
365
+ | `sqrt(A, B)` | Square root. Fails for negative inputs. |
366
+ | `floor(A, B)`, `ceiling(A, B)`, `trunc(A, B)`, `rounded(A, B)` | Integer-valued numeric rounding functions. |
367
+ | `exp(A, B)`, `log(A, B)` | Natural exponent and logarithm. `log/2` fails for non-positive inputs. |
365
368
  | `add(A, B, C)` | `C = A + B`. |
366
369
  | `sub(A, B, C)` | `C = A - B`. |
367
370
  | `mul(A, B, C)` | `C = A * B`. |
368
371
  | `div(A, B, C)` | `C = A / B`; integer inputs use integer division. |
369
372
  | `mod(A, B, C)` | Integer remainder. |
370
373
  | `pow(A, B, C)` | `C = A^B`. |
371
- | `min(A, B, C)` | Numeric minimum. |
374
+ | `min(A, B, C)`, `max(A, B, C)` | Numeric minimum and maximum. |
372
375
 
373
376
  ### 9.3 Comparison
374
377
 
@@ -404,6 +407,14 @@ Comparisons interpret numeric-looking terms numerically. Other scalar terms are
404
407
  | `matches(Text, Pattern)` | Text matches a simple implementation regex/search pattern. |
405
408
  | `matches(Text, Pattern, Context)` | Text matches a JavaScript regular expression with named capture groups; `Context` is a comma context containing one unary term per matched capture group. |
406
409
  | `not_matches(Text, Pattern)` | Negation of `matches/2`. |
410
+ | `split(Text, Separator, Parts)` | Splits text into a proper list of strings. |
411
+ | `join(Parts, Separator, Text)` | Joins a proper list of scalar terms into a string. |
412
+ | `substring(Text, Start, Length, Out)` | Extracts a zero-based substring. |
413
+ | `replace(Text, Search, Replacement, Out)` | Replaces all non-empty literal occurrences of `Search`. |
414
+ | `lowercase(Text, Out)`, `uppercase(Text, Out)`, `trim(Text, Out)` | Text normalization helpers. |
415
+ | `number_string(Number, String)` | Converts a number to a string or parses a numeric string into a number. |
416
+ | `atom_string(Atom, String)` | Converts between atom constants and strings. |
417
+ | `term_string(Term, String)` | Renders a ground term as its eyelang source string. |
407
418
 
408
419
  ### 9.7 Lists
409
420
 
@@ -412,12 +423,21 @@ Comparisons interpret numeric-looking terms numerically. Other scalar terms are
412
423
  | `append(A, B, C)` | List append/split relation. |
413
424
  | `nth0(Index, List, Value)` | Zero-based list lookup. |
414
425
  | `set_nth0(Index, List, Value, Out)` | Functional list update. |
426
+ | `head(List, Head)` | Head of a non-empty list. |
415
427
  | `rest(List, Tail)` | Tail of a non-empty list. |
428
+ | `last(List, Last)` | Last element of a non-empty proper list. |
429
+ | `take(N, List, Prefix)` | First `N` items of a proper list. |
430
+ | `drop(N, List, Suffix)` | Proper-list suffix after dropping `N` items. |
431
+ | `slice(Start, Length, List, Slice)` | Zero-based proper-list slice. |
416
432
  | `member(X, List)` | Member generator. |
417
433
  | `select(X, List, Rest)` | Selects one occurrence. |
418
434
  | `not_member(X, List)` | Succeeds when `X` is not a member. |
419
435
  | `reverse(A, B)` | Reverses a proper list. |
420
436
  | `length(List, N)` | Proper-list length. |
437
+ | `sum_list(List, Sum)` | Numeric sum of a proper list; empty lists produce `0`. |
438
+ | `min_list(List, Min)`, `max_list(List, Max)` | Minimum and maximum under standard term ordering. |
439
+ | `list_to_set(List, Set)` | Removes duplicates while preserving the first occurrence order. |
440
+ | `sort(Input, Output)` | Sorts and deduplicates a proper list. |
421
441
 
422
442
  ### 9.8 Aggregation and ordering
423
443
 
@@ -428,9 +448,8 @@ Comparisons interpret numeric-looking terms numerically. Other scalar terms are
428
448
  | `sumall(Template, Goal, Sum)` | Sums numeric `Template` values over solutions of `Goal`; empty solution sets produce `0`. |
429
449
  | `aggregate_min(Key, Template, Goal, BestKey, BestTemplate)` | Selects the solution of `Goal` with the smallest resolved `Key`, returning that key and the corresponding resolved `Template`. Fails when `Goal` has no solutions. |
430
450
  | `aggregate_max(Key, Template, Goal, BestKey, BestTemplate)` | Selects the solution of `Goal` with the largest resolved `Key`, returning that key and the corresponding resolved `Template`. Fails when `Goal` has no solutions. |
431
- | `sort(Input, Output)` | Sorts and deduplicates a proper list. |
432
451
 
433
- ### 9.9 Context terms
452
+ ### 9.9 Context and term inspection
434
453
 
435
454
  Context terms are data representations of atomic formulas and comma conjunctions.
436
455
 
@@ -438,12 +457,18 @@ Context terms are data representations of atomic formulas and comma conjunctions
438
457
  |---|---|
439
458
  | `holds(Context, Term)` | Enumerates member terms inside a context term and unifies each member with `Term`. |
440
459
  | `holds(Context, Name, Args)` | Enumerates context members of any arity, exposing each member as atom constant `Name` plus a proper argument list `Args`. |
460
+ | `functor(Term, Name, Arity)` | Decomposes a non-variable term into its name and arity. |
461
+ | `arg(Index, Term, Arg)` | Extracts the 1-based argument of a compound term. |
462
+ | `compound_name_arguments(Term, Name, Args)` | Decomposes a compound term or constructs one from an atom name and proper argument list. |
441
463
 
442
464
  Example:
443
465
 
444
466
  ```prolog
445
467
  holds((name(alice, "Alice"), knows(alice, bob)), name(S, O)).
446
468
  holds((ready, name(alice, "Alice"), route(alice, bob, 7)), Name, Args).
469
+ functor(route(alice, bob, 7), route, 3).
470
+ arg(2, route(alice, bob, 7), bob).
471
+ compound_name_arguments(Term, route, [alice, bob, 7]).
447
472
  ```
448
473
 
449
474
  The first goal can yield `holds((name(alice, "Alice"), knows(alice, bob)), name(alice, "Alice")).` The second can yield `holds((ready, name(alice, "Alice"), route(alice, bob, 7)), ready, []).`, `holds((ready, name(alice, "Alice"), route(alice, bob, 7)), name, [alice, "Alice"]).`, and `holds((ready, name(alice, "Alice"), route(alice, bob, 7)), route, [alice, bob, 7]).`
@@ -458,6 +483,7 @@ The N3 example [`context-schema-audit.n3`](../examples/context-schema-audit.n3)
458
483
  |---|---|
459
484
  | `not(Goal)` | Negation as failure. Succeeds when `Goal` has no solution. |
460
485
  | `once(Goal)` | Succeeds with at most the first solution of `Goal`. |
486
+ | `forall(Generator, Test)` | Succeeds when every solution of `Generator` also satisfies `Test`; succeeds vacuously when `Generator` has no solutions. |
461
487
 
462
488
  ## 10. Extension built-ins
463
489
 
@@ -473,7 +499,7 @@ An extension built-in SHOULD obey the same surface-language discipline as standa
473
499
  - it SHOULD document its intended modes, especially which arguments must be ground before it runs deterministically;
474
500
  - it MUST NOT change the meaning of ordinary facts, rules, unification, or standard built-ins.
475
501
 
476
- For example, an implementation may include extension modules for number-theory algorithms, graph search, or matrix operations. Those modules may be valuable and may make example programs much faster, but their predicate names, arities, algorithms, and modes are implementation-defined unless they are separately standardized.
502
+ For example, an implementation may include extension modules for number-theory algorithms, matrix operations, or host-specific integrations. Those modules may be valuable and may make example programs much faster, but their predicate names, arities, algorithms, and modes are implementation-defined unless they are separately standardized.
477
503
 
478
504
  An implementation that provides explanation output SHOULD make extension built-ins explainable at least as opaque successful or failed built-in calls, so that proof traces do not incorrectly report "no clauses" for a host-provided relation.
479
505
 
@@ -10014,5 +10014,19 @@ edge(i48, i89, i48).
10014
10014
  edge(i26, i42, i54).
10015
10015
 
10016
10016
  % Derivation rules: each rule below contributes one logical step toward the displayed results.
10017
- cycle(R, Cycle) :-
10018
- fixed_length_cycle(edge, 10, R, Cycle).
10017
+ %
10018
+ % Keep this example independent from specialized search builtins by spelling out the
10019
+ % ten-edge monadic benchmark directly. The left-to-right shape binds the next
10020
+ % node before the next edge lookup, so the ordinary predicate indexes can keep the
10021
+ % query finite and selective.
10022
+ cycle(R, [D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D0]) :-
10023
+ edge(D0, R, D1),
10024
+ edge(D1, R, D2),
10025
+ edge(D2, R, D3),
10026
+ edge(D3, R, D4),
10027
+ edge(D4, R, D5),
10028
+ edge(D5, R, D6),
10029
+ edge(D6, R, D7),
10030
+ edge(D7, R, D8),
10031
+ edge(D8, R, D9),
10032
+ edge(D9, R, D0).
@@ -106,9 +106,9 @@ scores_for([Disease|RestDiseases], [Score|RestScores]) :-
106
106
  score(Disease, Score),
107
107
  scores_for(RestDiseases, RestScores).
108
108
 
109
- sum_list([], 0.0).
110
- sum_list([Value|Rest], Sum) :-
111
- sum_list(Rest, TailSum),
109
+ score_sum([], 0.0).
110
+ score_sum([Value|Rest], Sum) :-
111
+ score_sum(Rest, TailSum),
112
112
  add(Value, TailSum, Sum).
113
113
 
114
114
  normalize_scores([], _Total, []).
@@ -159,7 +159,7 @@ scores(case, Scores) :-
159
159
  scores_for(Diseases, Scores).
160
160
  evidenceTotal(case, Total) :-
161
161
  scores(case, Scores),
162
- sum_list(Scores, Total).
162
+ score_sum(Scores, Total).
163
163
  posteriors(case, Posteriors) :-
164
164
  scores(case, Scores),
165
165
  evidenceTotal(case, Total),