# Ideals in PBW-algebras

## Types

The OSCAR type for ideals in PBW-algebras is of parametrized form `PBWAlgIdeal{D, T, S}`

, where `D`

encodes the direction left, right, or two-sided, and `T`

is the element type of the field over which the PBW-algebra is defined (the type `S`

is added for internal use).

## Constructors

`left_ideal`

— Method`left_ideal(g::Vector{<:PBWAlgElem})`

Given a vector `g`

of elements in a PBW-algebra `A`

, say, return the left ideal of `A`

generated by these elements.

`left_ideal(A::PBWAlgRing, g::AbstractVector)`

Given a vector `g`

of elements of `A`

, return the left ideal of `A`

generated by these elements.

**Examples**

```
julia> R, (x, y, z) = QQ["x", "y", "z"];
julia> L = [x*y, x*z, y*z + 1];
julia> REL = strictly_upper_triangular_matrix(L);
julia> A, (x, y, z) = pbw_algebra(R, REL, deglex(gens(R)))
(PBW-algebra over Rational Field in x, y, z with relations y*x = x*y, z*x = x*z, z*y = y*z + 1, PBWAlgElem{fmpq, Singular.n_Q}[x, y, z])
julia> I = left_ideal(A, [x^2*y^2, x*z+y*z])
left_ideal(x^2*y^2, x*z + y*z)
```

`right_ideal`

— Method`right_ideal(g::Vector{<:PBWAlgElem})`

Given a vector `g`

of elements in a PBW-algebra `A`

, say, return the right ideal of `A`

generated by these elements.

`right_ideal(A::PBWAlgRing, g::AbstractVector)`

Given a vector `g`

of elements of `A`

, return the right ideal of `A`

generated by these elements.

`two_sided_ideal`

— Method`two_sided_ideal(g::Vector{<:PBWAlgElem})`

Given a vector `g`

of elements in a PBW-algebra `A`

, say, return the two-sided ideal of `A`

generated by these elements.

`two_sided_ideal(A::PBWAlgRing, g::AbstractVector)`

Given a vector `g`

of elements of `A`

, return the two-sided ideal of `A`

generated by these elements.

## Gröbner bases

## Data Associated to Ideals

If `I`

is an ideal of a PBW-algebra `A`

, then

`base_ring(I)`

refers to`A`

,`gens(I)`

to the generators of`I`

,`ngens(I)`

to the number of these generators, and`gen(I, k)`

as well as`I[k]`

to the`k`

-th such generator.

###### Examples

```
julia> D, (x, y, dx, dy) = weyl_algebra(QQ, ["x", "y"])
(PBW-algebra over Rational Field in x, y, dx, dy with relations y*x = x*y, dx*x = x*dx + 1, dy*x = x*dy, dx*y = y*dx, dy*y = y*dy + 1, dy*dx = dx*dy, PBWAlgElem{fmpq, Singular.n_Q}[x, y, dx, dy])
julia> I = left_ideal(D, [x, dx])
left_ideal(x, dx)
julia> base_ring(I)
PBW-algebra over Rational Field in x, y, dx, dy with relations y*x = x*y, dx*x = x*dx + 1, dy*x = x*dy, dx*y = y*dx, dy*y = y*dy + 1, dy*dx = dx*dy
julia> gens(I)
2-element Vector{PBWAlgElem{fmpq, Singular.n_Q}}:
x
dx
julia> ngens(I)
2
julia> gen(I, 2)
dx
```

## Operations on Ideals

### Simple Ideal Operations

#### Powers of Ideal

`^`

— Method`^(I::PBWAlgIdeal{D, T, S}, k::Int) where {D, T, S}`

Given a two_sided ideal `I`

, return the `k`

-th power of `I`

.

**Examples**

```
julia> D, (x, dx) = weyl_algebra(GF(3), ["x"]);
julia> I = two_sided_ideal(D, [x^3])
two_sided_ideal(x^3)
julia> I^2
two_sided_ideal(x^6)
```

#### Sum of Ideals

`+`

— Method`+(I::PBWAlgIdeal{D, T, S}, J::PBWAlgIdeal{D, T, S}) where {D, T, S}`

Return the sum of `I`

and `J`

.

#### Product of Ideals

`*`

— Method`*(I::PBWAlgIdeal{DI, T, S}, J::PBWAlgIdeal{DJ, T, S}) where {DI, DJ, T, S}`

Given two ideals `I`

and `J`

such that both `I`

and `J`

are two-sided ideals or `I`

and `J`

are a left and a right ideal, respectively, return the product of `I`

and `J`

.

**Examples**

