l3lab/ntp-mathlib huggingface dataset:
variable {R M N} in
lemma equiv [IsReflexive R M] (e : M ≃ₗ[R] N) : IsReflexive R N where
  bijective_dual_eval' := by
    let ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := e.symm.dualMap.dualMap
    have : Dual.eval R N = ed.symm.comp ((Dual.eval R M).comp e.symm.toLinearMap) := by
      

Proof state:
K : Type uK
V : Type uV
inst✝¹⁰ : CommRing K
inst✝⁹ : AddCommGroup V
inst✝⁸ : Module K V
inst✝⁷ : Free K V
R : Type u_1
M : Type u_2
N : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : AddCommGroup M
inst✝⁴ : AddCommGroup N
inst✝³ : Module R M
inst✝² : Module R N
inst✝¹ inst✝ : IsReflexive R M
e : M ≃ₗ[R] N
ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := LinearEquiv.dualMap (LinearEquiv.dualMap (LinearEquiv.symm e))
⊢ Dual.eval R N = ↑(LinearEquiv.symm ed) ∘ₗ Dual.eval R M ∘ₗ ↑(LinearEquiv.symm e)

Next tactic:
ext m f
variable {R M N} in
lemma equiv [IsReflexive R M] (e : M ≃ₗ[R] N) : IsReflexive R N where
  bijective_dual_eval' := by
    let ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := e.symm.dualMap.dualMap
    have : Dual.eval R N = ed.symm.comp ((Dual.eval R M).comp e.symm.toLinearMap) := by
      ext m f
      

Proof state:
case h.h
K : Type uK
V : Type uV
inst✝¹⁰ : CommRing K
inst✝⁹ : AddCommGroup V
inst✝⁸ : Module K V
inst✝⁷ : Free K V
R : Type u_1
M : Type u_2
N : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : AddCommGroup M
inst✝⁴ : AddCommGroup N
inst✝³ : Module R M
inst✝² : Module R N
inst✝¹ inst✝ : IsReflexive R M
e : M ≃ₗ[R] N
ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := LinearEquiv.dualMap (LinearEquiv.dualMap (LinearEquiv.symm e))
m : N
f : Dual R N
⊢ ((Dual.eval R N) m) f = ((↑(LinearEquiv.symm ed) ∘ₗ Dual.eval R M ∘ₗ ↑(LinearEquiv.symm e)) m) f

Next tactic:
exact FunLike.congr_arg f (e.apply_symm_apply m).symm
variable {R M N} in
lemma equiv [IsReflexive R M] (e : M ≃ₗ[R] N) : IsReflexive R N where
  bijective_dual_eval' := by
    let ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := e.symm.dualMap.dualMap
    have : Dual.eval R N = ed.symm.comp ((Dual.eval R M).comp e.symm.toLinearMap) := by
      ext m f
      exact FunLike.congr_arg f (e.apply_symm_apply m).symm
    

Proof state:
K : Type uK
V : Type uV
inst✝¹⁰ : CommRing K
inst✝⁹ : AddCommGroup V
inst✝⁸ : Module K V
inst✝⁷ : Free K V
R : Type u_1
M : Type u_2
N : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : AddCommGroup M
inst✝⁴ : AddCommGroup N
inst✝³ : Module R M
inst✝² : Module R N
inst✝¹ inst✝ : IsReflexive R M
e : M ≃ₗ[R] N
ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := LinearEquiv.dualMap (LinearEquiv.dualMap (LinearEquiv.symm e))
this : Dual.eval R N = ↑(LinearEquiv.symm ed) ∘ₗ Dual.eval R M ∘ₗ ↑(LinearEquiv.symm e)
⊢ Bijective ⇑(Dual.eval R N)

Next tactic:
simp only [this, LinearEquiv.trans_symm, LinearEquiv.symm_symm, LinearEquiv.dualMap_symm,
      coe_comp, LinearEquiv.coe_coe, EquivLike.comp_bijective]
variable {R M N} in
lemma equiv [IsReflexive R M] (e : M ≃ₗ[R] N) : IsReflexive R N where
  bijective_dual_eval' := by
    let ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := e.symm.dualMap.dualMap
    have : Dual.eval R N = ed.symm.comp ((Dual.eval R M).comp e.symm.toLinearMap) := by
      ext m f
      exact FunLike.congr_arg f (e.apply_symm_apply m).symm
    simp only [this, LinearEquiv.trans_symm, LinearEquiv.symm_symm, LinearEquiv.dualMap_symm,
      coe_comp, LinearEquiv.coe_coe, EquivLike.comp_bijective]
    

Proof state:
K : Type uK
V : Type uV
inst✝¹⁰ : CommRing K
inst✝⁹ : AddCommGroup V
inst✝⁸ : Module K V
inst✝⁷ : Free K V
R : Type u_1
M : Type u_2
N : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : AddCommGroup M
inst✝⁴ : AddCommGroup N
inst✝³ : Module R M
inst✝² : Module R N
inst✝¹ inst✝ : IsReflexive R M
e : M ≃ₗ[R] N
ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := LinearEquiv.dualMap (LinearEquiv.dualMap (LinearEquiv.symm e))
this : Dual.eval R N = ↑(LinearEquiv.symm ed) ∘ₗ Dual.eval R M ∘ₗ ↑(LinearEquiv.symm e)
⊢ Bijective (⇑(Dual.eval R M) ∘ ⇑(LinearEquiv.symm e))

Next tactic:
exact Bijective.comp (bijective_dual_eval R M) (LinearEquiv.bijective _)
theorem exists_dual_map_eq_bot_of_nmem {x : M} (hx : x ∉ p) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f x ≠ 0 ∧ p.map f = ⊥ := by
  

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
x : M
hx : x ∉ p
hp' : Free R (M ⧸ p)
⊢ ∃ f, f x ≠ 0 ∧ map f p = ⊥

Next tactic:
suffices ∃ f : Dual R (M ⧸ p), f (p.mkQ x) ≠ 0 by
    obtain ⟨f, hf⟩ := this; exact ⟨f.comp p.mkQ, hf, by simp [Submodule.map_comp]⟩
theorem exists_dual_map_eq_bot_of_nmem {x : M} (hx : x ∉ p) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f x ≠ 0 ∧ p.map f = ⊥ := by
  suffices ∃ f : Dual R (M ⧸ p), f (p.mkQ x) ≠ 0 by
    

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
x : M
hx : x ∉ p
hp' : Free R (M ⧸ p)
this : ∃ f, f ((mkQ p) x) ≠ 0
⊢ ∃ f, f x ≠ 0 ∧ map f p = ⊥

Next tactic:
obtain ⟨f, hf⟩ := this
theorem exists_dual_map_eq_bot_of_nmem {x : M} (hx : x ∉ p) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f x ≠ 0 ∧ p.map f = ⊥ := by
  suffices ∃ f : Dual R (M ⧸ p), f (p.mkQ x) ≠ 0 by
    obtain ⟨f, hf⟩ := this; 

Proof state:
case intro
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
x : M
hx : x ∉ p
hp' : Free R (M ⧸ p)
f : Dual R (M ⧸ p)
hf : f ((mkQ p) x) ≠ 0
⊢ ∃ f, f x ≠ 0 ∧ map f p = ⊥

Next tactic:
exact ⟨f.comp p.mkQ, hf, by simp [Submodule.map_comp]⟩
theorem exists_dual_map_eq_bot_of_nmem {x : M} (hx : x ∉ p) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f x ≠ 0 ∧ p.map f = ⊥ := by
  suffices ∃ f : Dual R (M ⧸ p), f (p.mkQ x) ≠ 0 by
    obtain ⟨f, hf⟩ := this; exact ⟨f.comp p.mkQ, hf, by 

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
x : M
hx : x ∉ p
hp' : Free R (M ⧸ p)
f : Dual R (M ⧸ p)
hf : f ((mkQ p) x) ≠ 0
⊢ map (f ∘ₗ mkQ p) p = ⊥

Next tactic:
simp [Submodule.map_comp]
theorem exists_dual_map_eq_bot_of_nmem {x : M} (hx : x ∉ p) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f x ≠ 0 ∧ p.map f = ⊥ := by
  suffices ∃ f : Dual R (M ⧸ p), f (p.mkQ x) ≠ 0 by
    obtain ⟨f, hf⟩ := this; exact ⟨f.comp p.mkQ, hf, by simp [Submodule.map_comp]⟩
  

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
x : M
hx : x ∉ p
hp' : Free R (M ⧸ p)
⊢ ∃ f, f ((mkQ p) x) ≠ 0

Next tactic:
rwa [← Submodule.Quotient.mk_eq_zero, ← Submodule.mkQ_apply,
    ← forall_dual_apply_eq_zero_iff (K := R), not_forall] at hx
theorem exists_dual_map_eq_bot_of_lt_top (hp : p < ⊤) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f ≠ 0 ∧ p.map f = ⊥ := by
  

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
hp : p < ⊤
hp' : Free R (M ⧸ p)
⊢ ∃ f, f ≠ 0 ∧ map f p = ⊥

Next tactic:
obtain ⟨x, hx⟩ : ∃ x : M, x ∉ p := by rw [lt_top_iff_ne_top] at hp; contrapose! hp; ext; simp [hp]
theorem exists_dual_map_eq_bot_of_lt_top (hp : p < ⊤) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f ≠ 0 ∧ p.map f = ⊥ := by
  obtain ⟨x, hx⟩ : ∃ x : M, x ∉ p := by 

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
hp : p < ⊤
hp' : Free R (M ⧸ p)
⊢ ∃ x, x ∉ p

Next tactic:
rw [lt_top_iff_ne_top] at hp
theorem exists_dual_map_eq_bot_of_lt_top (hp : p < ⊤) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f ≠ 0 ∧ p.map f = ⊥ := by
  obtain ⟨x, hx⟩ : ∃ x : M, x ∉ p := by rw [lt_top_iff_ne_top] at hp; 

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
hp : p ≠ ⊤
hp' : Free R (M ⧸ p)
⊢ ∃ x, x ∉ p

Next tactic:
contrapose! hp
theorem exists_dual_map_eq_bot_of_lt_top (hp : p < ⊤) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f ≠ 0 ∧ p.map f = ⊥ := by
  obtain ⟨x, hx⟩ : ∃ x : M, x ∉ p := by rw [lt_top_iff_ne_top] at hp; contrapose! hp; 

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
hp' : Free R (M ⧸ p)
hp : ∀ (x : M), x ∈ p
⊢ p = ⊤

Next tactic:
ext
theorem exists_dual_map_eq_bot_of_lt_top (hp : p < ⊤) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f ≠ 0 ∧ p.map f = ⊥ := by
  obtain ⟨x, hx⟩ : ∃ x : M, x ∉ p := by rw [lt_top_iff_ne_top] at hp; contrapose! hp; ext; 

Proof state:
case h
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
hp' : Free R (M ⧸ p)
hp : ∀ (x : M), x ∈ p
x✝ : M
⊢ x✝ ∈ p ↔ x✝ ∈ ⊤

Next tactic:
simp [hp]
theorem exists_dual_map_eq_bot_of_lt_top (hp : p < ⊤) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f ≠ 0 ∧ p.map f = ⊥ := by
  obtain ⟨x, hx⟩ : ∃ x : M, x ∉ p := by rw [lt_top_iff_ne_top] at hp; contrapose! hp; ext; simp [hp]
  

Proof state:
case intro
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
hp : p < ⊤
hp' : Free R (M ⧸ p)
x : M
hx : x ∉ p
⊢ ∃ f, f ≠ 0 ∧ map f p = ⊥

Next tactic:
obtain ⟨f, hf, hf'⟩ := p.exists_dual_map_eq_bot_of_nmem hx hp'
theorem exists_dual_map_eq_bot_of_lt_top (hp : p < ⊤) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f ≠ 0 ∧ p.map f = ⊥ := by
  obtain ⟨x, hx⟩ : ∃ x : M, x ∉ p := by rw [lt_top_iff_ne_top] at hp; contrapose! hp; ext; simp [hp]
  obtain ⟨f, hf, hf'⟩ := p.exists_dual_map_eq_bot_of_nmem hx hp'
  

