diff --git a/lib/prolog/tests/programs/nqueens.pl b/lib/prolog/tests/programs/nqueens.pl new file mode 100644 index 00000000..c5fc43c9 --- /dev/null +++ b/lib/prolog/tests/programs/nqueens.pl @@ -0,0 +1,27 @@ +%% nqueens — permutation-and-test formulation. +%% Caller passes the row list [1..N]; queens/2 finds N column placements +%% s.t. no two queens attack on a diagonal. Same-column attacks are +%% structurally impossible — Qs is a permutation, all distinct. +%% +%% No `>/2` `/2` etc.). - [ ] `family.pl` — facts + rules (parent/ancestor) - [ ] `lib/prolog/conformance.sh` + runner, `scoreboard.json` + `scoreboard.md` - [ ] Target: all 5 classic programs passing @@ -88,6 +88,7 @@ Representation choices (finalise in phase 1, document here): _Newest first. Agent appends on every commit._ +- 2026-04-25 — `nqueens.pl` fourth classic program. Permute-and-test variant exercises every Phase-3 feature: lists with `[H|T]` cons sugar, multi-clause backtracking, recursive `permute`/`select`/`safe`/`no_attack`, `is/2` arithmetic on diagonals, `\=/2` for diagonal-conflict check. 6 tests at N ∈ {1,2,3,4,5} with expected counts {1,0,0,2,10} + first-solution `[2,4,1,3]`. N=5 takes ~30s (120 perms × safe-check); N=8 omitted as it would be ~thousands of seconds. Total 173 (+6). - 2026-04-25 — `member.pl` third classic program. Standard 2-clause definition; 7 tests cover bound-element hit/miss, empty-list fail, generator-count = list length, first-solution binding (X=11), duplicate elements matched twice on backtrack, anonymous-head unification (`member(a, [X, b, c])` binds X=a). Total 167 (+7). - 2026-04-25 — `reverse.pl` second classic program. Naive reverse defined via append. 6 tests (empty/singleton/3-list/4-atom-list/ground match/ground mismatch). Confirms the solver handles non-trivial recursive composition: `reverse([1,2,3], R)` recurses to depth 3 then unwinds via 3 nested `append`s. Total 160 (+6). - 2026-04-25 — `append.pl` first classic program. `lib/prolog/tests/programs/append.pl` is the canonical 2-clause source; `append.sx` embeds the source as a string (no file-read primitive in SX yet) and runs 6 tests covering build, check, full split-backtrack (4 solutions), and deduction modes. Helpers `pl-ap-list-to-sx` / `pl-ap-term-to-sx` convert deep-walked Prolog lists (`("compound" "." (h t))` / `("atom" "[]")`) to SX lists for structural assertion. Total 154 (+6).