# mathlibdocumentation

linear_algebra.affine_space.combination

# Affine combinations of points #

This file defines affine combinations of points.

## Main definitions #

• weighted_vsub_of_point is a general weighted combination of subtractions with an explicit base point, yielding a vector.

• weighted_vsub uses an arbitrary choice of base point and is intended to be used when the sum of weights is 0, in which case the result is independent of the choice of base point.

• affine_combination adds the weighted combination to the arbitrary base point, yielding a point rather than a vector, and is intended to be used when the sum of weights is 1, in which case the result is independent of the choice of base point.

These definitions are for sums over a finset; versions for a fintype may be obtained using finset.univ, while versions for a finsupp may be obtained using finsupp.support.

## References #

def finset.weighted_vsub_of_point {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (p : ι → P) (b : P) :
(ι → k) →ₗ[k] V

A weighted sum of the results of subtracting a base point from the given points, as a linear map on the weights. The main cases of interest are where the sum of the weights is 0, in which case the sum is independent of the choice of base point, and where the sum of the weights is 1, in which case the sum added to the base point is independent of the choice of base point.

Equations
• = ∑ (i : ι) in s, (p i -ᵥ b)
@[simp]
theorem finset.weighted_vsub_of_point_apply {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (b : P) :
b) w = ∑ (i : ι) in s, w i (p i -ᵥ b)
theorem finset.weighted_vsub_of_point_eq_of_sum_eq_zero {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (h : ∑ (i : ι) in s, w i = 0) (b₁ b₂ : P) :
b₁) w = b₂) w

The weighted sum is independent of the base point when the sum of the weights is 0.

theorem finset.weighted_vsub_of_point_vadd_eq_of_sum_eq_one {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (h : ∑ (i : ι) in s, w i = 1) (b₁ b₂ : P) :
b₁) w +ᵥ b₁ = b₂) w +ᵥ b₂

The weighted sum, added to the base point, is independent of the base point when the sum of the weights is 1.

@[simp]
theorem finset.weighted_vsub_of_point_erase {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (i : ι) :
((s.erase i).weighted_vsub_of_point p (p i)) w = (p i)) w

The weighted sum is unaffected by removing the base point, if present, from the set of points.

@[simp]
theorem finset.weighted_vsub_of_point_insert {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (i : ι) :
((insert i s).weighted_vsub_of_point p (p i)) w = (p i)) w

The weighted sum is unaffected by adding the base point, whether or not present, to the set of points.

theorem finset.weighted_vsub_of_point_indicator_subset {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (w : ι → k) (p : ι → P) (b : P) {s₁ s₂ : finset ι} (h : s₁ s₂) :
b) w = b) (s₁.indicator w)

The weighted sum is unaffected by changing the weights to the corresponding indicator function and adding points to the set.

theorem finset.weighted_vsub_of_point_map {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} {ι₂ : Type u_5} (s₂ : finset ι₂) (e : ι₂ ι) (w : ι → k) (p : ι → P) (b : P) :

A weighted sum, over the image of an embedding, equals a weighted sum with the same points and weights over the original finset.

