Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread Nils Bruin
On Saturday, 28 October 2023 at 18:50:12 UTC-7 Nils Bruin wrote:

On Saturday, 28 October 2023 at 15:26:35 UTC-7 Kwankyu wrote:


f1, f2, f3 are univariate polynomials (say in y) over rational function 
field (say in x). Then x and y are not always the variables X and Y of the 
coordinate ring of the affine plane. Things are more complicated if the 
curve is in space (of dim > 2).
 

Sure. But you did get x,y somehow from the model with which C was given. 
Most likely, the A2 on which x,y are coordinates is obtained via projection 
from whatever model C was given by? Even if it is not a linear map, there 
are still expressions through which you can pull back x,y to the original 
model. You're right that the representations may get rather bad, but I'm 
not sure there's really something you can do about that. 


The most pressing problem in sage at the moment seems to be that presently 
there only seem to be morphisms between schemes. You need rational maps for 
this (especially from a singular model, the map to a canonical model might 
only be a rational map).

So I think we'd first need a bit of a push to get some infrastructure for 
rational maps. In fact "maps" between schemes in magma are just rational 
maps. So presently there is really a difference in functionality.

There are some conceptual problems with the main "map" type between schemes 
being a rational map. But it is very convenient and certainly for curves a 
much better fit than maps that are clearly morphisms.

I might be overlooking something ... currently sage allows for the 
construction of a rational map P2 -> P2, but then asking for the image of a 
curve C in P2 leads to

TypeError: map must be a morphism

(which should probably be a ValueError). Perhaps the code is just 
unnecessarily picky? 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/efdf5070-97a8-49b1-876b-1cdce5b61455n%40googlegroups.com.


Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread Nils Bruin
On Saturday, 28 October 2023 at 15:26:35 UTC-7 Kwankyu wrote:


f1, f2, f3 are univariate polynomials (say in y) over rational function 
field (say in x). Then x and y are not always the variables X and Y of the 
coordinate ring of the affine plane. Things are more complicated if the 
curve is in space (of dim > 2).
 

Sure. But you did get x,y somehow from the model with which C was given. 
Most likely, the A2 on which x,y are coordinates is obtained via projection 
from whatever model C was given by? Even if it is not a linear map, there 
are still expressions through which you can pull back x,y to the original 
model. You're right that the representations may get rather bad, but I'm 
not sure there's really something you can do about that. 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/3ea279ab-4b25-43ee-856f-8e9ca8bcc147n%40googlegroups.com.


Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread Kwankyu


That's actually trivially simple: if [f1,f2,f3] is the basis of your 
Riemann-Roch space, you just consider the map defined by [f1:f2:f3]. So you 
lift f1,f2,f3 to rational functions on the affine space that contains your 
curve: you just take the rational function representation and forget the 
algebraic relations between the variables. 


f1, f2, f3 are univariate polynomials (say in y) over rational function 
field (say in x). Then x and y are not always the variables X and Y of the 
coordinate ring of the affine plane. Things are more complicated if the 
curve is in space (of dim > 2).

 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/e86f87d9-8448-4f4e-af0e-1c749b193291n%40googlegroups.com.


Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread John H Palmieri
Nils, thanks to you, too, for your responses.

On Saturday, October 28, 2023 at 11:16:39 AM UTC-7 Nils Bruin wrote:

> On Saturday, 28 October 2023 at 05:39:26 UTC-7 Kwankyu wrote:
>
> I looked the Magma code in ask.sagemath. There's no problem in computing a 
> canonical divisor for the curve (through the attached function field). 
> Computing a basis of the Riemann-Roch space is no problem as well. Actually 
> the hard part is to construct the morphism from C to P2 from the basis. 
> Magma does this seamlessly. But Sage lacks this functionality (perhaps 
> because I did not implement it). I think, the gist of the matter is to 
> convert an element of the function field to a rational function of the 
> coordinate ring of P2.
>
>
> That's actually trivially simple: if [f1,f2,f3] is the basis of your 
> Riemann-Roch space, you just consider the map defined by [f1:f2:f3]. So you 
> lift f1,f2,f3 to rational functions on the affine space that contains your 
> curve: you just take the rational function representation and forget the 
> algebraic relations between the variables. You now have rational functions 
> in a rational function field, so you can clear denominators there. Now you 
> have a rational map (described by polynomials) A^2->P^r under which the 
> rational image of your curve C in A^2 is the corresponding projective 
> image. Computing that image is the usual groebner-basis operation for 
> finding images of rational maps, so that's potentially quite expensive.
>
> In practice, you know something about the denominators of the 
> representations of f1,f2,f3, so you can probably do a little better.
>
> At its core, that is what the magma code does too, although perhaps it has 
> some smart tricks here and there to try and keep degrees in check a bit.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/9449eaa0-6470-4cd2-91a5-6780f1faab86n%40googlegroups.com.


Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread Nils Bruin
On Saturday, 28 October 2023 at 05:39:26 UTC-7 Kwankyu wrote:

I looked the Magma code in ask.sagemath. There's no problem in computing a 
canonical divisor for the curve (through the attached function field). 
Computing a basis of the Riemann-Roch space is no problem as well. Actually 
the hard part is to construct the morphism from C to P2 from the basis. 
Magma does this seamlessly. But Sage lacks this functionality (perhaps 
because I did not implement it). I think, the gist of the matter is to 
convert an element of the function field to a rational function of the 
coordinate ring of P2.


