eyeling 1.33.4 → 1.33.6

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 (98) hide show
  1. package/README.md +50 -105
  2. package/docs/eyelang-guide.md +551 -0
  3. package/{examples/eyelang/SPEC.md → docs/eyelang-language-reference.md} +6 -10
  4. package/lib/eyelang/builtins/arithmetic.js +1 -3
  5. package/lib/eyelang/builtins/formula.js +0 -16
  6. package/lib/eyelang/builtins/lists.js +0 -5
  7. package/lib/eyelang/builtins/registry.js +1 -2
  8. package/lib/eyelang/builtins/search.js +1 -61
  9. package/lib/eyelang/builtins/strings.js +10 -14
  10. package/package.json +2 -1
  11. package/test/eyelang/conformance/README.md +7 -7
  12. package/test/eyelang/conformance/cases/core/001_fact_output.pl +1 -1
  13. package/test/eyelang/conformance/cases/core/002_rule_recursion.pl +1 -1
  14. package/test/eyelang/conformance/cases/core/003_terms_and_readback.pl +1 -1
  15. package/test/eyelang/conformance/cases/core/004_conjunction_and_parentheses.pl +1 -1
  16. package/test/eyelang/conformance/cases/core/005_list_deconstruction.pl +1 -1
  17. package/test/eyelang/conformance/cases/core/006_comma_formula_data.pl +1 -1
  18. package/test/eyelang/conformance/cases/core/007_anonymous_variables.pl +1 -1
  19. package/test/eyelang/conformance/cases/core/008_graphic_atoms.pl +1 -1
  20. package/test/eyelang/conformance/cases/core/009_comments_and_whitespace.pl +1 -1
  21. package/test/eyelang/conformance/cases/core/010_variable_scope_and_reuse.pl +1 -1
  22. package/test/eyelang/conformance/cases/core/011_predicate_arity.pl +1 -1
  23. package/test/eyelang/conformance/cases/core/012_nested_compound_unification.pl +1 -1
  24. package/test/eyelang/conformance/cases/core/013_multiple_clauses_order.pl +1 -1
  25. package/test/eyelang/conformance/cases/core/014_failure_filters_answers.pl +1 -1
  26. package/test/eyelang/conformance/cases/core/015_improper_list_unification.pl +1 -1
  27. package/test/eyelang/conformance/cases/core/016_zero_arity_compound.pl +1 -1
  28. package/test/eyelang/conformance/cases/core/017_three_step_recursion.pl +1 -1
  29. package/test/eyelang/conformance/cases/core/018_quoted_atom_readback.pl +1 -1
  30. package/test/eyelang/conformance/cases/core/019_parenthesized_three_conjuncts.pl +1 -1
  31. package/test/eyelang/conformance/cases/core/020_nested_list_terms.pl +1 -1
  32. package/test/eyelang/conformance/cases/core/021_repeated_variable_head.pl +1 -1
  33. package/test/eyelang/conformance/cases/core/022_rule_head_structure.pl +1 -1
  34. package/test/eyelang/conformance/cases/core/023_quoted_escapes_readback.pl +1 -1
  35. package/test/eyelang/conformance/cases/core/024_numeric_literal_readback.pl +1 -1
  36. package/test/eyelang/conformance/cases/core/025_body_parentheses_with_formula_data.pl +1 -1
  37. package/test/eyelang/conformance/cases/core/026_underscore_named_variable_reuse.pl +1 -1
  38. package/test/eyelang/conformance/cases/extension/001_default_derived_output.pl +1 -1
  39. package/test/eyelang/conformance/cases/extension/002_materialize_focus.pl +1 -1
  40. package/test/eyelang/conformance/cases/extension/003_arithmetic_and_comparison.pl +1 -2
  41. package/test/eyelang/conformance/cases/extension/004_strings_and_atoms.pl +1 -3
  42. package/test/eyelang/conformance/cases/extension/005_lists_aggregation_ordering.pl +1 -1
  43. package/test/eyelang/conformance/cases/extension/006_formula_terms.pl +1 -2
  44. package/test/eyelang/conformance/cases/extension/007_negation_once_generators.pl +1 -1
  45. package/test/eyelang/conformance/cases/extension/008_equality_and_inequality.pl +1 -1
  46. package/test/eyelang/conformance/cases/extension/009_list_relations.pl +1 -2
  47. package/test/eyelang/conformance/cases/extension/010_append_splits.pl +1 -1
  48. package/test/eyelang/conformance/cases/extension/011_matching_and_comparison.pl +1 -1
  49. package/test/eyelang/conformance/cases/extension/012_memoize_declaration.pl +1 -1
  50. package/test/eyelang/conformance/cases/extension/013_numeric_functions.pl +1 -1
  51. package/test/eyelang/conformance/cases/extension/014_between_enumeration.pl +1 -1
  52. package/test/eyelang/conformance/cases/extension/015_smallest_divisor.pl +1 -1
  53. package/test/eyelang/conformance/cases/extension/016_negation_filter.pl +1 -1
  54. package/test/eyelang/conformance/cases/extension/017_once_user_predicate.pl +1 -1
  55. package/test/eyelang/conformance/cases/extension/018_findall_user_goal.pl +1 -1
  56. package/test/eyelang/conformance/cases/extension/019_sort_deduplicates_atoms.pl +1 -1
  57. package/test/eyelang/conformance/cases/extension/020_append_bound_prefix_suffix.pl +1 -1
  58. package/test/eyelang/conformance/cases/extension/021_nth0_index_generation.pl +1 -1
  59. package/test/eyelang/conformance/cases/extension/022_set_nth0_edges.pl +1 -1
  60. package/test/eyelang/conformance/cases/extension/023_select_duplicate_occurrences.pl +1 -1
  61. package/test/eyelang/conformance/cases/extension/024_not_member_filter.pl +1 -1
  62. package/test/eyelang/conformance/cases/extension/026_nested_formula_terms.pl +1 -2
  63. package/test/eyelang/conformance/cases/extension/027_materialize_excludes_source_fact.pl +1 -1
  64. package/test/eyelang/conformance/cases/extension/028_numeric_and_lexical_comparison.pl +1 -1
  65. package/test/eyelang/conformance/cases/extension/029_string_matching_filters.pl +1 -1
  66. package/test/eyelang/conformance/cases/extension/030_string_and_atom_concat.pl +1 -2
  67. package/test/eyelang/conformance/cases/extension/035_date_difference.pl +1 -1
  68. package/test/eyelang/conformance/cases/extension/036_extended_gcd.pl +1 -1
  69. package/test/eyelang/conformance/cases/extension/037_collatz_trajectory.pl +1 -1
  70. package/test/eyelang/conformance/cases/extension/038_kaprekar_steps.pl +1 -1
  71. package/test/eyelang/conformance/cases/extension/039_goldbach_pair.pl +1 -1
  72. package/test/eyelang/conformance/cases/extension/040_matrix_operations.pl +1 -1
  73. package/test/eyelang/conformance/cases/extension/042_n_queens_small.pl +1 -1
  74. package/test/eyelang/conformance/cases/extension/043_cnf_model.pl +1 -1
  75. package/test/eyelang/conformance/cases/extension/045_alphametic_sum_small.pl +1 -1
  76. package/test/eyelang/conformance/cases/extension/046_bounded_subset.pl +1 -1
  77. package/test/eyelang/conformance/expected/extension/003_arithmetic_and_comparison.out +0 -1
  78. package/test/eyelang/conformance/expected/extension/004_strings_and_atoms.out +0 -2
  79. package/test/eyelang/conformance/expected/extension/006_formula_terms.out +0 -2
  80. package/test/eyelang/conformance/expected/extension/009_list_relations.out +0 -1
  81. package/test/eyelang/conformance/expected/extension/026_nested_formula_terms.out +0 -3
  82. package/test/eyelang/conformance/expected/extension/030_string_and_atom_concat.out +0 -1
  83. package/test/eyelang/run-regression.mjs +2 -2
  84. package/test/packlist.test.js +2 -0
  85. package/examples/eyelang/INTEGRATION.md +0 -20
  86. package/examples/eyelang/README.md +0 -567
  87. package/examples/eyelang/exact-cover-sudoku.pl +0 -113
  88. package/examples/eyelang/output/exact-cover-sudoku.pl +0 -3
  89. package/examples/eyelang/output/sudoku.pl +0 -2
  90. package/examples/eyelang/sudoku.pl +0 -20
  91. package/lib/eyelang/builtins/sudoku.js +0 -141
  92. package/test/eyelang/conformance/cases/extension/025_is_list_filter.pl +0 -5
  93. package/test/eyelang/conformance/cases/extension/025_is_list_filter.query +0 -1
  94. package/test/eyelang/conformance/cases/extension/041_atom_range_generators.pl +0 -5
  95. package/test/eyelang/conformance/cases/extension/044_cover9_filter.pl +0 -6
  96. package/test/eyelang/conformance/expected/extension/025_is_list_filter.out +0 -1
  97. package/test/eyelang/conformance/expected/extension/041_atom_range_generators.out +0 -8
  98. package/test/eyelang/conformance/expected/extension/044_cover9_filter.out +0 -2
