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

polynomial_ring cached=false for tropical geometry #3858

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/TropicalGeometry/debug.jl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]]
Expand All @@ -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]
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
16 changes: 8 additions & 8 deletions src/TropicalGeometry/debugTropicalVariety.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/TropicalGeometry/groebner_basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -252,7 +252,7 @@ function desimulate_valuation(sG::Vector{<:MPolyRingElem}, nu::TropicalSemiringM
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
Expand Down
2 changes: 1 addition & 1 deletion src/TropicalGeometry/hypersurface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,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)

Expand Down
2 changes: 1 addition & 1 deletion src/TropicalGeometry/initial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function initial(f::MPolyRingElem, nu::TropicalSemiringMap, w::Vector{<:Union{QQ
###
# 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)
Expand Down
2 changes: 1 addition & 1 deletion src/TropicalGeometry/semiring_map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/TropicalGeometry/variety.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading