Strictly-increasing column-tuple enumeration #
The Cauchy-Binet sum-of-squares formula needs a Mathlib-free enumeration of the
"essentially distinct" column choices: each strictly increasing length-n
selection from Fin m represents one orbit of injective ordered tuples under
the action of permutations of Fin n. The enumeration below builds these
tuples by appending the new largest element, recursing on a bound parameter
that constrains the next entry to be strictly less than bound.
All strictly increasing length-n column tuples in Fin m whose entries
are all < bound. The recursion appends a new largest element c < bound and
recurses on the remaining prefix with the smaller bound c.val.
Equations
Instances For
Enumerate all strictly increasing length-n column selections from Fin m.
This list of orbit representatives drives the Cauchy-Binet grouping argument
that re-folds the ordered-tuple Gram expansion as a sum of squared minors.
Equations
Instances For
Public membership characterization: a column tuple lies in
selectedColumnTuples n m iff it is strictly increasing.
Strictly increasing column tuples induce injective Fin n → Fin m selection
functions, so each enumerated tuple yields an injective columnTupleVectorFn.
Convenience corollary: every column tuple enumerated by selectedColumnTuples
yields an injective column-selection function.
The strictly-increasing column-tuple enumeration has no duplicates.
Canonical sort and orbit factorization for injective column tuples #
For the Cauchy-Binet orbit-grouping argument we need, for every injective
ordered column tuple cols : Vector (Fin m) n, a canonical factorization
cols[i] = (sortInjTuple cols)[(sortInjPerm cols)[i]]
where sortInjTuple cols is strictly increasing (i.e. lives in
selectedColumnTuples n m) and sortInjPerm cols is a permutation of
Fin n (i.e. lives in permutationVectors n). This gives a bijection
between injective columnTupleVectors n m entries and the product
selectedColumnTuples n m × permutationVectors n, which lets the orbit
sum group ordered minors by their canonical sorted column choice.
The implementation is rank-based: sortInjPerm cols i is the number of
columns in cols strictly smaller in value than cols[i]. For any
cols, this is < n because cols[i] is never strictly less than
itself; for injective cols, the rank is moreover a bijection on
Fin n.
Count of indices whose cols-image has strictly smaller Fin.val
than that at i. This is the natural-number form of the rank.
Equations
- Hex.Matrix.columnRankNat cols i = (List.filter (fun (j : Fin n) => decide (↑cols[j] < ↑cols[i])) (List.finRange n)).length
Instances For
The rank is always strictly less than n: index i itself is never
in the filter, so the filter is a strict sublist of finRange n.
Canonical sorting permutation: for each index i, output the rank of
cols[i] (number of strictly smaller positions). For an injective cols
this is genuinely a permutation of Fin n; for a non-injective cols it
is still well-defined but may have repeated values.
Equations
- Hex.Matrix.sortInjPerm cols = Vector.ofFn fun (i : Fin n) => ⟨Hex.Matrix.columnRankNat cols i, ⋯⟩
Instances For
The i-th value of the sorting permutation is the rank columnRankNat cols i
of cols[i] (the number of strictly smaller positions).
The canonical sorted version of cols: read cols through the inverse
of sortInjPerm. For an injective cols this is strictly increasing; for
a non-injective cols the value is well-defined but not meaningful.
Equations
- Hex.Matrix.sortInjTuple cols = Vector.ofFn fun (r : Fin n) => cols[(Hex.Matrix.inversePermutationVector (Hex.Matrix.sortInjPerm cols))[r]]
Instances For
For an injective cols, sortInjPerm cols ∈ permutationVectors n.
Every length-n tuple of column indices appears in
columnTupleVectors n m.
Factorization equation: each entry of cols is recovered through the
canonical sort/permutation pair. Requires injectivity of cols.
For an injective cols, the canonical sorted tuple is strictly
increasing.
For an injective cols, the canonical sorted tuple is enumerated by
selectedColumnTuples n m.
Forward injectivity of the sort/permutation pair #
Pairwise distinctness: two injective column tuples that map to the
same (sortInjTuple, sortInjPerm) pair must be equal.
Reconstruction from selectedColumnTuples × permutationVectors #
For a strictly-increasing sel and a permutation perm, the
"reconstruction" Vector.ofFn (fun i => sel[perm[i]]) is itself
injective, and its canonical sort/permutation pair recovers
(sel, perm). This is the inverse map of sortInjTuple/sortInjPerm.
Reconstruction map: given a sorted choice and a permutation, build an ordered column tuple.
Equations
- Hex.Matrix.reconstructInjTuple sel perm = Vector.ofFn fun (i : Fin n) => sel[perm[i]]
Instances For
Selecting columns via the reconstructed tuple equals selecting via sel
with the column index permuted by perm: entry (r, c) agrees with entry
(r, perm[c]) of the sel-selected minor.
Reconstructing an injective tuple from a selected tuple and a permutation turns the coefficient product into the corresponding determinant product.
The reconstructed column tuple is itself injective when sel is
strictly increasing and perm is a permutation.
sortInjPerm of a reconstructed tuple recovers the original permutation.
sortInjTuple of a reconstructed tuple recovers the original selection.
Bijection wrappers #
Forward-then-backward identity: reconstruction inverts the canonical sort/permutation pair on injective column tuples.
The flat list of reconstructed column tuples, indexed by
selectedColumnTuples × permutationVectors, has no duplicates.
A column tuple is injective iff it is enumerated by the
selectedColumnTuples × permutationVectors reconstruction. This is the
bijection statement in membership form.
Refold the ordered column-tuple Gram expansion over the canonical
selectedColumnTuples × permutationVectors reconstruction list. Non-injective
ordered tuples contribute zero determinants, and the remaining injective tuples
are exactly the reconstructed selected/permutation tuples.
Cauchy-Binet for the row Gram matrix: the Gram determinant is the finite sum of squares of the selected column minors.
Integer row Gram determinants are nonnegative, by Cauchy-Binet as a finite sum of integer squares.
The identity selection of the first k columns of an n-column matrix.
Equations
- Hex.Matrix.firstColumns k n hk = Vector.ofFn fun (i : Fin k) => ⟨↑i, ⋯⟩
Instances For
The first k columns form a strictly increasing selected column tuple.
Selecting the first k columns from the leading k rows of a square
matrix gives exactly its leading k × k prefix.
The Gram determinant of the first k rows of a positive-diagonal integer
upper-triangular matrix is strictly positive. The leading-principal minor
provides a positive square term in the Cauchy-Binet expansion.