forked from leanprover-community/mathlib4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.lean
More file actions
95 lines (71 loc) · 3.67 KB
/
Copy pathModule.lean
File metadata and controls
95 lines (71 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/-
Copyright (c) 2026 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
module
public import Mathlib.Geometry.Convex.ConvexSpace.Prod
public import Mathlib.LinearAlgebra.AffineSpace.Combination
public import Mathlib.LinearAlgebra.AffineSpace.AffineMap
/-!
# Modules are convex spaces
This file shows that every module over ordered coefficients is a convex space.
## Main declarations
* `ConvexSpace.ofModule`: A semimodule space over a semiring is a convex space.
* `convexSpaceSelf`: A semiring is a convex space over itself.
* `IsModuleConvexSpace`: Predicate for a convex space and module structures to be compatible.
-/
public section
namespace Convexity
variable {R M N I : Type*} [Semiring R] [PartialOrder R] [IsStrictOrderedRing R]
[AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
/-- Any semimodule over an ordered semiring is a convex space.
This is not an instance because it creates a diamond with structural instances such as
`ConvexSpace R X → ConvexSpace R Y → ConvexSpace R (X × Y)` because
`(∑ i, f i).fst = ∑ i, (f i).fst` isn't defeq, ultimately because `Finset.sum` isn't a field of
`AddCommMonoid` but derived from them through recursion. -/
@[expose, implicit_reducible]
def ConvexSpace.ofModule : ConvexSpace R M where
sConvexComb w := w.weights.sum fun m r ↦ r • m
sConvexComb_single := by simp
assoc := by
simp [Finsupp.sum_mapDomain_index, add_smul, Finsupp.sum_sum_index, Finsupp.sum_smul_index,
mul_smul, Finsupp.smul_sum]
instance convexSpaceSelf : ConvexSpace R R := .ofModule
variable (R M) [ConvexSpace R M] in
/-- Typeclass for a convex space structure on a module to be given by weighted sums. -/
class IsModuleConvexSpace : Prop where
sConvexComb_eq_sum (w : StdSimplex R M) : w.sConvexComb = w.weights.sum fun m r ↦ r • m
export IsModuleConvexSpace (sConvexComb_eq_sum)
attribute [simp] sConvexComb_eq_sum
@[deprecated (since := "2026-04-03")]
alias _root_.convexCombination_eq_sum := sConvexComb_eq_sum
attribute [local instance] ConvexSpace.ofModule in
protected lemma IsModuleConvexSpace.ofModule : IsModuleConvexSpace R M where
sConvexComb_eq_sum _ := rfl
instance isModuleConvexSpace_self : IsModuleConvexSpace R R := .ofModule
section IsModuleConvexSpace
variable [ConvexSpace R M] [IsModuleConvexSpace R M]
/-- `iConvexComb` in a module can be expressed as a sum. -/
@[simp]
lemma iConvexComb_eq_sum (w : StdSimplex R I) (f : I → M) :
w.iConvexComb f = w.weights.sum fun i r ↦ r • f i := by
simp [iConvexComb, sConvexComb_eq_sum, Finsupp.sum_mapDomain_index, add_smul]
/-- `convexCombPair` in a module can be expressed as a sum. -/
@[simp]
lemma convexCombPair_eq_sum (a b : R) (ha hb hab) (x y : M) :
convexCombPair a b ha hb hab x y = a • x + b • y := by
classical simp [convexCombPair, sConvexComb_eq_sum, Finsupp.sum_add_index, add_smul]
instance [ConvexSpace R N] [IsModuleConvexSpace R N] : IsModuleConvexSpace R (M × N) where
sConvexComb_eq_sum w := by ext <;> simp [Finsupp.sum, Prod.fst_sum, Prod.snd_sum]
instance {ι : Type*} {M : ι → Type*} [∀ i, AddCommMonoid (M i)] [∀ i, Module R (M i)]
[∀ i, ConvexSpace R (M i)] [∀ i, IsModuleConvexSpace R (M i)] :
IsModuleConvexSpace R (∀ i, M i) where
sConvexComb_eq_sum w := by ext; simp [Finsupp.sum]
instance {ι : Type*} : IsModuleConvexSpace R (ι →₀ M) where
sConvexComb_eq_sum w := by ext; simp [Finsupp.sum]
end IsModuleConvexSpace
variable (R I) in
lemma StdSimplex.isAffineMap_weights : IsAffineMap R (weights (R := R) (M := I)) where
map_sConvexComb s := by simp [sConvexComb_eq_sum, Finsupp.sum_mapDomain_index, add_smul]
end Convexity