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

Proof steps:
state_before: m : ℕ
hm : m ≠ 1
⊢ schnirelmannDensity {n | n % m = 1} = (↑m)⁻¹
state_after: case inl
hm : 0 ≠ 1
⊢ schnirelmannDensity {n | n % 0 = 1} = (↑0)⁻¹

case inr
m : ℕ
hm : m ≠ 1
hm' : m > 0
⊢ schnirelmannDensity {n | n % m = 1} = (↑m)⁻¹
tactic: rcases m.eq_zero_or_pos with rfl | hm'
state_before: case inr
m : ℕ
hm : m ≠ 1
hm' : m > 0
⊢ schnirelmannDensity {n | n % m = 1} = (↑m)⁻¹
state_after: m : ℕ
hm : m ≠ 1
hm' : m > 0
⊢ ↑(filter (fun x => x ∈ {n | n % m = 1}) (Ioc 0 m)).card / ↑m ≤ (↑m)⁻¹

m : ℕ
hm : m ≠ 1
hm' : m > 0
⊢ (↑m)⁻¹ ≤ schnirelmannDensity {n | n % m = 1}
tactic: apply le_antisymm (schnirelmannDensity_le_of_le m hm'.ne' _) _
state_before: m : ℕ
hm : m ≠ 1
hm' : m > 0
⊢ (↑m)⁻¹ ≤ schnirelmannDensity {n | n % m = 1}
state_after: m : ℕ
hm : m ≠ 1
hm' : m > 0
⊢ ∀ (n : ℕ), 0 < n → (↑m)⁻¹ ≤ ↑(filter (fun x => x ∈ {n | n % m = 1}) (Ioc 0 n)).card / ↑n
tactic: rw [le_schnirelmannDensity_iff]
state_before: m : ℕ
hm : m ≠ 1
hm' : m > 0
⊢ ∀ (n : ℕ), 0 < n → (↑m)⁻¹ ≤ ↑(filter (fun x => x ∈ {n | n % m = 1}) (Ioc 0 n)).card / ↑n
state_after: m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
⊢ (↑m)⁻¹ ≤ ↑(filter (fun x => x ∈ {n | n % m = 1}) (Ioc 0 n)).card / ↑n
tactic: intro n hn
state_before: m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
⊢ (↑m)⁻¹ ≤ ↑(filter (fun x => x ∈ {n | n % m = 1}) (Ioc 0 n)).card / ↑n
state_after: m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
⊢ (↑m)⁻¹ ≤ ↑(filter (fun x => x % m = 1) (Ioc 0 n)).card / ↑n
tactic: simp only [Set.mem_setOf_eq]
state_before: m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
this : image (fun x => x * m + 1) (Icc 0 ((n - 1) / m)) ⊆ filter (fun x => x % m = 1) (Ioc 0 n)
⊢ (↑m)⁻¹ ≤ ↑(filter (fun x => x % m = 1) (Ioc 0 n)).card / ↑n
state_after: m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
this : image (fun x => x * m + 1) (Icc 0 ((n - 1) / m)) ⊆ filter (fun x => x % m = 1) (Ioc 0 n)
⊢ ↑n / ↑m ≤ ↑(filter (fun x => x % m = 1) (Ioc 0 n)).card
tactic: rw [le_div_iff (Nat.cast_pos.2 hn), mul_comm, ← div_eq_mul_inv]
state_before: m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
this : image (fun x => x * m + 1) (Icc 0 ((n - 1) / m)) ⊆ filter (fun x => x % m = 1) (Ioc 0 n)
⊢ ↑n / ↑m ≤ ↑(filter (fun x => x % m = 1) (Ioc 0 n)).card
state_after: m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
this : image (fun x => x * m + 1) (Icc 0 ((n - 1) / m)) ⊆ filter (fun x => x % m = 1) (Ioc 0 n)
⊢ ↑n / ↑m ≤ ↑(image (fun x => x * m + 1) (Icc 0 ((n - 1) / m))).card
tactic: apply (Nat.cast_le.2 (card_le_card this)).trans'
state_before: m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
this : image (fun x => x * m + 1) (Icc 0 ((n - 1) / m)) ⊆ filter (fun x => x % m = 1) (Ioc 0 n)
⊢ ↑n / ↑m ≤ ↑(image (fun x => x * m + 1) (Icc 0 ((n - 1) / m))).card
state_after: m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
this : image (fun x => x * m + 1) (Icc 0 ((n - 1) / m)) ⊆ filter (fun x => x % m = 1) (Ioc 0 n)
⊢ n ≤ (n - 1) / m * m + m

case H
m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
this : image (fun x => x * m + 1) (Icc 0 ((n - 1) / m)) ⊆ filter (fun x => x % m = 1) (Ioc 0 n)
⊢ Function.Injective fun x => x * m + 1
tactic: rw [card_image_of_injective, Nat.card_Icc, Nat.sub_zero, div_le_iff (Nat.cast_pos.2 hm'),
    ← Nat.cast_mul, Nat.cast_le, add_one_mul (α := ℕ)]
state_before: case H
m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
this : image (fun x => x * m + 1) (Icc 0 ((n - 1) / m)) ⊆ filter (fun x => x % m = 1) (Ioc 0 n)
⊢ Function.Injective fun x => x * m + 1
state_after: case H
m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
this : image (fun x => x * m + 1) (Icc 0 ((n - 1) / m)) ⊆ filter (fun x => x % m = 1) (Ioc 0 n)
a b : ℕ
⊢ (fun x => x * m + 1) a = (fun x => x * m + 1) b → a = b
tactic: intro a b
state_before: case H
m : ℕ
hm : m ≠ 1
hm' : m > 0
n : ℕ
hn : 0 < n
this : image (fun x => x * m + 1) (Icc 0 ((n - 1) / m)) ⊆ filter (fun x => x % m = 1) (Ioc 0 n)
a b : ℕ
⊢ (fun x => x * m + 1) a = (fun x => x * m + 1) b → a = b
state_after: no goals
tactic: simp [hm'.ne']