diff --git a/src/Misc/Poly.jl b/src/Misc/Poly.jl index 4398eeb38c..e1a0d9ff41 100644 --- a/src/Misc/Poly.jl +++ b/src/Misc/Poly.jl @@ -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) diff --git a/src/NumFieldOrd/NfOrd/Ideal/Valuation.jl b/src/NumFieldOrd/NfOrd/Ideal/Valuation.jl index d9c572be68..4cd2ef2a5a 100644 --- a/src/NumFieldOrd/NfOrd/Ideal/Valuation.jl +++ b/src/NumFieldOrd/NfOrd/Ideal/Valuation.jl @@ -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() diff --git a/test/Misc/Poly.jl b/test/Misc/Poly.jl index 45273b6ccd..e6ff83e384 100644 --- a/test/Misc/Poly.jl +++ b/test/Misc/Poly.jl @@ -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 diff --git a/test/NfOrd/Ideal/Prime.jl b/test/NfOrd/Ideal/Prime.jl index 7727f9fb32..74491dfa52 100644 --- a/test/NfOrd/Ideal/Prime.jl +++ b/test/NfOrd/Ideal/Prime.jl @@ -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