l3lab/ntp-mathlib huggingface dataset:
theorem surjective_of_linearIndependent_of_span [Nontrivial R] (hv : LinearIndependent R v)
    (f : ι' ↪ ι) (hss : range v ⊆ span R (range (v ∘ f))) : Surjective f := by
  intro i
  let repr : (span R (range (v ∘ f)) : Type _) → ι' →₀ R := (hv.comp f f.injective).repr
  let l := (repr ⟨v i, hss (mem_range_self i)⟩).mapDomain f
  have h_total_l : Finsupp.total ι M R v l = v i := by
    dsimp only []
    rw [Finsupp.total_mapDomain]
    rw [(hv.comp f f.injective).total_repr]
    -- Porting note: `rfl` isn't necessary.
  have h_total_eq : (Finsupp.total ι M R v) l = (Finsupp.total ι M R v) (Finsupp.single i 1) := by
    rw [h_total_l, Finsupp.total_single, one_smul]
  have l_eq : l = _ := LinearMap.ker_eq_bot.1 hv h_total_eq
  dsimp only [] at l_eq
  rw [← Finsupp.embDomain_eq_mapDomain] at l_eq
  

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
inst✝ : Nontrivial R
hv : LinearIndependent R v
f : ι' ↪ ι
hss : range v ⊆ ↑(span R (range (v ∘ ⇑f)))
i : ι
repr : ↥(span R (range (v ∘ ⇑f))) → ι' →₀ R := ⇑(LinearIndependent.repr (_ : LinearIndependent R (v ∘ ⇑f)))
l : ι →₀ R := Finsupp.mapDomain (⇑f) (repr { val := v i, property := (_ : v i ∈ ↑(span R (range (v ∘ ⇑f)))) })
h_total_l : (Finsupp.total ι M R v) l = v i
h_total_eq : (Finsupp.total ι M R v) l = (Finsupp.total ι M R v) fun₀ | i => 1
l_eq :
  Finsupp.embDomain f
      ((LinearIndependent.repr (_ : LinearIndependent R (v ∘ ⇑f)))
        { val := v i, property := (_ : v i ∈ ↑(span R (range (v ∘ ⇑f)))) }) =
    fun₀ | i => 1
⊢ ∃ a, f a = i

Next tactic:
rcases Finsupp.single_of_embDomain_single (repr ⟨v i, _⟩) f i (1 : R) zero_ne_one.symm l_eq with
    ⟨i', hi'⟩
theorem surjective_of_linearIndependent_of_span [Nontrivial R] (hv : LinearIndependent R v)
    (f : ι' ↪ ι) (hss : range v ⊆ span R (range (v ∘ f))) : Surjective f := by
  intro i
  let repr : (span R (range (v ∘ f)) : Type _) → ι' →₀ R := (hv.comp f f.injective).repr
  let l := (repr ⟨v i, hss (mem_range_self i)⟩).mapDomain f
  have h_total_l : Finsupp.total ι M R v l = v i := by
    dsimp only []
    rw [Finsupp.total_mapDomain]
    rw [(hv.comp f f.injective).total_repr]
    -- Porting note: `rfl` isn't necessary.
  have h_total_eq : (Finsupp.total ι M R v) l = (Finsupp.total ι M R v) (Finsupp.single i 1) := by
    rw [h_total_l, Finsupp.total_single, one_smul]
  have l_eq : l = _ := LinearMap.ker_eq_bot.1 hv h_total_eq
  dsimp only [] at l_eq
  rw [← Finsupp.embDomain_eq_mapDomain] at l_eq
  rcases Finsupp.single_of_embDomain_single (repr ⟨v i, _⟩) f i (1 : R) zero_ne_one.symm l_eq with
    ⟨i', hi'⟩
  

Proof state:
case intro
ι : 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
inst✝ : Nontrivial R
hv : LinearIndependent R v
f : ι' ↪ ι
hss : range v ⊆ ↑(span R (range (v ∘ ⇑f)))
i : ι
repr : ↥(span R (range (v ∘ ⇑f))) → ι' →₀ R := ⇑(LinearIndependent.repr (_ : LinearIndependent R (v ∘ ⇑f)))
l : ι →₀ R := Finsupp.mapDomain (⇑f) (repr { val := v i, property := (_ : v i ∈ ↑(span R (range (v ∘ ⇑f)))) })
h_total_l : (Finsupp.total ι M R v) l = v i
h_total_eq : (Finsupp.total ι M R v) l = (Finsupp.total ι M R v) fun₀ | i => 1
l_eq :
  Finsupp.embDomain f
      ((LinearIndependent.repr (_ : LinearIndependent R (v ∘ ⇑f)))
        { val := v i, property := (_ : v i ∈ ↑(span R (range (v ∘ ⇑f)))) }) =
    fun₀ | i => 1
i' : ι'
hi' : (repr { val := v i, property := (_ : v i ∈ ↑(span R (range (v ∘ ⇑f)))) } = fun₀ | i' => 1) ∧ f i' = i
⊢ ∃ a, f a = i

Next tactic:
use i'
theorem surjective_of_linearIndependent_of_span [Nontrivial R] (hv : LinearIndependent R v)
    (f : ι' ↪ ι) (hss : range v ⊆ span R (range (v ∘ f))) : Surjective f := by
  intro i
  let repr : (span R (range (v ∘ f)) : Type _) → ι' →₀ R := (hv.comp f f.injective).repr
  let l := (repr ⟨v i, hss (mem_range_self i)⟩).mapDomain f
  have h_total_l : Finsupp.total ι M R v l = v i := by
    dsimp only []
    rw [Finsupp.total_mapDomain]
    rw [(hv.comp f f.injective).total_repr]
    -- Porting note: `rfl` isn't necessary.
  have h_total_eq : (Finsupp.total ι M R v) l = (Finsupp.total ι M R v) (Finsupp.single i 1) := by
    rw [h_total_l, Finsupp.total_single, one_smul]
  have l_eq : l = _ := LinearMap.ker_eq_bot.1 hv h_total_eq
  dsimp only [] at l_eq
  rw [← Finsupp.embDomain_eq_mapDomain] at l_eq
  rcases Finsupp.single_of_embDomain_single (repr ⟨v i, _⟩) f i (1 : R) zero_ne_one.symm l_eq with
    ⟨i', hi'⟩
  use i'
  

Proof state:
case h
ι : 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
inst✝ : Nontrivial R
hv : LinearIndependent R v
f : ι' ↪ ι
hss : range v ⊆ ↑(span R (range (v ∘ ⇑f)))
i : ι
repr : ↥(span R (range (v ∘ ⇑f))) → ι' →₀ R := ⇑(LinearIndependent.repr (_ : LinearIndependent R (v ∘ ⇑f)))
l : ι →₀ R := Finsupp.mapDomain (⇑f) (repr { val := v i, property := (_ : v i ∈ ↑(span R (range (v ∘ ⇑f)))) })
h_total_l : (Finsupp.total ι M R v) l = v i
h_total_eq : (Finsupp.total ι M R v) l = (Finsupp.total ι M R v) fun₀ | i => 1
l_eq :
  Finsupp.embDomain f
      ((LinearIndependent.repr (_ : LinearIndependent R (v ∘ ⇑f)))
        { val := v i, property := (_ : v i ∈ ↑(span R (range (v ∘ ⇑f)))) }) =
    fun₀ | i => 1
i' : ι'
hi' : (repr { val := v i, property := (_ : v i ∈ ↑(span R (range (v ∘ ⇑f)))) } = fun₀ | i' => 1) ∧ f i' = i
⊢ f i' = i

Next tactic:
exact hi'.2
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := 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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
⊢ s = t

Next tactic:
let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  

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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
⊢ s = t

Next tactic:
have h_surj : Surjective f := by
    apply surjective_of_linearIndependent_of_span hs f _
    convert hst <;> simp [comp]
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  have h_surj : Surjective f := 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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
⊢ Surjective ⇑f

Next tactic:
apply surjective_of_linearIndependent_of_span hs f _
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  have h_surj : Surjective f := by
    apply surjective_of_linearIndependent_of_span hs f _
    

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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
⊢ (range fun x => ↑x) ⊆ ↑(span R (range ((fun x => ↑x) ∘ ⇑f)))

Next tactic:
convert hst
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  have h_surj : Surjective f := by
    apply surjective_of_linearIndependent_of_span hs f _
    convert hst <;> 

Proof state:
case h.e'_3
ι : 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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
⊢ (range fun x => ↑x) = s

Next tactic:
simp [comp]
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  have h_surj : Surjective f := by
    apply surjective_of_linearIndependent_of_span hs f _
    convert hst <;> 

Proof state:
case h.e'_4.h.e'_4.h.e'_6
ι : 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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
⊢ range ((fun x => ↑x) ∘ ⇑f) = t

Next tactic:
simp [comp]
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  have h_surj : Surjective f := by
    apply surjective_of_linearIndependent_of_span hs f _
    convert hst <;> simp [comp]
  

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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
h_surj : Surjective ⇑f
⊢ s = t

Next tactic:
show s = t
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  have h_surj : Surjective f := by
    apply surjective_of_linearIndependent_of_span hs f _
    convert hst <;> simp [comp]
  show s = t
  · 

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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
h_surj : Surjective ⇑f
⊢ s = t

Next tactic:
apply Subset.antisymm _ h
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  have h_surj : Surjective f := by
    apply surjective_of_linearIndependent_of_span hs f _
    convert hst <;> simp [comp]
  show s = t
  · apply Subset.antisymm _ h
    

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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
h_surj : Surjective ⇑f
⊢ s ⊆ t

Next tactic:
intro x hx
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  have h_surj : Surjective f := by
    apply surjective_of_linearIndependent_of_span hs f _
    convert hst <;> simp [comp]
  show s = t
  · apply Subset.antisymm _ h
    intro x hx
    

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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
h_surj : Surjective ⇑f
x : M
hx : x ∈ s
⊢ x ∈ t

Next tactic:
rcases h_surj ⟨x, hx⟩ with ⟨y, hy⟩
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  have h_surj : Surjective f := by
    apply surjective_of_linearIndependent_of_span hs f _
    convert hst <;> simp [comp]
  show s = t
  · apply Subset.antisymm _ h
    intro x hx
    rcases h_surj ⟨x, hx⟩ with ⟨y, hy⟩
    

Proof state:
case intro
ι : 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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
h_surj : Surjective ⇑f
x : M
hx : x ∈ s
y : ↑t
hy : f y = { val := x, property := hx }
⊢ x ∈ t

Next tactic:
convert y.mem
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M}
    (hs : LinearIndependent R (fun x => x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t := by
  let f : t ↪ s :=
    ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩
  have h_surj : Surjective f := by
    apply surjective_of_linearIndependent_of_span hs f _
    convert hst <;> simp [comp]
  show s = t
  · apply Subset.antisymm _ h
    intro x hx
    rcases h_surj ⟨x, hx⟩ with ⟨y, hy⟩
    convert y.mem
    

Proof state:
case h.e'_4
ι : 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
inst✝ : Nontrivial R
s t : Set M
hs : LinearIndependent R fun (x : ↑s) => ↑x
h : t ⊆ s
hst : s ⊆ ↑(span R t)
f : ↑t ↪ ↑s :=
  { toFun := fun x => { val := ↑x, property := (_ : ↑x ∈ s) },
    inj' :=
      (_ :
        ∀ (a b : ↑t),
          (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) a = (fun x => { val := ↑x, property := (_ : ↑x ∈ s) }) b →
            a = b) }
h_surj : Surjective ⇑f
x : M
hx : x ∈ s
y : ↑t
hy : f y = { val := x, property := hx }
⊢ x = ↑y

Next tactic:
rw [← Subtype.mk.inj hy]
theorem LinearIndependent.image_subtype {s : Set M} {f : M →ₗ[R] M'}
    (hs : LinearIndependent R (fun x => x : s → M))
    (hf_inj : Disjoint (span R s) (LinearMap.ker f)) :
    LinearIndependent R (fun x => x : f '' s → M') := 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
s : Set M
f : M →ₗ[R] M'
hs : LinearIndependent R fun (x : ↑s) => ↑x
hf_inj : Disjoint (span R s) (ker f)
⊢ LinearIndependent R fun (x : ↑(⇑f '' s)) => ↑x

Next tactic:
rw [← Subtype.range_coe (s := s)] at hf_inj
theorem LinearIndependent.image_subtype {s : Set M} {f : M →ₗ[R] M'}
    (hs : LinearIndependent R (fun x => x : s → M))
    (hf_inj : Disjoint (span R s) (LinearMap.ker f)) :
    LinearIndependent R (fun x => x : f '' s → M') := by
  rw [← Subtype.range_coe (s := s)] at hf_inj
  

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
s : Set M
f : M →ₗ[R] M'
hs : LinearIndependent R fun (x : ↑s) => ↑x
hf_inj : Disjoint (span R (Set.range Subtype.val)) (ker f)
⊢ LinearIndependent R fun (x : ↑(⇑f '' s)) => ↑x

Next tactic:
refine' (hs.map hf_inj).to_subtype_range' _
theorem LinearIndependent.image_subtype {s : Set M} {f : M →ₗ[R] M'}
    (hs : LinearIndependent R (fun x => x : s → M))
    (hf_inj : Disjoint (span R s) (LinearMap.ker f)) :
    LinearIndependent R (fun x => x : f '' s → M') := by
  rw [← Subtype.range_coe (s := s)] at hf_inj
  refine' (hs.map hf_inj).to_subtype_range' _
  

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
s : Set M
f : M →ₗ[R] M'
hs : LinearIndependent R fun (x : ↑s) => ↑x
hf_inj : Disjoint (span R (Set.range Subtype.val)) (ker f)
⊢ Set.range (⇑f ∘ fun x => ↑x) = ⇑f '' s

Next tactic:
simp [Set.range_comp f]
theorem LinearIndependent.inl_union_inr {s : Set M} {t : Set M'}
    (hs : LinearIndependent R (fun x => x : s → M))
    (ht : LinearIndependent R (fun x => x : t → M')) :
    LinearIndependent R (fun x => x : ↥(inl R M M' '' s ∪ inr R M M' '' t) → M × M') := 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
s : Set M
t : Set M'
hs : LinearIndependent R fun (x : ↑s) => ↑x
ht : LinearIndependent R fun (x : ↑t) => ↑x
⊢ LinearIndependent R fun (x : ↑(⇑(inl R M M') '' s ∪ ⇑(inr R M M') '' t)) => ↑x

Next tactic:
refine' (hs.image_subtype _).union (ht.image_subtype _) _ <;> [simp; simp; skip]
theorem LinearIndependent.inl_union_inr {s : Set M} {t : Set M'}
    (hs : LinearIndependent R (fun x => x : s → M))
    (ht : LinearIndependent R (fun x => x : t → M')) :
    LinearIndependent R (fun x => x : ↥(inl R M M' '' s ∪ inr R M M' '' t) → M × M') := 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
s : Set M
t : Set M'
hs : LinearIndependent R fun (x : ↑s) => ↑x
ht : LinearIndependent R fun (x : ↑t) => ↑x
⊢ LinearIndependent R fun (x : ↑(⇑(inl R M M') '' s ∪ ⇑(inr R M M') '' t)) => ↑x

Next tactic:
refine' (hs.image_subtype _).union (ht.image_subtype _) _