Repository navigation
Conversation
This was referenced Nov 26, 2026
Build handlers with `toFun`, apply them through a function coercion, and state their constructions through application equations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dtumad
force-pushed
the
dtumad/handler-structure
branch
from
November 26, 2026 01:57
b7596cf to
0bc4e32
Compare
This branch has not been deployed
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.
PFunctor.Handlerwas a reducible function type, so instance search looked through it: an instance stated for handlers would also apply to every function of the same shape. That is whyHandler.sumhad no+. It is now a structure with the single fieldtoFun : (a : q.A) → m (q.B a), andf + gis an instance forHandler.sumthat leaves pointwise addition of functions alone.h a, throughCoeFunwith the projection registered as a coercion), so code that runs handlers, including CSLib'sFreeM.liftM h, is unchanged. A function does not coerce to a handler: write⟨f⟩orwhere toFun a := ….Handler.equivFunis the equivalence with functions.PolyFunTest/ModuleAPI/HandlerCoercion.leanfixes which coercions elaborate and which do not, that application lemmas fire at abstract and literal interfaces, how+behaves on handlers and on functions, and that kernel comparison does not reduce a handler's answers.@[simps](CacheMeter'scacheuses-isSimp: its equation leaves amatchon the cache lookup, and proofs userun_apply_of_dlookup_eq_someand_noneinstead). Unfolding a handler instead makessimptraverse its body at every occurrence. Equalities of handlers useext.handlerApplyreports a handler built by the constructor that is reducible or has no application lemma; equation lemmas Lean derives from the definition do not count.handlerApplyFortakes a list of structures, so a library with its own handler structure can register it.PolyFunTest/Lint/HandlerApply.leanhas a control for each case.Migration. Wrap the function (
⟨f⟩), replacefunexton handlers withext a : 1, and namefoo_applywhere a proof unfoldedfoo. Signatures that took a raw answer function for a handler (Display,Wiring) take aHandler.This is the first of a stack of three draft PRs: VCVio Verified-zkEVM/VCVio#1241 makes
QueryImpla structure on top of this one, and ArkLib Verified-zkEVM/ArkLib#1604 ports a large downstream user to both. Its design record, with timings and what the ports exposed, is VCVio'sdocs/design/handler-structure.md.Based on
6aded150. At the head (0bc4e329),./scripts/validate.sh --lint --test --axiomspassed andhandlerApplyreports nothing onPolyFun. The linter test's control for derived equation lemmas fails without the fix it guards.