Fold and reduction lemmas for dependent tensors.
This module packages the algebra needed to reason about tensor reductions, finite sums, and shape-indexed traversals.
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
One-step unfolding of the internal tail-recursive helper tensor_foldl_spec.go when the loop
condition holds (k < n).
This lemma is a proof tool: it lets proofs peel one loop step without using unfold directly.
One-step unfolding of the internal tail-recursive helper tensor_foldl_spec.go when the loop
condition fails (¬ k < n), i.e. the loop terminates and returns the accumulator.
Accumulator lemma for tensor_foldl_spec specialized to addition.
Informally: folding with (+) over a tensor adds sum_spec t to the initial accumulator.
This is frequently used to move between “fold-style” specs and “sum-style” algebra.
Unfolding lemma for get2 (2D tensor indexing).
Coordinate formula for mat_vec_mul_spec, converted from the spec's List.finRange fold to a
Finset.univ.sum.
This is the “PyTorch-looking” statement of matvec: each output entry is a dot product of the corresponding row with the input vector.
Coordinate formula for mat_mul_spec (matrix-matrix multiplication).
This is the standard triple-sum 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
The real-analysis Spec.dot agrees with the backend-generic recursive dot.
Spec.dot is defined as sumSpec (mulSpec a b), which is the proof-facing version of the
PyTorch idiom (a * b).sum(). Proofs.TensorAlgebra.dot is recursive over the tensor shape so it
works over arbitrary semiring-like scalar models. This bridge lets real proofs reuse generic
algebra instead of repeating finite-sum rearrangements.