Skip to content

Commit 996c094

Browse files
committed
feat(Geometry/Convex): bundled type of affine maps between convex spaces (leanprover-community#42126)
1 parent 5b3f719 commit 996c094

3 files changed

Lines changed: 106 additions & 0 deletions

File tree

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4598,6 +4598,7 @@ public import Mathlib.Geometry.Convex.Cone.Face.Basic
45984598
public import Mathlib.Geometry.Convex.Cone.Pointed
45994599
public import Mathlib.Geometry.Convex.Cone.Simplicial
46004600
public import Mathlib.Geometry.Convex.Cone.TensorProduct
4601+
public import Mathlib.Geometry.Convex.ConvexSpace.AffineMap
46014602
public import Mathlib.Geometry.Convex.ConvexSpace.AffineSpace
46024603
public import Mathlib.Geometry.Convex.ConvexSpace.Defs
46034604
public import Mathlib.Geometry.Convex.ConvexSpace.Module
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/-
2+
Copyright (c) 2026 Joël Riou. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Joël Riou
5+
-/
6+
module
7+
8+
public import Mathlib.Geometry.Convex.ConvexSpace.Defs
9+
10+
/-!
11+
# Bundled affine maps between convex spaces
12+
13+
If `X` and `Y` are convex spaces (over `R`), we introduce the type
14+
`ConvexSpace.AffineMap R X Y` of bundled affine maps from `X` to `Y`.
15+
16+
-/
17+
18+
@[expose] public section
19+
20+
variable {R : Type*} [PartialOrder R] [Semiring R] [IsStrictOrderedRing R]
21+
22+
namespace Convexity.ConvexSpace
23+
24+
variable (R) in
25+
/-- The type of (bundled) affine maps between two convex spaces. -/
26+
protected structure AffineMap
27+
(X Y : Type*) [ConvexSpace R X] [ConvexSpace R Y] where
28+
/-- The underlying map of an affine map between convex spaces. -/
29+
toFun : X → Y
30+
isAffineMap_toFun : IsAffineMap R toFun := by fun_prop
31+
32+
namespace AffineMap
33+
34+
instance {X Y : Type*} [ConvexSpace R X] [ConvexSpace R Y] :
35+
FunLike (ConvexSpace.AffineMap R X Y) X Y where
36+
coe := ConvexSpace.AffineMap.toFun
37+
coe_injective := fun ⟨f, _⟩ ⟨g, _⟩ h ↦ by simpa
38+
39+
initialize_simps_projections ConvexSpace.AffineMap (toFun → apply)
40+
41+
@[ext]
42+
lemma ext {X Y : Type*} [ConvexSpace R X] [ConvexSpace R Y]
43+
{f g : ConvexSpace.AffineMap R X Y} (h : (f : X → Y) = g) : f = g :=
44+
DFunLike.coe_injective h
45+
46+
@[fun_prop]
47+
lemma isAffineMap
48+
{X Y : Type*} [ConvexSpace R X] [ConvexSpace R Y]
49+
(f : ConvexSpace.AffineMap R X Y) :
50+
IsAffineMap R f :=
51+
f.isAffineMap_toFun
52+
53+
/-- The identity map, as a bundled affine map of convex spaces. -/
54+
@[simps, implicit_reducible]
55+
def id (X : Type*) [ConvexSpace R X] :
56+
ConvexSpace.AffineMap R X X where
57+
toFun := _root_.id
58+
59+
/-- The composition of bundled affine maps between convex spaces. -/
60+
@[simps, implicit_reducible]
61+
def comp
62+
{X Y Z : Type*} [ConvexSpace R X] [ConvexSpace R Y] [ConvexSpace R Z]
63+
(g : ConvexSpace.AffineMap R Y Z) (f : ConvexSpace.AffineMap R X Y) :
64+
ConvexSpace.AffineMap R X Z where
65+
toFun := g ∘ f
66+
67+
@[simp]
68+
lemma coe_comp
69+
{X Y Z : Type*} [ConvexSpace R X] [ConvexSpace R Y] [ConvexSpace R Z]
70+
(g : ConvexSpace.AffineMap R Y Z) (f : ConvexSpace.AffineMap R X Y) :
71+
⇑(g.comp f) = g ∘ f := rfl
72+
73+
@[simp]
74+
lemma id_comp
75+
{X Y : Type*} [ConvexSpace R X] [ConvexSpace R Y]
76+
(f : ConvexSpace.AffineMap R X Y) :
77+
(AffineMap.id _).comp f = f := rfl
78+
79+
@[simp]
80+
lemma comp_id
81+
{X Y : Type*} [ConvexSpace R X] [ConvexSpace R Y]
82+
(f : ConvexSpace.AffineMap R X Y) :
83+
f.comp (.id _) = f := rfl
84+
85+
lemma assoc {X Y Z T : Type*}
86+
[ConvexSpace R X] [ConvexSpace R Y] [ConvexSpace R Z] [ConvexSpace R T]
87+
(f₁ : ConvexSpace.AffineMap R Z T) (f₂ : ConvexSpace.AffineMap R Y Z)
88+
(f₃ : ConvexSpace.AffineMap R X Y) :
89+
(f₁.comp f₂).comp f₃ = f₁.comp (f₂.comp f₃) :=
90+
rfl
91+
92+
/-- A constant map between convex spaces, as a bundled affine map. -/
93+
@[simps, implicit_reducible]
94+
def const {X Y : Type*} [ConvexSpace R X] [ConvexSpace R Y] (y : Y) :
95+
ConvexSpace.AffineMap R X Y where
96+
toFun _ := y
97+
98+
end AffineMap
99+
100+
end Convexity.ConvexSpace

Mathlib/Geometry/Convex/ConvexSpace/Defs.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ lemma IsAffineMap.comp {g : N → P} (hg : IsAffineMap R g) {f : M → N} (hf :
339339
map_sConvexComb s := by
340340
simp [StdSimplex.map_comp, hf.map_sConvexComb, hg.map_sConvexComb]
341341

342+
@[fun_prop]
343+
lemma IsAffineMap.const (x : N) :
344+
IsAffineMap R (fun (_ : M) ↦ x) where
345+
map_sConvexComb _ := by simp
346+
342347
variable (R) in
343348
@[fun_prop]
344349
lemma StdSimplex.isAffineMap_map (f : I → J) : IsAffineMap R (StdSimplex.map (R := R) f) :=

0 commit comments

Comments
 (0)