l3lab/ntp-mathlib huggingface dataset:
theorem exists_mulVec_eq_zero_iff' {A : Type*} (K : Type*) [DecidableEq n] [CommRing A]
    [Nontrivial A] [Field K] [Algebra A K] [IsFractionRing A K] {M : Matrix n n A} :
    (∃ v ≠ 0, M.mulVec v = 0) ↔ M.det = 0 := by
  have : (∃ v ≠ 0, mulVec ((algebraMap A K).mapMatrix M) v = 0) ↔ _ :=
    exists_mulVec_eq_zero_iff_aux
  rw [← RingHom.map_det, IsFractionRing.to_map_eq_zero_iff] at this
  refine' Iff.trans _ this; constructor <;> rintro ⟨v, hv, mul_eq⟩
  · refine' ⟨fun i => algebraMap _ _ (v i), mt (fun h => funext fun i => _) hv, _⟩
    · exact IsFractionRing.to_map_eq_zero_iff.mp (congr_fun h i)
    · ext i
      refine' (RingHom.map_mulVec _ _ _ i).symm.trans _
      rw [mul_eq, Pi.zero_apply, RingHom.map_zero, Pi.zero_apply]
  · letI := Classical.decEq K
    obtain ⟨⟨b, hb⟩, ba_eq⟩ :=
      IsLocalization.exist_integer_multiples_of_finset (nonZeroDivisors A) (Finset.univ.image v)
    choose f hf using ba_eq
    refine'
      ⟨fun i => f _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩),
        mt (fun h => funext fun i => _) hv, _⟩
    · 

Proof state:
case mpr.intro.intro.intro.mk.refine'_1
n : Type u_1
inst✝⁹ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : Module R M✝
A : Type u_4
K : Type u_5
inst✝⁵ : DecidableEq n
inst✝⁴ : CommRing A
inst✝³ : Nontrivial A
inst✝² : Field K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
M : Matrix n n A
this✝ : (∃ v, v ≠ 0 ∧ mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0) ↔ det M = 0
v : n → K
hv : v ≠ 0
mul_eq : mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0
this : DecidableEq K := Classical.decEq K
b : A
hb : b ∈ nonZeroDivisors A
f : (a : K) → a ∈ Finset.image v Finset.univ → A
hf : ∀ (a : K) (a_1 : a ∈ Finset.image v Finset.univ), (algebraMap A K) (f a a_1) = ↑{ val := b, property := hb } • a
h : (fun i => f (v i) (_ : v i ∈ Finset.image v Finset.univ)) = 0
i : n
⊢ v i = OfNat.ofNat 0 i

Next tactic:
have := congr_arg (algebraMap A K) (congr_fun h i)
theorem exists_mulVec_eq_zero_iff' {A : Type*} (K : Type*) [DecidableEq n] [CommRing A]
    [Nontrivial A] [Field K] [Algebra A K] [IsFractionRing A K] {M : Matrix n n A} :
    (∃ v ≠ 0, M.mulVec v = 0) ↔ M.det = 0 := by
  have : (∃ v ≠ 0, mulVec ((algebraMap A K).mapMatrix M) v = 0) ↔ _ :=
    exists_mulVec_eq_zero_iff_aux
  rw [← RingHom.map_det, IsFractionRing.to_map_eq_zero_iff] at this
  refine' Iff.trans _ this; constructor <;> rintro ⟨v, hv, mul_eq⟩
  · refine' ⟨fun i => algebraMap _ _ (v i), mt (fun h => funext fun i => _) hv, _⟩
    · exact IsFractionRing.to_map_eq_zero_iff.mp (congr_fun h i)
    · ext i
      refine' (RingHom.map_mulVec _ _ _ i).symm.trans _
      rw [mul_eq, Pi.zero_apply, RingHom.map_zero, Pi.zero_apply]
  · letI := Classical.decEq K
    obtain ⟨⟨b, hb⟩, ba_eq⟩ :=
      IsLocalization.exist_integer_multiples_of_finset (nonZeroDivisors A) (Finset.univ.image v)
    choose f hf using ba_eq
    refine'
      ⟨fun i => f _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩),
        mt (fun h => funext fun i => _) hv, _⟩
    · have := congr_arg (algebraMap A K) (congr_fun h i)
      

