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

Reduce elements of QuotientRing modulo ideal #691

Closed
asbuch opened this issue Aug 4, 2023 · 11 comments · Fixed by #703
Closed

Reduce elements of QuotientRing modulo ideal #691

asbuch opened this issue Aug 4, 2023 · 11 comments · Fixed by #703
Labels

Comments

@asbuch
Copy link

asbuch commented Aug 4, 2023

Describe the bug
Elements of a QuotientRing are not reduced modulo the ideal defining the quotient.

To Reproduce
Steps to reproduce the behavior:

using Singular
R, (x,y) = polynomial_ring(QQ, ["x", "y"]);
Q, (a,b) = QuotientRing(R, Ideal(R, x-y));
a-b  # Returns x-y. Expected zero.

Expected behavior
Expected result: 0

Information about your setup:
julia> versioninfo()
Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: 13th Gen Intel(R) Core(TM) i5-1345U
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, goldmont)

julia> using Pkg; Pkg.status(mode=PKGMODE_MANIFEST)
Status /tmp/singbug/Manifest.toml
[c3fe647b] AbstractAlgebra v0.31.0
[f01c122e] BinaryWrappers v0.1.2
[1f15a43c] CxxWrap v0.13.4
[d5909c97] GroupsCore v0.4.0
[692b3bcd] JLLWrappers v1.4.1
[1914dd2f] MacroTools v0.5.10
[2edaba10] Nemo v0.35.3
[fa939f87] Pidfile v1.3.0
[21216c6a] Preferences v1.4.0
[fb686558] RandomExtensions v0.4.3
[6c6a2e73] Scratch v1.2.0
[bcd08a7b] Singular v0.18.9
[e21ec000] Antic_jll v0.201.500+0
[d9960996] Arb_jll v200.2300.0+0
[fcfa6d1b] Calcium_jll v0.401.100+0
[e134572f] FLINT_jll v200.900.7+0
[e8aa6df9] GLPK_jll v5.0.1+0
[656ef2d0] OpenBLAS32_jll v0.3.17+0
[43d676ae] Singular_jll v403.203.202+0
[f07e07eb] cddlib_jll v0.94.13+0
[1493ae25] lib4ti2_jll v1.6.10+0
[3eaa8342] libcxxwrap_julia_jll v0.9.7+3
[ae4fbd8f] libsingular_julia_jll v0.36.0+0
[0dad84c5] ArgTools
[56f22d72] Artifacts
[2a0f44e3] Base64
[ade2ca70] Dates
[f43a241f] Downloads
[7b1f6079] FileWatching
[b77e0a4c] InteractiveUtils
[b27032c2] LibCURL
[76f85450] LibGit2
[8f399da3] Libdl
[37e2e46d] LinearAlgebra
[56ddb016] Logging
[d6f4376e] Markdown
[ca575930] NetworkOptions
[44cfe95a] Pkg
[de0858da] Printf
[3fa0cd96] REPL
[9a3f8284] Random
[ea8e919c] SHA
[9e88b42a] Serialization
[6462fe0b] Sockets
[2f01184e] SparseArrays
[10745b16] Statistics
[fa267f1f] TOML
[a4e569a6] Tar
[8dfed614] Test
[cf7118a7] UUIDs
[4ec0a83e] Unicode
[e66e0078] CompilerSupportLibraries_jll
[781609d7] GMP_jll
[deac9b47] LibCURL_jll
[29816b5a] LibSSH2_jll
[3a97d323] MPFR_jll
[c8ffd9c3] MbedTLS_jll
[14a3606d] MozillaCACerts_jll
[4536629a] OpenBLAS_jll
[83775a58] Zlib_jll
[8e850b90] libblastrampoline_jll
[8e850ede] nghttp2_jll
[3f19e933] p7zip_jll

Additional context
In case QuotientRing works as intended, then I suggest explaining this in the documentation here:
https://oscar-system.github.io/Singular.jl/dev/qring/

@asbuch asbuch added the bug label Aug 4, 2023
@fingolfin
Copy link
Member

In general I would not expect a-b to print as zero, because doing so requires a normal form computation, which is expensive and normally only computed when necessary.

However, in this example also iszero(a-b) returns false, which it shouldn't.

That said, I think this is a matter of things just not being implemented in the non-associative case, as your other issue also shows. Singular really is focused on commutative algebra, and some special cases of non-commutative algebras. The support for free algebras is limited, and I don't think anyone is currently working on providing more of the Singular functionality in Singular.jl right now (patches would be welcome, but it just isn't a focus for us right now)

@asbuch
Copy link
Author

asbuch commented Aug 16, 2023

Thanks for the update about priorities, fair enough.

Regarding desired behavior, I think elements in a QuotientRing ought to be reduced automatically. If this is too slow for an application, then one can work with element in the base ring. If elements of a quotient ring are not reduced, then what is the point of having those elements?

@thofma
Copy link
Collaborator

thofma commented Aug 17, 2023

The observed behaviour is what Singular is doing, see https://www.singular.uni-kl.de/Manual/4-0-3/sing_165.htm#SEC204. Since this here is just a wrapper around Singular and purposefully does not change the behaviour, I think there is nothing to do.

@fingolfin
Copy link
Member

If you need such functionality, please check out Oscar.jl

@asbuch
Copy link
Author

asbuch commented Aug 17, 2023

If you need such functionality, please check out Oscar.jl

Thanks, this is helpful! Although I am trying to use FreeAlgebra, which doesn't seem to have an interface in Oscar.jl yet?

Also, I think that Oscar's projection map to a quotient ring ought to reduce modulo the ideal?

Example:

using Oscar
R, (x, y) = polynomial_ring(QQ, ["x", "y"])
S, pi = quo(R, ideal(R, [x-y]))
pi(x)        # returns x, expected y
1*pi(x)      # returns y

@thofma
Copy link
Collaborator

thofma commented Aug 17, 2023

Yes, it does not "reduce" because reduction is not well-defined (in general). The elements of the quotient ring behave like elements of the quotient ring. But they are represented by a representative, which is in general not unique. I do not consider this a bug, but a choice made in the implementation.

P.S.: Hm, it might appear a bit arbitrary when something is "reduced", I agree.

Do you have an example where there is a wrong result with a computation involving quotient rings?

@wdecker
Copy link
Collaborator

wdecker commented Aug 17, 2023 via email

@fingolfin
Copy link
Member

So it seems that iszero, and == etc. are implemented the same for polynomials and elements of the quotient ring; indeed these have the same type:

julia> typeof(a)
spoly{n_Q}

julia> typeof(x)
spoly{n_Q}

But the code for iszero does not check in which case we are:

function iszero(p::SPolyUnion)
   GC.@preserve p p.ptr.cpp_object == C_NULL
end

So to fix this we need to do one of these:

  1. disallow these operations (throw an error)
  2. implement them
  3. ... ?

@fingolfin
Copy link
Member

@hannes14 said he'll look into it ;-)

@fingolfin
Copy link
Member

@thofma regarding "Do you have an example where there is a wrong result with a computation involving quotient rings?" I would consider iszero(a-b) and a == b returning false in the example as a bug, don't you?

@thofma
Copy link
Collaborator

thofma commented Aug 24, 2023

This is expected, since it is exactly what Singular is doing, see the link to the Singular documentation.

PS: My comment was more about the Oscar example, that was mentioned right before. But my statement about this not being a bug but Singular behaviour still stands.

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

Successfully merging a pull request may close this issue.

4 participants