@@ -1,4 +1,4 @@
1
- % SPEC 9.3, 9.6: lexical comparison and simple text matching.
1
+ % Reference 9.3, 9.6: lexical comparison and simple text matching.
2
2
  answer(matches, true) :- matches("eyelang", "eye").
3
3
  answer(not_matches, true) :- not_matches("eyelang", "cat").
4
4
  answer(lex_lt, true) :- lt(alpha, beta).
@@ -1,4 +1,4 @@
1
- % SPEC 10.1: memoize/2 is a declaration and does not change answers.
1
+ % Reference 10.1: memoize/2 is a declaration and does not change answers.
2
2
  materialize(reach, 2).
3
3
  memoize(reach_any, 2).
4
4
  edge(a, b).
@@ -1,4 +1,4 @@
1
- % SPEC 9.2: scalar arithmetic functions return numeric values.
1
+ % Reference 9.2: scalar arithmetic functions return numeric values.
2
2
  answer(neg, X) :- neg(5, X).
3
3
  answer(abs, X) :- abs(-5, X).
4
4
  answer(rounded, X) :- rounded(2.6, X).
@@ -1,3 +1,3 @@
1
- % SPEC 9.5: between/3 enumerates every integer in an inclusive range.
1
+ % Reference 9.5: between/3 enumerates every integer in an inclusive range.
2
2
  answer(n, X) :- between(3, 5, X).
3
3
  materialize(answer, 2).
@@ -1,3 +1,3 @@
1
- % SPEC 9.5: smallest_divisor_from/3 finds the first divisor at or above the start.
1
+ % Reference 9.5: smallest_divisor_from/3 finds the first divisor at or above the start.
2
2
  answer(divisor, D) :- smallest_divisor_from(21, 2, D).
3
3
  materialize(answer, 2).
@@ -1,4 +1,4 @@
1
- % SPEC 9.10: not/1 succeeds when the subgoal has no proof.
1
+ % Reference 9.10: not/1 succeeds when the subgoal has no proof.
2
2
  candidate(a).
3
3
  candidate(b).
4
4
  candidate(c).
@@ -1,4 +1,4 @@
1
- % SPEC 9.10: once/1 keeps at most the first solution from a user predicate.
1
+ % Reference 9.10: once/1 keeps at most the first solution from a user predicate.
2
2
  choice(a).
3
3
  choice(b).
4
4
  answer(first, X) :- once(choice(X)).
@@ -1,4 +1,4 @@
1
- % SPEC 9.8: findall/3 collects templates for every solution of a user goal.
1
+ % Reference 9.8: findall/3 collects templates for every solution of a user goal.
2
2
  p(b).
3
3
  p(a).
4
4
  p(b).
@@ -1,3 +1,3 @@
1
- % SPEC 9.8: sort/2 sorts and deduplicates a proper list.
1
+ % Reference 9.8: sort/2 sorts and deduplicates a proper list.
2
2
  answer(sorted, X) :- sort([c, a, b, a], X).
3
3
  materialize(answer, 2).
@@ -1,4 +1,4 @@
1
- % SPEC 9.7: append/3 supports bound prefix and suffix use cases.
1
+ % Reference 9.7: append/3 supports bound prefix and suffix use cases.
2
2
  answer(prefix, X) :- append(X, [c], [a, b, c]).
3
3
  answer(suffix, X) :- append([a], X, [a, b, c]).
4
4
  materialize(answer, 2).
@@ -1,3 +1,3 @@
1
- % SPEC 9.7: nth0/3 can bind the index for a known list element.
1
+ % Reference 9.7: nth0/3 can bind the index for a known list element.
2
2
  answer(index, I) :- nth0(I, [a, b, c], b).
3
3
  materialize(answer, 2).
@@ -1,4 +1,4 @@
1
- % SPEC 9.7: set_nth0/4 updates zero-based positions functionally.
1
+ % Reference 9.7: set_nth0/4 updates zero-based positions functionally.
2
2
  answer(first, X) :- set_nth0(0, [a, b, c], x, X).
3
3
  answer(last, X) :- set_nth0(2, [a, b, c], z, X).
4
4
  materialize(answer, 2).
@@ -1,3 +1,3 @@
1
- % SPEC 9.7: select/3 enumerates removals of matching occurrences.
1
+ % Reference 9.7: select/3 enumerates removals of matching occurrences.
2
2
  answer(rest, X) :- select(a, [a, b, a], X).
3
3
  materialize(answer, 2).
@@ -1,4 +1,4 @@
1
- % SPEC 9.7: not_member/2 can filter finite candidates.
1
+ % Reference 9.7: not_member/2 can filter finite candidates.
2
2
  candidate(a).
3
3
  candidate(b).
4
4
  candidate(c).
@@ -1,5 +1,4 @@
1
- % SPEC 9.9: formula helpers enumerate nested comma formula members.
1
+ % Reference 9.9: formula helpers enumerate nested comma formula members.
2
2
  formula(((name(a, "A"), knows(a, b)), likes(b, c))).
3
- answer(atom, A) :- formula(F), formula_atom(F, A).
4
3
  answer(binary, exposed(S, P, O)) :- formula(F), formula_binary(F, S, P, O).
5
4
  materialize(answer, 2).
@@ -1,4 +1,4 @@
1
- % SPEC 11: default materialization excludes source facts even if also derivable.
1
+ % Reference 11: default materialization excludes source facts even if also derivable.
2
2
  materialize(answer, 2).
3
3
  seed(a).
4
4
  answer(a, ok).
@@ -1,4 +1,4 @@
1
- % SPEC 9.3: comparisons handle numeric and lexical scalar ordering.
1
+ % Reference 9.3: comparisons handle numeric and lexical scalar ordering.
2
2
  answer(numeric_gt, true) :- gt(10, 2).
3
3
  answer(numeric_le, true) :- le(2, 2.0).
4
4
  answer(lexical_ge, true) :- ge(beta, alpha).
@@ -1,4 +1,4 @@
1
- % SPEC 9.6: matches/2 and not_matches/2 can filter candidate strings.
1
+ % Reference 9.6: matches/2 and not_matches/2 can filter candidate strings.
2
2
  text(a, "alpha").
3
3
  text(b, "beta").
4
4
  answer(has_ph, K) :- text(K, T), matches(T, "ph").
