Skip to content

feat(pfunctor): identify the adjoint derivative of finite lens reindexing - #481

Draft
dtumad wants to merge 2 commits into
dtumad/tensor-reshape-buffersfrom
dtumad/weighted-lens-euclidean
Draft

dtumad wants to merge 2 commits into
dtumad/tensor-reshape-buffersfrom
dtumad/weighted-lens-euclidean

Conversation

@dtumad

@dtumad dtumad commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

At a fixed shape, a polynomial lens gathers real coordinates by reading the input specified for each output. Lens.euclideanGather bundles this operation as a continuous linear map. Its Fréchet derivative at each labelling is the same gather. For finite direction types at the chosen shape, Lens.fderiv_euclideanGather_adjoint proves that its Hilbert adjoint returns output weights through Lens.bangWMap. The proof uses the additive pairing from #479 and Mathlib’s characterization of the adjoint.

Import PolyFun.PFunctor.Lens.BangW.Euclidean for the public API. The module explicitly re-exports Mathlib’s basic Fréchet derivative lemmas so consumers can recover fderiv from the public HasFDerivAt theorem on Lean 4.36. The optional tree tutorial then proves the derivative for the executable flatten-and-gather function from #480 and identifies each coordinate of the adjoint with a lookup in the prepared buffer. The tree shape and selection are fixed throughout differentiation.

The real-valued regression checks the pairing in both directions gives 244, a repeated input receives 5, an omitted input receives 0, and an empty selection gives the zero adjoint. An independent ordinary-import check also exercised cancellation. The headline proofs use only propext, Classical.choice, and Quot.sound. The full build, lint, test, documentation, consumer and axiom checks passed with ./scripts/validate.sh --lint --test --axioms on Lean 4.36 at dc7108acb2b23d677eb715de25a5ce0c16ae77a0 against #480.

@dtumad
dtumad added this pull request to stack #483 November 17, 2026 23:32
@dtumad
dtumad force-pushed the dtumad/weighted-lens-euclidean branch 2 times, most recently from dc7108a to 3257836 Compare November 18, 2026 00:44
@dtumad
dtumad force-pushed the dtumad/weighted-lens-euclidean branch from 3257836 to 9a3f947 Compare November 25, 2026 21:36
dtumad and others added 2 commits November 25, 2026 15:52
…xing

Bundle coordinate reads as a continuous linear map and use additive
pairing to identify the adjoint with the weighted lens. Relate the result
to the executable tree reshape and its prepared reverse buffer.

Co-Authored-By: Codex <noreply@openai.com>
Import FDeriv.Basic explicitly so that both the adjoint proof and public consumers of the gather derivative retain HasFDerivAt.fderiv.

Co-Authored-By: Codex <noreply@openai.com>
@dtumad
dtumad force-pushed the dtumad/weighted-lens-euclidean branch from 9a3f947 to 9c97b86 Compare November 25, 2026 21:52

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant