eyeling 1.33.4 → 1.33.5

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 (95) hide show
  1. package/README.md +1 -0
  2. package/{examples/eyelang/SPEC.md → docs/eyelang-language-reference.md} +6 -10
  3. package/examples/eyelang/README.md +11 -25
  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/packlist.test.js +1 -0
  84. package/examples/eyelang/exact-cover-sudoku.pl +0 -113
  85. package/examples/eyelang/output/exact-cover-sudoku.pl +0 -3
  86. package/examples/eyelang/output/sudoku.pl +0 -2
  87. package/examples/eyelang/sudoku.pl +0 -20
  88. package/lib/eyelang/builtins/sudoku.js +0 -141
  89. package/test/eyelang/conformance/cases/extension/025_is_list_filter.pl +0 -5
  90. package/test/eyelang/conformance/cases/extension/025_is_list_filter.query +0 -1
  91. package/test/eyelang/conformance/cases/extension/041_atom_range_generators.pl +0 -5
  92. package/test/eyelang/conformance/cases/extension/044_cover9_filter.pl +0 -6
  93. package/test/eyelang/conformance/expected/extension/025_is_list_filter.out +0 -1
  94. package/test/eyelang/conformance/expected/extension/041_atom_range_generators.out +0 -8
  95. package/test/eyelang/conformance/expected/extension/044_cover9_filter.out +0 -2
@@ -1,4 +1,4 @@
1
- % SPEC 5.1, 7.1: repeated variables in a rule body require the same term.
1
+ % Reference 5.1, 7.1: repeated variables in a rule body require the same term.
2
2
  pair(a, a).
3
3
  pair(a, b).
4
4
  pair(c, c).
@@ -1,4 +1,4 @@
1
- % SPEC 5.3, 6, 7.1: structured rule heads destructure matching goals.
1
+ % Reference 5.3, 6, 7.1: structured rule heads destructure matching goals.
2
2
  unpack(pair(X, Y), X, Y).
3
3
  answer(first, A) :- unpack(pair(alpha, beta), A, _).
4
4
  answer(second, B) :- unpack(pair(alpha, beta), _, B).
@@ -1,4 +1,4 @@
1
- % SPEC 3.5, 11: quoted strings and atoms preserve escape sequences at read-back.
1
+ % Reference 3.5, 11: quoted strings and atoms preserve escape sequences at read-back.
2
2
  raw(string, "line\nnext\t\\slash").
3
3
  raw(atom, 'line\nnext\t\\slash').
4
4
  answer(K, V) :- raw(K, V).
@@ -1,4 +1,4 @@
1
- % SPEC 3.3, 11: signed, decimal, and exponent numeric literals retain lexical form.
1
+ % Reference 3.3, 11: signed, decimal, and exponent numeric literals retain lexical form.
2
2
  raw(negative_decimal, -3.5).
3
3
  raw(positive_exp, 6.02e23).
4
4
  raw(negative_exp, -1.0e-3).
@@ -1,4 +1,4 @@
1
- % SPEC 5.5, 7: formula data can be passed through parenthesized conjunctions.
1
+ % Reference 5.5, 7: formula data can be passed through parenthesized conjunctions.
2
2
  record((left(a), right(b))).
3
3
  accept((left(a), right(b))).
4
4
  answer(ok, F) :- (record(F), accept(F)).
@@ -1,4 +1,4 @@
1
- % SPEC 3.4, 5.1: variables beginning with underscore are named variables unless exactly _.
1
+ % Reference 3.4, 5.1: variables beginning with underscore are named variables unless exactly _.
2
2
  pair(a, a).
3
3
  pair(a, b).
4
4
  answer(shared, _Value) :- pair(_Value, _Value).
@@ -1,4 +1,4 @@
1
- % SPEC 11: default output prints new ground binary derivations, not source facts.
1
+ % Reference 11: default output prints new ground binary derivations, not source facts.
2
2
  parent(pat, jan).
