Skip to content

Commit 969565b

Browse files
authored
Allow TropicalSemiringMap to not have a valued field (#5514)
* chg: TropicalSemiringMap, allow valuedField to be unspeficied intended for future use-cases where valued field is unimportant, e.g., when working with Puiseux polynomials. * TropicalGeometry: groebner_basis, added TropicalSemiringMap checks * TropicalGeometry: added / changed comments * TropicalGeometry: added domain, codomain for TropicalSemiringMap * TropicalGeometry: relaxed assertions for initial * TropicalGeometry: tropical_semiring_map, field renaming - `uniformizer_field` -> `uniformizer_in_field` - `uniformizer_ring` -> `uniformizer_in_ring` * TropicalGeometry: adding linebreaks to overlong docstring line * TropicalGeometry: hypersurface, simplified optional parameter specification * TropicalGeometry: hypersurface, added check for valued field The notion of a tropical hypersurface over a general ring is ambigious, so it makes sense to disallow it for now. * TropicalGeometry: replace `valued_field` calls by `domain` calls * TropicalGeometry: replace if bracket with ternary if * TropicalGeometry: fixed forgotten `uniformizer_field` in namechange
1 parent 49193cc commit 969565b

File tree

4 files changed

+96
-40
lines changed

4 files changed

+96
-40
lines changed

src/TropicalGeometry/groebner_basis.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414

1515
################################################################################
1616
#
17-
# Caching of polynomial rings over valued rings
17+
# Caching of polynomial rings
18+
#
19+
# Tropical Groebner basis computations are done via standard basis computations
20+
# in a different polynomial ring (that depends on the valuation). We cache
21+
# these polynomial rings as a dictionary in the original polynomial ring
1822
#
1923
################################################################################
2024
function get_polynomial_ring_for_groebner_simulation(R::MPolyRing, nu::TropicalSemiringMap)
21-
@req coefficient_ring(R)==valued_field(nu) "coefficient ring is not valued field"
25+
@req coefficient_ring(R)==domain(nu) "coefficient ring is not valued field"
2226

2327
if !has_attribute(R, :tropical_geometry_polynomial_rings_for_groebner)
2428
set_attribute!(R, :tropical_geometry_polynomial_rings_for_groebner, Dict{TropicalSemiringMap,MPolyRing}())
@@ -30,7 +34,7 @@ end
3034

3135
# special function for trivial valuation to ensure reusing original ring
3236
function get_polynomial_ring_for_groebner_simulation(R::MPolyRing, nu::TropicalSemiringMap{K,Nothing,minOrMax}) where {K<:Field, minOrMax<:Union{typeof(min),typeof(max)}}
33-
@req coefficient_ring(R)==valued_field(nu) "coefficient ring is not valued field"
37+
@req coefficient_ring(R)==domain(nu) "coefficient ring is not valued field"
3438
return R
3539
end
3640

@@ -180,7 +184,7 @@ t*x2 + (s^2 + s + 1)*x1 + x3
180184
```
181185
"""
182186
function tighten_simulation(f::MPolyRingElem, nu::TropicalSemiringMap)
183-
# substitute first variable tsim by uniformizer_ring
187+
# substitute first variable tsim by uniformizer_in_ring
184188
# so that all monomials have distinct x-monomials
185189
f = evaluate(f,[1],[uniformizer(nu)])
186190

@@ -286,7 +290,7 @@ function desimulate_valuation(sG::AbstractVector{<:MPolyRingElem}, nu::TropicalS
286290

287291
# map everything from simulation ring to the specified polynomial ring
288292
# whilst substituting first variable tsim by uniformizer
289-
desimulation_map = hom(S, R, valued_field(nu), vcat(uniformizer_field(nu),gens(R)))
293+
desimulation_map = hom(S, R, domain(nu), vcat(uniformizer_in_field(nu),gens(R)))
290294
G = desimulation_map.(sG)
291295
# filter for nonzero elements
292296
G = filter(!iszero,G)
@@ -379,9 +383,11 @@ julia> groebner_basis(I,nu,w)
379383
```
380384
"""
381385
function groebner_basis(I::MPolyIdeal, nu::TropicalSemiringMap, w::AbstractVector{<:Union{QQFieldElem,ZZRingElem,Rational,Integer}})
386+
@req domain(nu) isa Field "valuation must be defined on a field"
387+
@req domain(nu)==coefficient_ring(I) "coefficient ring of ideal does not match valued field of valuation"
388+
382389
G = gens(I)
383-
# Principal ideal shortcut, return G
384-
if isone(length(G))
390+
if isone(length(G)) # for principal ideals, just return generator
385391
return G
386392
end
387393

src/TropicalGeometry/hypersurface.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ Min tropical hypersurface
121121
122122
```
123123
"""
124-
function tropical_hypersurface(f::MPolyRingElem, nu::Union{Nothing,TropicalSemiringMap}=nothing;
124+
function tropical_hypersurface(f::MPolyRingElem, nu::TropicalSemiringMap=tropical_semiring_map(coefficient_ring(f));
125125
weighted_polyhedral_complex_only::Bool=false)
126-
# initialize nu as the trivial valuation if not specified by user
127-
isnothing(nu) && (nu=tropical_semiring_map(coefficient_ring(f)))
126+
127+
@req (coefficient_ring(f) isa Field) "coefficient ring of polynomial must be a field"
128128

129129
tropf = tropical_polynomial(f,nu)
130130
TropH = tropical_hypersurface(tropf,weighted_polyhedral_complex_only=weighted_polyhedral_complex_only)

src/TropicalGeometry/initial.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#
1414
################################################################################
1515
function get_polynomial_ring_for_initial(R::MPolyRing, nu::TropicalSemiringMap)
16-
@req coefficient_ring(R)==valued_field(nu) "coefficient ring is not valued field"
16+
@req coefficient_ring(R)==domain(nu) "coefficient ring of polynomials is not domain of tropical semiring map"
1717

1818
polynomialRingsForInitial = get_attribute!(R, :tropical_geometry_polynomial_rings_for_initial) do
1919
return Dict{TropicalSemiringMap,MPolyRing}()
@@ -23,7 +23,7 @@ end
2323

2424
# special function for trivial valuation to ensure reusing original ring
2525
function get_polynomial_ring_for_initial(R::MPolyRing, nu::TropicalSemiringMap{K,Nothing,minOrMax}) where {K<:Field, minOrMax<:Union{typeof(min),typeof(max)}}
26-
@req coefficient_ring(R)==valued_field(nu) "coefficient ring is not valued field"
26+
@req coefficient_ring(R)==domain(nu) "coefficient ring of polynomials is not domain of tropical semiring map"
2727
return R
2828
end
2929

src/TropicalGeometry/semiring_map.jl

Lines changed: 78 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,68 @@
11
################################################################################
22
#
3-
# Tropical semiring maps
4-
# ======================
5-
# maps from a field K to a tropical semiring T with the purpose of encoding
6-
# - a valuation on K
7-
# - a choice of min- or max-convention
3+
# Tropical semiring map
84
#
95
################################################################################
10-
struct TropicalSemiringMap{typeofValuedField,typeofUniformizer,minOrMax}
11-
valued_field::typeofValuedField
12-
uniformizer_field::Union{Nothing,FieldElem}
6+
7+
@doc raw"""
8+
TropicalSemiringMap{DomainType, UniformizerType, MinOrMax}
9+
10+
A structure representing a map from a valued field or ring to a tropical
11+
semiring, encoding a valuation and a choice of min- or max-convention.
12+
13+
# Parameters
14+
- `DomainType`: type of valued field (if specified)
15+
or type of valued ring (if valued field unspecified)
16+
- `UniformizerType`: type of uniformizer in valued ring
17+
- `MinOrMax`: either `typeof(min)` or `typeof(max)` depending on convention
18+
19+
# Fields
20+
- `valued_field`: the valued field. can be `nothing` if valued field unspecified
21+
- `uniformizer_in_field`: the uniformizer as element in the valued field
22+
can be `nothing` if valued field unspecified or valuation trivial
23+
- `valued_ring`: the valued ring, either specified by user or
24+
inferred from the valued field specified by user
25+
- `uniformizer_in_ring`: the uniformizer as element in the valued ring specified by user
26+
can be `nothing` if valuation trivial
27+
- `residue_field`: the residue field, inferred from fields above
28+
- `tropical_semiring`: either `tropical_semiring(min)` or `tropical_semiring(max)`
29+
depending on convention
30+
"""
31+
struct TropicalSemiringMap{DomainType, UniformizerType, MinOrMax}
32+
valued_field::Union{Nothing,Field}
33+
uniformizer_in_field::Union{Nothing,FieldElem}
1334
valued_ring::Ring
14-
uniformizer_ring::typeofUniformizer
35+
uniformizer_in_ring::Union{Nothing,RingElem}
1536
residue_field::Field
16-
tropical_semiring::TropicalSemiring{minOrMax}
17-
18-
# Constructor with empty dictionaries
19-
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)}}
20-
return new{typeofValuedField,typeofUniformizer,minOrMax}(valuedField,uniformizerField,valuedRing,uniformizerRing,residueField,tropicalSemiring)
37+
tropical_semiring::TropicalSemiring{MinOrMax}
38+
39+
function TropicalSemiringMap{DomainType, UniformizerType, MinOrMax}(
40+
valuedField::Union{Nothing,Field},
41+
uniformizerField::Union{Nothing,FieldElem},
42+
valuedRing::Ring,
43+
uniformizerRing::Union{Nothing,RingElem},
44+
residueField::Field,
45+
tropicalSemiring::TropicalSemiring{MinOrMax}
46+
) where {
47+
DomainType <: Ring,
48+
UniformizerType <: Union{Nothing,RingElem},
49+
MinOrMax <: Union{typeof(min),typeof(max)}
50+
}
51+
52+
# if valuedField is unspecified, check that uniformizerField is unspecified
53+
# if uniformizerRing is unspecified, check that uniformizerField is unspecified
54+
@req !isnothing(valuedField) || isnothing(uniformizerField) "valuedField / uniformizerField mismatch"
55+
@req !isnothing(uniformizerRing) || isnothing(uniformizerField) "uniformizerRing / uniformizerField mismatch"
56+
57+
# if no valued field specified, first parameter captures the valued ring
58+
# otherwise, first parameter captures the valued field
59+
return new{isnothing(valuedField) ? typeof(valuedRing) : typeof(valuedField), typeof(uniformizerRing),MinOrMax}(
60+
valuedField,
61+
uniformizerField,
62+
valuedRing,
63+
uniformizerRing,
64+
residueField,
65+
tropicalSemiring)
2166
end
2267
end
2368

@@ -29,13 +74,16 @@ end
2974
#
3075
################################################################################
3176
valued_field(nu::TropicalSemiringMap) = nu.valued_field
32-
uniformizer_field(nu::TropicalSemiringMap) = nu.uniformizer_field
77+
uniformizer_in_field(nu::TropicalSemiringMap) = nu.uniformizer_in_field
3378
valued_ring(nu::TropicalSemiringMap) = nu.valued_ring
34-
uniformizer_ring(nu::TropicalSemiringMap) = nu.uniformizer_ring
35-
uniformizer(nu::TropicalSemiringMap) = uniformizer_ring(nu)
79+
uniformizer_in_ring(nu::TropicalSemiringMap) = nu.uniformizer_in_ring
3680
residue_field(nu::TropicalSemiringMap) = nu.residue_field
3781
tropical_semiring(nu::TropicalSemiringMap) = nu.tropical_semiring
3882

83+
domain(nu::TropicalSemiringMap) = isnothing(valued_field(nu)) ? valued_ring(nu) : valued_field(nu)
84+
codomain(nu::TropicalSemiringMap) = tropical_semiring(nu)
85+
uniformizer(nu::TropicalSemiringMap) = uniformizer_in_ring(nu)
86+
3987
convention(::TropicalSemiringMap{typeofValuedField,typeofUniformizer,typeof(min)}) where {typeofValuedField,typeofUniformizer} = min
4088
convention(::TropicalSemiringMap{typeofValuedField,typeofUniformizer,typeof(max)}) where {typeofValuedField,typeofUniformizer} = max
4189