@@ -1,4 +1,3 @@
1
- % SPEC 9.6: atom_concat/3 and str_concat/3 concatenate like-typed scalars.
2
- answer(atom, X) :- atom_concat(eye, lang, X).
1
+ % Reference 9.6: str_concat/3 concatenates strings.
3
2
  answer(string, X) :- str_concat("eye", "lang", X).
4
3
  materialize(answer, 2).
@@ -1,4 +1,4 @@
1
- % SPEC 9.1: difference/3 computes ISO date durations.
1
+ % Reference 9.1: difference/3 computes ISO date durations.
2
2
  answer(duration, D) :- difference("2024-03-01", "2020-02-29", D).
3
3
  answer(month_borrow, D) :- difference("2024-03-01", "2024-01-31", D).
4
4
  materialize(answer, 2).
@@ -1,3 +1,3 @@
1
- % SPEC 9.2: extended_gcd/5 returns gcd and Bezout coefficients.
1
+ % Reference 9.2: extended_gcd/5 returns gcd and Bezout coefficients.
2
2
  answer(gcd, result(G, S, T)) :- extended_gcd(240, 46, G, S, T).
3
3
  materialize(answer, 2).
@@ -1,3 +1,3 @@
1
- % SPEC 9.2: collatz_trajectory/2 returns the full path to 1.
1
+ % Reference 9.2: collatz_trajectory/2 returns the full path to 1.
2
2
  answer(path, T) :- collatz_trajectory(6, T).
3
3
  materialize(answer, 2).
@@ -1,3 +1,3 @@
1
- % SPEC 9.2: kaprekar_steps/2 counts iterations to 6174.
1
+ % Reference 9.2: kaprekar_steps/2 counts iterations to 6174.
2
2
  answer(steps, N) :- kaprekar_steps(3524, N).
3
3
  materialize(answer, 2).
@@ -1,3 +1,3 @@
1
- % SPEC 9.2: goldbach_pair/3 enumerates prime decompositions in ascending first prime order.
1
+ % Reference 9.2: goldbach_pair/3 enumerates prime decompositions in ascending first prime order.
2
2
  answer(pair, pair(P, Q)) :- goldbach_pair(28, P, Q).
3
3
  materialize(answer, 2).
@@ -1,4 +1,4 @@
1
- % SPEC 9.2: matrix helpers handle small ground numeric matrices.
1
+ % Reference 9.2: matrix helpers handle small ground numeric matrices.
2
2
  answer(sum, M) :- matrix_sum([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], M).
3
3
  answer(product, M) :- matrix_multiply([[[1, 2], [3, 4]], [[2, 0], [1, 2]]], M).
4
4
  answer(determinant, D) :- determinant([[4, 2], [2, 3]], D).
@@ -1,3 +1,3 @@
1
- % SPEC 9.5: n_queens/2 enumerates finite board solutions.
1
+ % Reference 9.5: n_queens/2 enumerates finite board solutions.
2
2
  answer(solution, Qs) :- n_queens(4, Qs).
3
3
  materialize(answer, 2).
@@ -1,3 +1,3 @@
1
- % SPEC 9.5: cnf_model/3 enumerates satisfying truth assignments for a CNF.
1
+ % Reference 9.5: cnf_model/3 enumerates satisfying truth assignments for a CNF.
2
2
  answer(model, M) :- cnf_model([a, b], [[pos(a), pos(b)], [neg(a)]], M).
3
3
  materialize(answer, 2).
@@ -1,3 +1,3 @@
1
- % SPEC 9.5: alphametic_sum/5 enumerates unique digit assignments for column addition.
1
+ % Reference 9.5: alphametic_sum/5 enumerates unique digit assignments for column addition.
2
2
  answer(solution, result(Digits, Values)) :- alphametic_sum([a, b], [[a], [a]], [b], Digits, Values).
3
3
  materialize(answer, 2).
@@ -1,4 +1,4 @@
1
- % SPEC 9.5: bounded_subset/7 enumerates subsets within budget and risk caps.
1
+ % Reference 9.5: bounded_subset/7 enumerates subsets within budget and risk caps.
2
2
  projects([p(a, 5, 3, 1), p(b, 4, 2, 2), p(c, 7, 5, 3)]).
