Add Puiseux polynomials#2391
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
|
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 |
| ################################################################################# | ||
| # | ||
| # 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 |
There was a problem hiding this comment.
| ################################################################################# | |
| # | |
| # 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) |
There was a problem hiding this comment.
this file contains multiple references to Oscar which won't work here
| @testset "TrivialTests" begin | ||
| @test 1+1==2 | ||
| @test 1+2==3 | ||
| # @test 1+1==3 # this one fails | ||
| end | ||
|
|
There was a problem hiding this comment.
| @testset "TrivialTests" begin | |
| @test 1+1==2 | |
| @test 1+2==3 | |
| # @test 1+1==3 # this one fails | |
| end |
|
@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. |
Working repository for adding Puiseux Polynomials to AA, this should supersede oscar-system/Oscar.jl#5861