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

pretty printing for quotients, graded and localized multivariate polynomial rings #2184

Merged
merged 7 commits into from
May 27, 2023

Conversation

simonbrandhorst
Copy link
Collaborator

This pr should probably wait until the changes from nemo and abstract algebra propagate.

@codecov
Copy link

codecov bot commented Apr 1, 2023

Codecov Report

Merging #2184 (31192c1) into master (d34b118) will decrease coverage by 71.94%.
The diff coverage is 0.00%.

❗ Current head 31192c1 differs from pull request most recent head 3f21812. Consider uploading reports for the commit 3f21812 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #2184       +/-   ##
==========================================
- Coverage   71.93%   0.00%   -71.94%     
==========================================
  Files         391     347       -44     
  Lines       52657   48392     -4265     
==========================================
- Hits        37879       0    -37879     
- Misses      14778   48392    +33614     
Impacted Files Coverage Δ
src/Rings/MPolyQuo.jl 0.00% <0.00%> (-77.11%) ⬇️
src/Rings/mpoly-graded.jl 0.00% <0.00%> (-82.00%) ⬇️

... and 423 files with indirect coverage changes

Comment on lines 40 to 42
println(io, "Quotient")
println(io, " of ", base_ring(Q))
print(io, " by Ideal with " , ngens(modulus(Q)), "generators")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key information of the quotient ring is the base_ring and the modulus.

I agree that in standard view only the number of generators is printed, but there should be an even more detailed view available, which prints the modulus (and not in supercompact printing of an ideal). Think of a user having defined several quotients of the same base_ring and trying to pick the right one for the next computation.

Copy link
Collaborator Author

@simonbrandhorst simonbrandhorst Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more information on the modulus is probably desirable in standard view.
There will be no more detailed view than standard view. In this case you have to ask the quotient ring for the information that you desire.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this also solves the dilemma of how much information is necessary.

Comment on lines 395 to 413
function Base.show(io::IO, W::AbsLocalizedRing)
io = pretty(io)
if get(io, :supercompact, false)
print(io, "Localized ring")
else
print(io, "Localization of ", Lowercase(), base_ring(W))
print(pretty(IOContext(io, :supercompact =>true)), " at ", Lowercase(), inverted_set(W))
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thofma this is it.

@simonbrandhorst simonbrandhorst marked this pull request as ready for review May 25, 2023 20:12
Copy link
Collaborator

@thofma thofma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A part from a few things, looks good from a technical point of view.

src/Rings/mpolyquo-localizations.jl Show resolved Hide resolved
src/Rings/localization_interface.jl Outdated Show resolved Hide resolved
src/Rings/mpoly-localizations.jl Show resolved Hide resolved
src/Rings/mpoly-localizations.jl Outdated Show resolved Hide resolved
@simonbrandhorst simonbrandhorst changed the title pretting printing for quotients and graded multivariate polynomial rings pretty printing for quotients and graded multivariate polynomial rings May 26, 2023
@simonbrandhorst simonbrandhorst changed the title pretty printing for quotients and graded multivariate polynomial rings pretty printing for quotients, graded and localized multivariate polynomial rings May 26, 2023
Copy link
Collaborator

@afkafkafk13 afkafkafk13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through all the output and wrote at least one comment for each of the small nitpicks I have. Overall there are the following central points:

  • better pretty printing mult. set inverting powers of elements
  • something changed in try - catch doctests -- is this intentional
  • some supercompact suggestions

x -> [1]
y -> [2]
z -> [3], MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}[x, y, z])
(Graded multivariate polynomial ring in 3 variables over QQ, MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}[x, y, z])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nitpick: printing of the variables still needs improvement

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how?

Copy link
Collaborator

@afkafkafk13 afkafkafk13 May 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'... over QQ, variables [x,y,z]'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we print here is a tuple (Ring, Vector{Variables}) because the constructor also returns the variables.
Arrays always print their type. Since we do not own arrays (they come from Base), we cannot change this.
And it might not be a good idea even if we could.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.
What struck me, was the enormous disbalance between the amount of detail printed for the first entry (nice and suitable for mathematicians) and the second entry (which easily takes more than a line before even opening the square bracket, if you are dealing with a graded ring over an algebraic extension of QQ).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something very similar has been discussed in #2064, although without a result.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For (multivarite) rings a solution would be to return the generators as a tuple and not as an array. The tuple does not print its type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.... but this is not type stable, so we are back to arrays.

