-- Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean
/-- If `R` satisfies the strong rank condition,
then any linearly independent family `v : ι → M`
contained in the span of some finite `w : Set M`,
is itself finite.
-/
lemma LinearIndependent.finite_of_le_span_finite {ι : Type*} (v : ι → M) (i : LinearIndependent R v)
    (w : Set M) [Finite w] (s : range v ≤ span R w) : Finite ι :=
  letI := Fintype.ofFinite w
  Fintype.finite <| fintypeOfFinsetCardLe (Fintype.card w) fun t => by
    let v' := fun x : (t : Set ι) => v x
    have i' : LinearIndependent R v' := i.comp _ Subtype.val_injective
    have s' : range v' ≤ span R w := (range_comp_subset_range _ _).trans s
    simpa using linearIndependent_le_span_aux' v' i' w s'

Proof state:
R : Type u
M : Type v
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : StrongRankCondition R
ι : Type u_1
v : ι → M
i : LinearIndependent R v
w : Set M
inst✝ : Finite ↑w
s : range v ≤ ↑(span R w)
this : Fintype ↑w := Fintype.ofFinite ↑w
t : Finset ι
⊢ t.card ≤ Fintype.card ↑w

Tactic:
let v' := fun x : (t : Set ι) => v x

Result:
R : Type u
M : Type v
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : StrongRankCondition R
ι : Type u_1
v : ι → M
i : LinearIndependent R v
w : Set M
inst✝ : Finite ↑w
s : range v ≤ ↑(span R w)
this : Fintype ↑w := Fintype.ofFinite ↑w
t : Finset ι
v' : ↑↑t → M := fun x => v ↑x
⊢ t.card ≤ Fintype.card ↑w

Proof state:
R : Type u
M : Type v
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : StrongRankCondition R
ι : Type u_1
v : ι → M
i : LinearIndependent R v
w : Set M
inst✝ : Finite ↑w
s : range v ≤ ↑(span R w)
this : Fintype ↑w := Fintype.ofFinite ↑w
t : Finset ι
v' : ↑↑t → M := fun x => v ↑x
i' : LinearIndependent (ι := ↑↑t) R v'
⊢ t.card ≤ Fintype.card ↑w

Tactic:
have s' : range v' ≤ span R w := (range_comp_subset_range _ _).trans s

Result:
R : Type u
M : Type v
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : StrongRankCondition R
ι : Type u_1
v : ι → M
i : LinearIndependent R v
w : Set M
inst✝ : Finite ↑w
s : range v ≤ ↑(span R w)
this : Fintype ↑w := Fintype.ofFinite ↑w
t : Finset ι
v' : ↑↑t → M := fun x => v ↑x
i' : LinearIndependent (ι := ↑↑t) R v'
s' : range v' ≤ ↑(span R w)
⊢ t.card ≤ Fintype.card ↑w

Proof state:
R : Type u
M : Type v
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : StrongRankCondition R
ι : Type u_1
v : ι → M
i : LinearIndependent R v
w : Set M
inst✝ : Finite ↑w
s : range v ≤ ↑(span R w)
this : Fintype ↑w := Fintype.ofFinite ↑w
t : Finset ι
v' : ↑↑t → M := fun x => v ↑x
i' : LinearIndependent (ι := ↑↑t) R v'
s' : range v' ≤ ↑(span R w)
⊢ t.card ≤ Fintype.card ↑w

Tactic:
simpa using linearIndependent_le_span_aux' v' i' w s'

Result:
no goals

Proof state:
R : Type u
M : Type v
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : StrongRankCondition R
ι : Type u_1
v : ι → M
i : LinearIndependent R v
w : Set M
inst✝ : Finite ↑w
s : range v ≤ ↑(span R w)
this : Fintype ↑w := Fintype.ofFinite ↑w
t : Finset ι
v' : ↑↑t → M := fun x => v ↑x
⊢ t.card ≤ Fintype.card ↑w

Tactic:
have i' : LinearIndependent R v' := i.comp _ Subtype.val_injective

Result:
R : Type u
M : Type v
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
inst✝¹ : StrongRankCondition R
ι : Type u_1
v : ι → M
i : LinearIndependent R v
w : Set M
inst✝ : Finite ↑w
s : range v ≤ ↑(span R w)
this : Fintype ↑w := Fintype.ofFinite ↑w
t : Finset ι
v' : ↑↑t → M := fun x => v ↑x
i' : LinearIndependent (ι := ↑↑t) R v'
⊢ t.card ≤ Fintype.card ↑w