Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global function fields: divisors #27121

Closed
kwankyu opened this issue Jan 25, 2019 · 18 comments
Closed

Global function fields: divisors #27121

kwankyu opened this issue Jan 25, 2019 · 18 comments

Comments

@kwankyu
Copy link
Collaborator

kwankyu commented Jan 25, 2019

This is part of the meta-ticket #22982.

The goal of the present ticket is to add code for computing with divisors of global function fields.

Component: algebra

Author: Kwankyu Lee

Branch/Commit: 642b659

Reviewer: Travis Scrimshaw

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

@kwankyu kwankyu added this to the sage-8.7 milestone Jan 25, 2019
@kwankyu
Copy link
Collaborator Author

kwankyu commented Feb 12, 2019

Branch: u/klee/27121

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 12, 2019

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

86481c4Add divisors to function fields

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 12, 2019

Commit: 86481c4

@kwankyu
Copy link
Collaborator Author

kwankyu commented Feb 12, 2019

Author: Kwankyu Lee

@tscrim
Copy link
Collaborator

tscrim commented Feb 13, 2019

comment:4

Here are my comments.

The __radd__ should not be necessary as the coercion framework should take care of that (which you are using with _add_), unless you are trying to explicitly avoid the coercion framework (as the coercions you would need are not (or should not) be there).

Is there a way to minimize the duplication of divisor, divisor_of_zeros, and divisor_of_poles in the two files (say, by putting them in a common base class for the respective files)? It all looks like basically the same code.

self.divisor_group()(0) -> self.divisor_group().zero() (the latter is cached).

Similarly, I am not sure I like having the zero_divisor method. If anything, it should do DivisorGroup(field).zero() and not be used to construct the 0 of the divisor group. I am slightly in favor of removing it for the explicitness of the code (as it is a one-liner), but I can somewhat see how it might be a more natural operation.

I don't see the point in the valuation_ring method as it does not involve self. This was something I missed on a previous review, but I noticed here because of the diff.

The keys here is unnecessary: sorted(self._data.keys()).

It is faster to use while s and o: instead of while len(s) > 0 and len(o) > 0:.

@kwankyu
Copy link
Collaborator Author

kwankyu commented Feb 14, 2019

comment:5

Replying to @tscrim:

The __radd__ should not be necessary as the coercion framework should take care of that (which you are using with _add_), unless you are trying to explicitly avoid the coercion framework (as the coercions you would need are not (or should not) be there).

How could I achieve the following without __radd__? An integer (in particular zero) is not supposed to be coerced to a place. Then how the coercion framework could enable the example below. Would you give me hints?

        This is only to support the ``sum`` function, that adds
        the argument to initial (int) zero.

        EXAMPLES::

            sage: k.<a>=GF(2)
            sage: K.<x>=FunctionField(k)
            sage: sum(K.places_finite())
            Place (x) + Place (x + 1)

        .. NOTE:

        This does not work though::

            sage: 0 + K.place_infinite()
            Traceback (most recent call last):
            ...
            TypeError: unsupported operand parent(s) for +: ...

        The reason is that the ``0`` is a Sage integer, for which
        the coercion system applies. 

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 14, 2019

Changed commit from 86481c4 to b902189

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 14, 2019

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

b902189Various fixes

@kwankyu
Copy link
Collaborator Author

kwankyu commented Feb 14, 2019

comment:7

Replying to @tscrim:

Is there a way to minimize the duplication of divisor, divisor_of_zeros, and divisor_of_poles in the two files (say, by putting them in a common base class for the respective files)? It all looks like basically the same code.

Right. Done.

self.divisor_group()(0) -> self.divisor_group().zero() (the latter is cached).

Done.

Similarly, I am not sure I like having the zero_divisor method. If anything, it should do DivisorGroup(field).zero() and not be used to construct the 0 of the divisor group. I am slightly in favor of removing it for the explicitness of the code (as it is a one-liner), but I can somewhat see how it might be a more natural operation.

Done.

I don't see the point in the valuation_ring method as it does not involve self. This was something I missed on a previous review, but I noticed here because of the diff.

Removed.

The keys here is unnecessary: sorted(self._data.keys()).

Done.

It is faster to use while s and o: instead of while len(s) > 0 and len(o) > 0:.

Done.

@tscrim
Copy link
Collaborator

tscrim commented Feb 14, 2019

comment:8

Replying to @kwankyu:

Replying to @tscrim:

The __radd__ should not be necessary as the coercion framework should take care of that (which you are using with _add_), unless you are trying to explicitly avoid the coercion framework (as the coercions you would need are not (or should not) be there).

How could I achieve the following without __radd__? An integer (in particular zero) is not supposed to be coerced to a place. Then how the coercion framework could enable the example below. Would you give me hints?

To get this to work, you would need to allow 0 to convert into the parent (which is a special case within the coercion framework). So that is why this works:

sage: 0 + vector([1,2,1])
(1, 2, 1)
sage: coercion_model.canonical_coercion(0, v)
((0, 0, 0), (1, 2, 1))

So if you want it to work, you can hack something together to have 0 be some sort of allowed conversion to a dummy element.

@tscrim
Copy link
Collaborator

tscrim commented Feb 14, 2019

comment:9

Also, the .. NOTE:: block should have two colons and the following text should be indented, but this might be moot.

@kwankyu
Copy link
Collaborator Author

kwankyu commented Feb 14, 2019

comment:10

Replying to @tscrim:

Replying to @kwankyu:

Replying to @tscrim:

The __radd__ should not be necessary as the coercion framework should take care of that (which you are using with _add_), unless you are trying to explicitly avoid the coercion framework (as the coercions you would need are not (or should not) be there).

How could I achieve the following without __radd__? An integer (in particular zero) is not supposed to be coerced to a place. Then how the coercion framework could enable the example below. Would you give me hints?

To get this to work, you would need to allow 0 to convert into the parent (which is a special case within the coercion framework). So that is why this works:

sage: 0 + vector([1,2,1])
(1, 2, 1)
sage: coercion_model.canonical_coercion(0, v)
((0, 0, 0), (1, 2, 1))

So if you want it to work, you can hack something together to have 0 be some sort of allowed conversion to a dummy element.

For vectors, 0 is naturally understood as zero vector, and the coercion system implements this. But as I said above, I don't want 0 to be coerced as some place (there is nothing like zero place). All I want is to make sum(a bunch of places) work.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 14, 2019

Changed commit from b902189 to 642b659

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 14, 2019

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

642b659Fix docstring for __radd__

@tscrim
Copy link
Collaborator

tscrim commented Feb 14, 2019

comment:12

Okay, if it does what you want, then positive review.

@tscrim
Copy link
Collaborator

tscrim commented Feb 14, 2019

Reviewer: Travis Scrimshaw

@kwankyu
Copy link
Collaborator Author

kwankyu commented Feb 14, 2019

comment:13

Replying to @tscrim:

Okay, if it does what you want, then positive review.

I admit that the __radd__ thing is ugly. What I want is to allow 0 + p for a place p to result in the divisor p (=1*p; divisors are just formal sums of places). I wish that I could fix this later when I have a solution example of similar situation.

Thank you!

@vbraun
Copy link
Member

vbraun commented Feb 15, 2019

Changed branch from u/klee/27121 to 642b659

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants