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

Rename FreeAssAlgebra and FreeAssAlgElem #1779

Merged
merged 5 commits into from
Aug 28, 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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "AbstractAlgebra"
uuid = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
version = "0.42.2"
version = "0.42.3"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down
74 changes: 37 additions & 37 deletions docs/src/free_associative_algebra.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ end

# Free algebras

AbstractAlgebra.jl provides a module, implemented in `src/FreeAssAlgebra.jl` for
AbstractAlgebra.jl provides a module, implemented in `src/FreeAssociativeAlgebra.jl` for
free associative algebras over any commutative ring belonging to the
AbstractAlgebra abstract type hierarchy.

## Generic free algebra types

AbstractAlgebra provides a generic type `Generic.FreeAssAlgElem{T}`
AbstractAlgebra provides a generic type `Generic.FreeAssociativeAlgebraElem{T}`
where `T` is the type of elements of the coefficient ring. The elements are
implemented using a Julia array of coefficients and a vector of
vectors of `Int`s for the monomial words. Parent objects of such elements have
type `Generic.FreeAssAlgebra{T}`.
type `Generic.FreeAssociativeAlgebra{T}`.

The element types belong to the abstract type `NCRingElem`,
and the algebra types belong to the abstract type `NCRing`.

The following basic functions are implemented.
```julia
base_ring(R::FreeAssAlgebra)
base_ring(a::FreeAssAlgElem)
parent(a::FreeAssAlgElem)
characteristic(R::FreeAssAlgebra)
base_ring(R::FreeAssociativeAlgebra)
base_ring(a::FreeAssociativeAlgebraElem)
parent(a::FreeAssociativeAlgebraElem)
characteristic(R::FreeAssociativeAlgebra)
```

## Free algebra constructors
Expand All @@ -53,7 +53,7 @@ the parent object `S` from being cached.

```jldoctest
julia> R, (x, y) = free_associative_algebra(ZZ, ["x", "y"])
(Free associative algebra on 2 indeterminates over integers, AbstractAlgebra.Generic.FreeAssAlgElem{BigInt}[x, y])
(Free associative algebra on 2 indeterminates over integers, AbstractAlgebra.Generic.FreeAssociativeAlgebraElem{BigInt}[x, y])

julia> (x + y + 1)^2
x^2 + x*y + y*x + y^2 + 2*x + 2*y + 1
Expand All @@ -74,7 +74,7 @@ with coefficients and monomial words and not exponent vectors.

```jldoctest
julia> R, (x, y, z) = free_associative_algebra(ZZ, ["x", "y", "z"])
(Free associative algebra on 3 indeterminates over integers, AbstractAlgebra.Generic.FreeAssAlgElem{BigInt}[x, y, z])
(Free associative algebra on 3 indeterminates over integers, AbstractAlgebra.Generic.FreeAssociativeAlgebraElem{BigInt}[x, y, z])

julia> B = MPolyBuildCtx(R)
Builder for an element of free associative algebra
Expand All @@ -86,7 +86,7 @@ julia> push_term!(B, ZZ(3), [3,3,3]); push_term!(B, ZZ(4), Int[]); finish(B)
3*z^3 + 4

