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, CanonicallyOrderedMul or SuccOrder
and subsequently be moved upstream to Order.Interval.Finset.
@[implicit_reducible]
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 := ⋯ }
@[simp]
@[simp]
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_right_eq_insert_Ico
{a b : ℕ}
(h : a ≤ b)
:
Finset.Ico a b.succ = insert b (Finset.Ico a b)
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_add_eq_union
(a b : ℕ)
:
range (a + b) = range a ∪ map (addLeftEmbedding a) (range b)
theorem
Nat.strong_decreasing_induction
{P : ℕ → Prop}
(base : ∃ (n : ℕ), ∀ m > n, P m)
(step : ∀ (n : ℕ), (∀ m > n, P m) → P n)
(n : ℕ)
:
P n
theorem
Nat.cauchy_induction'
{P : ℕ → Prop}
(seed : ℕ)
(h : ∀ (n : ℕ), P (n + 1) → P n)
(hs : P seed)
(hi : ∀ (x : ℕ), seed ≤ x → P x → ∃ (y : ℕ), x < y ∧ P y)
(n : ℕ)
:
P n
theorem
Nat.cauchy_induction
{P : ℕ → Prop}
(h : ∀ (n : ℕ), P (n + 1) → P n)
(seed : ℕ)
(hs : P seed)
(f : ℕ → ℕ)
(hf : ∀ (x : ℕ), seed ≤ x → P x → x < f x ∧ P (f x))
(n : ℕ)
:
P n
theorem
Nat.cauchy_induction_mul
{P : ℕ → Prop}
(h : ∀ (n : ℕ), P (n + 1) → P n)
(k seed : ℕ)
(hk : 1 < k)
(hs : P seed.succ)
(hm : ∀ (x : ℕ), seed < x → P x → P (k * x))
(n : ℕ)
:
P n
theorem
Nat.cauchy_induction_two_mul
{P : ℕ → Prop}
(h : ∀ (n : ℕ), P (n + 1) → P n)
(seed : ℕ)
(hs : P seed.succ)
(hm : ∀ (x : ℕ), seed < x → P x → P (2 * x))
(n : ℕ)
:
P n