Theorem: schnirelmannDensity_finset
File: Mathlib/Combinatorics/Schnirelmann.lean

tactic: refine le_antisymm ?_ schnirelmannDensity_nonneg
state_before: A : Finset ℕ
⊢ schnirelmannDensity ↑A = 0
state_after: A : Finset ℕ
⊢ schnirelmannDensity ↑A ≤ 0

tactic: simp only [schnirelmannDensity_le_iff_forall, zero_add]
state_before: A : Finset ℕ
⊢ schnirelmannDensity ↑A ≤ 0
state_after: A : Finset ℕ
⊢ ∀ (ε : ℝ), 0 < ε → ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε

tactic: intro ε hε
state_before: A : Finset ℕ
⊢ ∀ (ε : ℝ), 0 < ε → ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
state_after: A : Finset ℕ
ε : ℝ
hε : 0 < ε
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε

tactic: wlog hε₁ : ε ≤ 1 generalizing ε
state_before: A : Finset ℕ
ε : ℝ
hε : 0 < ε
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
state_after: case inr
A : Finset ℕ
ε : ℝ
hε : 0 < ε
this : ∀ (ε : ℝ), 0 < ε → ε ≤ 1 → ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
hε₁ : ¬ε ≤ 1
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε

A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε

tactic: let n : ℕ := ⌊A.card / ε⌋₊ + 1
state_before: A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
state_after: A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε

tactic: have hn : 0 < n := Nat.succ_pos _
state_before: A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
state_after: A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
hn : 0 < n
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε

tactic: use n, hn
state_before: A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
hn : 0 < n
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
state_after: case right
A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
hn : 0 < n
⊢ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε

tactic: rw [div_lt_iff (Nat.cast_pos.2 hn), ← div_lt_iff' hε, Nat.cast_add_one]
state_before: case right
A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
hn : 0 < n
⊢ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
state_after: case right
A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
hn : 0 < n
⊢ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ε < ↑⌊↑A.card / ε⌋₊ + 1

tactic: exact (Nat.lt_floor_add_one _).trans_le' <| by gcongr; simp [subset_iff]
state_before: case right
A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
hn : 0 < n
⊢ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ε < ↑⌊↑A.card / ε⌋₊ + 1
state_after: no goals

tactic: obtain ⟨n, hn, hn'⟩ := this 1 zero_lt_one le_rfl
state_before: case inr
A : Finset ℕ
ε : ℝ
hε : 0 < ε
this : ∀ (ε : ℝ), 0 < ε → ε ≤ 1 → ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
hε₁ : ¬ε ≤ 1
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
state_after: case inr.intro.intro
A : Finset ℕ
ε : ℝ
hε : 0 < ε
this : ∀ (ε : ℝ), 0 < ε → ε ≤ 1 → ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
hε₁ : ¬ε ≤ 1
n : ℕ
hn : 0 < n
hn' : ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < 1
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε

tactic: exact ⟨n, hn, hn'.trans_le (le_of_not_le hε₁)⟩
state_before: case inr.intro.intro
A : Finset ℕ
ε : ℝ
hε : 0 < ε
this : ∀ (ε : ℝ), 0 < ε → ε ≤ 1 → ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
hε₁ : ¬ε ≤ 1
n : ℕ
hn : 0 < n
hn' : ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < 1
⊢ ∃ n, 0 < n ∧ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ↑n < ε
state_after: no goals

tactic: gcongr
state_before: A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
hn : 0 < n
⊢ ↑(filter (fun x => x ∈ ↑A) (Ioc 0 n)).card / ε ≤ ↑A.card / ε
state_after: case hab.h.a
A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
hn : 0 < n
⊢ filter (fun x => x ∈ ↑A) (Ioc 0 n) ⊆ A

tactic: simp [subset_iff]
state_before: case hab.h.a
A : Finset ℕ
ε : ℝ
hε : 0 < ε
hε₁ : ε ≤ 1
n : ℕ := ⌊↑A.card / ε⌋₊ + 1
hn : 0 < n
⊢ filter (fun x => x ∈ ↑A) (Ioc 0 n) ⊆ A
state_after: no goals