Proof state:
case mpr.intro.intro.intro.mk.refine'_1
n : Type u_1
inst✝⁹ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : Module R M✝
A : Type u_4
K : Type u_5
inst✝⁵ : DecidableEq n
inst✝⁴ : CommRing A
inst✝³ : Nontrivial A
inst✝² : Field K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
M : Matrix n n A
this✝¹ : (∃ v, v ≠ 0 ∧ mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0) ↔ det M = 0
v : n → K
hv : v ≠ 0
mul_eq : mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0
this✝ : DecidableEq K := Classical.decEq K
b : A
hb : b ∈ nonZeroDivisors A
f : (a : K) → a ∈ Finset.image v Finset.univ → A
hf : ∀ (a : K) (a_1 : a ∈ Finset.image v Finset.univ), (algebraMap A K) (f a a_1) = ↑{ val := b, property := hb } • a
h : (fun i => f (v i) (_ : v i ∈ Finset.image v Finset.univ)) = 0
i : n
this : (algebraMap A K) (f (v i) (_ : v i ∈ Finset.image v Finset.univ)) = (algebraMap A K) (OfNat.ofNat 0 i)
⊢ v i = OfNat.ofNat 0 i

Next tactic:
rw [hf, Subtype.coe_mk, Pi.zero_apply, RingHom.map_zero, Algebra.smul_def, mul_eq_zero,
        IsFractionRing.to_map_eq_zero_iff] at this
theorem exists_mulVec_eq_zero_iff' {A : Type*} (K : Type*) [DecidableEq n] [CommRing A]
    [Nontrivial A] [Field K] [Algebra A K] [IsFractionRing A K] {M : Matrix n n A} :
    (∃ v ≠ 0, M.mulVec v = 0) ↔ M.det = 0 := by
  have : (∃ v ≠ 0, mulVec ((algebraMap A K).mapMatrix M) v = 0) ↔ _ :=
    exists_mulVec_eq_zero_iff_aux
  rw [← RingHom.map_det, IsFractionRing.to_map_eq_zero_iff] at this
  refine' Iff.trans _ this; constructor <;> rintro ⟨v, hv, mul_eq⟩
  · refine' ⟨fun i => algebraMap _ _ (v i), mt (fun h => funext fun i => _) hv, _⟩
    · exact IsFractionRing.to_map_eq_zero_iff.mp (congr_fun h i)
    · ext i
      refine' (RingHom.map_mulVec _ _ _ i).symm.trans _
      rw [mul_eq, Pi.zero_apply, RingHom.map_zero, Pi.zero_apply]
  · letI := Classical.decEq K
    obtain ⟨⟨b, hb⟩, ba_eq⟩ :=
      IsLocalization.exist_integer_multiples_of_finset (nonZeroDivisors A) (Finset.univ.image v)
    choose f hf using ba_eq
    refine'
      ⟨fun i => f _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩),
        mt (fun h => funext fun i => _) hv, _⟩
    · have := congr_arg (algebraMap A K) (congr_fun h i)
      rw [hf, Subtype.coe_mk, Pi.zero_apply, RingHom.map_zero, Algebra.smul_def, mul_eq_zero,
        IsFractionRing.to_map_eq_zero_iff] at this
      

Proof state:
case mpr.intro.intro.intro.mk.refine'_1
n : Type u_1
inst✝⁹ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : Module R M✝
A : Type u_4
K : Type u_5
inst✝⁵ : DecidableEq n
inst✝⁴ : CommRing A
inst✝³ : Nontrivial A
inst✝² : Field K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
M : Matrix n n A
this✝¹ : (∃ v, v ≠ 0 ∧ mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0) ↔ det M = 0
v : n → K
hv : v ≠ 0
mul_eq : mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0
this✝ : DecidableEq K := Classical.decEq K
b : A
hb : b ∈ nonZeroDivisors A
f : (a : K) → a ∈ Finset.image v Finset.univ → A
hf : ∀ (a : K) (a_1 : a ∈ Finset.image v Finset.univ), (algebraMap A K) (f a a_1) = ↑{ val := b, property := hb } • a
h : (fun i => f (v i) (_ : v i ∈ Finset.image v Finset.univ)) = 0
i : n
this : b = 0 ∨ v i = 0
⊢ v i = OfNat.ofNat 0 i

