# Morphisms of affine schemes

## Constructors

### General constructors

`SpecMor`

— Method`SpecMor(X::AbsSpec, Y::AbsSpec, f::Vector{<:RingElem}; check::Bool=true)`

This method constructs a morphism from the scheme $X$ to the scheme $Y$. For this one has to specify the images of the coordinates (the generators of `ambient_coordinate_ring(Y)`

) under the pullback map $𝒪(Y) → 𝒪(X)$ as third argument.

Note that expensive checks can be turned off by setting `check=false`

.

**Examples**

```
julia> X = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> Y = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> SpecMor(X, Y, gens(OO(X)))
Morphism
from [x1, x2, x3] affine 3-space over QQ
to [x1, x2, x3] affine 3-space over QQ
given by the pullback function
x1 -> x1
x2 -> x2
x3 -> x3
```

### Special constructors

`identity_map`

— Method`identity_map(X::AbsSpec{<:Any, <:MPolyRing})`

This method constructs the identity morphism from an affine scheme to itself.

**Examples**

```
julia> X = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> identity_map(X)
Morphism
from [x1, x2, x3] affine 3-space over QQ
to [x1, x2, x3] affine 3-space over QQ
given by the pullback function
x1 -> x1
x2 -> x2
x3 -> x3
```

`inclusion_morphism`

— Method`inclusion_morphism(X::AbsSpec, Y::AbsSpec; check::Bool=true)`

Return the inclusion map from $X$ to $Y$.

**Examples**

```
julia> X = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> R = OO(X)
Multivariate polynomial ring in 3 variables x1, x2, x3
over rational field
julia> (x1,x2,x3) = gens(R)
3-element Vector{QQMPolyRingElem}:
x1
x2
x3
julia> Y = subscheme(X, x1)
Spectrum
of quotient
of multivariate polynomial ring in 3 variables over QQ
by ideal(x1)
julia> f = inclusion_morphism(Y, X)
Morphism
from [x1, x2, x3] spec of quotient of multivariate polynomial ring
to [x1, x2, x3] affine 3-space over QQ
given by the pullback function
x1 -> 0
x2 -> x2
x3 -> x3
julia> I = kernel(pullback(f)) # this is a way to obtain the ideal ``I ⊆ O(X)`` cutting out ``Y`` from ``X``.
ideal(x1)
julia> base_ring(I) == OO(X)
true
```

`compose`

— Method`compose(f::AbsSpecMor, g::AbsSpecMor)`

This method computes the composition of two morphisms.

**Examples**

```
julia> X = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> R = OO(X)
Multivariate polynomial ring in 3 variables x1, x2, x3
over rational field
julia> (x1,x2,x3) = gens(R)
3-element Vector{QQMPolyRingElem}:
x1
x2
x3
julia> Y = subscheme(X, x1)
Spectrum
of quotient
of multivariate polynomial ring in 3 variables over QQ
by ideal(x1)
julia> m1 = inclusion_morphism(Y, X)
Morphism
from [x1, x2, x3] spec of quotient of multivariate polynomial ring
to [x1, x2, x3] affine 3-space over QQ
given by the pullback function
x1 -> 0
x2 -> x2
x3 -> x3
julia> m2 = identity_map(X)
Morphism
from [x1, x2, x3] affine 3-space over QQ
to [x1, x2, x3] affine 3-space over QQ
given by the pullback function
x1 -> x1
x2 -> x2
x3 -> x3
julia> m3 = identity_map(Y)
Morphism
from [x1, x2, x3] spec of quotient of multivariate polynomial ring
to [x1, x2, x3] spec of quotient of multivariate polynomial ring
given by the pullback function
x1 -> 0
x2 -> x2
x3 -> x3
julia> compose(m3, compose(m1, m2)) == m1
true
```

`restrict`

— Method`restrict(f::SpecMor, U::AbsSpec, V::AbsSpec)`

This method restricts the domain of the morphism $f$ to $U$ and its codomain to $V$.

**Examples**

```
julia> X = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> R = OO(X)
Multivariate polynomial ring in 3 variables x1, x2, x3
over rational field
julia> (x1,x2,x3) = gens(R)
3-element Vector{QQMPolyRingElem}:
x1
x2
x3
julia> Y = subscheme(X, x1)
Spectrum
of quotient
of multivariate polynomial ring in 3 variables over QQ
by ideal(x1)
julia> restrict(identity_map(X), Y, Y) == identity_map(Y)
true
```

## Attributes

### General attributes

`domain`

— Method`domain(f::AbsSpecMor)`

On a morphism $f : X → Y$ of affine schemes, this returns $X$.

**Examples**

```
julia> Y = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> R = OO(Y)
Multivariate polynomial ring in 3 variables x1, x2, x3
over rational field
julia> (x1,x2,x3) = gens(R)
3-element Vector{QQMPolyRingElem}:
x1
x2
x3
julia> X = subscheme(Y, x1)
Spectrum
of quotient
of multivariate polynomial ring in 3 variables over QQ
by ideal(x1)
julia> f = inclusion_morphism(X, Y)
Morphism
from [x1, x2, x3] spec of quotient of multivariate polynomial ring
to [x1, x2, x3] affine 3-space over QQ
given by the pullback function
x1 -> 0
x2 -> x2
x3 -> x3
julia> domain(f)
Spectrum
of quotient
of multivariate polynomial ring in 3 variables over QQ
by ideal(x1)
```

`codomain`

— Method`codomain(f::AbsSpecMor)`

On a morphism $f : X → Y$ of affine schemes, this returns $Y$.

**Examples**

