l3lab/ntp-mathlib huggingface dataset:
/-- `stdSimplex 𝕜 ι` is the convex hull of the canonical basis in `ι → 𝕜`. -/
theorem convexHull_basis_eq_stdSimplex :
    convexHull R (range fun i j : ι => if i = j then (1 : R) else 0) = stdSimplex R ι := by
  refine' Subset.antisymm (convexHull_min _ (convex_stdSimplex R ι)) _
  · 

Proof state:
case refine'_1
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι
c : R
t : Finset ι
w : ι → R
z : ι → E
inst✝ : Fintype ι
f : ι → R
⊢ (Set.range fun i j => if i = j then 1 else 0) ⊆ stdSimplex R ι

Next tactic:
rintro _ ⟨i, rfl⟩
/-- `stdSimplex 𝕜 ι` is the convex hull of the canonical basis in `ι → 𝕜`. -/
theorem convexHull_basis_eq_stdSimplex :
    convexHull R (range fun i j : ι => if i = j then (1 : R) else 0) = stdSimplex R ι := by
  refine' Subset.antisymm (convexHull_min _ (convex_stdSimplex R ι)) _
  · rintro _ ⟨i, rfl⟩
    

Proof state:
case refine'_1.intro
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i✝ j : ι
c : R
t : Finset ι
w : ι → R
z : ι → E
inst✝ : Fintype ι
f : ι → R
i : ι
⊢ (fun i j => if i = j then 1 else 0) i ∈ stdSimplex R ι

Next tactic:
exact ite_eq_mem_stdSimplex R i
/-- `stdSimplex 𝕜 ι` is the convex hull of the canonical basis in `ι → 𝕜`. -/
theorem convexHull_basis_eq_stdSimplex :
    convexHull R (range fun i j : ι => if i = j then (1 : R) else 0) = stdSimplex R ι := by
  refine' Subset.antisymm (convexHull_min _ (convex_stdSimplex R ι)) _
  · rintro _ ⟨i, rfl⟩
    exact ite_eq_mem_stdSimplex R i
  · 

Proof state:
case refine'_2
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι
c : R
t : Finset ι
w : ι → R
z : ι → E
inst✝ : Fintype ι
f : ι → R
⊢ stdSimplex R ι ⊆ (convexHull R) (Set.range fun i j => if i = j then 1 else 0)

Next tactic:
rintro w ⟨hw₀, hw₁⟩
/-- `stdSimplex 𝕜 ι` is the convex hull of the canonical basis in `ι → 𝕜`. -/
theorem convexHull_basis_eq_stdSimplex :
    convexHull R (range fun i j : ι => if i = j then (1 : R) else 0) = stdSimplex R ι := by
  refine' Subset.antisymm (convexHull_min _ (convex_stdSimplex R ι)) _
  · rintro _ ⟨i, rfl⟩
    exact ite_eq_mem_stdSimplex R i
  · rintro w ⟨hw₀, hw₁⟩
    

Proof state:
case refine'_2.intro
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι
c : R
t : Finset ι
w✝ : ι → R
z : ι → E
inst✝ : Fintype ι
f w : ι → R
hw₀ : ∀ (x : ι), 0 ≤ w x
hw₁ : ∑ x : ι, w x = 1
⊢ w ∈ (convexHull R) (Set.range fun i j => if i = j then 1 else 0)

Next tactic:
rw [pi_eq_sum_univ w, ← Finset.univ.centerMass_eq_of_sum_1 _ hw₁]
/-- `stdSimplex 𝕜 ι` is the convex hull of the canonical basis in `ι → 𝕜`. -/
theorem convexHull_basis_eq_stdSimplex :
    convexHull R (range fun i j : ι => if i = j then (1 : R) else 0) = stdSimplex R ι := by
  refine' Subset.antisymm (convexHull_min _ (convex_stdSimplex R ι)) _
  · rintro _ ⟨i, rfl⟩
    exact ite_eq_mem_stdSimplex R i
  · rintro w ⟨hw₀, hw₁⟩
    rw [pi_eq_sum_univ w, ← Finset.univ.centerMass_eq_of_sum_1 _ hw₁]
    

