Skip to content

Commit

Permalink
Trac #31736: ManifoldSubset: New methods declare_equal, equal_subsets…
Browse files Browse the repository at this point in the history
…, equal_subset_family

Two subsets are equal if they are subsets of each other.

We add methods `equal_subsets`, `equal_subset_family`; and a method
`declare_equal` to make two or more subsets equal.

We modify the method `subset_poset` and `superset_poset` to quotient out
by equality.

URL: https://trac.sagemath.org/31736
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Eric Gourgoulhon
  • Loading branch information
Release Manager committed Jun 20, 2021
2 parents 3a36b12 + fd4506a commit 88b652e
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
AUTHORS:
- Florentin Jaffredo (2018): initial version
- Eric Gourgoulhon (2018-2019): add documentation
- Matthias Koeppe (2021): open subsets of submanifolds
REFERENCES:
Expand All @@ -26,7 +28,9 @@
"""

# *****************************************************************************
# Copyright (C) 2018 Florentin Jaffredo <florentin.jaffredo@polytechnique.edu>
# Copyright (C) 2018 Florentin Jaffredo <florentin.jaffredo@polytechnique.edu>
# Copyright (C) 2018-2019 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr>
# Copyright (C) 2021 Matthias Koeppe <mkoeppe@math.ucdavis.edu>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
11 changes: 8 additions & 3 deletions src/sage/manifolds/differentiable/manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@
- Eric Gourgoulhon (2015): initial version
- Travis Scrimshaw (2016): review tweaks
- Michael Jung (2020): tensor bundles and orientability
- Matthias Koeppe (2021): refactoring of subsets code
REFERENCES:
Expand All @@ -424,9 +425,13 @@
"""

# ****************************************************************************
# Copyright (C) 2015 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr>
# Copyright (C) 2015 Michal Bejger <bejger@camk.edu.pl>
# Copyright (C) 2016 Travis Scrimshaw <tscrimsh@umn.edu>
# Copyright (C) 2015-2019 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr>
# Copyright (C) 2015 Michal Bejger <bejger@camk.edu.pl>
# Copyright (C) 2015-2016 Travis Scrimshaw <tscrimsh@umn.edu>
# Copyright (C) 2017 Karim Van Aelst
# Copyright (C) 2019 Hans Fotsing Tetsing
# Copyright (C) 2019-2020 Michael Jung
# Copyright (C) 2021 Matthias Koeppe
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@
AUTHORS:
- Florentin Jaffredo (2018): initial version
- Eric Gourgoulhon (2018-2019): add documentation
- Matthias Koeppe (2021): open subsets of submanifolds
REFERENCES:
Expand All @@ -177,7 +179,9 @@
"""

# *****************************************************************************
# Copyright (C) 2018 Florentin Jaffredo <florentin.jaffredo@polytechnique.edu>
# Copyright (C) 2018 Florentin Jaffredo <florentin.jaffredo@polytechnique.edu>
# Copyright (C) 2018-2019 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr>
# Copyright (C) 2021 Matthias Koeppe <mkoeppe@math.ucdavis.edu>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
29 changes: 29 additions & 0 deletions src/sage/manifolds/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
The subclass :class:`ManifoldSubsetFiniteFamily` customizes the print
representation further.
AUTHORS:
- Matthias Koeppe (2021): initial version
"""
#*****************************************************************************
# Copyright (C) 2021 Matthias Koeppe <mkoeppe@math.ucdavis.edu>
Expand Down Expand Up @@ -216,6 +220,31 @@ class ManifoldSubsetFiniteFamily(ManifoldObjectFiniteFamily):
"""

@classmethod
def from_subsets_or_families(cls, *subsets_or_families):
r"""
Construct a ManifoldSubsetFiniteFamily from given subsets or iterables of subsets.
EXAMPLES::
sage: from sage.manifolds.family import ManifoldSubsetFiniteFamily
sage: M = Manifold(2, 'M', structure='topological')
sage: A = M.subset('A')
sage: Bs = (M.subset(f'B{i}') for i in range(5))
sage: Cs = ManifoldSubsetFiniteFamily([M.subset('C0'), M.subset('C1')])
sage: ManifoldSubsetFiniteFamily.from_subsets_or_families(A, Bs, Cs)
Set {A, B0, B1, B2, B3, B4, C0, C1} of subsets of the 2-dimensional topological manifold M
"""
def generate_subsets():
from sage.manifolds.subset import ManifoldSubset
for arg in subsets_or_families:
if isinstance(arg, ManifoldSubset):
yield arg
else:
# arg must be an iterable of ManifoldSubset instances
yield from arg
return cls(generate_subsets())

def _repr_object_type(self):
r"""
String that describes the type of the elements (plural).
Expand Down
18 changes: 13 additions & 5 deletions src/sage/manifolds/manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,13 @@
"""

#*****************************************************************************
# Copyright (C) 2015 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr>
# Copyright (C) 2015 Travis Scrimshaw <tscrimsh@umn.edu>
# Copyright (C) 2015-2020 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr>
# Copyright (C) 2015 Travis Scrimshaw <tscrimsh@umn.edu>
# Copyright (C) 2016 Andrew Mathas
# Copyright (C) 2018 Florentin Jaffredo
# Copyright (C) 2019 Hans Fotsing Tetsing
# Copyright (C) 2019-2020 Michael Jung
# Copyright (C) 2021 Matthias Koeppe <mkoeppe@math.ucdavis.edu>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -899,9 +904,12 @@ def _init_open_subset(self, resu, coord_def):
Open subset U of the 2-dimensional topological manifold R^2
"""
resu._calculus_method = self._calculus_method
resu._supersets.update(self._supersets)
for sd in self._supersets:
sd._subsets.add(resu)
if self.is_empty():
self.declare_equal(resu)
else:
resu._supersets.update(self._supersets)
for sd in self._supersets:
sd._subsets.add(resu)
self._top_subsets.add(resu)
# Charts on the result from the coordinate definition:
for chart, restrictions in coord_def.items():
Expand Down
Loading

0 comments on commit 88b652e

Please sign in to comment.