Ranges of naturals as lists #
This file shows basic results about List.iota
, List.range
, List.range'
and defines List.finRange
.
finRange n
is the list of elements of Fin n
.
iota n = [n, n - 1, ..., 1]
and range n = [0, ..., n - 1]
are basic list constructions used for
tactics. range' a b = [a, ..., a + b - 1]
is there to help prove properties about them.
Actual maths should use List.Ico
instead.
theorem
List.pairwise_lt_range'
(s : ℕ)
(n : ℕ)
(step : optParam ℕ 1)
:
autoParam (0 < step) _auto✝ → List.Pairwise (fun x x_1 => x < x_1) (List.range' s n step)
theorem
List.nodup_range'
(s : ℕ)
(n : ℕ)
(step : optParam ℕ 1)
(h : autoParam (0 < step) _auto✝)
:
List.Nodup (List.range' s n step)
@[simp]
theorem
List.nthLe_range'
{n : ℕ}
{m : ℕ}
{step : ℕ}
(i : ℕ)
(H : i < List.length (List.range' n m step))
:
List.nthLe (List.range' n m step) i H = n + step * i
theorem
List.nthLe_range'_1
{n : ℕ}
{m : ℕ}
(i : ℕ)
(H : i < List.length (List.range' n m))
:
List.nthLe (List.range' n m) i H = n + i
theorem
List.chain'_range_succ
(r : ℕ → ℕ → Prop)
(n : ℕ)
:
List.Chain' r (List.range (Nat.succ n)) ↔ (m : ℕ) → m < n → r m (Nat.succ m)
theorem
List.chain_range_succ
(r : ℕ → ℕ → Prop)
(n : ℕ)
(a : ℕ)
:
List.Chain r a (List.range (Nat.succ n)) ↔ r a 0 ∧ ((m : ℕ) → m < n → r m (Nat.succ m))
All elements of Fin n
, from 0
to n-1
. The corresponding finset is Finset.univ
.
Equations
- List.finRange n = List.pmap Fin.mk (List.range n) (_ : ∀ (x : ℕ), x ∈ List.range n → x < n)
Instances For
theorem
List.pairwise_lt_finRange
(n : ℕ)
:
List.Pairwise (fun x x_1 => x < x_1) (List.finRange n)
theorem
List.sum_range_succ
{α : Type u}
[AddMonoid α]
(f : ℕ → α)
(n : ℕ)
:
List.sum (List.map f (List.range (Nat.succ n))) = List.sum (List.map f (List.range n)) + f n
theorem
List.prod_range_succ
{α : Type u}
[Monoid α]
(f : ℕ → α)
(n : ℕ)
:
List.prod (List.map f (List.range (Nat.succ n))) = List.prod (List.map f (List.range n)) * f n
theorem
List.sum_range_succ'
{α : Type u}
[AddMonoid α]
(f : ℕ → α)
(n : ℕ)
:
List.sum (List.map f (List.range (Nat.succ n))) = f 0 + List.sum (List.map (fun i => f (Nat.succ i)) (List.range n))
A variant of sum_range_succ
which pulls off the first term in the sum rather than the last.
theorem
List.prod_range_succ'
{α : Type u}
[Monoid α]
(f : ℕ → α)
(n : ℕ)
:
List.prod (List.map f (List.range (Nat.succ n))) = f 0 * List.prod (List.map (fun i => f (Nat.succ i)) (List.range n))
A variant of prod_range_succ
which pulls off the first
term in the product rather than the last.
theorem
List.enum_eq_zip_range
{α : Type u}
(l : List α)
:
List.enum l = List.zip (List.range (List.length l)) l
@[simp]
theorem
List.unzip_enum_eq_prod
{α : Type u}
(l : List α)
:
List.unzip (List.enum l) = (List.range (List.length l), l)
theorem
List.enumFrom_eq_zip_range'
{α : Type u}
(l : List α)
{n : ℕ}
:
List.enumFrom n l = List.zip (List.range' n (List.length l)) l
@[simp]
theorem
List.unzip_enumFrom_eq_prod
{α : Type u}
(l : List α)
{n : ℕ}
:
List.unzip (List.enumFrom n l) = (List.range' n (List.length l), l)
@[simp]
theorem
List.nthLe_range
{n : ℕ}
(i : ℕ)
(H : i < List.length (List.range n))
:
List.nthLe (List.range n) i H = i
@[simp]
theorem
List.get_finRange
{n : ℕ}
{i : ℕ}
(h : i < List.length (List.finRange n))
:
List.get (List.finRange n) { val := i, isLt := h } = { val := i, isLt := (_ : i < n) }
@[simp]
theorem
List.finRange_map_get
{α : Type u}
(l : List α)
:
List.map (List.get l) (List.finRange (List.length l)) = l
@[simp]
theorem
List.nthLe_finRange
{n : ℕ}
{i : ℕ}
(h : i < List.length (List.finRange n))
:
List.nthLe (List.finRange n) i h = { val := i, isLt := (_ : i < n) }
@[simp]