Finite intervals of naturals #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file proves that ℕ
is a locally_finite_order
and calculates the cardinality of its
intervals as finsets and fintypes.
TODO #
Some lemmas can be generalized using ordered_group
, canonically_ordered_monoid
or succ_order
and subsequently be moved upstream to data.finset.locally_finite
.
@[protected, instance]
Equations
- nat.locally_finite_order = {finset_Icc := λ (a b : ℕ), {val := ↑(list.range' a (b + 1 - a)), nodup := _}, finset_Ico := λ (a b : ℕ), {val := ↑(list.range' a (b - a)), nodup := _}, finset_Ioc := λ (a b : ℕ), {val := ↑(list.range' (a + 1) (b - a)), nodup := _}, finset_Ioo := λ (a b : ℕ), {val := ↑(list.range' (a + 1) (b - a - 1)), nodup := _}, finset_mem_Icc := nat.locally_finite_order._proof_5, finset_mem_Ico := nat.locally_finite_order._proof_6, finset_mem_Ioc := nat.locally_finite_order._proof_7, finset_mem_Ioo := nat.locally_finite_order._proof_8}
theorem
nat.Icc_eq_range'
(a b : ℕ) :
finset.Icc a b = {val := ↑(list.range' a (b + 1 - a)), nodup := _}
theorem
nat.Ico_eq_range'
(a b : ℕ) :
finset.Ico a b = {val := ↑(list.range' a (b - a)), nodup := _}
theorem
nat.Ioc_eq_range'
(a b : ℕ) :
finset.Ioc a b = {val := ↑(list.range' (a + 1) (b - a)), nodup := _}
theorem
nat.Ioo_eq_range'
(a b : ℕ) :
finset.Ioo a b = {val := ↑(list.range' (a + 1) (b - a - 1)), nodup := _}
theorem
nat.uIcc_eq_range'
(a b : ℕ) :
finset.uIcc a b = {val := ↑(list.range' (linear_order.min a b) (linear_order.max a b + 1 - linear_order.min a b)), nodup := _}
theorem
nat.Ico_succ_right_eq_insert_Ico
{a b : ℕ}
(h : a ≤ b) :
finset.Ico a (b + 1) = has_insert.insert b (finset.Ico a b)
theorem
nat.Ico_insert_succ_left
{a b : ℕ}
(h : a < b) :
has_insert.insert a (finset.Ico a.succ b) = finset.Ico a b
theorem
nat.image_sub_const_Ico
{a b c : ℕ}
(h : c ≤ a) :
finset.image (λ (x : ℕ), x - c) (finset.Ico a b) = finset.Ico (a - c) (b - c)
theorem
nat.Ico_image_const_sub_eq_Ico
{a b c : ℕ}
(hac : a ≤ c) :
finset.image (λ (x : ℕ), c - x) (finset.Ico a b) = finset.Ico (c + 1 - b) (c + 1 - a)
theorem
nat.image_Ico_mod
(n a : ℕ) :
finset.image (λ (_x : ℕ), _x % a) (finset.Ico n (n + a)) = finset.range a
Note that while this lemma cannot be easily generalized to a type class, it holds for ℤ as
well. See int.image_Ico_mod
for the ℤ version.
theorem
nat.multiset_Ico_map_mod
(n a : ℕ) :
multiset.map (λ (_x : ℕ), _x % a) (multiset.Ico n (n + a)) = multiset.range a
theorem
finset.range_image_pred_top_sub
(n : ℕ) :
finset.image (λ (j : ℕ), n - 1 - j) (finset.range n) = finset.range n
theorem
finset.range_add_eq_union
(a b : ℕ) :
finset.range (a + b) = finset.range a ∪ finset.map (add_left_embedding a) (finset.range b)