Skip to content

Add Puiseux polynomials#2391

Draft
ollieclarke8787 wants to merge 5 commits intoNemocas:masterfrom
ollieclarke8787:oc/PuiseuxPolynomialsFromLaurent
Draft

Add Puiseux polynomials#2391
ollieclarke8787 wants to merge 5 commits intoNemocas:masterfrom
ollieclarke8787:oc/PuiseuxPolynomialsFromLaurent

Conversation

@ollieclarke8787
Copy link
Copy Markdown

@ollieclarke8787 ollieclarke8787 commented Apr 9, 2026

Working repository for adding Puiseux Polynomials to AA, this should supersede oscar-system/Oscar.jl#5861

@joschmitt joschmitt added enhancement New feature or request release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes labels Apr 9, 2026
@joschmitt joschmitt changed the title Add Puiseux polynomials package Add Puiseux polynomials Apr 9, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 0% with 198 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.59%. Comparing base (3355a14) to head (d6e032a).

Files with missing lines Patch % Lines
src/PuiseuxMPoly.jl 0.00% 198 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2391      +/-   ##
==========================================
- Coverage   88.12%   87.59%   -0.53%     
==========================================
  Files         128      129       +1     
  Lines       32886    33084     +198     
==========================================
  Hits        28981    28981              
- Misses       3905     4103     +198     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joschmitt
Copy link
Copy Markdown
Collaborator

The test file needs to be included explicitly to be executed (there is no magic like in OSCAR). I assume it could fit in the list of includes in test/Rings-test.jl.

Comment thread src/PuiseuxMPoly.jl
Comment on lines +453 to +525
#################################################################################
#
# tropical semiring maps for puiseux polynomials
#
#################################################################################


@doc raw"""
tropical_semiring_map(K::Field, minOrMax::Union{typeof(min),typeof(max)}=min)

Return a map `nu` from `K` to the min (default) or max tropical semiring `T` such that `nu(0)=zero(T)` and `nu(c)=one(T)` for `c` non-zero. In other words, `nu` extends the trivial valuation on `K`.

# Examples
```jldoctest
julia> nu = tropical_semiring_map(QQ) # arbitrary rings possible
Map into Min tropical semiring encoding the trivial valuation on Rational field

julia> nu(1)
(0)

julia> nu(0)
infty

julia> nu = tropical_semiring_map(QQ,max) # arbitrary rings possible
Map into Max tropical semiring encoding the trivial valuation on Rational field

julia> nu(1)
(0)

julia> nu(0)
-infty

```
"""
function tropical_semiring_map(R::PuiseuxMPolyRing, t::PuiseuxMPolyRingElem, minOrMax::Union{typeof(min),typeof(max)}=min)
@assert ngens(R) == 1 "The tropical_semiring_map is only implemented for Puiseux polynomial rings in one variable."
@assert t == first(gens(R)) "The uniformizer must be the generator of the Puiseux polynomial ring."

valuedField = nothing
uniformizerField = nothing
valuedRing = R
uniformizerRing = t
residueField = base_ring(R)
tropicalSemiring = tropical_semiring(minOrMax)
return TropicalSemiringMap{typeof(R),typeof(t),typeof(minOrMax)}(
valuedField,
uniformizerField,
valuedRing,
uniformizerRing,
residueField,
tropicalSemiring)
end

# Print string
function Base.show(io::IO, nu::TropicalSemiringMap{<:PuiseuxMPolyRing,<:PuiseuxMPolyRingElem,MinOrMax}) where {MinOrMax<:Union{typeof(min),typeof(max)}}
print(io, "Map into $(tropical_semiring(nu)) encoding the $(uniformizer(nu))-adic valuation on $(Oscar.valued_ring(nu))")
end

# Mapping an element of the valued field or ring to the tropical semiring
function (nu::TropicalSemiringMap{<:PuiseuxMPolyRing,<:PuiseuxMPolyRingElem,MinOrMax})(c::PuiseuxMPolyRingElem) where MinOrMax<:Union{typeof(min),typeof(max)}
# return tropical zero if c is zero and valuation otherwise
iszero(c) && return zero(tropical_semiring(nu))
# preserve_ordering ensures that valuation is negated if convention(nu)==max
return tropical_semiring(nu)(valuation(c); preserve_ordering=true)
end

