Zulip Chat Archive
Stream: general
Topic: Convexity refactor
Yaël Dillies (Sep 13 2021 at 21:21):
State of the convexity refactor
- port convexity to vector spaces (
[module 𝕜 E]
) - port convexity to affine spaces (
[module 𝕜 V] [affine_space V E]
). Very much not done.
Yaël Dillies (Sep 13 2021 at 21:23):
Little update, #9058 (finally!) compiles. It was much easier to generalize convex
and convex_hull
than segment
and open_segment
because somehow their properties are closer to the axioms and require less typeclass fuss.
Yaël Dillies (Sep 13 2021 at 21:25):
BTw @Yury G. Kudryashov I think you should have your say on this, as you started #4787.
Yury G. Kudryashov (Sep 13 2021 at 21:26):
I failed to localize my porting efforts, created a huge mess, then failed to make it ready for review. So, I'm not sure that I should have a say on this. ;)
Yury G. Kudryashov (Sep 13 2021 at 21:27):
IMHO porting to affine spaces is not much harder than porting to modules.
Yaël Dillies (Sep 13 2021 at 21:28):
Oh that's not kindly worded for yourself! I would rather say that you opened my eyes a PR, sparked the idea in me, warned me of the monstruousity of the refactor, and then let me the opportunity to have a go myself!
Yaël Dillies (Sep 13 2021 at 21:29):
Yury G. Kudryashov said:
IMHO porting to affine spaces is not much harder than porting to modules.
That's exactly what I thought, but one design decision I have done (which is very easily reversible, though) is that I allow convexity and stuff even the space has no negation.
Yaël Dillies (Sep 13 2021 at 21:30):
And that's incompatible with affine spaces, right? It looks like generalization of convexity branches here and there's no common ancestor we can generalize to.
Yury G. Kudryashov (Sep 13 2021 at 21:32):
Here is a problem I can't solve without creating diamonds. You can define convexity_space
to be a space with convex combinations ∀ x y : R, 0 ≤ x → 0 ≤ y → x + y = 1 → E → E → E
with some natural axioms.
Yury G. Kudryashov (Sep 13 2021 at 21:32):
Then you have two ways to go from vector_space R E
to convexity_space R E
.
Yury G. Kudryashov (Sep 13 2021 at 21:33):
(deleted)
Yury G. Kudryashov (Sep 13 2021 at 21:35):
One way is to use module
structure and treat R
as a semiring. Another is to use affine_space
structure (but this needs subtraction).
Yaël Dillies (Sep 13 2021 at 21:36):
Oh, interesting. I will sleep on it.
Yury G. Kudryashov (Sep 13 2021 at 21:37):
While these two ways result in equal convexity structures, it seems that we can't make these structures defeq.
Yury G. Kudryashov (Sep 13 2021 at 21:38):
So, only one of the ways can be an instance.
Yaël Dillies (Sep 13 2021 at 21:38):
Are you saying we should have convexity_space
?
Frédéric Dupuis (Sep 13 2021 at 21:56):
I'm having flashbacks to some old conversations:
https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/convexity
https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/3728.3A.20define.20ordered.20semimodules.20and.20generalize.20convexity.2E.2E.2E
Yury G. Kudryashov (Sep 13 2021 at 22:05):
@Yaël Dillies No, I've described a half-solution to the problem. Since it doesn't solve the problem, I don't suggest we implement it.
Yury G. Kudryashov (Sep 13 2021 at 22:06):
On the one hand, we can't have a notion of convexity that works both for modules over nnreal
and for affine spaces without an abstraction like convexity_space
.
Yury G. Kudryashov (Sep 13 2021 at 22:06):
On the other hand, I'm not sure that we really need both.
Yaël Dillies (Sep 14 2021 at 06:52):
Frédéric Dupuis said:
I'm having flashbacks to some old conversations:
Pleas have flashbacks more often!
Yaël Dillies (Sep 14 2021 at 06:57):
If we were to implement your half-solution, Yury, then I feel like the convex operation in a vector space should be inherited from the module
side of things, rather than the affine_space
one, because it is much closer to the axioms of a vector space.
Yaël Dillies (Sep 17 2021 at 12:35):
Next up is #9247! It's just splitting analysis.convex.basic
further.
Johan Commelin (Sep 17 2021 at 12:54):
Fantastic! That's easy to review (-;
Yaël Dillies (Sep 17 2021 at 16:54):
finset.center_mass
uses division, which makes it very restrictive. How much do people care about that division being there?
Yaël Dillies (Sep 17 2021 at 16:59):
From my point of view,
Pros: Doesn't require that the sum of the weights is 1, but merely that it's positive.
Cons: Needs a field. Doesn't follow affine_combination
.
Yury G. Kudryashov (Sep 17 2021 at 17:01):
It was written before affine_combination
.
Yaël Dillies (Sep 17 2021 at 17:01):
This looks as if we had taken docs#convex_iff_div to be the definition of convexity.
Yury G. Kudryashov (Sep 17 2021 at 17:01):
Feel free to change it.
Yaël Dillies (Sep 17 2021 at 17:01):
Okay :smile:
Yaël Dillies (Sep 17 2021 at 17:02):
What do you think about renaming it linear_combination
?
Yury G. Kudryashov (Sep 17 2021 at 17:03):
You can also introduce a proper type for {x : ι →₀ R | (∀ i, 0 ≤ x i) ∧ x.sum (λ i, id)}
.
Yury G. Kudryashov (Sep 17 2021 at 17:03):
This is the free object in the category of convex spaces.
Yury G. Kudryashov (Sep 17 2021 at 17:04):
See what we do about linear combinations in linear algebra.
Yaël Dillies (Sep 17 2021 at 17:05):
Yury G. Kudryashov said:
This is the free object in the category of convex spaces.
Erhm... will look that up :sweat:
Yury G. Kudryashov (Sep 17 2021 at 17:14):
I mean that for any convex space and a map f : ι → E
you have a unique map from g : {x : ι →₀ R | (∀ i, 0 ≤ x i) ∧ x.sum (λ i, id)}
to E
such that g (single i x) = f x
.
Yury G. Kudryashov (Sep 17 2021 at 17:15):
You can ignore the category theory language.
Yaël Dillies (Sep 17 2021 at 17:15):
Ah! Did you mean to add an = 1
?
Yaël Dillies (Sep 17 2021 at 17:15):
I was stuck typechecking.
Yaël Dillies (Sep 17 2021 at 17:16):
Yury G. Kudryashov said:
I mean that for any convex space and a map
f : ι → E
you have a unique map fromg : {x : ι →₀ R | (∀ i, 0 ≤ x i) ∧ x.sum (λ i, id)}
toE
such thatg (single i x) = f x
.
Is this not exactly docs#std_simplex?
Yaël Dillies (Sep 17 2021 at 17:17):
Aaah, →₀
is finsupp
.
Yaël Dillies (Sep 17 2021 at 17:17):
Time for me to learn what that does.
Yury G. Kudryashov (Sep 17 2021 at 17:19):
This is one of the ways to speak about sums indexed by an infinite type.
Yaël Dillies (Sep 17 2021 at 17:20):
Ah so that's actually a generalization of std_simplex
!
Yury G. Kudryashov (Sep 17 2021 at 17:20):
Basically, we have
- docs#finsupp;
- docs#dfinsupp - a dependent and more computable version;
- docs#finsum;
- docs#finset.sum.
Yury G. Kudryashov (Sep 17 2021 at 17:20):
Yes.
Yury G. Kudryashov (Sep 17 2021 at 17:21):
You allow ι
to be infinite but require f
to be zero outside of a finite set.
Yaël Dillies (Sep 17 2021 at 17:22):
Unrelatingly, what do you think about defining strict_convex_on
/strict_concave_on
?
Yury G. Kudryashov (Sep 17 2021 at 17:22):
I have no time to do this. Feel free to define them.
Yury G. Kudryashov (Sep 17 2021 at 17:22):
Then you'll get a better version of mean inequalities for free.
Yaël Dillies (Sep 17 2021 at 17:22):
Will do!
Yaël Dillies (Sep 18 2021 at 14:54):
#9264 is ready. It takes care of is_extreme
and is_exposed
.
Yaël Dillies (Sep 22 2021 at 15:33):
@Scott Morrison, you should have warned me about #9298 :confused:
Yaël Dillies (Sep 22 2021 at 19:39):
Next up is #9268! It takes care of std_simplex
(yes, just as #9298) and finset.center_mass
, which I'm renaming to finset.linear_combination
. Ultimately, docs#finset.linear_combination and docs#finset.affine_combination will take in docs#finsupp and drop their finset.
namespace.
Yury G. Kudryashov (Sep 22 2021 at 20:29):
We already have linear combinations with finsupp
. They're used all over the place in linear_independent
Yaël Dillies (Sep 22 2021 at 20:52):
Wait, are they defined, or are they used ad hoc? I couldn't find the relevant declaration.
Yaël Dillies (Sep 22 2021 at 20:54):
What do you think I should do, then?
Scott Morrison (Sep 22 2021 at 21:19):
Yaël Dillies said:
Scott Morrison, you should have warned me about #9298 :confused:
Sorry about that. I was worried there were other PRs going on but I hadn't been following closely. :-(
Scott Morrison (Sep 22 2021 at 21:20):
If it's made a mess of a bigger PR we can back it out.
Yury G. Kudryashov (Sep 22 2021 at 21:46):
docs#linear_independent uses docs#finsupp.total
Yury G. Kudryashov (Sep 22 2021 at 21:48):
We can bundle it even more into (α → M) →ₗ[R] ((α →₀ R) →ₗ[R] M)
Yury G. Kudryashov (Sep 22 2021 at 21:51):
For convexity, you actually need the restriction of this map to the standard simplex (which should be defined as {x : α →₀ R | (∀ a, 0 ≤ x a) ∧ x.sum (λ a, id) = 1}
.
Joseph Myers (Sep 22 2021 at 21:58):
I expect you may need to add quite a few definitions / lemmas about finsupp
to make manipulations of finsupp
as convenient as those of unbundled functions and finset.sum
(i.e., so that none of the existing proofs involving affine combinations become any more complicated as a result of using finsupp
). I certainly expect a definition of affine_combination
using finsupp
will turn out to be cleaner in the end, but finsupp
seemed harder to use than unbundled functions and finset.sum
when I was originally defining affine_combination
.
There might be a question of whether affine_combination
should use the affine subspace of finsupp
where the sum of the weights is 1 (as opposed to using an arbitrary finsupp
and a separate hypothesis about the sum of the weights on those lemmas that need it), but that could complicate things and I don't know if it would bring much practical benefit.
Yaël Dillies (Sep 23 2021 at 07:00):
Scott Morrison said:
If it's made a mess of a bigger PR we can back it out.
No, that's fine. I will just look petty by changing the name of the variable everywhere :rofl:
Yaël Dillies (Sep 23 2021 at 07:25):
Yury G. Kudryashov said:
Okay, so what is supposed to be the point of linear_combination
? If it's really just finsupp.total
without finsupp
, maybe we can drop it altogether?
Eric Wieser (Sep 23 2021 at 07:36):
Part of the problem I suspect is that finsupp.total
is hard to find vs docs#finset.linear_combination which has a clearer name.
Eric Wieser (Sep 23 2021 at 07:37):
I'm confused, what linear_combination
are you even talking about?
Yaël Dillies (Sep 23 2021 at 08:18):
I renamed docs#finset.center_mass. See #9268
Yaël Dillies (Sep 23 2021 at 08:19):
Thanks for inadvertently affirming this choice :grinning_face_with_smiling_eyes:
Yaël Dillies (Sep 24 2021 at 07:04):
Okay so #9356 (convex_on
, concave_on
is also ready for review. It's independent of #9268 (std_simplex
, finset.center_mass
/finset.linear_combination
) except for Jensen's inequality. If we could just decide what to do with finset.center_mass
, this one could go through rather easily.
Oliver Nash (Sep 24 2021 at 07:41):
I'll take a look at these this afternoon.
Yaël Dillies (Sep 24 2021 at 08:33):
Thanks!
Oliver Nash (Sep 24 2021 at 15:32):
@Yaël Dillies I just spent some time looking over #9268 and left this comment.
Oliver Nash (Sep 24 2021 at 15:34):
I have not looked at #9356 beyond noting that it has a huge diff and technically does depend on #9268. I note that you say that "it's not much work to make it independent". I suggest doing this work as it will make me review it!
Yaël Dillies (Sep 24 2021 at 20:33):
@Oliver Nash, you have it!
Yaël Dillies (Sep 24 2021 at 20:34):
It won't compile for the Jensen inequality part. I'll fix that tomorrow morning. The rest won't be affected and can be reviewed already.
Johan Commelin (Sep 27 2021 at 12:23):
https://github.com/leanprover-community/mathlib/pull/9268#discussion_r715692515 is still an open remark. Are there further comments for #9268 ? Otherwise I think that one should be mergeable soonish.
Oliver Nash (Sep 27 2021 at 12:29):
For me a resolution of https://github.com/leanprover-community/mathlib/pull/9268#pullrequestreview-763215418 would help decide.
Oliver Nash (Sep 27 2021 at 12:29):
But I agree, this PR is certainly close.
Yaël Dillies (Sep 27 2021 at 12:31):
To be honest, I think there are two options now:
- Merge as is and I'll change to using
finsupp.total
in another PR - Change everything to use
finsupp.total
Oliver Nash (Sep 27 2021 at 12:32):
What's wrong with writing s.sum (w • p)
instead of finset.linear_combination p w
everywhere?
Yaël Dillies (Sep 27 2021 at 12:32):
Missing glue :grimacing:
Yaël Dillies (Sep 27 2021 at 12:32):
I also think that #9356 should be merged before now that it's been made independent from #9268.
Oliver Nash (Sep 27 2021 at 12:34):
Yaël Dillies said:
Missing glue :grimacing:
Maybe I'm begin dense but your proposed definition is:
def linear_combination {𝕜 E ι : Type*} [ordered_semiring 𝕜] [add_comm_monoid E] [module 𝕜 E]
(s : finset ι) (p : ι → E) (w : ι → 𝕜) : E :=
∑ i in s, w i • p i
Isn't that defeq to s.sum (w • p)
?
Oliver Nash (Sep 27 2021 at 12:34):
Basically we avoided making this definition in the linear algebra part of the library so introducing it here (with restrictive typeclasses) seems wrong to me.
Yaël Dillies (Sep 27 2021 at 12:35):
Ah wait, you're still having s : finset ι
. I thought you meant to switch to finsupp
.
Yaël Dillies (Sep 27 2021 at 12:35):
But what's docs#finsupp.total then?
Oliver Nash (Sep 27 2021 at 12:36):
The finitely-supported version.
Yaël Dillies (Sep 27 2021 at 12:37):
Okay so I have branch#std_simplex_finsupp (currently a mess, feel free to help!) to change docs#std_simplex to a set of finsupp
s, hence relaxing the fintype assumption.
Oliver Nash (Sep 27 2021 at 12:37):
I should say that even as it stands I think this PR is a net positive so if others want to merge it as it stands, I will support that.
Yaël Dillies (Sep 27 2021 at 12:38):
And I think that affine_combination
and liner_combination
shoudl be changed to using finsupp
too.
Oliver Nash (Sep 27 2021 at 12:39):
Scope creep can destroy the best intentions. My 2c is to focus on one thing at a time.
Yaël Dillies (Sep 27 2021 at 12:40):
Yes sure. So I think the answer here is to merge #9268
Oliver Nash (Sep 27 2021 at 12:41):
I'm keen to see this merged but question about finset.linear_combination
is still unresolved, right?
Oliver Nash (Sep 27 2021 at 12:41):
I think you'll need to convince someone else to merge it or convince me that it is non-trivial to start writing s.sum (w • p)
instead of s.linear_combination p w
.
Yaël Dillies (Sep 27 2021 at 12:43):
I'm fine with dropping finset.linear_combination
altogether and use s.sum (w • p)
. Then we can use finsupp.total
when we want to switch to finsupp
.
Oliver Nash (Sep 27 2021 at 12:43):
Right, I see the role of finsupp
as completely orthogonal to the concerns of this PR.
Yaël Dillies (Sep 27 2021 at 12:44):
The space of refactors is of high dimension :upside_down:
Oliver Nash (Sep 27 2021 at 17:16):
@Yaël Dillies I've just been looking over #9356 and I think it can be merged but I think the title is out of date because you already split out the generalisation of convexity (concavity) of functions.
Oliver Nash (Sep 27 2021 at 17:16):
Do you feel something along the lines of "reorganise lemmas about convexity (concavity) of functions and generalise Jensen" is about right?
Yaël Dillies (Sep 27 2021 at 17:18):
What about adding plainly "in lemmas"?
Oliver Nash (Sep 27 2021 at 17:18):
Go for it!
Oliver Nash (Sep 27 2021 at 17:20):
I pulled the trigger.
Yaël Dillies (Sep 27 2021 at 17:21):
Scary!
Yaël Dillies (Sep 27 2021 at 20:37):
Now that #9356 is merged, I'll clean up #9268 tomorrow and hopefully it is mergeable soon.
Yaël Dillies (Sep 27 2021 at 20:38):
In parallel (strictly speaking, this isn't part of the refactor), I'll define strict_convex_on
and strict_concave_on
.
Yaël Dillies (Sep 28 2021 at 14:19):
Good thing that we split off analysis.convex.function
. Strict convex/concave functions are about to inflate the number of line to 1.1k!
Yaël Dillies (Sep 28 2021 at 16:58):
I've just opened
- #9438 (+194, −137): general cleanup of
analysis.convex.function
- #9439 (+18, −6): define strictly convex/concave functions
- #9437 (+531, −123) : provide all the API for strictly convex/concave functions
The first two are independent and can be merged simultaneously.
Oliver Nash (Sep 28 2021 at 17:57):
I just noticed that #9356 relaxed some add_comm_group
typeclass assumptions to add_comm_monoid
. I think we should possibly undo this because these monoids have a scalar action of a ring
(in fact a linear_ordered_field
) so they're actually groups and so this is not a more general situation and is just a bit more awkward.
Oliver Nash (Sep 28 2021 at 17:58):
For example:
import algebra.order.field
import algebra.module.basic
variables {R E : Type*} [linear_ordered_field R] [add_comm_monoid E] [module R E]
example : add_comm_group E := module.add_comm_monoid_to_add_comm_group R
Oliver Nash (Sep 28 2021 at 18:00):
For an example of why this is more awkward note that I had to fix this bors failure with this commit.
Oliver Nash (Sep 28 2021 at 18:01):
However I claim the right fix is to revert add_comm_monoid E
back to add_comm_group E
here
Oliver Nash (Sep 28 2021 at 18:02):
Do I have support to carry out this reversion?
Yaël Dillies (Sep 28 2021 at 18:04):
Oh okay, as soon as you have ring R
... That's interesting.
Yaël Dillies (Sep 28 2021 at 18:04):
Go for it. It might also simplify the structure of the files.
Oliver Nash (Sep 28 2021 at 18:04):
Exactly, x - y = x + (-1)•y
.
Oliver Nash (Sep 28 2021 at 18:05):
OK I'll push that fix for this file as part of #9103
Oliver Nash (Sep 28 2021 at 18:05):
Would you be available to hunt down any other examples of this introduced in #9356?
Oliver Nash (Sep 28 2021 at 18:08):
Actually I think that was the only instance of this (introduced in #9356) so once #9103 lands all should be well again :tada:
This looks suspicious: https://github.com/leanprover-community/mathlib/pull/9356/files#diff-2c41777d2dc24191912a0713d599feb75a13f1f12ad4978dbba711b15e5d228bR461
Oliver Nash (Sep 28 2021 at 18:09):
Oliver Nash (Sep 28 2021 at 18:10):
Last one I think: https://github.com/leanprover-community/mathlib/pull/9356/files#diff-2c41777d2dc24191912a0713d599feb75a13f1f12ad4978dbba711b15e5d228bR644
Oliver Nash (Sep 28 2021 at 18:11):
I should have flagged these in review. Sorry about that.
Yaël Dillies (Sep 28 2021 at 19:29):
Sorry these links are broken. What did you mean to show me?
Oliver Nash (Sep 28 2021 at 19:32):
I think they work if you click “Load diff” on the file analysis/convex/function.lean
. If you like you can ignore this and I’ll create a PR tomorrow morning!
Yaël Dillies (Sep 28 2021 at 19:33):
Okay, I'll wait for the PR!
Yaël Dillies (Sep 28 2021 at 19:35):
Just so you know, this should be an easy fix as I've structured the files according to the instance on 𝕜
. So the fix should be as simple as looking for section ordered_ring
, section linear_ordered_field
, ... and modifying the variables
that comes just after.
Oliver Nash (Sep 28 2021 at 19:38):
Great, that should make it very easy.
Yaël Dillies (Sep 28 2021 at 19:39):
Or just look for add_comm_monoid E
, add_comm_monoid F
. Also very easy.
Scott Morrison (Sep 29 2021 at 00:18):
Would it make sense to put all the material about strictly convex functions in a new file?
Oliver Nash (Sep 29 2021 at 07:44):
Yaël Dillies said:
Okay, I'll wait for the PR!
I just created #9442 for this. In the end I left the monoid
s appearing here https://github.com/leanprover-community/mathlib/blob/d7abdff7d5abd82d0fbdf795e2a0766150e06c42/src/analysis/convex/function.lean#L461-L467 unchanged because there is no compatibility between the action of the scalars and the structure on the types E
, β
(which incidentally suggests to me that there's room for improvement here).
Yaël Dillies (Sep 29 2021 at 07:58):
Great!
Yaël Dillies (Sep 29 2021 at 07:59):
The room for improvement you're talking about is replacing add_comm_monoid E
by has_zero E
,has_add E
(and same in the definition of convex
), I think.
Yaël Dillies (Sep 29 2021 at 08:08):
Scott Morrison said:
Would it make sense to put all the material about strictly convex functions in a new file?
I don't think so. The stuff is really similar and all the variants of the same lemma deserve to be a few lines apart. Instead, we could split along other criteria, like Jensen's stuff + maximum principle can earn its own file (albeit it's not many lines).
Yaël Dillies (Sep 29 2021 at 08:18):
Without Jensen and maximum principle, we're at 993 lines. If we further remove the slope stuff (which is used for convexity from positive second derivative), we get down to 792.
Yaël Dillies (Sep 29 2021 at 08:23):
For comparison, analysis.convex.basic
was 1723 lines long before I started the refactor :scream:
Yaël Dillies (Sep 29 2021 at 13:40):
Just opened #9444 (+114, −104) and #9445 (+128, −102)! They do exactly the two splits I just proposed.
Johan Commelin (Sep 29 2021 at 14:27):
Thanks! #9445 currently has merge conflicts.
Yaël Dillies (Sep 29 2021 at 14:30):
Solved :tools:
Yaël Dillies (Sep 30 2021 at 15:06):
Does it make sense to move convex_hull
to something like analysis.convex.hull
?
Yaël Dillies (Sep 30 2021 at 15:08):
or do we declare that analysis.convex.basic
is short enough?
Johan Commelin (Sep 30 2021 at 15:50):
1066 is of course a very important number, but I don't think it hurts to make that file a bit shorter still. So yes, please split it further.
Yaël Dillies (Sep 30 2021 at 18:57):
I'm doing convex cones now.
Oliver Nash (Oct 02 2021 at 10:55):
@Yaël Dillies I was just having a quick look at #9268 again but I see you've marked it WIP (I guess till you fix the build). So I'm going to wait for now unless you'd like more input right now. OK?
Yaël Dillies (Oct 02 2021 at 10:56):
Yeah, I'm still pondering. Sorry I should have marked it WIP a bit earlier.
Oliver Nash (Oct 02 2021 at 10:57):
No problem at all! I'll be ready when you are.
Oliver Nash (Oct 02 2021 at 10:57):
Incidentally I've just created #9499 which will conflict but not much.
Yaël Dillies (Oct 02 2021 at 10:58):
Oh yeah, maybe merge that before I do anything.
Oliver Nash (Oct 02 2021 at 10:58):
I'm happy either way, the conflicts will be simple to fix.
Oliver Nash (Oct 02 2021 at 11:00):
Proving convex_hull_range_eq_exists_affine_combination
in #9499 almost convinced me to attempt my own version of #9268 where we nuke center_mass
and replace it affine_combination
but in the end I decided that can wait.
Yaël Dillies (Oct 02 2021 at 11:00):
So long as you are there, could you prove the following lemma?
lemma (𝕜 : Type u_1) {E : Type u_2} {ι : Type u_3} [ordered_semiring 𝕜] [add_comm_group E] [module 𝕜 E] (p : ι → E) :
affine_independent 𝕜 p = ∀ (s : set ι) (x : ι), p x ∈ affine_span 𝕜 (p '' s) → x ∈ s := sorry
Oliver Nash (Oct 02 2021 at 11:00):
:laughing: Let me see. I'm about to head out for a run but I'll give it a go!
Yaël Dillies (Oct 02 2021 at 11:01):
This is the definition of docs#convex_independent, but made affine.
Yaël Dillies (Oct 02 2021 at 11:01):
Once we have it, I can make affine.independent.convex_independent
a one-liner!
Yaël Dillies (Oct 02 2021 at 11:02):
(feel free to change to change the typeclasses, they are probably not the full generality)
Oliver Nash (Oct 02 2021 at 11:04):
OK I've fired up VSCode and I'll see what I think. Here it is again in MWE form:
import linear_algebra.affine_space.independent
lemma foo (𝕜 E ι : Type*) [ordered_ring 𝕜] [add_comm_group E] [module 𝕜 E] (p : ι → E) :
affine_independent 𝕜 p ↔ ∀ (s : set ι) (x : ι), p x ∈ affine_span 𝕜 (p '' s) → x ∈ s :=
begin
sorry,
end
Oliver Nash (Oct 02 2021 at 11:15):
Sorry, outatime for now!
Yaël Dillies (Oct 08 2021 at 09:51):
Here, @Oliver Nash, @Yakov Pechersky
Yaël Dillies (Oct 08 2021 at 09:51):
What would be your definition of convex space?
Oliver Nash (Oct 08 2021 at 09:52):
Well, if we decided we could restrict to the case of needing negation I think the following:
Oliver Nash (Oct 08 2021 at 09:52):
import linear_algebra.affine_space.combination
open_locale affine
variables (k : Type*) {V P : Type*}
variables [ordered_ring k] [add_comm_group V] [module k V] [affine_space V P]
include V
def convex (s : set P) :=
∀ ⦃x y : P⦄, x ∈ s → y ∈ s → ∀ ⦃a : k⦄, 0 ≤ a → a ≤ 1 → affine_map.line_map x y a ∈ s
Yaël Dillies (Oct 08 2021 at 09:53):
No, I meant a convex space :smile:
Yaël Dillies (Oct 08 2021 at 09:54):
Am I right in thinking there isn't one kind of convex space but a hierarchy of them? Supposedly every kind of scalar action between has_scalar
and module
gives rise to a different kind of convex space.
Oliver Nash (Oct 08 2021 at 09:56):
What's a convex space?
Yaël Dillies (Oct 08 2021 at 09:59):
A space where you can define convexity.
Yaël Dillies (Oct 08 2021 at 10:01):
I don't have many references. That's the problem. Here's something on ncatlab: https://ncatlab.org/nlab/show/convex+space
Oliver Nash (Oct 08 2021 at 10:03):
Oh I see.
Oliver Nash (Oct 08 2021 at 10:05):
So basically it's a space which has line_map
.
Oliver Nash (Oct 08 2021 at 10:05):
Then my definition would be the same!
Yaël Dillies (Oct 08 2021 at 10:05):
More like a segment_map
because you don't care about what's not between the points.
Oliver Nash (Oct 08 2021 at 10:06):
Right.
Yaël Dillies (Oct 08 2021 at 10:09):
Do you think we should put convex combinations as a field of convex_space
or construct it from segment_map
?
Oliver Nash (Oct 08 2021 at 10:14):
I don't know. My null hypothesis would be to construct it from segment_map
but I would not have a strong view here.
Yury G. Kudryashov (Oct 08 2021 at 15:00):
I think that the main difficulty with convex_space
is not to define it and provide instances for an affine_space
and a module
. The main difficulty is that we unavoidably get a TC diamond for a convex_space real E
: the instance going through affine_space
can't be defeq to the instance going through module
.
Yury G. Kudryashov (Oct 08 2021 at 15:00):
So, only one of these instances can be a global instance.
Yury G. Kudryashov (Oct 08 2021 at 15:02):
And more diamonds: probably you want to define a convex_space
structure on the product of two spaces etc. If you get the product of two modules (or affine spaces), then probably the segment_map
coming from prod
won't be defeq to the segment_map
coming from module
/affine_space
.
Yaël Dillies (Oct 08 2021 at 15:30):
Oh, I hadn't thought about prod
. The module instance for prod
is well-behaved, right? I know you probably want affine_space
-> convex_space
to be the global instance instead of module
-> convex_space
, but I have the instinct that the module
-> convex_space
instance is cleaner.
Yury G. Kudryashov (Oct 08 2021 at 15:34):
The best way to verify this is to make a one-field typeclass (just segment_map
, no axioms), add instances, and try prove equality by rfl
.
Yaël Dillies (Oct 08 2021 at 15:38):
Will do!
Last updated: Dec 20 2023 at 11:08 UTC