Proof state:
case refine'_2.intro
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι
c : R
t : Finset ι
w✝ : ι → R
z : ι → E
inst✝ : Fintype ι
f w : ι → R
hw₀ : ∀ (x : ι), 0 ≤ w x
hw₁ : ∑ x : ι, w x = 1
⊢ (centerMass Finset.univ (fun i => w i) fun i j => if i = j then 1 else 0) ∈
    (convexHull R) (Set.range fun i j => if i = j then 1 else 0)

Next tactic:
exact Finset.univ.centerMass_mem_convexHull (fun i _ => hw₀ i) (hw₁.symm ▸ zero_lt_one)
      fun i _ => mem_range_self i
/-- The convex hull of a finite set is the image of the standard simplex in `s → ℝ`
under the linear map sending each function `w` to `∑ x in s, w x • x`.

Since we have no sums over finite sets, we use sum over `@Finset.univ _ hs.fintype`.
The map is defined in terms of operations on `(s → ℝ) →ₗ[ℝ] ℝ` so that later we will not need
to prove that this map is linear. -/
theorem Set.Finite.convexHull_eq_image {s : Set E} (hs : s.Finite) : convexHull R s =
    haveI := hs.fintype
    (⇑(∑ x : s, (@LinearMap.proj R s _ (fun _ => R) _ _ x).smulRight x.1)) '' stdSimplex R s := by
  -- Porting note: Original proof didn't need to specify `hs.fintype`
  

Proof state:
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s✝ : Set E
i j : ι
c : R
t : Finset ι
w : ι → R
z : ι → E
inst✝ : Fintype ι
f : ι → R
s : Set E
hs : Set.Finite s
⊢ (convexHull R) s = ⇑(∑ x : ↑s, LinearMap.smulRight (LinearMap.proj x) ↑x) '' stdSimplex R ↑s

Next tactic:
rw [← @convexHull_basis_eq_stdSimplex _ _ _ hs.fintype, ← LinearMap.convexHull_image,
    ← Set.range_comp]
/-- The convex hull of a finite set is the image of the standard simplex in `s → ℝ`
under the linear map sending each function `w` to `∑ x in s, w x • x`.

Since we have no sums over finite sets, we use sum over `@Finset.univ _ hs.fintype`.
The map is defined in terms of operations on `(s → ℝ) →ₗ[ℝ] ℝ` so that later we will not need
to prove that this map is linear. -/
theorem Set.Finite.convexHull_eq_image {s : Set E} (hs : s.Finite) : convexHull R s =
    haveI := hs.fintype
    (⇑(∑ x : s, (@LinearMap.proj R s _ (fun _ => R) _ _ x).smulRight x.1)) '' stdSimplex R s := by
  -- Porting note: Original proof didn't need to specify `hs.fintype`
  rw [← @convexHull_basis_eq_stdSimplex _ _ _ hs.fintype, ← LinearMap.convexHull_image,
    ← Set.range_comp]
  

Proof state:
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s✝ : Set E
i j : ι
c : R
t : Finset ι
w : ι → R
z : ι → E
inst✝ : Fintype ι
f : ι → R
s : Set E
hs : Set.Finite s
⊢ (convexHull R) s =
    (convexHull R) (range (⇑(∑ x : ↑s, LinearMap.smulRight (LinearMap.proj x) ↑x) ∘ fun i j => if i = j then 1 else 0))

Next tactic:
simp_rw [Function.comp]
/-- The convex hull of a finite set is the image of the standard simplex in `s → ℝ`
under the linear map sending each function `w` to `∑ x in s, w x • x`.

Since we have no sums over finite sets, we use sum over `@Finset.univ _ hs.fintype`.
The map is defined in terms of operations on `(s → ℝ) →ₗ[ℝ] ℝ` so that later we will not need
to prove that this map is linear. -/
theorem Set.Finite.convexHull_eq_image {s : Set E} (hs : s.Finite) : convexHull R s =
    haveI := hs.fintype
    (⇑(∑ x : s, (@LinearMap.proj R s _ (fun _ => R) _ _ x).smulRight x.1)) '' stdSimplex R s := by
  -- Porting note: Original proof didn't need to specify `hs.fintype`
  rw [← @convexHull_basis_eq_stdSimplex _ _ _ hs.fintype, ← LinearMap.convexHull_image,
    ← Set.range_comp]
  simp_rw [Function.comp]
  