julia> [gen(R, 2), R(9)]
2-element Vector{AbstractAlgebra.Generic.FreeAssAlgElem{BigInt}}:
2-element Vector{AbstractAlgebra.Generic.FreeAssociativeAlgebraElem{BigInt}}:
y
9
```
Expand All @@ -99,13 +99,13 @@ The standard ring functions are available. The following functions from the
multivariate polynomial interface are provided.

```julia
symbols(S::FreeAssAlgebra)
number_of_variables(f::FreeAssAlgebra)
gens(S::FreeAssAlgebra)
gen(S::FreeAssAlgebra, i::Int)
is_gen(x::FreeAssAlgElem)
total_degree(a::FreeAssAlgElem)
length(f::FreeAssAlgElem)
symbols(S::FreeAssociativeAlgebra)
number_of_variables(f::FreeAssociativeAlgebra)
gens(S::FreeAssociativeAlgebra)
gen(S::FreeAssociativeAlgebra, i::Int)
is_gen(x::FreeAssociativeAlgebraElem)
total_degree(a::FreeAssociativeAlgebraElem)
length(f::FreeAssociativeAlgebraElem)
```

As with multivariate polynomials, an implementation must provide access to
Expand All @@ -115,34 +115,34 @@ provide the first such term.


```julia
leading_coefficient(a::FreeAssAlgElem)
leading_monomial(a::FreeAssAlgElem)
leading_term(a::FreeAssAlgElem)
leading_exponent_word(a::FreeAssAlgElem)
leading_coefficient(a::FreeAssociativeAlgebraElem)
leading_monomial(a::FreeAssociativeAlgebraElem)
leading_term(a::FreeAssociativeAlgebraElem)
leading_exponent_word(a::FreeAssociativeAlgebraElem)
```

For types that allow constant time access to coefficients, the following are
also available, allowing access to the given coefficient, monomial or term.
Terms are numbered from the most significant first.

```julia
coeff(f::FreeAssAlgElem, n::Int)
monomial(f::FreeAssAlgElem, n::Int)
term(f::FreeAssAlgElem, n::Int)
coeff(f::FreeAssociativeAlgebraElem, n::Int)
monomial(f::FreeAssociativeAlgebraElem, n::Int)
term(f::FreeAssociativeAlgebraElem, n::Int)
```

In contrast with the interface for multivariable polynomials, the function
`exponent_vector` is replaced by `exponent_word`

```@docs
exponent_word(a::Generic.FreeAssAlgElem{T}, i::Int) where T <: RingElement
exponent_word(a::Generic.FreeAssociativeAlgebraElem{T}, i::Int) where T <: RingElement
```

**Examples**

```jldoctest
julia> R, (x, y, z) = free_associative_algebra(ZZ, ["x", "y", "z"])
(Free associative algebra on 3 indeterminates over integers, AbstractAlgebra.Generic.FreeAssAlgElem{BigInt}[x, y, z])
(Free associative algebra on 3 indeterminates over integers, AbstractAlgebra.Generic.FreeAssociativeAlgebraElem{BigInt}[x, y, z])

julia> map(total_degree, (R(0), R(1), -x^2*y^2*z^2*x + z*y))
(-1, 0, 7)
Expand All @@ -168,7 +168,7 @@ julia> exponent_word(-x^2*y^2*z^2*x + z*y, 1)
```

```@docs
evaluate(a::AbstractAlgebra.FreeAssAlgElem{T}, vals::Vector{U}) where {T <: RingElement, U <: NCRingElem}
evaluate(a::AbstractAlgebra.FreeAssociativeAlgebraElem{T}, vals::Vector{U}) where {T <: RingElement, U <: NCRingElem}
```

### Iterators
Expand All @@ -178,20 +178,20 @@ with `exponent_words` providing the analogous functionality that `exponent_vecto
provides for multivariate polynomials.

```julia
terms(p::FreeAssAlgElem)
coefficients(p::FreeAssAlgElem)
monomials(p::FreeAssAlgElem)
terms(p::FreeAssociativeAlgebraElem)
coefficients(p::FreeAssociativeAlgebraElem)
monomials(p::FreeAssociativeAlgebraElem)
```

```@docs
exponent_words(a::FreeAssAlgElem{T}) where T <: RingElement
exponent_words(a::FreeAssociativeAlgebraElem{T}) where T <: RingElement
```

**Examples**

