# 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)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> Y = affine_space(QQ,3)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> SpecMor(X, Y, gens(OO(X)));
```

### 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)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> identity_map(X);
```

`inclusion_morphism`

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

This method constructs the inclusion map from $X$ to $Y$. For convenience, also the method `inclusion_morphism`

is supported.

**Examples**

```
julia> X = affine_space(QQ,3)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(X)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> Y = subscheme(X, x1)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1)
julia> f = inclusion_morphism(Y, X);
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)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(X)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> Y = subscheme(X, x1)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1)
julia> m1 = inclusion_morphism(Y, X);
julia> m2 = identity_map(X);
julia> 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)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(X)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> Y = subscheme(X, x1)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field 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)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(Y)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> X = subscheme(Y, x1)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1)
julia> f = inclusion_morphism(X, Y);
julia> domain(f)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field 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)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(Y)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> X = subscheme(Y, x1)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1)
julia> f = inclusion_morphism(X, Y);
julia> codomain(f)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
```

`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)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(Y)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> X = subscheme(Y, x1)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1)
julia> pullback(inclusion_morphism(X, Y))
Map with following data
Domain:
=======
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
Codomain:
=========
Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1)
```

`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)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(Y)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> X = subscheme(Y, x1)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1)
julia> f = inclusion_morphism(X, Y);
julia> graph(f);
```

### 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)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(X)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> Y = subscheme(X, x1)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field 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)`

Returns 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 the triple $(Y, f, g)$ where $Y = Spec(R')$ and $f : Y ↔ X : g$ are the identifying isomorphisms.

***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 `==`

.