Zulip Chat Archive

Stream: maths

Topic: Convex space


Yaël Dillies (Oct 09 2021 at 12:27):

@Yury G. Kudryashov, at least the prod instances work perfectly!

import algebra.module.pi
import algebra.module.prod
import linear_algebra.affine_space.basic

open_locale affine

variables {𝕜 V V₁ V₂ E E₁ E₂ ι : Type*} {𝕜i Vi Ei : Π i : ι, Type*}

variables (𝕜 E)

class convex_space :=
(segment_map : 𝕜  𝕜  E  E  E)

section prod
variables [convex_space 𝕜 E₁] [convex_space 𝕜 E₂]

instance : convex_space 𝕜 (E₁ × E₂) :=
{ segment_map := λ a b x y, begin
  exact convex_space.segment_map a b x.1 y.1, convex_space.segment_map a b x.2 y.2⟩,
end }

end prod

section pi
variables [Π i, convex_space (𝕜i i) (Ei i)]

instance : convex_space (Π i : ι, 𝕜i i) (Π i : ι, Ei i) :=
{ segment_map := λ a b x y i, convex_space.segment_map (a i) (b i) (x i) (y i) }

end pi

variables {𝕜 E}

section affine
variables [ring 𝕜] [add_comm_group V] [module 𝕜 V] [affine_space V E]
  [add_comm_group V₁] [module 𝕜 V₁] [affine_space V₁ E₁]
  [add_comm_group V₂] [module 𝕜 V₂] [affine_space V₂ E₂]
  [Π i, ring (𝕜i i)] [Π i, add_comm_group (Vi i)] [Π i, module (𝕜i i) (Vi i)]
  [Π i, affine_space (Vi i) (Ei i)]

section
include V

instance affine_space.to_convex_space : convex_space 𝕜 E :=
{ segment_map := λ a _ x y, a  (y -ᵥ x) +ᵥ x }
end

include V₁ V₂

example : @affine_space.to_convex_space 𝕜 _ _ _ _ _ (@prod.add_torsor V₁ E₁ V₂ E₂ _ _ _ _) =
  @prod.convex_space 𝕜 E₁ E₂ _ _ :=
rfl