Proof state:
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s✝ : Set E
i j : ι
c : R
t : Finset ι
w : ι → R
z : ι → E
inst✝ : Fintype ι
f : ι → R
s : Set E
hs : Set.Finite s
⊢ (convexHull R) s =
    (convexHull R)
      (range fun x => (∑ x : ↑s, LinearMap.smulRight (LinearMap.proj x) ↑x) fun j => if x = j then 1 else 0)

Next tactic:
apply congr_arg
/-- The convex hull of a finite set is the image of the standard simplex in `s → ℝ`
under the linear map sending each function `w` to `∑ x in s, w x • x`.

Since we have no sums over finite sets, we use sum over `@Finset.univ _ hs.fintype`.
The map is defined in terms of operations on `(s → ℝ) →ₗ[ℝ] ℝ` so that later we will not need
to prove that this map is linear. -/
theorem Set.Finite.convexHull_eq_image {s : Set E} (hs : s.Finite) : convexHull R s =
    haveI := hs.fintype
    (⇑(∑ x : s, (@LinearMap.proj R s _ (fun _ => R) _ _ x).smulRight x.1)) '' stdSimplex R s := by
  -- Porting note: Original proof didn't need to specify `hs.fintype`
  rw [← @convexHull_basis_eq_stdSimplex _ _ _ hs.fintype, ← LinearMap.convexHull_image,
    ← Set.range_comp]
  simp_rw [Function.comp]
  apply congr_arg
  

Proof state:
case h
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s✝ : Set E
i j : ι
c : R
t : Finset ι
w : ι → R
z : ι → E
inst✝ : Fintype ι
f : ι → R
s : Set E
hs : Set.Finite s
⊢ s = range fun x => (∑ x : ↑s, LinearMap.smulRight (LinearMap.proj x) ↑x) fun j => if x = j then 1 else 0

Next tactic:
convert Subtype.range_coe.symm
/-- The convex hull of a finite set is the image of the standard simplex in `s → ℝ`
under the linear map sending each function `w` to `∑ x in s, w x • x`.

Since we have no sums over finite sets, we use sum over `@Finset.univ _ hs.fintype`.
The map is defined in terms of operations on `(s → ℝ) →ₗ[ℝ] ℝ` so that later we will not need
to prove that this map is linear. -/
theorem Set.Finite.convexHull_eq_image {s : Set E} (hs : s.Finite) : convexHull R s =
    haveI := hs.fintype
    (⇑(∑ x : s, (@LinearMap.proj R s _ (fun _ => R) _ _ x).smulRight x.1)) '' stdSimplex R s := by
  -- Porting note: Original proof didn't need to specify `hs.fintype`
  rw [← @convexHull_basis_eq_stdSimplex _ _ _ hs.fintype, ← LinearMap.convexHull_image,
    ← Set.range_comp]
  simp_rw [Function.comp]
  apply congr_arg
  convert Subtype.range_coe.symm
  -- Porting note: Original proof didn't need to specify `hs.fintype` and `(1 : R)`
  

Proof state:
case h.e'_3.h.e'_3.h
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s✝ : Set E
i j : ι
c : R
t : Finset ι
w : ι → R
z : ι → E
inst✝ : Fintype ι
f : ι → R
s : Set E
hs : Set.Finite s
x✝ : ↑s
⊢ ((∑ x : ↑s, LinearMap.smulRight (LinearMap.proj x) ↑x) fun j => if x✝ = j then 1 else 0) = ↑x✝

Next tactic:
simp [LinearMap.sum_apply, ite_smul _ (1 : R), Finset.filter_eq,
    @Finset.mem_univ _ hs.fintype _]
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  

Proof state:
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι✝
c : R
t : Finset ι✝
w : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
⊢ (convexHull R) (Set.range ⇑b) = {x | ∀ (i : ι), 0 ≤ (coord b i) x}