That's actually trivially simple: if [f1,f2,f3] is the basis of your 
Riemann-Roch space, you just consider the map defined by [f1:f2:f3]. So you 
lift f1,f2,f3 to rational functions on the affine space that contains your 
curve: you just take the rational function representation and forget the 
algebraic relations between the variables. You now have rational functions 
in a rational function field, so you can clear denominators there. Now you 
have a rational map (described by polynomials) A^2->P^r under which the 
rational image of your curve C in A^2 is the corresponding projective 
image. Computing that image is the usual groebner-basis operation for 
finding images of rational maps, so that's potentially quite expensive.

In practice, you know something about the denominators of the 
representations of f1,f2,f3, so you can probably do a little better.

At its core, that is what the magma code does too, although perhaps it has 
some smart tricks here and there to try and keep degrees in check a bit.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/ddd052ef-029c-4237-b2b7-9d5328201e07n%40googlegroups.com.


Re: [sage-support] Re: ideal intersection in ZZ

2023-10-28 Thread Nils Bruin
On Saturday, 28 October 2023 at 10:22:15 UTC-7 G. M.-S. wrote:


Thanks, Nils.

My question was motivated by using SageMath in my teachings.

Do you think it would be difficult/worthwhile taking care of this?
I mean, ideals in euclidean rings (or at least in ZZ).


Mathematically or algorithmically not difficult of course. I'd expect that 
to make it play nice with the category framework you'll need to do a lot of 
work. By the looks of ZZ.categories(), there is a category of "euclidean 
domains". The parent of ideals in ZZ, however, looks rather generic. I 
don't think the euclidean properties are propagated to the monoid of ideals 
at all at the moment. The "appropriate" level of generality would be there. 
However, there's not much to be gained from ideals in euclidean domains: we 
already have lcm and gcd! So I suspect that's why it's not implemented at 
the moment.

