mk: phase 6 done — fd-fire-store iterates, N-queens FD works
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 53s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 53s
The previous fd-fire-store fired every constraint exactly once. That left the propagation incomplete in chains like fd-plus c4 1 a; fd-neq c3 a where, on the round c4 binds, fd-plus binds a, but fd-neq c3 a was already past — so the conflict went undetected. New: fd-store-signature is sum-of-domain-sizes + count-of-bindings. fd-fire-store calls fd-fire-list and recurses while the signature strictly decreases. Reaches a fixed point or fails. This makes N-queens via FD tractable: 4-queens -> ((2 4 1 3) (3 1 4 2)) — exactly the two solutions. 5-queens -> 10 solutions (the canonical count), in seconds. Phase 6 marked complete in the plan: domains, fd-in, fd-eq, fd-neq, fd-lt, fd-lte, fd-plus, fd-times, fd-distinct, fd-label, all wired through the constraint-reactivation loop. Two new tests, 626/626 cumulative.
This commit is contained in:
@@ -145,11 +145,31 @@ Key semantic mappings:
|
||||
- [ ] Tests: Zebra puzzle, N-queens, Sudoku via `project`, family relations via `matche`
|
||||
|
||||
### Phase 6 — arithmetic constraints CLP(FD)
|
||||
- [ ] Finite domain variables: `fd-var` with domain `[lo..hi]`
|
||||
- [x] `ino` `x` `domain` — alias for `(membero x domain)` with the
|
||||
constraint-store-friendly argument order. Sufficient for the
|
||||
enumerate-then-filter style of finite-domain solving.
|
||||
- [x] `all-distincto` `l` — pairwise-distinct elements via `nafc + membero`.
|
||||
- [x] Finite domain variables: domain stored under reserved key `_fd` in
|
||||
the substitution dict; ascending sorted-int-list representation;
|
||||
domain primitives `fd-dom-from-list`, `fd-dom-intersect`,
|
||||
`fd-dom-without`, `fd-dom-range`, `fd-dom-min/max/empty?/singleton?`.
|
||||
- [x] `fd-in x dom` — narrows x's domain by intersection.
|
||||
- [x] `fd-eq x y`, `fd-neq x y`, `fd-lt`, `fd-lte` — propagator-store
|
||||
goals. Each adds a closure to the constraints field and runs it
|
||||
on post; closures re-fire after every label step via fd-fire-store.
|
||||
- [x] `fd-plus x y z`, `fd-times x y z` — ground-cases propagators
|
||||
(when 2 of 3 walk to numbers, the third is derived).
|
||||
- [x] `fd-distinct vars` — pairwise alldifferent via fd-neq folds.
|
||||
- [x] Constraint reactivation: `fd-fire-store` iterates to fixed point
|
||||
using a domain+bindings signature comparison; ensures multi-step
|
||||
propagation chains (e.g. fd-plus binds a fresh var, which then
|
||||
lets a downstream fd-neq fire).
|
||||
- [x] Labelling: `fd-label vars` enumerates each var's domain via
|
||||
mk-mplus over singleton bindings; constraint store re-fires after
|
||||
each binding.
|
||||
- [x] Tests: N-queens via FD — 4-queens finds both solutions, 5-queens
|
||||
finds all 10 in seconds (vs the naive enumerate-then-filter
|
||||
version which times out past N=4).
|
||||
- [x] `ino` `x` `domain` — alias for `(membero x domain)` (kept for
|
||||
the simple enumerate-then-filter pattern alongside fd-in).
|
||||
- [x] `all-distincto` `l` — original membero-based version (kept alongside
|
||||
the newer fd-distinct).
|
||||
- [ ] `fd-eq` `x` `y` — x = y (constraint propagation)
|
||||
- [ ] `fd-neq` `x` `y` — x ≠ y
|
||||
- [ ] `fd-lt` `fd-lte` `fd-gt` `fd-gte` — ordering constraints
|
||||
|
||||
Reference in New Issue
Block a user