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

feat: add residue ring/field maps #1559

Merged
merged 1 commit into from
Jan 23, 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
1 change: 0 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ makedocs(
"function_field.md",
"finfield.md",
"real.md",
"numberfield.md",
],
"Groups" => [
"perm.md",
Expand Down
7 changes: 3 additions & 4 deletions docs/src/constructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ AbstractAlgebra.jl and explain what mathematical domains they represent.
| $R = \mathbb{Z}$ | `R = ZZ` |
| $R = \mathbb{Q}$ | `R = QQ` |
| $R = \mathbb{F}_{p}$ | `R = GF(p)` |
| $R = \mathbb{Z}/n\mathbb{Z}$ | `R = residue_ring(ZZ, n)` |
| $R = \mathbb{Z}/n\mathbb{Z}$ | `R, = residue_ring(ZZ, n)` |
| $S = R[x]$ | `S, x = polynomial_ring(R, :x)` |
| $S = R[x, y]$ | `S, (x, y) = polynomial_ring(R, [:x, :y])` |
| $S = R\langle x, y\rangle$ | `S, (x, y) = free_associative_algebra(R, [:x, :y])` |
Expand All @@ -77,10 +77,9 @@ AbstractAlgebra.jl and explain what mathematical domains they represent.
| Puiseux series field to precision $n$| `S, x = puiseux_series_field(R, n, :x)` |
| $S = K(x)(y)/(f)$ | `S, y = function_field(f, :y)` with $f\in K(x)[t]$ |
| $S = \mathrm{Frac}_R$ | `S = fraction_field(R)` |
| $S = R/(f)$ | `S = residue_ring(R, f)` |
| $S = R/(f)$ (with $(f)$ maximal) | `S = residue_field(R, f)` |
| $S = R/(f)$ | `S, = residue_ring(R, f)` |
| $S = R/(f)$ (with $(f)$ maximal) | `S, = residue_field(R, f)` |
| $S = \mathrm{Mat}_{m\times n}(R)$ | `S = matrix_space(R, m, n)` |
| $S = \mathbb{Q}[x]/(f)$ | `S, a = number_field(f, :a)` |

## Parent objects with variable names

Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ R = GF(7)

S, y = polynomial_ring(R, "y")

T = residue_ring(S, y^3 + 3y + 1)
T, = residue_ring(S, y^3 + 3y + 1)

U, z = polynomial_ring(T, "z")

Expand Down
15 changes: 5 additions & 10 deletions docs/src/matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,7 @@ fflu{T <: RingElem}(::MatElem{T}, ::SymmetricGroup)
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> K, a = number_field(x^3 + 3x + 1, "a")
(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x)
julia> K, = residue_field(R, x^3 + 3x + 1); a = K(x);

julia> S = matrix_space(K, 3, 3)
Matrix space of 3 rows and 3 columns
Expand Down Expand Up @@ -865,8 +864,7 @@ is_rref{T <: FieldElem}(::MatElem{T})
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> K, a = number_field(x^3 + 3x + 1, "a")
(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x)
julia> K, = residue_field(R, x^3 + 3x + 1); a = K(x);

julia> S = matrix_space(K, 3, 3)
Matrix space of 3 rows and 3 columns
Expand Down Expand Up @@ -995,8 +993,7 @@ can_solve_left_reduced_triu{T <: RingElement}(::MatElem{T}, ::MatElem{T})
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> K, a = number_field(x^3 + 3x + 1, "a")
(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x)
julia> K, = residue_field(R, x^3 + 3x + 1); a = K(x);

julia> S = matrix_space(K, 3, 3)
Matrix space of 3 rows and 3 columns
Expand Down Expand Up @@ -1120,8 +1117,7 @@ is_invertible{T <: RingElement}(::MatrixElem{T})
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> K, a = number_field(x^3 + 3x + 1, "a")
(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x)
julia> K, = residue_field(R, x^3 + 3x + 1); a = K(x);

julia> S = matrix_space(K, 3, 3)
Matrix space of 3 rows and 3 columns
Expand Down Expand Up @@ -1211,8 +1207,7 @@ is_hessenberg{T <: RingElem}(::MatElem{T})
**Examples**

```jldoctest
julia> R = residue_ring(ZZ, 7)
Residue ring of integers modulo 7
julia> R, = residue_ring(ZZ, 7);

julia> S = matrix_space(R, 4, 4)
Matrix space of 4 rows and 4 columns
Expand Down
54 changes: 0 additions & 54 deletions docs/src/numberfield.md

This file was deleted.

9 changes: 3 additions & 6 deletions docs/src/polynomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ gcdinv(f::PolyRingElem, g::PolyRingElem)
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> S = residue_ring(R, x^3 + 3x + 1)
Residue ring of univariate polynomial ring modulo x^3 + 3*x + 1
julia> S, = residue_ring(R, x^3 + 3x + 1);

julia> T, y = polynomial_ring(S, "y")
(Univariate polynomial ring in y over residue ring, y)
Expand Down Expand Up @@ -464,8 +463,7 @@ julia> S, y = polynomial_ring(R, "y")
julia> T, z = polynomial_ring(QQ, "z")
(Univariate polynomial ring in z over rationals, z)

julia> U = residue_ring(ZZ, 17)
Residue ring of integers modulo 17
julia> U, = residue_ring(ZZ, 17);

julia> V, w = polynomial_ring(U, "w")
(Univariate polynomial ring in w over residue ring, w)
Expand Down Expand Up @@ -859,8 +857,7 @@ julia> S, y = polynomial_ring(R, "y")
julia> T, z = polynomial_ring(QQ, "z")
(Univariate polynomial ring in z over rationals, z)

julia> U = residue_ring(T, z^3 + 3z + 1)
Residue ring of univariate polynomial ring modulo z^3 + 3*z + 1
julia> U, = residue_ring(T, z^3 + 3z + 1);

julia> V, w = polynomial_ring(U, "w")
(Univariate polynomial ring in w over residue ring, w)
Expand Down
23 changes: 8 additions & 15 deletions docs/src/residue.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ residue_field(R::Ring, m::RingElem; cached::Bool = true)
```

Given a base ring `R` and residue $m$ contained in this ring, return the parent object
of the residue ring $R/(m)$. By default the parent object `S` will depend only on `R`
and `m` and will be cached. Setting the optional argument `cached` to `false` will
of the residue ring $R/(m)$ together with the canonical projection. By default
the parent object `S` will depend only on `R` and `m` and will be cached.
Setting the optional argument `cached` to `false` will
prevent the parent object `S` from being cached.

The `residue_field` constructor does the same thing as the `residue_ring` constructor,
Expand All @@ -71,8 +72,7 @@ resulting parent objects to coerce various elements into the residue ring.
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> S = residue_ring(R, x^3 + 3x + 1)
Residue ring of univariate polynomial ring modulo x^3 + 3*x + 1
julia> S, = residue_ring(R, x^3 + 3x + 1);

julia> f = S()
0
Expand Down Expand Up @@ -174,8 +174,7 @@ modulus(::ResElem)
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> S = residue_ring(R, x^3 + 3x + 1)
Residue ring of univariate polynomial ring modulo x^3 + 3*x + 1
julia> S, = residue_ring(R, x^3 + 3x + 1);

julia> f = S(x + 1)
x + 1
Expand Down Expand Up @@ -229,8 +228,7 @@ Base.inv(::ResElem)
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> S = residue_ring(R, x^3 + 3x + 1)
Residue ring of univariate polynomial ring modulo x^3 + 3*x + 1
julia> S, = residue_ring(R, x^3 + 3x + 1);

julia> f = S(x + 1)
x + 1
Expand All @@ -252,8 +250,7 @@ gcd{T <: RingElem}(::ResElem{T}, ::ResElem{T})
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> S = residue_ring(R, x^3 + 3x + 1)
Residue ring of univariate polynomial ring modulo x^3 + 3*x + 1
julia> S, = residue_ring(R, x^3 + 3x + 1);

julia> f = S(x + 1)
x + 1
Expand Down Expand Up @@ -304,18 +301,14 @@ rand(R::ResidueRing, v...)
**Examples**

```jldoctest; setup = :(import Random; Random.seed!(42))
julia> R = residue_ring(ZZ, 7)
Residue ring of integers modulo 7
julia> R, = residue_ring(ZZ, 7);

julia> f = rand(R, 0:6)
4

julia> S, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> U = residue_field(S, x^3 + 3x + 1)
Residue field of univariate polynomial ring modulo x^3 + 3*x + 1

julia> g = rand(S, 2:2, -10:10)
-1//4*x^2 - 2//7*x + 1
```
3 changes: 1 addition & 2 deletions docs/src/total_fraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ rand(R::TotFracRing, v...)
**Examples**

```jldoctest; setup = :(import Random; Random.seed!(42))
julia> R = residue_ring(ZZ, 12)
Residue ring of integers modulo 12
julia> R, = residue_ring(ZZ, 12);
julia> K = total_ring_of_fractions(R)
Total ring of fractions of Residue ring of integers modulo 12
Expand Down
2 changes: 1 addition & 1 deletion docs/src/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ corresponding to the ring $\mathbb{Z}/7\mathbb{Z}$. We then create a new element
of this ring by calling the parent object `R`.

```julia
R = residue_ring(ZZ, 7)
R, = residue_ring(ZZ, 7)
a = R(3)
```

Expand Down
8 changes: 5 additions & 3 deletions src/AbstractAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import GroupsCore: gens, ngens, order, mul!, istrivial

# A list of all symbols external packages should not import from AbstractAlgebra
const import_exclude = [:import_exclude, :QQ, :ZZ,
:RealField, :number_field, :NumberField, :GF,
:RealField, :GF,
:AbstractAlgebra,
:inv, :log, :exp, :sqrt, :div, :divrem,
:numerator, :denominator,
Expand Down Expand Up @@ -655,6 +655,8 @@ import .Generic: dense_matrix_type
import .Generic: dim
import .Generic: disable_cache!
import .Generic: downscale
import .Generic: EuclideanRingResidueField
import .Generic: EuclideanRingResidueRing
import .Generic: enable_cache!
import .Generic: exp_gcd
import .Generic: exponent
Expand Down Expand Up @@ -716,7 +718,6 @@ import .Generic: norm
import .Generic: normal_form
import .Generic: normalise
import .Generic: num_coeff
import .Generic: number_field
import .Generic: one
import .Generic: order
import .Generic: ordering
Expand Down Expand Up @@ -861,6 +862,8 @@ export divhigh
export divides
export domain
export downscale
export EuclideanRingResidueField
export EuclideanRingResidueRing
export elem_type
export enable_cache!
export evaluate
Expand Down Expand Up @@ -1047,7 +1050,6 @@ export normalise
export nrows
export nullspace
export num_coeff
export number_field
export nvars
export O
export one
Expand Down
1 change: 0 additions & 1 deletion src/Aliases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Base.@deprecate_binding LaurentPolynomialRing laurent_polynomial_ring
Base.@deprecate_binding LaurentSeriesRing laurent_series_ring
Base.@deprecate_binding LaurentSeriesField laurent_series_field
Base.@deprecate_binding FractionField fraction_field
Base.@deprecate_binding NumberField number_field

Base.@deprecate_binding FunctionField function_field
Base.@deprecate_binding RationalFunctionField rational_function_field
Expand Down
2 changes: 0 additions & 2 deletions src/Generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,6 @@ include("generic/Residue.jl")

include("generic/ResidueField.jl")

include("generic/NumberField.jl")

include("generic/Poly.jl")

include("generic/NCPoly.jl")
Expand Down
39 changes: 6 additions & 33 deletions src/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2226,21 +2226,10 @@ Return the determinant of the matrix $M$. We assume $M$ is square.
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> K, a = number_field(x^3 + 3x + 1, "a")
(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x)

julia> S = matrix_space(K, 3, 3)
Matrix space of 3 rows and 3 columns
over residue field of univariate polynomial ring modulo x^3 + 3*x + 1

julia> A = S([K(0) 2a + 3 a^2 + 1; a^2 - 2 a - 1 2a; a^2 + 3a + 1 2a K(1)])
[ 0 2*x + 3 x^2 + 1]
[ x^2 - 2 x - 1 2*x]
[x^2 + 3*x + 1 2*x 1]
julia> A = R[x 1; 1 x^2];

julia> d = det(A)
11*x^2 - 30*x - 5

x^3 - 1
```
"""
function det(M::MatrixElem{T}) where {T <: RingElement}
Expand Down Expand Up @@ -2599,24 +2588,10 @@ Return the rank of the matrix $M$.
# Examples

```jldoctest; setup = :(using AbstractAlgebra)
julia> R, x = polynomial_ring(QQ, "x")
(Univariate polynomial ring in x over rationals, x)

julia> K, a = number_field(x^3 + 3x + 1, "a")
(Residue field of univariate polynomial ring modulo x^3 + 3*x + 1, x)

julia> S = matrix_space(K, 3, 3)
Matrix space of 3 rows and 3 columns
over residue field of univariate polynomial ring modulo x^3 + 3*x + 1

julia> A = S([K(0) 2a + 3 a^2 + 1; a^2 - 2 a - 1 2a; a^2 + 3a + 1 2a K(1)])
[ 0 2*x + 3 x^2 + 1]
[ x^2 - 2 x - 1 2*x]
[x^2 + 3*x + 1 2*x 1]
julia> A = QQ[1 2; 3 4];

julia> d = rank(A)
3

2
```
"""
function rank(M::MatrixElem{T}) where {T <: RingElement}
Expand Down Expand Up @@ -4469,8 +4444,7 @@ the resulting polynomial is an element of it.
# Examples

```jldoctest; setup = :(using AbstractAlgebra)
julia> R = residue_ring(ZZ, 7)
Residue ring of integers modulo 7
julia> R, = residue_ring(ZZ, 7);

julia> S = matrix_space(R, 4, 4)
Matrix space of 4 rows and 4 columns
Expand Down Expand Up @@ -6276,8 +6250,7 @@ preserves the minimal and characteristic polynomials of a matrix.
# Examples

```jldoctest; setup = :(using AbstractAlgebra)
julia> R = residue_ring(ZZ, 7)
Residue ring of integers modulo 7
julia> R, = residue_ring(ZZ, 7);

julia> S = matrix_space(R, 4, 4)
Matrix space of 4 rows and 4 columns
Expand Down
Loading
Loading