Theorem: Nat.Squarefree.ext_iff
File: Mathlib/Data/Nat/Squarefree.lean

tactic: refine' ⟨by rintro rfl; simp, fun h => eq_of_factorization_eq hn.ne_zero hm.ne_zero fun p => _⟩
state_before: n m : ℕ
hn : Squarefree n
hm : Squarefree m
⊢ n = m ↔ ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)

tactic: by_cases hp : p.Prime
state_before: n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
⊢ ↑(factorization n) p = ↑(factorization m) p

tactic: rw [factorization_eq_zero_of_non_prime _ hp, factorization_eq_zero_of_non_prime _ hp]
state_before: case neg
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : ¬Prime p
⊢ ↑(factorization n) p = ↑(factorization m) p

tactic: rintro rfl
state_before: n m : ℕ
hn : Squarefree n
hm : Squarefree m
⊢ n = m → ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)

tactic: simp
state_before: n : ℕ
hn hm : Squarefree n
⊢ ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ n)

tactic: have h₁ := h _ hp
state_before: case pos
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : Prime p
⊢ ↑(factorization n) p = ↑(factorization m) p

tactic: rw [← not_iff_not, hp.dvd_iff_one_le_factorization hn.ne_zero, not_le, lt_one_iff,
  hp.dvd_iff_one_le_factorization hm.ne_zero, not_le, lt_one_iff] at h₁
state_before: case pos
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : Prime p
h₁ : p ∣ n ↔ p ∣ m
⊢ ↑(factorization n) p = ↑(factorization m) p

tactic: have h₂ := Squarefree.factorization_le_one p hn
state_before: case pos
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : Prime p
h₁ : ↑(factorization n) p = 0 ↔ ↑(factorization m) p = 0
⊢ ↑(factorization n) p = ↑(factorization m) p

tactic: have h₃ := Squarefree.factorization_le_one p hm
state_before: case pos
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : Prime p
h₁ : ↑(factorization n) p = 0 ↔ ↑(factorization m) p = 0
h₂ : ↑(factorization n) p ≤ 1
⊢ ↑(factorization n) p = ↑(factorization m) p

tactic: rw [Nat.le_add_one_iff, le_zero_iff] at h₂ h₃
state_before: case pos
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : Prime p
h₁ : ↑(factorization n) p = 0 ↔ ↑(factorization m) p = 0
h₂ : ↑(factorization n) p ≤ 1
h₃ : ↑(factorization m) p ≤ 1
⊢ ↑(factorization n) p = ↑(factorization m) p

tactic: cases' h₂ with h₂ h₂
state_before: case pos
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : Prime p
h₁ : ↑(factorization n) p = 0 ↔ ↑(factorization m) p = 0
h₂ : ↑(factorization n) p = 0 ∨ ↑(factorization n) p = 0 + 1
h₃ : ↑(factorization m) p = 0 ∨ ↑(factorization m) p = 0 + 1
⊢ ↑(factorization n) p = ↑(factorization m) p

tactic: rwa [h₂, eq_comm, ← h₁]
state_before: case pos.inl
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : Prime p
h₁ : ↑(factorization n) p = 0 ↔ ↑(factorization m) p = 0
h₃ : ↑(factorization m) p = 0 ∨ ↑(factorization m) p = 0 + 1
h₂ : ↑(factorization n) p = 0
⊢ ↑(factorization n) p = ↑(factorization m) p

tactic: rw [h₂, h₃.resolve_left]
state_before: case pos.inr
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : Prime p
h₁ : ↑(factorization n) p = 0 ↔ ↑(factorization m) p = 0
h₃ : ↑(factorization m) p = 0 ∨ ↑(factorization m) p = 0 + 1
h₂ : ↑(factorization n) p = 0 + 1
⊢ ↑(factorization n) p = ↑(factorization m) p

tactic: rw [← h₁, h₂]
state_before: case pos.inr
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : Prime p
h₁ : ↑(factorization n) p = 0 ↔ ↑(factorization m) p = 0
h₃ : ↑(factorization m) p = 0 ∨ ↑(factorization m) p = 0 + 1
h₂ : ↑(factorization n) p = 0 + 1
⊢ ¬↑(factorization m) p = 0

tactic: simp only [Nat.one_ne_zero, not_false_iff]
state_before: case pos.inr
n m : ℕ
hn : Squarefree n
hm : Squarefree m
h : ∀ (p : ℕ), Prime p → (p ∣ n ↔ p ∣ m)
p : ℕ
hp : Prime p
h₁ : ↑(factorization n) p = 0 ↔ ↑(factorization m) p = 0
h₃ : ↑(factorization m) p = 0 ∨ ↑(factorization m) p = 0 + 1
h₂ : ↑(factorization n) p = 0 + 1
⊢ ¬0 + 1 = 0