Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 33ea401

Browse files
committed
feat(linear_algebra/affine_space/barycentric_coords): barycentric coordinates are ratio of determinants (#10320)
The main goal of this PR is the new lemma `affine_basis.det_smul_coords_eq_camer_coords` A secondary goal is a minor refactor of barycentric coordinates so that they are associated to a new structure `affine_basis`. As well as making the API for affine spaces more similar to that of modules, this enables an extremely useful dot notation. The work here could easily be split into two PRs and I will happily do so if requested. Formalized as part of the Sphere Eversion project.
1 parent d94772b commit 33ea401

File tree

6 files changed

+206
-91
lines changed

6 files changed

+206
-91
lines changed

src/analysis/convex/combination.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -410,24 +410,24 @@ lemma mem_Icc_of_mem_std_simplex (hf : f ∈ std_simplex R ι) (x) :
410410

411411
/-- The convex hull of an affine basis is the intersection of the half-spaces defined by the
412412
corresponding barycentric coordinates. -/
413-
lemma convex_hull_affine_basis_eq_nonneg_barycentric {ι : Type*}
414-
{p : ι → E} (h_ind : affine_independent R p) (h_tot : affine_span R (range p) = ⊤) :
415-
convex_hull R (range p) = { x | ∀ i, 0 ≤ barycentric_coord h_ind h_tot i x } :=
413+
lemma convex_hull_affine_basis_eq_nonneg_barycentric {ι : Type*} (b : affine_basis ι R E) :
414+
convex_hull R (range b.points) = { x | ∀ i, 0 ≤ b.coord i x } :=
416415
begin
417416
rw convex_hull_range_eq_exists_affine_combination,
418417
ext x,
419418
split,
420419
{ rintros ⟨s, w, hw₀, hw₁, rfl⟩ i,
421420
by_cases hi : i ∈ s,
422-
{ rw barycentric_coord_apply_combination_of_mem h_ind h_tot hi hw₁,
421+
{ rw b.coord_apply_combination_of_mem hi hw₁,
423422
exact hw₀ i hi, },
424-
{ rw barycentric_coord_apply_combination_of_not_mem h_ind h_tot hi hw₁, }, },
423+
{ rw b.coord_apply_combination_of_not_mem hi hw₁, }, },
425424
{ intros hx,
426-
have hx' : x ∈ affine_span R (range p), { rw h_tot, exact affine_subspace.mem_top R E x, },
425+
have hx' : x ∈ affine_span R (range b.points),
426+
{ rw b.tot, exact affine_subspace.mem_top R E x, },
427427
obtain ⟨s, w, hw₁, rfl⟩ := (mem_affine_span_iff_eq_affine_combination R E).mp hx',
428428
refine ⟨s, w, _, hw₁, rfl⟩,
429429
intros i hi,
430430
specialize hx i,
431-
rw barycentric_coord_apply_combination_of_mem h_ind h_tot hi hw₁ at hx,
431+
rw b.coord_apply_combination_of_mem hi hw₁ at hx,
432432
exact hx, },
433433
end

src/analysis/normed_space/add_torsor_bases.lean

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,17 @@ section barycentric
2828
variables {ι 𝕜 E P : Type*} [nondiscrete_normed_field 𝕜] [complete_space 𝕜]
2929
variables [normed_group E] [normed_space 𝕜 E] [finite_dimensional 𝕜 E]
3030
variables [metric_space P] [normed_add_torsor E P]
31-
variables {p : ι → P} (h_ind : affine_independent 𝕜 p) (h_tot : affine_span 𝕜 (set.range p) = ⊤)
31+
variables (b : affine_basis ι 𝕜 P)
3232

3333
@[continuity]
34-
lemma continuous_barycentric_coord (i : ι) : continuous (barycentric_coord h_ind h_tot i) :=
34+
lemma continuous_barycentric_coord (i : ι) : continuous (b.coord i) :=
3535
affine_map.continuous_of_finite_dimensional _
3636

3737
local attribute [instance] finite_dimensional.complete
3838

3939
lemma is_open_map_barycentric_coord [nontrivial ι] (i : ι) :
40-
is_open_map (barycentric_coord h_ind h_tot i) :=
41-
open_mapping_affine
42-
(continuous_barycentric_coord h_ind h_tot i)
43-
(surjective_barycentric_coord h_ind h_tot i)
40+
is_open_map (b.coord i) :=
41+
open_mapping_affine (continuous_barycentric_coord b i) (b.surjective_coord i)
4442

4543
end barycentric
4644

@@ -53,27 +51,26 @@ to this basis.
5351
TODO Restate this result for affine spaces (instead of vector spaces) once the definition of
5452
convexity is generalised to this setting. -/
5553
lemma interior_convex_hull_aff_basis {ι E : Type*} [fintype ι] [normed_group E] [normed_space ℝ E]
56-
{p : ι → E} (h_ind : affine_independent ℝ p) (h_tot : affine_span ℝ (range p) = ⊤) :
57-
interior (convex_hull ℝ (range p)) = { x | ∀ i, 0 < barycentric_coord h_ind h_tot i x } :=
54+
(b : affine_basis ι ℝ E) :
55+
interior (convex_hull ℝ (range b.points)) = { x | ∀ i, 0 < b.coord i x } :=
5856
begin
5957
cases subsingleton_or_nontrivial ι with h h,
6058
{ -- The zero-dimensional case.
6159
haveI := h,
62-
suffices : range p = univ, { simp [this], },
63-
refine affine_subspace.eq_univ_of_subsingleton_span_eq_top _ h_tot,
60+
suffices : range (b.points) = univ, { simp [this], },
61+
refine affine_subspace.eq_univ_of_subsingleton_span_eq_top _ b.tot,
6462
rw ← image_univ,
65-
exact subsingleton.image subsingleton_of_subsingleton p, },
63+
exact subsingleton.image subsingleton_of_subsingleton b.points, },
6664
{ -- The positive-dimensional case.
6765
haveI : finite_dimensional ℝ E,
6866
{ classical,
6967
obtain ⟨i⟩ := (infer_instance : nonempty ι),
70-
have b := basis_of_aff_ind_span_eq_top h_ind h_tot i,
71-
exact finite_dimensional.of_fintype_basis b, },
72-
have : convex_hull ℝ (range p) = ⋂ i, (barycentric_coord h_ind h_tot i)⁻¹' Ici 0,
73-
{ rw convex_hull_affine_basis_eq_nonneg_barycentric h_ind h_tot, ext, simp, },
68+
exact finite_dimensional.of_fintype_basis (b.basis_of i), },
69+
have : convex_hull ℝ (range b.points) = ⋂ i, (b.coord i)⁻¹' Ici 0,
70+
{ rw convex_hull_affine_basis_eq_nonneg_barycentric b, ext, simp, },
7471
ext,
7572
simp only [this, interior_Inter_of_fintype, ← is_open_map.preimage_interior_eq_interior_preimage
76-
(continuous_barycentric_coord h_ind h_tot _) (is_open_map_barycentric_coord h_ind h_tot _),
73+
(continuous_barycentric_coord b _) (is_open_map_barycentric_coord b _),
7774
interior_Ici, mem_Inter, mem_set_of_eq, mem_Ioi, mem_preimage], },
7875
end
7976

