l3lab/ntp-mathlib huggingface dataset:
instance [CommSemiring S] [Algebra S R] : Algebra S ℍ[R,c₁,c₂] where
  smul := (· • ·)
  toFun s := coe (algebraMap S R s)
  map_one' := by simp only [map_one, coe_one]
  map_zero' := by simp only [map_zero, coe_zero]
  map_mul' x y := by simp only [map_mul, coe_mul]
  map_add' x y := by simp only [map_add, coe_add]
  smul_def' s x := by ext <;> 

Proof state:
case imK
S : Type u_1
T : Type u_2
R : Type u_3
inst✝² : CommRing R
c₁ c₂ r x✝ y z : R
a b c : ℍ[R,c₁,c₂]
inst✝¹ : CommSemiring S
inst✝ : Algebra S R
s : S
x : ℍ[R,c₁,c₂]
⊢ (s • x).imK =
    ({
            toMonoidHom :=
              { toOneHom := { toFun := fun s => ↑((algebraMap S R) s), map_one' := (_ : ↑((algebraMap S R) 1) = 1) },
                map_mul' :=
                  (_ : ∀ (x y : S), ↑((algebraMap S R) (x * y)) = ↑((algebraMap S R) x) * ↑((algebraMap S R) y)) },
            map_zero' := (_ : ↑((algebraMap S R) 0) = 0),
            map_add' := (_ : ∀ (x y : S), ↑((algebraMap S R) (x + y)) = ↑((algebraMap S R) x) + ↑((algebraMap S R) y)) }
          s *
        x).imK

Next tactic:
simp [Algebra.smul_def]
theorem algebraMap_injective : (algebraMap R ℍ[R,c₁,c₂] : _ → _).Injective :=
  fun _ _ ↦ by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c : ℍ[R,c₁,c₂]
x✝¹ x✝ : R
⊢ (algebraMap R ℍ[R,c₁,c₂]) x✝¹ = (algebraMap R ℍ[R,c₁,c₂]) x✝ → x✝¹ = x✝

Next tactic:
simp [algebraMap_eq]
instance [NoZeroDivisors R] : NoZeroSMulDivisors R ℍ[R,c₁,c₂] := ⟨by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
inst✝¹ : CommRing R
c₁ c₂ r x y z : R
a b c : ℍ[R,c₁,c₂]
inst✝ : NoZeroDivisors R
⊢ ∀ {c : R} {x : ℍ[R,c₁,c₂]}, c • x = 0 → c = 0 ∨ x = 0

Next tactic:
rintro t ⟨a, b, c, d⟩ h
instance [NoZeroDivisors R] : NoZeroSMulDivisors R ℍ[R,c₁,c₂] := ⟨by
  rintro t ⟨a, b, c, d⟩ h
  

Proof state:
case mk
S : Type u_1
T : Type u_2
R : Type u_3
inst✝¹ : CommRing R
c₁ c₂ r x y z : R
a✝ b✝ c✝ : ℍ[R,c₁,c₂]
inst✝ : NoZeroDivisors R
t a b c d : R
h : t • { re := a, imI := b, imJ := c, imK := d } = 0
⊢ t = 0 ∨ { re := a, imI := b, imJ := c, imK := d } = 0

Next tactic:
rw [or_iff_not_imp_left]
instance [NoZeroDivisors R] : NoZeroSMulDivisors R ℍ[R,c₁,c₂] := ⟨by
  rintro t ⟨a, b, c, d⟩ h
  rw [or_iff_not_imp_left]
  

Proof state:
case mk
S : Type u_1
T : Type u_2
R : Type u_3
inst✝¹ : CommRing R
c₁ c₂ r x y z : R
a✝ b✝ c✝ : ℍ[R,c₁,c₂]
inst✝ : NoZeroDivisors R
t a b c d : R
h : t • { re := a, imI := b, imJ := c, imK := d } = 0
⊢ ¬t = 0 → { re := a, imI := b, imJ := c, imK := d } = 0

Next tactic:
intro ht
instance [NoZeroDivisors R] : NoZeroSMulDivisors R ℍ[R,c₁,c₂] := ⟨by
  rintro t ⟨a, b, c, d⟩ h
  rw [or_iff_not_imp_left]
  intro ht
  

Proof state:
case mk
S : Type u_1
T : Type u_2
R : Type u_3
inst✝¹ : CommRing R
c₁ c₂ r x y z : R
a✝ b✝ c✝ : ℍ[R,c₁,c₂]
inst✝ : NoZeroDivisors R
t a b c d : R
h : t • { re := a, imI := b, imJ := c, imK := d } = 0
ht : ¬t = 0
⊢ { re := a, imI := b, imJ := c, imK := d } = 0

Next tactic:
simpa [QuaternionAlgebra.ext_iff, ht] using h
theorem rank_eq_four [StrongRankCondition R] : Module.rank R ℍ[R,c₁,c₂] = 4 := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
inst✝¹ : CommRing R
c₁ c₂ r x y z : R
a b c : ℍ[R,c₁,c₂]
inst✝ : StrongRankCondition R
⊢ Module.rank R ℍ[R,c₁,c₂] = 4

Next tactic:
rw [rank_eq_card_basis (basisOneIJK c₁ c₂), Fintype.card_fin]
theorem rank_eq_four [StrongRankCondition R] : Module.rank R ℍ[R,c₁,c₂] = 4 := by
  rw [rank_eq_card_basis (basisOneIJK c₁ c₂), Fintype.card_fin]
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
inst✝¹ : CommRing R
c₁ c₂ r x y z : R
a b c : ℍ[R,c₁,c₂]
inst✝ : StrongRankCondition R
⊢ ↑4 = 4

Next tactic:
norm_num
theorem finrank_eq_four [StrongRankCondition R] : FiniteDimensional.finrank R ℍ[R,c₁,c₂] = 4 := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
inst✝¹ : CommRing R
c₁ c₂ r x y z : R
a b c : ℍ[R,c₁,c₂]
inst✝ : StrongRankCondition R
⊢ FiniteDimensional.finrank R ℍ[R,c₁,c₂] = 4

Next tactic:
rw [FiniteDimensional.finrank, rank_eq_four, Cardinal.toNat_ofNat]
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝ : ℍ[R,c₁,c₂]
⊢ (fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK })
      ((fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK }) x✝) =
    x✝

