Skip to content

Commit

Permalink
Bump AA, Nemo, and Hecke compat (oscar-system#4122)
Browse files Browse the repository at this point in the history
* Bump AA, Nemo, and Hecke compat
* Adapt to `addeq!` deprecation and remove some now unnecessary mutable arith methods
* Adapt to `@attr` changes
* `prime_field` -> `absolute_base_field` for padics
* Assertions.jl moved to AA

---------

Co-authored-by: Johannes Schmitt <[email protected]>
  • Loading branch information
2 people authored and HechtiDerLachs committed Sep 30, 2024
1 parent fe63200 commit 6029c59
Show file tree
Hide file tree
Showing 24 changed files with 84 additions and 123 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
cohomCalg_jll = "5558cf25-a90e-53b0-b813-cadaa3ae7ade"

[compat]
AbstractAlgebra = "0.42.5"
AbstractAlgebra = "0.43.1"
AlgebraicSolving = "0.7.0"
Distributed = "1.6"
GAP = "0.11.3"
Hecke = "0.33.0"
Hecke = "0.34.1"
JSON = "^0.20, ^0.21"
JSON3 = "1.13.2"
LazyArtifacts = "1.6"
Markdown = "1.6"
Nemo = "0.46.2"
Nemo = "0.47.1"
Pkg = "1.6"
Polymake = "0.11.20"
Random = "1.6"
Expand Down
8 changes: 4 additions & 4 deletions experimental/GModule/src/GaloisCohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ defaulting to the full automorphism group over the prime field.
Find the embedding of Gp -> G, realizing the local automorphism group
as a subgroup of the global one.
"""
function Oscar.decomposition_group(K::AbsSimpleNumField, mK::Map, mG::Map = automorphism_group(K)[2], mGp::Map = automorphism_group(codomain(mK), prime_field(codomain(mK))); _sub::Bool = false)
function Oscar.decomposition_group(K::AbsSimpleNumField, mK::Map, mG::Map = automorphism_group(K)[2], mGp::Map = automorphism_group(codomain(mK), absolute_base_field(codomain(mK))); _sub::Bool = false)
Kp = codomain(mK)
@assert domain(mK) == K

Expand Down Expand Up @@ -998,7 +998,7 @@ function idele_class_gmodule(k::AbsSimpleNumField, s::Vector{Int} = Int[]; redo:
Hecke.popindent()
@vprint :GaloisCohomology 2 " .. gathering the local modules ..\n"
Hecke.pushindent()
C = [gmodule(x[1], prime_field(x[1])) for x = L];
C = [gmodule(x[1], absolute_base_field(x[1])) for x = L];
I.D = [x[2] for x = C]
I.L = [x[3] for x = C]
@hassert :GaloisCohomology 1 all(x->is_consistent(x[1]), C)
Expand Down Expand Up @@ -1314,7 +1314,7 @@ function local_index(CC::Vector{GrpCoh.CoChain{2, PermGroupElem, GrpCoh.MultGrpE
cn = data[7]
else
L, mL = completion(k, P)#, 40*ramification_index(P))
C, mGp, mU = gmodule(L, prime_field(L))
C, mGp, mU = gmodule(L, absolute_base_field(L))

G = domain(mG)
emb, _m = decomposition_group(k, mL, mG, mGp, _sub = true)
Expand Down Expand Up @@ -1860,7 +1860,7 @@ function serre(A::IdeleParent, P::AbsNumFieldOrderIdeal)
Kp, mKp, mGp, mUp, pro, inj = completion(A, P)
mp = decomposition_group(A.k, mKp, A.mG, mGp)
qr = restrict(C, mp)
s = Hecke.Hecke.local_fundamental_class_serre(Kp, prime_field(Kp))
s = Hecke.Hecke.local_fundamental_class_serre(Kp, absolute_base_field(Kp))
# Oscar.GModuleFromGap.istwo_cocycle(Dict( (g, h) => s(mGp(g), mGp(h)) for g = domain(mGp) for h = domain(mGp)), mGp)

z = gmodule(domain(mGp), [hom(domain(mUp), domain(mUp), [preimage(mUp, mGp(g)(mUp(u))) for u = gens(domain(mUp))]) for g = gens(domain(mGp))])
Expand Down
4 changes: 2 additions & 2 deletions experimental/GModule/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ end

l2 = prime_decomposition(maximal_order(k), 2)
k2, _ = Hecke.completion(k, l2[1][1], 120)
z = Hecke.local_fundamental_class_serre(k2, prime_field(k2))
C, mG, mU = Oscar.GrpCoh.gmodule(k2, prime_field(k2))
z = Hecke.local_fundamental_class_serre(k2, absolute_base_field(k2))
C, mG, mU = Oscar.GrpCoh.gmodule(k2, absolute_base_field(k2))
G = domain(mG)

pe = gen(k2)
Expand Down
2 changes: 1 addition & 1 deletion experimental/Schemes/src/Resolution_tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ julia> L[4]
```
"""
@attr function intersection_matrix(phi::Union{BlowUpSequence,MixedBlowUpSequence})
@attr Any function intersection_matrix(phi::Union{BlowUpSequence,MixedBlowUpSequence})
phi.resolves_sing || error("intersection_matrix not available for partial desingularizations")
!isdefined(phi, :is_embedded) || !phi.is_embedded || error("not available yet for embedded desingularization of curves")
dim(domain(phi))==2 || error("not a surface -- exceptional locus not a graph")
Expand Down
6 changes: 3 additions & 3 deletions src/InvariantTheory/invariant_rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function right_action(R::MPolyRing{T}, M::MatrixElem{T}) where {T}
if iszero(M[i, j])
continue
end
vars[i] = addeq!(vars[i], M[i, j] * x[j])
vars[i] = add!(vars[i], M[i, j] * x[j])
end
end

Expand Down Expand Up @@ -214,7 +214,7 @@ function reynolds_operator(
function reynolds(f::PolyRingElemT)
g = parent(f)()
for action in actions
g = addeq!(g, action(f))
g = add!(g, action(f))
end
return g * base_ring(f)(1//order(group(IR)))
end
Expand Down Expand Up @@ -344,7 +344,7 @@ function reynolds_operator(
function reynolds(f::PolyRingElemT)
g = parent(f)()
for (action, val) in actions_and_values
g = addeq!(g, action(f) * val)
g = add!(g, action(f) * val)
end
return g * base_ring(f)(1//order(group(IR)))
end
Expand Down
3 changes: 0 additions & 3 deletions src/NumberTheory/GaloisGrp/GaloisGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ function total_degree(I::SLPoly)
return value(evaluate(I, [C(1) for i = 1:n]))
end

Oscar.mul!(a::BoundRingElem, b::BoundRingElem, c::BoundRingElem) = b*c
Oscar.addeq!(a::BoundRingElem, b::BoundRingElem) = a+b

#my 1st invariant!!!
@doc raw"""
sqrt_disc(a::Vector)
Expand Down
34 changes: 24 additions & 10 deletions src/Rings/AbelianClosure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import Base: +, *, -, //, ==, zero, one, ^, div, isone, iszero,

#import ..Oscar.AbstractAlgebra: promote_rule

import ..Oscar: AbstractAlgebra, addeq!, base_ring, base_ring_type, characteristic, elem_type, divexact, gen,
has_preimage_with_preimage, is_root_of_unity, is_unit, mul!, parent,
parent_type, promote_rule, root, root_of_unity, roots
import ..Oscar: AbstractAlgebra, add!, base_ring, base_ring_type, characteristic, elem_type, divexact, gen,
has_preimage_with_preimage, is_root_of_unity, is_unit, mul!, neg!, parent,
parent_type, promote_rule, root, root_of_unity, roots, @req

using Hecke
import Hecke: conductor, data
Expand Down Expand Up @@ -625,25 +625,39 @@ end
#
################################################################################

function addeq!(c::QQAbFieldElem, a::QQAbFieldElem)
_c, _a = make_compatible(c, a)
addeq!(_c.data, _a.data)
return _c
function add!(c::QQAbFieldElem, a::QQAbFieldElem, b::QQAbFieldElem)
a, b = make_compatible(a, b)
b, c = make_compatible(b, c)
a, b = make_compatible(a, b)
c.data = add!(c.data, a.data, b.data)
return c
end

function add!(a::QQAbFieldElem, b::QQAbFieldElem)
a, b = make_compatible(a, b)
a.data = add!(a.data, b.data)
return a
end

function neg!(a::QQAbFieldElem)
mul!(a.data,a.data,-1)
a.data = neg!(a.data)
return a
end

function mul!(c::QQAbFieldElem, a::QQAbFieldElem, b::QQAbFieldElem)
a, b = make_compatible(a, b)
b, c = make_compatible(b, c)
a, b = make_compatible(a, b)
mul!(c.data, a.data, b.data)
c.data = mul!(c.data, a.data, b.data)
return c
end

function mul!(a::QQAbFieldElem, b::QQAbFieldElem)
a, b = make_compatible(a, b)
a.data = mul!(a.data, b.data)
return a
end

################################################################################
#
# Ad hoc binary operations
Expand Down Expand Up @@ -760,7 +774,7 @@ AbstractAlgebra.promote_rule(::Type{QQAbFieldElem}, ::Type{QQFieldElem}) = QQAbF
###############################################################################

function Oscar.root(a::QQAbFieldElem, n::Int)
Hecke.@req is_root_of_unity(a) "Element must be a root of unity"
@req is_root_of_unity(a) "Element must be a root of unity"
o = Oscar.order(a)
l = o*n
mu = root_of_unity2(parent(a), Int(l))
Expand Down
6 changes: 3 additions & 3 deletions src/Rings/MPolyQuo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,13 @@ end
#^(a::MPolyQuoRingElem, b::Base.Integer) = MPolyQuoRingElem(Base.power_by_squaring(a.f, b), a.P)

function Oscar.mul!(a::MPolyQuoRingElem, b::MPolyQuoRingElem, c::MPolyQuoRingElem)
a.f = b.f*c.f
a.f = b.f * c.f
a.simplified = false
return a
end

function Oscar.addeq!(a::MPolyQuoRingElem, b::MPolyQuoRingElem)
a.f += b.f
function Oscar.add!(a::MPolyQuoRingElem, b::MPolyQuoRingElem, c::MPolyQuoRingElem)
a.f = b.f + c.f
a.simplified = false
return a
end
Expand Down
5 changes: 0 additions & 5 deletions src/Rings/NumberField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,6 @@ function Oscar.add!(a::NfNSGenElem, b::NfNSGenElem, c::NfNSGenElem)
return a
end

function Oscar.addeq!(a::NfNSGenElem, b::NfNSGenElem)
a.f += b.f
return a
end

################################################################################
#
# Comparison
Expand Down
20 changes: 0 additions & 20 deletions src/Rings/localization_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -423,26 +423,6 @@ function Base.show(io::IO, W::AbsLocalizedRing)
end
end

function zero!(a::AbsLocalizedRingElem)
a = zero(parent(a))
return a
end

function mul!(c::T, a::T, b::T) where {T<:AbsLocalizedRingElem}
c = a*b
return c
end

function add!(c::T, a::T, b::T) where {T<:AbsLocalizedRingElem}
c = a+b
return c
end

function addeq!(a::T, b::T) where {T<:AbsLocalizedRingElem}
a = a+b
return a
end

### promotion rules
AbstractAlgebra.promote_rule(::Type{S}, ::Type{S}) where {S<:AbsLocalizedRingElem} = S

Expand Down
8 changes: 0 additions & 8 deletions src/Rings/mpoly-graded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,6 @@ end

^(a::MPolyDecRingElem, i::Int) = MPolyDecRingElem(forget_decoration(a)^i, parent(a))

function mul!(a::MPolyDecRingElem, b::MPolyDecRingElem, c::MPolyDecRingElem)
return b*c
end

function addeq!(a::MPolyDecRingElem, b::MPolyDecRingElem)
return a+b
end

length(a::MPolyDecRingElem) = length(forget_decoration(a))

@doc raw"""
Expand Down
5 changes: 0 additions & 5 deletions src/Rings/mpolyquo-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,6 @@ function +(a::T, b::T) where {T<:MPolyQuoLocRingElem}
return (parent(a))(lifted_numerator(a)*q + lifted_numerator(b)*p, new_den, check=false)
end

# TODO: improve this method.
function addeq!(a::T, b::T) where {T<:MPolyQuoLocRingElem}
a = a+b
return a
end

function -(a::T, b::T) where {T<:MPolyQuoLocRingElem}
return a + (-b)
Expand Down
20 changes: 10 additions & 10 deletions src/Rings/slpolys.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,26 +238,26 @@ function SLP.combine!(op::SLP.Op, p::SLPoly, q::SLPoly)
p
end

addeq!(p::SLPoly{T}, q::SLPoly{T}) where {T} = SLP.combine!(SLP.plus, p, q)
add!(p::SLPoly{T}, q::SLPoly{T}) where {T} = SLP.combine!(SLP.plus, p, q)

function add!(r::SLPoly{T}, p::SLPoly{T}, q::SLPoly{T}) where {T}
copy!(r.slprogram, p.slprogram)
addeq!(r, q)
add!(r, q)
r
end

SLP.subeq!(p::SLPoly{T}, q::SLPoly{T}) where {T} = SLP.combine!(SLP.minus, p, q)
sub!(p::SLPoly{T}, q::SLPoly{T}) where {T} = SLP.combine!(SLP.minus, p, q)

function SLP.subeq!(p::SLPoly)
function neg!(p::SLPoly)
SLP.combine!(SLP.uniminus, p.slprogram)
p
end

SLP.muleq!(p::SLPoly{T}, q::SLPoly{T}) where {T} = SLP.combine!(SLP.times, p, q)
mul!(p::SLPoly{T}, q::SLPoly{T}) where {T} = SLP.combine!(SLP.times, p, q)

function mul!(r::SLPoly{T}, p::SLPoly{T}, q::SLPoly{T}) where {T}
copy!(r.slprogram, p.slprogram)
SLP.muleq!(r, q)
mul!(r, q)
r
end

Expand All @@ -275,13 +275,13 @@ end

## unary/binary ops

+(p::SLPoly{T}, q::SLPoly{T}) where {T} = addeq!(copy(p), q)
+(p::SLPoly{T}, q::SLPoly{T}) where {T} = add!(copy(p), q)

*(p::SLPoly{T}, q::SLPoly{T}) where {T} = SLP.muleq!(copy(p), q)
*(p::SLPoly{T}, q::SLPoly{T}) where {T} = mul!(copy(p), q)

-(p::SLPoly{T}, q::SLPoly{T}) where {T} = SLP.subeq!(copy(p), q)
-(p::SLPoly{T}, q::SLPoly{T}) where {T} = sub!(copy(p), q)

-(p::SLPoly) = SLP.subeq!(copy(p))
-(p::SLPoly) = SLP.neg!(copy(p))

^(p::SLPoly, e::Base.Integer) = SLP.expeq!(copy(p), e)

Expand Down
2 changes: 1 addition & 1 deletion src/StraightLinePrograms/StraightLinePrograms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module StraightLinePrograms

import Base: +, -, *, ^, parent

import ..AbstractAlgebra: evaluate
import ..AbstractAlgebra: evaluate, add!, sub!, mul!, neg!

export AbstractSLProgram
export AtlasSLDecision
Expand Down
22 changes: 11 additions & 11 deletions src/StraightLinePrograms/straightline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,16 @@ end

## mutating ops

addeq!(p::SLProgram, q::SLProgram) = combine!(plus, p, q)
add!(p::SLProgram, q::SLProgram) = combine!(plus, p, q)

subeq!(p::SLProgram, q::SLProgram) = combine!(minus, p, q)
sub!(p::SLProgram, q::SLProgram) = combine!(minus, p, q)

function subeq!(p::SLProgram)
function neg!(p::SLProgram)
combine!(uniminus, p)
p
end

muleq!(p::SLProgram, q::SLProgram) = combine!(times, p, q)
mul!(p::SLProgram, q::SLProgram) = combine!(times, p, q)

function expeq!(p::SLProgram, e::Integer)
combine!(exponentiate, p, e)
Expand All @@ -564,13 +564,13 @@ end
copy_jointype(p::SLProgram, q::SLProgram) =
copy_oftype(p, typejoin(constantstype(p), constantstype(q)))

+(p::SLProgram, q::SLProgram) = addeq!(copy_jointype(p, q), q)
+(p::SLProgram, q::SLProgram) = add!(copy_jointype(p, q), q)

*(p::SLProgram, q::SLProgram) = muleq!(copy_jointype(p, q), q)
*(p::SLProgram, q::SLProgram) = mul!(copy_jointype(p, q), q)

-(p::SLProgram, q::SLProgram) = subeq!(copy_jointype(p, q), q)
-(p::SLProgram, q::SLProgram) = sub!(copy_jointype(p, q), q)

-(p::SLProgram) = subeq!(copy(p))
-(p::SLProgram) = neg!(copy(p))

^(p::SLProgram, e::Integer) = expeq!(copy(p), e)

Expand Down Expand Up @@ -708,7 +708,7 @@ retrieve(ints, cs, xs, res, i, conv::F=identity) where {F} =
function evaluate!(res::Vector{S}, p::SLProgram{T}, xs::Vector{S},
conv::F=identity) where {S,T,F}
# TODO: handle isempty(lines(p))
# TODO: use inplace (addeq!, mul!, ... ) when applicable
# TODO: use inplace (add!, mul!, ... ) when applicable
# TODO: add permutation of input?
empty!(res)

Expand Down Expand Up @@ -825,13 +825,13 @@ function compile!(p::SLProgram; isPoly::Bool = false)
mininput = max(mininput, idy)
if isplus(op)
if idx == 0 && isPoly
:($rk = Nemo.addeq!($x, $y))
:($rk = Nemo.add!($x, $y))
else
:($rk = $x + $y)
end
elseif isminus(op)
if idx == 0 && isPoly
:($rk = Nemo.subeq!($x, $y))
:($rk = Nemo.sub!($x, $y))
else
:($rk = $x - $y)
end
Expand Down
Loading

0 comments on commit 6029c59

Please sign in to comment.