```jldoctest
julia> R, (a, b, c) = free_associative_algebra(ZZ, ["a", "b", "c"])
(Free associative algebra on 3 indeterminates over integers, AbstractAlgebra.Generic.FreeAssAlgElem{BigInt}[a, b, c])
(Free associative algebra on 3 indeterminates over integers, AbstractAlgebra.Generic.FreeAssociativeAlgebraElem{BigInt}[a, b, c])

julia> collect(terms(3*b*a*c - b + c + 2))
4-element Vector{Any}:
Expand Down Expand Up @@ -230,11 +230,11 @@ Since such a Groebner basis is not necessarily finite, one can additionally pass
to the function, to only compute a partial Groebner basis.

```@docs
groebner_basis(g::Vector{FreeAssAlgElem{T}}, reduction_bound::Int = typemax(Int), remove_redundancies::Bool = false) where T <: FieldElement
groebner_basis(g::Vector{FreeAssociativeAlgebraElem{T}}, reduction_bound::Int = typemax(Int), remove_redundancies::Bool = false) where T <: FieldElement

normal_form(f::FreeAssAlgElem{T}, g::Vector{FreeAssAlgElem{T}}, aut::AhoCorasickAutomaton) where T
normal_form(f::FreeAssociativeAlgebraElem{T}, g::Vector{FreeAssociativeAlgebraElem{T}}, aut::AhoCorasickAutomaton) where T

interreduce!(g::Vector{FreeAssAlgElem{T}}) where T
interreduce!(g::Vector{FreeAssociativeAlgebraElem{T}}) where T
```

The implementation uses a non-commutative version of the Buchberger algorithm as described in
Expand All @@ -246,10 +246,10 @@ The implementation uses a non-commutative version of the Buchberger algorithm as

```jldoctest; setup = :(using AbstractAlgebra)
julia> R, (x, y, u, v, t, s) = free_associative_algebra(GF(2), ["x", "y", "u", "v", "t", "s"])
(Free associative algebra on 6 indeterminates over finite field F_2, AbstractAlgebra.Generic.FreeAssAlgElem{AbstractAlgebra.GFElem{Int64}}[x, y, u, v, t, s])
(Free associative algebra on 6 indeterminates over finite field F_2, AbstractAlgebra.Generic.FreeAssociativeAlgebraElem{AbstractAlgebra.GFElem{Int64}}[x, y, u, v, t, s])

julia> g = Generic.groebner_basis([u*(x*y)^3 + u*(x*y)^2 + u + v, (y*x)^3*t + (y*x)^2*t + t + s])
5-element Vector{AbstractAlgebra.Generic.FreeAssAlgElem{AbstractAlgebra.GFElem{Int64}}}:
5-element Vector{AbstractAlgebra.Generic.FreeAssociativeAlgebraElem{AbstractAlgebra.GFElem{Int64}}}:
u*x*y*x*y*x*y + u*x*y*x*y + u + v
y*x*y*x*y*x*t + y*x*y*x*t + t + s
u*x*s + v*x*t
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ include("Fraction.jl")
include("TotalFraction.jl")
include("MPoly.jl")
include("UnivPoly.jl")
include("FreeAssAlgebra.jl")
include("FreeAssociativeAlgebra.jl")
include("LaurentMPoly.jl")
include("MatrixNormalForms.jl")

Expand Down
4 changes: 2 additions & 2 deletions src/AbstractTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ abstract type MatSpace{T} <: Module{T} end

abstract type MatRing{T} <: NCRing end

abstract type FreeAssAlgebra{T} <: NCRing end
abstract type FreeAssociativeAlgebra{T} <: NCRing end

# Abstract types for number fields, parmeterised by the element type of
# the base field.
Expand Down Expand Up @@ -144,7 +144,7 @@ abstract type MatElem{T} <: ModuleElem{T} end

abstract type MatRingElem{T} <: NCRingElem end

abstract type FreeAssAlgElem{T} <: NCRingElem end
abstract type FreeAssociativeAlgebraElem{T} <: NCRingElem end

abstract type NumFieldElem{T} <: FieldElem end

Expand Down
4 changes: 3 additions & 1 deletion src/Deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
# ALL aliases here are only a temporary measure to allow for a smooth transition downstream.
# they will be replaced by deprecations eventually

