Theorem: LinearMap.exists_leftInverse_of_injective
File: Mathlib/LinearAlgebra/Basis.lean

tactic: let B := Basis.ofVectorSpaceIndex K V
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
⊢ ∃ g, comp g f = id

tactic: let hB := Basis.ofVectorSpace K V
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
⊢ ∃ g, comp g f = id

tactic: have hB₀ : _ := hB.linearIndependent.to_subtype_range
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
⊢ ∃ g, comp g f = id

tactic: have : LinearIndependent K (fun x => x : f '' B → V') := by
  have h₁ : LinearIndependent K ((↑) : ↥(f '' Set.range (Basis.ofVectorSpace K V)) → V') :=
    @LinearIndependent.image_subtype _ _ _ _ _ _ _ _ _ f hB₀ (show Disjoint _ _ by simp [hf_inj])
  rwa [Basis.range_ofVectorSpace K V] at h₁
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
⊢ ∃ g, comp g f = id

tactic: let C := this.extend (subset_univ _)
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
⊢ ∃ g, comp g f = id

tactic: have BC := this.subset_extend (subset_univ _)
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
⊢ ∃ g, comp g f = id

tactic: let hC := Basis.extend this
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
BC : ↑f '' B ⊆ LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
⊢ ∃ g, comp g f = id

tactic: haveI Vinh : Inhabited V := ⟨0⟩
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
BC : ↑f '' B ⊆ LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
hC : Basis (↑(LinearIndependent.extend this (_ : ↑f '' B ⊆ univ))) K V' := Basis.extend this
⊢ ∃ g, comp g f = id

tactic: refine' ⟨(hC.constr ℕ : _ → _) (C.restrict (invFun f)), hB.ext fun b => _⟩
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
BC : ↑f '' B ⊆ LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
hC : Basis (↑(LinearIndependent.extend this (_ : ↑f '' B ⊆ univ))) K V' := Basis.extend this
Vinh : Inhabited V
⊢ ∃ g, comp g f = id

tactic: rw [image_subset_iff] at BC
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
BC : ↑f '' B ⊆ LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
hC : Basis (↑(LinearIndependent.extend this (_ : ↑f '' B ⊆ univ))) K V' := Basis.extend this
Vinh : Inhabited V
b : ↑(Basis.ofVectorSpaceIndex K V)
⊢ ↑(comp (↑(Basis.constr hC ℕ) (Set.restrict C (invFun ↑f))) f) (↑hB b) = ↑id (↑hB b)

tactic: have fb_eq : f b = hC ⟨f b, BC b.2⟩ := by
  change f b = Basis.extend this _
  simp_rw [Basis.extend_apply_self]
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
BC : B ⊆ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
hC : Basis (↑(LinearIndependent.extend this (_ : ↑f '' B ⊆ univ))) K V' := Basis.extend this
Vinh : Inhabited V
b : ↑(Basis.ofVectorSpaceIndex K V)
⊢ ↑(comp (↑(Basis.constr hC ℕ) (Set.restrict C (invFun ↑f))) f) (↑hB b) = ↑id (↑hB b)

tactic: dsimp []
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
BC : B ⊆ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
hC : Basis (↑(LinearIndependent.extend this (_ : ↑f '' B ⊆ univ))) K V' := Basis.extend this
Vinh : Inhabited V
b : ↑(Basis.ofVectorSpaceIndex K V)
fb_eq : ↑f ↑b = ↑hC { val := ↑f ↑b, property := (_ : ↑b ∈ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)) }
⊢ ↑(comp (↑(Basis.constr hC ℕ) (Set.restrict C (invFun ↑f))) f) (↑hB b) = ↑id (↑hB b)

tactic: rw [Basis.ofVectorSpace_apply_self, fb_eq, hC.constr_basis]
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
BC : B ⊆ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
hC : Basis (↑(LinearIndependent.extend this (_ : ↑f '' B ⊆ univ))) K V' := Basis.extend this
Vinh : Inhabited V
b : ↑(Basis.ofVectorSpaceIndex K V)
fb_eq : ↑f ↑b = ↑hC { val := ↑f ↑b, property := (_ : ↑b ∈ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)) }
⊢ ↑(↑(Basis.constr (Basis.extend this) ℕ)
          (Set.restrict (LinearIndependent.extend this (_ : ↑f '' Basis.ofVectorSpaceIndex K V ⊆ univ)) (invFun ↑f)))
      (↑f (↑(Basis.ofVectorSpace K V) b)) =
    ↑(Basis.ofVectorSpace K V) b

tactic: exact leftInverse_invFun (LinearMap.ker_eq_bot.1 hf_inj) _
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
BC : B ⊆ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
hC : Basis (↑(LinearIndependent.extend this (_ : ↑f '' B ⊆ univ))) K V' := Basis.extend this
Vinh : Inhabited V
b : ↑(Basis.ofVectorSpaceIndex K V)
fb_eq : ↑f ↑b = ↑hC { val := ↑f ↑b, property := (_ : ↑b ∈ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)) }
⊢ Set.restrict (LinearIndependent.extend this (_ : ↑f '' Basis.ofVectorSpaceIndex K V ⊆ univ)) (invFun ↑f)
      { val := ↑f ↑b, property := (_ : ↑b ∈ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)) } =
    ↑b

tactic: have h₁ : LinearIndependent K ((↑) : ↥(f '' Set.range (Basis.ofVectorSpace K V)) → V') :=
  @LinearIndependent.image_subtype _ _ _ _ _ _ _ _ _ f hB₀ (show Disjoint _ _ by simp [hf_inj])
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
⊢ LinearIndependent K fun x => ↑x

tactic: rwa [Basis.range_ofVectorSpace K V] at h₁
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
h₁ : LinearIndependent K Subtype.val
⊢ LinearIndependent K fun x => ↑x

tactic: simp [hf_inj]
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
⊢ Disjoint (span K (Set.range ↑(Basis.ofVectorSpace K V))) (ker f)

tactic: change f b = Basis.extend this _
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
BC : B ⊆ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
hC : Basis (↑(LinearIndependent.extend this (_ : ↑f '' B ⊆ univ))) K V' := Basis.extend this
Vinh : Inhabited V
b : ↑(Basis.ofVectorSpaceIndex K V)
⊢ ↑f ↑b = ↑hC { val := ↑f ↑b, property := (_ : ↑b ∈ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)) }

tactic: simp_rw [Basis.extend_apply_self]
state_before: ι : Type ?u.1179439
ι' : Type ?u.1179442
R : Type ?u.1179445
R₂ : Type ?u.1179448
K : Type u_1
M : Type ?u.1179454
M' : Type ?u.1179457
M'' : Type ?u.1179460
V : Type u
V' : Type u_2
inst✝⁴ : DivisionRing K
inst✝³ : AddCommGroup V
inst✝² : AddCommGroup V'
inst✝¹ : Module K V
inst✝ : Module K V'
v : ι → V
s t : Set V
x y z : V
f : V →ₗ[K] V'
hf_inj : ker f = ⊥
B : Set V := Basis.ofVectorSpaceIndex K V
hB : Basis (↑(Basis.ofVectorSpaceIndex K V)) K V := Basis.ofVectorSpace K V
hB₀ : LinearIndependent K Subtype.val
this : LinearIndependent K fun x => ↑x
C : Set V' := LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
BC : B ⊆ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)
hC : Basis (↑(LinearIndependent.extend this (_ : ↑f '' B ⊆ univ))) K V' := Basis.extend this
Vinh : Inhabited V
b : ↑(Basis.ofVectorSpaceIndex K V)
⊢ ↑f ↑b =
    ↑(Basis.extend this)
      { val := ↑f ↑b, property := (_ : ↑b ∈ ↑f ⁻¹' LinearIndependent.extend this (_ : ↑f '' B ⊆ univ)) }