Next tactic:
rw [convexHull_range_eq_exists_affineCombination]
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  rw [convexHull_range_eq_exists_affineCombination]
  

Proof state:
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι✝
c : R
t : Finset ι✝
w : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
⊢ {x | ∃ s w, (∀ i ∈ s, 0 ≤ w i) ∧ Finset.sum s w = 1 ∧ (affineCombination R s ⇑b) w = x} =
    {x | ∀ (i : ι), 0 ≤ (coord b i) x}

Next tactic:
ext x
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  rw [convexHull_range_eq_exists_affineCombination]
  ext x
  

Proof state:
case h
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι✝
c : R
t : Finset ι✝
w : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
x : E
⊢ x ∈ {x | ∃ s w, (∀ i ∈ s, 0 ≤ w i) ∧ Finset.sum s w = 1 ∧ (affineCombination R s ⇑b) w = x} ↔
    x ∈ {x | ∀ (i : ι), 0 ≤ (coord b i) x}

Next tactic:
refine' ⟨_, fun hx => _⟩
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  rw [convexHull_range_eq_exists_affineCombination]
  ext x
  refine' ⟨_, fun hx => _⟩
  · 

Proof state:
case h.refine'_1
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι✝
c : R
t : Finset ι✝
w : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
x : E
⊢ x ∈ {x | ∃ s w, (∀ i ∈ s, 0 ≤ w i) ∧ Finset.sum s w = 1 ∧ (affineCombination R s ⇑b) w = x} →
    x ∈ {x | ∀ (i : ι), 0 ≤ (coord b i) x}

Next tactic:
rintro ⟨s, w, hw₀, hw₁, rfl⟩ i
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  rw [convexHull_range_eq_exists_affineCombination]
  ext x
  refine' ⟨_, fun hx => _⟩
  · rintro ⟨s, w, hw₀, hw₁, rfl⟩ i
    

Proof state:
case h.refine'_1.intro.intro.intro.intro
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s✝ : Set E
i✝ j : ι✝
c : R
t : Finset ι✝
w✝ : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
s : Finset ι
w : ι → R
hw₀ : ∀ i ∈ s, 0 ≤ w i
hw₁ : Finset.sum s w = 1
i : ι
⊢ 0 ≤ (coord b i) ((affineCombination R s ⇑b) w)

Next tactic:
by_cases hi : i ∈ s
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  rw [convexHull_range_eq_exists_affineCombination]
  ext x
  refine' ⟨_, fun hx => _⟩
  · rintro ⟨s, w, hw₀, hw₁, rfl⟩ i
    by_cases hi : i ∈ s
    · 

Proof state:
case pos
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s✝ : Set E
i✝ j : ι✝
c : R
t : Finset ι✝
w✝ : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
s : Finset ι
w : ι → R
hw₀ : ∀ i ∈ s, 0 ≤ w i
hw₁ : Finset.sum s w = 1
i : ι
hi : i ∈ s
⊢ 0 ≤ (coord b i) ((affineCombination R s ⇑b) w)

Next tactic:
rw [b.coord_apply_combination_of_mem hi hw₁]
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  rw [convexHull_range_eq_exists_affineCombination]
  ext x
  refine' ⟨_, fun hx => _⟩
  · rintro ⟨s, w, hw₀, hw₁, rfl⟩ i
    by_cases hi : i ∈ s
    · rw [b.coord_apply_combination_of_mem hi hw₁]
      

Proof state:
case pos
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s✝ : Set E
i✝ j : ι✝
c : R
t : Finset ι✝
w✝ : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
s : Finset ι
w : ι → R
hw₀ : ∀ i ∈ s, 0 ≤ w i
hw₁ : Finset.sum s w = 1
i : ι
hi : i ∈ s
⊢ 0 ≤ w i

Next tactic:
exact hw₀ i hi
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  rw [convexHull_range_eq_exists_affineCombination]
  ext x
  refine' ⟨_, fun hx => _⟩
  · rintro ⟨s, w, hw₀, hw₁, rfl⟩ i
    by_cases hi : i ∈ s
    · rw [b.coord_apply_combination_of_mem hi hw₁]
      exact hw₀ i hi
    · 

