Repository navigation
BendTT converts a λ+ as a λ: a q=2 binder says how a λ runs, not what it is (#1189) - #1224
Conversation
Lorenzobattistela
left a comment
There was a problem hiding this comment.
I merged this onto main 1159f0b0 and ran the gates over BEND_HOC. Everything passes, and the fix does what it says.
Gates on the merge
gates/_run.ts: repo PASS 50 / 50, test PASS 1547 / 1547, perf PASS 124 / 124, ping PASS 46 / 46, in 20.6 s.gates/safe.ts tests, this PR's kernel against main's:- main: 1,557 files; 992 agree, 71 u, 491 bend2 rejects, 2 out of scope, 1 false reject (
agree_32, out of fuel, already there on main). - this PR: 1,558 files; 993 agree, everything else the same.
- The one extra agree is
tests/proof/lam_copy_eta.bend. Every other file's output is byte-identical to main.
- main: 1,557 files; 992 agree, 71 u, 491 bend2 rejects, 2 out of scope, 1 false reject (
bendtt.leanalso builds with no errors under the pinned Lean v4.34.0 (the description says v4.34.1).
1. No gate catches a revert
tests/proof/lam_copy_eta.bend prints ALL PROOFS CHECK on main as well, because gates/test.ts runs it without --verdict. Under --verdict, main prints SOME PROOFS FAIL and still exits 0. gates/safe.ts lists that as ! and also exits 0. So reverting the change in Term.parts and Par.lam would leave every gate green. This isn't something to fix in this PR, since the gates are Taelin's, but it's worth knowing that the test documents the fix without guarding it.
2. The paper's subject-reduction paragraph (main.typ, Subject Reduction) now undersells the problem
It says that reduction of open terms does not preserve the live check, and then gives the reason: BendTT evaluates closed terms only. With the new step, a closed term loses the live check too. λ² x. (x, x) is closed and passes the live check, but ⇒ now steps it to λ¹ x. (x, x), which uses a q=1 variable twice. This is still sound, because Progress and the live claims use ↦, which never takes the λ step. The paragraph should say so: parallel reduction may also lose the live check on closed terms, by the λ² ⇒ λ¹ step, and that is harmless because the live claims are about evaluation.
3. The paper's account of the development (main.typ, Confluence) no longer matches Term.dev
"The complete development Term.dev now also sends every λ² to λ¹, which is not a redex. That needs one clause there, for example "and steps every
… it is (bendlang#1189) Rebased onto bendlang#1203. Par steps a λ+ to a λ and never back; Term.parts pairs two λs when their Quan.lin agree (the same as one liveness on Q0/Q1/Q2), so conv_lam closes without a lemma relating .live and .lin. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Proof-only: qmin_eq, conv_typ_enu, closed_app, index_lt, called_iff, walk_total and eval_decreases are inlined into their single uses or were unused; crefl replaces spelled-out reflexive joins; the twin cases of fits_at, at_trans, wnf_pars's fire, ev and gsl share one script. No def, inductive or Claim changes. 63,506 ttok, 4,118 lines. Co-Authored-By: Claude Opus 5.5 <[email protected]>
966c530 to
edac9a6
Compare
… 64k cap Proof-only: every def, inductive and Claim is byte-identical; only the single-use unlhs tactic macro goes. Single-use lemmas are inlined (cmp_size, get_le, good_top, pad_le, ok_let, wnf_fits, conv_lam, takes_sub, value_call, kindof_live, no_kind2, conv_eql, conv_inst, canon_fun); value_form (a closed value has its type's former) replaces canon_pair and fits_former; live_sub, uses_sub, chk's check cases, ev and bud_once share one script across their cases. 3,924 lines; BendTT.pdf rebuilt with the new count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Proof-only: every def, inductive and Claim is byte-identical but RenOk, a predicate only typed_ren used; typed_ren goes, and substok_up proves the weakening it needs locally. snd_wnf2, pars_all, sl_mid, index_key and the uses_spine/spine_unspine pair (now uses_unspine) go; vm_up and bud_up are one lemma; chk's check side covers the scrutinee's wnf once; sr, ev, fits_at and qmin_par/qmin_map share one script across cases. 3,803 lines, build time unchanged (~9.5 s); BendTT.pdf rebuilt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
live_sub, ev, bud_once, qmin_par, qmin_map, fits_all, head_used and pos_ok's Tup case get their per-case proofs from main back, with qmin_eq and sl_mid restored for them: elaboration was ~17% slower than main, now within ~5% (7.5 s vs 7.1 s wall, 17.3 s vs 16.5 s CPU), for 756 ttok (60,457, 3,839 lines). Proof-only; BendTT.pdf rebuilt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… step may lose the live check From the review of bendlang#1224: Confluence now says t* also steps every λ² to λ¹, as Term.dev does, and Subject Reduction says parallel reduction can lose the live check on a closed term too (λ² x. (x, x) ⇒ λ¹ x. (x, x)), harmless since the live claims are about ↦, which never takes that step. BendTT.pdf rebuilt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The 64k ttok cap keeps the file near that size, so the paper no longer needs a rebuild each time a proof changes length. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes #1189. Replaces #1223, which patched
safe.tsinstead.Cause
The kernel's typing and conversion disagree about a λ's quantity:
∀in liveness.Term.checkandTyped.lamaccept aλ+at a q=1∀, plus a Data domain for theλ+.Term.partspaired two λs only whenq = p, andPar.lamkeptq.bend2 is consistent with the typing side. The checked book drops a λ's quantity, and
compare_gocompares λs by η, with no quantity involved.In #1189 this surfaces as follows.
safe.tsemits+a => Nat.add(a, a)asλ+a => …, and the abstractfinsame's type goes out η-long as a plainλx => (f x). Instantiated, that isλx => ({λ+a => … : ∀} x). The kernel stopped atλvsλ+before reducing the redex. bend2 accepts the file.Change (kernel:
bendtt.lean)Quan.lin: sendsQ2toQ1and leaves the others alone. Aλ+copies its argument, which is how it runs, not what it is.Term.parts: pairs two λs whenq.lin = p.lin. On Q0/Q1/Q2 that is the same as one liveness, the test typing,WalkandEvaluse, and it is stated in the same terms asPar.Par.lam: takesp = q ∨ p = q.lin, so aλ+may reduce to aλand never back. That direction keeps subject reduction: theλkeeps its liveness and needs no Data domain.Term.dev: sends each λ to itslin.par_refland thetrianglelemma get one more alternative each.parts_convgets a newconv_lam, andsrgets a one-line λ case.Claimstatement, and evaluation and the live check, which don't usePar.Rebased onto #1203, which had left
bendtt.leanat 63,985 ttok. The rule adds 353, so a second commit shortens proofs elsewhere, with no def, inductive orClaimchanges:qmin_eq,conv_typ_enu,closed_app,index_lt,called_iff,walk_totalandeval_decreaseswere unused or are inlined into their single uses.creflreplaces spelled-out reflexive joins.fits_at,at_trans,wnf_pars's fire,evandgslshare one script.A third commit shortens proofs throughout, to leave room under the cap for later kernel rules. Again, every def, inductive and
Claimis byte-identical; only the single-useunlhstactic macro goes.value_form(a closed value has its type's former) replacescanon_pairandfits_former.live_sub,uses_sub,chk's check cases,evandbud_onceeach share one script across their cases.A fourth commit shortens proofs again (61,151 → 59,701 ttok), with every def, inductive and
Claimbyte-identical exceptRenOk, a predicate onlytyped_renused:typed_rengoes;substok_upproves the weakening it needs locally.snd_wnf2,pars_all,sl_midandindex_keyare inlined.uses_unspinereplacesuses_spineandspine_unspine, andvm_upandbud_upbecome one lemma.chk's check side covers the scrutinee's wnf once, andsr,ev,fits_atandqmin_par/qmin_mapeach share one script across cases.The shared scripts made Lean's check of the file about 17% slower than main, so a fifth commit puts main's per-case proofs back for the slowest ones (
live_sub,ev,bud_once,qmin_par,qmin_map,fits_all,head_used, andpos_ok's Tup case), withqmin_eqandsl_midrestored for them.bendtt.leanends at 60,457 ttok and 3,839 lines, 3,543 under its cap.lean bendtt.leantakes about 7.5 s wall and 17.3 s CPU, against 7.1 s and 16.5 s on main. The compiled kernel's code differs from main only inTerm.parts's λ case.safe.tsis unchanged.The paper's Metatheory ($λ^2$ to $λ^1$ . Its Confluence section says the complete development does that step too. Its Subject Reduction section says this step can lose the live check on a closed term, which is harmless because the live claims are about evaluation, and $↦$ never takes it. Its Mechanization section now says
bend2/docs/BendTT/main.typ) now says that parallel reduction also stepsbendtt.leanis about 4,000 lines instead of giving an exact count.paper/BendTT.pdfis rebuilt from it with typst 0.15.1 (typst compile --root bend2/docs bend2/docs/BendTT/main.typ).An elaborator fix (#1223) has to decide for each λ whether it is a value or part of a def's case tree. At a def root it breaks the case tree: 75 tests regress when that fix drops the distinction. It also misses a curried
+a => +b => …unless it runs at every λ of a value. The kernel rule covers all of these.Checks
lean bendtt.leanbuilds with no errors or warnings under both the pinned v4.34.0 and v4.34.1.#print axiomsforconsistent,sr,confluent,progressandhaltslists onlypropext,Classical.choiceandQuot.sound.tests/proof/lam_copy_eta.bendholds the issue's case and the used-once case. It fails--verdicton main and passes here.--verdictovertests/: run locally on main (1cce4999) and on this branch. Main checks 1,004 of 1,570 files; here 1,005 of 1,571 check, the extra one being the new test, and every other output is byte-identical.do-chain shape from the issue)gates/repo.ts: PASS 50 / 50.gates/test.tsandgates/safe.ts.Review
🤖 Generated with Claude Code