Repository navigation
BendTT fits ∀s by their parts, as bend2's LE does, so the kernel, not safe.ts, fits Nat -> Kind(&2) to Nat -> Type - #1344
Merged
Conversation
…d, the codomain along, so the kernel, not safe.ts, fits Nat -> Kind(&2) to Nat -> Type bend2's LE compares a function type's domains swapped and its codomain along, so g : Type -> Nat fits Kind(&0) -> Nat and K : Nat -> Kind(&2) fits Nat -> Type. The kernel fitted only at the top, so safe.ts made up for it: a self-call's argument went eta-long where the domains or kinds differed (qsig_eq), and a rewrite went out at its own type (rwt_type). --verdict trusted that bridge. Now the kernel has the rule, and proves it. - Fits is inductive: conversion, kinds, enums, ∀s by their parts (the domain reversed), and a transitivity rule, so fits_trans is the rule. Fits.at and fits_at read a fit at a former, both ways, and give fits_all, fits_conv, fits2 and fits_former, which replace the case analysis of the old disjunction. - Term.fits threads fuel and fits two ∀s of one quantity by their parts; fits_sound proves it. - Subject reduction and progress take the ∀ rule: β casts the argument along the domain fit and the result along the codomain's; a split, a hit and a miss likewise; lab_in reads a label through a fit. - Every claim (consistent, book_check, confluent, sr, progress, halts, empty) checks with no sorry and depends only on [propext, Classical.choice, Quot.sound], with Lean v4.34.0. 63,988 ttok (cap 64,000). - safe.ts: qsig_eq compares binder quantities only, and rwt_type is gone. Hand-written books: the kernel rejects K : <A> -> *1 at <A> -> *2, a ∀(∀ *1 -> <A>) -> <A> at ∀(∀ *2 -> <A>) -> <A>, a function on <A> at <A, B>, and a ∀ at a ∀+; it accepts each fit in the other direction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… parts, the domain reversed, and subject reduction reads a fit at a former - Kinds: function types fit by their parts, as in Bend, so a Nat -> Data fits where a Nat -> Type is expected, and a Type -> Nat where a Data -> Nat is. - Figure 3's caption: U <= T adds the ∀ case and transitivity. - Subject reduction: a fit is inverted at a type former like a conversion, so β casts the argument along the domains' fit and the result along the codomains'. - bendtt.lean is 4,157 lines. paper/BendTT.pdf rebuilt with typst 0.15.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nicolas-abril
force-pushed
the
kernel-all-fits
branch
from
October 5, 2026 12:13
0f0a385 to
daa9295
Compare
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1203 (base:
kernel-kind-terms).Why
bend2's LE goes under a binder. It compares a function type's domains swapped and its codomain along, so:
g : Type -> NatfitsKind(&0) -> Nat;K : Nat -> Kind(&2)fitsNat -> Type;Nat -> Kind(&0)fits aNat -> Typegoal.The kernel fitted only at the top, so on #1203
safe.tsbridged the gap:qsig_eq);rwt_type).--verdicttrusted that bridge, and all three divergences that review found were in it. This moves the rule into the kernel, with proofs, so the kernel decides those fits itself.Kernel (
bend2/bendtt.lean)Fitsis inductive: conversion, kinds (*(g)fits*(h)wheregis.Q2whereverhis, as before), enums (fewer labels),∀q A Bfits∀q C DwhenCfitsAandBfitsD, and transitivity. Transitivity is a rule, so the old nine-wayfits_transis gone.Fits.at/fits_atread a fit at a former, in both directions. IfTconverts to a formerX, thenUconverts to aYthat fitsXpart by part, and the same fromU's side.fits_all,fits_conv,fits2andfits_formerfollow from it. They replace the case analysis of the old disjunction, includingfits_conv's "any non-kind fit converts", which a ∀ rule breaks.Term.fitsthreads fuel, asqgedoes, and fits two∀s of one quantity by their parts.fits_soundproves it.lab_inreads a label through a fit.consistent,book_check,confluent,sr,progress,halts,empty) checks with nosorryunder Lean v4.34.0 (the pinned version) and v4.34.1. Each depends only on[propext, Classical.choice, Quot.sound]. The claim statements are unchanged; the typing judgment they quantify over is now more general.Elaborator (
bend2/safe.ts)qsig_eqcompares binder quantities only, since the kernel's fit still needs them equal.rwt_typeand the annotation it added are gone.Checks
K : <A> -> *1at<A> -> *2;∀(∀ *1 -> <A>) -> <A>at∀(∀ *2 -> <A>) -> <A>; a function on<A>at<A, B>; a∀at a∀+.kind_*,meet_*) pass. Inkind_none_is_type, the self-call now passesK0whole, and the kernel fits∀ Nat -> *(.Q0)to∀ Nat -> *(.Q1)itself; on BendTT: kinds as quantity terms, meets, Σ at any kind and subsumption under ∀; --verdict emits generic defs once #1203 it went out asλx2 => (K0 x2).repoPASS 50 / 50,testPASS 1551 / 1551.perf: the cluster was noisy.mainitself scored 89 / 124 and this branch 49–110 / 124 in back-to-back runs. This branch doesn't touchbend.ts,comp.tsormain.ts, which are all perf measures.pingwas skipped: there is no site repo here.gates/safe.ts testswith this kernel: per file, identical tomain's table plus BendTT: kinds as quantity terms, meets, Σ at any kind and subsumption under ∀; --verdict emits generic defs once #1203's new tests (999 agree, 69 unsafe, 491 bend2 rejects, 2 out of scope, 1 false reject: --verdict: the kernel runs out of fuel on conversion_shared_cells_once.bend, which bend2 checks by sharing (2.0.34) #1193).tsc: the same 12 errors asmain.∀s instead of converting them, and fewer arguments go out η-long.Paper
bend2/docs/BendTT/main.typandpaper/BendTT.pdfgive the∀rule:U <= T, together with transitivity;The Lean line count is now 4,157.
🤖 Generated with Claude Code