l3lab/ntp-mathlib huggingface dataset:
/-- Given an affine basis for an affine space `P`, if we single out one member of the family, we
obtain a linear basis for the model space `V`.

The linear basis corresponding to the singled-out member `i : ι` is indexed by `{j : ι // j ≠ i}`
and its `j`th element is `b j -ᵥ b i`. (See `basisOf_apply`.) -/
noncomputable def basisOf (i : ι) : Basis { j : ι // j ≠ i } k V :=
  Basis.mk ((affineIndependent_iff_linearIndependent_vsub k b i).mp b.ind)
    (by
      suffices
        Submodule.span k (range fun j : { x // x ≠ i } => b ↑j -ᵥ b i) = vectorSpan k (range b) by
        rw [this, ← direction_affineSpan, b.tot, AffineSubspace.direction_top]
      conv_rhs => rw [← image_univ]
      rw [vectorSpan_image_eq_span_vsub_set_right_ne k b (mem_univ i)]
      congr
      

Proof state:
case e_s
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
i : ι
⊢ (range fun j => b ↑j -ᵥ b i) = (fun x => x -ᵥ b i) '' (⇑b '' (univ \ {i}))

Next tactic:
ext v
/-- Given an affine basis for an affine space `P`, if we single out one member of the family, we
obtain a linear basis for the model space `V`.

The linear basis corresponding to the singled-out member `i : ι` is indexed by `{j : ι // j ≠ i}`
and its `j`th element is `b j -ᵥ b i`. (See `basisOf_apply`.) -/
noncomputable def basisOf (i : ι) : Basis { j : ι // j ≠ i } k V :=
  Basis.mk ((affineIndependent_iff_linearIndependent_vsub k b i).mp b.ind)
    (by
      suffices
        Submodule.span k (range fun j : { x // x ≠ i } => b ↑j -ᵥ b i) = vectorSpan k (range b) by
        rw [this, ← direction_affineSpan, b.tot, AffineSubspace.direction_top]
      conv_rhs => rw [← image_univ]
      rw [vectorSpan_image_eq_span_vsub_set_right_ne k b (mem_univ i)]
      congr
      ext v
      

Proof state:
case e_s.h
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
i : ι
v : V
⊢ (v ∈ range fun j => b ↑j -ᵥ b i) ↔ v ∈ (fun x => x -ᵥ b i) '' (⇑b '' (univ \ {i}))

Next tactic:
simp
@[simp]
theorem basisOf_apply (i : ι) (j : { j : ι // j ≠ i }) : b.basisOf i j = b ↑j -ᵥ b i := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j✝ : ι
e : ι ≃ ι'
i : ι
j : { j // j ≠ i }
⊢ (basisOf b i) j = b ↑j -ᵥ b i

Next tactic:
simp [basisOf]
@[simp]
theorem basisOf_reindex (i : ι') :
    (b.reindex e).basisOf i =
      (b.basisOf <| e.symm i).reindex (e.subtypeEquiv fun _ => e.eq_symm_apply.not) := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
i : ι'
⊢ basisOf (reindex b e) i =
    Basis.reindex (basisOf b (e.symm i)) (Equiv.subtypeEquiv e (_ : ∀ (x : ι), ¬x = e.symm i ↔ ¬e x = i))

Next tactic:
ext j
@[simp]
theorem basisOf_reindex (i : ι') :
    (b.reindex e).basisOf i =
      (b.basisOf <| e.symm i).reindex (e.subtypeEquiv fun _ => e.eq_symm_apply.not) := by
  ext j
  

Proof state:
case a
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j✝ : ι
e : ι ≃ ι'
i : ι'
j : { j // j ≠ i }
⊢ (basisOf (reindex b e) i) j =
    (Basis.reindex (basisOf b (e.symm i)) (Equiv.subtypeEquiv e (_ : ∀ (x : ι), ¬x = e.symm i ↔ ¬e x = i))) j

Next tactic:
simp
/-- The `i`th barycentric coordinate of a point. -/
noncomputable def coord (i : ι) : P →ᵃ[k] k where
  toFun q := 1 - (b.basisOf i).sumCoords (q -ᵥ b i)
  linear := -(b.basisOf i).sumCoords
  map_vadd' q v := by
    

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
i : ι
q : P
v : V
⊢ (fun q => 1 - (Basis.sumCoords (basisOf b i)) (q -ᵥ b i)) (v +ᵥ q) =
    (-Basis.sumCoords (basisOf b i)) v +ᵥ (fun q => 1 - (Basis.sumCoords (basisOf b i)) (q -ᵥ b i)) q

Next tactic:
dsimp only
/-- The `i`th barycentric coordinate of a point. -/
noncomputable def coord (i : ι) : P →ᵃ[k] k where
  toFun q := 1 - (b.basisOf i).sumCoords (q -ᵥ b i)
  linear := -(b.basisOf i).sumCoords
  map_vadd' q v := by
    dsimp only
    

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
i : ι
q : P
v : V
⊢ 1 - (Basis.sumCoords (basisOf b i)) (v +ᵥ q -ᵥ b i) =
    (-Basis.sumCoords (basisOf b i)) v +ᵥ (1 - (Basis.sumCoords (basisOf b i)) (q -ᵥ b i))

Next tactic:
rw [vadd_vsub_assoc, LinearMap.map_add, vadd_eq_add, LinearMap.neg_apply,
      sub_add_eq_sub_sub_swap, add_comm, sub_eq_add_neg]
@[simp]
theorem coord_reindex (i : ι') : (b.reindex e).coord i = b.coord (e.symm i) := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
i : ι'
⊢ coord (reindex b e) i = coord b (e.symm i)

Next tactic:
ext
@[simp]
theorem coord_reindex (i : ι') : (b.reindex e).coord i = b.coord (e.symm i) := by
  ext
  

Proof state:
case h
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
i : ι'
p✝ : P
⊢ (coord (reindex b e) i) p✝ = (coord b (e.symm i)) p✝

Next tactic:
classical simp [AffineBasis.coord]
@[simp]
theorem coord_reindex (i : ι') : (b.reindex e).coord i = b.coord (e.symm i) := by
  ext
  classical 

Proof state:
case h
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
i : ι'
p✝ : P
⊢ (coord (reindex b e) i) p✝ = (coord b (e.symm i)) p✝

Next tactic:
simp [AffineBasis.coord]
@[simp]
theorem coord_apply_eq (i : ι) : b.coord i (b i) = 1 := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
i : ι
⊢ (coord b i) (b i) = 1

Next tactic:
simp only [coord, Basis.coe_sumCoords, LinearEquiv.map_zero, LinearEquiv.coe_coe, sub_zero,
    AffineMap.coe_mk, Finsupp.sum_zero_index, vsub_self]
@[simp]
theorem coord_apply_ne (h : i ≠ j) : b.coord i (b j) = 0 := by
  -- Porting note:
  -- in mathlib3 we didn't need to given the `fun j => j ≠ i` argument to `Subtype.coe_mk`,
  -- but I don't think we can complain: this proof was over-golfed.
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
h : i ≠ j
⊢ (coord b i) (b j) = 0

Next tactic:
rw [coord, AffineMap.coe_mk, ← @Subtype.coe_mk _ (fun j => j ≠ i) j h.symm, ← b.basisOf_apply,
    Basis.sumCoords_self_apply, sub_self]
theorem coord_apply [DecidableEq ι] (i j : ι) : b.coord i (b j) = if i = j then 1 else 0 := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j✝ : ι
e : ι ≃ ι'
inst✝ : DecidableEq ι
i j : ι
⊢ (coord b i) (b j) = if i = j then 1 else 0

Next tactic:
rcases eq_or_ne i j with h | h
theorem coord_apply [DecidableEq ι] (i j : ι) : b.coord i (b j) = if i = j then 1 else 0 := by
  rcases eq_or_ne i j with h | h <;> 

Proof state:
case inl
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j✝ : ι
e : ι ≃ ι'
inst✝ : DecidableEq ι
i j : ι
h : i = j
⊢ (coord b i) (b j) = if i = j then 1 else 0

Next tactic:
simp [h]
theorem coord_apply [DecidableEq ι] (i j : ι) : b.coord i (b j) = if i = j then 1 else 0 := by
  rcases eq_or_ne i j with h | h <;> 

Proof state:
case inr
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j✝ : ι
e : ι ≃ ι'
inst✝ : DecidableEq ι
i j : ι
h : i ≠ j
⊢ (coord b i) (b j) = if i = j then 1 else 0

Next tactic:
simp [h]
@[simp]
theorem coord_apply_combination_of_mem (hi : i ∈ s) {w : ι → k} (hw : s.sum w = 1) :
    b.coord i (s.affineCombination k b w) = w i := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
hi : i ∈ s
w : ι → k
hw : Finset.sum s w = 1
⊢ (coord b i) ((Finset.affineCombination k s ⇑b) w) = w i

Next tactic:
classical simp only [coord_apply, hi, Finset.affineCombination_eq_linear_combination, if_true,
      mul_boole, hw, Function.comp_apply, smul_eq_mul, s.sum_ite_eq,
      s.map_affineCombination b w hw]
@[simp]
theorem coord_apply_combination_of_mem (hi : i ∈ s) {w : ι → k} (hw : s.sum w = 1) :
    b.coord i (s.affineCombination k b w) = w i := by
  classical 

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
hi : i ∈ s
w : ι → k
hw : Finset.sum s w = 1
⊢ (coord b i) ((Finset.affineCombination k s ⇑b) w) = w i

Next tactic:
simp only [coord_apply, hi, Finset.affineCombination_eq_linear_combination, if_true,
      mul_boole, hw, Function.comp_apply, smul_eq_mul, s.sum_ite_eq,
      s.map_affineCombination b w hw]
@[simp]
theorem coord_apply_combination_of_not_mem (hi : i ∉ s) {w : ι → k} (hw : s.sum w = 1) :
    b.coord i (s.affineCombination k b w) = 0 := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
hi : i ∉ s
w : ι → k
hw : Finset.sum s w = 1
⊢ (coord b i) ((Finset.affineCombination k s ⇑b) w) = 0

Next tactic:
classical simp only [coord_apply, hi, Finset.affineCombination_eq_linear_combination, if_false,
      mul_boole, hw, Function.comp_apply, smul_eq_mul, s.sum_ite_eq,
      s.map_affineCombination b w hw]
@[simp]
theorem coord_apply_combination_of_not_mem (hi : i ∉ s) {w : ι → k} (hw : s.sum w = 1) :
    b.coord i (s.affineCombination k b w) = 0 := by
  classical 

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝³ : AddCommGroup V
inst✝² : AffineSpace V P
inst✝¹ : Ring k
inst✝ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
hi : i ∉ s
w : ι → k
hw : Finset.sum s w = 1
⊢ (coord b i) ((Finset.affineCombination k s ⇑b) w) = 0

Next tactic:
simp only [coord_apply, hi, Finset.affineCombination_eq_linear_combination, if_false,
      mul_boole, hw, Function.comp_apply, smul_eq_mul, s.sum_ite_eq,
      s.map_affineCombination b w hw]
@[simp]
theorem sum_coord_apply_eq_one [Fintype ι] (q : P) : ∑ i, b.coord i q = 1 := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
q : P
⊢ ∑ i : ι, (coord b i) q = 1

Next tactic:
have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    exact AffineSubspace.mem_top k V q
@[simp]
theorem sum_coord_apply_eq_one [Fintype ι] (q : P) : ∑ i, b.coord i q = 1 := by
  have hq : q ∈ affineSpan k (range b) := by
    

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
q : P
⊢ q ∈ affineSpan k (range ⇑b)

Next tactic:
rw [b.tot]
@[simp]
theorem sum_coord_apply_eq_one [Fintype ι] (q : P) : ∑ i, b.coord i q = 1 := by
  have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
q : P
⊢ q ∈ ⊤

Next tactic:
exact AffineSubspace.mem_top k V q
@[simp]
theorem sum_coord_apply_eq_one [Fintype ι] (q : P) : ∑ i, b.coord i q = 1 := by
  have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    exact AffineSubspace.mem_top k V q
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
q : P
hq : q ∈ affineSpan k (range ⇑b)
⊢ ∑ i : ι, (coord b i) q = 1

Next tactic:
obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype hq
@[simp]
theorem sum_coord_apply_eq_one [Fintype ι] (q : P) : ∑ i, b.coord i q = 1 := by
  have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    exact AffineSubspace.mem_top k V q
  obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype hq
  

Proof state:
case intro.intro
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
w : ι → k
hw : ∑ i : ι, w i = 1
hq : (Finset.affineCombination k Finset.univ ⇑b) w ∈ affineSpan k (range ⇑b)
⊢ ∑ i : ι, (coord b i) ((Finset.affineCombination k Finset.univ ⇑b) w) = 1

Next tactic:
convert hw
@[simp]
theorem sum_coord_apply_eq_one [Fintype ι] (q : P) : ∑ i, b.coord i q = 1 := by
  have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    exact AffineSubspace.mem_top k V q
  obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype hq
  convert hw
  

Proof state:
case h.e'_2.a
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
w : ι → k
hw : ∑ i : ι, w i = 1
hq : (Finset.affineCombination k Finset.univ ⇑b) w ∈ affineSpan k (range ⇑b)
x✝ : ι
a✝ : x✝ ∈ Finset.univ
⊢ (coord b x✝) ((Finset.affineCombination k Finset.univ ⇑b) w) = w x✝

Next tactic:
exact b.coord_apply_combination_of_mem (Finset.mem_univ _) hw
@[simp]
theorem affineCombination_coord_eq_self [Fintype ι] (q : P) :
    (Finset.univ.affineCombination k b fun i => b.coord i q) = q := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
q : P
⊢ ((Finset.affineCombination k Finset.univ ⇑b) fun i => (coord b i) q) = q

Next tactic:
have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    exact AffineSubspace.mem_top k V q
@[simp]
theorem affineCombination_coord_eq_self [Fintype ι] (q : P) :
    (Finset.univ.affineCombination k b fun i => b.coord i q) = q := by
  have hq : q ∈ affineSpan k (range b) := by
    

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
q : P
⊢ q ∈ affineSpan k (range ⇑b)

Next tactic:
rw [b.tot]
@[simp]
theorem affineCombination_coord_eq_self [Fintype ι] (q : P) :
    (Finset.univ.affineCombination k b fun i => b.coord i q) = q := by
  have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
q : P
⊢ q ∈ ⊤

Next tactic:
exact AffineSubspace.mem_top k V q
@[simp]
theorem affineCombination_coord_eq_self [Fintype ι] (q : P) :
    (Finset.univ.affineCombination k b fun i => b.coord i q) = q := by
  have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    exact AffineSubspace.mem_top k V q
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
q : P
hq : q ∈ affineSpan k (range ⇑b)
⊢ ((Finset.affineCombination k Finset.univ ⇑b) fun i => (coord b i) q) = q

Next tactic:
obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype hq
@[simp]
theorem affineCombination_coord_eq_self [Fintype ι] (q : P) :
    (Finset.univ.affineCombination k b fun i => b.coord i q) = q := by
  have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    exact AffineSubspace.mem_top k V q
  obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype hq
  

Proof state:
case intro.intro
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
w : ι → k
hw : ∑ i : ι, w i = 1
hq : (Finset.affineCombination k Finset.univ ⇑b) w ∈ affineSpan k (range ⇑b)
⊢ ((Finset.affineCombination k Finset.univ ⇑b) fun i => (coord b i) ((Finset.affineCombination k Finset.univ ⇑b) w)) =
    (Finset.affineCombination k Finset.univ ⇑b) w

Next tactic:
congr
@[simp]
theorem affineCombination_coord_eq_self [Fintype ι] (q : P) :
    (Finset.univ.affineCombination k b fun i => b.coord i q) = q := by
  have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    exact AffineSubspace.mem_top k V q
  obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype hq
  congr
  

Proof state:
case intro.intro.h.e_6.h
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
w : ι → k
hw : ∑ i : ι, w i = 1
hq : (Finset.affineCombination k Finset.univ ⇑b) w ∈ affineSpan k (range ⇑b)
⊢ (fun i => (coord b i) ((Finset.affineCombination k Finset.univ ⇑b) w)) = w

Next tactic:
ext i
@[simp]
theorem affineCombination_coord_eq_self [Fintype ι] (q : P) :
    (Finset.univ.affineCombination k b fun i => b.coord i q) = q := by
  have hq : q ∈ affineSpan k (range b) := by
    rw [b.tot]
    exact AffineSubspace.mem_top k V q
  obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype hq
  congr
  ext i
  

Proof state:
case intro.intro.h.e_6.h.h
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
w : ι → k
hw : ∑ i : ι, w i = 1
hq : (Finset.affineCombination k Finset.univ ⇑b) w ∈ affineSpan k (range ⇑b)
i : ι
⊢ (coord b i) ((Finset.affineCombination k Finset.univ ⇑b) w) = w i

Next tactic:
exact b.coord_apply_combination_of_mem (Finset.mem_univ i) hw
/-- A variant of `AffineBasis.affineCombination_coord_eq_self` for the special case when the
affine space is a module so we can talk about linear combinations. -/
@[simp]
theorem linear_combination_coord_eq_self [Fintype ι] (b : AffineBasis ι k V) (v : V) :
    ∑ i, b.coord i v • b i = v := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b✝ : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
b : AffineBasis ι k V
v : V
⊢ ∑ i : ι, (coord b i) v • b i = v

Next tactic:
have hb := b.affineCombination_coord_eq_self v
/-- A variant of `AffineBasis.affineCombination_coord_eq_self` for the special case when the
affine space is a module so we can talk about linear combinations. -/
@[simp]
theorem linear_combination_coord_eq_self [Fintype ι] (b : AffineBasis ι k V) (v : V) :
    ∑ i, b.coord i v • b i = v := by
  have hb := b.affineCombination_coord_eq_self v
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b✝ : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Fintype ι
b : AffineBasis ι k V
v : V
hb : ((Finset.affineCombination k Finset.univ ⇑b) fun i => (coord b i) v) = v
⊢ ∑ i : ι, (coord b i) v • b i = v

Next tactic:
rwa [Finset.univ.affineCombination_eq_linear_combination _ _ (b.sum_coord_apply_eq_one v)] at hb
theorem ext_elem [Finite ι] {q₁ q₂ : P} (h : ∀ i, b.coord i q₁ = b.coord i q₂) : q₁ = q₂ := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Finite ι
q₁ q₂ : P
h : ∀ (i : ι), (coord b i) q₁ = (coord b i) q₂
⊢ q₁ = q₂

Next tactic:
cases nonempty_fintype ι
theorem ext_elem [Finite ι] {q₁ q₂ : P} (h : ∀ i, b.coord i q₁ = b.coord i q₂) : q₁ = q₂ := by
  cases nonempty_fintype ι
  

Proof state:
case intro
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Finite ι
q₁ q₂ : P
h : ∀ (i : ι), (coord b i) q₁ = (coord b i) q₂
val✝ : Fintype ι
⊢ q₁ = q₂

Next tactic:
rw [← b.affineCombination_coord_eq_self q₁, ← b.affineCombination_coord_eq_self q₂]
theorem ext_elem [Finite ι] {q₁ q₂ : P} (h : ∀ i, b.coord i q₁ = b.coord i q₂) : q₁ = q₂ := by
  cases nonempty_fintype ι
  rw [← b.affineCombination_coord_eq_self q₁, ← b.affineCombination_coord_eq_self q₂]
  

Proof state:
case intro
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i j : ι
e : ι ≃ ι'
inst✝ : Finite ι
q₁ q₂ : P
h : ∀ (i : ι), (coord b i) q₁ = (coord b i) q₂
val✝ : Fintype ι
⊢ ((Finset.affineCombination k Finset.univ ⇑b) fun i => (coord b i) q₁) =
    (Finset.affineCombination k Finset.univ ⇑b) fun i => (coord b i) q₂

Next tactic:
simp only [h]
@[simp]
theorem coe_coord_of_subsingleton_eq_one [Subsingleton ι] (i : ι) : (b.coord i : P → k) = 1 := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
inst✝ : Subsingleton ι
i : ι
⊢ ⇑(coord b i) = 1

Next tactic:
ext q
@[simp]
theorem coe_coord_of_subsingleton_eq_one [Subsingleton ι] (i : ι) : (b.coord i : P → k) = 1 := by
  ext q
  

Proof state:
case h
ι : Type u_1
ι' : Type u_2
k : Type u_3
V : Type u_4
P : Type u_5
inst✝⁴ : AddCommGroup V
inst✝³ : AffineSpace V P
inst✝² : Ring k
inst✝¹ : Module k V
b : AffineBasis ι k P
s : Finset ι
i✝ j : ι
e : ι ≃ ι'
inst✝ : Subsingleton ι
i : ι
q : P
⊢ (coord b i) q = OfNat.ofNat 1 q

Next tactic:
have hp : (range b).Subsingleton := by
    rw [← image_univ]
    apply Subsingleton.image
    apply subsingleton_of_subsingleton