Opened 2 years ago

# symbolic ring, coercion, restriction: compatible?

Reported by: Owned by: Michael Jung major sage-9.8 manifolds Eric Gourgoulhon, Matthias Köppe, Travis Scrimshaw N/A

At the current stage, we get the following output:

```sage: M = Manifold(2, 'M', structure='topological') # the 2-dimensional sphere S^2
sage: U = M.open_subset('U') # complement of the North pole
sage: c_xy.<x,y> = U.chart() # stereographic coordinates from the North pole
sage: V = M.open_subset('V') # complement of the South pole
sage: c_uv.<u,v> = V.chart() # stereographic coordinates from the South pole
sage: M.declare_union(U,V)   # S^2 is the union of U and V
sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)),
....:                                intersection_name='W',
....:                                restrictions1= x^2+y^2!=0,
....:                                restrictions2= u^2+v^2!=0)
sage: uv_to_xy = xy_to_uv.inverse()
sage: f = M.scalar_field_algebra()(x+u)
sage: f.display()
M --> R
sage: f._express
{}
```

This output is not consistent with the coercion model, in particular not with the coercion `SR -> ScalarFieldAlgebra`. First of all, each element in `SR` should give rise to a well-defined element in `ScalarFieldAlgebra`. This is not fulfilled in the first example. More precisely:

```sage: g = A(x)
sage: g.display()
M --> R
on U: (x, y) |--> x
on W: (u, v) |--> u/(u^2 + v^2)
sage: h = V.scalar_field_algebra()(x)
sage: h.display()
V --> R
on W: (u, v) |--> u/(u^2 + v^2)
on W: (x, y) |--> x
```

The scalar fields resulting from the coercion `SR -> ScalarFieldAlgebra` are not defined on the whole manifold, as they should be for a coercion. In fact, the results are not even well-defined since they are not uniquely determined by the input.

Things get more out of control if no transition map is stated (for example, the transitivity axiom for coercions is violated). However, we probably can assume that this would not reflect the intended usage.

### comment:1 Changed 2 years ago by Michael Jung

Description: modified (diff)

### comment:2 Changed 2 years ago by Michael Jung

Description: modified (diff)

### comment:3 Changed 2 years ago by Michael Jung

What about applying `add_expr_by_continuation` to obtain a scalar field on the whole manifold? This would also result in an error message if no transition map has been stated and solve two problems at once.

Last edited 2 years ago by Michael Jung (previous) (diff)

### comment:4 Changed 2 years ago by Matthias Köppe

I can't comment on the details, but if it's not canonical, it should not be a coercion but only a conversion.

### comment:5 Changed 2 years ago by Michael Jung

I agree. However, the symbolic ring is stated as the base ring of the commutative algebra of scalar fields, which means that there must be a coercion by definition.

Alternatively, the base ring must be changed. But to what?

Last edited 2 years ago by Michael Jung (previous) (diff)

### comment:6 Changed 2 years ago by Travis Scrimshaw

The implementation of the scalar field algebra is currently a bit of an abuse since `SR` is not the true base topological field of the manifold, just an approximation for it. However, there is a good case for the convenience of having it. If you decide to not keep the abuse, then I would change the base field of the scalar field algebra to be the base field of the manifold.

### comment:7 follow-up:  8 Changed 2 years ago by Michael Jung

What about this stating as our base ring? It seems that this is exactly what we need.

### comment:8 in reply to:  7 ; follow-up:  9 Changed 2 years ago by Eric Gourgoulhon

What about this stating as our base ring? It seems that this is exactly what we need.

Well, I am not sure, because in addition to the coordinate symbols, we need other variables, which may represent some parameters in the scalar field. For instance, we may have

```sage: M = Manifold(2, 'M')
sage: X.<x,y> = M.chart()
sage: a = var('a')
sage: f = M.scalar_field(a*x)
```

### comment:9 in reply to:  8 ; follow-up:  11 Changed 2 years ago by Eric Gourgoulhon

What about this stating as our base ring? It seems that this is exactly what we need.

Well, I am not sure, because in addition to the coordinate symbols, we need other variables, which may represent some parameters in the scalar field.

To clarify, we have currently:

```sage: M = Manifold(2, 'M')
sage: X.<x,y> = M.chart()
sage: a = var('a', domain='real')
sage: f = M.scalar_field(a*x)
sage: g = a*f
sage: g
Scalar field on the 2-dimensional differentiable manifold M
sage: g.display()
M --> R
(x, y) |--> a^2*x
```

Having `SR` be the base field of the scalar field algebra allows the operation `a*f` to work directly, but maybe there is a better way...

### comment:10 Changed 2 years ago by Matthias Köppe

Milestone: sage-9.2 → sage-9.3

### comment:11 in reply to:  9 ; follow-up:  12 Changed 2 years ago by Michael Jung

What about this stating as our base ring? It seems that this is exactly what we need.

Well, I am not sure, because in addition to the coordinate symbols, we need other variables, which may represent some parameters in the scalar field.

To clarify, we have currently:

```sage: M = Manifold(2, 'M')
sage: X.<x,y> = M.chart()
sage: a = var('a', domain='real')
sage: f = M.scalar_field(a*x)
sage: g = a*f
sage: g
Scalar field on the 2-dimensional differentiable manifold M
sage: g.display()
M --> R
(x, y) |--> a^2*x
```

Having `SR` be the base field of the scalar field algebra allows the operation `a*f` to work directly, but maybe there is a better way...

I see your point. What about using the option `accepting_variables` and then successively add parameters to the base ring?

### comment:12 in reply to:  11 Changed 2 years ago by Eric Gourgoulhon

Having `SR` be the base field of the scalar field algebra allows the operation `a*f` to work directly, but maybe there is a better way...

I see your point. What about using the option `accepting_variables` and then successively add parameters to the base ring?

Do you mean calling `accepting_variables` internally, i.e. in a way transparent to the user? I don't think we can ask the end user to do something more fancy than `var('a')...

### comment:13 Changed 23 months ago by Michael Jung

Last edited 17 months ago by Michael Jung (previous) (diff)

### comment:14 Changed 21 months ago by Matthias Köppe

Milestone: sage-9.3 → sage-9.4

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date.

### comment:15 Changed 17 months ago by Matthias Köppe

+1 on encoding dependence on parameters via subrings. #32008 (`CallableSymbolicExpressionRing` over subrings of `SR`) may be relevant.

### comment:16 Changed 17 months ago by Michael Jung

We probably have to subclass that subring, so that it dynamically keeps track of charts defined on the manifold and thus rejects all variables coming from charts.

Last edited 17 months ago by Michael Jung (previous) (diff)

### comment:17 Changed 16 months ago by Matthias Köppe

Milestone: sage-9.4 → sage-9.5

### comment:18 Changed 12 months ago by Matthias Köppe

Milestone: sage-9.5 → sage-9.6

### comment:19 Changed 8 months ago by Matthias Köppe

Milestone: sage-9.6 → sage-9.7

### comment:20 Changed 3 months ago by Matthias Köppe

Milestone: sage-9.7 → sage-9.8
Note: See TracTickets for help on using tickets.