Next tactic:
exact this.resolve_left (nonZeroDivisors.ne_zero hb)
theorem exists_mulVec_eq_zero_iff' {A : Type*} (K : Type*) [DecidableEq n] [CommRing A]
    [Nontrivial A] [Field K] [Algebra A K] [IsFractionRing A K] {M : Matrix n n A} :
    (∃ v ≠ 0, M.mulVec v = 0) ↔ M.det = 0 := by
  have : (∃ v ≠ 0, mulVec ((algebraMap A K).mapMatrix M) v = 0) ↔ _ :=
    exists_mulVec_eq_zero_iff_aux
  rw [← RingHom.map_det, IsFractionRing.to_map_eq_zero_iff] at this
  refine' Iff.trans _ this; constructor <;> rintro ⟨v, hv, mul_eq⟩
  · refine' ⟨fun i => algebraMap _ _ (v i), mt (fun h => funext fun i => _) hv, _⟩
    · exact IsFractionRing.to_map_eq_zero_iff.mp (congr_fun h i)
    · ext i
      refine' (RingHom.map_mulVec _ _ _ i).symm.trans _
      rw [mul_eq, Pi.zero_apply, RingHom.map_zero, Pi.zero_apply]
  · letI := Classical.decEq K
    obtain ⟨⟨b, hb⟩, ba_eq⟩ :=
      IsLocalization.exist_integer_multiples_of_finset (nonZeroDivisors A) (Finset.univ.image v)
    choose f hf using ba_eq
    refine'
      ⟨fun i => f _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩),
        mt (fun h => funext fun i => _) hv, _⟩
    · have := congr_arg (algebraMap A K) (congr_fun h i)
      rw [hf, Subtype.coe_mk, Pi.zero_apply, RingHom.map_zero, Algebra.smul_def, mul_eq_zero,
        IsFractionRing.to_map_eq_zero_iff] at this
      exact this.resolve_left (nonZeroDivisors.ne_zero hb)
    · 

Proof state:
case mpr.intro.intro.intro.mk.refine'_2
n : Type u_1
inst✝⁹ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : Module R M✝
A : Type u_4
K : Type u_5
inst✝⁵ : DecidableEq n
inst✝⁴ : CommRing A
inst✝³ : Nontrivial A
inst✝² : Field K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
M : Matrix n n A
this✝ : (∃ v, v ≠ 0 ∧ mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0) ↔ det M = 0
v : n → K
hv : v ≠ 0
mul_eq : mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0
this : DecidableEq K := Classical.decEq K
b : A
hb : b ∈ nonZeroDivisors A
f : (a : K) → a ∈ Finset.image v Finset.univ → A
hf : ∀ (a : K) (a_1 : a ∈ Finset.image v Finset.univ), (algebraMap A K) (f a a_1) = ↑{ val := b, property := hb } • a
⊢ (mulVec M fun i => f (v i) (_ : v i ∈ Finset.image v Finset.univ)) = 0

