a4be1e58a3
Iteration-discipline milestone, 2 of 3. Strictly additive (nothing tail-related removed; that is it.3). New whole-body pass verify_structural_recursion sibling of verify_tail_positions (DD-1): smaller-set algorithm with implicit candidate inference + unconstrained accumulators (DD-2, foldl=structural), self/mutual via inline ADT-family union-find (DD-3), it.2-only tail==false grandfather. CheckError::NonStructuralRecursion. term_contains_loop (stops at Term::Lam, DD-4) injects Diverge so existing UndeclaredEffect enforces it, no new variant; lam-arrow + LetRec sub-effect sites wired. DESIGN.md Decision 3 synced. Four it.1 loop fixtures gained !Diverge. Two spec-premise boundary defects surfaced + resolved within the additive invariant (corpus clean, check not weakened), recorded as corrected it.3 corpus-migration scope: (1) the "21 tail-app fixtures" grandfather premise under-counts the corpus — no-ADT-candidate counter recursions have no structural position to verify, deferred to it.3; (2) two RC-regression fixtures joined the spec's transitional tail-app grandfather as the other 20 do (RC==GC guards verified still green). cargo test --workspace 622/0; 9 acceptance pins non-vacuous. Specfda9b78, planbc9f512.
27 lines
896 B
Plaintext
27 lines
896 B
Plaintext
; Iter it.2 positive (spec D1): foldl-shape accumulator. `go` recurses
|
|
; on the Cons-tail `t` at position 0 (structurally guarded) while
|
|
; threading an unconstrained accumulator `acc` at position 1. The
|
|
; accumulator position is never examined by the guardedness check, so
|
|
; this classifies as structural recursion: pure, total, Diverge-free,
|
|
; with NO `tail-app` marker. This is the single most LLM-natural
|
|
; iteration shape and must stay structural (spec D1).
|
|
|
|
(module struct_rec_foldl_sum
|
|
|
|
(data IntList
|
|
(ctor INil)
|
|
(ctor ICons (con Int) (con IntList)))
|
|
|
|
(fn go
|
|
(doc "Sum via a foldl-shape accumulator; structural on the tail.")
|
|
(type
|
|
(fn-type
|
|
(params (con IntList) (con Int))
|
|
(ret (con Int))))
|
|
(params xs acc)
|
|
(body
|
|
(match xs
|
|
(case (pat-ctor INil) acc)
|
|
(case (pat-ctor ICons h t)
|
|
(app go t (app + acc h)))))))
|