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
339 stars 120 forks source link

fraction in quotient ring #264

Closed delphinepol closed 1 year ago

delphinepol commented 3 years ago

I don't manage to define a fraction in a quotient ring, it is looking for a gcd which does not exist, and would anyway probably not make sense for general quotient rings. Is there a way to not require the fractions to be reduced, to avoid this problem ?

julia> R, (x,y) = PolynomialRing(QQ, ["x", "y"])
(Multivariate Polynomial Ring in x, y over Rational Field, fmpq_mpoly[x, y])

julia> I = ideal(R, [x^2+y+y^2])
ideal generated by: x^2 + y^2 + y

julia> Q = quo(R, I)
(Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal generated by: x^2 + y^2 + y, Map from
Multivariate Polynomial Ring in x, y over Rational Field to Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal generated by: x^2 + y^2 + y defined by a julia-function with inverse
)

julia> K = FractionField(Q[1])
Fraction field of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal generated by: x^2 + y^2 + y

julia> K(Q[1](x)//Q[1](y))
ERROR: MethodError: no method matching gcd(::Oscar.MPolyQuoElem{fmpq_mpoly}, ::Oscar.MPolyQuoElem{fmpq_mpoly})
Stacktrace:
 [1] //(::Oscar.MPolyQuoElem{fmpq_mpoly}, ::Oscar.MPolyQuoElem{fmpq_mpoly}) at /home/pol/.julia/packages/AbstractAlgebra/aF5Iw/src/generic/Fraction.jl:72
 [2] top-level scope at REPL[6]:1

julia> K(Q[1](x))//K(Q[1](y))
ERROR: MethodError: no method matching gcd(::Oscar.MPolyQuoElem{fmpq_mpoly}, ::Oscar.MPolyQuoElem{fmpq_mpoly})
Stacktrace:
 [1] divexact(::AbstractAlgebra.Generic.Frac{Oscar.MPolyQuoElem{fmpq_mpoly}}, ::AbstractAlgebra.Generic.Frac{Oscar.MPolyQuoElem{fmpq_mpoly}}) at /home/pol/.julia/packages/AbstractAlgebra/aF5Iw/src/generic/Fraction.jl:650
 [2] //(::AbstractAlgebra.Generic.Frac{Oscar.MPolyQuoElem{fmpq_mpoly}}, ::AbstractAlgebra.Generic.Frac{Oscar.MPolyQuoElem{fmpq_mpoly}}) at /home/pol/.julia/packages/AbstractAlgebra/aF5Iw/src/Fields.jl:11
 [3] top-level scope at REPL[7]:1
thofma commented 3 years ago

The answer is unfortunately no. The fraction field construction that is currently implemented assumes that the ring is a GCD domain and there is no way to disable it. Not sure what the way forward is here.

delphinepol commented 3 years ago

OK, then I will see how to avoid it in my code for the divisors.

fieker commented 3 years ago

On Thu, Feb 04, 2021 at 06:41:01AM -0800, delphinepol wrote:

I don't manage to define a fraction in a quotient ring, it is looking for a gcd which does not exist, and would anyway probably not make sense for general quotient rings. Is there a way to not require the fractions to be reduced, to avoid this problem ?

What exactly are you trying to do? in Q, defined your way, we have division and inversion (at least in the current dev), so the generic fractions should not be neccessary at all

julia> R, (x,y) = PolynomialRing(QQ, ["x", "y"])
(Multivariate Polynomial Ring in x, y over Rational Field, fmpq_mpoly[x, y])

julia> I = ideal(R, [x^2+y+y^2])
ideal generated by: x^2 + y^2 + y

julia> Q = quo(R, I)
(Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal generated by: x^2 + y^2 + y, Map from
Multivariate Polynomial Ring in x, y over Rational Field to Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal generated by: x^2 + y^2 + y defined by a julia-function with inverse
)

julia> K = FractionField(Q[1])
Fraction field of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal generated by: x^2 + y^2 + y

julia> K(Q[1](x)//Q[1](y))
ERROR: MethodError: no method matching gcd(::Oscar.MPolyQuoElem{fmpq_mpoly}, ::Oscar.MPolyQuoElem{fmpq_mpoly})
Stacktrace:
 [1] //(::Oscar.MPolyQuoElem{fmpq_mpoly}, ::Oscar.MPolyQuoElem{fmpq_mpoly}) at /home/pol/.julia/packages/AbstractAlgebra/aF5Iw/src/generic/Fraction.jl:72
 [2] top-level scope at REPL[6]:1

julia> K(Q[1](x))//K(Q[1](y))
ERROR: MethodError: no method matching gcd(::Oscar.MPolyQuoElem{fmpq_mpoly}, ::Oscar.MPolyQuoElem{fmpq_mpoly})
Stacktrace:
 [1] divexact(::AbstractAlgebra.Generic.Frac{Oscar.MPolyQuoElem{fmpq_mpoly}}, ::AbstractAlgebra.Generic.Frac{Oscar.MPolyQuoElem{fmpq_mpoly}}) at /home/pol/.julia/packages/AbstractAlgebra/aF5Iw/src/generic/Fraction.jl:650
 [2] //(::AbstractAlgebra.Generic.Frac{Oscar.MPolyQuoElem{fmpq_mpoly}}, ::AbstractAlgebra.Generic.Frac{Oscar.MPolyQuoElem{fmpq_mpoly}}) at /home/pol/.julia/packages/AbstractAlgebra/aF5Iw/src/Fields.jl:11
 [3] top-level scope at REPL[7]:1

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/oscar-system/Oscar.jl/issues/264

delphinepol commented 3 years ago

I wanted to define the divisor associated to an element of the fraction field of the coordinate ring of the curve.

fieker commented 3 years ago

My point is that there are other ways to get the field, the quo ring should be good enough

On Thu, 4 Feb 2021, 17:34 delphinepol, notifications@github.com wrote:

I wanted to define the divisor associated to an element of the fraction field of the coordinate ring of the curve.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/oscar-system/Oscar.jl/issues/264#issuecomment-773440378, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA36CV7VEYBMCIMFR6WTGZ3S5LEDFANCNFSM4XC6GRHA .

delphinepol commented 3 years ago

What do you mean exactly ? In which sense should the quo ring should be enough ?

fieker commented 3 years ago

On Fri, Feb 05, 2021 at 12:31:40AM -0800, delphinepol wrote:

What do you mean exactly ? In which sense should the quo ring should be enough ?

Sorry - probably not. However, Q(x)[y]/f would be a model for your fractions? -- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/oscar-system/Oscar.jl/issues/264#issuecomment-773880152

delphinepol commented 3 years ago

It would indeed be a model for the fractions for the affine plane curve. I would need to think if it would work for the projective plane curves... For the moment I might keep the fractions in the ambient space to keep it simple, passing as an argument for the function the curve and the fraction.

fieker commented 3 years ago

On Fri, Feb 05, 2021 at 01:22:53AM -0800, delphinepol wrote:

It would indeed be a model for the fractions for the affine plane curve. I would need to think if it would work for the projective plane curves... For the moment I might keep the fractions in the ambient space to keep it simple, passing as an argument for the function the curve and the fraction.

I'd guess that this is isomorphic to the FractionField that cannot be computed? If no, then what element is missing? -- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/oscar-system/Oscar.jl/issues/264#issuecomment-773907161

delphinepol commented 3 years ago

Yes, from the mathematical point of vue it's isomorphic, but it is making it more complicated to use for the moment, I would need to think about it and play around a little to see.

tthsqe12 commented 3 years ago

Haha. I just recently ran into this issue in AA. Math is hard. The main prom is that AA's fraction field requires a gcd, while the abstract definition of a fraction field does not. The theoretical obstacle is that the ring F[x,y,z...]/ideal may not be a gcd domain and may not even be a domain. We could make the gcd here always return 1 or 0 to make AA happy, but this not useful and very questionable mathematically. Thus constructing the function field of a variety via the fraction field of a quotient ring is a dead end. It needs a more dedicated implimentation.

simonbrandhorst commented 3 years ago

I think half a year ago I ran into similar problems trying to compute in the function field of a variety.

HechtiDerLachs commented 3 years ago

We might soon need such functionalities in our Schemes project for the same reasons.

Mathematically it would make sense to introduce fraction fields for integral domains S = R/I where R is a free polynomial ring and I is a prime ideal. In that case one should be able to replace the functionality provided by the use of gcd by groebner basis methods. In the end, the main point should be to achieve computationally feasible cancellation. And that must be possible to implement.

For the case where I is not necessarily prime, one could even think of implementing the total ring of fractions: https://en.wikipedia.org/wiki/Total_ring_of_fractions again using Groebner basis.

fingolfin commented 1 year ago

The error is a bit different now:

julia> K(Q[1](x)//Q[1](y))
ERROR: function divrem is not implemented for arguments
MPolyQuoElem{fmpq_mpoly}: x
MPolyQuoElem{fmpq_mpoly}: y

Stacktrace: ...

julia> K(Q[1](x))//K(Q[1](y))
ERROR: function divrem is not implemented for arguments
MPolyQuoElem{fmpq_mpoly}: x
MPolyQuoElem{fmpq_mpoly}: y

Stacktrace: ...
thofma commented 1 year ago

I guess @HechtiDerLachs found a way to work in the function field without doing this construction from OP?

simonbrandhorst commented 1 year ago

One way to get the field of fractions is by localizing at the complement of the zero ideal (in a domain ).

julia> P,(x,y) = PolynomialRing(QQ,["x","y"])
(Multivariate Polynomial Ring in x, y over Rational Field, fmpq_mpoly[x, y])

julia> I = ideal(P,y^2-x^6-x^2-1)
ideal(-x^6 - x^2 + y^2 - 1)

julia> is_prime(I)
true

julia> PmodI,i = quo(P,I);

julia> S = complement_of_ideal(I)
complement of ideal(-x^6 - x^2 + y^2 - 1)

julia> K, j = localization(PmodI, S);

julia> K(x)*inv(K(x))
x//x

julia> K(x)*inv(K(x)) == 1
true

Of course this was never intended to model fraction fields. And Oscar probably doesn't know K is a field.

thofma commented 1 year ago

I see. I remember that we have a total field of fractions, https://nemocas.github.io/AbstractAlgebra.jl/dev/total_fraction/. This should be used. It might do something useful. If not, open an issue.