Next tactic:
ext i
theorem exists_mulVec_eq_zero_iff' {A : Type*} (K : Type*) [DecidableEq n] [CommRing A]
    [Nontrivial A] [Field K] [Algebra A K] [IsFractionRing A K] {M : Matrix n n A} :
    (∃ v ≠ 0, M.mulVec v = 0) ↔ M.det = 0 := by
  have : (∃ v ≠ 0, mulVec ((algebraMap A K).mapMatrix M) v = 0) ↔ _ :=
    exists_mulVec_eq_zero_iff_aux
  rw [← RingHom.map_det, IsFractionRing.to_map_eq_zero_iff] at this
  refine' Iff.trans _ this; constructor <;> rintro ⟨v, hv, mul_eq⟩
  · refine' ⟨fun i => algebraMap _ _ (v i), mt (fun h => funext fun i => _) hv, _⟩
    · exact IsFractionRing.to_map_eq_zero_iff.mp (congr_fun h i)
    · ext i
      refine' (RingHom.map_mulVec _ _ _ i).symm.trans _
      rw [mul_eq, Pi.zero_apply, RingHom.map_zero, Pi.zero_apply]
  · letI := Classical.decEq K
    obtain ⟨⟨b, hb⟩, ba_eq⟩ :=
      IsLocalization.exist_integer_multiples_of_finset (nonZeroDivisors A) (Finset.univ.image v)
    choose f hf using ba_eq
    refine'
      ⟨fun i => f _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩),
        mt (fun h => funext fun i => _) hv, _⟩
    · have := congr_arg (algebraMap A K) (congr_fun h i)
      rw [hf, Subtype.coe_mk, Pi.zero_apply, RingHom.map_zero, Algebra.smul_def, mul_eq_zero,
        IsFractionRing.to_map_eq_zero_iff] at this
      exact this.resolve_left (nonZeroDivisors.ne_zero hb)
    · ext i
      

Proof state:
case mpr.intro.intro.intro.mk.refine'_2.h
n : Type u_1
inst✝⁹ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : Module R M✝
A : Type u_4
K : Type u_5
inst✝⁵ : DecidableEq n
inst✝⁴ : CommRing A
inst✝³ : Nontrivial A
inst✝² : Field K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
M : Matrix n n A
this✝ : (∃ v, v ≠ 0 ∧ mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0) ↔ det M = 0
v : n → K
hv : v ≠ 0
mul_eq : mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0
this : DecidableEq K := Classical.decEq K
b : A
hb : b ∈ nonZeroDivisors A
f : (a : K) → a ∈ Finset.image v Finset.univ → A
hf : ∀ (a : K) (a_1 : a ∈ Finset.image v Finset.univ), (algebraMap A K) (f a a_1) = ↑{ val := b, property := hb } • a
i : n
⊢ mulVec M (fun i => f (v i) (_ : v i ∈ Finset.image v Finset.univ)) i = OfNat.ofNat 0 i

Next tactic:
refine' IsFractionRing.injective A K _
theorem exists_mulVec_eq_zero_iff' {A : Type*} (K : Type*) [DecidableEq n] [CommRing A]
    [Nontrivial A] [Field K] [Algebra A K] [IsFractionRing A K] {M : Matrix n n A} :
    (∃ v ≠ 0, M.mulVec v = 0) ↔ M.det = 0 := by
  have : (∃ v ≠ 0, mulVec ((algebraMap A K).mapMatrix M) v = 0) ↔ _ :=
    exists_mulVec_eq_zero_iff_aux
  rw [← RingHom.map_det, IsFractionRing.to_map_eq_zero_iff] at this
  refine' Iff.trans _ this; constructor <;> rintro ⟨v, hv, mul_eq⟩
  · refine' ⟨fun i => algebraMap _ _ (v i), mt (fun h => funext fun i => _) hv, _⟩
    · exact IsFractionRing.to_map_eq_zero_iff.mp (congr_fun h i)
    · ext i
      refine' (RingHom.map_mulVec _ _ _ i).symm.trans _
      rw [mul_eq, Pi.zero_apply, RingHom.map_zero, Pi.zero_apply]
  · letI := Classical.decEq K
    obtain ⟨⟨b, hb⟩, ba_eq⟩ :=
      IsLocalization.exist_integer_multiples_of_finset (nonZeroDivisors A) (Finset.univ.image v)
    choose f hf using ba_eq
    refine'
      ⟨fun i => f _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩),
        mt (fun h => funext fun i => _) hv, _⟩
    · have := congr_arg (algebraMap A K) (congr_fun h i)
      rw [hf, Subtype.coe_mk, Pi.zero_apply, RingHom.map_zero, Algebra.smul_def, mul_eq_zero,
        IsFractionRing.to_map_eq_zero_iff] at this
      exact this.resolve_left (nonZeroDivisors.ne_zero hb)
    · ext i
      refine' IsFractionRing.injective A K _
      

