l3lab/ntp-mathlib huggingface dataset:
theorem units_ne_iff_eq_neg {u u' : ℤˣ} : u ≠ u' ↔ u = -u' := by
  rcases units_eq_one_or u with rfl | rfl <;>
  

Proof state:
case inr
u' : ℤˣ
⊢ -1 ≠ u' ↔ -1 = -u'

Next tactic:
rcases units_eq_one_or u' with rfl | rfl
theorem units_ne_iff_eq_neg {u u' : ℤˣ} : u ≠ u' ↔ u = -u' := by
  rcases units_eq_one_or u with rfl | rfl <;>
  rcases units_eq_one_or u' with rfl | rfl <;>
  

Proof state:
case inl.inl
⊢ 1 ≠ 1 ↔ 1 = -1

Next tactic:
decide
theorem units_ne_iff_eq_neg {u u' : ℤˣ} : u ≠ u' ↔ u = -u' := by
  rcases units_eq_one_or u with rfl | rfl <;>
  rcases units_eq_one_or u' with rfl | rfl <;>
  

Proof state:
case inl.inr
⊢ 1 ≠ -1 ↔ 1 = - -1

Next tactic:
decide
theorem units_ne_iff_eq_neg {u u' : ℤˣ} : u ≠ u' ↔ u = -u' := by
  rcases units_eq_one_or u with rfl | rfl <;>
  rcases units_eq_one_or u' with rfl | rfl <;>
  

Proof state:
case inr.inl
⊢ -1 ≠ 1 ↔ -1 = -1

Next tactic:
decide
theorem units_ne_iff_eq_neg {u u' : ℤˣ} : u ≠ u' ↔ u = -u' := by
  rcases units_eq_one_or u with rfl | rfl <;>
  rcases units_eq_one_or u' with rfl | rfl <;>
  

Proof state:
case inr.inr
⊢ -1 ≠ -1 ↔ -1 = - -1

Next tactic:
decide
theorem isUnit_ne_iff_eq_neg {u u' : ℤ} (hu : IsUnit u) (hu' : IsUnit u') : u ≠ u' ↔ u = -u' := by
  

Proof state:
u u' : ℤ
hu : IsUnit u
hu' : IsUnit u'
⊢ u ≠ u' ↔ u = -u'

Next tactic:
simpa only [Ne, Units.ext_iff] using units_ne_iff_eq_neg (u := hu.unit) (u' := hu'.unit)
theorem isUnit_iff {a : ℤ} : IsUnit a ↔ a = 1 ∨ a = -1 := by
  

Proof state:
a : ℤ
⊢ IsUnit a ↔ a = 1 ∨ a = -1

Next tactic:
refine' ⟨fun h => isUnit_eq_one_or h, fun h => _⟩
theorem isUnit_iff {a : ℤ} : IsUnit a ↔ a = 1 ∨ a = -1 := by
  refine' ⟨fun h => isUnit_eq_one_or h, fun h => _⟩
  

Proof state:
a : ℤ
h : a = 1 ∨ a = -1
⊢ IsUnit a

Next tactic:
rcases h with (rfl | rfl)
theorem isUnit_iff {a : ℤ} : IsUnit a ↔ a = 1 ∨ a = -1 := by
  refine' ⟨fun h => isUnit_eq_one_or h, fun h => _⟩
  rcases h with (rfl | rfl)
  · 

Proof state:
case inl
⊢ IsUnit 1

Next tactic:
exact isUnit_one
theorem isUnit_iff {a : ℤ} : IsUnit a ↔ a = 1 ∨ a = -1 := by
  refine' ⟨fun h => isUnit_eq_one_or h, fun h => _⟩
  rcases h with (rfl | rfl)
  · exact isUnit_one
  · 

Proof state:
case inr
⊢ IsUnit (-1)

Next tactic:
exact isUnit_one.neg
theorem eq_one_or_neg_one_of_mul_eq_one' {z w : ℤ} (h : z * w = 1) :
    z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  

Proof state:
z w : ℤ
h : z * w = 1
⊢ z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1

Next tactic:
have h' : w * z = 1 := mul_comm z w ▸ h
theorem eq_one_or_neg_one_of_mul_eq_one' {z w : ℤ} (h : z * w = 1) :
    z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  have h' : w * z = 1 := mul_comm z w ▸ h
  

Proof state:
z w : ℤ
h : z * w = 1
h' : w * z = 1
⊢ z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1

Next tactic:
rcases eq_one_or_neg_one_of_mul_eq_one h with (rfl | rfl)
theorem eq_one_or_neg_one_of_mul_eq_one' {z w : ℤ} (h : z * w = 1) :
    z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  have h' : w * z = 1 := mul_comm z w ▸ h
  rcases eq_one_or_neg_one_of_mul_eq_one h with (rfl | rfl) <;>
      

Proof state:
case inl
w : ℤ
h : 1 * w = 1
h' : w * 1 = 1
⊢ 1 = 1 ∧ w = 1 ∨ 1 = -1 ∧ w = -1

Next tactic:
rcases eq_one_or_neg_one_of_mul_eq_one h' with (rfl | rfl)
theorem eq_one_or_neg_one_of_mul_eq_one' {z w : ℤ} (h : z * w = 1) :
    z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  have h' : w * z = 1 := mul_comm z w ▸ h
  rcases eq_one_or_neg_one_of_mul_eq_one h with (rfl | rfl) <;>
      

Proof state:
case inr
w : ℤ
h : -1 * w = 1
h' : w * -1 = 1
⊢ -1 = 1 ∧ w = 1 ∨ -1 = -1 ∧ w = -1

Next tactic:
rcases eq_one_or_neg_one_of_mul_eq_one h' with (rfl | rfl)
theorem eq_one_or_neg_one_of_mul_eq_one' {z w : ℤ} (h : z * w = 1) :
    z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  have h' : w * z = 1 := mul_comm z w ▸ h
  rcases eq_one_or_neg_one_of_mul_eq_one h with (rfl | rfl) <;>
      rcases eq_one_or_neg_one_of_mul_eq_one h' with (rfl | rfl) <;> 

Proof state:
case inl.inl
h h' : 1 * 1 = 1
⊢ 1 = 1 ∧ 1 = 1 ∨ 1 = -1 ∧ 1 = -1

Next tactic:
tauto
theorem eq_one_or_neg_one_of_mul_eq_one' {z w : ℤ} (h : z * w = 1) :
    z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  have h' : w * z = 1 := mul_comm z w ▸ h
  rcases eq_one_or_neg_one_of_mul_eq_one h with (rfl | rfl) <;>
      rcases eq_one_or_neg_one_of_mul_eq_one h' with (rfl | rfl) <;> 

Proof state:
case inl.inr
h : 1 * -1 = 1
h' : -1 * 1 = 1
⊢ 1 = 1 ∧ -1 = 1 ∨ 1 = -1 ∧ -1 = -1

Next tactic:
tauto
theorem eq_one_or_neg_one_of_mul_eq_one' {z w : ℤ} (h : z * w = 1) :
    z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  have h' : w * z = 1 := mul_comm z w ▸ h
  rcases eq_one_or_neg_one_of_mul_eq_one h with (rfl | rfl) <;>
      rcases eq_one_or_neg_one_of_mul_eq_one h' with (rfl | rfl) <;> 

Proof state:
case inr.inl
h : -1 * 1 = 1
h' : 1 * -1 = 1
⊢ -1 = 1 ∧ 1 = 1 ∨ -1 = -1 ∧ 1 = -1

Next tactic:
tauto
theorem eq_one_or_neg_one_of_mul_eq_one' {z w : ℤ} (h : z * w = 1) :
    z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  have h' : w * z = 1 := mul_comm z w ▸ h
  rcases eq_one_or_neg_one_of_mul_eq_one h with (rfl | rfl) <;>
      rcases eq_one_or_neg_one_of_mul_eq_one h' with (rfl | rfl) <;> 

Proof state:
case inr.inr
h h' : -1 * -1 = 1
⊢ -1 = 1 ∧ -1 = 1 ∨ -1 = -1 ∧ -1 = -1

Next tactic:
tauto
theorem mul_eq_one_iff_eq_one_or_neg_one {z w : ℤ} :
    z * w = 1 ↔ z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  

Proof state:
z w : ℤ
⊢ z * w = 1 ↔ z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1

Next tactic:
refine' ⟨eq_one_or_neg_one_of_mul_eq_one', fun h => Or.elim h (fun H => _) fun H => _⟩
theorem mul_eq_one_iff_eq_one_or_neg_one {z w : ℤ} :
    z * w = 1 ↔ z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  refine' ⟨eq_one_or_neg_one_of_mul_eq_one', fun h => Or.elim h (fun H => _) fun H => _⟩ <;>
      

Proof state:
case refine'_1
z w : ℤ
h : z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1
H : z = 1 ∧ w = 1
⊢ z * w = 1

Next tactic:
rcases H with ⟨rfl, rfl⟩
theorem mul_eq_one_iff_eq_one_or_neg_one {z w : ℤ} :
    z * w = 1 ↔ z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  refine' ⟨eq_one_or_neg_one_of_mul_eq_one', fun h => Or.elim h (fun H => _) fun H => _⟩ <;>
      

Proof state:
case refine'_2
z w : ℤ
h : z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1
H : z = -1 ∧ w = -1
⊢ z * w = 1

Next tactic:
rcases H with ⟨rfl, rfl⟩
theorem mul_eq_one_iff_eq_one_or_neg_one {z w : ℤ} :
    z * w = 1 ↔ z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  refine' ⟨eq_one_or_neg_one_of_mul_eq_one', fun h => Or.elim h (fun H => _) fun H => _⟩ <;>
      rcases H with ⟨rfl, rfl⟩ <;>
    

Proof state:
case refine'_1.intro
h : 1 = 1 ∧ 1 = 1 ∨ 1 = -1 ∧ 1 = -1
⊢ 1 * 1 = 1

Next tactic:
rfl
theorem mul_eq_one_iff_eq_one_or_neg_one {z w : ℤ} :
    z * w = 1 ↔ z = 1 ∧ w = 1 ∨ z = -1 ∧ w = -1 := by
  refine' ⟨eq_one_or_neg_one_of_mul_eq_one', fun h => Or.elim h (fun H => _) fun H => _⟩ <;>
      rcases H with ⟨rfl, rfl⟩ <;>
    

Proof state:
case refine'_2.intro
h : -1 = 1 ∧ -1 = 1 ∨ -1 = -1 ∧ -1 = -1
⊢ -1 * -1 = 1

Next tactic:
rfl
theorem eq_one_or_neg_one_of_mul_eq_neg_one' {z w : ℤ} (h : z * w = -1) :
    z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1 := by
  

Proof state:
z w : ℤ
h : z * w = -1
⊢ z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1

Next tactic:
rcases isUnit_eq_one_or (IsUnit.mul_iff.mp (Int.isUnit_iff.mpr (Or.inr h))).1 with (rfl | rfl)
theorem eq_one_or_neg_one_of_mul_eq_neg_one' {z w : ℤ} (h : z * w = -1) :
    z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1 := by
  rcases isUnit_eq_one_or (IsUnit.mul_iff.mp (Int.isUnit_iff.mpr (Or.inr h))).1 with (rfl | rfl)
  · 

Proof state:
case inl
w : ℤ
h : 1 * w = -1
⊢ 1 = 1 ∧ w = -1 ∨ 1 = -1 ∧ w = 1

Next tactic:
exact Or.inl ⟨rfl, one_mul w ▸ h⟩
theorem eq_one_or_neg_one_of_mul_eq_neg_one' {z w : ℤ} (h : z * w = -1) :
    z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1 := by
  rcases isUnit_eq_one_or (IsUnit.mul_iff.mp (Int.isUnit_iff.mpr (Or.inr h))).1 with (rfl | rfl)
  · exact Or.inl ⟨rfl, one_mul w ▸ h⟩
  · 

Proof state:
case inr
w : ℤ
h : -1 * w = -1
⊢ -1 = 1 ∧ w = -1 ∨ -1 = -1 ∧ w = 1

Next tactic:
exact Or.inr ⟨rfl, neg_inj.mp (neg_one_mul w ▸ h)⟩
theorem mul_eq_neg_one_iff_eq_one_or_neg_one {z w : ℤ} :
    z * w = -1 ↔ z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1 := by
  

Proof state:
z w : ℤ
⊢ z * w = -1 ↔ z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1

Next tactic:
refine' ⟨eq_one_or_neg_one_of_mul_eq_neg_one', fun h => Or.elim h (fun H => _) fun H => _⟩
theorem mul_eq_neg_one_iff_eq_one_or_neg_one {z w : ℤ} :
    z * w = -1 ↔ z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1 := by
  refine' ⟨eq_one_or_neg_one_of_mul_eq_neg_one', fun h => Or.elim h (fun H => _) fun H => _⟩ <;>
      

Proof state:
case refine'_1
z w : ℤ
h : z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1
H : z = 1 ∧ w = -1
⊢ z * w = -1

Next tactic:
rcases H with ⟨rfl, rfl⟩
theorem mul_eq_neg_one_iff_eq_one_or_neg_one {z w : ℤ} :
    z * w = -1 ↔ z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1 := by
  refine' ⟨eq_one_or_neg_one_of_mul_eq_neg_one', fun h => Or.elim h (fun H => _) fun H => _⟩ <;>
      

Proof state:
case refine'_2
z w : ℤ
h : z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1
H : z = -1 ∧ w = 1
⊢ z * w = -1

Next tactic:
rcases H with ⟨rfl, rfl⟩
theorem mul_eq_neg_one_iff_eq_one_or_neg_one {z w : ℤ} :
    z * w = -1 ↔ z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1 := by
  refine' ⟨eq_one_or_neg_one_of_mul_eq_neg_one', fun h => Or.elim h (fun H => _) fun H => _⟩ <;>
      rcases H with ⟨rfl, rfl⟩ <;>
    

Proof state:
case refine'_1.intro
h : 1 = 1 ∧ -1 = -1 ∨ 1 = -1 ∧ -1 = 1
⊢ 1 * -1 = -1

Next tactic:
rfl
theorem mul_eq_neg_one_iff_eq_one_or_neg_one {z w : ℤ} :
    z * w = -1 ↔ z = 1 ∧ w = -1 ∨ z = -1 ∧ w = 1 := by
  refine' ⟨eq_one_or_neg_one_of_mul_eq_neg_one', fun h => Or.elim h (fun H => _) fun H => _⟩ <;>
      rcases H with ⟨rfl, rfl⟩ <;>
    

Proof state:
case refine'_2.intro
h : -1 = 1 ∧ 1 = -1 ∨ -1 = -1 ∧ 1 = 1
⊢ -1 * 1 = -1

Next tactic:
rfl
theorem isUnit_iff_natAbs_eq {n : ℤ} : IsUnit n ↔ n.natAbs = 1 := by
  

Proof state:
n : ℤ
⊢ IsUnit n ↔ natAbs n = 1

Next tactic:
simp [natAbs_eq_iff, isUnit_iff, Nat.cast_zero]
@[norm_cast]
theorem ofNat_isUnit {n : ℕ} : IsUnit (n : ℤ) ↔ IsUnit n := by
  

Proof state:
n : ℕ
⊢ IsUnit ↑n ↔ IsUnit n

Next tactic:
simp [isUnit_iff_natAbs_eq]
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  

Proof state:
a b c d : ℤ
ha : IsUnit a
hb : IsUnit b
hc : IsUnit c
hd : IsUnit d
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
rw [isUnit_iff] at ha hb hc hd
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  

Proof state:
a b c d : ℤ
ha : a = 1 ∨ a = -1
hb : b = 1 ∨ b = -1
hc : c = 1 ∨ c = -1
hd : d = 1 ∨ d = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases ha
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> 

Proof state:
case inl
a b c d : ℤ
hb : b = 1 ∨ b = -1
hc : c = 1 ∨ c = -1
hd : d = 1 ∨ d = -1
h✝ : a = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hb
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> 

Proof state:
case inr
a b c d : ℤ
hb : b = 1 ∨ b = -1
hc : c = 1 ∨ c = -1
hd : d = 1 ∨ d = -1
h✝ : a = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hb
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> 

Proof state:
case inl.inl
a b c d : ℤ
hc : c = 1 ∨ c = -1
hd : d = 1 ∨ d = -1
h✝¹ : a = 1
h✝ : b = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hc
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> 

Proof state:
case inl.inr
a b c d : ℤ
hc : c = 1 ∨ c = -1
hd : d = 1 ∨ d = -1
h✝¹ : a = 1
h✝ : b = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hc
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> 

Proof state:
case inr.inl
a b c d : ℤ
hc : c = 1 ∨ c = -1
hd : d = 1 ∨ d = -1
h✝¹ : a = -1
h✝ : b = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hc
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> 

Proof state:
case inr.inr
a b c d : ℤ
hc : c = 1 ∨ c = -1
hd : d = 1 ∨ d = -1
h✝¹ : a = -1
h✝ : b = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hc
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> 

Proof state:
case inl.inl.inl
a b c d : ℤ
hd : d = 1 ∨ d = -1
h✝² : a = 1
h✝¹ : b = 1
h✝ : c = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hd
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> 

Proof state:
case inl.inl.inr
a b c d : ℤ
hd : d = 1 ∨ d = -1
h✝² : a = 1
h✝¹ : b = 1
h✝ : c = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hd
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> 

Proof state:
case inl.inr.inl
a b c d : ℤ
hd : d = 1 ∨ d = -1
h✝² : a = 1
h✝¹ : b = -1
h✝ : c = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hd
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> 

Proof state:
case inl.inr.inr
a b c d : ℤ
hd : d = 1 ∨ d = -1
h✝² : a = 1
h✝¹ : b = -1
h✝ : c = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hd
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> 

Proof state:
case inr.inl.inl
a b c d : ℤ
hd : d = 1 ∨ d = -1
h✝² : a = -1
h✝¹ : b = 1
h✝ : c = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hd
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> 

Proof state:
case inr.inl.inr
a b c d : ℤ
hd : d = 1 ∨ d = -1
h✝² : a = -1
h✝¹ : b = 1
h✝ : c = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hd
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> 

Proof state:
case inr.inr.inl
a b c d : ℤ
hd : d = 1 ∨ d = -1
h✝² : a = -1
h✝¹ : b = -1
h✝ : c = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hd
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> 

Proof state:
case inr.inr.inr
a b c d : ℤ
hd : d = 1 ∨ d = -1
h✝² : a = -1
h✝¹ : b = -1
h✝ : c = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
cases hd
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inl.inl.inl.inl
a b c d : ℤ
h✝³ : a = 1
h✝² : b = 1
h✝¹ : c = 1
h✝ : d = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inl.inl.inl.inr
a b c d : ℤ
h✝³ : a = 1
h✝² : b = 1
h✝¹ : c = 1
h✝ : d = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inl.inl.inr.inl
a b c d : ℤ
h✝³ : a = 1
h✝² : b = 1
h✝¹ : c = -1
h✝ : d = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inl.inl.inr.inr
a b c d : ℤ
h✝³ : a = 1
h✝² : b = 1
h✝¹ : c = -1
h✝ : d = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inl.inr.inl.inl
a b c d : ℤ
h✝³ : a = 1
h✝² : b = -1
h✝¹ : c = 1
h✝ : d = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inl.inr.inl.inr
a b c d : ℤ
h✝³ : a = 1
h✝² : b = -1
h✝¹ : c = 1
h✝ : d = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inl.inr.inr.inl
a b c d : ℤ
h✝³ : a = 1
h✝² : b = -1
h✝¹ : c = -1
h✝ : d = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inl.inr.inr.inr
a b c d : ℤ
h✝³ : a = 1
h✝² : b = -1
h✝¹ : c = -1
h✝ : d = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inr.inl.inl.inl
a b c d : ℤ
h✝³ : a = -1
h✝² : b = 1
h✝¹ : c = 1
h✝ : d = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inr.inl.inl.inr
a b c d : ℤ
h✝³ : a = -1
h✝² : b = 1
h✝¹ : c = 1
h✝ : d = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inr.inl.inr.inl
a b c d : ℤ
h✝³ : a = -1
h✝² : b = 1
h✝¹ : c = -1
h✝ : d = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inr.inl.inr.inr
a b c d : ℤ
h✝³ : a = -1
h✝² : b = 1
h✝¹ : c = -1
h✝ : d = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inr.inr.inl.inl
a b c d : ℤ
h✝³ : a = -1
h✝² : b = -1
h✝¹ : c = 1
h✝ : d = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inr.inr.inl.inr
a b c d : ℤ
h✝³ : a = -1
h✝² : b = -1
h✝¹ : c = 1
h✝ : d = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inr.inr.inr.inl
a b c d : ℤ
h✝³ : a = -1
h✝² : b = -1
h✝¹ : c = -1
h✝ : d = 1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      

Proof state:
case inr.inr.inr.inr
a b c d : ℤ
h✝³ : a = -1
h✝² : b = -1
h✝¹ : c = -1
h✝ : d = -1
⊢ a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c

Next tactic:
subst a
theorem isUnit_add_isUnit_eq_isUnit_add_isUnit {a b c d : ℤ} (ha : IsUnit a) (hb : IsUnit b)
    (hc : IsUnit c) (hd : IsUnit d) : a + b = c + d ↔ a = c ∧ b = d ∨ a = d ∧ b = c := by
  rw [isUnit_iff] at ha hb hc hd
  cases ha <;> cases hb <;> cases hc <;> cases hd <;>
      subst a <;> 

Proof state:
case inl.inl.inl.inl
b c d : ℤ
h✝² : b = 1
h✝¹ : c = 1
h✝ : d = 1
⊢ 1 + b = c + d ↔ 1 = c ∧ b = d ∨ 1 = d ∧ b = c

Next tactic:
subst b