Next tactic:
simp
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c : ℍ[R,c₁,c₂]
x✝ : ℍ[R,c₂,c₁]
⊢ (fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK })
      ((fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK }) x✝) =
    x✝

Next tactic:
simp
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ Equiv.toFun
      { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
        invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
        left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
        right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
      (x✝¹ * x✝) =
    Equiv.toFun
        { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
          right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
        x✝¹ *
      Equiv.toFun
        { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
          right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
        x✝

Next tactic:
ext
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> 

Proof state:
case re
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ (Equiv.toFun
        { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
          right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
        (x✝¹ * x✝)).re =
    (Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝¹ *
        Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝).re

Next tactic:
simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> 

Proof state:
case imI
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ (Equiv.toFun
        { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
          right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
        (x✝¹ * x✝)).imI =
    (Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝¹ *
        Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝).imI

Next tactic:
simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> 

Proof state:
case imJ
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ (Equiv.toFun
        { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
          right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
        (x✝¹ * x✝)).imJ =
    (Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝¹ *
        Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝).imJ

Next tactic:
simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> 

Proof state:
case imK
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ (Equiv.toFun
        { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
          right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
        (x✝¹ * x✝)).imK =
    (Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝¹ *
        Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝).imK

Next tactic:
simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
      <;> 

Proof state:
case re
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ x✝¹.re * x✝.re + c₁ * x✝¹.imI * x✝.imI + c₂ * x✝¹.imJ * x✝.imJ - c₁ * c₂ * x✝¹.imK * x✝.imK =
    x✝¹.re * x✝.re + c₂ * x✝¹.imJ * x✝.imJ + c₁ * x✝¹.imI * x✝.imI - c₂ * c₁ * x✝¹.imK * x✝.imK

Next tactic:
ring
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
      <;> 

Proof state:
case imI
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ x✝¹.re * x✝.imJ + c₁ * x✝¹.imI * x✝.imK + x✝¹.imJ * x✝.re - c₁ * x✝¹.imK * x✝.imI =
    x✝¹.re * x✝.imJ + x✝¹.imJ * x✝.re + c₁ * x✝¹.imI * x✝.imK + -(c₁ * x✝¹.imK * x✝.imI)

Next tactic:
ring
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
      <;> 

Proof state:
case imJ
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ x✝¹.re * x✝.imI + x✝¹.imI * x✝.re - c₂ * x✝¹.imJ * x✝.imK =
    x✝¹.re * x✝.imI + -(c₂ * x✝¹.imJ * x✝.imK) + x✝¹.imI * x✝.re

Next tactic:
ring
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
      <;> 

Proof state:
case imK
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ -(x✝¹.imK * x✝.re) + (x✝¹.imJ * x✝.imI - (x✝¹.re * x✝.imK + x✝¹.imI * x✝.imJ)) =
    -(x✝¹.re * x✝.imK) + x✝¹.imJ * x✝.imI - x✝¹.imI * x✝.imJ + -(x✝¹.imK * x✝.re)

Next tactic:
ring
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
      <;> ring
  map_add' _ _ := by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ Equiv.toFun
      { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
        invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
        left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
        right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
      (x✝¹ + x✝) =
    Equiv.toFun
        { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
          right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
        x✝¹ +
      Equiv.toFun
        { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
          right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
        x✝

Next tactic:
ext
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
      <;> ring
  map_add' _ _ := by ext <;> 

Proof state:
case re
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ (Equiv.toFun
        { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
          right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
        (x✝¹ + x✝)).re =
    (Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝¹ +
        Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝).re

Next tactic:
simp [add_comm]
/-- There is a natural equivalence when swapping the coefficients of a quaternion algebra. -/
@[simps]
def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where
  toFun t := ⟨t.1, t.3, t.2, -t.4⟩
  invFun t := ⟨t.1, t.3, t.2, -t.4⟩
  left_inv _ := by simp
  right_inv _ := by simp
  map_mul' _ _ := by
    ext
      <;> simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev,
                     neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add]
      <;> ring
  map_add' _ _ := by ext <;> 

Proof state:
case imI
S : Type u_1
T : Type u_2
R : Type u_3
inst✝ : CommRing R
c₁ c₂ r x y z : R
a b c x✝¹ x✝ : ℍ[R,c₁,c₂]
⊢ (Equiv.toFun
        { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
          left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
          right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
        (x✝¹ + x✝)).imI =
    (Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝¹ +
        Equiv.toFun
          { toFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            invFun := fun t => { re := t.re, imI := t.imJ, imJ := t.imI, imK := -t.imK },
            left_inv := (_ : ∀ (x : ℍ[R,c₁,c₂]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x),
            right_inv := (_ : ∀ (x : ℍ[R,c₂,c₁]), { re := x.re, imI := x.imI, imJ := x.imJ, imK := - -x.imK } = x) }
          x✝).imI

Next tactic:
simp [add_comm]