mk: phase 4C — permuteo (with inserto helper)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 58s

inserto a l p: p is l with a inserted at some position. Recursive: head
of l first, then push past head and recurse.

permuteo l p: classical recursive permutation. Empty -> empty; otherwise
take a head off l, recursively permute the tail, insert head at any
position in the recursive result.

7 new tests including all-6-perms-of-3 as a set check (independent of
generation order). 208/208 cumulative.
This commit is contained in:
2026-05-08 07:22:41 +00:00
parent a038d41815
commit b8a0c504bc
3 changed files with 86 additions and 1 deletions

View File

@@ -112,7 +112,9 @@ Key semantic mappings:
- [x] `reverseo` `l` `r` — reverse of list. Forward is fast; backward is `run 1`-clean,
`run*` diverges due to interleaved unbounded list search (canonical TRS issue).
- [ ] `flatteno` `l` `f` — flatten nested lists (deferred — needs atom predicate)
- [ ] `permuteo` `l` `p` — permutation of list (deferred to Phase 5 with `matche`)
- [x] `permuteo` `l` `p` — permutation of list. Built on `inserto` (insert at any
position) and recursive permutation of tail. All 6 perms of (1 2 3) generated
forward; backward `run 1 q (permuteo q (a b c))` finds the input.
- [x] `lengtho` `l` `n` — length as a relation, Peano-encoded:
`:z` / `(:s :z)` / `(:s (:s :z))` ... matches TRS. Forward is direct;
backward enumerates lists of a given length.
@@ -159,6 +161,9 @@ _(none yet)_
_Newest first._
- **2026-05-08** — **Phase 4 piece C — permuteo + inserto**: standard recursive
insert-at-any-position + permute-tail. 7 new tests, including all-6-perms-of-3
as a set check. 208/208 cumulative.
- **2026-05-07** — **Phase 5 piece C — nafc**: `lib/minikanren/nafc.sx`. Three-line
primitive: stream-take 1; if empty, `(unit s)`, else `mzero`. 7 tests including
double-negation and use as a guard. 201/201 cumulative.