```
julia> D, (x, y, dx, dy) = weyl_algebra(GF(3), ["x", "y"]);
julia> I = left_ideal(D, [x^3+y^3, x*y^2])
left_ideal(x^3 + y^3, x*y^2)
julia> J = right_ideal(D, [dx^3, dy^5])
right_ideal(dx^3, dy^5)
julia> I*J
two_sided_ideal(x^3*dx^3 + y^3*dx^3, x^3*dy^5 + y^3*dy^5, x*y^2*dx^3, x*y^2*dy^5)
```

### Intersection of Ideals

`intersect`

— Method`intersect(I::PBWAlgIdeal{D, T, S}, Js::PBWAlgIdeal{D, T, S}...) where {D, T, S}`

Return the intersection of two or more ideals.

**Examples**

```
julia> D, (x, y, dx, dy) = weyl_algebra(QQ, ["x", "y"]);
julia> I = intersect(left_ideal(D, [x^2, x*dy, dy^2])+left_ideal(D, [dx]), left_ideal(D, [dy^2-x^3+x]))
left_ideal(-x^3 + dy^2 + x)
```

### Elimination

Let

\[A = K\langle x_1, \dots , x_n \mid x_jx_i = c_{ij}x_ix_j+d_{ij}, \ 1\leq i<j \leq n \rangle,\]

be a PBW-algebra. Fix a subset $\sigma\subset \{1,\dots, n\}$, write $x_\sigma$ for the set of variables $x_i$ with $i\in\sigma$, and let $A_\sigma$ be the $K$-linear subspace of $A$ which is generated by the standard monomials in $\langle x_\sigma \rangle$. Suppose there exists a global monomial ordering $>$ on $A$ which is both admissible for $A$ and an elimination ordering for $x\smallsetminus x_\sigma$. Then $A_\sigma$ is a subalgebra of $A$ with $d_{ij}\in A_\sigma$ for each pair of indices $1\leq i<j \leq n$ with $i,j\in\sigma$. In particular, $A_\sigma$ is a PBW-algebra with admissible ordering $>_\sigma$, where $>_\sigma$ is the restriction of $>$ to the set of standard monomials in $\langle x_\sigma\rangle$. Moreover, if $I\subset A$ is a nonzero (left, right, two-sided) ideal, and $\mathcal G$ is a (left, right, two-sided) Gröbner basis for $I$ with respect to $>$, then $\mathcal G\cap A_\sigma$ is a (left, right, two-sided) Gröbner basis for $I\cap A_\sigma$ with respect to $>_\sigma$. We refer to computing $I\cap A_\sigma$ as *eliminating the variables in $x\smallsetminus x_\sigma$ from $I.$*

If the relevant $d_{ij}$ are all contained in $A_\sigma$, we also say that $A_\sigma$ is *admissible for elimination*.

A monomial ordering which is both admissible for $A$ and an elimination ordering for $x\smallsetminus x_\sigma$ may not exist.

`eliminate`

— Method`eliminate(I::PBWAlgIdeal, V::Vector{<:PBWAlgElem}; ordering = nothing)`

Given a vector `V`

of variables, these variables are eliminated from `I`

. That is, return the ideal generated by all polynomials in `I`

which only involve the remaining variables.

`eliminate(I::PBWAlgIdeal, V::Vector{Int}; ordering = nothing)`

Given a vector `V`

of indices which specify variables, these variables are eliminated from `I`

. That is, return the ideal generated by all polynomials in `I`

which only involve the remaining variables.

The return value is an ideal of the original algebra.

If provided, the `ordering`

must be an admissible elimination ordering (this is checked by the function). If not provided, finding an admissible elimination ordering may involve solving a particular linear programming problem. Here, the function is implemented so that it searches for solutions in a certain range only. If no solution is found in that range, the function will throw an error.

**Examples**

```
julia> R, (x, y, z, a) = QQ["x", "y", "z", "a"];
julia> L = [x*y-z, x*z+2*x, x*a, y*z-2*y, y*a, z*a];
julia> REL = strictly_upper_triangular_matrix(L);
julia> A, (x, y, z, a) = pbw_algebra(R, REL, deglex(gens(R)))
(PBW-algebra over Rational Field in x, y, z, a with relations y*x = x*y - z, z*x = x*z + 2*x, a*x = x*a, z*y = y*z - 2*y, a*y = y*a, a*z = z*a, PBWAlgElem{fmpq, Singular.n_Q}[x, y, z, a])
julia> f = 4*x*y+z^2-2*z-a;
julia> I = left_ideal(A, [x^2, y^2, z^2-1, f])
left_ideal(x^2, y^2, z^2 - 1, 4*x*y + z^2 - 2*z - a)
julia> eliminate(I, [x, y, z])
left_ideal(a - 3)
julia> eliminate(I, [1, 2 ,3])
left_ideal(a - 3)
julia> try eliminate(I, [z, a]); catch e; e; end
ErrorException("no elimination is possible: subalgebra is not admissible")
```

