BackwardDot #
Conv2D backward dot-level correctness (bridge lemma).
The runtime autograd engine (NN.Runtime.Autograd.Engine) computes Conv2D gradients via the
handwritten spec:
Spec.conv2d_backward_spec(kernel/bias/input)
For the analytic spec-level theorem over ℝ, Conv2D is already covered via fderiv/adjoints in:
That file provides a proof-only Conv2D node whose VJP is (fderiv forward)†, so any DAG using it
is covered by the global theorem Graph.backpropVec_eq_adjoint_fderiv.
What remains here is the dot/adjointness bridge:
dot (JVP_conv2d …) δ = dot dKernel gK + dot dBias gB + dot dInput gX
where (gK, gB, gX) = Spec.conv2d_backward_spec … δ.
The padding-related rewrites needed for the input-gradient proof are factored into:
NN/Spec/Layers/Utils.lean(get_at_or_zero_pad_multi_channel*lemmas)
Broadcast a bias gradient outC across spatial axes into an outC×outH×outW tensor.
Instances For
paddedInput matches the forward spec’s padding convention:
- if
padding = 0, it is just a shape cast; and - otherwise it is
pad_multi_channel.
PyTorch analogue: torch.nn.functional.pad (or implicit padding inside conv2d).
https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
https://pytorch.org/docs/stable/generated/torch.nn.functional.conv2d.html
Instances For
Output shape helpers (no dilation): these are the standard “convolution arithmetic” formulas. They are kept as definitions so later statements can share the same expression.
Output width helper (no dilation).
Instances For
Main dot-level bridge theorem for Conv2D.
It states that the triple returned by Spec.conv2d_backward_spec is the adjoint (w.r.t. Spec.dot)
of the corresponding forward-mode directional derivatives with respect to (kernel, bias, input).
This is the key lemma connecting the handwritten runtime backward to the analytic “VJP is adjoint
of fderiv” theorem in NN.Proofs.Autograd.Tape.Ops.Conv.FDeriv.