From 889dce292fec1fa745853b584aa5eee23632d6ec Mon Sep 17 00:00:00 2001 From: ederc Date: Thu, 13 Jun 2024 13:06:41 +0200 Subject: [PATCH 1/4] sets poly ring caching to false for tropical geometry --- src/TropicalGeometry/debug.jl | 12 ++++++------ src/TropicalGeometry/debugTropicalVariety.jl | 16 ++++++++-------- src/TropicalGeometry/groebner_basis.jl | 4 ++-- src/TropicalGeometry/hypersurface.jl | 2 +- src/TropicalGeometry/initial.jl | 2 +- src/TropicalGeometry/semiring_map.jl | 2 +- src/TropicalGeometry/variety.jl | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/TropicalGeometry/debug.jl b/src/TropicalGeometry/debug.jl index 953dfbcdec8c..b3fa1a10d2b9 100644 --- a/src/TropicalGeometry/debug.jl +++ b/src/TropicalGeometry/debug.jl @@ -1,5 +1,5 @@ K = GF(2) -Kx,(x1,x2,x3,x4) = polynomial_ring(K,4); +Kx,(x1,x2,x3,x4) = polynomial_ring(K,4; cached=false); inI = ideal([x2 + x3 + x4, x1 + x3]) println(inI) # same print as input for tropical_link println(base_ring(inI)) # same print as input for tropical_link @@ -13,7 +13,7 @@ singularIdeal = Singular.satstd(singularIdeal,Singular.MaximalIdeal(singularRing inI1 = ideal(Kx,singularIdeal) L,t = rational_function_field(K,"t") -Lx,x = polynomial_ring(L,symbols(Kx)) +Lx,x = polynomial_ring(L,symbols(Kx); cached=false) inI1 = ideal(Lx,[change_base_ring(L,g) for g in gens(inI1)]) hyperplanes = [x[i]-t for i in [2,3,4]] @@ -37,7 +37,7 @@ end -Kx,(x1,x2,x3,x4) = polynomial_ring(QQ,4); +Kx,(x1,x2,x3,x4) = polynomial_ring(QQ,4; cached=false); p = 2; I = ideal([x1-p*x2+(p+1)*x3,3*x2-p^2*x3+(p^2+1)*x4]); w = Int[-1, 1, -1, 1] @@ -49,7 +49,7 @@ w = Int[-1, 1, -1, 1] # Step 1.1: running simulate_valuation G = gens(I) -Rtx,tx = polynomial_ring(ZZ,vcat([:t],symbols(parent(G[1])))) +Rtx,tx = polynomial_ring(ZZ,vcat([:t],symbols(parent(G[1]))); cached=false) vvG = [p-tx[1]] for f in G fRtx = MPolyBuildCtx(Rtx) @@ -75,7 +75,7 @@ x = copy(symbols(Rx)) popfirst!(x) K = QQ -Kx,_ = polynomial_ring(K,x) +Kx,_ = polynomial_ring(K,x; cached=false) GB = [] for i = 2:3 @@ -94,6 +94,6 @@ end # Step 2: construct initial ideal from the tropical groebner basis ### f = GB[1] -kx, x = polynomial_ring(GF(2),[repr(x) for x in gens(parent(f))]) +kx, x = polynomial_ring(GF(2),[repr(x) for x in gens(parent(f))]; cached=false) initialf = MPolyBuildCtx(kx) diff --git a/src/TropicalGeometry/debugTropicalVariety.jl b/src/TropicalGeometry/debugTropicalVariety.jl index 5b087ca14189..87ba6ad807cf 100644 --- a/src/TropicalGeometry/debugTropicalVariety.jl +++ b/src/TropicalGeometry/debugTropicalVariety.jl @@ -3,7 +3,7 @@ ### import Random K,s = rational_function_field(QQ,"s"); -Kx,(x1,x2,x3,x4) = polynomial_ring(K,4); +Kx,(x1,x2,x3,x4) = polynomial_ring(K,4; cached=false); I = ideal([x1-s*x2+(s+1)*x3,3*x2-s^2*x3+(s^2+1)*x4]); val = TropicalSemiringMap(K,s,min); Random.seed!(3847598273423); TropI = tropical_variety(I,val) # works val = TropicalSemiringMap(K,s,max); Random.seed!(3847598273423); TropI = tropical_variety(I,val) # does not work @@ -14,7 +14,7 @@ val = TropicalSemiringMap(K,s,max); Random.seed!(3847598273423); TropI = tropica # Linear example /QQ_p ### import Random -Kx,(x1,x2,x3,x4) = polynomial_ring(QQ,4); +Kx,(x1,x2,x3,x4) = polynomial_ring(QQ,4; cached=false); p = 2; I = ideal([x1-p*x2+(p+1)*x3,3*x2-p^2*x3+(p^2+1)*x4]); val = TropicalSemiringMap(QQ,p,min); Random.seed!(3847598273423); TropI = tropical_variety(I,val) @@ -28,7 +28,7 @@ val = TropicalSemiringMap(QQ,p,max); Random.seed!(3847598273423); TropI = tropic import Random K = QQ; p = K(3); -Kx,(x,y,z) = polynomial_ring(K,3); +Kx,(x,y,z) = polynomial_ring(K,3; cached=false); val = TropicalSemiringMap(K,p,max); Random.seed!(1337133713371337); I = ideal( @@ -45,7 +45,7 @@ TropI, wG = tropical_variety(I,val) ### import Random K,s = rational_function_field(QQ,"s"); -Kx,(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = polynomial_ring(K,10); +Kx,(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = polynomial_ring(K,10; cached=false); p01 = x1 p02 = x2 p03 = x3 @@ -85,7 +85,7 @@ val = TropicalSemiringMap(K,s,max); Random.seed!(3847598273423); TropI,wG = trop ### import Random K,s = rational_function_field(GF(32003),"s"); -Kx,(p01,p02,p03,p04,p12,p13,p14,p23,p24,p34) = polynomial_ring(K,10); +Kx,(p01,p02,p03,p04,p12,p13,p14,p23,p24,p34) = polynomial_ring(K,10; cached=false); I = ideal([p03*p12-p02*p13+p01*p23, p04*p12-p02*p14+p01*p24, p04*p13-p03*p14+p01*p34, @@ -115,7 +115,7 @@ val = TropicalSemiringMap(K,s,max); Random.seed!(3847598273423); TropI = tropica ### import Random K,s = rational_function_field(QQ,"s"); -Kx,(p01,p02,p03,p04,p05,p12,p13,p14,p15,p23,p24,p25,p34,p35,p45) = polynomial_ring(K,15); +Kx,(p01,p02,p03,p04,p05,p12,p13,p14,p15,p23,p24,p25,p34,p35,p45) = polynomial_ring(K,15; cached=false); val = TropicalSemiringMap(K,s); I = ideal([p03*p12-p02*p13+p01*p23, p04*p12-p02*p14+p01*p24, p05*p12-p02*p15+p01*p25, p04*p13-p03*p14+p01*p34, @@ -156,7 +156,7 @@ Random.seed!(133713371337); TropI,wG = tropical_variety(I,val) ### import Random K,s = rational_function_field(GF(32003),"s"); -Kx,(p01,p02,p03,p04,p05,p12,p13,p14,p15,p23,p24,p25,p34,p35,p45) = polynomial_ring(K,15); +Kx,(p01,p02,p03,p04,p05,p12,p13,p14,p15,p23,p24,p25,p34,p35,p45) = polynomial_ring(K,15; cached=false); val = TropicalSemiringMap(K,s); I = ideal([p03*p12-p02*p13+p01*p23, p04*p12-p02*p14+p01*p24, p05*p12-p02*p15+p01*p25, p04*p13-p03*p14+p01*p34, @@ -197,7 +197,7 @@ Random.seed!(133713371337); TropI,wG = tropical_variety(I,val) ### import Random K,s = rational_function_field(GF(32003),"s"); -Kx,(p012,p013,p014,p015,p023,p024,p025,p034,p035,p045,p123,p124,p125,p134,p135,p145,p234,p235,p245,p345) = polynomial_ring(K,20); +Kx,(p012,p013,p014,p015,p023,p024,p025,p034,p035,p045,p123,p124,p125,p134,p135,p145,p234,p235,p245,p345) = polynomial_ring(K,20; cached=false); val = TropicalSemiringMap(K,s); I = ideal([p014*p023-p013*p024+p012*p034, p015*p023-p013*p025+p012*p035, p015*p024-p014*p025+p012*p045, p015*p034-p014*p035+p013*p045, diff --git a/src/TropicalGeometry/groebner_basis.jl b/src/TropicalGeometry/groebner_basis.jl index 0aac21d73a40..cdcbb1fa32a5 100644 --- a/src/TropicalGeometry/groebner_basis.jl +++ b/src/TropicalGeometry/groebner_basis.jl @@ -62,7 +62,7 @@ function simulate_valuation(I::MPolyIdeal, nu::TropicalSemiringMap) @req !isempty(gens(I)) "input ideal empty" R = valued_ring(nu) - Rtx,tx = polynomial_ring(R,vcat([:tsim],symbols(base_ring(I)))) + Rtx,tx = polynomial_ring(R,vcat([:tsim],symbols(base_ring(I))); cached=false) sG = [R(uniformizer(nu))-tx[1]] for f in clear_coefficient_denominators.(gens(I)) @@ -252,7 +252,7 @@ function desimulate_valuation(sG::AbstractVector{<:MPolyRingElem}, nu::TropicalS Rtx = parent(first(sG)) xSymbols = copy(symbols(Rtx))[2:end] K = valued_field(nu) - Kx,x = polynomial_ring(K,xSymbols) + Kx,x = polynomial_ring(K,xSymbols; cached=false) # map everything from simulation ring to original polynomial ring # whilst substituting first variable tsim by uniformizer diff --git a/src/TropicalGeometry/hypersurface.jl b/src/TropicalGeometry/hypersurface.jl index ac1bb6fda54f..2ede094769b8 100644 --- a/src/TropicalGeometry/hypersurface.jl +++ b/src/TropicalGeometry/hypersurface.jl @@ -162,7 +162,7 @@ function tropical_hypersurface(Delta::SubdivisionOfPoints, minOrMax::Union{typeo # e.g., [0 0; 1 0; 0 1; 2 0] decomposed into [0 0; 1 0; 0 1] and [1 0; 0 1; 2 0] has min_weight [+1,0,0,0] # which is dual to the tropical hypersurface of min(+1, x, y, 2*x) or max(-1, x, y, 2*x) coeffs = TT.(coeffs; preserve_ordering=true) - _,x = polynomial_ring(TT,length(first(expvs))) + _,x = polynomial_ring(TT,length(first(expvs)); cached=false) tropf = sum([c*prod(x.^alpha) for (c,alpha) in zip(coeffs,expvs)]) TropH = tropical_hypersurface(tropf) diff --git a/src/TropicalGeometry/initial.jl b/src/TropicalGeometry/initial.jl index a5315f86bd57..fbd691ebfd9f 100644 --- a/src/TropicalGeometry/initial.jl +++ b/src/TropicalGeometry/initial.jl @@ -62,7 +62,7 @@ function initial(f::MPolyRingElem, nu::TropicalSemiringMap, w::AbstractVector{<: ### # Construct the initial form ### - kx, _ = polynomial_ring(residue_field(nu),symbols(parent(f))) + kx, _ = polynomial_ring(residue_field(nu),symbols(parent(f)); cached=false) initialForm = MPolyBuildCtx(kx) for (c,alpha) in zip(coeffs,expvs) push_term!(initialForm,initial(c,nu),alpha) diff --git a/src/TropicalGeometry/semiring_map.jl b/src/TropicalGeometry/semiring_map.jl index cc1513093a1a..14f2f9ab0209 100644 --- a/src/TropicalGeometry/semiring_map.jl +++ b/src/TropicalGeometry/semiring_map.jl @@ -241,7 +241,7 @@ end # valued ring: function valued_ring(nu::TropicalSemiringMap{Kt,t,minOrMax}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem, minOrMax<:Union{typeof(min),typeof(max)}} - return polynomial_ring(base_ring(valued_field(nu)),symbols(valued_field(nu)))[1] + return polynomial_ring(base_ring(valued_field(nu)),symbols(valued_field(nu)); cached=false)[1] end # residue field: diff --git a/src/TropicalGeometry/variety.jl b/src/TropicalGeometry/variety.jl index 844360b5d1fa..ef6107e81bc7 100644 --- a/src/TropicalGeometry/variety.jl +++ b/src/TropicalGeometry/variety.jl @@ -325,7 +325,7 @@ function homogenize_pre_tropicalization(I::MPolyIdeal) Kx = base_ring(I) K = coefficient_ring(Kx) x = symbols(Kx) - Kxhx,_ = polynomial_ring(K,vcat([:xh],x)) + Kxhx,_ = polynomial_ring(K,vcat([:xh],x); cached=false) Gh = Vector{elem_type(Kx)}(undef,length(G)) for (i,g) in enumerate(G) From 33cb934d105e0e59397078e34758e438d9d38212 Mon Sep 17 00:00:00 2001 From: Yue Ren Date: Fri, 13 Sep 2024 20:57:03 +0100 Subject: [PATCH 2/4] TropicalGeometry: TropicalSemiringMap, added caching of polynomial rings --- src/TropicalGeometry/groebner_basis.jl | 2 +- src/TropicalGeometry/initial.jl | 2 +- src/TropicalGeometry/semiring_map.jl | 200 +++++++++++++++---------- test/TropicalGeometry/initial.jl | 13 +- 4 files changed, 135 insertions(+), 82 deletions(-) diff --git a/src/TropicalGeometry/groebner_basis.jl b/src/TropicalGeometry/groebner_basis.jl index cdcbb1fa32a5..0747e7cc0c15 100644 --- a/src/TropicalGeometry/groebner_basis.jl +++ b/src/TropicalGeometry/groebner_basis.jl @@ -64,7 +64,7 @@ function simulate_valuation(I::MPolyIdeal, nu::TropicalSemiringMap) R = valued_ring(nu) Rtx,tx = polynomial_ring(R,vcat([:tsim],symbols(base_ring(I))); cached=false) - sG = [R(uniformizer(nu))-tx[1]] + sG = [uniformizer(nu)-tx[1]] for f in clear_coefficient_denominators.(gens(I)) fRtx = MPolyBuildCtx(Rtx) for (cK,expvKx) = zip(coefficients(f),exponents(f)) diff --git a/src/TropicalGeometry/initial.jl b/src/TropicalGeometry/initial.jl index fbd691ebfd9f..8da369f18f40 100644 --- a/src/TropicalGeometry/initial.jl +++ b/src/TropicalGeometry/initial.jl @@ -62,7 +62,7 @@ function initial(f::MPolyRingElem, nu::TropicalSemiringMap, w::AbstractVector{<: ### # Construct the initial form ### - kx, _ = polynomial_ring(residue_field(nu),symbols(parent(f)); cached=false) + kx = get_polynomial_ring_over_residue_field(parent(f),nu) initialForm = MPolyBuildCtx(kx) for (c,alpha) in zip(coeffs,expvs) push_term!(initialForm,initial(c,nu),alpha) diff --git a/src/TropicalGeometry/semiring_map.jl b/src/TropicalGeometry/semiring_map.jl index 14f2f9ab0209..675913876888 100644 --- a/src/TropicalGeometry/semiring_map.jl +++ b/src/TropicalGeometry/semiring_map.jl @@ -5,12 +5,34 @@ # maps from a field K to a tropical semiring T with the purpose of encoding # - a valuation on K # - a choice of min- or max-convention +# also collects dictionaries that assign to a polynomial ring over K +# - a polynomial ring over the ring of integers +# - a polynomial ring over the residue field +# (for the sake of avoiding caching polynomial ring caches) # ################################################################################ struct TropicalSemiringMap{typeofValuedField,typeofUniformizer,minOrMax} valued_field::typeofValuedField - uniformizer::typeofUniformizer + uniformizer_field::Union{Nothing,FieldElem} + valued_ring::Ring + uniformizer_ring::typeofUniformizer + residue_field::Field tropical_semiring::TropicalSemiring{minOrMax} + ### + # Dictionaries for polynomial ring caches consisting of pairs + # R => S + # where + # - R is a polynomial ring over valued_field + # - S is a polynomial ring over valued_ring or residue_field + # (with the same variables as R) + ### + polynomial_rings_over_valued_ring::Dict{MPolyRing,MPolyRing} + polynomial_rings_over_residue_field::Dict{MPolyRing,MPolyRing} + + # Constructor with empty dictionaries + function TropicalSemiringMap{typeofValuedField,typeofUniformizer,minOrMax}(valuedField::typeofValuedField,uniformizerField::Union{Nothing,FieldElem},valuedRing::Ring,uniformizerRing::typeofUniformizer,residueField::Field,tropicalSemiring::TropicalSemiring{minOrMax}) where {typeofValuedField<:Field,typeofUniformizer<:Union{Nothing,RingElem},minOrMax<:Union{typeof(min),typeof(max)}} + return new{typeofValuedField,typeofUniformizer,minOrMax}(valuedField,uniformizerField,valuedRing,uniformizerRing,residueField,tropicalSemiring,Dict{MPolyRing,MPolyRing}(),Dict{MPolyRing,MPolyRing}()) + end end @@ -21,14 +43,23 @@ end # ################################################################################ valued_field(nu::TropicalSemiringMap) = nu.valued_field -uniformizer(nu::TropicalSemiringMap) = nu.uniformizer +uniformizer_field(nu::TropicalSemiringMap) = nu.uniformizer_field +valued_ring(nu::TropicalSemiringMap) = nu.valued_ring +uniformizer_ring(nu::TropicalSemiringMap) = nu.uniformizer_ring +uniformizer(nu::TropicalSemiringMap) = uniformizer_ring(nu) +residue_field(nu::TropicalSemiringMap) = nu.residue_field tropical_semiring(nu::TropicalSemiringMap) = nu.tropical_semiring -convention(nu::TropicalSemiringMap{typeofValuedField,typeofUniformizer,typeof(min)}) where {typeofValuedField,typeofUniformizer} = min -convention(nu::TropicalSemiringMap{typeofValuedField,typeofUniformizer,typeof(max)}) where {typeofValuedField,typeofUniformizer} = max +convention(::TropicalSemiringMap{typeofValuedField,typeofUniformizer,typeof(min)}) where {typeofValuedField,typeofUniformizer} = min +convention(::TropicalSemiringMap{typeofValuedField,typeofUniformizer,typeof(max)}) where {typeofValuedField,typeofUniformizer} = max + +is_trivial(::TropicalSemiringMap{K,Nothing,minOrMax}) where {K,minOrMax<:Union{typeof(min),typeof(max)}} = true +is_trivial(::TropicalSemiringMap) = false + +polynomial_rings_over_valued_ring(nu::TropicalSemiringMap) = nu.polynomial_rings_over_valued_ring +polynomial_rings_over_residue_field(nu::TropicalSemiringMap) = nu.polynomial_rings_over_residue_field + -is_trivial(nu::TropicalSemiringMap{K,Nothing,minOrMax}) where {K,minOrMax<:Union{typeof(min),typeof(max)}} = true -is_trivial(nu::TropicalSemiringMap) = false ################################################################################ # @@ -65,31 +96,29 @@ julia> nu(0) ``` """ function tropical_semiring_map(K::Field, minOrMax::Union{typeof(min),typeof(max)}=min) - return TropicalSemiringMap{typeof(K),Nothing,typeof(minOrMax)}(K,nothing,tropical_semiring(minOrMax)) + valuedField = K + uniformizerField = nothing + valuedRing = K + uniformizerRing = nothing + residueField = K + tropicalSemiring = tropical_semiring(minOrMax) + return TropicalSemiringMap{typeof(valuedField),typeof(uniformizerRing),typeof(minOrMax)}(valuedField,uniformizerField,valuedRing,uniformizerRing,residueField,tropicalSemiring) end -# display: +# Print string function Base.show(io::IO, nu::TropicalSemiringMap{K,Nothing,minOrMax} where {K<:Ring, minOrMax<:Union{typeof(min),typeof(max)}}) print(io, "Map into $(tropical_semiring(nu)) encoding the trivial valuation on $(valued_field(nu))") end -# evaluation: +# Mapping an element of the valued field or ring to the tropical semiring function (nu::TropicalSemiringMap{K,Nothing,minOrMax})(c::Union{RingElem,Integer,Rational}) where {K<:Field, minOrMax<:Union{typeof(min),typeof(max)}} - return (iszero(valued_field(nu)(c)) ? inf(tropical_semiring(nu)) : one(tropical_semiring(nu))) -end - -# valued ring: -function valued_ring(nu::TropicalSemiringMap{K,Nothing,minOrMax}) where {K,minOrMax<:Union{typeof(min),typeof(max)}} - return valued_field(nu) -end - -# residue field: -function residue_field(nu::TropicalSemiringMap{K,Nothing,minOrMax}) where {K,minOrMax<:Union{typeof(min),typeof(max)}} - return valued_field(nu) + # return tropical zero if c is zero + # and tropical one otherwise + return (iszero(valued_field(nu)(c)) ? zero(tropical_semiring(nu)) : one(tropical_semiring(nu))) end -# initial: -function initial(c::RingElem, nu::TropicalSemiringMap{K,Nothing,minOrMax}) where {K,minOrMax<:Union{typeof(min),typeof(max)}} +# Mapping an element of the valued field or ring to the residue field +function initial(c::Union{RingElem,Integer,Rational}, nu::TropicalSemiringMap{K,Nothing,minOrMax}) where {K<:Field, minOrMax<:Union{typeof(min),typeof(max)}} return residue_field(nu)(c) end @@ -128,45 +157,38 @@ julia> nu_2(1//4) ``` """ -function tropical_semiring_map(K::QQField, p::Union{RingElem,Integer,Rational}, minOrMax::Union{typeof(min),typeof(max)}=min) - p = ZZ(p) - @req is_prime(ZZ(p)) "input p not prime" - @req p < 2^63-1 "input p may not exceed 2^63" - return TropicalSemiringMap{typeof(K),typeof(p),typeof(minOrMax)}(K,p,tropical_semiring(minOrMax)) +function tropical_semiring_map(::QQField, p::Union{RingElem,Integer,Rational}, minOrMax::Union{typeof(min),typeof(max)}=min) + valuedField = QQ + uniformizerField = QQ(p) + valuedRing = ZZ + uniformizerRing = ZZ(p) + residueField = GF(uniformizerRing) + tropicalSemiring = tropical_semiring(minOrMax) + return TropicalSemiringMap{typeof(valuedField),typeof(uniformizerRing),typeof(minOrMax)}(valuedField,uniformizerField,valuedRing,uniformizerRing,residueField,tropicalSemiring) end -# Display: +# Print string function Base.show(io::IO, nu::TropicalSemiringMap{QQField,ZZRingElem,minOrMax}) where {minOrMax<:Union{typeof(min),typeof(max)}} print(io, "Map into $(tropical_semiring(nu)) encoding the $(uniformizer(nu))-adic valuation on $(valued_field(nu))") end -# Evaluation: -function (nu::TropicalSemiringMap{QQField,ZZRingElem,typeof(min)})(c::Union{RingElem,Integer,Rational}) +# Mapping an element of the valued field or ring to the tropical semiring +function (nu::TropicalSemiringMap{QQField,ZZRingElem,minOrMax})(c::Union{RingElem,Integer,Rational}) where minOrMax<:Union{typeof(min),typeof(max)} c = valued_field(nu)(c) - iszero(c) && return zero(tropical_semiring(nu)) # if input is zero, return tropical zero - return tropical_semiring(nu)(valuation(c,ZZ(uniformizer(nu)))) -end -function (nu::TropicalSemiringMap{QQField,ZZRingElem,typeof(max)})(c::Union{RingElem,Integer,Rational}) - c = valued_field(nu)(c) - iszero(c) && return zero(tropical_semiring(nu)) # if input is zero, return tropical zero - return tropical_semiring(nu)(-valuation(c,ZZ(uniformizer(nu)))) -end - -# valued ring: -function valued_ring(nu::TropicalSemiringMap{QQField,ZZRingElem,minOrMax}) where {minOrMax<:Union{typeof(min),typeof(max)}} - return ZZ + # return tropical zero if c is zero + # and p-adic valuation otherwise + # preserve_ordering ensures that valuation is negated if convention(nu)==max + iszero(c) && return zero(tropical_semiring(nu)) + return tropical_semiring(nu)(valuation(c,uniformizer(nu)); preserve_ordering=true) end -# residue field: -function residue_field(nu::TropicalSemiringMap{QQField,ZZRingElem,minOrMax}) where {minOrMax<:Union{typeof(min),typeof(max)}} - return GF(Int(uniformizer(nu))) -end - -# initial: -function initial(c::Union{RingElem,Integer,Rational}, nu::TropicalSemiringMap{QQField,ZZRingElem,minOrMax}) where {minOrMax<:Union{typeof(min),typeof(max)}} +# Mapping an element of the valued field or ring to the residue field +function initial(c::Union{RingElem,Integer,Rational}, nu::TropicalSemiringMap{QQField,ZZRingElem,minOrMax}) where minOrMax<:Union{typeof(min),typeof(max)} c = valued_field(nu)(c) + # return residue field zero if c is zero + # and the correct non-zero residue otherwise iszero(c) && return zero(residue_field(nu)) # if c is zero, return 0 - c *= QQ(uniformizer(nu))^(-valuation(c,ZZ(uniformizer(nu)))) + c *= uniformizer_field(nu)^(-valuation(c,uniformizer(nu))) return residue_field(nu)(c) end @@ -209,50 +231,76 @@ julia> nu_t(1//t^2) ``` """ function tropical_semiring_map(Kt::Generic.RationalFunctionField, t::Generic.RationalFunctionFieldElem, minOrMax::Union{typeof(min),typeof(max)}=min) - @req isone(denominator(t)) "input uniformizer denominator not 1" - t = numerator(t) - @req degree(t)>0 "input uniformizer constant" - return TropicalSemiringMap{typeof(Kt),typeof(t),typeof(minOrMax)}(Kt,t,tropical_semiring(minOrMax)) + valuedField = Kt + uniformizerField = t + uniformizerRing = numerator(t) + valuedRing = parent(uniformizerRing) + residueField = base_ring(valuedRing) + tropicalSemiring = tropical_semiring(minOrMax) + @req is_unit(denominator(uniformizerField)) "input uniformizer denominator not unit" + @req degree(uniformizerRing)>0 "input uniformizer constant" + return TropicalSemiringMap{typeof(valuedField),typeof(uniformizerRing),typeof(minOrMax)}(valuedField,uniformizerField,valuedRing,uniformizerRing,residueField,tropicalSemiring) end -# Display: +# Print String function Base.show(io::IO, nu::TropicalSemiringMap{Kt,t,minOrMax}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem, minOrMax<:Union{typeof(min),typeof(max)}} print(io, "Map into $(tropical_semiring(nu)) encoding the $(uniformizer(nu))-adic valuation on $(valued_field(nu))") end -# Evaluation: +# Mapping an element of the valued field or ring to the tropical semiring function t_adic_valuation(c::Generic.RationalFunctionFieldElem, t::PolyRingElem) - c_num = numerator(c) - c_nom = denominator(c) - return valuation(c_num,t)-valuation(c_nom,t) + return valuation(numerator(c),t)-valuation(denominator(c),t) end -function (nu::TropicalSemiringMap{Kt,t,typeof(min)})(c::Union{RingElem,Integer,Rational}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem} +function (nu::TropicalSemiringMap{Kt,t,minOrMax})(c::Union{RingElem,Integer,Rational}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem, minOrMax<:Union{typeof(min),typeof(max)}} c = valued_field(nu)(c) + # return tropical zero if c is zero + # and p-adic valuation otherwise + # preserve_ordering ensures that valuation is negated if convention(nu)==max iszero(c) && return zero(tropical_semiring(nu)) # if c zero, return tropical zero - return tropical_semiring(nu)(t_adic_valuation(c,uniformizer(nu))) + return tropical_semiring(nu)(t_adic_valuation(c,uniformizer(nu)); preserve_ordering=true) end -function (nu::TropicalSemiringMap{Kt,t,typeof(max)})(c::Union{RingElem,Integer,Rational}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem} +# Mapping an element of the valued field or ring to the residue field +function initial(c::Union{RingElem,Integer,Rational}, nu::TropicalSemiringMap{Kt,t,minOrMax}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem, minOrMax<:Union{typeof(min),typeof(max)}} c = valued_field(nu)(c) - iszero(c) && return zero(tropical_semiring(nu)) # if c zero, return tropical zero - return tropical_semiring(nu)(-t_adic_valuation(c,uniformizer(nu))) + # return residue field zero if c is zero + # and the correct non-zero residue otherwise + iszero(c) && return zero(residue_field(nu)) # if c is zero, return 0 + c *= uniformizer_field(nu)^(-t_adic_valuation(c,uniformizer(nu))) + return evaluate(numerator(c),0) end -# valued ring: -function valued_ring(nu::TropicalSemiringMap{Kt,t,minOrMax}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem, minOrMax<:Union{typeof(min),typeof(max)}} - return polynomial_ring(base_ring(valued_field(nu)),symbols(valued_field(nu)); cached=false)[1] + + +################################################################################ +# +# constructing and caching polynomial rings over valued rings and residue fields +# +################################################################################ + +function get_polynomial_ring_over_valued_ring(R::MPolyRing, nu::TropicalSemiringMap) + @req coefficient_ring(R)==valued_field(nu) "coefficient ring is not valued field" + # return cached polynomial ring if available, create and cache it otherwise + return get!(polynomial_rings_over_valued_ring(nu), R, first(polynomial_ring(valued_ring(R),symbols(R); cached=false))) end -# residue field: -function residue_field(nu::TropicalSemiringMap{Kt,t,minOrMax}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem, minOrMax<:Union{typeof(min),typeof(max)}} - return base_ring(valued_field(nu)) +function get_polynomial_ring_over_residue_field(R::MPolyRing, nu::TropicalSemiringMap) + @req coefficient_ring(R)==valued_field(nu) "coefficient ring is not valued field" + # return cached polynomial ring if available, create and cache it otherwise + return get!(polynomial_rings_over_residue_field(nu), R, first(polynomial_ring(residue_field(nu),symbols(R); cached=false))) end -# initial: -function initial(c::Union{RingElem,Integer,Rational}, nu::TropicalSemiringMap{Kt,t,minOrMax}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem, minOrMax<:Union{typeof(min),typeof(max)}} - c = valued_field(nu)(c) - iszero(c) && return zero(residue_field(nu)) # if c is zero, return 0 - c *= valued_field(nu)(uniformizer(nu))^(-t_adic_valuation(c,uniformizer(nu))) - return evaluate(numerator(c),0) +# special function for trivial valuation to ensure reusing original ring +# (it is cached nonetheless for the sake of consistency) +function get_polynomial_ring_over_valued_ring(R::MPolyRing, nu::TropicalSemiringMap{K,Nothing,minOrMax}) where {K<:Field, minOrMax<:Union{typeof(min),typeof(max)}} + @req coefficient_ring(R)==valued_field(nu) "coefficient ring is not valued field" + # return cached polynomial ring if available, create and cache it otherwise + return get!(polynomial_rings_over_valued_ring(nu), R, R) +end + +function get_polynomial_ring_over_residue_field(R::MPolyRing, nu::TropicalSemiringMap{K,Nothing,minOrMax}) where {K<:Field, minOrMax<:Union{typeof(min),typeof(max)}} + @req coefficient_ring(R)==valued_field(nu) "coefficient ring is not valued field" + # return cached polynomial ring if available, create and cache it otherwise + return get!(polynomial_rings_over_residue_field(nu), R, R) end diff --git a/test/TropicalGeometry/initial.jl b/test/TropicalGeometry/initial.jl index 89a3beb463c9..ba66b9cc3f40 100644 --- a/test/TropicalGeometry/initial.jl +++ b/test/TropicalGeometry/initial.jl @@ -10,9 +10,11 @@ @test initial(f,nuMax,w) == 2*x+2*y # trivial, max nuMin = tropical_semiring_map(QQ,2) - nuMax = tropical_semiring_map(QQ,2,max) - S,(x,y) = GF(2)["x","y"] + S = Oscar.get_polynomial_ring_over_residue_field(R,nuMin) + x,y = gens(S) @test initial(f,nuMin,w) == x^2+y^2 # padic, min + S = Oscar.get_polynomial_ring_over_residue_field(R,nuMax) + x,y = gens(S) @test initial(f,nuMax,w) == x^2+y^2+x+y # tadic, max K,t = rational_function_field(GF(2),"t") @@ -20,9 +22,12 @@ f = x^2+y^2+t*x+t*y w = [-1,-1] nuMin = tropical_semiring_map(K,t) - nuMax = tropical_semiring_map(K,t,max) - S,(x,y) = GF(2)["x","y"] + S = Oscar.get_polynomial_ring_over_residue_field(R,nuMin) + x,y = gens(S) @test initial(f,nuMin,w) == x^2+y^2 # tadic, min + nuMax = tropical_semiring_map(K,t,max) + S = Oscar.get_polynomial_ring_over_residue_field(R,nuMax) + x,y = gens(S) @test initial(f,nuMax,w) == x^2+y^2+x+y # tadic, max end From dd96acdded104357ffb9f62ad735201a6185b69e Mon Sep 17 00:00:00 2001 From: Yue Ren Date: Fri, 13 Sep 2024 21:38:50 +0100 Subject: [PATCH 3/4] TropicalGeometry: removed redundant files --- src/TropicalGeometry/debug.jl | 99 ------- src/TropicalGeometry/debugReduce.jl | 2 - src/TropicalGeometry/debugTropicalVariety.jl | 270 ------------------- 3 files changed, 371 deletions(-) delete mode 100644 src/TropicalGeometry/debug.jl delete mode 100644 src/TropicalGeometry/debugReduce.jl delete mode 100644 src/TropicalGeometry/debugTropicalVariety.jl diff --git a/src/TropicalGeometry/debug.jl b/src/TropicalGeometry/debug.jl deleted file mode 100644 index b3fa1a10d2b9..000000000000 --- a/src/TropicalGeometry/debug.jl +++ /dev/null @@ -1,99 +0,0 @@ -K = GF(2) -Kx,(x1,x2,x3,x4) = polynomial_ring(K,4; cached=false); -inI = ideal([x2 + x3 + x4, x1 + x3]) -println(inI) # same print as input for tropical_link -println(base_ring(inI)) # same print as input for tropical_link - -x = gens(Kx) -inI1 = inI + ideal(Kx,[x[1]+1]) - -singularIdeal = singular_generators(inI1) -singularRing = base_ring(singularIdeal) -singularIdeal = Singular.satstd(singularIdeal,Singular.MaximalIdeal(singularRing,1)) -inI1 = ideal(Kx,singularIdeal) - -L,t = rational_function_field(K,"t") -Lx,x = polynomial_ring(L,symbols(Kx); cached=false) -inI1 = ideal(Lx,[change_base_ring(L,g) for g in gens(inI1)]) - -hyperplanes = [x[i]-t for i in [2,3,4]] -append!(hyperplanes,[t*x[i]-1 for i in [2,3,4]]) -for hyperplane in hyperplanes - display(inI1) - inI0 = inI1+ideal(Lx,[hyperplane]) - display(inI0) -end - - - - - - - - - - - - - - -Kx,(x1,x2,x3,x4) = polynomial_ring(QQ,4; cached=false); -p = 2; -I = ideal([x1-p*x2+(p+1)*x3,3*x2-p^2*x3+(p^2+1)*x4]); -w = Int[-1, 1, -1, 1] - -### -# Step 1: compute a tropical Groebner basis via -# groebner_basis(I,val,w), val=2-adic valuation -### - -# Step 1.1: running simulate_valuation -G = gens(I) -Rtx,tx = polynomial_ring(ZZ,vcat([:t],symbols(parent(G[1]))); cached=false) -vvG = [p-tx[1]] -for f in G - fRtx = MPolyBuildCtx(Rtx) - for (cK,expvKx) = zip(AbstractAlgebra.coefficients(f), AbstractAlgebra.exponent_vectors(f)) - cR = numerator(cK) - expvRtx = vcat([0],expvKx) - push_term!(fRtx,cR,expvRtx) - end - push!(vvG,tighten_simulation(finish(fRtx),val)) -end - -# Step 1.2: compute standard basis in Singular -vvw = -w -pushfirst!(vvw,-1) -S,_ = Singular.polynomial_ring(singular_ring(base_ring(Rtx)), symbols(Rtx); ordering = Singular.ordering_a(vvw)*Singular.ordering_dp()) -SI = Singular.Ideal(S, [S(g) for g in vvG]) -vvGB = Singular.gens(Singular.satstd(SI,Singular.MaximalIdeal(S,1))) -vvGB = [Rtx(g) for g in vvGB] - -# Step 1.3: desimulate_valuation -Rx = parent(vvGB[1]) -x = copy(symbols(Rx)) -popfirst!(x) - -K = QQ -Kx,_ = polynomial_ring(K,x; cached=false) - -GB = [] -for i = 2:3 - vvg = evaluate(vvGB[i],[1],[ZZ(p)]) - g = MPolyBuildCtx(Kx) - for (c, expvRtx) = Base.Iterators.zip(AbstractAlgebra.coefficients(vvg), AbstractAlgebra.exponent_vectors(vvg)) - expvKx = expvRtx - popfirst!(expvKx) - push_term!(g,K(c),expvKx) - end - append!(GB,[finish(g)]) -end - - -### -# Step 2: construct initial ideal from the tropical groebner basis -### -f = GB[1] -kx, x = polynomial_ring(GF(2),[repr(x) for x in gens(parent(f))]; cached=false) - -initialf = MPolyBuildCtx(kx) diff --git a/src/TropicalGeometry/debugReduce.jl b/src/TropicalGeometry/debugReduce.jl deleted file mode 100644 index 7771547fb513..000000000000 --- a/src/TropicalGeometry/debugReduce.jl +++ /dev/null @@ -1,2 +0,0 @@ -R,(t,x,y,z) = Singular.polynomial_ring(QQ,["t","x","y","z","w"],ordering=Singular.ordering_a([-1,1,1,1])*Singular.ordering_lp()) -I = Singular.Ideal(R,[x,y,z]) diff --git a/src/TropicalGeometry/debugTropicalVariety.jl b/src/TropicalGeometry/debugTropicalVariety.jl deleted file mode 100644 index 87ba6ad807cf..000000000000 --- a/src/TropicalGeometry/debugTropicalVariety.jl +++ /dev/null @@ -1,270 +0,0 @@ -### -# Linear example /QQ(s) -### -import Random -K,s = rational_function_field(QQ,"s"); -Kx,(x1,x2,x3,x4) = polynomial_ring(K,4; cached=false); -I = ideal([x1-s*x2+(s+1)*x3,3*x2-s^2*x3+(s^2+1)*x4]); -val = TropicalSemiringMap(K,s,min); Random.seed!(3847598273423); TropI = tropical_variety(I,val) # works -val = TropicalSemiringMap(K,s,max); Random.seed!(3847598273423); TropI = tropical_variety(I,val) # does not work - - - -### -# Linear example /QQ_p -### -import Random -Kx,(x1,x2,x3,x4) = polynomial_ring(QQ,4; cached=false); -p = 2; -I = ideal([x1-p*x2+(p+1)*x3,3*x2-p^2*x3+(p^2+1)*x4]); -val = TropicalSemiringMap(QQ,p,min); Random.seed!(3847598273423); TropI = tropical_variety(I,val) -val = TropicalSemiringMap(QQ,p,max); Random.seed!(3847598273423); TropI = tropical_variety(I,val) - - -### -# Mixed degree example, space sextic /QQ_p (t-adic valuation is too hard) -# todo: send non-terminating GB computation to Christian -### -import Random -K = QQ; -p = K(3); -Kx,(x,y,z) = polynomial_ring(K,3; cached=false); -val = TropicalSemiringMap(K,p,max); -Random.seed!(1337133713371337); -I = ideal( - [rand(1:2)*p*1+rand(1:2)*x+rand(1:2)*y+rand(1:2)*z+rand(1:2)*x*y+rand(1:2)*x*z+rand(1:2)*y*z+rand(1:2)*p*x^2+rand(1:2)*p*y^2+rand(1:2)*p*z^2, - rand(1:2)*p^-3*1+rand(1:2)*p^-3*x^3+rand(1:2)*p^-3*y^3+rand(1:2)*p^-3*z^3+rand(1:2)*p^0*x*y+rand(1:2)*p^0*x*z+rand(1:2)*p^0*y*z+rand(1:2)*p^0*x*y*z+rand(1:2)*p^-1*x+rand(1:2)*p^-1*y+rand(1:2)*p^-1*z+rand(1:2)*p^-1*x^2+rand(1:2)*p^-1*y^2+rand(1:2)*p^-1*z^2+rand(1:2)*p^-1*x^2*y+rand(1:2)*p^-1*x^2*z+rand(1:2)*p^-1*x*y^2+rand(1:2)*p^-1*x*z^2+rand(1:2)*p^-1*y^2*z+rand(1:2)*p^-1*y*z^2]); -TropI, wG = tropical_variety(I,val) - - - - - -### -# Grass(2,5) /QQ(s) -### -import Random -K,s = rational_function_field(QQ,"s"); -Kx,(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = polynomial_ring(K,10; cached=false); -p01 = x1 -p02 = x2 -p03 = x3 -p04 = x4 -p12 = x5 -p13 = x6 -p14 = x7 -p23 = x8 -p24 = x9 -p34 = x10 -I = ideal([p03*p12-p02*p13+p01*p23, - p04*p12-p02*p14+p01*p24, - p04*p13-p03*p14+p01*p34, - p04*p23-p03*p24+p02*p34, - p03*p12-p02*p13+p01*p23, - p04*p12-p02*p14+p01*p24, - p04*p13-p03*p14+p01*p34, - p14*p23-p13*p24+p12*p34, - p03*p12-p02*p13+p01*p23, - p04*p12-p02*p14+p01*p24, - p04*p23-p03*p24+p02*p34, - p14*p23-p13*p24+p12*p34, - p03*p12-p02*p13+p01*p23, - p04*p13-p03*p14+p01*p34, - p04*p23-p03*p24+p02*p34, - p14*p23-p13*p24+p12*p34, - p04*p12-p02*p14+p01*p24, - p04*p13-p03*p14+p01*p34, - p04*p23-p03*p24+p02*p34, - p14*p23-p13*p24+p12*p34]) -val = TropicalSemiringMap(K,s,min); Random.seed!(3847598273423); TropI,wG = tropical_variety(I,val) -val = TropicalSemiringMap(K,s,max); Random.seed!(3847598273423); TropI,wG = tropical_variety(I,val) - - -### -# Grass(2,5) /FF_p(s) -### -import Random -K,s = rational_function_field(GF(32003),"s"); -Kx,(p01,p02,p03,p04,p12,p13,p14,p23,p24,p34) = polynomial_ring(K,10; cached=false); -I = ideal([p03*p12-p02*p13+p01*p23, - p04*p12-p02*p14+p01*p24, - p04*p13-p03*p14+p01*p34, - p04*p23-p03*p24+p02*p34, - p03*p12-p02*p13+p01*p23, - p04*p12-p02*p14+p01*p24, - p04*p13-p03*p14+p01*p34, - p14*p23-p13*p24+p12*p34, - p03*p12-p02*p13+p01*p23, - p04*p12-p02*p14+p01*p24, - p04*p23-p03*p24+p02*p34, - p14*p23-p13*p24+p12*p34, - p03*p12-p02*p13+p01*p23, - p04*p13-p03*p14+p01*p34, - p04*p23-p03*p24+p02*p34, - p14*p23-p13*p24+p12*p34, - p04*p12-p02*p14+p01*p24, - p04*p13-p03*p14+p01*p34, - p04*p23-p03*p24+p02*p34, - p14*p23-p13*p24+p12*p34]) -val = TropicalSemiringMap(K,s,min); Random.seed!(3847598273423); TropI = tropical_variety(I,val) -val = TropicalSemiringMap(K,s,max); Random.seed!(3847598273423); TropI = tropical_variety(I,val) - - -### -# Grass(2,6) /QQ(s) -### -import Random -K,s = rational_function_field(QQ,"s"); -Kx,(p01,p02,p03,p04,p05,p12,p13,p14,p15,p23,p24,p25,p34,p35,p45) = polynomial_ring(K,15; cached=false); -val = TropicalSemiringMap(K,s); -I = ideal([p03*p12-p02*p13+p01*p23, p04*p12-p02*p14+p01*p24, - p05*p12-p02*p15+p01*p25, p04*p13-p03*p14+p01*p34, - p05*p13-p03*p15+p01*p35, p05*p14-p04*p15+p01*p45, - p04*p23-p03*p24+p02*p34, p05*p23-p03*p25+p02*p35, - p05*p24-p04*p25+p02*p45, p05*p34-p04*p35+p03*p45, - p03*p12-p02*p13+p01*p23, p04*p12-p02*p14+p01*p24, - p05*p12-p02*p15+p01*p25, p04*p13-p03*p14+p01*p34, - p05*p13-p03*p15+p01*p35, p05*p14-p04*p15+p01*p45, - p14*p23-p13*p24+p12*p34, p15*p23-p13*p25+p12*p35, - p15*p24-p14*p25+p12*p45, p15*p34-p14*p35+p13*p45, - p03*p12-p02*p13+p01*p23, p04*p12-p02*p14+p01*p24, - p05*p12-p02*p15+p01*p25, p04*p23-p03*p24+p02*p34, - p05*p23-p03*p25+p02*p35, p05*p24-p04*p25+p02*p45, - p14*p23-p13*p24+p12*p34, p15*p23-p13*p25+p12*p35, - p15*p24-p14*p25+p12*p45, p25*p34-p24*p35+p23*p45, - p03*p12-p02*p13+p01*p23, p04*p13-p03*p14+p01*p34, - p05*p13-p03*p15+p01*p35, p04*p23-p03*p24+p02*p34, - p05*p23-p03*p25+p02*p35, p05*p34-p04*p35+p03*p45, - p14*p23-p13*p24+p12*p34, p15*p23-p13*p25+p12*p35, - p15*p34-p14*p35+p13*p45, p25*p34-p24*p35+p23*p45, - p04*p12-p02*p14+p01*p24, p04*p13-p03*p14+p01*p34, - p05*p14-p04*p15+p01*p45, p04*p23-p03*p24+p02*p34, - p05*p24-p04*p25+p02*p45, p05*p34-p04*p35+p03*p45, - p14*p23-p13*p24+p12*p34, p15*p24-p14*p25+p12*p45, - p15*p34-p14*p35+p13*p45, p25*p34-p24*p35+p23*p45, - p05*p12-p02*p15+p01*p25, p05*p13-p03*p15+p01*p35, - p05*p14-p04*p15+p01*p45, p05*p23-p03*p25+p02*p35, - p05*p24-p04*p25+p02*p45, p05*p34-p04*p35+p03*p45, - p15*p23-p13*p25+p12*p35, p15*p24-p14*p25+p12*p45, - p15*p34-p14*p35+p13*p45, p25*p34-p24*p35+p23*p45]) -Random.seed!(133713371337); TropI,wG = tropical_variety(I,val) - - - -### -# Grass(2,6) /FF_p(s) -### -import Random -K,s = rational_function_field(GF(32003),"s"); -Kx,(p01,p02,p03,p04,p05,p12,p13,p14,p15,p23,p24,p25,p34,p35,p45) = polynomial_ring(K,15; cached=false); -val = TropicalSemiringMap(K,s); -I = ideal([p03*p12-p02*p13+p01*p23, p04*p12-p02*p14+p01*p24, - p05*p12-p02*p15+p01*p25, p04*p13-p03*p14+p01*p34, - p05*p13-p03*p15+p01*p35, p05*p14-p04*p15+p01*p45, - p04*p23-p03*p24+p02*p34, p05*p23-p03*p25+p02*p35, - p05*p24-p04*p25+p02*p45, p05*p34-p04*p35+p03*p45, - p03*p12-p02*p13+p01*p23, p04*p12-p02*p14+p01*p24, - p05*p12-p02*p15+p01*p25, p04*p13-p03*p14+p01*p34, - p05*p13-p03*p15+p01*p35, p05*p14-p04*p15+p01*p45, - p14*p23-p13*p24+p12*p34, p15*p23-p13*p25+p12*p35, - p15*p24-p14*p25+p12*p45, p15*p34-p14*p35+p13*p45, - p03*p12-p02*p13+p01*p23, p04*p12-p02*p14+p01*p24, - p05*p12-p02*p15+p01*p25, p04*p23-p03*p24+p02*p34, - p05*p23-p03*p25+p02*p35, p05*p24-p04*p25+p02*p45, - p14*p23-p13*p24+p12*p34, p15*p23-p13*p25+p12*p35, - p15*p24-p14*p25+p12*p45, p25*p34-p24*p35+p23*p45, - p03*p12-p02*p13+p01*p23, p04*p13-p03*p14+p01*p34, - p05*p13-p03*p15+p01*p35, p04*p23-p03*p24+p02*p34, - p05*p23-p03*p25+p02*p35, p05*p34-p04*p35+p03*p45, - p14*p23-p13*p24+p12*p34, p15*p23-p13*p25+p12*p35, - p15*p34-p14*p35+p13*p45, p25*p34-p24*p35+p23*p45, - p04*p12-p02*p14+p01*p24, p04*p13-p03*p14+p01*p34, - p05*p14-p04*p15+p01*p45, p04*p23-p03*p24+p02*p34, - p05*p24-p04*p25+p02*p45, p05*p34-p04*p35+p03*p45, - p14*p23-p13*p24+p12*p34, p15*p24-p14*p25+p12*p45, - p15*p34-p14*p35+p13*p45, p25*p34-p24*p35+p23*p45, - p05*p12-p02*p15+p01*p25, p05*p13-p03*p15+p01*p35, - p05*p14-p04*p15+p01*p45, p05*p23-p03*p25+p02*p35, - p05*p24-p04*p25+p02*p45, p05*p34-p04*p35+p03*p45, - p15*p23-p13*p25+p12*p35, p15*p24-p14*p25+p12*p45, - p15*p34-p14*p35+p13*p45, p25*p34-p24*p35+p23*p45]) -Random.seed!(133713371337); TropI,wG = tropical_variety(I,val) - - - -### -# Grass(3,6) /FF_p(s) -### -import Random -K,s = rational_function_field(GF(32003),"s"); -Kx,(p012,p013,p014,p015,p023,p024,p025,p034,p035,p045,p123,p124,p125,p134,p135,p145,p234,p235,p245,p345) = polynomial_ring(K,20; cached=false); -val = TropicalSemiringMap(K,s); -I = ideal([p014*p023-p013*p024+p012*p034, p015*p023-p013*p025+p012*p035, - p015*p024-p014*p025+p012*p045, p015*p034-p014*p035+p013*p045, - p014*p123-p013*p124+p012*p134, p015*p123-p013*p125+p012*p135, - p015*p124-p014*p125+p012*p145, p015*p134-p014*p135+p013*p145, - p015*p234-p014*p235+p013*p245-p012*p345, p014*p023-p013*p024+p012*p034, - p015*p023-p013*p025+p012*p035, p015*p024-p014*p025+p012*p045, - p025*p034-p024*p035+p023*p045, p024*p123-p023*p124+p012*p234, - p025*p123-p023*p125+p012*p235, p025*p124-p024*p125+p012*p245, - p025*p134-p024*p135+p023*p145+p012*p345, p025*p234-p024*p235+p023*p245, - p014*p023-p013*p024+p012*p034, p015*p023-p013*p025+p012*p035, - p015*p034-p014*p035+p013*p045, p025*p034-p024*p035+p023*p045, - p034*p123-p023*p134+p013*p234, p035*p123-p023*p135+p013*p235, - p035*p124-p034*p125-p023*p145+p013*p245, p035*p134-p034*p135+p013*p345, - p035*p234-p034*p235+p023*p345, p014*p023-p013*p024+p012*p034, - p015*p024-p014*p025+p012*p045, p015*p034-p014*p035+p013*p045, - p025*p034-p024*p035+p023*p045, p034*p124-p024*p134+p014*p234, - p045*p123+p034*p125-p024*p135+p014*p235, p045*p124-p024*p145+p014*p245, - p045*p134-p034*p145+p014*p345, p045*p234-p034*p245+p024*p345, - p015*p023-p013*p025+p012*p035, p015*p024-p014*p025+p012*p045, - p015*p034-p014*p035+p013*p045, p025*p034-p024*p035+p023*p045, - p045*p123-p035*p124+p025*p134-p015*p234, p035*p125-p025*p135+p015*p235, - p045*p125-p025*p145+p015*p245, p045*p135-p035*p145+p015*p345, - p045*p235-p035*p245+p025*p345, p014*p123-p013*p124+p012*p134, - p015*p123-p013*p125+p012*p135, p015*p124-p014*p125+p012*p145, - p024*p123-p023*p124+p012*p234, p025*p123-p023*p125+p012*p235, - p025*p124-p024*p125+p012*p245, p045*p123-p035*p124+p034*p125-p012*p345, - p125*p134-p124*p135+p123*p145, p125*p234-p124*p235+p123*p245, - p014*p123-p013*p124+p012*p134, p015*p123-p013*p125+p012*p135, - p015*p134-p014*p135+p013*p145, p034*p123-p023*p134+p013*p234, - p035*p123-p023*p135+p013*p235, p045*p123+p025*p134-p024*p135+p013*p245, - p035*p134-p034*p135+p013*p345, p125*p134-p124*p135+p123*p145, - p135*p234-p134*p235+p123*p345, p014*p123-p013*p124+p012*p134, - p015*p124-p014*p125+p012*p145, p015*p134-p014*p135+p013*p145, - p034*p124-p024*p134+p014*p234, p035*p124-p025*p134-p023*p145+p014*p235, - p045*p124-p024*p145+p014*p245, p045*p134-p034*p145+p014*p345, - p125*p134-p124*p135+p123*p145, p145*p234-p134*p245+p124*p345, - p015*p123-p013*p125+p012*p135, p015*p124-p014*p125+p012*p145, - p015*p134-p014*p135+p013*p145, p034*p125-p024*p135+p023*p145+p015*p234, - p035*p125-p025*p135+p015*p235, p045*p125-p025*p145+p015*p245, - p045*p135-p035*p145+p015*p345, p125*p134-p124*p135+p123*p145, - p145*p235-p135*p245+p125*p345, p024*p123-p023*p124+p012*p234, - p025*p123-p023*p125+p012*p235, p034*p123-p023*p134+p013*p234, - p035*p123-p023*p135+p013*p235, p045*p123-p023*p145-p015*p234+p014*p235, - p025*p234-p024*p235+p023*p245, p035*p234-p034*p235+p023*p345, - p125*p234-p124*p235+p123*p245, p135*p234-p134*p235+p123*p345, - p024*p123-p023*p124+p012*p234, p025*p124-p024*p125+p012*p245, - p034*p124-p024*p134+p014*p234, p035*p124-p024*p135+p015*p234+p013*p245, - p045*p124-p024*p145+p014*p245, p025*p234-p024*p235+p023*p245, - p045*p234-p034*p245+p024*p345, p125*p234-p124*p235+p123*p245, - p145*p234-p134*p245+p124*p345, p025*p123-p023*p125+p012*p235, - p025*p124-p024*p125+p012*p245, p034*p125-p025*p134+p014*p235-p013*p245, - p035*p125-p025*p135+p015*p235, p045*p125-p025*p145+p015*p245, - p025*p234-p024*p235+p023*p245, p045*p235-p035*p245+p025*p345, - p125*p234-p124*p235+p123*p245, p145*p235-p135*p245+p125*p345, - p034*p123-p023*p134+p013*p234, p034*p124-p024*p134+p014*p234, - p034*p125-p025*p134+p015*p234-p012*p345, p035*p134-p034*p135+p013*p345, - p045*p134-p034*p145+p014*p345, p035*p234-p034*p235+p023*p345, - p045*p234-p034*p245+p024*p345, p135*p234-p134*p235+p123*p345, - p145*p234-p134*p245+p124*p345, p035*p123-p023*p135+p013*p235, - p035*p124-p024*p135+p014*p235+p012*p345, p035*p125-p025*p135+p015*p235, - p035*p134-p034*p135+p013*p345, p045*p135-p035*p145+p015*p345, - p035*p234-p034*p235+p023*p345, p045*p235-p035*p245+p025*p345, - p135*p234-p134*p235+p123*p345, p145*p235-p135*p245+p125*p345, - p045*p123-p023*p145+p013*p245-p012*p345, p045*p124-p024*p145+p014*p245, - p045*p125-p025*p145+p015*p245, p045*p134-p034*p145+p014*p345, - p045*p135-p035*p145+p015*p345, p045*p234-p034*p245+p024*p345, - p045*p235-p035*p245+p025*p345, p145*p234-p134*p245+p124*p345, - p145*p235-p135*p245+p125*p345]) -Random.seed!(133713371337); TropI,wG = tropical_variety(I,val) From 0c6792a0a53f01810fd8b3d511e87956c77148b6 Mon Sep 17 00:00:00 2001 From: Yue Ren Date: Fri, 13 Sep 2024 21:45:27 +0100 Subject: [PATCH 4/4] TropicalGeometry: fixed tests --- test/TropicalGeometry/initial.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/TropicalGeometry/initial.jl b/test/TropicalGeometry/initial.jl index ba66b9cc3f40..6e22b8ea50b1 100644 --- a/test/TropicalGeometry/initial.jl +++ b/test/TropicalGeometry/initial.jl @@ -13,6 +13,7 @@ S = Oscar.get_polynomial_ring_over_residue_field(R,nuMin) x,y = gens(S) @test initial(f,nuMin,w) == x^2+y^2 # padic, min + nuMax = tropical_semiring_map(QQ,2,max) S = Oscar.get_polynomial_ring_over_residue_field(R,nuMax) x,y = gens(S) @test initial(f,nuMax,w) == x^2+y^2+x+y # tadic, max