#= currently none =#
# renamed in 0.42.3
@alias FreeAssAlgebra FreeAssociativeAlgebra
@alias FreeAssAlgElem FreeAssociativeAlgebraElem

###############################################################################
#
Expand Down
46 changes: 23 additions & 23 deletions src/FreeAssAlgebra.jl → src/FreeAssociativeAlgebra.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###############################################################################
#
# FreeAssAlgebra.jl : free associative algebra R<x1,...,xn>
# FreeAssociativeAlgebra.jl : free associative algebra R<x1,...,xn>
#
###############################################################################

Expand All @@ -10,13 +10,13 @@
#
###############################################################################

coefficient_ring(R::FreeAssAlgebra{T}) where T <: RingElement = base_ring(R)
coefficient_ring(R::FreeAssociativeAlgebra{T}) where T <: RingElement = base_ring(R)

function is_domain_type(::Type{S}) where {T <: RingElement, S <: FreeAssAlgElem{T}}
function is_domain_type(::Type{S}) where {T <: RingElement, S <: FreeAssociativeAlgebraElem{T}}
return is_domain_type(T)
end

function is_exact_type(a::Type{S}) where {T <: RingElement, S <: FreeAssAlgElem{T}}
function is_exact_type(a::Type{S}) where {T <: RingElement, S <: FreeAssociativeAlgebraElem{T}}
return is_exact_type(T)
end

Expand Down Expand Up @@ -44,7 +44,7 @@ function _expressify_word!(prod::Expr, x, v::Vector)
end
end