Proof state:
case neg
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s✝ : Set E
i✝ j : ι✝
c : R
t : Finset ι✝
w✝ : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
s : Finset ι
w : ι → R
hw₀ : ∀ i ∈ s, 0 ≤ w i
hw₁ : Finset.sum s w = 1
i : ι
hi : i ∉ s
⊢ 0 ≤ (coord b i) ((affineCombination R s ⇑b) w)

Next tactic:
rw [b.coord_apply_combination_of_not_mem hi hw₁]
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  rw [convexHull_range_eq_exists_affineCombination]
  ext x
  refine' ⟨_, fun hx => _⟩
  · rintro ⟨s, w, hw₀, hw₁, rfl⟩ i
    by_cases hi : i ∈ s
    · rw [b.coord_apply_combination_of_mem hi hw₁]
      exact hw₀ i hi
    · rw [b.coord_apply_combination_of_not_mem hi hw₁]
  · 

Proof state:
case h.refine'_2
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι✝
c : R
t : Finset ι✝
w : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
x : E
hx : x ∈ {x | ∀ (i : ι), 0 ≤ (coord b i) x}
⊢ x ∈ {x | ∃ s w, (∀ i ∈ s, 0 ≤ w i) ∧ Finset.sum s w = 1 ∧ (affineCombination R s ⇑b) w = x}

Next tactic:
have hx' : x ∈ affineSpan R (range b) := by
      rw [b.tot]
      exact AffineSubspace.mem_top R E x
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  rw [convexHull_range_eq_exists_affineCombination]
  ext x
  refine' ⟨_, fun hx => _⟩
  · rintro ⟨s, w, hw₀, hw₁, rfl⟩ i
    by_cases hi : i ∈ s
    · rw [b.coord_apply_combination_of_mem hi hw₁]
      exact hw₀ i hi
    · rw [b.coord_apply_combination_of_not_mem hi hw₁]
  · have hx' : x ∈ affineSpan R (range b) := by
      

Proof state:
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι✝
c : R
t : Finset ι✝
w : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
x : E
hx : x ∈ {x | ∀ (i : ι), 0 ≤ (coord b i) x}
⊢ x ∈ affineSpan R (Set.range ⇑b)

Next tactic:
rw [b.tot]
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
corresponding barycentric coordinates. -/
theorem AffineBasis.convexHull_eq_nonneg_coord {ι : Type*} (b : AffineBasis ι R E) :
    convexHull R (range b) = { x | ∀ i, 0 ≤ b.coord i x } := by
  rw [convexHull_range_eq_exists_affineCombination]
  ext x
  refine' ⟨_, fun hx => _⟩
  · rintro ⟨s, w, hw₀, hw₁, rfl⟩ i
    by_cases hi : i ∈ s
    · rw [b.coord_apply_combination_of_mem hi hw₁]
      exact hw₀ i hi
    · rw [b.coord_apply_combination_of_not_mem hi hw₁]
  · have hx' : x ∈ affineSpan R (range b) := by
      rw [b.tot]
      

Proof state:
R : Type u_1
R' : Type u_2
E : Type u_3
F : Type u_4
ι✝ : Type u_5
ι' : Type u_6
α : Type u_7
inst✝⁹ : LinearOrderedField R
inst✝⁸ : LinearOrderedField R'
inst✝⁷ : AddCommGroup E
inst✝⁶ : AddCommGroup F
inst✝⁵ : LinearOrderedAddCommGroup α
inst✝⁴ : Module R E
inst✝³ : Module R F
inst✝² : Module R α
inst✝¹ : OrderedSMul R α
s : Set E
i j : ι✝
c : R
t : Finset ι✝
w : ι✝ → R
z : ι✝ → E
inst✝ : Fintype ι✝
f : ι✝ → R
ι : Type u_8
b : AffineBasis ι R E
x : E
hx : x ∈ {x | ∀ (i : ι), 0 ≤ (coord b i) x}
⊢ x ∈ ⊤

Next tactic:
exact AffineSubspace.mem_top R E x