```
julia> R, (p, q) = QQ["p", "q"];
julia> L = [p*q+q^2];
julia> REL = strictly_upper_triangular_matrix(L);
julia> A, (p, q) = pbw_algebra(R, REL, lex(gens(R)))
(PBW-algebra over Rational Field in p, q with relations q*p = p*q + q^2, PBWAlgElem{fmpq, Singular.n_Q}[p, q])
julia> I = left_ideal(A, [p, q])
left_ideal(p, q)
julia> try eliminate(I, [q]); catch e; e; end # in fact, no elimination ordering exists
ErrorException("could not find elimination ordering")
```

## Tests on Ideals

`iszero`

— Method`iszero(I::PBWAlgIdeal)`

Return `true`

if `I`

is the zero ideal, `false`

otherwise.

**Examples**

```
julia> D, (x, y, dx, dy) = weyl_algebra(QQ, ["x", "y"])
(PBW-algebra over Rational Field in x, y, dx, dy with relations y*x = x*y, dx*x = x*dx + 1, dy*x = x*dy, dx*y = y*dx, dy*y = y*dy + 1, dy*dx = dx*dy, PBWAlgElem{fmpq, Singular.n_Q}[x, y, dx, dy])
julia> I = left_ideal(D, [x, dx])
left_ideal(x, dx)
julia> iszero(I)
false
```

`isone`

— Method`isone(I::PBWAlgIdeal{D}) where D`

Return `true`

if `I`

is generated by `1`

, `false`

otherwise.

**Examples**

```
julia> D, (x, y, dx, dy) = weyl_algebra(QQ, ["x", "y"])
(PBW-algebra over Rational Field in x, y, dx, dy with relations y*x = x*y, dx*x = x*dx + 1, dy*x = x*dy, dx*y = y*dx, dy*y = y*dy + 1, dy*dx = dx*dy, PBWAlgElem{fmpq, Singular.n_Q}[x, y, dx, dy])
julia> I = left_ideal(D, [x, dx])
left_ideal(x, dx)
julia> isone(I)
true
julia> J = left_ideal(D, [y*x])
left_ideal(x*y)
julia> isone(J)
false
julia> K = two_sided_ideal(D, [y*x])
two_sided_ideal(x*y)
julia> isone(K)
true
```

```
julia> D, (x, y, dx, dy) = weyl_algebra(GF(3), ["x", "y"]);
julia> I = two_sided_ideal(D, [x^3])
two_sided_ideal(x^3)
julia> isone(I)
false
```

`issubset`

— Method`issubset(I::PBWAlgIdeal{D, T, S}, J::PBWAlgIdeal{D, T, S}) where {D, T, S}`

Return `true`

if `I`

is contained in `J`

, `false`

otherwise.

**Examples**

```
julia> D, (x, dx) = weyl_algebra(QQ, ["x"]);
julia> I = left_ideal(D, [dx^2])
left_ideal(dx^2)
julia> J = left_ideal(D, [x*dx^4, x^3*dx^2])
left_ideal(x*dx^4, x^3*dx^2)
julia> issubset(I, J)
true
```

`==`

— Method`==(I::PBWAlgIdeal{D, T, S}, J::PBWAlgIdeal{D, T, S}) where {D, T, S}`

Return `true`

if `I`

is equal to `J`

, `false`

otherwise.

**Examples**

```
julia> D, (x, dx) = weyl_algebra(QQ, ["x"]);
julia> I = left_ideal(D, [dx^2])
left_ideal(dx^2)
julia> J = left_ideal(D, [x*dx^4, x^3*dx^2])
left_ideal(x*dx^4, x^3*dx^2)
julia> I == J
true
```

`ideal_membership`

— Method`ideal_membership(f::PBWAlgElem{T, S}, I::PBWAlgIdeal{D, T, S}) where {D, T, S}`

Return `true`

if `f`

is contained in `I`

, `false`

otherwise. Alternatively, use `f in I`

.

**Examples**

```
julia> D, (x, dx) = weyl_algebra(QQ, ["x"]);
julia> I = left_ideal(D, [x*dx^4, x^3*dx^2])
left_ideal(x*dx^4, x^3*dx^2)
julia> dx^2 in I
true
```

```
julia> D, (x, y, dx, dy) = weyl_algebra(QQ, ["x", "y"]);
julia> I = two_sided_ideal(D, [x, dx])
two_sided_ideal(x, dx)
julia> one(D) in I
true
```