Theorem: primorial_le_4_pow
File: Mathlib/NumberTheory/Primorial.lean

tactic: induction' n using Nat.strong_induction_on with n ihn
state_before: n : ℕ
⊢ n# ≤ 4 ^ n
state_after: case h
n : ℕ
ihn : ∀ m < n, m# ≤ 4 ^ m
⊢ n# ≤ 4 ^ n

tactic: cases' n with n
state_before: case h
n : ℕ
ihn : ∀ m < n, m# ≤ 4 ^ m
⊢ n# ≤ 4 ^ n
state_after: case h.zero
ihn : ∀ m < 0, m# ≤ 4 ^ m
⊢ 0# ≤ 4 ^ 0

case h.succ
n : ℕ
ihn : ∀ m < n + 1, m# ≤ 4 ^ m
⊢ (n + 1)# ≤ 4 ^ (n + 1)

tactic: rcases n.even_or_odd with (⟨m, rfl⟩ | ho)
state_before: case h.succ
n : ℕ
ihn : ∀ m < n + 1, m# ≤ 4 ^ m
⊢ (n + 1)# ≤ 4 ^ (n + 1)
state_after: case h.succ.inl.intro
m : ℕ
ihn : ∀ m_1 < m + m + 1, m_1# ≤ 4 ^ m_1
⊢ (m + m + 1)# ≤ 4 ^ (m + m + 1)

case h.succ.inr
n : ℕ
ihn : ∀ m < n + 1, m# ≤ 4 ^ m
ho : Odd n
⊢ (n + 1)# ≤ 4 ^ (n + 1)

tactic: rfl
state_before: case h.zero
ihn : ∀ m < 0, m# ≤ 4 ^ m
⊢ 0# ≤ 4 ^ 0
state_after: no goals

tactic: rcases m.eq_zero_or_pos with (rfl | hm)
state_before: case h.succ.inl.intro
m : ℕ
ihn : ∀ m_1 < m + m + 1, m_1# ≤ 4 ^ m_1
⊢ (m + m + 1)# ≤ 4 ^ (m + m + 1)
state_after: case h.succ.inl.intro.inl
ihn : ∀ m < 0 + 0 + 1, m# ≤ 4 ^ m
⊢ (0 + 0 + 1)# ≤ 4 ^ (0 + 0 + 1)

case h.succ.inl.intro.inr
m : ℕ
ihn : ∀ m_1 < m + m + 1, m_1# ≤ 4 ^ m_1
hm : m > 0
⊢ (m + m + 1)# ≤ 4 ^ (m + m + 1)

tactic: calc
  (m + m + 1)# = (m + 1 + m)# := by rw [add_right_comm]
  _ ≤ (m + 1)# * choose (m + 1 + m) (m + 1) := primorial_add_le m.le_succ
  _ = (m + 1)# * choose (2 * m + 1) m := by rw [choose_symm_add, two_mul, add_right_comm]
  _ ≤ 4 ^ (m + 1) * 4 ^ m :=
    mul_le_mul' (ihn _ <| succ_lt_succ <| (lt_add_iff_pos_left _).2 hm) (choose_middle_le_pow _)
  _ ≤ 4 ^ (m + m + 1) := by rw [← pow_add, add_right_comm]
state_before: case h.succ.inl.intro.inr
m : ℕ
ihn : ∀ m_1 < m + m + 1, m_1# ≤ 4 ^ m_1
hm : m > 0
⊢ (m + m + 1)# ≤ 4 ^ (m + m + 1)
state_after: no goals

tactic: decide
state_before: case h.succ.inl.intro.inl
ihn : ∀ m < 0 + 0 + 1, m# ≤ 4 ^ m
⊢ (0 + 0 + 1)# ≤ 4 ^ (0 + 0 + 1)
state_after: no goals

tactic: rw [add_right_comm]
state_before: m : ℕ
ihn : ∀ m_1 < m + m + 1, m_1# ≤ 4 ^ m_1
hm : m > 0
⊢ (m + m + 1)# = (m + 1 + m)#
state_after: no goals

tactic: rw [choose_symm_add, two_mul, add_right_comm]
state_before: m : ℕ
ihn : ∀ m_1 < m + m + 1, m_1# ≤ 4 ^ m_1
hm : m > 0
⊢ (m + 1)# * (m + 1 + m).choose (m + 1) = (m + 1)# * (2 * m + 1).choose m
state_after: no goals

tactic: rw [← pow_add, add_right_comm]
state_before: m : ℕ
ihn : ∀ m_1 < m + m + 1, m_1# ≤ 4 ^ m_1
hm : m > 0
⊢ 4 ^ (m + 1) * 4 ^ m ≤ 4 ^ (m + m + 1)
state_after: no goals

tactic: rcases Decidable.eq_or_ne n 1 with (rfl | hn)
state_before: case h.succ.inr
n : ℕ
ihn : ∀ m < n + 1, m# ≤ 4 ^ m
ho : Odd n
⊢ (n + 1)# ≤ 4 ^ (n + 1)
state_after: case h.succ.inr.inl
ihn : ∀ m < 1 + 1, m# ≤ 4 ^ m
ho : Odd 1
⊢ (1 + 1)# ≤ 4 ^ (1 + 1)

case h.succ.inr.inr
n : ℕ
ihn : ∀ m < n + 1, m# ≤ 4 ^ m
ho : Odd n
hn : n ≠ 1
⊢ (n + 1)# ≤ 4 ^ (n + 1)

tactic: decide
state_before: case h.succ.inr.inl
ihn : ∀ m < 1 + 1, m# ≤ 4 ^ m
ho : Odd 1
⊢ (1 + 1)# ≤ 4 ^ (1 + 1)
state_after: no goals

tactic: calc
  (n + 1)# = n# := primorial_succ hn ho
  _ ≤ 4 ^ n := ihn n n.lt_succ_self
  _ ≤ 4 ^ (n + 1) := pow_le_pow_of_le_right four_pos n.le_succ
state_before: case h.succ.inr.inr
n : ℕ
ihn : ∀ m < n + 1, m# ≤ 4 ^ m
ho : Odd n
hn : n ≠ 1
⊢ (n + 1)# ≤ 4 ^ (n + 1)
state_after: no goals