@@ -57,7 +105,9 @@ polynomial_rings_for_initial(nu::TropicalSemiringMap) = nu.polynomial_rings_for_
57105
@doc raw"""
58106
tropical_semiring_map(K::Field, minOrMax::Union{typeof(min),typeof(max)}=min)
59107
60-
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`.
108+
Return a map `nu` from `K` to the min (default) or max tropical semiring `T`
109+
such that `nu(0)=zero(T)` and `nu(c)=one(T)` for `c` non-zero. In other words,
110+
`nu` represents the trivial valuation on `K`.
61111
62112
# Examples
63113
```jldoctest
@@ -93,14 +143,14 @@ end
93143

94144
# Print string
95145
function Base.show(io::IO, nu::TropicalSemiringMap{K,Nothing,minOrMax} where {K<:Ring, minOrMax<:Union{typeof(min),typeof(max)}})
96-
print(io, "Map into $(tropical_semiring(nu)) encoding the trivial valuation on $(valued_field(nu))")
146+
print(io, "Map into $(tropical_semiring(nu)) encoding the trivial valuation on $(domain(nu))")
97147
end
98148

99149
# Mapping an element of the valued field or ring to the tropical semiring
100150
function (nu::TropicalSemiringMap{K,Nothing,minOrMax})(c::Union{RingElem,Integer,Rational}) where {K<:Field, minOrMax<:Union{typeof(min),typeof(max)}}
101151
# return tropical zero if c is zero
102152
# and tropical one otherwise
103-
return (iszero(valued_field(nu)(c)) ? zero(tropical_semiring(nu)) : one(tropical_semiring(nu)))
153+
return (iszero(domain(nu)(c)) ? zero(tropical_semiring(nu)) : one(tropical_semiring(nu)))
104154
end
105155

106156
# Mapping an element of the valued field or ring to the residue field
@@ -155,12 +205,12 @@ end
155205

156206
# Print string
157207
function Base.show(io::IO, nu::TropicalSemiringMap{QQField,ZZRingElem,minOrMax}) where {minOrMax<:Union{typeof(min),typeof(max)}}
158-
print(io, "Map into $(tropical_semiring(nu)) encoding the $(uniformizer(nu))-adic valuation on $(valued_field(nu))")
208+
print(io, "Map into $(tropical_semiring(nu)) encoding the $(uniformizer(nu))-adic valuation on $(domain(nu))")
159209
end
160210

161211
# Mapping an element of the valued field or ring to the tropical semiring
162212
function (nu::TropicalSemiringMap{QQField,ZZRingElem,minOrMax})(c::Union{RingElem,Integer,Rational}) where minOrMax<:Union{typeof(min),typeof(max)}
163-
c = valued_field(nu)(c)
213+
c = domain(nu)(c)
164214
# return tropical zero if c is zero
165215
# and p-adic valuation otherwise
166216
# preserve_ordering ensures that valuation is negated if convention(nu)==max
@@ -170,11 +220,11 @@ end
170220

171221
# Mapping an element of the valued field or ring to the residue field
172222
function initial(c::Union{RingElem,Integer,Rational}, nu::TropicalSemiringMap{QQField,ZZRingElem,minOrMax}) where minOrMax<:Union{typeof(min),typeof(max)}
173-
c = valued_field(nu)(c)
223+
c = domain(nu)(c)
174224
# return residue field zero if c is zero
175225
# and the correct non-zero residue otherwise
176226
iszero(c) && return zero(residue_field(nu)) # if c is zero, return 0
177-
c *= uniformizer_field(nu)^(-valuation(c,uniformizer(nu)))
227+
c *= uniformizer_in_field(nu)^(-valuation(c,uniformizer(nu)))
178228
return residue_field(nu)(c)
179229
end
180230

@@ -230,7 +280,7 @@ end
230280

231281
# Print String
232282
function Base.show(io::IO, nu::TropicalSemiringMap{Kt,t,minOrMax}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem, minOrMax<:Union{typeof(min),typeof(max)}}
233-
print(io, "Map into $(tropical_semiring(nu)) encoding the $(uniformizer(nu))-adic valuation on $(valued_field(nu))")
283+
print(io, "Map into $(tropical_semiring(nu)) encoding the $(uniformizer(nu))-adic valuation on $(domain(nu))")
234284
end
235285

236286
# Mapping an element of the valued field or ring to the tropical semiring
@@ -239,7 +289,7 @@ function t_adic_valuation(c::Generic.RationalFunctionFieldElem, t::PolyRingElem)
239289
end
240290

241291
function (nu::TropicalSemiringMap{Kt,t,minOrMax})(c::Union{RingElem,Integer,Rational}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem, minOrMax<:Union{typeof(min),typeof(max)}}
242-
c = valued_field(nu)(c)
292+
c = domain(nu)(c)
243293
# return tropical zero if c is zero
244294
# and p-adic valuation otherwise
245295
# preserve_ordering ensures that valuation is negated if convention(nu)==max
@@ -249,10 +299,10 @@ end
249299

250300
# Mapping an element of the valued field or ring to the residue field
251301
function initial(c::Union{RingElem,Integer,Rational}, nu::TropicalSemiringMap{Kt,t,minOrMax}) where {Kt<:Generic.RationalFunctionField, t<:PolyRingElem, minOrMax<:Union{typeof(min),typeof(max)}}
252-
c = valued_field(nu)(c)
302+
c = domain(nu)(c)
253303
# return residue field zero if c is zero
254304
# and the correct non-zero residue otherwise
255305
iszero(c) && return zero(residue_field(nu)) # if c is zero, return 0
256-
c *= uniformizer_field(nu)^(-t_adic_valuation(c,uniformizer(nu)))
306+
c *= uniformizer_in_field(nu)^(-t_adic_valuation(c,uniformizer(nu)))
257307
return evaluate(numerator(c),0)
258308
end

0 commit comments

Comments
 (0)