Finite intervals of naturals #
This file proves that ℕ
is a LocallyFiniteOrder
and calculates the cardinality of its
intervals as finsets and fintypes.
TODO #
Some lemmas can be generalized using OrderedGroup
, CanonicallyOrderedCommMonoid
or SuccOrder
and subsequently be moved upstream to Order.Interval.Finset
.
Equations
- One or more equations did not get rendered due to their size.
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' (min a b) (max a b + 1 - min a b)), nodup := ⋯ }
theorem
Nat.Ico_succ_right_eq_insert_Ico
{a : ℕ}
{b : ℕ}
(h : a ≤ b)
:
Finset.Ico a (b + 1) = insert b (Finset.Ico a b)
theorem
Nat.Ico_insert_succ_left
{a : ℕ}
{b : ℕ}
(h : a < b)
:
insert a (Finset.Ico a.succ b) = Finset.Ico a b
theorem
Nat.Icc_insert_succ_left
{a : ℕ}
{b : ℕ}
(h : a ≤ b)
:
insert a (Finset.Icc (a + 1) b) = Finset.Icc a b
theorem
Nat.Icc_insert_succ_right
{a : ℕ}
{b : ℕ}
(h : a ≤ b + 1)
:
insert (b + 1) (Finset.Icc a b) = Finset.Icc a (b + 1)
theorem
Nat.image_sub_const_Ico
{a : ℕ}
{b : ℕ}
{c : ℕ}
(h : c ≤ a)
:
Finset.image (fun (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 (fun (x : ℕ) => c - x) (Finset.Ico a b) = Finset.Ico (c + 1 - b) (c + 1 - a)
theorem
Nat.Ico_succ_left_eq_erase_Ico
{a : ℕ}
{b : ℕ}
:
Finset.Ico a.succ b = (Finset.Ico a b).erase a
theorem
Nat.image_Ico_mod
(n : ℕ)
(a : ℕ)
:
Finset.image (fun (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_emod
for the ℤ version.
theorem
Nat.multiset_Ico_map_mod
(n : ℕ)
(a : ℕ)
:
Multiset.map (fun (x : ℕ) => x % a) (Multiset.Ico n (n + a)) = Multiset.range a
theorem
Finset.range_image_pred_top_sub
(n : ℕ)
:
Finset.image (fun (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 (addLeftEmbedding a) (Finset.range b)