Theorem: Nat.ModEq.cancel_left_div_gcd
File: Mathlib/Data/Nat/ModEq.lean

tactic: let d := gcd m c
state_before: m n a b c d : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
⊢ a ≡ b [MOD m / m.gcd c]
state_after: m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
⊢ a ≡ b [MOD m / m.gcd c]

tactic: have hmd := gcd_dvd_left m c
state_before: m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
⊢ a ≡ b [MOD m / m.gcd c]
state_after: m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
⊢ a ≡ b [MOD m / m.gcd c]

tactic: have hcd := gcd_dvd_right m c
state_before: m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
⊢ a ≡ b [MOD m / m.gcd c]
state_after: m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ a ≡ b [MOD m / m.gcd c]

tactic: rw [modEq_iff_dvd]
state_before: m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ a ≡ b [MOD m / m.gcd c]
state_after: m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ ↑(m / m.gcd c) ∣ ↑b - ↑a

tactic: refine @Int.dvd_of_dvd_mul_right_of_gcd_one (m / d) (c / d) (b - a) ?_ ?_
state_before: m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ ↑(m / m.gcd c) ∣ ↑b - ↑a
state_after: case refine_1
m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ ↑m / ↑d ∣ ↑c / ↑d * (↑b - ↑a)

case refine_2
m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ (↑m / ↑d).gcd (↑c / ↑d) = 1

tactic: rw [mul_comm, ← Int.mul_ediv_assoc (b - a) (Int.natCast_dvd_natCast.mpr hcd), mul_comm]
state_before: case refine_1
m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ ↑m / ↑d ∣ ↑c / ↑d * (↑b - ↑a)
state_after: case refine_1
m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ ↑m / ↑d ∣ ↑c * (↑b - ↑a) / ↑(m.gcd c)

tactic: apply Int.ediv_dvd_ediv (Int.natCast_dvd_natCast.mpr hmd)
state_before: case refine_1
m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ ↑m / ↑d ∣ ↑c * (↑b - ↑a) / ↑(m.gcd c)
state_after: case refine_1
m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ ↑m ∣ ↑c * (↑b - ↑a)

tactic: rw [mul_sub]
state_before: case refine_1
m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ ↑m ∣ ↑c * (↑b - ↑a)
state_after: case refine_1
m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ ↑m ∣ ↑c * ↑b - ↑c * ↑a

tactic: exact modEq_iff_dvd.mp h
state_before: case refine_1
m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ ↑m ∣ ↑c * ↑b - ↑c * ↑a
state_after: no goals

tactic: simp only [← Int.natCast_div, Int.gcd_natCast_natCast (m / d) (c / d), gcd_div hmd hcd,
  Nat.div_self (gcd_pos_of_pos_left c hm)]
state_before: case refine_2
m n a b c d✝ : ℕ
hm : 0 < m
h : c * a ≡ c * b [MOD m]
d : ℕ := m.gcd c
hmd : m.gcd c ∣ m
hcd : m.gcd c ∣ c
⊢ (↑m / ↑d).gcd (↑c / ↑d) = 1
state_after: no goals