# Qadics

Q-adic fields, that is, unramified extensions of p-adic fields, are provided in Nemo by Flint. This allows construction of $q$-adic fields for any prime power $q$.

Q-adic fields are constructed using the `FlintQadicField`

function. However, for convenience we define

`QadicField = FlintQadicField`

so that $q$-adic fields can be constructed using `QadicField`

rather than `FlintQadicField`

. Note that this is the name of the constructor, but not of qadic field type.

The types of $q$-adic fields in Nemo are given in the following table, along with the libraries that provide them and the associated types of the parent objects.

Library | Field | Element type | Parent type |
---|---|---|---|

Flint | $\mathbb{Q}_q$ | `qadic` | `QadicField` |

All the $q$-adic field types belong to the `Field`

abstract type and the $q$-adic field element types belong to the `FieldElem`

abstract type.

## P-adic functionality

Q-adic fields in Nemo implement the AbstractAlgebra.jl field interface.

https://nemocas.github.io/AbstractAlgebra.jl/fields.html

Below, we document all the additional function that is provide by Nemo for p-adic fields.

### Constructors

In order to construct $q$-adic field elements in Nemo, one must first construct the $q$-adic field itself. This is accomplished with one of the following constructors.

`Nemo.FlintQadicField`

— Method.`FlintQadicField(p::Integer, d::Int, prec::Int)`

Returns the parent object for the $q$-adic field for given prime $p$ and degree $d$, where the default absolute precision of elements of the field is given by

`prec`

.

It is also possible to call the inner constructor directly. It has the following form.

`FlintQadicField(p::fmpz, d::Int, prec::Int)`

Returns the parent object for the $q$-adic field for given prime $p$ and degree $d$, where the default absolute precision of elements of the field is given by `prec`

.

Here are some examples of creating $q$-adic fields and making use of the resulting parent objects to coerce various elements into those fields.

**Examples**

```
R = QadicField(7, 1, 30)
S = QadicField(ZZ(65537), 1, 30)
a = R()
b = S(1)
c = S(ZZ(123))
d = R(ZZ(1)//7^2)
```

### Big-oh notation

Elements of p-adic fields can be constructed using the big-oh notation. For this purpose we define the following functions.

`AbstractAlgebra.Generic.O`

— Method.`O(R::FlintQadicField, m::Integer)`

Construct the value $0 + O(p^n)$ given $m = p^n$. An exception results if $m$ is not found to be a power of

`p = prime(R)`

.

`AbstractAlgebra.Generic.O`

— Method.`O(R::FlintQadicField, m::fmpz)`

Construct the value $0 + O(p^n)$ given $m = p^n$. An exception results if $m$ is not found to be a power of

`p = prime(R)`

.

`AbstractAlgebra.Generic.O`

— Method.`O(R::FlintQadicField, m::fmpq)`

Construct the value $0 + O(p^n)$ given $m = p^n$. An exception results if $m$ is not found to be a power of

`p = prime(R)`

.

The $O(p^n)$ construction can be used to construct $q$-adic values of precision $n$ by adding it to integer values representing the $q$-adic value modulo $p^n$ as in the examples.

**Examples**

```
R = QadicField(7, 30)
S = QadicField(ZZ(65537), 30)
c = 1 + 2*7 + 4*7^2 + O(R, 7^3)
d = 13 + 357*ZZ(65537) + O(S, ZZ(65537)^12)
f = ZZ(1)//7^2 + ZZ(2)//7 + 3 + 4*7 + O(R, 7^2)
```

Beware that the expression `1 + 2*p + 3*p^2 + O(R, p^n)`

is actually computed as a normal Julia expression. Therefore if `{Int}`

values are used instead of Flint integers or Julia bignums, overflow may result in evaluating the value.

### Basic manipulation

`Nemo.prime`

— Method.`prime(R::FlintQadicField)`

Return the prime $q$ for the given $q$-adic field.

`Base.precision`

— Method.`precision(a::qadic)`

Return the precision of the given $q$-adic field element, i.e. if the element is known to $O(p^n)$ this function will return $n$.

`AbstractAlgebra.Generic.valuation`

— Method.`valuation(a::qadic)`

Return the valuation of the given $q$-adic field element, i.e. if the given element is divisible by $p^n$ but not a higher power of $q$ then the function will return $n$.

`Nemo.lift`

— Method.`lift(R::FmpqPolyRing, a::qadic)`

Return a lift of the given $q$-adic field element to $\mathbb{Q}[x]$.

`Nemo.lift`

— Method.`lift(R::FmpzPolyRing, a::qadic)`

Return a lift of the given $q$-adic field element to $\mathbb{Z}[x]$ if possible.

**Examples**

```
R = QadicField(7, 1, 30)
a = 1 + 2*7 + 4*7^2 + O(R, 7^3)
b = 7^2 + 3*7^3 + O(R, 7^5)
c = R(2)
k = precision(a)
m = prime(R)
n = valuation(b)
Qx, x = FlintQQ["x"]
p = lift(Qx, a)
Zy, y = FlintZZ["y"]
q = lift(Zy, divexact(a, b))
```

### Square root

`Base.sqrt`

— Method.`sqrt(a::qadic)`

Return the $q$-adic square root of $a$. We define this only when the valuation of $a$ is even. The precision of the output will be precision$(a) -$ valuation$(a)/2$. If the square root does not exist, an exception is thrown.

**Examples**

```
R = QadicField(7, 1, 30)
a = 1 + 7 + 2*7^2 + O(R, 7^3)
b = 2 + 3*7 + O(R, 7^5)
c = 7^2 + 2*7^3 + O(R, 7^4)
d = sqrt(a)
f = sqrt(b)
f = sqrt(c)
g = sqrt(R(121))
```

### Special functions

`Base.exp`

— Method.`exp(a::qadic)`

Return the $q$-adic exponential of $a$. We define this only when the valuation of $a$ is positive (unless $a = 0$). The precision of the output will be the same as the precision of the input. If the input is not valid an exception is thrown.

`Base.log`

— Method.`log(a::qadic)`

Return the $q$-adic logarithm of $a$. We define this only when the valuation of $a$ is zero (but not for $a == 0$). The precision of the output will be the same as the precision of the input. If the input is not valid an exception is thrown.

`Nemo.teichmuller`

— Method.`teichmuller(a::qadic)`

Return the Teichmuller lift of the $q$-adic value $a$. We require the valuation of $a$ to be nonnegative. The precision of the output will be the same as the precision of the input. For convenience, if $a$ is congruent to zero modulo $q$ we return zero. If the input is not valid an exception is thrown.

`Nemo.frobenius`

— Method.`frobenius(a::qadic, e::Int = 1)`

Return the image of the $e$-th power of Frobenius on the $q$-adic value $a$. The precision of the output will be the same as the precision of the input.

**Examples**

```
R = QadicField(7, 30)
a = 1 + 7 + 2*7^2 + O(R, 7^3)
b = 2 + 5*7 + 3*7^2 + O(R, 7^3)
c = 3*7 + 2*7^2 + O(R, 7^5)
c = exp(c)
d = log(a)
c = exp(R(0))
d = log(R(1))
f = teichmuller(b)
g = frobenius(a, 2)
```