3
3
  answer(selection, result(Names, Value, Cost, Risk)) :- projects(Ps), bounded_subset(Ps, 5, 3, Names, Value, Cost, Risk).
4
4
  materialize(answer, 2).
@@ -5,6 +5,5 @@ answer(integer_division, 3).
5
5
  answer(remainder, 1).
6
6
  answer(power, 256).
7
7
  answer(minimum, 3).
8
- answer(maximum, 9).
9
8
  answer(less_than, true).
10
9
  answer(greater_equal, true).
@@ -1,4 +1,2 @@
1
- answer(atom_concat, eyelang).
2
1
  answer(str_concat, "eyelang").
3
2
  answer(contains, true).
4
- answer(not_contains, true).
@@ -1,4 +1,2 @@
1
- answer(atom, name(alice, "Alice")).
2
- answer(atom, knows(alice, bob)).
3
1
  answer(binary, exposed(alice, name, "Alice")).
4
2
  answer(binary, exposed(alice, knows, bob)).
@@ -2,4 +2,3 @@ answer(rest, [b, c]).
2
2
  answer(select, selected(a, [b])).
3
3
  answer(select, selected(b, [a])).
4
4
  answer(not_member, true).
5
- answer(is_list, true).
@@ -1,6 +1,3 @@
1
- answer(atom, name(a, "A")).
2
- answer(atom, knows(a, b)).
3
- answer(atom, likes(b, c)).
4
1
  answer(binary, exposed(a, name, "A")).
5
2
  answer(binary, exposed(a, knows, b)).
6
3
  answer(binary, exposed(b, likes, c)).
@@ -1,2 +1 @@
1
- answer(atom, eyelang).
2
1
  answer(string, "eyelang").
@@ -491,9 +491,9 @@ function listExampleNames() {
491
491
  }
492
492
 
493
493
  function readmeCatalogExampleNames() {
494
- const readme = fs.readFileSync(path.join(packageRoot, 'examples', 'eyelang', 'README.md'), 'utf8');
494
+ const readme = fs.readFileSync(path.join(packageRoot, 'docs', 'eyelang-guide.md'), 'utf8');
495
495
  const section = between(readme, '## Example catalog', '## Golden outputs, tests, and conformance');
496
- return [...section.matchAll(/examples\/([A-Za-z0-9_-]+)\.pl/g)]
496
+ return [...section.matchAll(/examples\/eyelang\/([A-Za-z0-9_-]+)\.pl/g)]
497
497
  .map((match) => match[1])
498
498
  .filter((name, index, names) => names.indexOf(name) === index)
499
499
  .sort();
@@ -46,6 +46,8 @@ try {
46
46
  'bin/eyeling.cjs',
47
47
  'dist/browser/eyeling.browser.js',
48
48
  'dist/browser/index.mjs',
49
+ 'docs/eyelang-guide.md',
50
+ 'docs/eyelang-language-reference.md',
49
51
  ];
50
52
 
51
53
  for (const p of mustHave) assert.ok(paths.has(p), `missing from npm pack: ${p}`);
@@ -1,20 +0,0 @@
1
- # Eyelang examples inside Eyeling
2
-
3
- This directory contains eyelang examples that can be exercised through Eyeling's experimental second engine:
4
-
5
- ```bash
6
- eyeling --engine eyelang examples/eyelang/ancestor.pl
7
- ```
8
-
9
- For a paired example, compare the N3 and eyelang versions of the same dependency-risk scenario:
10
-
11
- ```bash
12
- eyeling examples/vulnerability-impact.n3
13
- eyeling --engine eyelang examples/eyelang/vulnerability-impact.pl
14
- ```
15
-
16
- The eyelang conformance corpus is kept under `test/eyelang/` and can be run with:
17
-
18
- ```bash
19
- npm run test:eyelang:corpus
20
- ```