I can see how having such ideals may seem instructive for teaching. I think 
that's a matter of philosophy / opinion. I happen to not believe that 
teaching students formalisms in computer algebra packages without real 
benefit/content (beyond lcm and gcd that they'll learn anyway) helps them 
much, so I wouldn't think it's worthwhile. Perhaps for having facilities 
for ideals universally available, it could be useful if ideals in ZZ have 
"intersection" implemented, but I have trouble seeing where that would come 
up.

There are rings with ZZ as a subring for which intersection works on ideals 
proper, since we have groebner bases over ZZ, apparently:

sage: R.=ZZ['x','y']
sage: I=R.ideal(15)
sage: J=R.ideal(35)
sage: I.intersection(J)

So you could use that ... or if you manage to define a multivariate 
polynomial ring over ZZ in 0 variables, you'd be good to go too. Free 
ZZ-modules of rank 1 would also get you the right behaviour.
 

Guillermo

On Sat, 28 Oct 2023 at 18:44, Nils Bruin  wrote:

I'm sure its omission is just an oversight. For fractional ideals in number 
fields it is defined:

sage: K.=QuadraticField(7)
sage: I=K.fractional_ideal(5)
sage: J=K.fractional_ideal(3)
sage: I.intersection(J)
Fractional ideal (15)

I doubt that just knowing a ring is a PID makes computing intersections of 
ideals easy. So the omission may be because there doesn't seem to be 
ZZ-specific (or euclidean ring-specific) ideal code. And with lcm around, 
the need for it has been low, I expect.

On Saturday, 28 October 2023 at 02:36:51 UTC-7 G. M.-S. wrote:


I wonder why SageMath cannot compute the intersection of 2 ideals in ZZ.

Is this due to the fact that ZZ would "only" be a PID?

Guillermo

┌┐

│ SageMath version 10.1, Release Date: 2023-08-20│

│ Using Python 3.11.1. Type "help()" for help.   │

└┘

sage: n1,n2=720,756

sage: d,m=gcd(n1,n2),lcm(n1,n2)

sage: n1,n2,d,m

(720, 756, 36, 15120)

sage: I1,I2=ZZ.ideal(n1),ZZ.ideal(n2)

sage: I1,I2

(Principal ideal (720) of Integer Ring, Principal ideal (756) of Integer 
Ring)

sage: I1+I2

Principal ideal (36) of Integer Ring

sage: I1.intersection(I2)

---

AttributeErrorTraceback (most recent call last)

Cell In [7], line 1

> 1 I1.intersection(I2)


File 
/private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:488,
 
in sage.structure.element.Element.__getattr__ 
(build/cythonized/sage/structure/element.c:4846)()

*486* AttributeError: 
'LeftZeroSemigroup_with_category.element_class' object has no attribute 
'blah_blah'

*487* """

--> 488 return self.getattr_from_category(name)

*489* 

*490* cdef getattr_from_category(self, name):


File 
/private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:501,
 
in sage.structure.element.Element.getattr_from_category 
(build/cythonized/sage/structure/element.c:4958)()

*499* else:

*500* cls = P._abstract_element_class

--> 501 return getattr_from_other_class(self, cls, name)

*502* 

*503* def __dir__(self):


File 
/private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/cpython/getattr.pyx:362,
 
in sage.cpython.getattr.getattr_from_other_class 
(build/cythonized/sage/cpython/getattr.c:2773)()

*360* dummy_error_message.cls = type(self)

*361* dummy_error_message.name = name

--> 362 raise AttributeError(dummy_error_message)

*363* attribute = attr

*364* # Check for a descriptor (__get__ in Python)


AttributeError: 'Ideal_pid' object has no attribute 'intersection'

sage: 

 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from 

Re: [sage-support] Re: ideal intersection in ZZ

2023-10-28 Thread G. M.-S.
Thanks, Nils.

My question was motivated by using SageMath in my teachings.

Do you think it would be difficult/worthwhile taking care of this?
I mean, ideals in euclidean rings (or at least in ZZ).

Guillermo

On Sat, 28 Oct 2023 at 18:44, Nils Bruin  wrote:

> I'm sure its omission is just an oversight. For fractional ideals in
> number fields it is defined:
>
> sage: K.=QuadraticField(7)
> sage: I=K.fractional_ideal(5)
> sage: J=K.fractional_ideal(3)
> sage: I.intersection(J)
> Fractional ideal (15)
>
> I doubt that just knowing a ring is a PID makes computing intersections of
> ideals easy. So the omission may be because there doesn't seem to be
> ZZ-specific (or euclidean ring-specific) ideal code. And with lcm around,
> the need for it has been low, I expect.
>
> On Saturday, 28 October 2023 at 02:36:51 UTC-7 G. M.-S. wrote:
>
>>
>> I wonder why SageMath cannot compute the intersection of 2 ideals in ZZ.
>>
>> Is this due to the fact that ZZ would "only" be a PID?
>>
>> Guillermo
>>
>> ┌┐
>>
>> │ SageMath version 10.1, Release Date: 2023-08-20│
>>
>> │ Using Python 3.11.1. Type "help()" for help.   │
>>
>> └┘
>>
>> sage: n1,n2=720,756
>>
>> sage: d,m=gcd(n1,n2),lcm(n1,n2)
>>
>> sage: n1,n2,d,m
>>
>> (720, 756, 36, 15120)
>>
>> sage: I1,I2=ZZ.ideal(n1),ZZ.ideal(n2)
>>
>> sage: I1,I2
>>
>> (Principal ideal (720) of Integer Ring, Principal ideal (756) of Integer
>> Ring)
>>
>> sage: I1+I2
>>
>> Principal ideal (36) of Integer Ring
>>
>> sage: I1.intersection(I2)
>>
>>
>> ---
>>
>> AttributeErrorTraceback (most recent call
>> last)
>>
>> Cell In [7], line 1
>>
>> > 1 I1.intersection(I2)
>>
>>
>> File
>> /private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:488,
>> in sage.structure.element.Element.__getattr__
>> (build/cythonized/sage/structure/element.c:4846)()
>>
>> *486* AttributeError:
>> 'LeftZeroSemigroup_with_category.element_class' object has no attribute
>> 'blah_blah'
>>
>> *487* """
>>
>> --> 488 return self.getattr_from_category(name)
>>
>> *489*
>>
>> *490* cdef getattr_from_category(self, name):
>>
>>
>> File
>> /private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:501,
>> in sage.structure.element.Element.getattr_from_category
>> (build/cythonized/sage/structure/element.c:4958)()
>>
>> *499* else:
>>
>> *500* cls = P._abstract_element_class
>>
>> --> 501 return getattr_from_other_class(self, cls, name)
>>
>> *502*
>>
>> *503* def __dir__(self):
>>
>>
>> File
>> /private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/cpython/getattr.pyx:362,
>> in sage.cpython.getattr.getattr_from_other_class
>> (build/cythonized/sage/cpython/getattr.c:2773)()
>>
>> *360* dummy_error_message.cls = type(self)
>>
>> *361* dummy_error_message.name = name
>>
>> --> 362 raise AttributeError(dummy_error_message)
>>
>> *363* attribute = attr
>>
>> *364* # Check for a descriptor (__get__ in Python)
>>
>>
>> AttributeError: 'Ideal_pid' object has no attribute 'intersection'
>>
>> sage:
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CANnG18_Mj3vkO62hj%2B2-oO%2BiV4mcx5vtzukRJSNYrU5evPgZOg%40mail.gmail.com.


Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread John H Palmieri
Thanks for all of your posts, Kwankyu. Helpful and informative.

  John


On Saturday, October 28, 2023 at 6:19:48 AM UTC-7 Kwankyu wrote:

> To answer John's question:
>
> sage: P2. = ProjectiveSpace(QQ, 2)
> sage: f = 2*x^5 - 4*x^3*y*z + x^2*y*z^2 + 2*x*y^3*z + 2*x*y^2*z^2+ y^5
> sage: C = P2.curve(f)
> sage: F = C.function_field()
> sage: z, = F.gens()
> sage: K = z.differential().divisor()  # canonical divisor
> sage: (-K).dimension()
> 3
> sage: f1, f2, f3 = (-K).basis_function_space()
> sage: phi = C.hom(P2, [f1,f2,f3]). <--- does not work
> sage: phi.image()  # will work
>
> On Saturday, October 28, 2023 at 9:59:58 PM UTC+9 Kwankyu wrote:
>
>> Let me mention also the related PR 
>>
>> https://github.com/sagemath/sage/pull/35467
>>
>> which implements Jacobian groups of curves (again via function field), 
>> referencing Nils' old code. The PR is long sleeping in draft state. If 
>> anyone finds it useful, I may wake it up. 
>>
>> On Saturday, October 28, 2023 at 9:39:26 PM UTC+9 Kwankyu wrote:
>>
>>> Hi,
>>>
>>> I replied to Dima's comment in 
>>> https://github.com/sagemath/sage/commit/977ace651af9b99689f7b6507f91f8b4e2588ae9#r131138149
>>> . 
>>>
>>> Note that the "divisor" method of a curve had existed long before I 
>>> added function field machinery and attached function fields to curves. 
>>> Hence actually there are two systems of "divisors" of curves in Sage. 
>>>
>>> The old system was implemented by William Stein, David Kohel, and Volker 
>>> Braun. In the old system, a divisor is a formal sum of rational points with 
>>> multiplicities. It is mainly implemented in 
>>> `src/sage/schemes/generic/divisor.py`. Overall it is very rudimentary. Dima 
>>> and John is attempting to use this system.
>>>
>>> The new system was implemented by me. Here a divisor is a formal sum of 
>>> places of a function field with multiplicities. This system is available 
>>> via the function field attached to a curve. This is much more powerful than 
>>> the old system. You can compute the Riemann-Roch space of a divisor. Nils 
>>> is using this system.
>>>
>>> I never attempted to combine the two systems, being afraid of breaking 
>>> the old system (or just being lazy :-) There are similarly two systems in 
>>> Magma too. But in Magma, the two systems are integrated tightly and 
>>> seamlessly. I did some integration in Sage too but far from complete 
>>> compared with Magma.
>>>
>>> I looked the Magma code in ask.sagemath. There's no problem in computing 
>>> a canonical divisor for the curve (through the attached function field). 
>>> Computing a basis of the Riemann-Roch space is no problem as well. Actually 
>>> the hard part is to construct the morphism from C to P2 from the basis. 
>>> Magma does this seamlessly. But Sage lacks this functionality (perhaps 
>>> because I did not implement it). I think, the gist of the matter is to 
>>> convert an element of the function field to a rational function of the 
>>> coordinate ring of P2. I have no idea how to do this now... Once you 
>>> construct the morphism, Sage can also compute the image of the morphism 
>>> (perhaps I implemented this). Hence unfortunately the Magma code cannot be 
>>> line by line converted to Sage code at present.
>>>
>>> On Saturday, October 28, 2023 at 8:27:07 AM UTC+9 Dima Pasechnik wrote:
>>>
 On Sat, Oct 28, 2023 at 1:02 AM John H Palmieri  
 wrote: 

 > Yes, I noticed that, too. It also fails to provide any information 
 about what ``v`` should be (beyond saying that it should be a "valid 
 object"): there is no INPUT block. 

 I've left a comment here: 

 https://github.com/sagemath/sage/commit/977ace651af9b99689f7b6507f91f8b4e2588ae9#r131117132
  

 fortunately, the author, @kwankyu is active 

 I can't locate the ticket, but it was merged in 9.0.beta9 


 > 
 > 
 > On Friday, October 27, 2023 at 3:51:10 PM UTC-7 Dima Pasechnik wrote: 
 >> 
 >> By the way, the docstring of divisor() misses an example, it's 
 >> 
 >> def divisor(self, v, base_ring=None, check=True, reduce=True): 
 >> r""" 
 >> Return the divisor specified by ``v``. 
 >> 
 >> .. WARNING:: 
 >> 
 >> The coefficients of the divisor must be in the base ring 
 >> and the terms must be reduced. If you set ``check=False`` 
 >> and/or ``reduce=False`` it is your responsibility to pass 
 >> a valid object ``v``. 
 >> 
 >> EXAMPLES:: 
 >> 
 >> sage: x,y,z = PolynomialRing(QQ, 3, names='x,y,z').gens() 
 >> sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2) 
 >> 
 >> """ 
 >> 
 >> Is there an issue for this? 
 >> 
 >> On Sat, Oct 28, 2023 at 12:42 AM Nils Bruin  wrote: 
 >> > 
 >> > A canonical divisor is the divisor of any differential on C so the 
 following does the trick: 
 >> > 
 >> > sage: kC=C.function_field() 
 >> > sage: 

[sage-support] Re: ideal intersection in ZZ

2023-10-28 Thread Nils Bruin
I'm sure its omission is just an oversight. For fractional ideals in number 
fields it is defined:

sage: K.=QuadraticField(7)
sage: I=K.fractional_ideal(5)
sage: J=K.fractional_ideal(3)
sage: I.intersection(J)
Fractional ideal (15)

I doubt that just knowing a ring is a PID makes computing intersections of 
ideals easy. So the omission may be because there doesn't seem to be 
ZZ-specific (or euclidean ring-specific) ideal code. And with lcm around, 
the need for it has been low, I expect.

On Saturday, 28 October 2023 at 02:36:51 UTC-7 G. M.-S. wrote:

>
> I wonder why SageMath cannot compute the intersection of 2 ideals in ZZ.
>
> Is this due to the fact that ZZ would "only" be a PID?
>
> Guillermo
>
> ┌┐
>
> │ SageMath version 10.1, Release Date: 2023-08-20│
>
> │ Using Python 3.11.1. Type "help()" for help.   │
>
> └┘
>
> sage: n1,n2=720,756
>
> sage: d,m=gcd(n1,n2),lcm(n1,n2)
>
> sage: n1,n2,d,m
>
> (720, 756, 36, 15120)
>
> sage: I1,I2=ZZ.ideal(n1),ZZ.ideal(n2)
>
> sage: I1,I2
>
> (Principal ideal (720) of Integer Ring, Principal ideal (756) of Integer 
> Ring)
>
> sage: I1+I2
>
> Principal ideal (36) of Integer Ring
>
> sage: I1.intersection(I2)
>
> ---
>
> AttributeErrorTraceback (most recent call 
> last)
>
> Cell In [7], line 1
>
> > 1 I1.intersection(I2)
>
>
> File 
> /private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:488,
>  
> in sage.structure.element.Element.__getattr__ 
> (build/cythonized/sage/structure/element.c:4846)()
>
> *486* AttributeError: 
> 'LeftZeroSemigroup_with_category.element_class' object has no attribute 
> 'blah_blah'
>
> *487* """
>
> --> 488 return self.getattr_from_category(name)
>
> *489* 
>
> *490* cdef getattr_from_category(self, name):
>
>
> File 
> /private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:501,
>  
> in sage.structure.element.Element.getattr_from_category 
> (build/cythonized/sage/structure/element.c:4958)()
>
> *499* else:
>
> *500* cls = P._abstract_element_class
>
> --> 501 return getattr_from_other_class(self, cls, name)
>
> *502* 
>
> *503* def __dir__(self):
>
>
> File 
> /private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/cpython/getattr.pyx:362,
>  
> in sage.cpython.getattr.getattr_from_other_class 
> (build/cythonized/sage/cpython/getattr.c:2773)()
>
> *360* dummy_error_message.cls = type(self)
>
> *361* dummy_error_message.name = name
>
> --> 362 raise AttributeError(dummy_error_message)
>
> *363* attribute = attr
>
> *364* # Check for a descriptor (__get__ in Python)
>
>
> AttributeError: 'Ideal_pid' object has no attribute 'intersection'
>
> sage: 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/f54544d4-93f5-4411-99c9-335a67de25f3n%40googlegroups.com.


Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread Kwankyu
To answer John's question:

sage: P2. = ProjectiveSpace(QQ, 2)
sage: f = 2*x^5 - 4*x^3*y*z + x^2*y*z^2 + 2*x*y^3*z + 2*x*y^2*z^2+ y^5
sage: C = P2.curve(f)
sage: F = C.function_field()
sage: z, = F.gens()
sage: K = z.differential().divisor()  # canonical divisor
sage: (-K).dimension()
3
sage: f1, f2, f3 = (-K).basis_function_space()
sage: phi = C.hom(P2, [f1,f2,f3]). <--- does not work
sage: phi.image()  # will work

On Saturday, October 28, 2023 at 9:59:58 PM UTC+9 Kwankyu wrote:

> Let me mention also the related PR 
>
> https://github.com/sagemath/sage/pull/35467
>
> which implements Jacobian groups of curves (again via function field), 
> referencing Nils' old code. The PR is long sleeping in draft state. If 
> anyone finds it useful, I may wake it up. 
>
> On Saturday, October 28, 2023 at 9:39:26 PM UTC+9 Kwankyu wrote:
>
>> Hi,
>>
>> I replied to Dima's comment in 
>> https://github.com/sagemath/sage/commit/977ace651af9b99689f7b6507f91f8b4e2588ae9#r131138149
>> . 
>>
>> Note that the "divisor" method of a curve had existed long before I added 
>> function field machinery and attached function fields to curves. Hence 
>> actually there are two systems of "divisors" of curves in Sage. 
>>
>> The old system was implemented by William Stein, David Kohel, and Volker 
>> Braun. In the old system, a divisor is a formal sum of rational points with 
>> multiplicities. It is mainly implemented in 
>> `src/sage/schemes/generic/divisor.py`. Overall it is very rudimentary. Dima 
>> and John is attempting to use this system.
>>
>> The new system was implemented by me. Here a divisor is a formal sum of 
>> places of a function field with multiplicities. This system is available 
>> via the function field attached to a curve. This is much more powerful than 
>> the old system. You can compute the Riemann-Roch space of a divisor. Nils 
>> is using this system.
>>
>> I never attempted to combine the two systems, being afraid of breaking 
>> the old system (or just being lazy :-) There are similarly two systems in 
>> Magma too. But in Magma, the two systems are integrated tightly and 
>> seamlessly. I did some integration in Sage too but far from complete 
>> compared with Magma.
>>
>> I looked the Magma code in ask.sagemath. There's no problem in computing 
>> a canonical divisor for the curve (through the attached function field). 
>> Computing a basis of the Riemann-Roch space is no problem as well. Actually 
>> the hard part is to construct the morphism from C to P2 from the basis. 
>> Magma does this seamlessly. But Sage lacks this functionality (perhaps 
>> because I did not implement it). I think, the gist of the matter is to 
>> convert an element of the function field to a rational function of the 
>> coordinate ring of P2. I have no idea how to do this now... Once you 
>> construct the morphism, Sage can also compute the image of the morphism 
>> (perhaps I implemented this). Hence unfortunately the Magma code cannot be 
>> line by line converted to Sage code at present.
>>
>> On Saturday, October 28, 2023 at 8:27:07 AM UTC+9 Dima Pasechnik wrote:
>>
>>> On Sat, Oct 28, 2023 at 1:02 AM John H Palmieri  
>>> wrote: 
>>>
>>> > Yes, I noticed that, too. It also fails to provide any information 
>>> about what ``v`` should be (beyond saying that it should be a "valid 
>>> object"): there is no INPUT block. 
>>>
>>> I've left a comment here: 
>>>
>>> https://github.com/sagemath/sage/commit/977ace651af9b99689f7b6507f91f8b4e2588ae9#r131117132
>>>  
>>>
>>> fortunately, the author, @kwankyu is active 
>>>
>>> I can't locate the ticket, but it was merged in 9.0.beta9 
>>>
>>>
>>> > 
>>> > 
>>> > On Friday, October 27, 2023 at 3:51:10 PM UTC-7 Dima Pasechnik wrote: 
>>> >> 
>>> >> By the way, the docstring of divisor() misses an example, it's 
>>> >> 
>>> >> def divisor(self, v, base_ring=None, check=True, reduce=True): 
>>> >> r""" 
>>> >> Return the divisor specified by ``v``. 
>>> >> 
>>> >> .. WARNING:: 
>>> >> 
>>> >> The coefficients of the divisor must be in the base ring 
>>> >> and the terms must be reduced. If you set ``check=False`` 
>>> >> and/or ``reduce=False`` it is your responsibility to pass 
>>> >> a valid object ``v``. 
>>> >> 
>>> >> EXAMPLES:: 
>>> >> 
>>> >> sage: x,y,z = PolynomialRing(QQ, 3, names='x,y,z').gens() 
>>> >> sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2) 
>>> >> 
>>> >> """ 
>>> >> 
>>> >> Is there an issue for this? 
>>> >> 
>>> >> On Sat, Oct 28, 2023 at 12:42 AM Nils Bruin  wrote: 
>>> >> > 
>>> >> > A canonical divisor is the divisor of any differential on C so the 
>>> following does the trick: 
>>> >> > 
>>> >> > sage: kC=C.function_field() 
>>> >> > sage: kC(kC.base_field().gen(0)).differential().divisor() 
>>> >> > 
>>> >> > It doesn't look like we quite have computation of Riemann-Roch 
>>> spaces natively in sage yet, so finding effective representatives requires 
>>> a little more work. In the RiemannSurface code this is done using 
>>> singular's adjoint 

Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread Kwankyu
Let me mention also the related PR 

https://github.com/sagemath/sage/pull/35467

which implements Jacobian groups of curves (again via function field), 
referencing Nils' old code. The PR is long sleeping in draft state. If 
anyone finds it useful, I may wake it up. 

On Saturday, October 28, 2023 at 9:39:26 PM UTC+9 Kwankyu wrote:

> Hi,
>
> I replied to Dima's comment in 
> https://github.com/sagemath/sage/commit/977ace651af9b99689f7b6507f91f8b4e2588ae9#r131138149
> . 
>
> Note that the "divisor" method of a curve had existed long before I added 
> function field machinery and attached function fields to curves. Hence 
> actually there are two systems of "divisors" of curves in Sage. 
>
> The old system was implemented by William Stein, David Kohel, and Volker 
> Braun. In the old system, a divisor is a formal sum of rational points with 
> multiplicities. It is mainly implemented in 
> `src/sage/schemes/generic/divisor.py`. Overall it is very rudimentary. Dima 
> and John is attempting to use this system.
>
> The new system was implemented by me. Here a divisor is a formal sum of 
> places of a function field with multiplicities. This system is available 
> via the function field attached to a curve. This is much more powerful than 
> the old system. You can compute the Riemann-Roch space of a divisor. Nils 
> is using this system.
>
> I never attempted to combine the two systems, being afraid of breaking the 
> old system (or just being lazy :-) There are similarly two systems in Magma 
> too. But in Magma, the two systems are integrated tightly and seamlessly. I 
> did some integration in Sage too but far from complete compared with Magma.
>
> I looked the Magma code in ask.sagemath. There's no problem in computing a 
> canonical divisor for the curve (through the attached function field). 
> Computing a basis of the Riemann-Roch space is no problem as well. Actually 
> the hard part is to construct the morphism from C to P2 from the basis. 
> Magma does this seamlessly. But Sage lacks this functionality (perhaps 
> because I did not implement it). I think, the gist of the matter is to 
> convert an element of the function field to a rational function of the 
> coordinate ring of P2. I have no idea how to do this now... Once you 
> construct the morphism, Sage can also compute the image of the morphism 
> (perhaps I implemented this). Hence unfortunately the Magma code cannot be 
> line by line converted to Sage code at present.
>
> On Saturday, October 28, 2023 at 8:27:07 AM UTC+9 Dima Pasechnik wrote:
>
>> On Sat, Oct 28, 2023 at 1:02 AM John H Palmieri  
>> wrote: 
>>
>> > Yes, I noticed that, too. It also fails to provide any information 
>> about what ``v`` should be (beyond saying that it should be a "valid 
>> object"): there is no INPUT block. 
>>
>> I've left a comment here: 
>>
>> https://github.com/sagemath/sage/commit/977ace651af9b99689f7b6507f91f8b4e2588ae9#r131117132
>>  
>>
>> fortunately, the author, @kwankyu is active 
>>
>> I can't locate the ticket, but it was merged in 9.0.beta9 
>>
>>
>> > 
>> > 
>> > On Friday, October 27, 2023 at 3:51:10 PM UTC-7 Dima Pasechnik wrote: 
>> >> 
>> >> By the way, the docstring of divisor() misses an example, it's 
>> >> 
>> >> def divisor(self, v, base_ring=None, check=True, reduce=True): 
>> >> r""" 
>> >> Return the divisor specified by ``v``. 
>> >> 
>> >> .. WARNING:: 
>> >> 
>> >> The coefficients of the divisor must be in the base ring 
>> >> and the terms must be reduced. If you set ``check=False`` 
>> >> and/or ``reduce=False`` it is your responsibility to pass 
>> >> a valid object ``v``. 
>> >> 
>> >> EXAMPLES:: 
>> >> 
>> >> sage: x,y,z = PolynomialRing(QQ, 3, names='x,y,z').gens() 
>> >> sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2) 
>> >> 
>> >> """ 
>> >> 
>> >> Is there an issue for this? 
>> >> 
>> >> On Sat, Oct 28, 2023 at 12:42 AM Nils Bruin  wrote: 
>> >> > 
>> >> > A canonical divisor is the divisor of any differential on C so the 
>> following does the trick: 
>> >> > 
>> >> > sage: kC=C.function_field() 
>> >> > sage: kC(kC.base_field().gen(0)).differential().divisor() 
>> >> > 
>> >> > It doesn't look like we quite have computation of Riemann-Roch 
>> spaces natively in sage yet, so finding effective representatives requires 
>> a little more work. In the RiemannSurface code this is done using 
>> singular's adjoint ideal code (or by Baker's theorem in cases where it 
>> applies). For this curve the canonical class is of degree -2, so there are 
>> no effective representatives in this case. 
>> >> > 
>> >> > On Friday, 27 October 2023 at 15:14:00 UTC-7 John H Palmieri wrote: 
>> >> >> 
>> >> >> If anyone here knows anything about canonical divisors and their 
>> implementation in Sage, please see 
>> https://ask.sagemath.org/question/74034/converting-algebraic-geometry-magmas-code-to-sage/.
>>  
>> The setup: 
>> >> >> 
>> >> >> sage: P2. = ProjectiveSpace(QQ, 2) 
>> >> >> sage: f = 2*x^5 - 4*x^3*y*z + x^2*y*z^2 + 

Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread Kwankyu
Hi,

I replied to Dima's comment in 
https://github.com/sagemath/sage/commit/977ace651af9b99689f7b6507f91f8b4e2588ae9#r131138149.
 

Note that the "divisor" method of a curve had existed long before I added 
function field machinery and attached function fields to curves. Hence 
actually there are two systems of "divisors" of curves in Sage. 

The old system was implemented by William Stein, David Kohel, and Volker 
Braun. In the old system, a divisor is a formal sum of rational points with 
multiplicities. It is mainly implemented in 
`src/sage/schemes/generic/divisor.py`. Overall it is very rudimentary. Dima 
and John is attempting to use this system.

The new system was implemented by me. Here a divisor is a formal sum of 
places of a function field with multiplicities. This system is available 
via the function field attached to a curve. This is much more powerful than 
the old system. You can compute the Riemann-Roch space of a divisor. Nils 
is using this system.

I never attempted to combine the two systems, being afraid of breaking the 
old system (or just being lazy :-) There are similarly two systems in Magma 
too. But in Magma, the two systems are integrated tightly and seamlessly. I 
did some integration in Sage too but far from complete compared with Magma.

I looked the Magma code in ask.sagemath. There's no problem in computing a 
canonical divisor for the curve (through the attached function field). 
Computing a basis of the Riemann-Roch space is no problem as well. Actually 
the hard part is to construct the morphism from C to P2 from the basis. 
Magma does this seamlessly. But Sage lacks this functionality (perhaps 
because I did not implement it). I think, the gist of the matter is to 
convert an element of the function field to a rational function of the 
coordinate ring of P2. I have no idea how to do this now... Once you 
construct the morphism, Sage can also compute the image of the morphism 
(perhaps I implemented this). Hence unfortunately the Magma code cannot be 
line by line converted to Sage code at present.

On Saturday, October 28, 2023 at 8:27:07 AM UTC+9 Dima Pasechnik wrote:

> On Sat, Oct 28, 2023 at 1:02 AM John H Palmieri  
> wrote:
>
> > Yes, I noticed that, too. It also fails to provide any information about 
> what ``v`` should be (beyond saying that it should be a "valid object"): 
> there is no INPUT block.
>
> I've left a comment here:
>
> https://github.com/sagemath/sage/commit/977ace651af9b99689f7b6507f91f8b4e2588ae9#r131117132
>
> fortunately, the author, @kwankyu is active
>
> I can't locate the ticket, but it was merged in 9.0.beta9
>
>
> >
> >
> > On Friday, October 27, 2023 at 3:51:10 PM UTC-7 Dima Pasechnik wrote:
> >>
> >> By the way, the docstring of divisor() misses an example, it's
> >>
> >> def divisor(self, v, base_ring=None, check=True, reduce=True):
> >> r"""
> >> Return the divisor specified by ``v``.
> >>
> >> .. WARNING::
> >>
> >> The coefficients of the divisor must be in the base ring
> >> and the terms must be reduced. If you set ``check=False``
> >> and/or ``reduce=False`` it is your responsibility to pass
> >> a valid object ``v``.
> >>
> >> EXAMPLES::
> >>
> >> sage: x,y,z = PolynomialRing(QQ, 3, names='x,y,z').gens()
> >> sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2)
> >>
> >> """
> >>
> >> Is there an issue for this?
> >>
> >> On Sat, Oct 28, 2023 at 12:42 AM Nils Bruin  wrote:
> >> >
> >> > A canonical divisor is the divisor of any differential on C so the 
> following does the trick:
> >> >
> >> > sage: kC=C.function_field()
> >> > sage: kC(kC.base_field().gen(0)).differential().divisor()
> >> >
> >> > It doesn't look like we quite have computation of Riemann-Roch spaces 
> natively in sage yet, so finding effective representatives requires a 
> little more work. In the RiemannSurface code this is done using singular's 
> adjoint ideal code (or by Baker's theorem in cases where it applies). For 
> this curve the canonical class is of degree -2, so there are no effective 
> representatives in this case.
> >> >
> >> > On Friday, 27 October 2023 at 15:14:00 UTC-7 John H Palmieri wrote:
> >> >>
> >> >> If anyone here knows anything about canonical divisors and their 
> implementation in Sage, please see 
> https://ask.sagemath.org/question/74034/converting-algebraic-geometry-magmas-code-to-sage/.
>  
> The setup:
> >> >>
> >> >> sage: P2. = ProjectiveSpace(QQ, 2)
> >> >> sage: f = 2*x^5 - 4*x^3*y*z + x^2*y*z^2 + 2*x*y^3*z + 2*x*y^2*z^2+ 
> y^5
> >> >> sage: C = P2.curve(f)
> >> >>
> >> >> How do you get the canonical divisor for C?
> >> >>
> >> >> (I encourage you to post answers directly to ask.sagemath.org, if 
> you're willing.)
> >> >>
> >> >> --
> >> >> John
> >> >>
> >> > --
> >> > You received this message because you are subscribed to the Google 
> Groups "sage-support" group.
> >> > To unsubscribe from this group and stop receiving emails from it, 
> send an email to sage-support...@googlegroups.com.
> >> > To view this 

[sage-support] ideal intersection in ZZ

2023-10-28 Thread G. M.-S.
I wonder why SageMath cannot compute the intersection of 2 ideals in ZZ.

Is this due to the fact that ZZ would "only" be a PID?

Guillermo

┌┐

│ SageMath version 10.1, Release Date: 2023-08-20│

│ Using Python 3.11.1. Type "help()" for help.   │

└┘

sage: n1,n2=720,756

sage: d,m=gcd(n1,n2),lcm(n1,n2)

sage: n1,n2,d,m

(720, 756, 36, 15120)

sage: I1,I2=ZZ.ideal(n1),ZZ.ideal(n2)

sage: I1,I2

(Principal ideal (720) of Integer Ring, Principal ideal (756) of Integer
Ring)

sage: I1+I2

Principal ideal (36) of Integer Ring

sage: I1.intersection(I2)

---

AttributeErrorTraceback (most recent call last)

Cell In [7], line 1

> 1 I1.intersection(I2)


File
/private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:488,
in sage.structure.element.Element.__getattr__
(build/cythonized/sage/structure/element.c:4846)()

*486* AttributeError:
'LeftZeroSemigroup_with_category.element_class' object has no attribute
'blah_blah'

*487* """

--> 488 return self.getattr_from_category(name)

*489*

*490* cdef getattr_from_category(self, name):


File
/private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:501,
in sage.structure.element.Element.getattr_from_category
(build/cythonized/sage/structure/element.c:4958)()

*499* else:

*500* cls = P._abstract_element_class

--> 501 return getattr_from_other_class(self, cls, name)

*502*

*503* def __dir__(self):


File
/private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/cpython/getattr.pyx:362,
in sage.cpython.getattr.getattr_from_other_class
(build/cythonized/sage/cpython/getattr.c:2773)()

*360* dummy_error_message.cls = type(self)

*361* dummy_error_message.name = name

--> 362 raise AttributeError(dummy_error_message)

*363* attribute = attr

*364* # Check for a descriptor (__get__ in Python)


AttributeError: 'Ideal_pid' object has no attribute 'intersection'

sage:

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CANnG18_BEyzLdcmikDNi8j9%3D%2BYHQLVdpMgaTw6UtWkg%3DoJCUAw%40mail.gmail.com.