# Local Polynomial Rings and Ideals

## Creation of Local Polynomial Rings and Accessing their Monomial Orders

Local polynomial rings are created from a coefficient field, the number of variables, and a monomial order. If no order is specified, the monomial order is taken to be the local lexicographical order.

### `LocalPolynomialRing(K, n): Rng, RngIntElt -> RngMPolLoc`

Create a local polynomial ring in $n>0$ variables over the field $K$. The *local lexicographical* ordering on the monomials is used for this default construction.

### `LocalPolynomialRing(K, n, order): Rng, RngIntElt, MonStgElt, ... -> RngMPolLoc`

### `LocalPolynomialAlgebra(K, n, order): Rng, RngIntElt, MonStgElt, ... -> RngMPolLoc`

Create a local polynomial ring in $n>0$ variables over the ring $R$ with the given order order on the monomials. See the above section on local monomial orders for the valid values for the argument order.

### `LocalPolynomialRing(K, n, T): Rng, RngIntElt, Tup -> RngMPolLoc`

Create a local polynomial ring in $n>0$ variables over the field $K$ with the order given by the tuple $T$ on the monomials. $T$ must be a tuple whose components match the valid arguments for the monomial orders in Section [Elements and Local Monomial Orders](elements-order.md#rngmpolloc-orders). Such a tuple is also returned by the next function.

### `MonomialOrder(R): RngMPolLoc -> Tup`

Given a local polynomial ring $R$ (or an ideal thereof), return a description of the monomial order of $R$. This is returned as a tuple which matches the relevant arguments listed for each possible order in Section [Elements and Local Monomial Orders](elements-order.md#rngmpolloc-orders), so may be passed as the third argument to the function [`LocalPolynomialRing`](#function-rngmpolloc-localpolynomialringtup) above.

### `MonomialOrderWeightVectors(R): RngMPol -> [ [ FldRatElt ] ]`

Given a polynomial ring $R$ of rank $n$ (or an ideal thereof), return the weight vectors of the underlying monomial order as a sequence of $n$ sequences of $n$ rationals. See, for example, [[Cox *et al.*, 1998](../../references.md#cite-uag-clo), p. 153] for more information.

### `Localization(R): RngMPol -> RngMPolLoc`

### `Localization(I): RngMPol -> RngMPolLoc`

Given a (global) multivariate polynomial ring $R=K[x_1, \ldots, x_n]$ (or an ideal $I$ of such an $R$), return the localization $K[x_1, \ldots, x_n]_{\langle x_1, \ldots, x_n\rangle}$ of $R$ (or the ideal of the localization of $R$ which corresponds to $I$). The print names for the variables of $R$ are carried over.

### `Example: Order (ex-ab71f5)`

We show how one can construct local polynomial rings with different orders. Note the order on the monomials for elements of the rings.

```magma
> K := RationalField();
> R<x,y,z> := LocalPolynomialRing(K, 3);
> R;
Localization of Polynomial Ring of rank 3 over Rational Field
Order: Local Lexicographical
Variables: x, y, z
> MonomialOrder(R);
<"llex">
> MonomialOrderWeightVectors(R);
[
    [ 0, 0, -1 ],
    [ 0, -1, 0 ],
    [ -1, 0, 0 ]
]
> 1 + x + y + z + x^7 + x^8*y^7 + y^5 + z^10;
1 + x + x^7 + y + y^5 + x^8*y^7 + z + z^10
> R<x,y,z> := LocalPolynomialRing(K, 3, "lgrevlex");
> R;
Localization of Polynomial Ring of rank 3 over Rational Field
Order: Local Graded Reverse Lexicographical
Variables: x, y, z
> MonomialOrder(R);
<"lgrevlex">
> MonomialOrderWeightVectors(R);
[
    [ -1, -1, -1 ],
    [ -1, -1, 0 ],
    [ -1, 0, 0 ]
]
> 1 + x + y + z + x^7 + x^8*y^7 + y^5 + z^10;
1 + z + y + x + y^5 + x^7 + z^10 + x^8*y^7

```

## Creation of Ideals and Accessing their Bases

As for global polynomial rings, within the general context of ideals of local polynomial rings, the term “basis” will refer to an *ordered* sequence of polynomials which generate an ideal. (Thus a basis can contain duplicates and zero elements so is not like a basis of a vector space.)

### `ideal<R | L>: RngMPolLoc, List -> RngMPolLoc`

Given a local polynomial ring $R$, return the ideal of $R$ generated by the elements of $R$ specified by the list $L$. Each term of the list $L$ must be an expression defining an object of one of the following types:

**(a)**
An element of $R$;

**(b)**
A set or sequence of elements of $R$;

**(c)**
An ideal of $R$;

**(d)**
A set or sequence of ideals of $R$.

### `Ideal(B): [ RngMPolLocElt ] -> RngMPolLoc`

### `Ideal(B): { RngMPolLocElt } -> RngMPolLoc`

Given a set or sequence $B$ of polynomials from a local polynomial ring $R$, return the ideal of $R$ generated by the elements of $B$ with the given basis $B$. This is equivalent to the above `ideal` constructor, but is more convenient when one simply has a set or sequence of polynomials.

### `Ideal(f): RngMPolLocElt -> RngMPolLoc`

Given a polynomial $f$ from a local polynomial ring $R$, return the principal ideal of $R$ generated by $f$.

### `IdealWithFixedBasis(B): [ RngMPolLocElt ] -> RngMPolLoc`

Given a sequence $B$ of polynomials from a local polynomial ring $R$, return the ideal of $R$ generated by the elements of $B$ with the given fixed basis $B$. When the function [`Coordinates`](groebner.md#function-rngmpolloc-coordinates) is called, its result will be with respect to the entries of $B$ instead of the Gröbner basis of $I$. **WARNING:** this function should *only* be used when it is desired to express polynomials of the ideal in terms of the elements of $B$, as the computation of the Gröbner basis in this case is *very* expensive, so it should be avoided if these expressions are not wanted.

### `Basis(I): RngMPolLoc -> [ RngMPolLocElt ]`

Given an ideal $I$, return the current basis of $I$. This will be the standard basis of $I$ if it is computed; otherwise it will be the original basis.

### `BasisElement(I, i): RngMPolLoc, RngIntElt -> RngMPolLocElt`

Given an ideal $I$ together with an integer $i$, return the $i$-th element of the current basis of $I$. This the same as `Basis(I)[i]`.
