Theorem: Nat.primeCounting'_add_le
File: Mathlib/NumberTheory/PrimeCounting.lean

tactic: rw [primeCounting', count_eq_card_filter_range, range_eq_Ico, ←
  Ico_union_Ico_eq_Ico (zero_le k) le_self_add, filter_union]
state_before: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ π' (k + n) ≤ (filter Prime (range k)).card + (filter Prime (Ico k (k + n))).card
state_after: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ (filter Prime (Ico 0 k) ∪ filter Prime (Ico k (k + n))).card ≤
    (filter Prime (Ico 0 k)).card + (filter Prime (Ico k (k + n))).card

tactic: apply card_union_le
state_before: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ (filter Prime (Ico 0 k) ∪ filter Prime (Ico k (k + n))).card ≤
    (filter Prime (Ico 0 k)).card + (filter Prime (Ico k (k + n))).card
state_after: no goals

tactic: rw [primeCounting', count_eq_card_filter_range]
state_before: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ (filter Prime (range k)).card + (filter Prime (Ico k (k + n))).card ≤ π' k + (filter Prime (Ico k (k + n))).card
state_after: no goals

tactic: refine add_le_add_left (card_le_card ?_) k.primeCounting'
state_before: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ π' k + (filter Prime (Ico k (k + n))).card ≤ π' k + (filter a.Coprime (Ico k (k + n))).card
state_after: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ filter Prime (Ico k (k + n)) ⊆ filter a.Coprime (Ico k (k + n))

tactic: simp only [subset_iff, and_imp, mem_filter, mem_Ico]
state_before: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ filter Prime (Ico k (k + n)) ⊆ filter a.Coprime (Ico k (k + n))
state_after: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ ∀ ⦃x : ℕ⦄, k ≤ x → x < k + n → Prime x → (k ≤ x ∧ x < k + n) ∧ a.Coprime x

tactic: intro p succ_k_le_p p_lt_n p_prime
state_before: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ ∀ ⦃x : ℕ⦄, k ≤ x → x < k + n → Prime x → (k ≤ x ∧ x < k + n) ∧ a.Coprime x
state_after: a k : ℕ
h0 : 0 < a
h1 : a < k
n p : ℕ
succ_k_le_p : k ≤ p
p_lt_n : p < k + n
p_prime : Prime p
⊢ (k ≤ p ∧ p < k + n) ∧ a.Coprime p

tactic: constructor
state_before: a k : ℕ
h0 : 0 < a
h1 : a < k
n p : ℕ
succ_k_le_p : k ≤ p
p_lt_n : p < k + n
p_prime : Prime p
⊢ (k ≤ p ∧ p < k + n) ∧ a.Coprime p
state_after: case left
a k : ℕ
h0 : 0 < a
h1 : a < k
n p : ℕ
succ_k_le_p : k ≤ p
p_lt_n : p < k + n
p_prime : Prime p
⊢ k ≤ p ∧ p < k + n

case right
a k : ℕ
h0 : 0 < a
h1 : a < k
n p : ℕ
succ_k_le_p : k ≤ p
p_lt_n : p < k + n
p_prime : Prime p
⊢ a.Coprime p

tactic: exact ⟨succ_k_le_p, p_lt_n⟩
state_before: case left
a k : ℕ
h0 : 0 < a
h1 : a < k
n p : ℕ
succ_k_le_p : k ≤ p
p_lt_n : p < k + n
p_prime : Prime p
⊢ k ≤ p ∧ p < k + n
state_after: no goals

tactic: rw [coprime_comm]
state_before: case right
a k : ℕ
h0 : 0 < a
h1 : a < k
n p : ℕ
succ_k_le_p : k ≤ p
p_lt_n : p < k + n
p_prime : Prime p
⊢ a.Coprime p
state_after: case right
a k : ℕ
h0 : 0 < a
h1 : a < k
n p : ℕ
succ_k_le_p : k ≤ p
p_lt_n : p < k + n
p_prime : Prime p
⊢ p.Coprime a

tactic: exact coprime_of_lt_prime h0 (gt_of_ge_of_gt succ_k_le_p h1) p_prime
state_before: case right
a k : ℕ
h0 : 0 < a
h1 : a < k
n p : ℕ
succ_k_le_p : k ≤ p
p_lt_n : p < k + n
p_prime : Prime p
⊢ p.Coprime a
state_after: no goals

tactic: rw [add_le_add_iff_left]
state_before: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ π' k + (filter a.Coprime (Ico k (k + n))).card ≤ π' k + φ a * (n / a + 1)
state_after: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ (filter a.Coprime (Ico k (k + n))).card ≤ φ a * (n / a + 1)

tactic: exact Ico_filter_coprime_le k n h0
state_before: a k : ℕ
h0 : 0 < a
h1 : a < k
n : ℕ
⊢ (filter a.Coprime (Ico k (k + n))).card ≤ φ a * (n / a + 1)
state_after: no goals