Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge #32089
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Jul 8, 2021
2 parents d6055c4 + 69d045a commit ffe18b0
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 114 deletions.
2 changes: 1 addition & 1 deletion src/sage/calculus/functional.py
Expand Up @@ -143,7 +143,7 @@ def derivative(f, *args, **kwds):
sage: derivative(a)
2-form da on the 2-dimensional differentiable manifold M
sage: derivative(a).display()
da = 2 dx/\dy
da = 2 dxdy
"""
try:
Expand Down
Expand Up @@ -120,9 +120,9 @@ def lie_group(self, name='G', **kwds):
sage: X = G.left_invariant_extension(2*p + 3*q, name='X'); X
Vector field X on the Lie group G of Heisenberg algebra of rank 1 over Rational Field
sage: X.at(G.one()).display()
X = 2 d/dx_0 + 3 d/dx_1
X = 2 ∂/∂x_0 + 3 ∂/∂x_1
sage: X.display()
X = 2 d/dx_0 + 3 d/dx_1 + (3/2*x_0 - x_1) d/dx_2
X = 2 ∂/∂x_0 + 3 ∂/∂x_1 + (3/2*x_0 - x_1) ∂/∂x_2
.. SEEALSO::
Expand Down
16 changes: 8 additions & 8 deletions src/sage/geometry/polyhedron/base.py
Expand Up @@ -11186,11 +11186,11 @@ def affine_hull_manifold(self, name=None, latex_name=None, start_index=0, ambien
sage: A = triangle.affine_hull_manifold(name='A'); A
2-dimensional Riemannian submanifold A embedded in the Euclidean space E^3
sage: A.embedding().display()
A --> E^3
(x0, x1) |--> (x, y, z) = (t0 + x0, t0 + x1, t0 - x0 - x1 + 1)
A E^3
(x0, x1) (x, y, z) = (t0 + x0, t0 + x1, t0 - x0 - x1 + 1)
sage: A.embedding().inverse().display()
E^3 --> A
(x, y, z) |--> (x0, x1) = (x, y)
E^3 A
(x, y, z) (x0, x1) = (x, y)
sage: A.adapted_chart()
[Chart (E^3, (x0_E3, x1_E3, t0_E3))]
sage: A.normal().display()
Expand All @@ -11205,11 +11205,11 @@ def affine_hull_manifold(self, name=None, latex_name=None, start_index=0, ambien
sage: A = triangle.affine_hull_manifold(name='A', orthogonal=True); A
2-dimensional Riemannian submanifold A embedded in the Euclidean space E^3
sage: A.embedding().display()
A --> E^3
(x0, x1) |--> (x, y, z) = (t0 - 1/2*x0 - 1/3*x1 + 1, t0 + 1/2*x0 - 1/3*x1, t0 + 2/3*x1)
A E^3
(x0, x1) (x, y, z) = (t0 - 1/2*x0 - 1/3*x1 + 1, t0 + 1/2*x0 - 1/3*x1, t0 + 2/3*x1)
sage: A.embedding().inverse().display()
E^3 --> A
(x, y, z) |--> (x0, x1) = (-x + y + 1, -1/2*x - 1/2*y + z + 1/2)
E^3 A
(x, y, z) (x0, x1) = (-x + y + 1, -1/2*x - 1/2*y + z + 1/2)
Arrangement of affine hull of facets::
Expand Down
60 changes: 31 additions & 29 deletions src/sage/groups/lie_gps/nilpotent_lie_group.py
Expand Up @@ -152,13 +152,13 @@ class NilpotentLieGroup(Group, DifferentiableManifold):
sage: exp1_frame = G.chart_exp1().frame()
sage: exp2_frame = G.chart_exp2().frame()
sage: X[0].display(exp1_frame)
X_0 = d/dx_0 - 1/2*x_1 d/dx_2
X_0 = ∂/∂x_0 - 1/2*x_1 ∂/∂x_2
sage: X[0].display(exp2_frame)
X_0 = d/dy_0
X_0 = ∂/∂y_0
sage: X[1].display(exp1_frame)
X_1 = d/dx_1 + 1/2*x_0 d/dx_2
X_1 = ∂/∂x_1 + 1/2*x_0 ∂/∂x_2
sage: X[1].display(exp2_frame)
X_1 = d/dy_1 + x_0 d/dy_2
X_1 = ∂/∂y_1 + x_0 ∂/∂y_2
Defining a left translation by a generic point::
Expand All @@ -167,11 +167,13 @@ class NilpotentLieGroup(Group, DifferentiableManifold):
sage: L_g = G.left_translation(g); L_g
Diffeomorphism of the Lie group G of Heisenberg algebra of rank 1 over Rational Field
sage: L_g.display()
G --> G
(x_0, x_1, x_2) |--> (a + x_0, b + x_1, -1/2*b*x_0 + 1/2*a*x_1 + c + x_2)
(x_0, x_1, x_2) |--> (y_0, y_1, y_2) = (a + x_0, b + x_1, 1/2*a*b + 1/2*(2*a + x_0)*x_1 + c + x_2)
(y_0, y_1, y_2) |--> (x_0, x_1, x_2) = (a + y_0, b + y_1, -1/2*b*y_0 + 1/2*(a - y_0)*y_1 + c + y_2)
(y_0, y_1, y_2) |--> (a + y_0, b + y_1, 1/2*a*b + a*y_1 + c + y_2)
G → G
(x_0, x_1, x_2) ↦ (a + x_0, b + x_1, -1/2*b*x_0 + 1/2*a*x_1 + c + x_2)
(x_0, x_1, x_2) ↦ (y_0, y_1, y_2) = (a + x_0, b + x_1,
1/2*a*b + 1/2*(2*a + x_0)*x_1 + c + x_2)
(y_0, y_1, y_2) ↦ (x_0, x_1, x_2) = (a + y_0, b + y_1,
-1/2*b*y_0 + 1/2*(a - y_0)*y_1 + c + y_2)
(y_0, y_1, y_2) ↦ (a + y_0, b + y_1, 1/2*a*b + a*y_1 + c + y_2)
Verifying the left-invariance of the left-invariant frame::
Expand All @@ -189,10 +191,10 @@ class NilpotentLieGroup(Group, DifferentiableManifold):
sage: X_L = G.left_invariant_extension(p + 3*q); X_L
Vector field p1 + 3*q1 on the Lie group G of Heisenberg algebra of rank 1 over Rational Field
sage: X_L.display(exp1_frame)
p1 + 3*q1 = d/dx_0 + 3 d/dx_1 + (3/2*x_0 - 1/2*x_1) d/dx_2
p1 + 3*q1 = ∂/∂x_0 + 3 ∂/∂x_1 + (3/2*x_0 - 1/2*x_1) ∂/∂x_2
sage: X_R = G.right_invariant_extension(p + 3*q)
sage: X_R.display(exp1_frame)
p1 + 3*q1 = d/dx_0 + 3 d/dx_1 + (-3/2*x_0 + 1/2*x_1) d/dx_2
p1 + 3*q1 = ∂/∂x_0 + 3 ∂/∂x_1 + (-3/2*x_0 + 1/2*x_1) ∂/∂x_2
The nilpotency step of the Lie group is the nilpotency step of its algebra.
Nilpotency for Lie groups means that group commutators that are longer than
Expand Down Expand Up @@ -503,16 +505,16 @@ def left_translation(self, g):
sage: L_g = G.left_translation(g); L_g
Diffeomorphism of the Lie group G of Heisenberg algebra of rank 1 over Rational Field
sage: L_g.display(chart1=G.chart_exp1(), chart2=G.chart_exp1())
G --> G
(x_0, x_1, x_2) |--> (x_0 + 1, x_1, 1/2*x_1 + x_2)
G G
(x_0, x_1, x_2) (x_0 + 1, x_1, 1/2*x_1 + x_2)
Left translation by a generic element::
sage: h = G.point([var('a'), var('b'), var('c')])
sage: L_h = G.left_translation(h)
sage: L_h.display(chart1=G.chart_exp1(), chart2=G.chart_exp1())
G --> G
(x_0, x_1, x_2) |--> (a + x_0, b + x_1, -1/2*b*x_0 + 1/2*a*x_1 + c + x_2)
G G
(x_0, x_1, x_2) (a + x_0, b + x_1, -1/2*b*x_0 + 1/2*a*x_1 + c + x_2)
"""
chart = self.default_chart()
x = self.point(chart[:])
Expand All @@ -537,11 +539,11 @@ def left_invariant_frame(self, **kwds):
Vector frame (G, (X_1,X_2,X_12))
sage: coord_frame = G.chart_exp1().frame()
sage: livf[0].display(coord_frame)
X_1 = d/dx_1 - 1/2*x_2 d/dx_12
X_1 = ∂/∂x_1 - 1/2*x_2 ∂/∂x_12
sage: livf[1].display(coord_frame)
X_2 = d/dx_2 + 1/2*x_1 d/dx_12
X_2 = ∂/∂x_2 + 1/2*x_1 ∂/∂x_12
sage: livf[2].display(coord_frame)
X_12 = d/dx_12
X_12 = ∂/∂x_12
Examples of custom labeling for the frame::
Expand Down Expand Up @@ -583,7 +585,7 @@ def left_invariant_extension(self, X, name=None):
sage: X = H.left_invariant_extension(p); X
Vector field p1 on the Lie group H of Heisenberg algebra of rank 1 over Rational Field
sage: X.display(H.chart_exp1().frame())
p1 = d/dx_0 - 1/2*x_1 d/dx_2
p1 = ∂/∂x_0 - 1/2*x_1 ∂/∂x_2
Default vs. custom naming for the invariant vector field::
Expand Down Expand Up @@ -625,16 +627,16 @@ def right_translation(self, g):
sage: R_g = G.right_translation(g); R_g
Diffeomorphism of the Lie group G of Heisenberg algebra of rank 1 over Rational Field
sage: R_g.display(chart1=G.chart_exp1(), chart2=G.chart_exp1())
G --> G
(x_0, x_1, x_2) |--> (x_0 + 1, x_1, -1/2*x_1 + x_2)
G G
(x_0, x_1, x_2) (x_0 + 1, x_1, -1/2*x_1 + x_2)
Right translation by a generic element::
sage: h = G.point([var('a'), var('b'), var('c')])
sage: R_h = G.right_translation(h)
sage: R_h.display(chart1=G.chart_exp1(), chart2=G.chart_exp1())
G --> G
(x_0, x_1, x_2) |--> (a + x_0, b + x_1, 1/2*b*x_0 - 1/2*a*x_1 + c + x_2)
G G
(x_0, x_1, x_2) (a + x_0, b + x_1, 1/2*b*x_0 - 1/2*a*x_1 + c + x_2)
"""
chart = self.default_chart()
x = self.point(chart[:])
Expand All @@ -659,11 +661,11 @@ def right_invariant_frame(self, **kwds):
Vector frame (G, (XR_1,XR_2,XR_12))
sage: coord_frame = G.chart_exp1().frame()
sage: rivf[0].display(coord_frame)
XR_1 = d/dx_1 + 1/2*x_2 d/dx_12
XR_1 = ∂/∂x_1 + 1/2*x_2 ∂/∂x_12
sage: rivf[1].display(coord_frame)
XR_2 = d/dx_2 - 1/2*x_1 d/dx_12
XR_2 = ∂/∂x_2 - 1/2*x_1 ∂/∂x_12
sage: rivf[2].display(coord_frame)
XR_12 = d/dx_12
XR_12 = ∂/∂x_12
Examples of custom labeling for the frame::
Expand Down Expand Up @@ -705,7 +707,7 @@ def right_invariant_extension(self, X, name=None):
sage: X = H.right_invariant_extension(p); X
Vector field p1 on the Lie group H of Heisenberg algebra of rank 1 over Rational Field
sage: X.display(H.chart_exp1().frame())
p1 = d/dx_0 + 1/2*x_1 d/dx_2
p1 = ∂/∂x_0 + 1/2*x_1 ∂/∂x_2
Default vs. custom naming for the invariant vector field::
Expand Down Expand Up @@ -747,8 +749,8 @@ def conjugation(self, g):
sage: C_g = G.conjugation(g); C_g
Diffeomorphism of the Lie group G of Heisenberg algebra of rank 1 over Rational Field
sage: C_g.display(chart1=G.chart_exp1(), chart2=G.chart_exp1())
G --> G
(x_0, x_1, x_2) |--> (x_0, x_1, -b*x_0 + a*x_1 + x_2)
G G
(x_0, x_1, x_2) (x_0, x_1, -b*x_0 + a*x_1 + x_2)
"""
chart = self.default_chart()
x = self.point(chart[:])
Expand Down
32 changes: 17 additions & 15 deletions src/sage/sets/condition_set.py
Expand Up @@ -17,6 +17,7 @@
from sage.structure.unique_representation import UniqueRepresentation
from sage.categories.sets_cat import Sets
from sage.misc.cachefunc import cached_method
from sage.misc.misc import _stable_uniq
from sage.symbolic.expression import is_Expression
from sage.symbolic.callable import is_CallableSymbolicExpression
from sage.symbolic.ring import SymbolicRing, SR, is_SymbolicVariable
Expand Down Expand Up @@ -155,7 +156,7 @@ def __classcall_private__(cls, universe, *predicates, vars=None, names=None, cat
else:
other_predicates.append(predicate)

predicates = sorted(set(callable_symbolic_predicates)) + other_predicates
predicates = list(_stable_uniq(callable_symbolic_predicates + other_predicates))

if not other_predicates and not callable_symbolic_predicates:
if names is None and category is None:
Expand Down Expand Up @@ -210,7 +211,8 @@ def _repr_(self):
t
sage: ZeroDimButNotNullary = ConditionSet(ZZ^0, t > 0, vars=("q"))
sage: ZeroDimButNotNullary._repr_()
'{ q ∈ Ambient free module of rank 0 over the principal ideal domain Integer Ring : t > 0 }'
'{ q ∈ Ambient free module of rank 0
over the principal ideal domain Integer Ring : t > 0 }'
"""
s = "{ "
names = self.variable_names()
Expand Down Expand Up @@ -322,9 +324,9 @@ def _call_predicate(self, predicate, element):
sage: TripleDigits = ZZ^3
sage: predicate(x, y, z) = sqrt(x^2 + y^2 + z^2) < 12; predicate
(x, y, z) |--> sqrt(x^2 + y^2 + z^2) < 12
sage: TripleDigits.rename('ZZ^3')
sage: SmallTriples = ConditionSet(ZZ^3, predicate); SmallTriples
{ (x, y, z) ∈ ZZ^3 : sqrt(x^2 + y^2 + z^2) < 12 }
{ (x, y, z) ∈ Ambient free module of rank 3 over the principal
ideal domain Integer Ring : sqrt(x^2 + y^2 + z^2) < 12 }
sage: predicate = SmallTriples._predicates[0]
sage: element = TripleDigits((1, 2, 3))
sage: SmallTriples._call_predicate(predicate, element)
Expand Down Expand Up @@ -355,9 +357,9 @@ def _an_element_(self):
sage: TripleDigits = ZZ^3
sage: predicate(x, y, z) = sqrt(x^2 + y^2 + z^2) < 12; predicate
(x, y, z) |--> sqrt(x^2 + y^2 + z^2) < 12
sage: TripleDigits.rename('ZZ^3')
sage: SmallTriples = ConditionSet(ZZ^3, predicate); SmallTriples
{ (x, y, z) ∈ ZZ^3 : sqrt(x^2 + y^2 + z^2) < 12 }
{ (x, y, z) ∈ Ambient free module of rank 3 over the principal
ideal domain Integer Ring : sqrt(x^2 + y^2 + z^2) < 12 }
sage: SmallTriples.an_element() # indirect doctest
(1, 0, 0)
"""
Expand Down Expand Up @@ -388,9 +390,9 @@ def _sympy_(self):
sage: predicate(x, y, z) = sqrt(x^2 + y^2 + z^2) < 12; predicate
(x, y, z) |--> sqrt(x^2 + y^2 + z^2) < 12
sage: (ZZ^3).rename('ZZ^3')
sage: SmallTriples = ConditionSet(ZZ^3, predicate); SmallTriples
{ (x, y, z) ∈ ZZ^3 : sqrt(x^2 + y^2 + z^2) < 12 }
{ (x, y, z) ∈ Ambient free module of rank 3 over the principal
ideal domain Integer Ring : sqrt(x^2 + y^2 + z^2) < 12 }
sage: ST = SmallTriples._sympy_(); ST
ConditionSet((x, y, z), sqrt(x**2 + y**2 + z**2) < 12,
ProductSet(Integers, Integers, Integers))
Expand All @@ -400,7 +402,7 @@ def _sympy_(self):
False
sage: Interval = ConditionSet(RR, x >= -7, x <= 4, vars=[x]); Interval
{ x ∈ Real Field with 53 bits of precision : x <= 4, x >= -7 }
{ x ∈ Real Field with 53 bits of precision : x >= -7, x <= 4 }
sage: Interval._sympy_()
ConditionSet(x, (x >= -7) & (x <= 4), SageSet(Real Field with 53 bits of precision))
Expand Down Expand Up @@ -443,14 +445,14 @@ def intersection(self, X):
EXAMPLES::
sage: (ZZ^2).rename("ZZ^2"); (QQ^2).rename("QQ^2")
sage: in_small_oblong(x, y) = x^2 + 3 * y^2 <= 42
sage: SmallOblongUniverse = ConditionSet(QQ^2, in_small_oblong)
sage: SmallOblongUniverse
{ (x, y) ∈ QQ^2 : x^2 + 3*y^2 <= 42 }
{ (x, y) ∈ Vector space of dimension 2 over Rational Field : x^2 + 3*y^2 <= 42 }
sage: parity_check(x, y) = abs(sin(pi/2*(x + y))) < 1/1000
sage: EvenUniverse = ConditionSet(ZZ^2, parity_check); EvenUniverse
{ (x, y) ∈ ZZ^2 : abs(sin(1/2*pi*x + 1/2*pi*y)) < (1/1000) }
{ (x, y) ∈ Ambient free module of rank 2 over the principal ideal
domain Integer Ring : abs(sin(1/2*pi*x + 1/2*pi*y)) < (1/1000) }
sage: SmallOblongUniverse & EvenUniverse
{ (x, y) ∈ Free module of degree 2 and rank 2 over Integer Ring
Echelon basis matrix:
Expand All @@ -462,11 +464,11 @@ def intersection(self, X):
sage: SmallMirrorUniverse = ConditionSet(QQ^2, in_small_oblong, vars=(y, x))
sage: SmallMirrorUniverse
{ (y, x) ∈ QQ^2 : 3*x^2 + y^2 <= 42 }
{ (y, x) ∈ Vector space of dimension 2 over Rational Field : 3*x^2 + y^2 <= 42 }
sage: SmallOblongUniverse & SmallMirrorUniverse
{ (x, y) ∈ QQ^2 : x^2 + 3*y^2 <= 42 }
{ (x, y) ∈ Vector space of dimension 2 over Rational Field : x^2 + 3*y^2 <= 42 }
sage: SmallMirrorUniverse & SmallOblongUniverse
{ (y, x) ∈ QQ^2 : 3*x^2 + y^2 <= 42 }
{ (y, x) ∈ Vector space of dimension 2 over Rational Field : 3*x^2 + y^2 <= 42 }
"""
if isinstance(X, ConditionSet):
return ConditionSet(self.ambient().intersection(X.ambient()),
Expand Down

0 comments on commit ffe18b0

Please sign in to comment.