Theorem: Nat.Ico_filter_coprime_le
File: Mathlib/Data/Nat/Totient.lean

tactic: conv_lhs => rw [← Nat.mod_add_div n a]
state_before: a k n : ℕ
a_pos : 0 < a
⊢ (filter a.Coprime (Ico k (k + n))).card ≤ φ a * (n / a + 1)
state_after: a k n : ℕ
a_pos : 0 < a
⊢ (filter a.Coprime (Ico k (k + (n % a + a * (n / a))))).card ≤ φ a * (n / a + 1)

tactic: induction' n / a with i ih
state_before: a k n : ℕ
a_pos : 0 < a
⊢ (filter a.Coprime (Ico k (k + (n % a + a * (n / a))))).card ≤ φ a * (n / a + 1)
state_after: case zero
a k n : ℕ
a_pos : 0 < a
⊢ (filter a.Coprime (Ico k (k + (n % a + a * 0)))).card ≤ φ a * (0 + 1)

case succ
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + (n % a + a * i)))).card ≤ φ a * (i + 1)
⊢ (filter a.Coprime (Ico k (k + (n % a + a * (i + 1))))).card ≤ φ a * (i + 1 + 1)

tactic: simp only [mul_succ]
state_before: case succ
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + (n % a + a * i)))).card ≤ φ a * (i + 1)
⊢ (filter a.Coprime (Ico k (k + (n % a + a * (i + 1))))).card ≤ φ a * (i + 1 + 1)
state_after: case succ
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + (n % a + a * i)))).card ≤ φ a * (i + 1)
⊢ (filter a.Coprime (Ico k (k + (n % a + (a * i + a))))).card ≤ φ a * i + φ a + φ a

tactic: simp_rw [← add_assoc] at ih ⊢
state_before: case succ
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + (n % a + a * i)))).card ≤ φ a * (i + 1)
⊢ (filter a.Coprime (Ico k (k + (n % a + (a * i + a))))).card ≤ φ a * i + φ a + φ a
state_after: case succ
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ (filter a.Coprime (Ico k (k + n % a + a * i + a))).card ≤ φ a * i + φ a + φ a

tactic: rw [← filter_coprime_Ico_eq_totient a k]
state_before: case zero
a k n : ℕ
a_pos : 0 < a
⊢ (filter a.Coprime (Ico k (k + (n % a + a * 0)))).card ≤ φ a * (0 + 1)
state_after: case zero
a k n : ℕ
a_pos : 0 < a
⊢ (filter a.Coprime (Ico k (k + (n % a + a * 0)))).card ≤ (filter a.Coprime (Ico k (k + a))).card * (0 + 1)

tactic: simp only [add_zero, mul_one, mul_zero, le_of_lt (mod_lt n a_pos),
  Nat.zero_eq, zero_add]
state_before: case zero
a k n : ℕ
a_pos : 0 < a
⊢ (filter a.Coprime (Ico k (k + (n % a + a * 0)))).card ≤ (filter a.Coprime (Ico k (k + a))).card * (0 + 1)
state_after: case zero
a k n : ℕ
a_pos : 0 < a
⊢ (filter a.Coprime (Ico k (k + n % a))).card ≤ (filter a.Coprime (Ico k (k + a))).card

tactic: gcongr
state_before: case zero
a k n : ℕ
a_pos : 0 < a
⊢ (filter a.Coprime (Ico k (k + n % a))).card ≤ (filter a.Coprime (Ico k (k + a))).card
state_after: case zero.a.h
a k n : ℕ
a_pos : 0 < a
⊢ Ico k (k + n % a) ⊆ Ico k (k + a)

tactic: exact Ico_subset_Ico rfl.le (add_le_add_left (le_of_lt (mod_lt n a_pos)) k)
state_before: case zero.a.h
a k n : ℕ
a_pos : 0 < a
⊢ Ico k (k + n % a) ⊆ Ico k (k + a)
state_after: no goals

tactic: congr
state_before: a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ (filter a.Coprime (Ico k (k + n % a + a * i + a))).card =
    (filter a.Coprime (Ico k (k + n % a + a * i) ∪ Ico (k + n % a + a * i) (k + n % a + a * i + a))).card
state_after: case e_s.e_s
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ Ico k (k + n % a + a * i + a) = Ico k (k + n % a + a * i) ∪ Ico (k + n % a + a * i) (k + n % a + a * i + a)

tactic: rw [Ico_union_Ico_eq_Ico]
state_before: case e_s.e_s
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ Ico k (k + n % a + a * i + a) = Ico k (k + n % a + a * i) ∪ Ico (k + n % a + a * i) (k + n % a + a * i + a)
state_after: case e_s.e_s.hab
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ k ≤ k + n % a + a * i

case e_s.e_s.hbc
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ k + n % a + a * i ≤ k + n % a + a * i + a

tactic: exact le_self_add
state_before: case e_s.e_s.hbc
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ k + n % a + a * i ≤ k + n % a + a * i + a
state_after: no goals

tactic: rw [add_assoc]
state_before: case e_s.e_s.hab
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ k ≤ k + n % a + a * i
state_after: case e_s.e_s.hab
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ k ≤ k + (n % a + a * i)

tactic: exact le_self_add
state_before: case e_s.e_s.hab
a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ k ≤ k + (n % a + a * i)
state_after: no goals

tactic: rw [filter_union, ← filter_coprime_Ico_eq_totient a (k + n % a + a * i)]
state_before: a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ (filter a.Coprime (Ico k (k + n % a + a * i) ∪ Ico (k + n % a + a * i) (k + n % a + a * i + a))).card ≤
    (filter a.Coprime (Ico k (k + n % a + a * i))).card + φ a
state_after: a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ (filter a.Coprime (Ico k (k + n % a + a * i)) ∪
        filter a.Coprime (Ico (k + n % a + a * i) (k + n % a + a * i + a))).card ≤
    (filter a.Coprime (Ico k (k + n % a + a * i))).card +
      (filter a.Coprime (Ico (k + n % a + a * i) (k + n % a + a * i + a))).card

tactic: apply card_union_le
state_before: a k n : ℕ
a_pos : 0 < a
i : ℕ
ih : (filter a.Coprime (Ico k (k + n % a + a * i))).card ≤ φ a * (i + 1)
⊢ (filter a.Coprime (Ico k (k + n % a + a * i)) ∪
        filter a.Coprime (Ico (k + n % a + a * i) (k + n % a + a * i + a))).card ≤
    (filter a.Coprime (Ico k (k + n % a + a * i))).card +
      (filter a.Coprime (Ico (k + n % a + a * i) (k + n % a + a * i + a))).card
state_after: no goals