Skip to content

Commit

Permalink
fix: valuation for inert primes
Browse files Browse the repository at this point in the history
- also fix Hensel lifting in the trivial case
  • Loading branch information
thofma committed Dec 20, 2024
1 parent 9f4ccb9 commit 1534667
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
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

0 comments on commit 1534667

Please sign in to comment.