```
julia> Y = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> R = OO(Y)
Multivariate polynomial ring in 3 variables x1, x2, x3
over rational field
julia> (x1,x2,x3) = gens(R)
3-element Vector{QQMPolyRingElem}:
x1
x2
x3
julia> X = subscheme(Y, x1)
Spectrum
of quotient
of multivariate polynomial ring in 3 variables over QQ
by ideal(x1)
julia> f = inclusion_morphism(X, Y)
Morphism
from [x1, x2, x3] spec of quotient of multivariate polynomial ring
to [x1, x2, x3] affine 3-space over QQ
given by the pullback function
x1 -> 0
x2 -> x2
x3 -> x3
julia> codomain(f)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
```

`pullback`

— Method`pullback(f::AbsSpecMor)`

On a morphism $f : X → Y$ of affine schemes $X = Spec(S)$ and $Y = Spec(R)$, this returns the ring homomorphism $f^* : R → S$.

**Examples**

```
julia> Y = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> R = OO(Y)
Multivariate polynomial ring in 3 variables x1, x2, x3
over rational field
julia> (x1,x2,x3) = gens(R)
3-element Vector{QQMPolyRingElem}:
x1
x2
x3
julia> X = subscheme(Y, x1)
Spectrum
of quotient
of multivariate polynomial ring in 3 variables over QQ
by ideal(x1)
julia> pullback(inclusion_morphism(X, Y))
Map with following data
Domain:
=======
Multivariate polynomial ring in 3 variables over QQ
Codomain:
=========
Quotient of multivariate polynomial ring by ideal with 1 generator
```

`graph`

— Method`graph(f::AbsSpecMor)`

Return the graph of $f : X → Y$ as a subscheme of $X×Y$ as well as the two projections to $X$ and $Y$.

**Examples**

```
julia> Y = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> R = OO(Y)
Multivariate polynomial ring in 3 variables x1, x2, x3
over rational field
julia> (x1,x2,x3) = gens(R)
3-element Vector{QQMPolyRingElem}:
x1
x2
x3
julia> X = subscheme(Y, x1)
Spectrum
of quotient
of multivariate polynomial ring in 3 variables over QQ
by ideal(x1)
julia> f = inclusion_morphism(X, Y)
Morphism
from [x1, x2, x3] spec of quotient of multivariate polynomial ring
to [x1, x2, x3] affine 3-space over QQ
given by the pullback function
x1 -> 0
x2 -> x2
x3 -> x3
julia> graph(f)
(Spec of quotient of multivariate polynomial ring, Morphism: spec of quotient of multivariate polynomial ring -> spec of quotient of multivariate polynomial ring, Morphism: spec of quotient of multivariate polynomial ring -> affine 3-space over QQ with coordinates [x1, x2, x3])
```

### Special attributes

In addition to the standard getters and methods for instances of `SpecMor`

, we also have

`image_ideal`

— Method`image_ideal(f::ClosedEmbedding)`

For a closed embedding $f : X → Y$ of affine schemes $X = Spec(S)$ into $Y = Spec(R)$ such that $S ≅ R/I$ via $f$ for some ideal $I ⊂ R$ this returns $I$.

### Undocumented

The following functions do exist but are currently undocumented:

`underlying_morphism`

,`complement_ideal`

,`complement_scheme`

,`preimage`

,`inverse`

,- various type getters.

## Properties

`is_isomorphism`

— Method`is_isomorphism(f::AbsSpecMor)`

This method checks if a morphism is an isomorphism.

`is_inverse_of`

— Method`is_inverse_of(f::AbsSpecMor, g::AbsSpecMor)`

This method checks if a morphism $f$ is the inverse of a morphism $g$.

`is_identity_map`

— Method`is_identity_map(f::AbsSpecMor)`

This method checks if a morphism is the identity map.

**Examples**

```
julia> X = affine_space(QQ,3)
Affine space of dimension 3
over rational field
with coordinates [x1, x2, x3]
julia> R = OO(X)
Multivariate polynomial ring in 3 variables x1, x2, x3
over rational field
julia> (x1,x2,x3) = gens(R)
3-element Vector{QQMPolyRingElem}:
x1
x2
x3
julia> Y = subscheme(X, x1)
Spectrum
of quotient
of multivariate polynomial ring in 3 variables over QQ
by ideal(x1)
julia> is_identity_map(inclusion_morphism(Y, X))
false
```

## Methods

`fiber_product`

— Method`fiber_product(f::SpecMor{SpecType, SpecType, <:Any}, g::SpecMor{SpecType, SpecType, <:Any}) where {SpecType<:StdSpec}`

For morphisms $f : Y → X$ and $g : Z → X$ return the fiber product $Y×Z$ over $X$ together with its two canonical projections.

`product`

— Method`product(X::AbsSpec, Y::AbsSpec)`

Return a triple $(X×Y, p₁, p₂)$ consisting of the product $X×Y$ over the common base ring $𝕜$ and the two projections $p₁ : X×Y → X$ and $p₂ : X×Y → Y$.

`simplify`

— Method`simplify(X::AbsSpec{<:Field})`

Given an affine scheme $X$ with coordinate ring $R = 𝕜[x₁,…,xₙ]/I$ (or a localization thereof), use `Singular`

's `elimpart`

to try to eliminate variables $xᵢ$ to arrive at a simpler presentation $R ≅ R' = 𝕜[y₁,…,yₘ]/J$ for some ideal $J$; return a `SimplifiedSpec`

$Y$ with $X$ as its `original`

.

***Note:*** The `ambient_coordinate_ring`

of the output `Y`

will be different from the one of `X`

and hence the two schemes will not compare using `==`

.