Skip to content

bend.ts accepts books the Lean kernel refuses: base-file live calls to later-filled laws, and non-Tree bodies #793

Closed as not planned

Description

@docxology

Summary

bend.ts accepts books whose semantics fall outside the fragment bend.lean states as Book.Ok — i.e. the implementation is strictly weaker than the mechanized core in two concrete, code-level ways. Neither is currently exploitable from a user file, but both are silent spec/implementation drift in the places the header claims are enforced ("mutual recursion cannot bypass the wall").

1. Base-file live calls to later-filled laws bypass the descent wall

infer-ref (bend.ts:~3292-3296) skips the "an unfilled law is a dead claim (live code cannot use it)" error whenever tld.b === true — a flag book_load sets for every base.bend tld. Shipped base.bend uses it: Word.adc.con (base.bend:1151) live-calls Word.adc, whose law is declared at 1143 and filled at 1156 — a forward live call, i.e. genuine mutual recursion whose descent the wall never tests. bend.lean's corresponding rule demands (q != .None -> j <= L.k) and rejects exactly this; its header even flags "that pair is mutual recursion the checker never tests ... The theory has no such call."

2. Def bodies are not required to be Trees

Lean's Book.Ok requires Tree beta d.n d.body (bend.lean:991) — the case-tree-over-columns invariant that check-mat's column-peel soundness rests on. book_valid (bend.ts:~3699-3712) checks bodies with term_check alone and never verifies Tree shape; e.g. a body that partially applies via check-any with zero columns bound checks fine in bend.ts while failing Tree. Benign for termination (fewer bound columns only tightens the descent scan), but it means the "model inclusion" claim does not hold for books bend.ts accepts.

Suggested direction

Restrict the b === true carve-out to demand-None (keep the live unfilled-law error for base too) and reorder base.bend's helpers, or thread a helper-self-recursion rule through the Lean model; record a Tree-shape bit at parse time so book_valid enforces what Book.Ok assumes.

Version / system

  • bend 2.0.5 (main @ e6676b0); reading-level finding against bend.ts/bend.lean/base.bend, no user-file trigger (the carve-out is set only for BASE_BEND).

Activity

  1. VictorTaelin commented on Sep 18, 2026

    @VictorTaelin
    Contributor

    Both points are documented scope differences, not gaps in what ships. (1) The carve-out is exactly bend.lean:96-104: only the base file (tld.b = true, set for BASE_BEND alone, bend.ts:1065-1071 and checked at 3294) may have a helper call a law filled below it; no user file can reach that path, and the base pair (Word.adc.con / Word.adc) is the one such case. (2) bend.lean:63-66 states that Book.Ok trusts the body shape the parser produces; the parser is the only producer of bodies, and no term outside that shape can be written. Folding Word.adc.con into Word.adc so the exemption has no user is on the list; enforcing the Tree shape in book_valid would be a check of the parser against itself. Closing as by design; reopen with a program that reaches either path from a user file.

    Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions