eyeling 1.33.3 → 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.
- package/README.md +1 -0
- package/{examples/eyelang/SPEC.md → docs/eyelang-language-reference.md} +6 -10
- package/examples/eyelang/README.md +11 -25
- package/lib/eyelang/builtins/arithmetic.js +1 -3
- package/lib/eyelang/builtins/formula.js +0 -16
- package/lib/eyelang/builtins/lists.js +0 -5
- package/lib/eyelang/builtins/registry.js +1 -2
- package/lib/eyelang/builtins/search.js +1 -61
- package/lib/eyelang/builtins/strings.js +10 -14
- package/package.json +2 -1
- package/test/eyelang/conformance/README.md +7 -7
- package/test/eyelang/conformance/cases/core/001_fact_output.pl +1 -1
- package/test/eyelang/conformance/cases/core/002_rule_recursion.pl +1 -1
- package/test/eyelang/conformance/cases/core/003_terms_and_readback.pl +1 -1
- package/test/eyelang/conformance/cases/core/004_conjunction_and_parentheses.pl +1 -1
- package/test/eyelang/conformance/cases/core/005_list_deconstruction.pl +1 -1
- package/test/eyelang/conformance/cases/core/006_comma_formula_data.pl +1 -1
- package/test/eyelang/conformance/cases/core/007_anonymous_variables.pl +1 -1
- package/test/eyelang/conformance/cases/core/008_graphic_atoms.pl +1 -1
- package/test/eyelang/conformance/cases/core/009_comments_and_whitespace.pl +1 -1
- package/test/eyelang/conformance/cases/core/010_variable_scope_and_reuse.pl +1 -1
- package/test/eyelang/conformance/cases/core/011_predicate_arity.pl +1 -1
- package/test/eyelang/conformance/cases/core/012_nested_compound_unification.pl +1 -1
- package/test/eyelang/conformance/cases/core/013_multiple_clauses_order.pl +1 -1
- package/test/eyelang/conformance/cases/core/014_failure_filters_answers.pl +1 -1
- package/test/eyelang/conformance/cases/core/015_improper_list_unification.pl +1 -1
- package/test/eyelang/conformance/cases/core/016_zero_arity_compound.pl +1 -1
- package/test/eyelang/conformance/cases/core/017_three_step_recursion.pl +1 -1
- package/test/eyelang/conformance/cases/core/018_quoted_atom_readback.pl +1 -1
- package/test/eyelang/conformance/cases/core/019_parenthesized_three_conjuncts.pl +1 -1
- package/test/eyelang/conformance/cases/core/020_nested_list_terms.pl +1 -1
- package/test/eyelang/conformance/cases/core/021_repeated_variable_head.pl +1 -1
- package/test/eyelang/conformance/cases/core/022_rule_head_structure.pl +1 -1
- package/test/eyelang/conformance/cases/core/023_quoted_escapes_readback.pl +1 -1
- package/test/eyelang/conformance/cases/core/024_numeric_literal_readback.pl +1 -1
- package/test/eyelang/conformance/cases/core/025_body_parentheses_with_formula_data.pl +1 -1
- package/test/eyelang/conformance/cases/core/026_underscore_named_variable_reuse.pl +1 -1
- package/test/eyelang/conformance/cases/extension/001_default_derived_output.pl +1 -1
- package/test/eyelang/conformance/cases/extension/002_materialize_focus.pl +1 -1
- package/test/eyelang/conformance/cases/extension/003_arithmetic_and_comparison.pl +1 -2
- package/test/eyelang/conformance/cases/extension/004_strings_and_atoms.pl +1 -3
- package/test/eyelang/conformance/cases/extension/005_lists_aggregation_ordering.pl +1 -1
- package/test/eyelang/conformance/cases/extension/006_formula_terms.pl +1 -2
- package/test/eyelang/conformance/cases/extension/007_negation_once_generators.pl +1 -1
- package/test/eyelang/conformance/cases/extension/008_equality_and_inequality.pl +1 -1
- package/test/eyelang/conformance/cases/extension/009_list_relations.pl +1 -2
- package/test/eyelang/conformance/cases/extension/010_append_splits.pl +1 -1
- package/test/eyelang/conformance/cases/extension/011_matching_and_comparison.pl +1 -1
- package/test/eyelang/conformance/cases/extension/012_memoize_declaration.pl +1 -1
- package/test/eyelang/conformance/cases/extension/013_numeric_functions.pl +1 -1
- package/test/eyelang/conformance/cases/extension/014_between_enumeration.pl +1 -1
- package/test/eyelang/conformance/cases/extension/015_smallest_divisor.pl +1 -1
- package/test/eyelang/conformance/cases/extension/016_negation_filter.pl +1 -1
- package/test/eyelang/conformance/cases/extension/017_once_user_predicate.pl +1 -1
- package/test/eyelang/conformance/cases/extension/018_findall_user_goal.pl +1 -1
- package/test/eyelang/conformance/cases/extension/019_sort_deduplicates_atoms.pl +1 -1
- package/test/eyelang/conformance/cases/extension/020_append_bound_prefix_suffix.pl +1 -1
- package/test/eyelang/conformance/cases/extension/021_nth0_index_generation.pl +1 -1
- package/test/eyelang/conformance/cases/extension/022_set_nth0_edges.pl +1 -1
- package/test/eyelang/conformance/cases/extension/023_select_duplicate_occurrences.pl +1 -1
- package/test/eyelang/conformance/cases/extension/024_not_member_filter.pl +1 -1
- package/test/eyelang/conformance/cases/extension/026_nested_formula_terms.pl +1 -2
- package/test/eyelang/conformance/cases/extension/027_materialize_excludes_source_fact.pl +1 -1
- package/test/eyelang/conformance/cases/extension/028_numeric_and_lexical_comparison.pl +1 -1
- package/test/eyelang/conformance/cases/extension/029_string_matching_filters.pl +1 -1
- package/test/eyelang/conformance/cases/extension/030_string_and_atom_concat.pl +1 -2
- package/test/eyelang/conformance/cases/extension/035_date_difference.pl +1 -1
- package/test/eyelang/conformance/cases/extension/036_extended_gcd.pl +1 -1
- package/test/eyelang/conformance/cases/extension/037_collatz_trajectory.pl +1 -1
- package/test/eyelang/conformance/cases/extension/038_kaprekar_steps.pl +1 -1
- package/test/eyelang/conformance/cases/extension/039_goldbach_pair.pl +1 -1
- package/test/eyelang/conformance/cases/extension/040_matrix_operations.pl +1 -1
- package/test/eyelang/conformance/cases/extension/042_n_queens_small.pl +1 -1
- package/test/eyelang/conformance/cases/extension/043_cnf_model.pl +1 -1
- package/test/eyelang/conformance/cases/extension/045_alphametic_sum_small.pl +1 -1
- package/test/eyelang/conformance/cases/extension/046_bounded_subset.pl +1 -1
- package/test/eyelang/conformance/expected/extension/003_arithmetic_and_comparison.out +0 -1
- package/test/eyelang/conformance/expected/extension/004_strings_and_atoms.out +0 -2
- package/test/eyelang/conformance/expected/extension/006_formula_terms.out +0 -2
- package/test/eyelang/conformance/expected/extension/009_list_relations.out +0 -1
- package/test/eyelang/conformance/expected/extension/026_nested_formula_terms.out +0 -3
- package/test/eyelang/conformance/expected/extension/030_string_and_atom_concat.out +0 -1
- package/test/packlist.test.js +1 -0
- package/test/run.js +21 -3
- package/examples/eyelang/exact-cover-sudoku.pl +0 -113
- package/examples/eyelang/output/exact-cover-sudoku.pl +0 -3
- package/examples/eyelang/output/sudoku.pl +0 -2
- package/examples/eyelang/sudoku.pl +0 -20
- package/lib/eyelang/builtins/sudoku.js +0 -141
- package/test/eyelang/conformance/cases/extension/025_is_list_filter.pl +0 -5
- package/test/eyelang/conformance/cases/extension/025_is_list_filter.query +0 -1
- package/test/eyelang/conformance/cases/extension/041_atom_range_generators.pl +0 -5
- package/test/eyelang/conformance/cases/extension/044_cover9_filter.pl +0 -6
- package/test/eyelang/conformance/expected/extension/025_is_list_filter.out +0 -1
- package/test/eyelang/conformance/expected/extension/041_atom_range_generators.out +0 -8
- package/test/eyelang/conformance/expected/extension/044_cover9_filter.out +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
%
|
|
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
|
-
%
|
|
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
|
-
%
|
|
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,5 +1,4 @@
|
|
|
1
|
-
%
|
|
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
|
-
%
|
|
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
|
-
%
|
|
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,4 +1,4 @@
|
|
|
1
|
-
%
|
|
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,5 +1,4 @@
|
|
|
1
|
-
%
|
|
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
|
-
%
|
|
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
|
-
%
|
|
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,4 +1,4 @@
|
|
|
1
|
-
%
|
|
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
|
-
%
|
|
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
|
-
%
|
|
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).
|
package/test/packlist.test.js
CHANGED
package/test/run.js
CHANGED
|
@@ -126,9 +126,26 @@ function addSectionToAggregate(summary) {
|
|
|
126
126
|
aggregate.nonconform += failed;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
function
|
|
129
|
+
function scoreColor(score) {
|
|
130
|
+
if (aggregate.crashed || aggregate.nonconform) return C.r;
|
|
131
|
+
if (aggregate.incomplete || score < 100) return C.y;
|
|
132
|
+
return C.g;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function scoreLine(elapsedMs) {
|
|
130
136
|
const score = aggregate.total === 0 ? 0 : (100 * aggregate.ok) / aggregate.total;
|
|
131
|
-
|
|
137
|
+
const scoreC = scoreColor(score);
|
|
138
|
+
return [
|
|
139
|
+
`${C.dim}TOTAL${C.n}`,
|
|
140
|
+
`${C.dim}[COUNT:${aggregate.total}]${C.n}`,
|
|
141
|
+
`${C.g}OK:${C.n} ${C.y}⭐${aggregate.ok}⭐${C.n}`,
|
|
142
|
+
`${C.r}INCOMPLETE:${C.n} ${C.y}⭐${aggregate.incomplete}⭐${C.n}`,
|
|
143
|
+
`${C.r}NONCONFORM:${C.n} ${C.y}⭐${aggregate.nonconform}⭐${C.n}`,
|
|
144
|
+
`${C.r}CRASHED:${C.n} ${C.y}⭐${aggregate.crashed}⭐${C.n}`,
|
|
145
|
+
'=>',
|
|
146
|
+
`${scoreC}SCORE:${C.n} ${C.y}⭐⭐⭐${score.toFixed(1)}⭐⭐⭐${C.n}`,
|
|
147
|
+
`${C.dim}ELAPSED:${C.n} ${C.y}${formatDuration(elapsedMs)}${C.n}`,
|
|
148
|
+
].join(' ');
|
|
132
149
|
}
|
|
133
150
|
|
|
134
151
|
function childEnv() {
|
|
@@ -194,6 +211,7 @@ function runSection(label, cmd, args) {
|
|
|
194
211
|
}
|
|
195
212
|
|
|
196
213
|
(async function main() {
|
|
214
|
+
const suiteStartedAt = Date.now();
|
|
197
215
|
let status = 0;
|
|
198
216
|
for (const [label, cmd, args] of sections) {
|
|
199
217
|
const sectionStatus = await runSection(label, cmd, args);
|
|
@@ -204,7 +222,7 @@ function runSection(label, cmd, args) {
|
|
|
204
222
|
}
|
|
205
223
|
|
|
206
224
|
console.log('');
|
|
207
|
-
console.log(scoreLine());
|
|
225
|
+
console.log(scoreLine(Date.now() - suiteStartedAt));
|
|
208
226
|
|
|
209
227
|
process.exit(status);
|
|
210
228
|
})();
|
|
@@ -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).
|