Theorem: Nat.image_div_divisors_eq_divisors
File: Mathlib/NumberTheory/Divisors.lean

tactic: by_cases hn : n = 0
state_before: n✝ n : ℕ
⊢ image (fun x => n / x) n.divisors = n.divisors
state_after: case pos
n✝ n : ℕ
hn : n = 0
⊢ image (fun x => n / x) n.divisors = n.divisors

case neg
n✝ n : ℕ
hn : ¬n = 0
⊢ image (fun x => n / x) n.divisors = n.divisors

tactic: ext a
state_before: case neg
n✝ n : ℕ
hn : ¬n = 0
⊢ image (fun x => n / x) n.divisors = n.divisors
state_after: case neg.a
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
⊢ a ∈ image (fun x => n / x) n.divisors ↔ a ∈ n.divisors

tactic: constructor
state_before: case neg.a
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
⊢ a ∈ image (fun x => n / x) n.divisors ↔ a ∈ n.divisors
state_after: case neg.a.mp
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
⊢ a ∈ image (fun x => n / x) n.divisors → a ∈ n.divisors

case neg.a.mpr
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
⊢ a ∈ n.divisors → a ∈ image (fun x => n / x) n.divisors

tactic: simp [hn]
state_before: case pos
n✝ n : ℕ
hn : n = 0
⊢ image (fun x => n / x) n.divisors = n.divisors
state_after: no goals

tactic: rw [mem_image]
state_before: case neg.a.mp
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
⊢ a ∈ image (fun x => n / x) n.divisors → a ∈ n.divisors
state_after: case neg.a.mp
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
⊢ (∃ a_1 ∈ n.divisors, n / a_1 = a) → a ∈ n.divisors

tactic: rintro ⟨x, hx1, hx2⟩
state_before: case neg.a.mp
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
⊢ (∃ a_1 ∈ n.divisors, n / a_1 = a) → a ∈ n.divisors
state_after: case neg.a.mp.intro.intro
n✝ n : ℕ
hn : ¬n = 0
a x : ℕ
hx1 : x ∈ n.divisors
hx2 : n / x = a
⊢ a ∈ n.divisors

tactic: rw [mem_divisors] at *
state_before: case neg.a.mp.intro.intro
n✝ n : ℕ
hn : ¬n = 0
a x : ℕ
hx1 : x ∈ n.divisors
hx2 : n / x = a
⊢ a ∈ n.divisors
state_after: case neg.a.mp.intro.intro
n✝ n : ℕ
hn : ¬n = 0
a x : ℕ
hx1 : x ∣ n ∧ n ≠ 0
hx2 : n / x = a
⊢ a ∣ n ∧ n ≠ 0

tactic: refine ⟨?_, hn⟩
state_before: case neg.a.mp.intro.intro
n✝ n : ℕ
hn : ¬n = 0
a x : ℕ
hx1 : x ∣ n ∧ n ≠ 0
hx2 : n / x = a
⊢ a ∣ n ∧ n ≠ 0
state_after: case neg.a.mp.intro.intro
n✝ n : ℕ
hn : ¬n = 0
a x : ℕ
hx1 : x ∣ n ∧ n ≠ 0
hx2 : n / x = a
⊢ a ∣ n

tactic: rw [← hx2]
state_before: case neg.a.mp.intro.intro
n✝ n : ℕ
hn : ¬n = 0
a x : ℕ
hx1 : x ∣ n ∧ n ≠ 0
hx2 : n / x = a
⊢ a ∣ n
state_after: case neg.a.mp.intro.intro
n✝ n : ℕ
hn : ¬n = 0
a x : ℕ
hx1 : x ∣ n ∧ n ≠ 0
hx2 : n / x = a
⊢ n / x ∣ n

tactic: exact div_dvd_of_dvd hx1.1
state_before: case neg.a.mp.intro.intro
n✝ n : ℕ
hn : ¬n = 0
a x : ℕ
hx1 : x ∣ n ∧ n ≠ 0
hx2 : n / x = a
⊢ n / x ∣ n
state_after: no goals

tactic: rw [mem_divisors, mem_image]
state_before: case neg.a.mpr
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
⊢ a ∈ n.divisors → a ∈ image (fun x => n / x) n.divisors
state_after: case neg.a.mpr
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
⊢ a ∣ n ∧ n ≠ 0 → ∃ a_2 ∈ n.divisors, n / a_2 = a

tactic: rintro ⟨h1, -⟩
state_before: case neg.a.mpr
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
⊢ a ∣ n ∧ n ≠ 0 → ∃ a_2 ∈ n.divisors, n / a_2 = a
state_after: case neg.a.mpr.intro
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
h1 : a ∣ n
⊢ ∃ a_1 ∈ n.divisors, n / a_1 = a

tactic: exact ⟨n / a, mem_divisors.mpr ⟨div_dvd_of_dvd h1, hn⟩, Nat.div_div_self h1 hn⟩
state_before: case neg.a.mpr.intro
n✝ n : ℕ
hn : ¬n = 0
a : ℕ
h1 : a ∣ n
⊢ ∃ a_1 ∈ n.divisors, n / a_1 = a
state_after: no goals