Theorem: Group.card_pow_eq_card_pow_card_univ_aux
File: Mathlib/Data/Set/Pointwise/Basic.lean

Proof steps:
state_before: F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
f : ℕ → ℕ
h1 : Monotone f
B : ℕ
h2 : ∀ (n : ℕ), f n ≤ B
h3 : ∀ (n : ℕ), f n = f (n + 1) → f (n + 1) = f (n + 2)
⊢ ∀ (k : ℕ), B ≤ k → f k = f B
state_after: F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
f : ℕ → ℕ
h1 : Monotone f
B : ℕ
h2 : ∀ (n : ℕ), f n ≤ B
h3 : ∀ (n : ℕ), f n = f (n + 1) → f (n + 1) = f (n + 2)
key : ∃ n ≤ B, f n = f (n + 1)
⊢ ∀ (k : ℕ), B ≤ k → f k = f B
tactic: have key : ∃ n : ℕ, n ≤ B ∧ f n = f (n + 1) := by
    contrapose! h2
    suffices ∀ n : ℕ, n ≤ B + 1 → n ≤ f n by exact ⟨B + 1, this (B + 1) (le_refl (B + 1))⟩
    exact fun n =>
      Nat.rec (fun _ => Nat.zero_le (f 0))
        (fun n ih h =>
          lt_of_le_of_lt (ih (n.le_succ.trans h))
            (lt_of_le_of_ne (h1 n.le_succ) (h2 n (Nat.succ_le_succ_iff.mp h))))
        n
state_before: F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
f : ℕ → ℕ
h1 : Monotone f
B : ℕ
h2 : ∀ (n : ℕ), f n ≤ B
h3 : ∀ (n : ℕ), f n = f (n + 1) → f (n + 1) = f (n + 2)
key : ∃ n ≤ B, f n = f (n + 1)
⊢ ∀ (k : ℕ), B ≤ k → f k = f B
state_after: case intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
f : ℕ → ℕ
h1 : Monotone f
B : ℕ
h2 : ∀ (n : ℕ), f n ≤ B
h3 : ∀ (n : ℕ), f n = f (n + 1) → f (n + 1) = f (n + 2)
n : ℕ
hn1 : n ≤ B
hn2 : f n = f (n + 1)
⊢ ∀ (k : ℕ), B ≤ k → f k = f B
tactic: obtain ⟨n, hn1, hn2⟩ := key
state_before: case intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
f : ℕ → ℕ
h1 : Monotone f
B : ℕ
h2 : ∀ (n : ℕ), f n ≤ B
h3 : ∀ (n : ℕ), f n = f (n + 1) → f (n + 1) = f (n + 2)
n : ℕ
hn1 : n ≤ B
hn2 : f n = f (n + 1)
⊢ ∀ (k : ℕ), B ≤ k → f k = f B
state_after: case intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
f : ℕ → ℕ
h1 : Monotone f
B : ℕ
h2 : ∀ (n : ℕ), f n ≤ B
h3 : ∀ (n : ℕ), f n = f (n + 1) → f (n + 1) = f (n + 2)
n : ℕ
hn1 : n ≤ B
hn2 : f n = f (n + 1)
key : ∀ (k : ℕ), f (n + k) = f (n + k + 1) ∧ f (n + k) = f n
⊢ ∀ (k : ℕ), B ≤ k → f k = f B
tactic: replace key : ∀ k : ℕ, f (n + k) = f (n + k + 1) ∧ f (n + k) = f n := fun k =>
    Nat.rec ⟨hn2, rfl⟩ (fun k ih => ⟨h3 _ ih.1, ih.1.symm.trans ih.2⟩) k
state_before: case intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
f : ℕ → ℕ
h1 : Monotone f
B : ℕ
h2 : ∀ (n : ℕ), f n ≤ B
h3 : ∀ (n : ℕ), f n = f (n + 1) → f (n + 1) = f (n + 2)
n : ℕ
hn1 : n ≤ B
hn2 : f n = f (n + 1)
key : ∀ (k : ℕ), f (n + k) = f (n + k + 1) ∧ f (n + k) = f n
⊢ ∀ (k : ℕ), B ≤ k → f k = f B
state_after: case intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
f : ℕ → ℕ
h1 : Monotone f
B : ℕ
h2 : ∀ (n : ℕ), f n ≤ B
h3 : ∀ (n : ℕ), f n = f (n + 1) → f (n + 1) = f (n + 2)
n : ℕ
hn1 : n ≤ B
hn2 : f n = f (n + 1)
key : ∀ (k : ℕ), n ≤ k → f k = f n
⊢ ∀ (k : ℕ), B ≤ k → f k = f B
tactic: replace key : ∀ k : ℕ, n ≤ k → f k = f n := fun k hk =>
    (congr_arg f (Nat.add_sub_of_le hk)).symm.trans (key (k - n)).2
state_before: case intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
f : ℕ → ℕ
h1 : Monotone f
B : ℕ
h2 : ∀ (n : ℕ), f n ≤ B
h3 : ∀ (n : ℕ), f n = f (n + 1) → f (n + 1) = f (n + 2)
n : ℕ
hn1 : n ≤ B
hn2 : f n = f (n + 1)
key : ∀ (k : ℕ), n ≤ k → f k = f n
⊢ ∀ (k : ℕ), B ≤ k → f k = f B
state_after: no goals
tactic: exact fun k hk => (key k (hn1.trans hk)).trans (key B hn1).symm