Antidiagonals in ℕ × ℕ as lists #
This file defines the antidiagonals of ℕ × ℕ as lists: the n
-th antidiagonal is the list of
pairs (i, j)
such that i + j = n
. This is useful for polynomial multiplication and more
generally for sums going from 0
to n
.
Notes #
Files Data.Multiset.NatAntidiagonal
and Data.Finset.NatAntidiagonal
successively turn the
List
definition we have here into Multiset
and Finset
.
The antidiagonal of a natural number n
is the list of pairs (i, j)
such that i + j = n
.
Equations
- List.Nat.antidiagonal n = List.map (fun i => (i, n - i)) (List.range (n + 1))
Instances For
@[simp]
The length of the antidiagonal of n
is n + 1
.
@[simp]
The antidiagonal of 0
is the list [(0, 0)]
The antidiagonal of n
does not contain duplicate entries.
@[simp]
theorem
List.Nat.antidiagonal_succ
{n : ℕ}
:
List.Nat.antidiagonal (n + 1) = (0, n + 1) :: List.map (Prod.map Nat.succ id) (List.Nat.antidiagonal n)
theorem
List.Nat.antidiagonal_succ'
{n : ℕ}
:
List.Nat.antidiagonal (n + 1) = List.map (Prod.map id Nat.succ) (List.Nat.antidiagonal n) ++ [(n + 1, 0)]
theorem
List.Nat.map_swap_antidiagonal
{n : ℕ}
:
List.map Prod.swap (List.Nat.antidiagonal n) = List.reverse (List.Nat.antidiagonal n)