3
3
  parent(jan, emma).
4
4
  ancestor(X, Y) :- parent(X, Y).
@@ -1,4 +1,4 @@
1
- % SPEC 10.2, 11: materialize/2 restricts selected default predicate groups.
1
+ % Reference 10.2, 11: materialize/2 restricts selected default predicate groups.
2
2
  materialize(answer, 2).
3
3
  seed(a).
4
4
  helper(X, y) :- seed(X).
@@ -1,4 +1,4 @@
1
- % SPEC 9.2, 9.3: arithmetic and comparison built-ins.
1
+ % Reference 9.2, 9.3: arithmetic and comparison built-ins.
2
2
  answer(sum, X) :- add(2, 3, X).
3
3
  answer(diff, X) :- sub(7, 4, X).
4
4
  answer(product, X) :- mul(6, 7, X).
@@ -6,7 +6,6 @@ answer(integer_division, X) :- div(7, 2, X).
6
6
  answer(remainder, X) :- mod(7, 2, X).
7
7
  answer(power, X) :- pow(2, 8, X).
8
8
  answer(minimum, X) :- min(3, 9, X).
9
- answer(maximum, X) :- max(3, 9, X).
10
9
  answer(less_than, true) :- lt(3, 9).
11
10
  answer(greater_equal, true) :- ge(9, 9).
12
11
  materialize(answer, 2).
@@ -1,6 +1,4 @@
1
- % SPEC 9.6: atom and string built-ins.
2
- answer(atom_concat, X) :- atom_concat(eye, lang, X).
1
+ % Reference 9.6: atom and string built-ins.
3
2
  answer(str_concat, X) :- str_concat("eye", "lang", X).
4
3
  answer(contains, true) :- contains("eyelang", "lang").
5
- answer(not_contains, true) :- not_contains("eyelang", "cat").
6
4
  materialize(answer, 2).
@@ -1,4 +1,4 @@
1
- % SPEC 9.7, 9.8: list, aggregation, and ordering built-ins.
1
+ % Reference 9.7, 9.8: list, aggregation, and ordering built-ins.
2
2
  answer(member, X) :- member(X, [a, b]).
3
3
  answer(append, X) :- append([a], [b, c], X).
4
4
  answer(nth0, X) :- nth0(1, [a, b, c], X).
@@ -1,5 +1,4 @@
1
- % SPEC 9.9: formula_atom/2 and formula_binary/4 over comma formula data.
1
+ % Reference 9.9: formula_binary/4 over comma formula data.
2
2
  formula((name(alice, "Alice"), knows(alice, bob))).
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 9.5, 9.10: generators, negation as failure, and once/1.
1
+ % Reference 9.5, 9.10: generators, negation as failure, and once/1.
2
2
  candidate(a).
3
3
  candidate(b).
4
4
  closed(b).
@@ -1,4 +1,4 @@
1
- % SPEC 9.1: eq/2 unifies terms and neq/2 succeeds on non-unifiable terms.
1
+ % Reference 9.1: eq/2 unifies terms and neq/2 succeeds on non-unifiable terms.
2
2
  answer(eq_variable, X) :- eq(X, pair(a, [b, c])).
3
3
  answer(eq_nested, true) :- eq(pair(X, X), pair(same, same)).
4
4
  answer(neq_atoms, true) :- neq(alice, bob).
@@ -1,6 +1,5 @@
1
- % SPEC 9.7: rest/2, select/3, not_member/2, and is_list/1.
1
+ % Reference 9.7: rest/2, select/3, and not_member/2.
2
2
  answer(rest, X) :- rest([a, b, c], X).
3
3
  answer(select, selected(X, R)) :- select(X, [a, b], R).
4
4
  answer(not_member, true) :- not_member(c, [a, b]).
5
- answer(is_list, true) :- is_list([a, b]).
6
5
  materialize(answer, 2).