@@ -140,17 +137,17 @@ begin
140137
obtain ⟨t, hts, h_tot, h_ind⟩ := exists_affine_independent ℝ V s,
141138
suffices : (interior (convex_hull ℝ (range (coe : t → V)))).nonempty,
142139
{ rw [subtype.range_coe_subtype, set_of_mem_eq] at this,
143-
apply nonempty.mono _ this,
140+
apply nonempty.mono _ this,
144141
mono* },
145142
haveI : fintype t := fintype_of_fin_dim_affine_independent ℝ h_ind,
146143
use finset.centroid ℝ (finset.univ : finset t) (coe : t → V),
147144
rw [h, ← @set_of_mem_eq V t, ← subtype.range_coe_subtype] at h_tot,
148-
rw interior_convex_hull_aff_basis h_ind h_tot,
145+
let b : affine_basis t ℝ V := ⟨coe, h_ind, h_tot⟩,
146+
rw interior_convex_hull_aff_basis b,
149147
have htne : (finset.univ : finset t).nonempty,
150148
{ simpa [finset.univ_nonempty_iff] using
151149
affine_subspace.nonempty_of_affine_span_eq_top ℝ V V h_tot, },
152-
simp [finset.centroid_def,
153-
barycentric_coord_apply_combination_of_mem h_ind h_tot (finset.mem_univ _)
150+
simp [finset.centroid_def, b.coord_apply_combination_of_mem (finset.mem_univ _)
154151
(finset.sum_centroid_weights_eq_one_of_nonempty ℝ (finset.univ : finset t) htne),
155152
finset.centroid_weights_apply, nat.cast_pos, inv_pos, finset.card_pos.mpr htne], },
156153
end

0 commit comments

Comments
 (0)