Proof state:
case intro.intro.intro
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
hp : p < ⊤
hp' : Free R (M ⧸ p)
x : M
hx : x ∉ p
f : Dual R M
hf : f x ≠ 0
hf' : map f p = ⊥
⊢ ∃ f, f ≠ 0 ∧ map f p = ⊥

Next tactic:
exact ⟨f, by aesop, hf'⟩
theorem exists_dual_map_eq_bot_of_lt_top (hp : p < ⊤) (hp' : Free R (M ⧸ p)) :
    ∃ f : Dual R M, f ≠ 0 ∧ p.map f = ⊥ := by
  obtain ⟨x, hx⟩ : ∃ x : M, x ∉ p := by rw [lt_top_iff_ne_top] at hp; contrapose! hp; ext; simp [hp]
  obtain ⟨f, hf, hf'⟩ := p.exists_dual_map_eq_bot_of_nmem hx hp'
  exact ⟨f, by 

Proof state:
R : Type u_1
M : Type u_2
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
p : Submodule R M
hp : p < ⊤
hp' : Free R (M ⧸ p)
x : M
hx : x ∉ p
f : Dual R M
hf : f x ≠ 0
hf' : map f p = ⊥
⊢ f ≠ 0

Next tactic:
aesop
/-- The coefficients of `v` on the basis `e` -/
def coeffs [DecidableEq ι] (h : DualBases e ε) (m : M) : ι →₀ R where
  toFun i := ε i m
  support := (h.Finite m).toFinset
  mem_support_toFun := by
    

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
m : M
⊢ ∀ (a : ι), a ∈ Set.Finite.toFinset (_ : Set.Finite {i | (ε i) m ≠ 0}) ↔ (fun i => (ε i) m) a ≠ 0

Next tactic:
intro i
/-- The coefficients of `v` on the basis `e` -/
def coeffs [DecidableEq ι] (h : DualBases e ε) (m : M) : ι →₀ R where
  toFun i := ε i m
  support := (h.Finite m).toFinset
  mem_support_toFun := by
    intro i
    

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
m : M
i : ι
⊢ i ∈ Set.Finite.toFinset (_ : Set.Finite {i | (ε i) m ≠ 0}) ↔ (fun i => (ε i) m) i ≠ 0

Next tactic:
rw [Set.Finite.mem_toFinset, Set.mem_setOf_eq]
theorem dual_lc (l : ι →₀ R) (i : ι) : ε i (DualBases.lc e l) = l i := by
  

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
l : ι →₀ R
i : ι
⊢ (ε i) (lc e l) = l i

Next tactic:
rw [lc, _root_.map_finsupp_sum, Finsupp.sum_eq_single i (g := fun a b ↦ (ε i) (b • e a))]
theorem dual_lc (l : ι →₀ R) (i : ι) : ε i (DualBases.lc e l) = l i := by
  rw [lc, _root_.map_finsupp_sum, Finsupp.sum_eq_single i (g := fun a b ↦ (ε i) (b • e a))]
  -- Porting note: cannot get at •
  -- simp only [h.eval, map_smul, smul_eq_mul]
  · 

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
l : ι →₀ R
i : ι
⊢ (ε i) (l i • e i) = l i

Next tactic:
simp [h.eval, smul_eq_mul]
theorem dual_lc (l : ι →₀ R) (i : ι) : ε i (DualBases.lc e l) = l i := by
  rw [lc, _root_.map_finsupp_sum, Finsupp.sum_eq_single i (g := fun a b ↦ (ε i) (b • e a))]
  -- Porting note: cannot get at •
  -- simp only [h.eval, map_smul, smul_eq_mul]
  · simp [h.eval, smul_eq_mul]
  · 

Proof state:
case h₀
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
l : ι →₀ R
i : ι
⊢ ∀ (b : ι), l b ≠ 0 → b ≠ i → (ε i) (l b • e b) = 0

Next tactic:
intro q _ q_ne
theorem dual_lc (l : ι →₀ R) (i : ι) : ε i (DualBases.lc e l) = l i := by
  rw [lc, _root_.map_finsupp_sum, Finsupp.sum_eq_single i (g := fun a b ↦ (ε i) (b • e a))]
  -- Porting note: cannot get at •
  -- simp only [h.eval, map_smul, smul_eq_mul]
  · simp [h.eval, smul_eq_mul]
  · intro q _ q_ne
    

Proof state:
case h₀
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
l : ι →₀ R
i q : ι
a✝ : l q ≠ 0
q_ne : q ≠ i
⊢ (ε i) (l q • e q) = 0

Next tactic:
simp [q_ne.symm, h.eval, smul_eq_mul]
theorem dual_lc (l : ι →₀ R) (i : ι) : ε i (DualBases.lc e l) = l i := by
  rw [lc, _root_.map_finsupp_sum, Finsupp.sum_eq_single i (g := fun a b ↦ (ε i) (b • e a))]
  -- Porting note: cannot get at •
  -- simp only [h.eval, map_smul, smul_eq_mul]
  · simp [h.eval, smul_eq_mul]
  · intro q _ q_ne
    simp [q_ne.symm, h.eval, smul_eq_mul]
  · 

Proof state:
case h₁
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
l : ι →₀ R
i : ι
⊢ l i = 0 → (ε i) (0 • e i) = 0

Next tactic:
simp
@[simp]
theorem coeffs_lc (l : ι →₀ R) : h.coeffs (DualBases.lc e l) = l := by
  

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
l : ι →₀ R
⊢ coeffs h (lc e l) = l

Next tactic:
ext i
@[simp]
theorem coeffs_lc (l : ι →₀ R) : h.coeffs (DualBases.lc e l) = l := by
  ext i
  

Proof state:
case h
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
l : ι →₀ R
i : ι
⊢ (coeffs h (lc e l)) i = l i

Next tactic:
rw [h.coeffs_apply, h.dual_lc]
/-- For any m : M n, \sum_{p ∈ Q n} (ε p m) • e p = m -/
@[simp]
theorem lc_coeffs (m : M) : DualBases.lc e (h.coeffs m) = m := by
  

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
m : M
⊢ lc e (coeffs h m) = m

Next tactic:
refine' eq_of_sub_eq_zero (h.Total _)
/-- For any m : M n, \sum_{p ∈ Q n} (ε p m) • e p = m -/
@[simp]
theorem lc_coeffs (m : M) : DualBases.lc e (h.coeffs m) = m := by
  refine' eq_of_sub_eq_zero (h.Total _)
  

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
m : M
⊢ ∀ (i : ι), (ε i) (lc e (coeffs h m) - m) = 0

Next tactic:
intro i
/-- For any m : M n, \sum_{p ∈ Q n} (ε p m) • e p = m -/
@[simp]
theorem lc_coeffs (m : M) : DualBases.lc e (h.coeffs m) = m := by
  refine' eq_of_sub_eq_zero (h.Total _)
  intro i
  

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
m : M
i : ι
⊢ (ε i) (lc e (coeffs h m) - m) = 0

Next tactic:
simp [LinearMap.map_sub, h.dual_lc, sub_eq_zero]
/-- `(h : dual_bases e ε).basis` shows the family of vectors `e` forms a basis. -/
@[simps]
def basis : Basis ι R M :=
  Basis.ofRepr
    { toFun := coeffs h
      invFun := lc e
      left_inv := lc_coeffs h
      right_inv := coeffs_lc h
      map_add' := fun v w => by
        

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
v w : M
⊢ coeffs h (v + w) = coeffs h v + coeffs h w

Next tactic:
ext i
/-- `(h : dual_bases e ε).basis` shows the family of vectors `e` forms a basis. -/
@[simps]
def basis : Basis ι R M :=
  Basis.ofRepr
    { toFun := coeffs h
      invFun := lc e
      left_inv := lc_coeffs h
      right_inv := coeffs_lc h
      map_add' := fun v w => by
        ext i
        

Proof state:
case h
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
v w : M
i : ι
⊢ (coeffs h (v + w)) i = (coeffs h v + coeffs h w) i

Next tactic:
exact (ε i).map_add v w
/-- `(h : dual_bases e ε).basis` shows the family of vectors `e` forms a basis. -/
@[simps]
def basis : Basis ι R M :=
  Basis.ofRepr
    { toFun := coeffs h
      invFun := lc e
      left_inv := lc_coeffs h
      right_inv := coeffs_lc h
      map_add' := fun v w => by
        ext i
        exact (ε i).map_add v w
      map_smul' := fun c v => by
        

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
c : R
v : M
⊢ AddHom.toFun { toFun := coeffs h, map_add' := (_ : ∀ (v w : M), coeffs h (v + w) = coeffs h v + coeffs h w) }
      (c • v) =
    (RingHom.id R) c •
      AddHom.toFun { toFun := coeffs h, map_add' := (_ : ∀ (v w : M), coeffs h (v + w) = coeffs h v + coeffs h w) } v

Next tactic:
ext i
/-- `(h : dual_bases e ε).basis` shows the family of vectors `e` forms a basis. -/
@[simps]
def basis : Basis ι R M :=
  Basis.ofRepr
    { toFun := coeffs h
      invFun := lc e
      left_inv := lc_coeffs h
      right_inv := coeffs_lc h
      map_add' := fun v w => by
        ext i
        exact (ε i).map_add v w
      map_smul' := fun c v => by
        ext i
        

Proof state:
case h
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
c : R
v : M
i : ι
⊢ (AddHom.toFun { toFun := coeffs h, map_add' := (_ : ∀ (v w : M), coeffs h (v + w) = coeffs h v + coeffs h w) }
        (c • v))
      i =
    ((RingHom.id R) c •
        AddHom.toFun { toFun := coeffs h, map_add' := (_ : ∀ (v w : M), coeffs h (v + w) = coeffs h v + coeffs h w) } v)
      i

Next tactic:
exact (ε i).map_smul c v
@[simp]
theorem coe_basis : ⇑h.basis = e := by
  

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
⊢ ⇑(basis h) = e

Next tactic:
ext i
@[simp]
theorem coe_basis : ⇑h.basis = e := by
  ext i
  

Proof state:
case h
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
i : ι
⊢ (basis h) i = e i

Next tactic:
rw [Basis.apply_eq_iff]
@[simp]
theorem coe_basis : ⇑h.basis = e := by
  ext i
  rw [Basis.apply_eq_iff]
  

Proof state:
case h
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
i : ι
⊢ (basis h).repr (e i) = fun₀ | i => 1

Next tactic:
ext j
@[simp]
theorem coe_basis : ⇑h.basis = e := by
  ext i
  rw [Basis.apply_eq_iff]
  ext j
  

Proof state:
case h.h
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
i j : ι
⊢ ((basis h).repr (e i)) j = (fun₀ | i => 1) j

Next tactic:
rw [h.basis_repr_apply, coeffs_apply, h.eval, Finsupp.single_apply]
@[simp]
theorem coe_basis : ⇑h.basis = e := by
  ext i
  rw [Basis.apply_eq_iff]
  ext j
  rw [h.basis_repr_apply, coeffs_apply, h.eval, Finsupp.single_apply]
  

Proof state:
case h.h
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
i j : ι
⊢ (if j = i then 1 else 0) = if i = j then 1 else 0

Next tactic:
convert if_congr (eq_comm (a := j) (b := i)) rfl rfl
theorem mem_of_mem_span {H : Set ι} {x : M} (hmem : x ∈ Submodule.span R (e '' H)) :
    ∀ i : ι, ε i x ≠ 0 → i ∈ H := by
  

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
H : Set ι
x : M
hmem : x ∈ Submodule.span R (e '' H)
⊢ ∀ (i : ι), (ε i) x ≠ 0 → i ∈ H

Next tactic:
intro i hi
theorem mem_of_mem_span {H : Set ι} {x : M} (hmem : x ∈ Submodule.span R (e '' H)) :
    ∀ i : ι, ε i x ≠ 0 → i ∈ H := by
  intro i hi
  

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
H : Set ι
x : M
hmem : x ∈ Submodule.span R (e '' H)
i : ι
hi : (ε i) x ≠ 0
⊢ i ∈ H

Next tactic:
rcases (Finsupp.mem_span_image_iff_total _).mp hmem with ⟨l, supp_l, rfl⟩
theorem mem_of_mem_span {H : Set ι} {x : M} (hmem : x ∈ Submodule.span R (e '' H)) :
    ∀ i : ι, ε i x ≠ 0 → i ∈ H := by
  intro i hi
  rcases (Finsupp.mem_span_image_iff_total _).mp hmem with ⟨l, supp_l, rfl⟩
  

Proof state:
case intro.intro
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
H : Set ι
i : ι
l : ι →₀ R
supp_l : l ∈ Finsupp.supported R R H
hmem : (Finsupp.total ι M R e) l ∈ Submodule.span R (e '' H)
hi : (ε i) ((Finsupp.total ι M R e) l) ≠ 0
⊢ i ∈ H

Next tactic:
apply not_imp_comm.mp ((Finsupp.mem_supported' _ _).mp supp_l i)
theorem mem_of_mem_span {H : Set ι} {x : M} (hmem : x ∈ Submodule.span R (e '' H)) :
    ∀ i : ι, ε i x ≠ 0 → i ∈ H := by
  intro i hi
  rcases (Finsupp.mem_span_image_iff_total _).mp hmem with ⟨l, supp_l, rfl⟩
  apply not_imp_comm.mp ((Finsupp.mem_supported' _ _).mp supp_l i)
  

Proof state:
case intro.intro
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
e : ι → M
ε : ι → Dual R M
inst✝ : DecidableEq ι
h : DualBases e ε
H : Set ι
i : ι
l : ι →₀ R
supp_l : l ∈ Finsupp.supported R R H
hmem : (Finsupp.total ι M R e) l ∈ Submodule.span R (e '' H)
hi : (ε i) ((Finsupp.total ι M R e) l) ≠ 0
⊢ ¬l i = 0

Next tactic:
rwa [← lc_def, h.dual_lc] at hi
theorem coe_dualBasis [Fintype ι] : ⇑h.basis.dualBasis = ε :=
  funext fun i =>
    h.basis.ext fun j => by
      

Proof state:
R : Type u_1
M : Type u_2
ι : Type u_3
inst✝⁴ : CommRing R
inst✝³ : AddCommGroup M
inst✝² : Module R M
e : ι → M
ε : ι → Dual R M
inst✝¹ : DecidableEq ι
h : DualBases e ε
inst✝ : Fintype ι
i j : ι
⊢ ((Basis.dualBasis (basis h)) i) ((basis h) j) = (ε i) ((basis h) j)

Next tactic:
rw [h.basis.dualBasis_apply_self, h.coe_basis, h.eval, if_congr eq_comm rfl rfl]
@[simp]
theorem mem_dualAnnihilator (φ : Module.Dual R M) : φ ∈ W.dualAnnihilator ↔ ∀ w ∈ W, φ w = 0 := by
  

Proof state:
R : Type u
M : Type v
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
W : Submodule R M
φ : Module.Dual R M
⊢ φ ∈ dualAnnihilator W ↔ ∀ w ∈ W, φ w = 0

Next tactic:
refine' LinearMap.mem_ker.trans _
@[simp]
theorem mem_dualAnnihilator (φ : Module.Dual R M) : φ ∈ W.dualAnnihilator ↔ ∀ w ∈ W, φ w = 0 := by
  refine' LinearMap.mem_ker.trans _
  

Proof state:
R : Type u
M : Type v
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
W : Submodule R M
φ : Module.Dual R M
⊢ (dualRestrict W) φ = 0 ↔ ∀ w ∈ W, φ w = 0

Next tactic:
simp_rw [LinearMap.ext_iff, dualRestrict_apply]