sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.46k stars 485 forks source link

Pullbacks (preimages) of manifold subsets under continuous maps #31688

Closed mkoeppe closed 3 years ago

mkoeppe commented 3 years ago

Similar to #31653, given a continuous map \Phi: N -> M and a manifold subset S of M, we define the pullback (preimage) of S as the subset of N of points p with \Phi(p) in S.

Given a real scalar field Phi: N -> R and a RealSet S, we define the pullback in the same way.

Also, we view a chart C as a continuous function Phi: C.domain() -> R^n and allow pulling back any subset of R^n (an object with a __contains__ method; for example polyhedra, lattices, linear subspaces, tensor modules) by it as well.

In all cases, because Phi is continuous, topological closures/interiors pull back.

An application is in #31981.

Depends on #31883 Depends on #31904 Depends on #31653 Depends on #31916 Depends on #31644 Depends on #31959 Depends on #31990 Depends on #21243

CC: @egourgoulhon @tscrim @mjungmath

Component: manifolds

Author: Matthias Koeppe

Branch/Commit: 4558e26

Reviewer: Eric Gourgoulhon

Issue created by migration from https://trac.sagemath.org/ticket/31688

mkoeppe commented 3 years ago

Changed dependencies from #31883, #31904, #31653, #31916 to #31883, #31904, #31653, #31916, #31959

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

6bef52bConvexSet_base._test_convex_set: Run the testsuite of relint
6ab5677RelativeInterior.is_universe: New
c085d30Polyhedron_base.interior: Handle the empty polyhedron correctly
686d0afPolyhedron_base.product: Add doctest for alias 'cartesian_product'
2b1d108Merge #31919
7323b10ConvexSet_base._test_contains: Only test extension to AA for exact base rings
e0d2eebMerge #31959
e6c3ed5RelativeInterior.__hash__: New
4c7d57fsrc/sage/geometry/relative_interior.py: Fix doctest output
9ea0ceaManifoldSubsetPullback: Do not trip over relative interiors of cones
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from e802a21 to 9ea0cea

egourgoulhon commented 3 years ago
comment:34

As revealed by the patchbot, there are some doctest failures, as well as some coverage and pyflakes issues.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 9ea0cea to d591234

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

94e6858RelativeInterior.ambient, ambient_vector_space, is_universe: New
0c9bc94ConvexSet_base: Add default implementations of ambient, ambient_dim; add doctests
d591234Merge #31959
mkoeppe commented 3 years ago
comment:36

Thanks for taking a look! Yes, I'll have to add more documentation and examples.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

87f3e30ManifoldSubsetPullback: Add documentation and tests
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from d591234 to 87f3e30

mkoeppe commented 3 years ago

Changed dependencies from #31883, #31904, #31653, #31916, #31959 to #31883, #31904, #31653, #31916, #31959, #31990

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

7d3ae5cMerge #31959
2b1040cConvexSet_base.{an_element,some_elements}, Polyhedron.some_elements, RelativeInterior.some_elements: New
a884517PolyhedronFace.some_elements: New
f6cc8f7Merge #31990
1a4805cManifoldSubsetPullback: For charts, use .point as the inverse
754e002ManifoldSubsetPullback._an_element_, some_elements: Implement
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 87f3e30 to 754e002

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 754e002 to a8e607c

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

a8e607cManifoldSubsetPullback._coord_def: Add documentation and examples
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

ce91e44src/sage/geometry/relative_interior.py: Fix doctest output
b19b3ccMerge #31959
c49ab33Merge #31990
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from a8e607c to c49ab33

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from c49ab33 to 7ae21da

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

f0e7c58ambient_vector_space docstring: Fix bad blocks
200d967ConvexSet_base.ambient doctest: Actually test the method
1c2bef5Merge #31959
ed898e6ConvexSet_base.an_element, some_elements: Go through generator method `_some_elements_`, make some_elements return a list
7ae21daMerge #31990
egourgoulhon commented 3 years ago

Reviewer: Eric Gourgoulhon

egourgoulhon commented 3 years ago
comment:44

Thanks for the last changes. Some comments regarding the documentation:

mkoeppe commented 3 years ago

Changed dependencies from #31883, #31904, #31653, #31916, #31959, #31990 to #31883, #31904, #31653, #31916, #31644, #31959, #31990

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 7ae21da to 3877c5f

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

8d3ad85Merge #31764
60505b0Merge #31798
b9909c0ManifoldSubsetClosure: Add examples, fix docstring markup
16c6a72ManifoldSubsetClosure, ManifoldSubset.closure: Improve documentation
2514586Merge #31644
3ca139asrc/doc/en/reference/manifolds: Add pullback
1d430eesrc/sage/manifolds/continuous_map.py, src/sage/manifolds/subsets: Use qualified class name in docstrings
1266de9src/sage/geometry/convex_set.py: Fix docstring markup
df64125ScalarField.preimage: Make pullback an alias; expand documentation
3877c5fManifoldSubsetPullback.is_closed: Remove unfinished NNC_Polyhedron example
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

0c549f0Chart.pullback, preimage: New
7bb720eManifoldSubsetPullback.__contains__: Handle the case of charts, which return tuples of coordinates, not vectors
60ea044ContinuousMap.preimage, ScalarField.preimage: Document that output can also be a manifold
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 3877c5f to 60ea044

mkoeppe commented 3 years ago