function expressify(a::FreeAssAlgElem, x = symbols(parent(a)); context = nothing)
function expressify(a::FreeAssociativeAlgebraElem, x = symbols(parent(a)); context = nothing)
sum = Expr(:call, :+)
for (c, v) in zip(coefficients(a), exponent_words(a))
prod = Expr(:call, :*)
Expand All @@ -57,9 +57,9 @@ function expressify(a::FreeAssAlgElem, x = symbols(parent(a)); context = nothing
return sum
end

@enable_all_show_via_expressify FreeAssAlgElem
@enable_all_show_via_expressify FreeAssociativeAlgebraElem

function show(io::IO, mime::MIME"text/plain", a::FreeAssAlgebra)
function show(io::IO, mime::MIME"text/plain", a::FreeAssociativeAlgebra)
@show_name(io, a)
@show_special(io, mime, a)

Expand All @@ -79,7 +79,7 @@ function show(io::IO, mime::MIME"text/plain", a::FreeAssAlgebra)
print(io, Dedent())
end

function show(io::IO, a::FreeAssAlgebra)
function show(io::IO, a::FreeAssociativeAlgebra)
@show_name(io, a)
@show_special(io, a)
if is_terse(io)
Expand All @@ -97,29 +97,29 @@ end
#
###############################################################################

function coefficients(a::FreeAssAlgElem)
function coefficients(a::FreeAssociativeAlgebraElem)
return Generic.MPolyCoeffs(a)
end

function terms(a::FreeAssAlgElem)
function terms(a::FreeAssociativeAlgebraElem)
return Generic.MPolyTerms(a)
end

function monomials(a::FreeAssAlgElem)
function monomials(a::FreeAssociativeAlgebraElem)
return Generic.MPolyMonomials(a)
end

@doc raw"""
exponent_words(a::FreeAssAlgElem{T}) where T <: RingElement
exponent_words(a::FreeAssociativeAlgebraElem{T}) where T <: RingElement

Return an iterator for the exponent words of the given polynomial. To
retrieve an array of the exponent words, use `collect(exponent_words(a))`.
"""
function exponent_words(a::FreeAssAlgElem{T}) where T <: RingElement
function exponent_words(a::FreeAssociativeAlgebraElem{T}) where T <: RingElement
return Generic.FreeAssAlgExponentWords(a)
end

function is_unit(a::FreeAssAlgElem{T}) where T
function is_unit(a::FreeAssociativeAlgebraElem{T}) where T
if is_constant(a)
return is_unit(leading_coefficient(a))
elseif is_domain_type(elem_type(coefficient_ring(a)))
Expand All @@ -137,7 +137,7 @@ end
#
###############################################################################

function Base.hash(x::FreeAssAlgElem{T}, h::UInt) where T <: RingElement
function Base.hash(x::FreeAssociativeAlgebraElem{T}, h::UInt) where T <: RingElement
b = 0x6220ed52502c8d9f%UInt
for (c, e) in zip(coefficients(x), exponent_words(x))
b = xor(b, xor(hash(c, h), h))
Expand All @@ -155,7 +155,7 @@ end
###############################################################################

@doc raw"""
evaluate(a::FreeAssAlgElem{T}, vals::Vector{U}) where {T <: RingElement, U <: NCRingElem}
evaluate(a::FreeAssociativeAlgebraElem{T}, vals::Vector{U}) where {T <: RingElement, U <: NCRingElem}

Evaluate `a` by substituting in the array of values for each of the variables.
The evaluation will succeed if multiplication is defined between elements of
Expand Down Expand Up @@ -192,7 +192,7 @@ julia> m1*m2 - m2*m1 == f(m1, m2)
true
```
"""
function evaluate(a::FreeAssAlgElem{T}, vals::Vector{U}) where {T <: RingElement, U <: NCRingElem}
function evaluate(a::FreeAssociativeAlgebraElem{T}, vals::Vector{U}) where {T <: RingElement, U <: NCRingElem}
length(vals) != nvars(parent(a)) && error("Number of variables does not match number of values")
R = base_ring(parent(a))
S = parent(one(R)*one(parent(vals[1])))
Expand All @@ -204,7 +204,7 @@ function evaluate(a::FreeAssAlgElem{T}, vals::Vector{U}) where {T <: RingElement
return r
end

function (a::FreeAssAlgElem{T})(val::U, vals::U...) where {T <: RingElement, U <: NCRingElem}
function (a::FreeAssociativeAlgebraElem{T})(val::U, vals::U...) where {T <: RingElement, U <: NCRingElem}
return evaluate(a, [val, vals...])
end

Expand All @@ -214,9 +214,9 @@ end
#
###############################################################################

RandomExtensions.maketype(S::FreeAssAlgebra, _, _, _) = elem_type(S)
RandomExtensions.maketype(S::FreeAssociativeAlgebra, _, _, _) = elem_type(S)

function RandomExtensions.make(S::FreeAssAlgebra,
function RandomExtensions.make(S::FreeAssociativeAlgebra,
term_range::AbstractUnitRange{Int},
exp_bound::AbstractUnitRange{Int}, vs...)
R = base_ring(S)
Expand All @@ -228,7 +228,7 @@ function RandomExtensions.make(S::FreeAssAlgebra,
end

function rand(rng::AbstractRNG, sp::SamplerTrivial{<:Make4{
<:NCRingElement, <:FreeAssAlgebra, <:AbstractUnitRange{Int}, <:AbstractUnitRange{Int}}})
<:NCRingElement, <:FreeAssociativeAlgebra, <:AbstractUnitRange{Int}, <:AbstractUnitRange{Int}}})
S, term_range, exp_bound, v = sp[][1:end]
f = S()
g = gens(S)
Expand All @@ -245,12 +245,12 @@ function rand(rng::AbstractRNG, sp::SamplerTrivial{<:Make4{
return f
end

function rand(rng::AbstractRNG, S::FreeAssAlgebra,
function rand(rng::AbstractRNG, S::FreeAssociativeAlgebra,
term_range::AbstractUnitRange{Int}, exp_bound::AbstractUnitRange{Int}, v...)
m = make(S, term_range, exp_bound, v...)
rand(rng, m)
end

function rand(S::FreeAssAlgebra, term_range, exp_bound, v...)
function rand(S::FreeAssociativeAlgebra, term_range, exp_bound, v...)
rand(GLOBAL_RNG, S, term_range, exp_bound, v...)
end
Loading
Loading