Fold and reduction lemmas for dependent tensors.
This module packages the algebra needed to reason about tensor reductions, finite sums, and shape-indexed traversals. The finite-sum and associativity results concern exact real arithmetic; they do not permit reassociating a floating-point reduction.
Elementwise multiplication is associative (mulSpec is pointwise (*)).
Elementwise multiplication is commutative (mulSpec is pointwise (*)).
Elementwise addition is commutative (addSpec is pointwise (+)).
Real dot product and fold bridges #
Real dot product for same-shape tensors, defined as the sum of elementwise products.
This matches the common PyTorch idiom (a * b).sum() for same-shape tensors.
Citations:
https://pytorch.org/docs/stable/generated/torch.sum.html
This is the Spec-namespace dot product used by real-analysis proofs. The backend-generic
recursive dot product is Proofs.TensorAlgebra.dot.
Instances For
Peel one slice from the proof-facing fold starting at k, when k < n.
Starting the proof-facing slice fold at or beyond its length returns the accumulator.
Coordinate formula for matMulSpec (matrix-matrix multiplication).
This is the coordinate identity (A @ B)[i,j] = ∑ k, A[i,k] * B[k,j], matching the
textbook/PyTorch view of matrix multiplication.
Citations: https://pytorch.org/docs/stable/generated/torch.matmul.html
A packed-buffer sum is the finite sum of the tensor's coordinate observations.
Sum over the outer dimension unfolds into a Finset.univ sum of inner sumSpec.
This is the tensor analogue of torch.sum reducing over a leading dimension.
The packed real sum-of-products agrees with the generic shape-recursive dot product.
This bridge allows real-analysis proofs to reuse generic dot-product algebra. The equality uses exact addition; the two groupings need not agree for a rounded scalar model.