Skip to content

Commit

Permalink
Fix 1509 (thofma#1511)
Browse files Browse the repository at this point in the history
  • Loading branch information
joschmitt authored May 16, 2024
1 parent 63b23ed commit f9a2779
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 19 deletions.
36 changes: 18 additions & 18 deletions src/LocalField/Completions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function image(f::CompletionMap, a::AbsSimpleNumFieldElem)
end
Qx = parent(parent(a).pol)
z = evaluate(Qx(a), f.prim_img)
if !is_unit(z)
if !is_unit(z)
v = valuation(a, f.P)
a = a*uniformizer(f.P).elem_in_nf^-v
z = evaluate(Qx(a), f.prim_img)
Expand All @@ -27,7 +27,7 @@ function preimage(f::CompletionMap{LocalField{QadicFieldElem, EisensteinLocalFie
coeffs = Vector{AbsSimpleNumFieldElem}()
#careful: we're working in a limited precision world and the lift
#can be waaaay to large
if abs(valuation(a)) > 100
if !iszero(a) && abs(valuation(a)) > 100
global last_a = a
error("elem too large")
end
Expand Down Expand Up @@ -131,7 +131,7 @@ The map giving the embedding of $K$ into the completion, admits a pointwise
preimage to obtain a lift. Note, that the map is not well defined by this
data: $K$ will have $\deg P$ many embeddings.
The map is guaranteed to yield a relative precision of at least `preciscion`.
The map is guaranteed to yield a relative precision of at least `preciscion`.
"""
function completion(K::AbsSimpleNumField, P::AbsNumFieldOrderIdeal{AbsSimpleNumField, AbsSimpleNumFieldElem}, precision::Int = 64)
#to guarantee a rel_prec we need to account for the index (or the
Expand Down Expand Up @@ -179,7 +179,7 @@ function completion(K::AbsSimpleNumField, P::AbsNumFieldOrderIdeal{AbsSimpleNumF
img_prim_elem[i] = coeff
end
img = Kp(Qqx(img_prim_elem))

u = uniformizer(P).elem_in_nf
completion_map = CompletionMap(K, Kp, img, (gq_in_K, u), precision)
completion_map.P = P
Expand All @@ -193,7 +193,7 @@ function _solve_internal(gq_in_K, P, precision, Zp, Qq)
precision += e - (precision % e)
@assert precision % e == 0
#problem/ feature:
#the lin. alg is done in/over Zp or Qp, thus precision is measured in
#the lin. alg is done in/over Zp or Qp, thus precision is measured in
#block of length e (power of the prime number p, rather than powers of
#pi, the prime element)
#so it is a good idea to increase the precision to be divisible by e
Expand Down Expand Up @@ -231,7 +231,7 @@ if true
# the can_solve... returns a precision of just 6 p-adic digits
# the snf gets 16 (both for the default precision)
# the det(M) has valuation 12, but the elem. divisors only 3
#TODO: rewrite can_solve? look at Avi's stuff?
#TODO: rewrite can_solve? look at Avi's stuff?
# x M = b
# u*M*v = s
# x inv(u) u M v = b v
Expand All @@ -251,7 +251,7 @@ else
bZp = map_entries(Zp, bK.num)
fl, xZp = can_solve_with_solution(MZp, bZp, side = :left)
@assert fl
end
end
coeffs_eisenstein = Vector{QadicFieldElem}(undef, e+1)
gQq = gen(Qq)
for i = 1:e
Expand All @@ -276,7 +276,7 @@ function setprecision!(f::CompletionMap{LocalField{QadicFieldElem, EisensteinLoc
new_prec += valuation(denominator(basis_matrix(OK, copy = false)), P)

if new_prec < f.precision
K = domain(f)
K = codomain(f)
setprecision!(K, new_prec)
e = ramification_index(P)
setprecision!(base_field(K), div(new_prec+e-1, e))
Expand All @@ -296,7 +296,7 @@ function setprecision!(f::CompletionMap{LocalField{QadicFieldElem, EisensteinLoc

Zp = maximal_order(prime_field(Kp))
Qq = base_field(Kp)

setprecision!(Qq, ex)
setprecision!(Zp, ex)
gQq = gen(Qq)
Expand Down Expand Up @@ -385,11 +385,12 @@ end

function setprecision!(f::CompletionMap{LocalField{PadicFieldElem, EisensteinLocalField}, LocalFieldElem{PadicFieldElem, EisensteinLocalField}}, new_prec::Int)
if new_prec < f.precision
K = domain(f)
setprecision!(K, new_prec)
setprecision!(base_field(K), new_prec)
Kp = codomain(f)
setprecision!(Kp, new_prec)
setprecision!(base_field(Kp), new_prec)
setprecision!(f.prim_img, new_prec)
else
K = domain(f)
#I need to increase the precision of the data
P = prime(f)
e = ramification_index(P)
Expand All @@ -402,13 +403,13 @@ function setprecision!(f::CompletionMap{LocalField{PadicFieldElem, EisensteinLoc
end
Qp = PadicField(prime(Kp), div(new_prec, e)+1)
Zp = maximal_order(Qp)
Qpx = polynomial_ring(Qp, "x")
Qpx, _ = polynomial_ring(Qp, "x")
pows_u = powers(u, e-1)
bK = basis_matrix(AbsSimpleNumFieldElem[u*pows_u[end], gen(K)])
append!(pows_u, map(elem_in_nf, basis(P^new_prec, copy = false)))
MK = basis_matrix(pows_u)
MQp = map_entries(Zp, MK)
bQp = map_entries(Zp, bK)
MZp = map_entries(Zp, MK)
bZp = map_entries(Zp, bK)
fl, xZp = can_solve_with_solution(MZp, bZp, side = :left)
@assert fl
coeffs_eisenstein = Vector{PadicFieldElem}(undef, e+1)
Expand Down Expand Up @@ -501,14 +502,13 @@ function setprecision!(f::CompletionMap{QadicField, QadicFieldElem}, new_prec::I
setprecision!(f.prim_img, new_prec)
else
P = prime(f)
f = inertia_degree(P)
gq, u = f.inv_img
Zx = polynomial_ring(FlintZZ, "x")[1]
q, mq = residue_field(Kp)
pol_gq = lift(Zx, defining_polynomial(q))
gq = _increase_precision(gq, pol_gq, f.precision, new_prec, P)
f.inv_img[1] = gq
setprecision!(Qq, new_prec)
f.inv_img = (gq, u)
setprecision!(Kp, new_prec)
#To increase the precision of the image of the primitive element, I use Hensel lifting
f.prim_img = newton_lift(Zx(defining_polynomial(domain(f))), f.prim_img, new_prec, f.precision)
end
Expand Down
26 changes: 25 additions & 1 deletion test/LocalField/Completions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@ end
@test precision(bb) >= 20
end

@testset "Issue 1509" begin
F, _ = cyclotomic_field(3)
OF = maximal_order(F);
K, toK = completion(F, 2*OF);
@test iszero(preimage(toK, toK(F(0))))
setprecision!(toK, 10)
@test precision(toK(F(1))) == 10
setprecision!(toK, 70)
@test precision(toK(F(1))) == 70

K, toK = Hecke.unramified_completion(F, 2*OF)
setprecision!(toK, 10)
@test precision(toK(F(1))) == 10
setprecision!(toK, 70)
@test precision(toK(F(1))) == 70

P = prime_decomposition(OF, 7)[1][1]
K, toK = Hecke.totally_ramified_completion(F, P)
setprecision!(toK, 10)
@test precision(toK(F(1))) == 10
setprecision!(toK, 70)
@test precision(toK(F(1))) == 70
end

@testset "another issue" begin
Qx, x = QQ["x"]
K, a = number_field(Qx([-881539931206823616,457325902411822080,16029750347584272,-124243211029392,-1536813216432,10162275552,33311655,-246753,0,1]), "a", cached = false)
Expand Down Expand Up @@ -71,7 +95,7 @@ end
end
end

let
let
Qx, x = QQ["x"]
t = [
(x^2 - 3, 3, 1//2), # C2
Expand Down

0 comments on commit f9a2779

Please sign in to comment.