@@ -1,3 +1,3 @@
1
- % SPEC 9.7: append/3 can enumerate proper prefix/suffix splits.
1
+ % Reference 9.7: append/3 can enumerate proper prefix/suffix splits.
2
2
  answer(split, split(A, B)) :- append(A, B, [a, b]).
3
3
  materialize(answer, 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").
@@ -46,6 +46,7 @@ try {
46
46
  'bin/eyeling.cjs',
47
47
  'dist/browser/eyeling.browser.js',
48
48
  'dist/browser/index.mjs',
49
+ 'docs/eyelang-language-reference.md',
49
50
  ];
50
51
 
51
52
  for (const p of mustHave) assert.ok(paths.has(p), `missing from npm pack: ${p}`);
@@ -1,113 +0,0 @@
1
- % Exact-cover-style 9x9 Sudoku without cut.
2
- %
3
- % Instead of generating every row permutation, each row has three candidate
4
- % rows that already satisfy the visible givens from a classic Sudoku puzzle.
5
- % The solver then chooses one candidate per row and checks the exact-cover
6
- % constraints for all columns and 3x3 boxes.
7
-
8
- % Output declarations: materialize/2 selects the relations written to this example's golden output.
9
- materialize(status, 2).
10
- materialize(solution, 2).
11
- materialize(firstRow, 2).
12
-
13
- % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
14
- % Derivation rules: each rule below contributes one logical step toward the displayed results.
15
- cover9(Cells) :-
16
- sort(Cells, [1, 2, 3, 4, 5, 6, 7, 8, 9]).
17
-
18
- % Puzzle givens, with dots shown in the comment for readability:
19
- % 53..7....
20
- % 6..195...
21
- % .98....6.
22
- % 8...6...3
23
- % 4..8.3..1
24
- % 7...2...6
25
- % .6....28.
26
- % ...419..5
27
- % ....8..79
28
-
29
- row_candidate(1, [5, 3, 6, 4, 7, 8, 9, 1, 2]).
30
- row_candidate(1, [5, 3, 8, 6, 7, 4, 9, 1, 2]).
31
- row_candidate(1, [5, 3, 4, 6, 7, 8, 9, 1, 2]).
32
-
33
- row_candidate(2, [6, 2, 7, 1, 9, 5, 3, 4, 8]).
34
- row_candidate(2, [6, 3, 2, 1, 9, 5, 7, 4, 8]).
35
- row_candidate(2, [6, 7, 2, 1, 9, 5, 3, 4, 8]).
36
-
37
- row_candidate(3, [3, 9, 8, 1, 4, 2, 5, 6, 7]).
38
- row_candidate(3, [4, 9, 8, 3, 1, 2, 5, 6, 7]).
39
- row_candidate(3, [1, 9, 8, 3, 4, 2, 5, 6, 7]).
40
-
41
- row_candidate(4, [8, 9, 5, 7, 6, 1, 4, 2, 3]).
42
- row_candidate(4, [8, 7, 9, 5, 6, 1, 4, 2, 3]).
43
- row_candidate(4, [8, 5, 9, 7, 6, 1, 4, 2, 3]).
44
-
45
- row_candidate(5, [4, 6, 2, 8, 5, 3, 7, 9, 1]).
46
- row_candidate(5, [4, 5, 6, 8, 2, 3, 7, 9, 1]).
47
- row_candidate(5, [4, 2, 6, 8, 5, 3, 7, 9, 1]).
48
-
49
- row_candidate(6, [7, 3, 1, 9, 2, 4, 8, 5, 6]).
50
- row_candidate(6, [7, 9, 3, 1, 2, 4, 8, 5, 6]).
51
- row_candidate(6, [7, 1, 3, 9, 2, 4, 8, 5, 6]).
52
-
53
- row_candidate(7, [1, 6, 9, 5, 3, 7, 2, 8, 4]).
54
- row_candidate(7, [5, 6, 1, 9, 3, 7, 2, 8, 4]).
55
- row_candidate(7, [9, 6, 1, 5, 3, 7, 2, 8, 4]).
56
-
57
- row_candidate(8, [8, 2, 7, 4, 1, 9, 6, 3, 5]).
58
- row_candidate(8, [7, 8, 2, 4, 1, 9, 6, 3, 5]).
59
- row_candidate(8, [2, 8, 7, 4, 1, 9, 6, 3, 5]).
60
-
61
- row_candidate(9, [4, 3, 5, 2, 8, 6, 1, 7, 9]).
62
- row_candidate(9, [5, 4, 3, 2, 8, 6, 1, 7, 9]).
63
- row_candidate(9, [3, 4, 5, 2, 8, 6, 1, 7, 9]).
64
-
65
- sudoku9([
66
- [A1, A2, A3, A4, A5, A6, A7, A8, A9],
67
- [B1, B2, B3, B4, B5, B6, B7, B8, B9],
68
- [C1, C2, C3, C4, C5, C6, C7, C8, C9],
69
- [D1, D2, D3, D4, D5, D6, D7, D8, D9],
70
- [E1, E2, E3, E4, E5, E6, E7, E8, E9],
71
- [F1, F2, F3, F4, F5, F6, F7, F8, F9],
72
- [G1, G2, G3, G4, G5, G6, G7, G8, G9],
73
- [H1, H2, H3, H4, H5, H6, H7, H8, H9],
74
- [I1, I2, I3, I4, I5, I6, I7, I8, I9]
75
- ]) :-
76
- row_candidate(1, [A1, A2, A3, A4, A5, A6, A7, A8, A9]),
77
- row_candidate(2, [B1, B2, B3, B4, B5, B6, B7, B8, B9]),
78
- row_candidate(3, [C1, C2, C3, C4, C5, C6, C7, C8, C9]),
79
- row_candidate(4, [D1, D2, D3, D4, D5, D6, D7, D8, D9]),
80
- row_candidate(5, [E1, E2, E3, E4, E5, E6, E7, E8, E9]),
81
- row_candidate(6, [F1, F2, F3, F4, F5, F6, F7, F8, F9]),
82
- row_candidate(7, [G1, G2, G3, G4, G5, G6, G7, G8, G9]),
83
- row_candidate(8, [H1, H2, H3, H4, H5, H6, H7, H8, H9]),
84
- row_candidate(9, [I1, I2, I3, I4, I5, I6, I7, I8, I9]),
85
-
86
- cover9([A1, B1, C1, D1, E1, F1, G1, H1, I1]),
87
- cover9([A2, B2, C2, D2, E2, F2, G2, H2, I2]),
88
- cover9([A3, B3, C3, D3, E3, F3, G3, H3, I3]),
89
- cover9([A4, B4, C4, D4, E4, F4, G4, H4, I4]),
90
- cover9([A5, B5, C5, D5, E5, F5, G5, H5, I5]),
91
- cover9([A6, B6, C6, D6, E6, F6, G6, H6, I6]),
92
- cover9([A7, B7, C7, D7, E7, F7, G7, H7, I7]),
93
- cover9([A8, B8, C8, D8, E8, F8, G8, H8, I8]),
94
- cover9([A9, B9, C9, D9, E9, F9, G9, H9, I9]),
95
-
96
- cover9([A1, A2, A3, B1, B2, B3, C1, C2, C3]),
97
- cover9([A4, A5, A6, B4, B5, B6, C4, C5, C6]),
98
- cover9([A7, A8, A9, B7, B8, B9, C7, C8, C9]),
99
- cover9([D1, D2, D3, E1, E2, E3, F1, F2, F3]),
100
- cover9([D4, D5, D6, E4, E5, E6, F4, F5, F6]),
101
- cover9([D7, D8, D9, E7, E8, E9, F7, F8, F9]),
102
- cover9([G1, G2, G3, H1, H2, H3, I1, I2, I3]),
103
- cover9([G4, G5, G6, H4, H5, H6, I4, I5, I6]),
104
- cover9([G7, G8, G9, H7, H8, H9, I7, I8, I9]).
105
-
106
- status(exact_cover_sudoku, solved) :-
107
- once(sudoku9(_Grid)).
108
-
109
- solution(exact_cover_sudoku, Grid) :-
110
- once(sudoku9(Grid)).
111
-
112
- firstRow(exact_cover_sudoku, Row) :-
113
- once(sudoku9([Row|_Rows])).
@@ -1,3 +0,0 @@
1
- status(exact_cover_sudoku, solved).
2
- solution(exact_cover_sudoku, [[5, 3, 4, 6, 7, 8, 9, 1, 2], [6, 7, 2, 1, 9, 5, 3, 4, 8], [1, 9, 8, 3, 4, 2, 5, 6, 7], [8, 5, 9, 7, 6, 1, 4, 2, 3], [4, 2, 6, 8, 5, 3, 7, 9, 1], [7, 1, 3, 9, 2, 4, 8, 5, 6], [9, 6, 1, 5, 3, 7, 2, 8, 4], [2, 8, 7, 4, 1, 9, 6, 3, 5], [3, 4, 5, 2, 8, 6, 1, 7, 9]]).
3
- firstRow(exact_cover_sudoku, [5, 3, 4, 6, 7, 8, 9, 1, 2]).
@@ -1,2 +0,0 @@
1
- solution(classic, [[1, 6, 2, 8, 5, 7, 4, 9, 3], [5, 3, 4, 1, 2, 9, 6, 7, 8], [7, 8, 9, 6, 4, 3, 5, 2, 1], [4, 7, 5, 3, 1, 2, 9, 8, 6], [9, 1, 3, 5, 8, 6, 7, 4, 2], [6, 2, 8, 7, 9, 4, 1, 3, 5], [3, 5, 6, 4, 7, 8, 2, 1, 9], [2, 4, 1, 9, 3, 5, 8, 6, 7], [8, 9, 7, 2, 6, 1, 3, 5, 4]]).
2
- solution(third, [[4, 7, 8, 2, 6, 9, 1, 3, 5], [2, 9, 5, 1, 7, 3, 4, 8, 6], [1, 3, 6, 4, 5, 8, 7, 9, 2], [9, 4, 2, 6, 3, 5, 8, 7, 1], [8, 1, 7, 9, 4, 2, 5, 6, 3], [6, 5, 3, 8, 1, 7, 2, 4, 9], [7, 2, 1, 3, 9, 4, 6, 5, 8], [5, 6, 9, 7, 8, 1, 3, 2, 4], [3, 8, 4, 5, 2, 6, 9, 1, 7]]).
@@ -1,20 +0,0 @@
1
- % Generic 9x9 Sudoku example using the compiled sudoku/2 builtin.
2
- %
3
- % Puzzles are 81-character strings read row-major. Digits 1..9 are givens;
4
- % 0, dot, or underscore marks a blank. The builtin also accepts a 9x9 list
5
- % of integers in the same representation.
6
-
7
- % Output declarations: materialize/2 selects the relations written to this example's golden output.
8
- materialize(solution, 2).
9
-
10
- % Program structure: facts set up the scenario, and rules derive the materialized conclusions.
11
- puzzle(classic,
12
- "100007090030129008009600500005300900010080002600794000350408219240005867897201304").
13
-
14
- puzzle(third,
15
- "078200000005000400100400092000035070007000500050810000720004008009000300000006910").
16
-
17
- % Derivation rules: each rule below contributes one logical step toward the displayed results.
18
- solution(Name, Rows) :-
19
- puzzle(Name, Grid),
20
- sudoku(Grid, Rows).