Repository navigation
Conversation
This was referenced Nov 26, 2026
🤖 PR Summary
Refactor: make QueryImpl a one-field structure Statistics
Lean Declarations ✏️ Removed: 6 declaration(s)
✏️ Added: 19 declaration(s)
✏️ Affected: 233 declaration(s) (line number changed)
Coverage Notes
Last updated: 2026-11-26 03:04 UTC. |
PolyFun makes lens properties classes, so `toLens_isCartesian` becomes an instance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`QueryImpl spec m` was a reducible function type, so instances stated for handlers, such as the `HAdd` of handler sums, were also found for ordinary functions. It is now a structure with the field `toFun`. A handler coerces to its answer function; a function does not coerce to a handler. Handlers built by the constructor are used through application equations generated by `@[simps]` (`-isSimp` where the equation competes with a preferred lemma or leaves a `match` on a variable), and equalities of handlers use `ext`. The environment linter `queryImplApply` instantiates PolyFun's `handlerApplyFor` for `QueryImpl`. `QueryImpl.liftTarget_self` becomes a simp lemma, as PolyFun's is. PolyFun is pinned to the commit of its matching change on a fork. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dtumad
force-pushed
the
dtumad/handler-structure
branch
from
November 26, 2026 02:01
0bab251 to
12d7444
Compare
Describe the change, how handlers are used and checked, local cost measurements, and what porting VCVio, PolyFun and ArkLib exposed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dtumad
force-pushed
the
dtumad/handler-structure
branch
from
November 26, 2026 02:49
12d7444 to
87925ee
Compare
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.
Summary
QueryImpl spec mwas a reducible function type, so instance search looked through it. An instance stated for handlers was also found for ordinary functions of that shape: theHAddfor handler sums applied to them too. It is now a structure with the single fieldtoFun : (x : spec.Domain) → m (spec.Range x).impl xandimpl₁ + impl₂read as before. A handler coerces to its answer function. A function does not coerce to a handler: writewhere toFun x := …,⟨fun x => …⟩or a combinator.impl.toHandlerandQueryImpl.ofHandlerconvert to and from PolyFun'sHandler, which the parent PR also makes a structure.@[simps];@[simps -isSimp]is kept for those whose equation competes with a preferred lemma or leaves amatchon a variable. Equalities of handlers useextinstead offunext.handlerApply(PolyFun) andqueryImplApplyreport a constructor-built handler with no application lemma, or one that is reducible.simptraverses its whole body at each occurrence; a first version that did so was markedly slower where proofs unfold handlers.CSLib's
FreeM.liftMstill takes a raw function, and a handler coerces to it.docs/agents/oracle-comp.mddescribes the pattern anddocs/agents/module-system.mdsays when a type should be an abbreviation and when a structure.The first commit only bumps PolyFun to
6aded150on itsmain(lens properties became classes, sotoLens_isCartesianis now an instance); the second contains the change; the third adds the design record.Stack. PolyFun (parent): Verified-zkEVM/PolyFun#534. This PR pins PolyFun to that PR's commit on a fork, so it cannot merge until the parent does and the pin moves. ArkLib (consumer): Verified-zkEVM/ArkLib#1604. #1111 gives handler sums a notation of their own for the same instance leak; the two are independent alternatives for that part, and #1111 is untouched here.
Cost. Local, with
lean -j1per module against the first commit: the 810VCVio/modules take 1649 s against 1655 s (0.997×). Four modules were 1.27–1.84× slower because their proofs unfolded handlers insimp; naming the application lemmas brought them to 1.00–1.05×. The first CI build took 1.47× the module time ofmain's nightly clean build, but modules the change cannot affect (Cslib,ToMathlib,Extern) were 1.3–1.65× slower too, so the two runners differed in speed; the comparison is consistent with a change within about 10% and does not measure it more closely. Details are indocs/design/handler-structure.md, which also lists what the ports exposed.Verification
Based on
84928e95c. At the head (12d744443):./scripts/validate.sh --lint --test --axiomspassed, including the build of the six proof libraries within the warning budget, boundary and import checks,initsweep, style and environment lint, the agent-docs and doc-name checks,lake test, andaxiomsweep --check(34,424 declarations, no taint).queryImplApplyandhandlerApplyreport nothing on all six libraries. CI runs them on theVCVioroot only, since the other roots do not import the linter.Checklist
public sectionwith per-declaration@[expose]../scripts/update-lib.shleaves the umbrella files unchanged, andlake exe axiomsweep --checkpasses.set_option linter.* false, no deprecated aliases, and no native FFI test executables on the PR path.check-agent-docs.pypasses.QueryImpl.liftTarget_selfbecomes a simp lemma, matching PolyFun's.