def finset.weighted_vsub {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (p : ι → P) :
(ι → k) →ₗ[k] V

A weighted sum of the results of subtracting a default base point from the given points, as a linear map on the weights. This is intended to be used when the sum of the weights is 0; that condition is specified as a hypothesis on those lemmas that require it.

Equations
theorem finset.weighted_vsub_apply {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) :
(s.weighted_vsub p) w = ∑ (i : ι) in s, w i

Applying weighted_vsub with given weights. This is for the case where a result involving a default base point is OK (for example, when that base point will cancel out later); a more typical use case for weighted_vsub would involve selecting a preferred base point with weighted_vsub_eq_weighted_vsub_of_point_of_sum_eq_zero and then using weighted_vsub_of_point_apply.

theorem finset.weighted_vsub_eq_weighted_vsub_of_point_of_sum_eq_zero {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (h : ∑ (i : ι) in s, w i = 0) (b : P) :
(s.weighted_vsub p) w = b) w

weighted_vsub gives the sum of the results of subtracting any base point, when the sum of the weights is 0.

@[simp]
theorem finset.weighted_vsub_empty {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (w : ι → k) (p : ι → P) :

The weighted_vsub for an empty set is 0.

theorem finset.weighted_vsub_indicator_subset {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (w : ι → k) (p : ι → P) {s₁ s₂ : finset ι} (h : s₁ s₂) :
(s₁.weighted_vsub p) w = (s₂.weighted_vsub p) (s₁.indicator w)

The weighted sum is unaffected by changing the weights to the corresponding indicator function and adding points to the set.

theorem finset.weighted_vsub_map {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} {ι₂ : Type u_5} (s₂ : finset ι₂) (e : ι₂ ι) (w : ι → k) (p : ι → P) :
((finset.map e s₂).weighted_vsub p) w = (s₂.weighted_vsub (p e)) (w e)

A weighted subtraction, over the image of an embedding, equals a weighted subtraction with the same points and weights over the original finset.

def finset.affine_combination {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (p : ι → P) :
(ι → k) →ᵃ[k] P

A weighted sum of the results of subtracting a default base point from the given points, added to that base point, as an affine map on the weights. This is intended to be used when the sum of the weights is 1, in which case it is an affine combination (barycenter) of the points with the given weights; that condition is specified as a hypothesis on those lemmas that require it.

Equations
@[simp]
theorem finset.affine_combination_linear {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (p : ι → P) :

The linear map corresponding to affine_combination is weighted_vsub.

theorem finset.affine_combination_apply {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) :

Applying affine_combination with given weights. This is for the case where a result involving a default base point is OK (for example, when that base point will cancel out later); a more typical use case for affine_combination would involve selecting a preferred base point with affine_combination_eq_weighted_vsub_of_point_vadd_of_sum_eq_one and then using weighted_vsub_of_point_apply.

theorem finset.affine_combination_eq_weighted_vsub_of_point_vadd_of_sum_eq_one {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (h : ∑ (i : ι) in s, w i = 1) (b : P) :

affine_combination gives the sum with any base point, when the sum of the weights is 1.

theorem finset.weighted_vsub_vadd_affine_combination {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w₁ w₂ : ι → k) (p : ι → P) :
(s.weighted_vsub p) w₁ +ᵥ (s.affine_combination p) w₂ = (s.affine_combination p) (w₁ + w₂)

Adding a weighted_vsub to an affine_combination.

theorem finset.affine_combination_vsub {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w₁ w₂ : ι → k) (p : ι → P) :
(s.affine_combination p) w₁ -ᵥ (s.affine_combination p) w₂ = (s.weighted_vsub p) (w₁ - w₂)

Subtracting two affine_combinations.

@[simp]
theorem finset.affine_combination_of_eq_one_of_eq_zero {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) {i : ι} (his : i s) (hwi : w i = 1) (hw0 : ∀ (i2 : ι), i2 si2 iw i2 = 0) :

An affine_combination equals a point if that point is in the set and has weight 1 and the other points in the set have weight 0.

theorem finset.affine_combination_indicator_subset {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} (w : ι → k) (p : ι → P) {s₁ s₂ : finset ι} (h : s₁ s₂) :

An affine combination is unaffected by changing the weights to the corresponding indicator function and adding points to the set.

theorem finset.affine_combination_map {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} {ι₂ : Type u_5} (s₂ : finset ι₂) (e : ι₂ ι) (w : ι → k) (p : ι → P) :

An affine combination, over the image of an embedding, equals an affine combination with the same points and weights over the original finset.

theorem finset.eq_weighted_vsub_of_point_subset_iff_eq_weighted_vsub_of_point_subtype {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} {v : V} {x : k} {s : set ι} {p : ι → P} {b : P} :
(∃ (fs : finset ι) (hfs : fs s) (w : ι → k) (hw : ∑ (i : ι) in fs, w i = x), v = b) w) ∃ (fs : finset s) (w : s → k) (hw : ∑ (i : s) in fs, w i = x), v = (fs.weighted_vsub_of_point (λ (i : s), p i) b) w

Suppose an indexed family of points is given, along with a subset of the index type. A vector can be expressed as weighted_vsub_of_point using a finset lying within that subset and with a given sum of weights if and only if it can be expressed as weighted_vsub_of_point with that sum of weights for the corresponding indexed family whose index type is the subtype corresponding to that subset.

theorem finset.eq_weighted_vsub_subset_iff_eq_weighted_vsub_subtype (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} {v : V} {s : set ι} {p : ι → P} :
(∃ (fs : finset ι) (hfs : fs s) (w : ι → k) (hw : ∑ (i : ι) in fs, w i = 0), v = (fs.weighted_vsub p) w) ∃ (fs : finset s) (w : s → k) (hw : ∑ (i : s) in fs, w i = 0), v = (fs.weighted_vsub (λ (i : s), p i)) w

Suppose an indexed family of points is given, along with a subset of the index type. A vector can be expressed as weighted_vsub using a finset lying within that subset and with sum of weights 0 if and only if it can be expressed as weighted_vsub with sum of weights 0 for the corresponding indexed family whose index type is the subtype corresponding to that subset.

theorem finset.eq_affine_combination_subset_iff_eq_affine_combination_subtype (k : Type u_1) (V : Type u_2) {P : Type u_3} [ring k] [ V] [S : P] {ι : Type u_4} {p0 : P} {s : set ι} {p : ι → P} :
(∃ (fs : finset ι) (hfs : fs s) (w : ι → k) (hw : ∑ (i : ι) in fs, w i = 1), p0 = (fs.affine_combination p) w) ∃ (fs : finset s) (w : s → k) (hw : ∑ (i : s) in fs, w i = 1), p0 = (fs.affine_combination (λ (i : s), p i)) w

Suppose an indexed family of points is given, along with a subset of the index type. A point can be expressed as an affine_combination using a finset lying within that subset and with sum of weights 1 if and only if it can be expressed an affine_combination with sum of weights 1 for the corresponding indexed family whose index type is the subtype corresponding to that subset.

def finset.centroid_weights (k : Type u_1) {ι : Type u_4} (s : finset ι) :
ι → k

The weights for the centroid of some points.

Equations
@[simp]
theorem finset.centroid_weights_apply (k : Type u_1) {ι : Type u_4} (s : finset ι) (i : ι) :

centroid_weights at any point.

theorem finset.centroid_weights_eq_const (k : Type u_1) {ι : Type u_4} (s : finset ι) :

centroid_weights equals a constant function.

theorem finset.sum_centroid_weights_eq_one_of_cast_card_ne_zero {k : Type u_1} {ι : Type u_4} (s : finset ι) (h : (s.card) 0) :
∑ (i : ι) in s, = 1

The weights in the centroid sum to 1, if the number of points, converted to k, is not zero.

theorem finset.sum_centroid_weights_eq_one_of_card_ne_zero (k : Type u_1) {ι : Type u_4} (s : finset ι) [char_zero k] (h : s.card 0) :
∑ (i : ι) in s, = 1

In the characteristic zero case, the weights in the centroid sum to 1 if the number of points is not zero.

theorem finset.sum_centroid_weights_eq_one_of_nonempty (k : Type u_1) {ι : Type u_4} (s : finset ι) [char_zero k] (h : s.nonempty) :
∑ (i : ι) in s, = 1

In the characteristic zero case, the weights in the centroid sum to 1 if the set is nonempty.

theorem finset.sum_centroid_weights_eq_one_of_card_eq_add_one (k : Type u_1) {ι : Type u_4} (s : finset ι) [char_zero k] {n : } (h : s.card = n + 1) :
∑ (i : ι) in s, = 1

In the characteristic zero case, the weights in the centroid sum to 1 if the number of points is n + 1.

def finset.centroid (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} (s : finset ι) (p : ι → P) :
P

The centroid of some points. Although defined for any s, this is intended to be used in the case where the number of points, converted to k, is not zero.

Equations
theorem finset.centroid_def (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} (s : finset ι) (p : ι → P) :

The definition of the centroid.

@[simp]
theorem finset.centroid_singleton (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} (p : ι → P) (i : ι) :
{i} p = p i

The centroid of a single point.

theorem finset.centroid_insert_singleton (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} [invertible 2] (p : ι → P) (i₁ i₂ : ι) :
{i₁, i₂} p = 2⁻¹ (p i₂ -ᵥ p i₁) +ᵥ p i₁

The centroid of two points, expressed directly as adding a vector to a point.

theorem finset.centroid_insert_singleton_fin (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] [invertible 2] (p : fin 2 → P) :
= 2⁻¹ (p 1 -ᵥ p 0) +ᵥ p 0

The centroid of two points indexed by fin 2, expressed directly as adding a vector to the first point.

theorem finset.centroid_map (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} {ι₂ : Type u_5} (s₂ : finset ι₂) (e : ι₂ ι) (p : ι → P) :
s₂) p = s₂ (p e)

A centroid, over the image of an embedding, equals a centroid with the same points and weights over the original finset.

def finset.centroid_weights_indicator (k : Type u_1) {ι : Type u_4} (s : finset ι) :
ι → k

centroid_weights gives the weights for the centroid as a constant function, which is suitable when summing over the points whose centroid is being taken. This function gives the weights in a form suitable for summing over a larger set of points, as an indicator function that is zero outside the set whose centroid is being taken. In the case of a fintype, the sum may be over univ.

Equations
theorem finset.centroid_weights_indicator_def (k : Type u_1) {ι : Type u_4} (s : finset ι) :

The definition of centroid_weights_indicator.

theorem finset.sum_centroid_weights_indicator (k : Type u_1) {ι : Type u_4} (s : finset ι) [fintype ι] :
∑ (i : ι), = ∑ (i : ι) in s,

The sum of the weights for the centroid indexed by a fintype.

theorem finset.sum_centroid_weights_indicator_eq_one_of_card_ne_zero (k : Type u_1) {ι : Type u_4} (s : finset ι) [char_zero k] [fintype ι] (h : s.card 0) :
∑ (i : ι), = 1

In the characteristic zero case, the weights in the centroid indexed by a fintype sum to 1 if the number of points is not zero.

theorem finset.sum_centroid_weights_indicator_eq_one_of_nonempty (k : Type u_1) {ι : Type u_4} (s : finset ι) [char_zero k] [fintype ι] (h : s.nonempty) :
∑ (i : ι), = 1

In the characteristic zero case, the weights in the centroid indexed by a fintype sum to 1 if the set is nonempty.

theorem finset.sum_centroid_weights_indicator_eq_one_of_card_eq_add_one (k : Type u_1) {ι : Type u_4} (s : finset ι) [char_zero k] [fintype ι] {n : } (h : s.card = n + 1) :
∑ (i : ι), = 1

In the characteristic zero case, the weights in the centroid indexed by a fintype sum to 1 if the number of points is n + 1.

theorem finset.centroid_eq_affine_combination_fintype (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} (s : finset ι) [fintype ι] (p : ι → P) :

The centroid as an affine combination over a fintype.

theorem finset.centroid_eq_centroid_image_of_inj_on (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} (s : finset ι) {p : ι → P} (hi : ∀ (i j : ι), i sj sp i = p ji = j) {ps : set P} [fintype ps] (hps : ps = p '' s) :
p = (λ (x : ps), x)

An indexed family of points that is injective on the given finset has the same centroid as the image of that finset. This is stated in terms of a set equal to the image to provide control of definitional equality for the index type used for the centroid of the image.

theorem finset.centroid_eq_of_inj_on_of_image_eq (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} (s : finset ι) {ι₂ : Type u_5} (s₂ : finset ι₂) {p : ι → P} (hi : ∀ (i j : ι), i sj sp i = p ji = j) {p₂ : ι₂ → P} (hi₂ : ∀ (i j : ι₂), i s₂j s₂p₂ i = p₂ ji = j) (he : p '' s = p₂ '' s₂) :
p = s₂ p₂

Two indexed families of points that are injective on the given finsets and with the same points in the image of those finsets have the same centroid.

theorem weighted_vsub_mem_vector_span {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [ P] {ι : Type u_4} {s : finset ι} {w : ι → k} (h : ∑ (i : ι) in s, w i = 0) (p : ι → P) :

A weighted_vsub with sum of weights 0 is in the vector_span of an indexed family.

theorem affine_combination_mem_affine_span {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [ P] {ι : Type u_4} [nontrivial k] {s : finset ι} {w : ι → k} (h : ∑ (i : ι) in s, w i = 1) (p : ι → P) :

An affine_combination with sum of weights 1 is in the affine_span of an indexed family, if the underlying ring is nontrivial.

theorem mem_vector_span_iff_eq_weighted_vsub (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [ V] [ P] {ι : Type u_4} {v : V} {p : ι → P} :
v (set.range p) ∃ (s : finset ι) (w : ι → k) (h : ∑ (i : ι) in s, w i = 0), v = (s.weighted_vsub p) w

A vector is in the vector_span of an indexed family if and only if it is a weighted_vsub with sum of weights 0.

theorem eq_affine_combination_of_mem_affine_span {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [ V] [ P] {ι : Type u_4} {p1 : P} {p : ι → P} (h : p1 (set.range p)) :
∃ (s : finset ι) (w : ι → k) (hw : ∑ (i : ι) in s, w i = 1), p1 = (s.affine_combination p) w

A point in the affine_span of an indexed family is an affine_combination with sum of weights 1.

theorem mem_affine_span_iff_eq_affine_combination (k : Type u_1) (V : Type u_2) {P : Type u_3} [ring k] [ V] [ P] {ι : Type u_4} [nontrivial k] {p1 : P} {p : ι → P} :
p1 (set.range p) ∃ (s : finset ι) (w : ι → k) (hw : ∑ (i : ι) in s, w i = 1), p1 = (s.affine_combination p) w

A point is in the affine_span of an indexed family if and only if it is an affine_combination with sum of weights 1, provided the underlying ring is nontrivial.

theorem centroid_mem_affine_span_of_cast_card_ne_zero {k : Type u_1} {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} {s : finset ι} (p : ι → P) (h : (s.card) 0) :
p (set.range p)

The centroid lies in the affine span if the number of points, converted to k, is not zero.

theorem centroid_mem_affine_span_of_card_ne_zero (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} [char_zero k] {s : finset ι} (p : ι → P) (h : s.card 0) :
p (set.range p)

In the characteristic zero case, the centroid lies in the affine span if the number of points is not zero.

theorem centroid_mem_affine_span_of_nonempty (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} [char_zero k] {s : finset ι} (p : ι → P) (h : s.nonempty) :
p (set.range p)

In the characteristic zero case, the centroid lies in the affine span if the set is nonempty.

theorem centroid_mem_affine_span_of_card_eq_add_one (k : Type u_1) {V : Type u_2} {P : Type u_3} [ V] [ P] {ι : Type u_4} [char_zero k] {s : finset ι} (p : ι → P) {n : } (h : s.card = n + 1) :
p (set.range p)

In the characteristic zero case, the centroid lies in the affine span if the number of points is n + 1.

def affine_map.weighted_vsub_of_point {k : Type u_1} {V : Type u_2} (P : Type u_3) [comm_ring k] [ V] [ P] {ι : Type u_4} (s : finset ι) (w : ι → k) :
(ι → P) × P →ᵃ[k] V

A weighted sum, as an affine map on the points involved.

Equations