Changed dependencies from #31883, #31904, #31653, #31916, #31644, #31959, #31990 to #31883, #31904, #31653, #31916, #31644, #31959, #31990, #21243

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

5b8cecaInternalRealInterval, RealSet: Add `_latex_` methods
69ca854RealSet._repr_: Use unicode cup sign instead of +
dbdfc06InternalRealInterval, RealSet: Remove extra whitespace in latex, add documentation
a0e3bf5Merge #31880
181b128RealSet.is_open, is_closed, closure, interior, boundary: New
7f56338PiecewiseFunction: Adjust doctests for changed RealSet repr
8cd74b5Merge #31880
8fdb104RealSet.boundary: Add another doctest
9d41f0esrc/sage/sets/real_set.py: Remove unnecessary import
c36e43bMerge #21243
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 60ea044 to c36e43b

egourgoulhon commented 3 years ago
comment:50

In the docstring of ManifoldSubsetPullback:

sage: r_squared = M.scalar_field(x^2+y^2)
sage: r_squared.set_immutable()
sage: cl_I = RealSet((1, 4)); cl_I
(1, 4)
sage: cl_O = ManifoldSubsetPullback(r_squared, None, I); cl_O

I guess I in the last line (which, at this stage, is the imaginary number i) should be replaced by cl_I and the subsequent True and False should become False and True respectively. But then, cl_I and cl_O are identical to I and O in the example that follows...

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from c36e43b to c540d35

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

c540d35ManifoldSubsetPullback: Fix up some doctests with closed intervals
mkoeppe commented 3 years ago
comment:52

Thanks for spotting this - I have fixed this and a similar example

mkoeppe commented 3 years ago
comment:53

Replying to @egourgoulhon:

In the docstring of ManifoldSubsetPullback:

  • in the INPUT section, there seems to be no entry for ConvexSet_base in the documentation

You may need to run ./sage -docbuild reference/discrete_geometry html

egourgoulhon commented 3 years ago
comment:54

Replying to @mkoeppe:

Replying to @egourgoulhon:

In the docstring of ManifoldSubsetPullback:

  • in the INPUT section, there seems to be no entry for ConvexSet_base in the documentation

You may need to run ./sage -docbuild reference/discrete_geometry html

Yes indeed!

egourgoulhon commented 3 years ago
comment:55

Replying to @mkoeppe:

Thanks for spotting this - I have fixed this and a similar example

Thanks.

At the moment, we have

sage: M = Manifold(2, 'M')                                                                          
sage: X.<x,y> = M.chart()                                                                           
sage: M.identity_map().preimage(M)                                                                  
Subset Id_M_inv_M of the 2-dimensional differentiable manifold M
sage: M.identity_map().preimage(M) is M                                                             
False
sage: M.zero_scalar_field().preimage(RealSet.point(0))                                              
Subset zero_inv_{0} of the 2-dimensional differentiable manifold M
sage: M.zero_scalar_field().preimage(RealSet.point(0)) is M                                         
False

Do you think it would be easy to have both answers to be True? If no, this should not hamper the current ticket, but be differed to another ticket.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from c540d35 to facad97

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

facad97ContinuousMap.preimage: Handle identity_map specially
mkoeppe commented 3 years ago
comment:57

Sure, that's easy to do and certainly a good idea. Here it is for ContinuousMap.preimage already, I'll look into the case of the scalar fields

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

c2ecf3eScalarField.preimage: Handle the case of the zero scalar field
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from facad97 to c2ecf3e

mkoeppe commented 3 years ago
comment:59

More general things such as detecting that the preimage of [0,oo) under squaring is the full domain will have to wait until a follow-up ticket

egourgoulhon commented 3 years ago
comment:60

Replying to @mkoeppe:

Sure, that's easy to do and certainly a good idea. Here it is for ContinuousMap.preimage already,

Thanks. Maybe one can add

if self._is_isomorphism and codomain_subset == self._codomain:
    return self._domain
egourgoulhon commented 3 years ago
comment:61

The patchbot reports a doctest error in src/sage/geometry/polyhedron/base.py as well as pyflakes errors in src/sage/manifolds/subsets/pullback.py.

mkoeppe commented 3 years ago
comment:62

Replying to @egourgoulhon:

Maybe one can add

if self._is_isomorphism and codomain_subset == self._codomain:
    return self._domain

I think I can do more generally

  if self._codomain.is_subset(codomain_subset):
      return self._domain
mkoeppe commented 3 years ago
comment:63

Replying to @egourgoulhon:

The patchbot reports a doctest error in src/sage/geometry/polyhedron/base.py

I've seen this one before locally, I don't think it's coming from this ticket, but I have opened #32030 for it

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from c2ecf3e to 3b1c428

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

3b1c428ManifoldSubsetPullback: Make codomain_subset required 2nd init arg; fix pycodestyle/pyflakes warnings
egourgoulhon commented 3 years ago
comment:65

Replying to @mkoeppe:

Replying to @egourgoulhon:

Maybe one can add

if self._is_isomorphism and codomain_subset == self._codomain:
    return self._domain

I think I can do more generally

  if self._codomain.is_subset(codomain_subset):
      return self._domain

Yes, indeed! Being an isomorphism is not necessary in that case.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 3b1c428 to d321b93

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

d321b93ContinuousMap: Return domain if the map's codomain is contained in the given subset