l3lab/ntp-mathlib huggingface dataset:
/-- If two vectors `x` and `y` are linearly independent, so are their linear combinations
`a x + b y` and `c x + d y` provided the determinant `a * d - b * c` is nonzero. -/
lemma LinearIndependent.linear_combination_pair_of_det_ne_zero {R M : Type*} [CommRing R]
    [NoZeroDivisors R] [AddCommGroup M] [Module R M]
    {x y : M} (h : LinearIndependent R ![x, y])
    {a b c d : R} (h' : a * d - b * c ≠ 0) :
    LinearIndependent R ![a • x + b • y, c • x + d • y] := by
  apply LinearIndependent.pair_iff.2 (fun s t hst ↦ ?_)
  have H : (s * a + t * c) • x + (s * b + t * d) • y = 0 := by
    convert hst using 1
    simp only [_root_.add_smul, smul_add, smul_smul]
    abel
  

Proof state:
ι : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a✝ b✝ : R✝
x✝ y✝ : M✝
R : Type u_8
M : Type u_9
inst✝³ : CommRing R
inst✝² : NoZeroDivisors R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
x y : M
h : LinearIndependent R ![x, y]
a b c d : R
h' : a * d - b * c ≠ 0
s t : R
hst : s • (a • x + b • y) + t • (c • x + d • y) = 0
H : (s * a + t * c) • x + (s * b + t * d) • y = 0
⊢ s = 0 ∧ t = 0

Next tactic:
have I1 : s * a + t * c = 0 := (h.eq_zero_of_pair H).1
/-- If two vectors `x` and `y` are linearly independent, so are their linear combinations
`a x + b y` and `c x + d y` provided the determinant `a * d - b * c` is nonzero. -/
lemma LinearIndependent.linear_combination_pair_of_det_ne_zero {R M : Type*} [CommRing R]
    [NoZeroDivisors R] [AddCommGroup M] [Module R M]
    {x y : M} (h : LinearIndependent R ![x, y])
    {a b c d : R} (h' : a * d - b * c ≠ 0) :
    LinearIndependent R ![a • x + b • y, c • x + d • y] := by
  apply LinearIndependent.pair_iff.2 (fun s t hst ↦ ?_)
  have H : (s * a + t * c) • x + (s * b + t * d) • y = 0 := by
    convert hst using 1
    simp only [_root_.add_smul, smul_add, smul_smul]
    abel
  have I1 : s * a + t * c = 0 := (h.eq_zero_of_pair H).1
  

Proof state:
ι : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a✝ b✝ : R✝
x✝ y✝ : M✝
R : Type u_8
M : Type u_9
inst✝³ : CommRing R
inst✝² : NoZeroDivisors R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
x y : M
h : LinearIndependent R ![x, y]
a b c d : R
h' : a * d - b * c ≠ 0
s t : R
hst : s • (a • x + b • y) + t • (c • x + d • y) = 0
H : (s * a + t * c) • x + (s * b + t * d) • y = 0
I1 : s * a + t * c = 0
⊢ s = 0 ∧ t = 0

Next tactic:
have I2 : s * b + t * d = 0 := (h.eq_zero_of_pair H).2
/-- If two vectors `x` and `y` are linearly independent, so are their linear combinations
`a x + b y` and `c x + d y` provided the determinant `a * d - b * c` is nonzero. -/
lemma LinearIndependent.linear_combination_pair_of_det_ne_zero {R M : Type*} [CommRing R]
    [NoZeroDivisors R] [AddCommGroup M] [Module R M]
    {x y : M} (h : LinearIndependent R ![x, y])
    {a b c d : R} (h' : a * d - b * c ≠ 0) :
    LinearIndependent R ![a • x + b • y, c • x + d • y] := by
  apply LinearIndependent.pair_iff.2 (fun s t hst ↦ ?_)
  have H : (s * a + t * c) • x + (s * b + t * d) • y = 0 := by
    convert hst using 1
    simp only [_root_.add_smul, smul_add, smul_smul]
    abel
  have I1 : s * a + t * c = 0 := (h.eq_zero_of_pair H).1
  have I2 : s * b + t * d = 0 := (h.eq_zero_of_pair H).2
  

Proof state:
ι : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a✝ b✝ : R✝
x✝ y✝ : M✝
R : Type u_8
M : Type u_9
inst✝³ : CommRing R
inst✝² : NoZeroDivisors R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
x y : M
h : LinearIndependent R ![x, y]
a b c d : R
h' : a * d - b * c ≠ 0
s t : R
hst : s • (a • x + b • y) + t • (c • x + d • y) = 0
H : (s * a + t * c) • x + (s * b + t * d) • y = 0
I1 : s * a + t * c = 0
I2 : s * b + t * d = 0
⊢ s = 0 ∧ t = 0

Next tactic:
have J1 : (a * d - b * c) * s = 0 := by linear_combination d * I1 - c * I2
/-- If two vectors `x` and `y` are linearly independent, so are their linear combinations
`a x + b y` and `c x + d y` provided the determinant `a * d - b * c` is nonzero. -/
lemma LinearIndependent.linear_combination_pair_of_det_ne_zero {R M : Type*} [CommRing R]
    [NoZeroDivisors R] [AddCommGroup M] [Module R M]
    {x y : M} (h : LinearIndependent R ![x, y])
    {a b c d : R} (h' : a * d - b * c ≠ 0) :
    LinearIndependent R ![a • x + b • y, c • x + d • y] := by
  apply LinearIndependent.pair_iff.2 (fun s t hst ↦ ?_)
  have H : (s * a + t * c) • x + (s * b + t * d) • y = 0 := by
    convert hst using 1
    simp only [_root_.add_smul, smul_add, smul_smul]
    abel
  have I1 : s * a + t * c = 0 := (h.eq_zero_of_pair H).1
  have I2 : s * b + t * d = 0 := (h.eq_zero_of_pair H).2
  have J1 : (a * d - b * c) * s = 0 := by 

Proof state:
ι : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a✝ b✝ : R✝
x✝ y✝ : M✝
R : Type u_8
M : Type u_9
inst✝³ : CommRing R
inst✝² : NoZeroDivisors R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
x y : M
h : LinearIndependent R ![x, y]
a b c d : R
h' : a * d - b * c ≠ 0
s t : R
hst : s • (a • x + b • y) + t • (c • x + d • y) = 0
H : (s * a + t * c) • x + (s * b + t * d) • y = 0
I1 : s * a + t * c = 0
I2 : s * b + t * d = 0
⊢ (a * d - b * c) * s = 0

Next tactic:
linear_combination d * I1 - c * I2
/-- If two vectors `x` and `y` are linearly independent, so are their linear combinations
`a x + b y` and `c x + d y` provided the determinant `a * d - b * c` is nonzero. -/
lemma LinearIndependent.linear_combination_pair_of_det_ne_zero {R M : Type*} [CommRing R]
    [NoZeroDivisors R] [AddCommGroup M] [Module R M]
    {x y : M} (h : LinearIndependent R ![x, y])
    {a b c d : R} (h' : a * d - b * c ≠ 0) :
    LinearIndependent R ![a • x + b • y, c • x + d • y] := by
  apply LinearIndependent.pair_iff.2 (fun s t hst ↦ ?_)
  have H : (s * a + t * c) • x + (s * b + t * d) • y = 0 := by
    convert hst using 1
    simp only [_root_.add_smul, smul_add, smul_smul]
    abel
  have I1 : s * a + t * c = 0 := (h.eq_zero_of_pair H).1
  have I2 : s * b + t * d = 0 := (h.eq_zero_of_pair H).2
  have J1 : (a * d - b * c) * s = 0 := by linear_combination d * I1 - c * I2
  

Proof state:
ι : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a✝ b✝ : R✝
x✝ y✝ : M✝
R : Type u_8
M : Type u_9
inst✝³ : CommRing R
inst✝² : NoZeroDivisors R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
x y : M
h : LinearIndependent R ![x, y]
a b c d : R
h' : a * d - b * c ≠ 0
s t : R
hst : s • (a • x + b • y) + t • (c • x + d • y) = 0
H : (s * a + t * c) • x + (s * b + t * d) • y = 0
I1 : s * a + t * c = 0
I2 : s * b + t * d = 0
J1 : (a * d - b * c) * s = 0
⊢ s = 0 ∧ t = 0

Next tactic:
have J2 : (a * d - b * c) * t = 0 := by linear_combination -b * I1 + a * I2
/-- If two vectors `x` and `y` are linearly independent, so are their linear combinations
`a x + b y` and `c x + d y` provided the determinant `a * d - b * c` is nonzero. -/
lemma LinearIndependent.linear_combination_pair_of_det_ne_zero {R M : Type*} [CommRing R]
    [NoZeroDivisors R] [AddCommGroup M] [Module R M]
    {x y : M} (h : LinearIndependent R ![x, y])
    {a b c d : R} (h' : a * d - b * c ≠ 0) :
    LinearIndependent R ![a • x + b • y, c • x + d • y] := by
  apply LinearIndependent.pair_iff.2 (fun s t hst ↦ ?_)
  have H : (s * a + t * c) • x + (s * b + t * d) • y = 0 := by
    convert hst using 1
    simp only [_root_.add_smul, smul_add, smul_smul]
    abel
  have I1 : s * a + t * c = 0 := (h.eq_zero_of_pair H).1
  have I2 : s * b + t * d = 0 := (h.eq_zero_of_pair H).2
  have J1 : (a * d - b * c) * s = 0 := by linear_combination d * I1 - c * I2
  have J2 : (a * d - b * c) * t = 0 := by 

Proof state:
ι : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a✝ b✝ : R✝
x✝ y✝ : M✝
R : Type u_8
M : Type u_9
inst✝³ : CommRing R
inst✝² : NoZeroDivisors R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
x y : M
h : LinearIndependent R ![x, y]
a b c d : R
h' : a * d - b * c ≠ 0
s t : R
hst : s • (a • x + b • y) + t • (c • x + d • y) = 0
H : (s * a + t * c) • x + (s * b + t * d) • y = 0
I1 : s * a + t * c = 0
I2 : s * b + t * d = 0
J1 : (a * d - b * c) * s = 0
⊢ (a * d - b * c) * t = 0

Next tactic:
linear_combination -b * I1 + a * I2
/-- If two vectors `x` and `y` are linearly independent, so are their linear combinations
`a x + b y` and `c x + d y` provided the determinant `a * d - b * c` is nonzero. -/
lemma LinearIndependent.linear_combination_pair_of_det_ne_zero {R M : Type*} [CommRing R]
    [NoZeroDivisors R] [AddCommGroup M] [Module R M]
    {x y : M} (h : LinearIndependent R ![x, y])
    {a b c d : R} (h' : a * d - b * c ≠ 0) :
    LinearIndependent R ![a • x + b • y, c • x + d • y] := by
  apply LinearIndependent.pair_iff.2 (fun s t hst ↦ ?_)
  have H : (s * a + t * c) • x + (s * b + t * d) • y = 0 := by
    convert hst using 1
    simp only [_root_.add_smul, smul_add, smul_smul]
    abel
  have I1 : s * a + t * c = 0 := (h.eq_zero_of_pair H).1
  have I2 : s * b + t * d = 0 := (h.eq_zero_of_pair H).2
  have J1 : (a * d - b * c) * s = 0 := by linear_combination d * I1 - c * I2
  have J2 : (a * d - b * c) * t = 0 := by linear_combination -b * I1 + a * I2
  

Proof state:
ι : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a✝ b✝ : R✝
x✝ y✝ : M✝
R : Type u_8
M : Type u_9
inst✝³ : CommRing R
inst✝² : NoZeroDivisors R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
x y : M
h : LinearIndependent R ![x, y]
a b c d : R
h' : a * d - b * c ≠ 0
s t : R
hst : s • (a • x + b • y) + t • (c • x + d • y) = 0
H : (s * a + t * c) • x + (s * b + t * d) • y = 0
I1 : s * a + t * c = 0
I2 : s * b + t * d = 0
J1 : (a * d - b * c) * s = 0
J2 : (a * d - b * c) * t = 0
⊢ s = 0 ∧ t = 0

Next tactic:
exact ⟨by simpa [h'] using mul_eq_zero.1 J1, by simpa [h'] using mul_eq_zero.1 J2⟩
/-- If two vectors `x` and `y` are linearly independent, so are their linear combinations
`a x + b y` and `c x + d y` provided the determinant `a * d - b * c` is nonzero. -/
lemma LinearIndependent.linear_combination_pair_of_det_ne_zero {R M : Type*} [CommRing R]
    [NoZeroDivisors R] [AddCommGroup M] [Module R M]
    {x y : M} (h : LinearIndependent R ![x, y])
    {a b c d : R} (h' : a * d - b * c ≠ 0) :
    LinearIndependent R ![a • x + b • y, c • x + d • y] := by
  apply LinearIndependent.pair_iff.2 (fun s t hst ↦ ?_)
  have H : (s * a + t * c) • x + (s * b + t * d) • y = 0 := by
    convert hst using 1
    simp only [_root_.add_smul, smul_add, smul_smul]
    abel
  have I1 : s * a + t * c = 0 := (h.eq_zero_of_pair H).1
  have I2 : s * b + t * d = 0 := (h.eq_zero_of_pair H).2
  have J1 : (a * d - b * c) * s = 0 := by linear_combination d * I1 - c * I2
  have J2 : (a * d - b * c) * t = 0 := by linear_combination -b * I1 + a * I2
  exact ⟨by 

Proof state:
ι : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a✝ b✝ : R✝
x✝ y✝ : M✝
R : Type u_8
M : Type u_9
inst✝³ : CommRing R
inst✝² : NoZeroDivisors R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
x y : M
h : LinearIndependent R ![x, y]
a b c d : R
h' : a * d - b * c ≠ 0
s t : R
hst : s • (a • x + b • y) + t • (c • x + d • y) = 0
H : (s * a + t * c) • x + (s * b + t * d) • y = 0
I1 : s * a + t * c = 0
I2 : s * b + t * d = 0
J1 : (a * d - b * c) * s = 0
J2 : (a * d - b * c) * t = 0
⊢ s = 0

Next tactic:
simpa [h'] using mul_eq_zero.1 J1
/-- If two vectors `x` and `y` are linearly independent, so are their linear combinations
`a x + b y` and `c x + d y` provided the determinant `a * d - b * c` is nonzero. -/
lemma LinearIndependent.linear_combination_pair_of_det_ne_zero {R M : Type*} [CommRing R]
    [NoZeroDivisors R] [AddCommGroup M] [Module R M]
    {x y : M} (h : LinearIndependent R ![x, y])
    {a b c d : R} (h' : a * d - b * c ≠ 0) :
    LinearIndependent R ![a • x + b • y, c • x + d • y] := by
  apply LinearIndependent.pair_iff.2 (fun s t hst ↦ ?_)
  have H : (s * a + t * c) • x + (s * b + t * d) • y = 0 := by
    convert hst using 1
    simp only [_root_.add_smul, smul_add, smul_smul]
    abel
  have I1 : s * a + t * c = 0 := (h.eq_zero_of_pair H).1
  have I2 : s * b + t * d = 0 := (h.eq_zero_of_pair H).2
  have J1 : (a * d - b * c) * s = 0 := by linear_combination d * I1 - c * I2
  have J2 : (a * d - b * c) * t = 0 := by linear_combination -b * I1 + a * I2
  exact ⟨by simpa [h'] using mul_eq_zero.1 J1, by 

Proof state:
ι : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a✝ b✝ : R✝
x✝ y✝ : M✝
R : Type u_8
M : Type u_9
inst✝³ : CommRing R
inst✝² : NoZeroDivisors R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
x y : M
h : LinearIndependent R ![x, y]
a b c d : R
h' : a * d - b * c ≠ 0
s t : R
hst : s • (a • x + b • y) + t • (c • x + d • y) = 0
H : (s * a + t * c) • x + (s * b + t * d) • y = 0
I1 : s * a + t * c = 0
I2 : s * b + t * d = 0
J1 : (a * d - b * c) * s = 0
J2 : (a * d - b * c) * t = 0
⊢ t = 0

Next tactic:
simpa [h'] using mul_eq_zero.1 J2
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  

Proof state:
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
i : LinearIndependent R v
⊢ Maximal i ↔ ∀ (κ : Type v) (w : κ → M), LinearIndependent R w → ∀ (j : ι → κ), w ∘ j = v → Surjective j

Next tactic:
constructor
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · 

Proof state:
case mp
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
i : LinearIndependent R v
⊢ Maximal i → ∀ (κ : Type v) (w : κ → M), LinearIndependent R w → ∀ (j : ι → κ), w ∘ j = v → Surjective j

Next tactic:
rintro p κ w i' j rfl
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    

Proof state:
case mp
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
κ : Type v
w : κ → M
i' : LinearIndependent R w
j : ι → κ
i : LinearIndependent R (w ∘ j)
p : Maximal i
⊢ Surjective j

Next tactic:
specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
    

Proof state:
case mp
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
κ : Type v
w : κ → M
i' : LinearIndependent R w
j : ι → κ
i : LinearIndependent R (w ∘ j)
p : range (w ∘ j) = range w
⊢ Surjective j

Next tactic:
rw [range_comp, ← image_univ (f := w)] at p
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
    rw [range_comp, ← image_univ (f := w)] at p
    

Proof state:
case mp
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
κ : Type v
w : κ → M
i' : LinearIndependent R w
j : ι → κ
i : LinearIndependent R (w ∘ j)
p : w '' range j = w '' univ
⊢ Surjective j

Next tactic:
exact range_iff_surjective.mp (image_injective.mpr i'.injective p)
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
    rw [range_comp, ← image_univ (f := w)] at p
    exact range_iff_surjective.mp (image_injective.mpr i'.injective p)
  · 

Proof state:
case mpr
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
i : LinearIndependent R v
⊢ (∀ (κ : Type v) (w : κ → M), LinearIndependent R w → ∀ (j : ι → κ), w ∘ j = v → Surjective j) → Maximal i

Next tactic:
intro p w i' h
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
    rw [range_comp, ← image_univ (f := w)] at p
    exact range_iff_surjective.mp (image_injective.mpr i'.injective p)
  · intro p w i' h
    

Proof state:
case mpr
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
i : LinearIndependent R v
p : ∀ (κ : Type v) (w : κ → M), LinearIndependent R w → ∀ (j : ι → κ), w ∘ j = v → Surjective j
w : Set M
i' : LinearIndependent (ι := { x // x ∈ w }) R Subtype.val
h : range v ≤ w
⊢ range v = w

Next tactic:
specialize
      p w ((↑) : w → M) i' (fun i => ⟨v i, range_subset_iff.mp h i⟩)
        (by
          ext
          simp)