oscar-system / Oscar.jl

A comprehensive open source computer algebra system for computations in algebra, geometry, and number theory.
https://www.oscar-system.org
Other
328 stars 118 forks source link

Map question (coercion) #1093

Open thofma opened 2 years ago

thofma commented 2 years ago

To all lovers of maps, there are some questions that came up during @ThomasBreuer recent cleanup of the julia <-> GAP conversions. Suppose that f is a Map with proper domain and codomain. I will only talk about image(f, x), but the same questions arise for preimage(f, y).

Should image(f, x) only work for parent(x) === domain(f) or should image(f, x) also work where we have "canonical" coercions in place?*

More concretely, if I have a map f : QQ[x] -> QQ[x], should f(1//2) or f(QQ(1//2)) also work?

Pro:

Con:

*: By canonical coercions I mean here the coercion that is already taken place for binary operations. For example, one can add an element of QQ and QQ[x] or an element of ZZ and any other (unitary) ring.

CC: @ThomasBreuer @fingolfin @fieker

ThomasBreuer commented 2 years ago

I think that such extended functionality is nice as long as the documented underlying rules are easy to understand.

For example, if image(f, obj) is defined as image(f, coerce_to(domain(f), obj)) whenever parent(obj) != domain(f) holds then the situation is clear for both users and developers.

If we want to support image(f, set) for subsets set of domain(f), as in the example of an ideal in domain(f), the rule becomes already more complicated. And then the natural question arises whether set may also be something that can be coerced to a subset of domain(f).