Proof state:
case mpr.intro.intro.intro.mk.refine'_2.h
n : Type u_1
inst✝⁹ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : Module R M✝
A : Type u_4
K : Type u_5
inst✝⁵ : DecidableEq n
inst✝⁴ : CommRing A
inst✝³ : Nontrivial A
inst✝² : Field K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
M : Matrix n n A
this✝ : (∃ v, v ≠ 0 ∧ mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0) ↔ det M = 0
v : n → K
hv : v ≠ 0
mul_eq : mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0
this : DecidableEq K := Classical.decEq K
b : A
hb : b ∈ nonZeroDivisors A
f : (a : K) → a ∈ Finset.image v Finset.univ → A
hf : ∀ (a : K) (a_1 : a ∈ Finset.image v Finset.univ), (algebraMap A K) (f a a_1) = ↑{ val := b, property := hb } • a
i : n
⊢ (algebraMap A K) (mulVec M (fun i => f (v i) (_ : v i ∈ Finset.image v Finset.univ)) i) =
    (algebraMap A K) (OfNat.ofNat 0 i)

Next tactic:
calc
        algebraMap A K (M.mulVec (fun i : n => f (v i) _) i) =
            ((algebraMap A K).mapMatrix M).mulVec (algebraMap _ K b • v) i := ?_
        _ = 0 := ?_
        _ = algebraMap A K 0 := (RingHom.map_zero _).symm
theorem exists_mulVec_eq_zero_iff' {A : Type*} (K : Type*) [DecidableEq n] [CommRing A]
    [Nontrivial A] [Field K] [Algebra A K] [IsFractionRing A K] {M : Matrix n n A} :
    (∃ v ≠ 0, M.mulVec v = 0) ↔ M.det = 0 := by
  have : (∃ v ≠ 0, mulVec ((algebraMap A K).mapMatrix M) v = 0) ↔ _ :=
    exists_mulVec_eq_zero_iff_aux
  rw [← RingHom.map_det, IsFractionRing.to_map_eq_zero_iff] at this
  refine' Iff.trans _ this; constructor <;> rintro ⟨v, hv, mul_eq⟩
  · refine' ⟨fun i => algebraMap _ _ (v i), mt (fun h => funext fun i => _) hv, _⟩
    · exact IsFractionRing.to_map_eq_zero_iff.mp (congr_fun h i)
    · ext i
      refine' (RingHom.map_mulVec _ _ _ i).symm.trans _
      rw [mul_eq, Pi.zero_apply, RingHom.map_zero, Pi.zero_apply]
  · letI := Classical.decEq K
    obtain ⟨⟨b, hb⟩, ba_eq⟩ :=
      IsLocalization.exist_integer_multiples_of_finset (nonZeroDivisors A) (Finset.univ.image v)
    choose f hf using ba_eq
    refine'
      ⟨fun i => f _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩),
        mt (fun h => funext fun i => _) hv, _⟩
    · have := congr_arg (algebraMap A K) (congr_fun h i)
      rw [hf, Subtype.coe_mk, Pi.zero_apply, RingHom.map_zero, Algebra.smul_def, mul_eq_zero,
        IsFractionRing.to_map_eq_zero_iff] at this
      exact this.resolve_left (nonZeroDivisors.ne_zero hb)
    · ext i
      refine' IsFractionRing.injective A K _
      calc
        algebraMap A K (M.mulVec (fun i : n => f (v i) _) i) =
            ((algebraMap A K).mapMatrix M).mulVec (algebraMap _ K b • v) i := ?_
        _ = 0 := ?_
        _ = algebraMap A K 0 := (RingHom.map_zero _).symm
      · 