# Mapping an element of the valued field or ring to the residue field
function initial(c::PuiseuxMPolyRingElem, nu::TropicalSemiringMap{<:PuiseuxMPolyRing,<:PuiseuxMPolyRingElem,MinOrMax}) where MinOrMax<:Union{typeof(min),typeof(max)}
# return residue field zero if c is zero and the correct non-zero residue otherwise
iszero(c) && return zero(residue_field(nu))
C = collect(coefficients(c))
return last(C)
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
#################################################################################
#
# tropical semiring maps for puiseux polynomials
#
#################################################################################
@doc raw"""
tropical_semiring_map(K::Field, minOrMax::Union{typeof(min),typeof(max)}=min)
Return a map `nu` from `K` to the min (default) or max tropical semiring `T` such that `nu(0)=zero(T)` and `nu(c)=one(T)` for `c` non-zero. In other words, `nu` extends the trivial valuation on `K`.
# Examples
```jldoctest
julia> nu = tropical_semiring_map(QQ) # arbitrary rings possible
Map into Min tropical semiring encoding the trivial valuation on Rational field
julia> nu(1)
(0)
julia> nu(0)
infty
julia> nu = tropical_semiring_map(QQ,max) # arbitrary rings possible
Map into Max tropical semiring encoding the trivial valuation on Rational field
julia> nu(1)
(0)
julia> nu(0)
-infty
```
"""
function tropical_semiring_map(R::PuiseuxMPolyRing, t::PuiseuxMPolyRingElem, minOrMax::Union{typeof(min),typeof(max)}=min)
@assert ngens(R) == 1 "The tropical_semiring_map is only implemented for Puiseux polynomial rings in one variable."
@assert t == first(gens(R)) "The uniformizer must be the generator of the Puiseux polynomial ring."
valuedField = nothing
uniformizerField = nothing
valuedRing = R
uniformizerRing = t
residueField = base_ring(R)
tropicalSemiring = tropical_semiring(minOrMax)
return TropicalSemiringMap{typeof(R),typeof(t),typeof(minOrMax)}(
valuedField,
uniformizerField,
valuedRing,
uniformizerRing,
residueField,
tropicalSemiring)
end
# Print string
function Base.show(io::IO, nu::TropicalSemiringMap{<:PuiseuxMPolyRing,<:PuiseuxMPolyRingElem,MinOrMax}) where {MinOrMax<:Union{typeof(min),typeof(max)}}
print(io, "Map into $(tropical_semiring(nu)) encoding the $(uniformizer(nu))-adic valuation on $(Oscar.valued_ring(nu))")
end
# Mapping an element of the valued field or ring to the tropical semiring
function (nu::TropicalSemiringMap{<:PuiseuxMPolyRing,<:PuiseuxMPolyRingElem,MinOrMax})(c::PuiseuxMPolyRingElem) where MinOrMax<:Union{typeof(min),typeof(max)}
# return tropical zero if c is zero and valuation otherwise
iszero(c) && return zero(tropical_semiring(nu))
# preserve_ordering ensures that valuation is negated if convention(nu)==max
return tropical_semiring(nu)(valuation(c); preserve_ordering=true)
end
# Mapping an element of the valued field or ring to the residue field
function initial(c::PuiseuxMPolyRingElem, nu::TropicalSemiringMap{<:PuiseuxMPolyRing,<:PuiseuxMPolyRingElem,MinOrMax}) where MinOrMax<:Union{typeof(min),typeof(max)}
# return residue field zero if c is zero and the correct non-zero residue otherwise
iszero(c) && return zero(residue_field(nu))
C = collect(coefficients(c))
return last(C)
end

this part belongs into Oscar

K, (t1,t2,t3) = laurent_polynomial_ring(QQ, ["t1","t2","t3"])
K_p,(tp1,tp2,tp3) = puiseux_polynomial_ring(QQ, ["t1","t2","t3"])
@test K_p.baseRing == K
@test K_p == Oscar.PuiseuxMPolyRing(K)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this file contains multiple references to Oscar which won't work here

Comment on lines +5 to +10
@testset "TrivialTests" begin
@test 1+1==2
@test 1+2==3
# @test 1+1==3 # this one fails
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
@testset "TrivialTests" begin
@test 1+1==2
@test 1+2==3
# @test 1+1==3 # this one fails
end

@YueRen
Copy link
Copy Markdown
Contributor

YueRen commented Apr 10, 2026

@lgoettgens Good point, I suggest we remove these for now and once this PR is merged and a new release of AA has happened, I will open a PR in OSCAR.

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

Labels

enhancement New feature or request release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants