Ranges of naturals as lists #
This file shows basic results about list.iota
, list.range
, list.range'
(all defined in
data.list.defs
) and defines list.fin_range
.
fin_range n
is the list of elements of fin n
.
iota n = [1, ..., n]
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.map_add_range'
(a s n : ℕ) :
list.map (has_add.add a) (list.range' s n) = list.range' (a + s) n
theorem
list.map_sub_range'
(a s n : ℕ)
(h : a ≤ s) :
list.map (λ (x : ℕ), x - a) (list.range' s n) = list.range' (s - a) n
theorem
list.chain_succ_range'
(s n : ℕ) :
list.chain (λ (a b : ℕ), b = a.succ) s (list.range' (s + 1) n)
@[simp]
theorem
list.range'_append
(s m n : ℕ) :
list.range' s m ++ list.range' (s + m) n = list.range' s (n + m)
@[simp]
theorem
list.nth_le_range'
{n m : ℕ}
(i : ℕ)
(H : i < (list.range' n m).length) :
(list.range' n m).nth_le i H = n + i
theorem
list.range_core_range'
(s n : ℕ) :
list.range_core s (list.range' s n) = list.range' 0 (n + s)
theorem
list.range'_eq_map_range
(s n : ℕ) :
list.range' s n = list.map (has_add.add s) (list.range n)
theorem
list.range_add
(a b : ℕ) :
list.range (a + b) = list.range a ++ list.map (λ (x : ℕ), a + x) (list.range b)
theorem
list.reverse_range'
(s n : ℕ) :
(list.range' s n).reverse = list.map (λ (i : ℕ), s + n - 1 - i) (list.range n)
All elements of fin n
, from 0
to n-1
.
Equations
- list.fin_range n = list.pmap fin.mk (list.range n) _
@[simp]
theorem
list.fin_range_succ_eq_map
(n : ℕ) :
list.fin_range n.succ = 0 :: list.map fin.succ (list.fin_range n)
theorem
list.prod_range_succ
{α : Type u}
[monoid α]
(f : ℕ → α)
(n : ℕ) :
(list.map f (list.range n.succ)).prod = ((list.map f (list.range n)).prod) * f n
theorem
list.sum_range_succ
{α : Type u}
[add_monoid α]
(f : ℕ → α)
(n : ℕ) :
(list.map f (list.range n.succ)).sum = (list.map f (list.range n)).sum + f n
A variant of sum_range_succ
which pulls off the first term in the sum
rather than the last.
@[simp]
theorem
list.enum_from_map_fst
{α : Type u}
(n : ℕ)
(l : list α) :
list.map prod.fst (list.enum_from n l) = list.range' n l.length
@[simp]
@[simp]
theorem
list.enum_from_eq_zip_range'
{α : Type u}
(l : list α)
{n : ℕ} :
list.enum_from n l = (list.range' n l.length).zip l
@[simp]
theorem
list.unzip_enum_from_eq_prod
{α : Type u}
(l : list α)
{n : ℕ} :
(list.enum_from n l).unzip = (list.range' n l.length, l)
@[simp]
theorem
list.nth_le_range
{n : ℕ}
(i : ℕ)
(H : i < (list.range n).length) :
(list.range n).nth_le i H = i
@[simp]
theorem
list.nth_le_fin_range
{n i : ℕ}
(h : i < (list.fin_range n).length) :
(list.fin_range n).nth_le i h = ⟨i, _⟩
theorem
list.of_fn_eq_pmap
{α : Type u_1}
{n : ℕ}
{f : fin n → α} :
list.of_fn f = list.pmap (λ (i : ℕ) (hi : i < n), f ⟨i, hi⟩) (list.range n) _
theorem
list.of_fn_eq_map
{α : Type u_1}
{n : ℕ}
{f : fin n → α} :
list.of_fn f = list.map f (list.fin_range n)
theorem
list.nodup_of_fn
{α : Type u_1}
{n : ℕ}
{f : fin n → α}
(hf : function.injective f) :
(list.of_fn f).nodup