Proof state:
case mpr.intro.intro.intro.mk.refine'_2.h.calc_1
n : Type u_1
inst✝⁹ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : Module R M✝
A : Type u_4
K : Type u_5
inst✝⁵ : DecidableEq n
inst✝⁴ : CommRing A
inst✝³ : Nontrivial A
inst✝² : Field K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
M : Matrix n n A
this✝ : (∃ v, v ≠ 0 ∧ mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0) ↔ det M = 0
v : n → K
hv : v ≠ 0
mul_eq : mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0
this : DecidableEq K := Classical.decEq K
b : A
hb : b ∈ nonZeroDivisors A
f : (a : K) → a ∈ Finset.image v Finset.univ → A
hf : ∀ (a : K) (a_1 : a ∈ Finset.image v Finset.univ), (algebraMap A K) (f a a_1) = ↑{ val := b, property := hb } • a
i : n
⊢ (algebraMap A K) (mulVec M (fun i => f (v i) (_ : v i ∈ Finset.image v Finset.univ)) i) =
    mulVec ((RingHom.mapMatrix (algebraMap A K)) M) ((algebraMap A K) b • v) i

Next tactic:
simp_rw [RingHom.map_mulVec, mulVec, dotProduct, Function.comp_apply, hf,
          RingHom.mapMatrix_apply, Pi.smul_apply, smul_eq_mul, Algebra.smul_def]
theorem exists_mulVec_eq_zero_iff' {A : Type*} (K : Type*) [DecidableEq n] [CommRing A]
    [Nontrivial A] [Field K] [Algebra A K] [IsFractionRing A K] {M : Matrix n n A} :
    (∃ v ≠ 0, M.mulVec v = 0) ↔ M.det = 0 := by
  have : (∃ v ≠ 0, mulVec ((algebraMap A K).mapMatrix M) v = 0) ↔ _ :=
    exists_mulVec_eq_zero_iff_aux
  rw [← RingHom.map_det, IsFractionRing.to_map_eq_zero_iff] at this
  refine' Iff.trans _ this; constructor <;> rintro ⟨v, hv, mul_eq⟩
  · refine' ⟨fun i => algebraMap _ _ (v i), mt (fun h => funext fun i => _) hv, _⟩
    · exact IsFractionRing.to_map_eq_zero_iff.mp (congr_fun h i)
    · ext i
      refine' (RingHom.map_mulVec _ _ _ i).symm.trans _
      rw [mul_eq, Pi.zero_apply, RingHom.map_zero, Pi.zero_apply]
  · letI := Classical.decEq K
    obtain ⟨⟨b, hb⟩, ba_eq⟩ :=
      IsLocalization.exist_integer_multiples_of_finset (nonZeroDivisors A) (Finset.univ.image v)
    choose f hf using ba_eq
    refine'
      ⟨fun i => f _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩),
        mt (fun h => funext fun i => _) hv, _⟩
    · have := congr_arg (algebraMap A K) (congr_fun h i)
      rw [hf, Subtype.coe_mk, Pi.zero_apply, RingHom.map_zero, Algebra.smul_def, mul_eq_zero,
        IsFractionRing.to_map_eq_zero_iff] at this
      exact this.resolve_left (nonZeroDivisors.ne_zero hb)
    · ext i
      refine' IsFractionRing.injective A K _
      calc
        algebraMap A K (M.mulVec (fun i : n => f (v i) _) i) =
            ((algebraMap A K).mapMatrix M).mulVec (algebraMap _ K b • v) i := ?_
        _ = 0 := ?_
        _ = algebraMap A K 0 := (RingHom.map_zero _).symm
      · simp_rw [RingHom.map_mulVec, mulVec, dotProduct, Function.comp_apply, hf,
          RingHom.mapMatrix_apply, Pi.smul_apply, smul_eq_mul, Algebra.smul_def]
      · 