docs/src/CommutativeAlgebra/localizations.md Outdated Show resolved Hide resolved
@@ -404,11 +404,11 @@ Spec of Multivariate polynomial ring in 3 variables over QQ

=====================================
Affine charts of the blown up scheme:
Spec of Localization of Quotient of Multivariate polynomial ring in 3 variables over QQ by ideal(0, 0, 0) at the multiplicative set powers of QQMPolyRingElem[1]
Spec of Localization of quotient of multivariate polynomial ring at multiplicative subset
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to be a bit more precise with the multiplicative set here, if this is not compact/supercompact: '... ring by inverting powers of an element' and suppress the multiplicative set completely in more compact printing. If we localize, we do it at a mult. closed subset, so the current information is redundant.

@@ -39,7 +39,7 @@ julia> I = ideal(R, [x]);
julia> U = complement_of_prime_ideal(I);

julia> Spec(R, U)
Spec of localization of Multivariate polynomial ring in 2 variables over QQ at the complement of ideal(x)
Spec of Localization of multivariate polynomial ring in 2 variables over QQ at Complement of prime ideal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really want this in capital letters? (Localization, Complement)

x -> [1]
y -> [1]
z -> [1], MPolyDecRingElem{MPolyQuoRingElem{QQMPolyRingElem}, AbstractAlgebra.Generic.MPoly{MPolyQuoRingElem{QQMPolyRingElem}}}[x, y, z])
(Graded multivariate polynomial ring in 3 variables over Quotient of multivariate polynomial ring, MPolyDecRingElem{MPolyQuoRingElem{QQMPolyRingElem}, AbstractAlgebra.Generic.MPoly{MPolyQuoRingElem{QQMPolyRingElem}}}[x, y, z])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nitpick: second and third argument still need pretty printing.

@@ -1306,7 +1306,7 @@ julia> I = left_ideal(A, [p, q])
left_ideal(p, q)

julia> try eliminate(I, [q]); catch e; e; end # in fact, no elimination ordering exists
ErrorException("could not find elimination ordering")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above.

src/Rings/localization_interface.jl Outdated Show resolved Hide resolved
src/Rings/localization_interface.jl Show resolved Hide resolved
src/Rings/mpoly-localizations.jl Outdated Show resolved Hide resolved
print(io, "powers of ")
print(io, denominators(S))
io = pretty(io)
if get(io, :supercompact, false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In supercompact, either print nothing at all or something stating that we are dealing with powers/products of elements.
The 'multiplicative set' should be left for multiple localizations, where we see more general multiplicative sets (unless we simplify them, which is not even on our agenda...)

Comment on lines 2678 to 2681
julia> PSI = hom(TL, RQL, RQL.([x]))
Ring homomorphism
from localization of multivariate polynomial ring in 1 variable over QQ at complement of maximal ideal
to Localization of quotient of multivariate polynomial ring at complement of maximal ideal
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thofma the Localization should be lowercase ?

Comment on lines 2786 to 2787
from Localization of quotient of multivariate polynomial ring at complement of maximal ideal
to localization of multivariate polynomial ring in 1 variable over QQ at complement of maximal ideal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for MPolyQuo the localizations start with a capital letter, for MPolyRing with a lowercase letter. Probably there is still a typo in the MPolyQuo-case somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is still something fishy in our printing system. @thofma is investigating

Copy link
Collaborator

@afkafkafk13 afkafkafk13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
Remember to change the respective testset in mpoly-localizations.jl to agree with the new output format.

@simonbrandhorst
Copy link
Collaborator Author

Looks good to me. Remember to change the respective testset in mpoly-localizations.jl to agree with the new output format.

I removed these old tests and added some doctests instead.

Copy link
Collaborator

@afkafkafk13 afkafkafk13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this is a clear approval.

Sideremark: Finding and solving the 'something fishy' in the printing system is related to this PR, but not part of the changes.

@thofma thofma enabled auto-merge (squash) May 27, 2023 06:20
@thofma thofma merged commit 04820d1 into oscar-system:master May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants