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

Support for arbitrary ring morphisms with number field domains #1324

Merged
merged 1 commit into from
Dec 15, 2023
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Hecke"
uuid = "3e1990a7-5d81-5526-99ce-9ba3ff248f21"
version = "0.23.2-DEV"
version = "0.23.2"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Expand Down
22 changes: 16 additions & 6 deletions src/Map/NumField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ end
function hom(K::S, L::T, x...; inverse = nothing,
check::Bool = true,
compute_inverse = false) where {S <: Union{NumField, QQField},
T <: NumField}
T <: Ring}
header = MapHeader(K, L)

#if length(x) == 0
Expand All @@ -166,7 +166,7 @@ function hom(K::S, L::T, x...; inverse = nothing,
typeof(inverse_data)}(header, image_data, inverse_data)

else
z = NumFieldMor{S, T, typeof(image_data), map_data_type(L, K)}()
z = NumFieldMor{S, T, typeof(image_data), map_data_type(L, K)}()
end

z.header = header
Expand Down Expand Up @@ -245,9 +245,9 @@ mutable struct MapDataFromAnticNumberField{T}
end

# Helper functions to create the type
map_data_type(K::AnticNumberField, L::Union{NumField, QQField}) = map_data_type(AnticNumberField, typeof(L))
map_data_type(K::AnticNumberField, L::Union{NumField, QQField, Ring}) = map_data_type(AnticNumberField, typeof(L))

map_data_type(::Type{AnticNumberField}, T::Type{S}) where {S <: Union{NumField, QQField}} = MapDataFromAnticNumberField{elem_type(T)}
map_data_type(::Type{AnticNumberField}, T::Type{S}) where {S <: Union{NumField, QQField, Ring}} = MapDataFromAnticNumberField{elem_type(T)}

# Test if data u, v specfiying a map K -> L define the same morphism
function _isequal(K, L, u::MapDataFromAnticNumberField{T},
Expand All @@ -272,7 +272,7 @@ end
#
map_data(K::AnticNumberField, L, ::Bool) = MapDataFromAnticNumberField{elem_type(L)}(true)

function map_data(K::AnticNumberField, L, x::NumFieldElem; check = true)
function map_data(K::AnticNumberField, L, x::RingElement; check = true)
if parent(x) === L
xx = x
else
Expand Down Expand Up @@ -322,7 +322,7 @@ function map_data_type(T::Type{<: NfRel}, L::Type{<:Any})
MapDataFromNfRel{elem_type(L), map_data_type(base_field_type(T), L)}
end

map_data_type(K::NfRel, L::NumField) = map_data_type(typeof(K), typeof(L))
map_data_type(K::NfRel, L::Ring) = map_data_type(typeof(K), typeof(L))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicate to line 1041

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm yes, all the f(x, y) = f(typeof(x), typeof(y)) could be consolidated. But I don't have time for this clean up now.


# Test if data u, v specfiying a map K -> L define the same morphism
function _isequal(K, L, u::MapDataFromNfRel{T, S}, v::MapDataFromNfRel{T, S}) where {T, S}
Expand Down Expand Up @@ -1030,6 +1030,16 @@ end

Base.hash(f::NumFieldMor, h::UInt) = hash(f.image_data, domain(f), codomain(f), h)

################################################################################
#
# Catch all for morphisms into arbitrary rings
#
################################################################################

map_data_type(::Type{<: Any}, x) = Nothing

map_data_type(R, x) = map_data_type(typeof(R), typeof(x))

################################################################################
#
# Restriction
Expand Down
15 changes: 15 additions & 0 deletions test/Map/NumField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,19 @@
D = Dict(f => 1)
@test haskey(D, g)
end

# Maps into arbitrary rings
begin
K, a = quadratic_field(-1);
Kx, x = K["x"]
h = @inferred hom(K, Kx, Kx(a))
@test h(a + 1) == Kx(a + 1)

Qx, x = QQ["x"]
K, a = number_field([x - 1, x - 2])
QQy, y = polynomial_ring(QQ, 2)
@test_throws ErrorException hom(K, QQy, [0, 0])
h = @inferred hom(K, QQy, [1, 2])
@test h(a[1] + a[2]) == QQy(3)
end
end
Loading