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

fix: valuation for inert primes #1708

Merged
merged 1 commit into from
Dec 20, 2024
Merged
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
8 changes: 8 additions & 0 deletions src/Misc/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ function hensel_lift(f::ZZPolyRingElem, g::ZZPolyRingElem, h::ZZPolyRingElem, p:
## is essentially f and f would be a legal answer. Probably reduced mod p^k
## with all non-negative coefficients
## for now:
if is_one(g)
h = mod(h, p^k)
return g, h
elseif is_one(h)
g = mod(g, p^k)
return g, h
end

@assert !iszero(a) && !iszero(b)
a = lift(parent(g), a)
b = lift(parent(g), b)
Expand Down
7 changes: 6 additions & 1 deletion src/NumFieldOrd/NfOrd/Ideal/Valuation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ function val_func_no_index_small(p::AbsNumFieldOrderIdeal{AbsSimpleNumField, Abs
gR = gcd!(gR, gR, f)
g = lift(Zx, gR)
k = flog(ZZRingElem(typemax(UInt)), P)
g = hensel_lift(Zx(K.pol), g, P, k)
if degree(p) == degree(K)
# inert prime, K.pol is irreducible mod p
g = Zx(K.pol)
else
g = hensel_lift(Zx(K.pol), g, P, k)
end
Sx = polynomial_ring(residue_ring(ZZ, UInt(P)^k, cached=false)[1], cached=false)[1]
g = Sx(g)
h = Sx()
Expand Down
9 changes: 9 additions & 0 deletions test/Misc/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,13 @@ end
end
end

@testset "hensel" begin
Zx, x = ZZ["x"]
f = x^2 + x + 1
h = one(Zx)
(gg, hh) = hensel_lift(f, f, h, ZZ(2), 2)
@test mod(gg * hh, ZZ(4)) == mod(f, ZZ(4))
(gg, hh) = hensel_lift(f, h, f, ZZ(2), 2)
@test mod(gg * hh, ZZ(4)) == mod(f, ZZ(4))
end

6 changes: 6 additions & 0 deletions test/NfOrd/Ideal/Prime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,9 @@ E = pmaximal_overorder(O, 23)
lp = prime_decomposition(E, 23)
@test length(lp) == 2

let
# valuation for large degree, inert prime
K, a = cyclotomic_real_subfield(101, :a)
P, = prime_ideals_over(maximal_order(K), 10007)
@test valuation(gen(K), P) == 0
end
Loading