Proof state:
case mpr.intro.intro.intro.mk.refine'_2.h.calc_2
n : Type u_1
inst✝⁹ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : Module R M✝
A : Type u_4
K : Type u_5
inst✝⁵ : DecidableEq n
inst✝⁴ : CommRing A
inst✝³ : Nontrivial A
inst✝² : Field K
inst✝¹ : Algebra A K
inst✝ : IsFractionRing A K
M : Matrix n n A
this✝ : (∃ v, v ≠ 0 ∧ mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0) ↔ det M = 0
v : n → K
hv : v ≠ 0
mul_eq : mulVec ((RingHom.mapMatrix (algebraMap A K)) M) v = 0
this : DecidableEq K := Classical.decEq K
b : A
hb : b ∈ nonZeroDivisors A
f : (a : K) → a ∈ Finset.image v Finset.univ → A
hf : ∀ (a : K) (a_1 : a ∈ Finset.image v Finset.univ), (algebraMap A K) (f a a_1) = ↑{ val := b, property := hb } • a
i : n
⊢ mulVec ((RingHom.mapMatrix (algebraMap A K)) M) ((algebraMap A K) b • v) i = 0

Next tactic:
rw [mulVec_smul, mul_eq, Pi.smul_apply, Pi.zero_apply, smul_zero]
theorem exists_vecMul_eq_zero_iff {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
    {M : Matrix n n A} : (∃ v ≠ 0, M.vecMul v = 0) ↔ M.det = 0 := by
  

Proof state:
n : Type u_1
inst✝⁶ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M✝
inst✝³ : Module R M✝
A : Type u_4
inst✝² : DecidableEq n
inst✝¹ : CommRing A
inst✝ : IsDomain A
M : Matrix n n A
⊢ (∃ v, v ≠ 0 ∧ vecMul v M = 0) ↔ det M = 0

Next tactic:
simpa only [← M.det_transpose, ← mulVec_transpose] using exists_mulVec_eq_zero_iff
theorem nondegenerate_iff_det_ne_zero {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
    {M : Matrix n n A} : Nondegenerate M ↔ M.det ≠ 0 := by
  

Proof state:
n : Type u_1
inst✝⁶ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M✝
inst✝³ : Module R M✝
A : Type u_4
inst✝² : DecidableEq n
inst✝¹ : CommRing A
inst✝ : IsDomain A
M : Matrix n n A
⊢ Nondegenerate M ↔ det M ≠ 0

Next tactic:
rw [ne_eq, ← exists_vecMul_eq_zero_iff]
theorem nondegenerate_iff_det_ne_zero {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
    {M : Matrix n n A} : Nondegenerate M ↔ M.det ≠ 0 := by
  rw [ne_eq, ← exists_vecMul_eq_zero_iff]
  

Proof state:
n : Type u_1
inst✝⁶ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M✝
inst✝³ : Module R M✝
A : Type u_4
inst✝² : DecidableEq n
inst✝¹ : CommRing A
inst✝ : IsDomain A
M : Matrix n n A
⊢ Nondegenerate M ↔ ¬∃ v, v ≠ 0 ∧ vecMul v M = 0

Next tactic:
push_neg
theorem nondegenerate_iff_det_ne_zero {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
    {M : Matrix n n A} : Nondegenerate M ↔ M.det ≠ 0 := by
  rw [ne_eq, ← exists_vecMul_eq_zero_iff]
  push_neg
  

Proof state:
n : Type u_1
inst✝⁶ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M✝
inst✝³ : Module R M✝
A : Type u_4
inst✝² : DecidableEq n
inst✝¹ : CommRing A
inst✝ : IsDomain A
M : Matrix n n A
⊢ Nondegenerate M ↔ ∀ (v : n → A), v ≠ 0 → vecMul v M ≠ 0

Next tactic:
constructor
theorem nondegenerate_iff_det_ne_zero {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
    {M : Matrix n n A} : Nondegenerate M ↔ M.det ≠ 0 := by
  rw [ne_eq, ← exists_vecMul_eq_zero_iff]
  push_neg
  constructor
  · 

Proof state:
case mp
n : Type u_1
inst✝⁶ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M✝
inst✝³ : Module R M✝
A : Type u_4
inst✝² : DecidableEq n
inst✝¹ : CommRing A
inst✝ : IsDomain A
M : Matrix n n A
⊢ Nondegenerate M → ∀ (v : n → A), v ≠ 0 → vecMul v M ≠ 0

Next tactic:
intro hM v hv hMv
theorem nondegenerate_iff_det_ne_zero {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
    {M : Matrix n n A} : Nondegenerate M ↔ M.det ≠ 0 := by
  rw [ne_eq, ← exists_vecMul_eq_zero_iff]
  push_neg
  constructor
  · intro hM v hv hMv
    

Proof state:
case mp
n : Type u_1
inst✝⁶ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M✝
inst✝³ : Module R M✝
A : Type u_4
inst✝² : DecidableEq n
inst✝¹ : CommRing A
inst✝ : IsDomain A
M : Matrix n n A
hM : Nondegenerate M
v : n → A
hv : v ≠ 0
hMv : vecMul v M = 0
⊢ False

Next tactic:
obtain ⟨w, hwMv⟩ := hM.exists_not_ortho_of_ne_zero hv
theorem nondegenerate_iff_det_ne_zero {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
    {M : Matrix n n A} : Nondegenerate M ↔ M.det ≠ 0 := by
  rw [ne_eq, ← exists_vecMul_eq_zero_iff]
  push_neg
  constructor
  · intro hM v hv hMv
    obtain ⟨w, hwMv⟩ := hM.exists_not_ortho_of_ne_zero hv
    

Proof state:
case mp.intro
n : Type u_1
inst✝⁶ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M✝
inst✝³ : Module R M✝
A : Type u_4
inst✝² : DecidableEq n
inst✝¹ : CommRing A
inst✝ : IsDomain A
M : Matrix n n A
hM : Nondegenerate M
v : n → A
hv : v ≠ 0
hMv : vecMul v M = 0
w : n → A
hwMv : v ⬝ᵥ mulVec M w ≠ 0
⊢ False

Next tactic:
simp [dotProduct_mulVec, hMv, zero_dotProduct, ne_eq, not_true] at hwMv
theorem nondegenerate_iff_det_ne_zero {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
    {M : Matrix n n A} : Nondegenerate M ↔ M.det ≠ 0 := by
  rw [ne_eq, ← exists_vecMul_eq_zero_iff]
  push_neg
  constructor
  · intro hM v hv hMv
    obtain ⟨w, hwMv⟩ := hM.exists_not_ortho_of_ne_zero hv
    simp [dotProduct_mulVec, hMv, zero_dotProduct, ne_eq, not_true] at hwMv
  · 

Proof state:
case mpr
n : Type u_1
inst✝⁶ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M✝
inst✝³ : Module R M✝
A : Type u_4
inst✝² : DecidableEq n
inst✝¹ : CommRing A
inst✝ : IsDomain A
M : Matrix n n A
⊢ (∀ (v : n → A), v ≠ 0 → vecMul v M ≠ 0) → Nondegenerate M

Next tactic:
intro h v hv
theorem nondegenerate_iff_det_ne_zero {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
    {M : Matrix n n A} : Nondegenerate M ↔ M.det ≠ 0 := by
  rw [ne_eq, ← exists_vecMul_eq_zero_iff]
  push_neg
  constructor
  · intro hM v hv hMv
    obtain ⟨w, hwMv⟩ := hM.exists_not_ortho_of_ne_zero hv
    simp [dotProduct_mulVec, hMv, zero_dotProduct, ne_eq, not_true] at hwMv
  · intro h v hv
    

Proof state:
case mpr
n : Type u_1
inst✝⁶ : Fintype n
R : Type u_2
M✝ : Type u_3
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M✝
inst✝³ : Module R M✝
A : Type u_4
inst✝² : DecidableEq n
inst✝¹ : CommRing A
inst✝ : IsDomain A
M : Matrix n n A
h : ∀ (v : n → A), v ≠ 0 → vecMul v M ≠ 0
v : n → A
hv : ∀ (w : n → A), v ⬝ᵥ mulVec M w = 0
⊢ v = 0

Next tactic:
refine' not_imp_not.mp (h v) (funext fun i => _)