example : @affine_space.to_convex_space (Π i, 𝕜i i) (Π i, Vi i) (Π i, Ei i) _ _
  (@pi.module' ι 𝕜i Vi _ _ _) (@pi.add_torsor ι Vi _ Ei _) = @pi.convex_space ι 𝕜i Ei _ :=
sorry --totally unrelated diamond issue?

end affine

section module
variables [semiring 𝕜] [add_comm_monoid E] [module 𝕜 E] [add_comm_monoid E₁] [module 𝕜 E₁]
  [add_comm_monoid E₂] [module 𝕜 E₂]
  [Π i, semiring (𝕜i i)] [Π i, add_comm_monoid (Ei i)] [Π i, module (𝕜i i) (Ei i)]

instance module.to_convex_space : convex_space 𝕜 E :=
{ segment_map := λ a b x y, a  x + b  y }

example : @module.to_convex_space 𝕜 (E₁ × E₂) _ _ (@prod.module 𝕜 E₁ E₂ _ _ _ _ _) = @prod.convex_space 𝕜 E₁ E₂ _ _
  :=
rfl

example : @module.to_convex_space _ _ _ _ (@pi.module' ι 𝕜i Ei _ _ _) = @pi.convex_space ι 𝕜i Ei _
  :=
rfl

end module

Yaël Dillies (Oct 09 2021 at 12:55):

This pi instance also works for defeqness with module. I didn't manage to try for affine_space because I seem to be getting another completely unrelated diamond...

Yaël Dillies (Oct 09 2021 at 12:57):

I've updated the snippet above.

Yaël Dillies (Oct 09 2021 at 13:07):

And here's the dreaded diamond vector space diamond.

example [ring 𝕜] [add_comm_group E] [module 𝕜 E] :
  @affine_space.to_convex_space 𝕜 E E _ _ _ _ = @module.to_convex_space 𝕜 E _ _ _ :=
rfl --fails

It is actually unprovable because I haven't required the two weights to sum up to 1 in segment_map. Should I add it?

Yury G. Kudryashov (Oct 09 2021 at 14:14):

Even if you add it, we can't make it rfl.

Yury G. Kudryashov (Oct 09 2021 at 14:15):

And I don't know what to do.

Yaël Dillies (Oct 09 2021 at 14:39):

Yeah, I know we can't, because it requires using h : a + b = 1 :worried:

Yaël Dillies (Oct 09 2021 at 14:40):

My point was that at least we could make the instances propeq, because they currently are not (they differ on the junk values of segment_map).

Reid Barton (Oct 09 2021 at 15:22):

If 𝕜 is a ring there would be no problem, right? You could define segment_map for a module using the same sort of formula as for an affine_space (and then just drop the redundant second argument of segment_map completely)

Reid Barton (Oct 09 2021 at 15:26):

Do we really need convex spaces over semirings?

Yaël Dillies (Oct 09 2021 at 15:31):

EDIT: Ah yes, I see what you mean

Yaël Dillies (Oct 09 2021 at 15:31):

But then there's no point in defining convex spaces anymore.

Yaël Dillies (Oct 09 2021 at 15:36):

I am working on branch#convex_space

Reid Barton (Oct 09 2021 at 15:43):

Yaël Dillies said:

But then there's no point in defining convex spaces anymore.

I think I'm missing some context on why you're interested in convex spaces in the first place

Yaël Dillies (Oct 09 2021 at 15:44):

I'm defining convex spaces to be able to generalize convexity to both affine spaces and modules. The convexity refactor generalized convexity to modules, and now we want it in affine spaces.

Reid Barton (Oct 09 2021 at 15:46):

Isn't a module an affine space?

Yaël Dillies (Oct 09 2021 at 15:47):

Not if it isn't over a ring but just a semiring, that's the point.

Yaël Dillies (Oct 09 2021 at 15:48):

(mathlib's module, mathematicians' semimodule)

Reid Barton (Oct 09 2021 at 15:48):

Well then that gets back to my original question, why do we care about convexity over semirings

Reid Barton (Oct 09 2021 at 15:48):

But also, I think there is more than one notion of affine space

Yaël Dillies (Oct 09 2021 at 15:48):

Oh? Is there one that doesn't intrinsically require substraction?

Yaël Dillies (Oct 09 2021 at 15:50):

Reid Barton said:

Well then that gets back to my original question, why do we care about convexity over semirings

And, for that, ask @Yakov Pechersky

Reid Barton (Oct 09 2021 at 15:51):

There is https://ncatlab.org/nlab/show/affine+space#unbiased_definition. Basically it means you have a "linear combination" operation AnAA^n \to A for each (c1,,cn)kn(c_1, \ldots, c_n) \in k^n with c1++cn=1c_1 + \cdots + c_n = 1, and they have to satisfy the equations expected of general linear combinations.

Reid Barton (Oct 09 2021 at 15:51):

Note that under this definition, the empty set would also be considered an affine space unless you explicitly rule it out

Yaël Dillies (Oct 09 2021 at 15:51):

Ah well that's what I'm trying to define here :grinning:

Yaël Dillies (Oct 09 2021 at 15:54):

cf https://ncatlab.org/nlab/show/convex+space

Kevin Buzzard (Oct 09 2021 at 16:04):

In my mind the whole point of an affine space is that it is a homogeneous object which looks everywhere locally like the thing it's modelled on. Additive groups look the same everywhere locally because left or right addition by a fixed element is a bijection, so affine spaces over additive groups are reasonable objects. The definition does not use negation explicitly but it's using it implicitly to make the definition capture the concept which mathematicians are trying to model. If one defines affine spaces over modules then I could imagine that the naive definition is not the useful one because monoids like {0,2,3,4,5,...} look different near 0 to how they look near 37 so you can't be a homogeneous space (another word for affine space) over this object because the object itself isn't homogeneous.

This reminds me of group actions. The definition of a group action doesn't mention inverses so it can in theory be made for monoids. However if you make it for monoids then there are two possibilities -- a multiplicative map into End(S) or a multiplicative map into Aut(S). For groups these are equivalent but for monoids they are not and so one has to decide which one is the useful one rather than just choosing one randomly because it's just what happens to be what you get if you write down the standard group definition (which doesn't assume actions are invertible because this follows from the group axioms) and then apply it to monoids.

Reid Barton (Oct 09 2021 at 16:11):

Part of the confusion is that mathlib (and Kevin) uses "affine space" in the sense of a torsor, but in the context of convexity there's another, more obviously relevant notion: something where you can form affine combinations.

Yaël Dillies (Oct 09 2021 at 16:16):

Yes, totally agreed! All I want is an affine-combinations space.

Kevin Buzzard (Oct 09 2021 at 16:18):

You can have torsors for an abelian group (and probably even more general objects but my rant above is suggesting that they might not be useful objects for monoids) but for this notion of affine space I guess you need a 1? And presumably for semirings it's the same situation --the definition we normally use happens to make sense but it's not clear (at least to me) that it's the useful one if there's no subtraction

Kevin Buzzard (Oct 09 2021 at 16:19):

For example any set would be an affine space (in the sense of linear combinations) over the naturals this way, right?

Reid Barton (Oct 09 2021 at 16:19):

Any torsor for an abelian group is an affine space (in the sense of linear combinations) over Z\mathbb{Z}

Reid Barton (Oct 09 2021 at 16:21):

Right, affine spaces over N\mathbb{N} is just the trivial theory (maybe plus the assumption that it is nonempty)

Kevin Buzzard (Oct 09 2021 at 16:21):

Is that actually used though?

Reid Barton (Oct 09 2021 at 16:21):

But then affine spaces over R0\mathbb{R}_{\ge 0} are the convex spaces.

Kevin Buzzard (Oct 09 2021 at 16:21):

I see!

Yaël Dillies (Oct 09 2021 at 16:22):

Yeah, anything is a convex space over N\N, and every set is N\N-convex.

Reid Barton (Oct 09 2021 at 16:23):

So you could do that, but it doesn't really matter because you could also define "convex space" directly with the nonnegativity assumption built in, and of course R0\mathbb{R}_{\ge 0} is the positive cone of a ring.

Kevin Buzzard (Oct 09 2021 at 16:23):

Is there a use for convex spaces which aren't subspaces of something sensible like a torsor for a real vector space?

Reid Barton (Oct 09 2021 at 16:24):

The nLab page has examples, apparently being embeddable in a torsor for a vector space is a kind of "cancellability" condition.

Yaël Dillies (Oct 09 2021 at 16:25):

Yeah, precisely because you get negation.

Reid Barton (Oct 09 2021 at 16:27):

The question I think is whether there is a use where the free convex spaces (i.e. the spaces parameterizing convex linear combinations) are themselves not embeddable in a module over a ring, and this is what I'm skeptical about

Reid Barton (Oct 09 2021 at 16:28):

so basically, convexity over a noncancellative semiring

Yaël Dillies (Oct 09 2021 at 16:31):

This I have no idea. But we can definitely come up with examples. What about ennreal-convexity, for example?

Reid Barton (Oct 09 2021 at 16:32):

it's the same as ordinary convexity, because \infty doesn't lie in [0,1][0, 1]

Reid Barton (Oct 09 2021 at 16:33):

So what I said above wasn't a precise characterization, it's more like just [0,1]R[0, 1] \subset R has to be cancellative in some sense, or something.

Yaël Dillies (Oct 09 2021 at 16:36):

For context, Yakov was interested in tropical geometry, where the usual stuff happens in R0\mathbb R_{\ge 0}.

Kevin Buzzard (Oct 09 2021 at 16:37):

But this is cancellative so the pathologies (non-homogeneity) I was concerned about don't show up.

Yaël Dillies (Oct 09 2021 at 16:37):

So I guess this could be converted to R\R-convexity, but at the price of coercing everywhere.

Kevin Buzzard (Oct 09 2021 at 16:38):

By R\R-convexity do you mean the useless notion (must be able to do av+bwav+bw if a+b=1a+b=1 with no positivity constraints, so it's just an affine space) or the usual notion?

Reid Barton (Oct 09 2021 at 16:39):

I meant the usual one

Reid Barton (Oct 09 2021 at 16:50):

Also when people talk about convexity in tropical geometry, I think they mean convexity in the usual sense (involving the usual multiplication on the reals), right?

Yaël Dillies (Oct 09 2021 at 16:52):

Apparently not. https://arxiv.org/pdf/math/0308254.pdf

Yaël Dillies (Oct 09 2021 at 16:53):

And the tropical semiring is most definitely not cancellative.

Reid Barton (Oct 09 2021 at 16:53):

What are you referencing specifically?

Yaël Dillies (Oct 09 2021 at 16:54):

Their definition of "tropical convexity"

Reid Barton (Oct 09 2021 at 16:55):

Really?

Yaël Dillies (Oct 09 2021 at 16:55):

𝕜-tropical convexity is precisely tropical 𝕜-convexity.

Reid Barton (Oct 09 2021 at 16:55):

image.png

Reid Barton (Oct 09 2021 at 16:56):

This one?

Yaël Dillies (Oct 09 2021 at 16:56):

Yeah

Yaël Dillies (Oct 09 2021 at 16:58):

I am not quite sure of what happened to a + b = 1.

Reid Barton (Oct 09 2021 at 16:58):

How so?

Yaël Dillies (Oct 09 2021 at 17:00):

Theorically, 1 : tropical 𝕜is 0 : 𝕜, so it should translate to min a b = 0, which isn't the case here?

Reid Barton (Oct 09 2021 at 17:00):

It seems much more like being a tropical 𝕜-module, right?

Yaël Dillies (Oct 09 2021 at 17:00):

Yeah actually

David Wärn (Oct 09 2021 at 18:04):

If you're used to thinking about vector spaces, then you might be surprised by the notion of "module over a ring" which allows weird non-free modules, but that doesn't mean it's not a good notion

David Wärn (Oct 09 2021 at 18:05):

I would assume that this unbiased notion of affine combination space is also the good one for general semirings

David Wärn (Oct 09 2021 at 18:06):

Is there a reason to believe it's not?

Yaël Dillies (Oct 09 2021 at 18:18):

That's where I'm coming from, indeed.

Kevin Buzzard (Oct 09 2021 at 18:22):

But the monoid action is an example where the naive approach ("just copy the axioms for a group action") gives you something which you might not want, because you have to add the extra axiom that m*_ is bijective, which is automatic in the group case.

Kevin Buzzard (Oct 09 2021 at 18:24):

Put another way, there are two definitions of group action, both of which make sense for monoids and give different structures

David Wärn (Oct 09 2021 at 18:34):

Right, but why would you require m* to be bijective? It's like saying modules have to be free

Kevin Buzzard (Oct 09 2021 at 18:57):

I'm saying that I've seen the definition of a group action on a set given as being a multiplicative map from G to Aut(S) and I'm observing that this definition makes sense for monoids, and I'm deducing that just because a random mathlib definition makes sense in some larger generality doesn't mean it's the "correct" definition in some larger generality, and the proof is that there are two definitions of a group action both of which make sense for monoids and become different concepts

Patrick Massot (Oct 09 2021 at 18:59):

The definition of monoid actions definitely doesn't ask for bijective maps.

Kevin Buzzard (Oct 09 2021 at 18:59):

Sure

Kevin Buzzard (Oct 09 2021 at 19:00):

But you can't deduce from this that an arbitrary definition which makes sense in more generality is "correct" in that greater generality

Kevin Buzzard (Oct 09 2021 at 19:00):

And my argument gives a proof that this can't always be true

Yury G. Kudryashov (Oct 09 2021 at 19:04):

Another reason to talk about convexity in nnreal-semimodules: the set of invariant measures of a map is convex.

Yaël Dillies (Oct 09 2021 at 19:18):

Ahah! This example is interesting because one thing we forgot is that having negative elements in the base (semi)ring also affects the space. That's because an add_comm_monoid acted on by a ring through module is promotable to an add_comm_group, negation in the space being -1 • x.

Yaël Dillies (Oct 09 2021 at 19:19):

So, by forcing the scalars to be a ring , we a fortiori force the space to be an add_comm_group.

David Wärn (Oct 09 2021 at 19:35):

Kevin Buzzard said:

But you can't deduce from this that an arbitrary definition which makes sense in more generality is "correct" in that greater generality

Sure, you can't deduce that "unbiased affine combination space" is a good notion just because it specializes to give affine spaces over fields. But still, I think it's definitely a good notion. For example, it specializes to give both the usual affine spaces and convex spaces, the category of such spaces is monadic over Type (so it's a nice algebraic notion), it has a forgetful functor from the category of semimodules, and you get the usual restriction-of-scalar functors (which is to say that you'll get lots of examples of these spaces). What's there not to like? In general this kind of space won't be a torsor for some semimodule, but I think this is just like how modules aren't generally free, and rings don't generally have unique factorisation (i.e., it's not necessarily a sign that you have the wrong notion).

Kevin Buzzard (Oct 09 2021 at 22:08):

If you've put some thought into it and understand that it's the correct definition then that's fine :-) My point is only that this needs to be done. Thanks for doing it :-)

Yaël Dillies (Oct 10 2021 at 06:28):

Should I understand that I have your blessing for defining them? :grinning_face_with_smiling_eyes: How should they be called?

David Wärn (Oct 10 2021 at 20:15):

You could say affine_combination_space to distinguish from the torsor affine_space, but it's a mouthful

Yaël Dillies (Oct 10 2021 at 20:16):

Is convex_space fine?

David Wärn (Oct 10 2021 at 20:16):

What do you mean by convex_space?

Yaël Dillies (Oct 10 2021 at 20:16):

The above

Yaël Dillies (Oct 10 2021 at 20:17):

What's bothering me with this name is that we never have to restrict to positive coefficients.

David Wärn (Oct 10 2021 at 20:17):

So an affine combination space over a semiring R?

Yaël Dillies (Oct 10 2021 at 20:17):

Yeah

David Wärn (Oct 10 2021 at 20:19):

It's a nice name I suppose, but maybe a bit misleading since R can have negative elements

David Wärn (Oct 10 2021 at 20:35):

To be clear, I'm not at all an expert on this, and agree that it's not clear what the best definition to formalise is. After thinking about this some more, my armchair understanding is that affine combination space isn't a very good notion for every semiring R, although it makes sense when R is a ring, or has enough multiplicative inverse (like nnreal). It was pointed out above that every set is an affine combination space over N\N in a unique way. But in fact there is a sensible notion of convex subsets in Z\Z-modules like Zn\Z^n, which you can use also to define convex functions (those for which the upper graph is convex); you just won't get it from thinking about Zn\Z^n as an affine combination space over N\N.

In this situation, you might prefer to use something like the "slice category" definition mention on nlab. Namely, say an affine space over a semiring RR is an RR-semimodule PP together with a linear map w:PRw : P \to R. Think of an element of PP as a kind of weighted sum, and ww as giving its weight, so really w1(1)w^{-1}(1) is what you would normally think of as the underlying type of an affine space, but if RR doesn't have enough multiplicative inverses then this type doesn't tell you very much about all of PP. Now you get a "forgetful functor" MM×RM \mapsto M \times R from semimodules to affine spaces. Taking R=NR = \N, I believe you can understand convex subsets of Zn\Z^n in terms of the "underlying" affine space.

Yaël Dillies (Oct 10 2021 at 20:46):

With that definition, would {0, 2} be Z\Z-convex in Z\Z?

Adam Topaz (Oct 10 2021 at 20:57):

I haven't been following this discussion at all, but I do think it's worthwhile to mention that the axioms of a convex space (or whatever you want to call it) can be formalized as an abstract algebraic gadget, without reference to any ring or semirng.
Essentially, consider a commutative monoid with 00, say RR, endowed with a function σ:RR\sigma : R \to R and a function R3RR^3 \to R denoted (x,a,b)Cx(a,b)(x,a,b) \mapsto C_x(a,b). Think of this as a signature (in the sense of first order logic), and consider the axioms appearing in nlab#convex-space which can all be written down without reference to any (semi)ring, given the data above (where σ(t)\sigma(t) should take the place of 1t1-t), together with axioms like σ(1)=0\sigma(1) = 0 and σ(σ(t))=t\sigma(\sigma(t)) = t for all tt.

Adam Topaz (Oct 10 2021 at 21:00):

(I don't know if these axioms actually give the same theory that's satisfied by all rings, but it's certainly contained in there.)

Yury G. Kudryashov (Oct 10 2021 at 21:01):

I see that the focus moved to "what is the right super-general definition?". I think that instead of this we should decide what example do we care about, then write a definition that will work in these cases. Whoever starts caring about a use case not covered by the current definition may refactor.

Yury G. Kudryashov (Oct 10 2021 at 21:01):

@Adam Topaz How exactly do you suggest to encode this in Lean?

Adam Topaz (Oct 10 2021 at 21:02):

class cing (A : Type*) extends monoid_with_zero A :=
(sigma : A \to A)
(C : A \to A \to A \to A)
... axioms

Yaël Dillies (Oct 10 2021 at 21:02):

That's what I started doing on branch#convex_space, right?

Yury G. Kudryashov (Oct 10 2021 at 21:03):

@Adam Topaz And what is a convex_space?

Yaël Dillies (Oct 10 2021 at 21:03):

I haven't yet gone through all the axioms, but this is certainly where I was heading.

Adam Topaz (Oct 10 2021 at 21:03):

Yaël Dillies said:

That's what I started doing on branch#convex_space, right?

It looks like you're working with semirings, rigght?

Adam Topaz (Oct 10 2021 at 21:03):

Yury G. Kudryashov said:

Adam Topaz And what is a convex_space?

The analogue of a module over a cing

Yaël Dillies (Oct 10 2021 at 21:03):

Only because they give me a 1. I could relax to add_monoid + has_one.

Adam Topaz (Oct 10 2021 at 21:04):

Well, I want, e.g. {0,1}\{0,1\} with σ(0)=1\sigma(0) = 1 to be such a gadget as well... no addition necessary

Yaël Dillies (Oct 10 2021 at 21:04):

Wait sorry what's a cing? :astonished:

Yury G. Kudryashov (Oct 10 2021 at 21:04):

@Adam Topaz Is there any specific example you care about where this generality is important?

Adam Topaz (Oct 10 2021 at 21:05):

This is the smallest reasonable algebraic theory where one can define the analogue of Milnor K-theory, but I don't know if anything meaningful can be said about such gadgets in the abstract

Yury G. Kudryashov (Oct 10 2021 at 21:06):

I have these examples in my head:

  • real vector spaces;
  • vector spaces over rational numbers;
  • affine spaces over real or rational numbers;
  • nnreal-semimodules, including measures.

Adam Topaz (Oct 10 2021 at 21:06):

Yury G. Kudryashov said:

Adam Topaz Is there any specific example you care about where this generality is important?

The interval [0,1][0,1] would also be an example.

Yury G. Kudryashov (Oct 10 2021 at 21:07):

I'm talking about convex spaces, not instances of cing.

Yaël Dillies (Oct 10 2021 at 21:07):

I assume going from my definition of convex space to your abstract gadgets is a rather independent step, right?

Adam Topaz (Oct 10 2021 at 21:07):

Ah, well I think "modules" over [0,1][0,1] in this sense should be the usual convex spaces (well, maybe there would be some weird quotients)

Yury G. Kudryashov (Oct 10 2021 at 21:08):

I don't think that we should generalize for the sake of generalization.

Yaël Dillies (Oct 10 2021 at 21:08):

I'm not against it, but clearly refactoring from semimodules to convex/unbiased affine spaces is gonna be some sleepless nights already.

Yaël Dillies (Oct 10 2021 at 21:08):

Yury G. Kudryashov said:

I don't think that we should generalize for the sake of generalization.

Category-theory-phobic :rofl:

Yury G. Kudryashov (Oct 10 2021 at 21:09):

@Adam Topaz The main problem I see with any definition is that once we have a theory that covers both modules over nnreals and real affine spaces, we get a diamond for real vector spaces.

Adam Topaz (Oct 10 2021 at 21:09):

Yes @Yury G. Kudryashov, I agree, this would not solve any diamond issues.

Adam Topaz (Oct 10 2021 at 21:10):

(Sorry, i have to run! I would be happy to discuss this laterr!)

Yaël Dillies (Oct 10 2021 at 21:10):

Well, there's no way around that diamond. So why not go for it anyway? Having a theory accessible through a def is better than not having it at all.

Yaël Dillies (Oct 11 2021 at 10:11):

Wait, once we have convex_space, what would be the point of affine_space? Maybe we can generalize the definition of affine_space rather than defining a new class.

David Wärn (Oct 11 2021 at 10:45):

Yes, it might be a good idea to change the definition of affine_space to be an affine combination space. You would get a different API, since you wouldn't have an unbundled vector space parameter. Instead you could define "the module associated to an affine space", and prove that any nonempty affine space over a ring is a torsor for this module.

Yury G. Kudryashov (Oct 11 2021 at 19:24):

BTW, this will solve the diamond. We can have a definition (not an instance) add_torsor.to_affine_space and a type class saying that add torsor and affine space structures agree.

Yury G. Kudryashov (Oct 11 2021 at 19:24):

BTW, this will solve the diamond. We can have a definition (not an instance) add_torsor.to_affine_space and a type class saying that add torsor and affine space structures agree.

Yury G. Kudryashov (Oct 11 2021 at 19:24):

But this is a large refactor

Yury G. Kudryashov (Oct 11 2021 at 19:26):

And you shouldn't add an instance of add torsor with a manually constructed module because the additive group in the definition of add torsor is an out param

Yury G. Kudryashov (Oct 11 2021 at 20:57):

What do you plan to use as the basic operation in the new affine_space? Something like Π (x y : R), x + y = 1 → P → P → P?

Yury G. Kudryashov (Oct 12 2021 at 00:15):

Or affine_comb (f : P →₀ R) (hf : f.sum id = 1) : P?

Reid Barton (Oct 12 2021 at 00:23):

I think the laws are (a lot?) easier to state for the second form

Yury G. Kudryashov (Oct 12 2021 at 00:53):

In the first form the axioms will be similar to those in https://ncatlab.org/nlab/show/convex+space#definition

Yury G. Kudryashov (Oct 12 2021 at 00:54):

But building affine_comb from the binary operation is not trivial.

Joseph Myers (Oct 12 2021 at 01:37):

Note that the vast bulk of lemmas about affine_space are really lemmas about add_torsor for a module (they involve vectors, they don't involve affine combinations), and, similarly, most of the lemmas about affine_subspace are really about a sub-torsor as they also involve vectors (constrained so that the subgroup is a submodule). So if you redefine affine_space, existing lemmas (that currently use the affine_space notation) should probably change to be about add_torsor and something similar should be done for renaming affine_subspace.

Yaël Dillies (Oct 12 2021 at 07:06):

Yury G. Kudryashov said:

But this is a large refactor

I have time to spare. I'm a Cambridge student :rofl:

Yaël Dillies (Oct 12 2021 at 07:07):

So are we heading towards changing affine_space from an abbreviation of add_torsor to an unbiased affine space?

Antoine Chambert-Loir (Oct 14 2021 at 07:51):

The definition of a monoid action will imply that invertible elements map to invertible elements, because it maps the unit element of the monoid to identity. But think of a semigroup action, where semigroups are just associative laws, possibly without unit — then a group action would not be a semigroup action of a group.

Similar question : a monoid action can be defined either as a map $M\times X \to X$ (plus axioms) or as a morphism of monoids from $M$ to the monoid of self-maps of $X$. For mathematicians, both are rapidly equivalent, and we switch from one to another (Bourbaki has a stylistic convention, speaks of action and of operation), but for automatic formalization, how are the two reconciled?

And for actions of topological monoids, the first definition is the good one, namely, the continuity of the map $M\times X\to X$, because for most applications, eg, representations of topological groups on Hilbert spaces, the map $M\to \operatorname{Aut}(X)$ is not continuous.

Johan Commelin (Oct 14 2021 at 07:54):

(Tip: Zulip needs double $$s around maths.)
We tend to focus on the M×XXM × X → X approach. It can be easily combined with nice notation, and works well together with forgetting structure. (E.g. a module is a monoid action. And it is the exact same map M×XXM × X → X, but for the MEnd(X)M → \text{End}(X) you would need to change the version of End\text{End} that you are considering.)

Yaël Dillies (Oct 14 2021 at 09:47):

I lost track of the discussion. Can someone explain me what I should do?

David Wärn (Oct 14 2021 at 09:53):

I think you should define unbiased affine combination spaces over a semiring R, and call it affine_space R

Yaël Dillies (Oct 14 2021 at 09:53):

affine_space R P, rather?

Yaël Dillies (Oct 14 2021 at 09:56):

I mean something like

class affine_space' (𝕜 E : Type*) [semiring 𝕜] :=
(affine_comb (f : E →₀ 𝕜) (hf : f.sum (λ x, id) = 1) : E)
-- more axioms

Yaël Dillies (Oct 14 2021 at 09:57):

Do you know what axioms I need?

David Wärn (Oct 14 2021 at 09:58):

You want an "associativity axiom", which says that an affine combination of affine combinations is ... some affine combination. And a "unitality" axiom which says that if you combine just one point with weight one, you get that point

Yaël Dillies (Oct 14 2021 at 09:58):

Is that it?

David Wärn (Oct 14 2021 at 10:00):

I think so. This is a general way of stating axioms for algebraic theories (you just have the two axioms for algebras over a monad)

Yaël Dillies (Oct 14 2021 at 10:02):

Okay. And what about this?
Yury G. Kudryashov said:

BTW, this will solve the diamond. We can have a definition (not an instance) add_torsor.to_affine_space and a type class saying that add torsor and affine space structures agree.

Scott Morrison (Oct 14 2021 at 10:09):

The associativity axiom is going to be quite painful expressed in terms of finitely supported functions!

Scott Morrison (Oct 14 2021 at 10:09):

It would be much easier to state in terms of indexing types.

Yaël Dillies (Oct 14 2021 at 10:12):

Do you mean affine_comb (ι : Type*) (f : ι →₀ 𝕜) (hf : f.sum (λ x, id) = 1) : E or affine_comb (ι : Type*) [fintype ι] (f : ι → 𝕜) (hf : ∑ x : ι, f x = 1) : E?

Scott Morrison (Oct 14 2021 at 10:14):

I think you need something more complicated: you need an indexing type, and both a function into k and a function into E

Scott Morrison (Oct 14 2021 at 10:14):

(to tell you the weights, and the points)

Reid Barton (Oct 14 2021 at 10:15):

It's still going to be a little awkward with indexing types for universe reasons

Yaël Dillies (Oct 14 2021 at 10:17):

Oh yeah of course. I mean, this is really about putting docs#finset.center_mass (or docs#finset.affine_combination) inside the typeclass.

Reid Barton (Oct 14 2021 at 10:17):

Maybe, since the type is finite anyways, you should use Type

Reid Barton (Oct 14 2021 at 10:19):

I guess you can define a universe-polymorphic affine_comb after the fact

Reid Barton (Oct 14 2021 at 10:21):

By the same logic, you could just use fin n as the indexing type but then it's again a little awkward to state associativity

David Wärn (Oct 14 2021 at 10:24):

I don't think it's too bad in terms of finsupp. Here's the statement of associativity, modulo two sorries (edit: hopefully it's right this time)

variables (R : Type) [semiring R] (α : Type)

def T : Type := { v : α →₀ R // v.sum (λ _, id) = 1 }

variables {R α}

def map {β} (f : α  β) (v : T R α) : T R β := v.val.map_domain f, sorry
def μ (v : T R (T R α)) : T R α := v.val.sum (λ w r, r  w.val), sorry
def associativity (comb : T R α  α) : Prop :=  v, comb (μ v) = comb (map comb v)

Reid Barton (Oct 14 2021 at 10:27):

For the convex version we have docs#pmf, though it's limited to real

Yaël Dillies (Oct 14 2021 at 16:04):

Given that affine_space is used quite widely, what do you think of first defining affine_space' and slowly refactor? Or do you prefer that I instead first rename all the affine_space to add_torsor?

Joseph Myers (Oct 15 2021 at 00:12):

You definitely need to define some kind of def for affine combinations (separate from that appearing in the type class) after the fact, even apart from any universe issues with index types, simply to get a version which is a bundled affine map (whatever form of affine maps makes sense with this affine space definition; I suppose that's maps that preserve affine combinations, with the linkage to linear maps then becoming something defined only for the type class that asserts propositional equality between the affine combinations in the definition and the affine combinations derived from the add_torsor structure).


Last updated: Dec 20 2023 at 11:08 UTC