function application to identifications

+-- {: .rightHandSide}
+-- {: .toc .clickDown tabindex="0"}
### Context
#### Type theory
+-- {: .hide}
[[!include type theory - contents]]
=--
=--
=--

#Contents#
* table of contents
{:toc}

## Idea ##

The [[type theory|type-theoretic]] version of the fact that in [[set theory]] [[functions]] preserve [[equality]] between [[elements]] in [[sets]].

## Definition ##

### Basic definition

In [[dependent type theory]], given [[types]] $A$ and $B$ and a [[function type|function]] $x  \colon A \vdash f(x) \colon B$, there is induced a [[dependent function]] between the corresponding [[identity types]]

$$
  a \colon A
  ,\,\;
  b\colon A
  ,\,\;
  p
    \,\colon\,
  a =_A b
  \;\;\;\vdash\;\;\;
  \mathrm{ap}_f(a, b)(p)
  \;\colon\;
  f(a) =_B f(b)
$$

defined by [[Id-induction]] from

$$
  ap_f\big(refl_a\big) \,\equiv\, refl_{f(a)}
$$

and called the **application** or **action** of $f$ to/on [[identities]]/[[identifications]]/[[equalities]]/[[paths]] [e.g. [UFP (2013, p. 69)](#UFP13), [Rijke (2022, §5.3)](#Rijke22)].

{#Functoriality} By repeated [[Id-induction]] it readily follows,  stagewise (e.g. [UFP13, Lem 2.2.1](#UFP13)), that $ap_f$ respects the [[concatenation]], and the [[inverse|inversion]] of [[identifications]], up to [[coherence|coherent]] higher-order identifications, hence that it acts as an [[infinity-functor|$\infty$-functor]] on the  [[infinity-groupoid|$\infty$-groupoid]]-[[structure]] on homotopy types :

<img src="/nlab/files/FuncApOnIds-230119b.jpg" width="700">

### As the non-dependent version of the dependent function application to identifications

The function application to identifications is a special case of the [[dependent function application to identifications]] for which the type family $x:A \vdash B$ is a constant type family, and thus the [[dependent identity type]] $f(a) =_B^p f(b)$ doesn't depend on the path $p:a =_A b$ and is thus a normal identity type $f(a) =_B f(b)$.

### Inductive definition

If the function application to identifications is inductively defined, then it comes with rules saying that the following judgment can be formed
$$a:A \vdash \mathrm{ap}_{f}(a, a)(\mathrm{refl}_{A}(a)) \equiv \mathrm{refl}_{B}(f(a)):\Omega(B, f(a))$$
where $\Omega(A, a)$ is the [[loop space type]] $a =_A a$ of $A$ at $a:A$.

### Binary function applications to identifications

Given types $A$, $B$, and $C$ and a [[binary function]] $x:A, y:B \vdash f(x, y):C$, there is a dependent function
$$a:A, a':A, b:B, b':B, p:a =_A a', q:b =_B b' \vdash \mathrm{apbinary}_f(a, a', b, b')(p, q):f(a, b) =_C f(a', b')$$
called the **binary function application to identifications** or **binary action on identifications** ([Rijke (2022), §19.5](#Rijke22)), inductively defined by
$$a:A, b:B \vdash \mathrm{apbinary}_{f}(a, a, b, b)(\mathrm{refl}_{A}(a), \mathrm{refl}_{B}(b)) \equiv \mathrm{refl}_{C}(f(a, b)):\Omega(C, f(a, b))$$
where $\Omega(A, a)$ is the [[loop space type]] $a =_A a$ of $A$ at $a:A$.

Binary function applications to identifications are used in proving [[product extensionality]] for [[product types]], as well as defining multiplication on the [[integers]] $\mathrm{apbinary}_{\mu}:\mathbb{Z} \times \mathbb{Z} \to \mathbb{Z}$ from multiplication on the [[circle type]] $\mu:S^1 \times S^1 \to S^1$ when the integers are defined as the [[loop space type]] of the element $\mathrm{base}:S^1$, $\mathbb{Z} \coloneqq \Omega(S^1, \mathrm{base})$.

### Finitary function application to identifications

Let $n$ be a natural number, let $A$ be a family of types indexed by the [[finite type]] with $n$ elements $\mathrm{Fin}(n)$, and let $B$ be a type. Then given a function
$$n:\mathbb{N}, x:\left(\prod_{i:\mathrm{Fin}(n)} A(i)\right) \vdash f(x):B$$
there is a dependent function
$$n:\mathbb{N}, a:\prod_{i:\mathrm{Fin}(n)} A(i), b:\prod_{i:\mathrm{Fin}(n)} A(i) \vdash \mathrm{ap}_f(n)(a, b):\left(\prod_{i:\mathrm{Fin}(n)} a(i) =_{A(i)} b(i)\right) \to f(a) =_{B} f(b)$$

## See also ##

* [[dependent function application to identifications]]

* [[identification]]

* [[identification type]]

## References ##

* {#UFP13} [[Univalent Foundations Project]], §2.2 in: *[[Homotopy Type Theory – Univalent Foundations of Mathematics]]* (2013) [[web](http://homotopytypetheory.org/book/), [pdf](http://hottheory.files.wordpress.com/2013/03/hott-online-323-g28e4374.pdf)]

* {#Rijke22} [[Egbert Rijke]], §5.3 in: *[[Introduction to Homotopy Type Theory]]*, Cambridge Studies in Advanced Mathematics, Cambridge University Press ([arXiv:2212.11082](https://arxiv.org/abs/2212.11082))

[[!redirects function application to identities]]
[[!redirects function application to identifications]]
[[!redirects function application to paths]]
[[!redirects function application to equalities]]

[[!redirects application of a function to identities]]
[[!redirects application of a function to identifications]]
[[!redirects application of a function to paths]]
[[!redirects application of a function to equalities]]

[[!redirects action on identities]]
[[!redirects action on identifications]]
[[!redirects action on paths]]
[[!redirects action on equalities]]

[[!redirects binary function application to identities]]
[[!redirects binary function application to identifications]]
[[!redirects binary function application to paths]]
[[!redirects binary function application to equalities]]

[[!redirects application of a binary function to identities]]
[[!redirects application of a binary function to identifications]]
[[!redirects application of a binary function to paths]]
[[!redirects application of a binary function to equalities]]

[[!redirects binary action on identities]]
[[!redirects binary action on identifications]]
[[!redirects binary action on paths]]
[[!redirects binary action on equalities]]

[[!redirects happly]]

[[!redirects function application to identities]]


function complex

+-- {: .rightHandSide}
+-- {: .toc .clickDown tabindex="0"}
### Context
#### Mapping spaces
+--{: .hide}
[[!include mapping space - contents]]
=--
#### Homotopy theory
+--{: .hide}
[[!include homotopy - contents]]
=--
=--
=--

#Contents#
* table of contents
{:toc}

## Idea

In [[categories]] of [[simplicial objects]], like [[SimplicialSets]], the [[sSet]]-value [[hom-object]] between two [[objects]] is often called the _function complex_ ("[[simplicial complex]] of [[functions]] from $X$ to $Y$).

The *simplicial mapping complex* or *simplicial hom complex* of simplicial *[[function complex]]* of two [[simplicial sets]] is the collection of [[maps]], [[left homotopies]] and [[higher homotopies]] between them, all itself organized into a simplicial set.

More formally, [[SimplicialSets]] is a [[Cartesian monoidal category]] and the corresponding [[internal hom]] is what is traditionally known as the simplicial mapping complex.

## Definition

### General
 {#GeneralDefinition}

Suppose $\mathcal{C}$ is a [[category]] that admits small [[coproducts]].

Given [[simplicial objects]] $X,A\in \mathcal{C}^{\Delta^{op}}$,
their __function complex__ is the [[simplicial set]]

$$
  Hom_{\Delta}(X,A)
  \;\;
  \in
  \;\;
  sSet
$$

whose set of $n$-simplices is the set of maps
$\Delta^n\otimes A\to B$

$$
  \big(
    Hom_{\Delta}(X,A)
  \big)_n
  \;\;
  =
  \;\;
  Hom_{\mathcal{C}}
  \big(
    \Delta^n \otimes X
    ,\,
    A
  \big)
  \,,
$$

where $\otimes$ denotes the [[copowering]] of [[simplicial objects]] over [[simplicial sets]] given by

$$
  (S \otimes X)_n
  \,=\,
  \coprod_{i \in S_n}
  X_n
  \,.
$$

### In simplicial sets

Specializing the general definition above to $\mathcal{C} = $ [[sSet]] itself, the required tensoring is just the [[product of simplicial sets]] and so

\begin{definition}\label{FunctionComplexOfSimplicialSets}
\linebreak
The function complex between [[simplicial sets]] $X, A$ is the [[cartesian closed category|cartesian]] [[internal hom]] given by

$$
  X, A \,\in\, sSet
  \;\;\;\;
  \vdash
  \;\;\;\;
  \left\{
  \,
  \begin{array}{l}
    Maps(X,A)
    \;\; \in \;\;
    sSet
    \\
    Maps(X,A)_\bullet
    \;\; = \;\;
    Hom_{sSet}\big(
      \Delta[\bullet] \times X
      ,\,
      A
    \big)
  \end{array}
  \right.
$$
\end{definition}
(e.g. [Goerss & Jardine (2009), I.5](#GoerssJardine09))

## Properties
 {#Properties}

### In simplicial sets

\begin{proposition}\label{ComponentFormulaForEvaluationMap}
**(component formula for [[evaluation map]] on [[function complexes]])**
\linebreak
In [[SimplicialSets]], the [[evaluation map]] of the function complex (from Def. \ref{FunctionComplexOfSimplicialSets}) --- defined as the [[counit of an adjunction|counit]] of the $\big(X \times (-)\big)\dashv Maps(X,-)$-[[adjoint functor|adjunction]] ---  is given by:

$$
  \begin{array}{cc}
    X \times Maps(X,A)
    &\xrightarrow{\;\; ev^X_A  \;\;}&
    A
    \\
    \phantom{A}
    \\
    X_n
      \times
    \overset{
      \mathclap{
        Hom(X \times \Delta[n], A)
      }
    }{
      \overbrace{
        Maps(X,A)_n
      }
    }
    &\xrightarrow{\; \big(ev^X_A\big)_n  \;}&
    A_n
    \\
    \big(
      x
      ,\,
      f
    \big)
    &\mapsto&
    f(x, \iota_n)
    \,,
  \end{array}
$$

where

$$
  \iota_n
     \;\coloneqq\;
  id_{\Delta[n]}
  \;\in\;
  Hom_{sSet}\big( \Delta[n],\, \Delta[n] \big)
  \;\simeq\;
  (\Delta[n])_n
$$

denotes the unique non-degenerate $n$-cell inside $\Delta[n]$.
\end{proposition}
(e.g. [Goerss & Jardine (2009), p. 20](#GoerssJardine09))

\begin{proposition}\label{NerveOfCategoriesPreservesMappingObjects}
**(simplicial nerve intertwines function complexes with functor categories)**
\linebreak

Let $\mathcal{X}, \mathcal{A}$ be [[small categories|small]] [[strict category|strict]] [[categories]] and write $Maps(\mathcal{X}, \mathcal{A})$ for their [[functor category]]. Then under the [[simplicial nerve]]
$
  N \;\colon\; Cat^{sm} \longrightarrow sSet
$
this is [[isomorphic]] to the function complex (Def. \ref{FunctionComplexOfSimplicialSets}) between their separate [[simplicial nerves]]:

$$
  N
  \big(
    Maps(\mathcal{X},\,\mathcal{A})
  \big)
  \;\simeq\;
  Maps
  \big(
    N(\mathcal{X})
    ,\,
    N(\mathcal{A})
  \big)
  \,.
$$

\end{proposition}
(For the proof see [here](nerve#NerveOfCategoriesPreservesMappingObjects) at *[[nerve]]*.)

## Examples

### General

\begin{example}\label{MappingComplexBetweenNervesOfGroupoids}
**([[simplicial mapping complex]] between [[nerves]] of [[groupoids]])**
For $N(\mathcal{G}_i)$ the [[nerves]] of [[groupoids]], their simplicial mapping complex is [[isomorphism|isomorphic]] to the [[nerve]] of the [[functor groupoid]] from $\mathcal{G}_1$ to $\mathcal{G}_2$:

$$
  \big[
    N(\mathcal{G}_1),
    \,
    N(\mathcal{G}_2)
  \big]
  \;\;
  \simeq
  \;\;
  N
  \big(
    Func(\mathcal{G}_1, \, \mathcal{G}_2)
  \big)
  \;\;\;
  \in
  \;
  SimplicialSets
$$
\end{example}

### Nerves of inertia groupoids

\begin{example}\label{EvaluationMapOnNervesOfInertiaGroupoids}
**([[evaluation map]] on [[function complexes]] which are [[nerves]] of [[inertia groupoids]])**
\linebreak

Consider a [[discrete group]] $G$.
We write $\mathbf{B}G$ for its [[delooping groupoid]], here specifically for its [[strict category|strict]] version $\mathbf{B}G \,\coloneqq\,\big(G \rightrightarrows \ast \big)$. The [[nerve]] of this groupoid is the canonical model for the [[simplicial classifying space]]:
$
  N \mathbf{B}G \,=\, \overline{W}G
  \,.
$
The [[functor groupoid]]
$$
  \Lambda \mathbf{B}G
  \;\coloneqq\;
  Maps\big(
    \mathbf{B}\mathbb{Z}
    ,\,
    \mathbf{B}G
  \big)
$$
is also known as the *[[inertia groupoid]]* of $\mathbf{B}G$.

The [[simplicial nerve]] of this functor groupoid is the following [[function complex]] of [[simplicial sets]] (using Prop. \ref{NerveOfCategoriesPreservesMappingObjects}):
$$
  N \Lambda \mathbf{B}G
  \;\coloneqq\;
  Maps\big(
    N \mathbf{B}\mathbb{Z}
    ,\,
    N \mathbf{B}G
  \big)
  \;\simeq\;
  Maps\big(
    S
    ,\,
    N \mathbf{B}G
  \big)
  \,.
$$
Here in the second step we introduced the simplicial set
\[
  \label{MinimalSimplicialCircle}
  S
  \;\coloneqq\;
  \Delta[1]/\partial \Delta[1]
  \;\;\;
  \in
  \;
  sSet
  \,,
\]
which is the [[minimal model]] for $\mathbf{B}\mathbb{Z}$, whose unique non-degenerate 1-cell we will denote by
$$
  \ell \;\coloneqq\; [0,1] \in \Delta[1]_1 \twoheadrightarrow S_1
$$

We now describe in detail the [[evaluation map]] on the simplicial [[function complex]]
$
  Maps\big(
    S
    ,\,
    N \mathbf{B}G
  \big)
  \,.
$

To that end, we denote by
\[
  \label{CellInNerveOfInertiaGroupoid}
 \big(
  \gamma
  ;\,
  g_{n-1}
  ,\,
  g_{n-2}
  ,\,
  \cdots
  ,\,
  g_{0}
 \big)
 \;\; \in \;\;
 \mathrm{Hom}
 \big(
   S \times \Delta[n]
   ,\,
   \overline{W}G
 \big)
 \;\simeq\;
 \Big(
 N
 \mathrm{Map}
  \big(
   { \mathbf{B}\mathbb{Z} }
   ,\,
   { \mathbf{B}G }
  \big)
 \Big)_{n}
\]
the $n$-cell in the [[nerve]] of the [[inertia groupoid]] that corresponds to the sequence of natural transformation which start at the functor
$$
  \gamma
    \,\in\,
   G
    \,\simeq\,
  \mathrm{Hom}_{\mathrm{Grp}}(\mathbb{Z}, G)
    \,\simeq\,
  \mathrm{Hom}\big(
    \mathbf{B}\mathbb{Z}
    ,\,
    \mathbf{B}G
  \big)
$$
and successively have components $g_{n-\bullet} \in G$.

> Throughout we are writing "$Hom$" for [[hom-sets]] and "$Map$" for [[hom-objects]], i.e. for [[internal homs]] and we keep tacitly going back and forth through the [[bijections]] in (eq:CellInNerveOfInertiaGroupoid).

If we abbreviate (this follows conventions familiar in discussion of *[[transgression in group cohomology]]*)
$$
  \begin{aligned}
    Ad_{k}(\gamma)
    & \;\coloneqq\;
    Ad_{(g_{n-1}\cdots g_{n-k})}(\gamma)
    \\
    & \;\coloneqq\;
    (g_{n-1} \cdots g_{n-k})^{-1}
      \cdot
    \gamma \cdot (g_{n-1} \cdots g_{n-k})
    \,,
  \end{aligned}
$$
then this corresponds to a sequence of composable morphisms in the inertia groupoid of this form:
$$
  \gamma
  \xrightarrow{ g_{n-1} }
  Ad_{1}(\gamma)
  \xrightarrow{ g_{n-2} }
  \cdots
  \xrightarrow{\; g_0 \;}
  Ad_{n}(\gamma)
  \;\;\;\;\;
  \in
  \;\;
  \Lambda B G
$$

The simplicial map (eq:CellInNerveOfInertiaGroupoid) maps the non-degenerate $(n+1)$-cells in the [[product of simplicial sets]] (see the discussion [there](product+of+simplices#NonDegenerateCellsInAProductOfSimplices)) of $S$ (eq:MinimalSimplicialCircle) with the [[simplicial simplex|simplicial $n$-simplex]] as follows:

\begin{imagefromfile}
    "file_name": "ActionOfCellInNerveOfIniertiaGroupoid-221205.jpg",
    "width": "800",
    "unit": "px",
    "margin": {
        "top": -20,
        "bottom": 20,
        "right": 0,
        "left": 10
    }
\end{imagefromfile}

This is not exactly what we need unwinding the [[evaluation map]], but it is close: the image of (eq:CellInNerveOfInertiaGroupoid) under the $k$th [[degeneracy map]] evidently gives the following mapping:

\begin{imagefromfile}
    "file_name": "ActOfDegOfCellInNerveOfInertiaGrpd-221205b.jpg",
    "width": "850",
    "unit": "px",
    "margin": {
        "top": -20,
        "bottom": 20,
        "right": 0,
        "left": 10
    }
\end{imagefromfile}

This is the type of mapping that appears in the component formula for the [[evaluation map]] on [[function complexes]] (from Prop. \ref{ComponentFormulaForEvaluationMap}). Hence we find that this evaluation map is given on non-degenerate $(n+1)$-simplices in the product (see again [there](product+of+simplices#NonDegenerateCellsInAProductOfSimplices)) as follows:

\begin{tikzcd}[
    column sep=30pt,
    row sep=4pt
  ]
  S_{n+1}
  \times
  \mathrm{Hom}
  \big(
    S \times \Delta[n+1]
    ,\,
    \overline{W}G
  \big)
  \ar[
    rr,
    "{ \mathrm{ev} }"
  ]
  &&
  \big(
    \overline{W}G
  \big)_{n+1}
  \\
  \Big(
  s_{(1,\cdots, \widehat{k}, \cdots, n)} \ell
  ,\,
  s_k
  \big(
    \gamma
    ;\,
    g_{n-1}
    ,\,
    \cdots
    ,\,
    g_{0}
  \big)
  \Big)
  &\mapsto&
  \big(
    g_{n-1}
    ,\,
    \cdots,
    g_{n-k}
    ,\,
    \mathrm{Ad}_k(\gamma)
    ,\,
    g_{n - (k+1)}
    ,\,
    \cdots
    ,\,
    g_0
  \big)
\end{tikzcd}

The expressions on the right happen to be those that appear in the formula for [[transgression in group cohomology]], see [there](transgression+in+group+cohomology#eq:SumFormulaForTransgressedCocycle).
\end{example}

## Related concepts

* [[internal hom]]

* [[simplicial object]]

* [[simplicial set]]

## Related concepts

* [[mapping space]], [[mapping complex]]

* [[derived mapping space]]

## References

The original definition of a function complex in the generality stated above:

* [[Daniel M. Kan]], _On c.s.s. categories_, Boletín de la Sociedad Matemática Mexicana 2 (1957), 82–94.  [PDF](https://dmitripavlov.org/scans/kan-on-css-categories.pdf).

In function complxes in the generality of [[simplicial presheaves]]

* [[William Dwyer]], [[Daniel Kan]], *Function complexes for diagrams of simplicial sets*, Indagationes Mathematicae (Proceedings) **86** 2 (1983) 139-147 [doi:10.1016/1385-7258(83)90051-3, [pdf](https://core.ac.uk/download/pdf/82652265.pdf)]

Textbook account in [[simplicial homotopy theory]]:

* {#GoerssJardine09} [[Paul Goerss]], [[J. F. Jardine]], Section I.5 of: _[[Simplicial homotopy theory]]_, Progress in Mathematics, Birkhäuser (1999) Modern Birkhäuser Classics (2009) [[doi:10.1007/978-3-0346-0189-4](https://link.springer.com/book/10.1007/978-3-0346-0189-4), [webpage](http://web.archive.org/web/19990208220238/http://www.math.uwo.ca/~jardine/papers/simp-sets/)]

Introduction with an eye towards [[quasicategories]]:

* {#Rezk22} [[Charles Rezk]], Section 15 of: *Introduction to quasicategories* (2022) [[pdf](https://faculty.math.illinois.edu/~rezk/quasicats.pdf), [[Rezk-IntroToQuasicategories.pdf:file]]]

[[!redirects function complexes]]

[[!redirects simplicial mapping complex]]
[[!redirects simplicial mapping complexes]]

[[!redirects simplicial hom complex]]
[[!redirects simplicial hom complexes]]

[[!redirects simplicial hom-complex]]
[[!redirects simplicial hom-complexes]]


function extensionality

+-- {: .rightHandSide}
+-- {: .toc .clickDown tabindex="0"}
### Context
#### Set theory
+-- {: .hide}
[[!include set theory - contents]]
=--
#### Type theory
+-- {: .hide}
[[!include type theory - contents]]
=--
#### Homotopy theory
+-- {: .hide}
[[!include homotopy - contents]]
=--
#### Category theory
+-- {: .hide}
[[!include category theory - contents]]
=--
#### Discrete and concrete objects
+-- {: .hide}
[[!include discrete and concrete objects - contents]]
=--
=--
=--

# Contents
* table of contents
{: toc}

## Idea

The principle of functional extensionality states that two [[functions]] are [[equal]] if their values are equal at every argument.

## Definition

### In set theory
 {#InSetTheory}

In set theory, in the same way that the [[axiom of choice]] has internal and external versions, depending on whether one uses the [[external logic]] or the [[internal logic]] of the [[set theory]], function extensionality also has internal and external versions.

#### External function extensionality

In [[set theory]], let $\mathbb{1}$ denote [[generalized the|the]] [[uniqueness quantifier|unique]] [[singleton]] up to [[bijection]]. There are multiple notions of **external function extensionality**, due to the different possible notions of [[function]] and [[element]] in set theory:

* for all sets $A$ and $B$ and functions $f:A \to B$ and $g:A \to B$, $f = g$ if and only if for all elements $x \in A$, $f(x) = g(x)$.

* for all sets $A$ and $B$ and functions $f:A \to B$ and $g:A \to B$, $f = g$ if and only if for all functions $x:\mathbb{1} \to A$, $f \circ x = g \circ x$.

* for all sets $A$ and $B$ and elements of the [[function set]] $f \in B^A$ and $g \in B^A$, $f = g$ if and only if for all elements $x \in A$, $\mathrm{ev}_{A, B}(f, x) = \mathrm{ev}_{A, B}(g, x)$.

* for all sets $A$ and $B$ and elements of the [[function set]] $f \in B^A$ and $g \in B^A$, $f = g$ if and only if for all elements of the function set $x \in A^\mathbb{1}$, $\mathrm{comp}_{\mathbb{1}, A, B}(f, x) = \mathrm{comp}_{\mathbb{1}, A, B}(g, x)$.

The first is the one most commonly found in foundations of [[categorical set theories]] with separate notions of [[element]] and [[function]]. The second is the one most commonly found in foundations of [[categorical set theories]] where an [[element]] is defined as a [[function]] out of [[generalized the|the]] terminal set $\mathbb{1}$.

The first and the third notions of function extensionality are equivalent to each other, since for every set theory with [[function sets]], the [[category of sets]] is a [[cartesian closed category]], which means that there is a [[bijection]] between the [[hom-sets]]
$$\mathrm{Hom}(X, Y) \cong \mathrm{Hom}(1, Y^X)$$
and thus for every function $f:X \to Y$ there is a unique element of a function set $[f] \in Y^X$, and for every element of a function set $g \in Y^X$ there is a unique function $g':X \to Y$.

#### Internal function extensionality

In [[set theory]], let $\mathbb{1}$ denote [[generalized the|the]] [[uniqueness quantifier|unique]] [[singleton]] up to [[bijection]] and let $\prod_{x \in A} B_x$ denote the [[Cartesian product]] of a family of sets $(B_x)_{x \in A}$. For all sets $A$, let $\Delta_{A}:A \to A \times A$ denote the [[diagonal function]]; this means that the [[preimage]] of $\Delta_{A}$ at $(x, y) \in A \times A$, $\Delta_{A}^*(x, y)$, is a [[subsingleton]], and $(\Delta_{A}^*(x, y))_{x \in A, y \in A}$ is a [[family of sets]].

The principle of **internal function extensionality** is given by one of the two equivalent statements:

* given sets $A$ and $B$, one can derive the element of the set
$$\mathrm{funext}_{A, B} \in \prod_{f \in B^A} \prod_{g \in B^A} \Delta_{B^A}^*(f, g)^{\prod_{x \in A} \Delta_{B}^*(\mathrm{ev}_{A, B}(f, x), \mathrm{ev}_{A, B}(g, x))}$$

* given sets $A$ and $B$, one can derive the element of the set
$$\mathrm{funext}_{A, B} \in \prod_{f \in B^A} \prod_{g \in B^A} \Delta_{B^A}^*(f, g)^{\prod_{x \in A^\mathbb{1}} \Delta_{B^\mathbb{1}}^*(\mathrm{comp}_{\mathbb{1}, A, B}(f, x), \mathrm{comp}_{\mathbb{1}, A, B}(g, x))}$$

This is the set theoretic analogue of the axiom of function extensionality found in [[dependent type theories]], where functions are elements of function types, the type theoretic analogue of function sets, and equalities are represented by identity types, the type theoretic analogue of the [[diagonal subset|diagonal]] [[one-to-one correspondence]], and is true in any set theory with [[Cartesian products]] of arbitrary [[families of sets]] as well as [[function sets]].

### In category theory
  {#InCategoryTheory}

#### Generalizing external function extensionality

There are multiple ways to extend the set-theoretic definition of external function extensionality from the category of sets to more general categories.

* The first notion of external function extensionality extends from the [[category of sets]] to any [[concrete category]] $C$, where objects are specific kinds of sets (such as [[groups]], [[rings]], [[topological spaces]], et cetera) and morphisms are specific kinds of functions between sets (such as [[group homomorphisms]], [[ring homomorphisms]], [[continuous maps]], et cetera).

* The second notion of external function extensionality extends from the category of sets to any [[well-pointed category]] $C$, and corresponds to the statement that the [[terminal object]] is an [[extremal generator]] in [[category]], and is one of the conditions for making a [[pretopos]] a [[well-pointed pretopos]]. This definition is satisfied in any [[concrete category]] $\mathcal{C}$. This is not the same as the first notion of external function extensionality, since not every concrete category is well-pointed, and not every well-pointed category is concrete: [[Grp]] is concrete but not well-pointed, while an arbitrary model of [[ETCS]] is well-pointed but not necessarily concrete.

* The third and fourth notions of external function extensionality extends from the category of sets to any concrete [[cartesian closed category]] $C$, and is equivalent to the first notion in any concrete cartesian closed category.

None of these notions are called "function extensionality" in category theory. The term "function extensionality" is reserved for the generalization of internal function extensionality to arbitrary categories, as documented in the next section.

#### Generalizing internal function extensionality

The notion of **function extensionality** in a category arises from the generalization of the set-theoretic definition of internal function extensionality from the category of sets to more general categories. In particular, similar to internal function extensionality, it the logical formulation of function extensionality in the [[internal language]] of the category. The “internal” formulation can be interpreted in a category with a rich enough [[internal language]]. For instance, function extensionality can be stated in the [[Mitchell-Benabou language]] and is true in any [[topos]]. So every topos *internally* satisfies function extensionality despite the fact that toposes do not generally satisfy the external notion of being concrete or well-pointed. This is because the quantifier $\forall x:X$ in the internal language is interpreted as a quantification over all [[generalized elements]] $I \to X$ rather than merely the [[global elements]] $1 \to X$. Then the statement when quantifying over generalized elements is true as a consequence of the definition of an [[exponential object]].

### In dependent type theory
 {#InTypeTheory}

In [[intensional type theory]], the notion of [[equality]] $a = a'$ is replaced by [[identifications]], these being [[terms]] of [[identity type]] $Id_A(a,a')$. Since such [[identity type]] are in general not [[mere propositions]], care needs to be exercised in stating function extensionality in intensional type theory:

For [[types]] $A, B \,\colon\, Type $ and [[parallel morphisms|parallel]] [[function type|functions]] $f, g  \,\colon\, A \to B$, there are the following two canonical functions (from [[identity types]] of [[function types]] to [[dependent products]] of pointwise identity types), which one may use for expressing function extensionality (eq:FunctionExtensionalityInTypeTheory), both defined via [[path induction]] (see *[[function application to identifications]]*) as shown now:

\[
  \label{happlyDefinition}
  \begin{array}{ll}
     \mathrm{happly}(f, g)
     &\colon&
     Id_{(A \to B)}
     (f ,\, g)
     &
     \longrightarrow
     &
     \underset{
       a \colon A
     }
     {\prod}
     Id_B
     \big(
       f(a)
       ,\,
       g(a)
     \big)
   \\
     \mathrm{happly}(f,f)
     &\colon&
     \mathrm{refl}_{(A \to B)}(f)
     &\mapsto&
     \lambda (a \colon A).
     \mathrm{refl}_B
     \big(f(a)\big)
     \\
     \phantom{-}
     \\
    \mathrm{happly}(f, g)
    &\colon&
    Id_{(A \to B)}(f, g)
    &
    \longrightarrow
    &
    \underset{a \colon A}{\prod}
    \;
    \underset{a' \colon A}{\prod}
    \prod_{p \colon Id_A(a,a')}
    Id_B
    \big(
      f(a) ,\, g(a')
    \big)
    \\
    \mathrm{happly}(f,f)
    &\colon&
    \mathrm{refl}_{A \to B}(f)
    &\mapsto&
    \lambda (a \colon A).
      \lambda (a \colon A).
        \lambda \big(
           \mathrm{refl}_A(x)
            \colon
            Id_A(a, a)
        \big).
        \mathrm{refl}_B\big(f(a)\big)
  \end{array}
\]

{#TheseTwoDefinitions} (These two definitions of $\mathrm{happly}$ become the same under [[singleton contractibility]]. The second definition behaves better with the [[function application to identifications]].)

In general, both functions $\mathrm{happly}(f, g)$ are not [[equivalences of types]] in [[intensional type theory]]: two functions could be defined in different ways, and thus be intensionally different, yet produce the same values on all inputs (i.e. be extensionally the same).

Function extensionality is then the statement that the function $\mathrm{happly}(f, g)$ (eq:happlyDefinition) is an [[equivalence of types]] after all, for all functions $f, g \,\colon\,A \to B$:

\[
  \label{FunctionExtensionalityInTypeTheory}
  \mathrm{funext}(f, g)
  \;\colon\;
  \mathrm{isEquiv}
  \big(
    \mathrm{happly}(f, g)
  \big)
\]

(e.g. [UFP13 (2.9.1)](#UFP13)).

{#StatementForDependentFunctions} In the generality of [[dependent functions]] $f,g \,:\, (d \colon D) \to C_d$ (using the notation [[dependent functions and dependent pairs -- table|here]]) this reads:

(In this dependent generality this is a special case of [UFP13, Lem. 2.9.7](#UFP13).)

Compare this to the analogous extensionality principle for [[dependent pairs]] (see *[there](dependent+sum+type#ExtensionalityPrinciple)*):

\linebreak

### Judgmental function extensionality

One could replace the equivalences of types above with [[judgmental equality]] of types, which results in **judgmental function extensionality**. Applied to each definition, judgmental function extensionality states that for all all types $A$ and $B$ and functions $f:A \to B$ and $g:A \to B$

$$
  Id_{(A \to B)}(f, g)
  \;\;\equiv\;
  \prod_{x:A}
  id_B\big(
    f(x)
    ,\,
    g(x)
  \big)
$$

and

$$
  Id_{(A \to B)}
  (f ,\, g)
  \;\equiv\;
  \prod_{x:A}
  \prod_{y:A}
  \prod_{p \colon Id_A(x, y)}
  Id_B\big(
    f(x) ,\, g(y)
  \big)
$$

respectively.

### For judgmental equality of sections

Suppose that given functions $f:A \to B$ and $g:A \to B$, for all $x:A$, $f(x)$ and $g(x)$ are [[judgmentally equal]] to each other $f(x) \equiv g(x):B$. Then it follows that $f$ and $g$ are judgmentally equal to each other, $f \equiv g:A \to B$, and thus function extensionality holds. This result is crucial in the proof of function extensionality from an [[interval type]] with judgmental computation rules.

## Properties
 {#Properties}

There are a number of axioms in [[dependent type theory]] which imply function extensionality. These include

* [[weak function extensionality]]
* [[univalence axiom]]
* an [[interval type]] with [[judgmental equality|judgmental]] [[computation rules]]
* [[equality reflection]] in [[extensional type theory]]
* the axiom which states that every type is a [[mere proposition]].

### Relation to weak function extensionality

Function extensionality is equivalent to [[weak function extensionality]] -- see at *[References -- General](#ReferencesGeneral)*.

### Relation to the univalence axiom

In [[homotopy type theory]], the [[univalence axiom]] implies type-theoretic function extensionality (eq:FunctionExtensionalityInTypeTheory) -- see at *[References -- in HoTT](#ReferencesInHomotopyTypeTheory)*.

### Relation to interval types

Postulating an [[interval type]] with [[judgmental equality|judgmental]] [[computation rules]] for the point constructors of the interval type implies function extensionality.

The proof assumes a typal [[uniqueness rule]] for [[function types]]. Let $\mathrm{ap}_f \colon Id_{\mathbb{I}}(0, 1) \to Id_A(f(0),f(1))$ be the [[function application to identities]], $\mathrm{concat}_{a, b, c}: Id_A(a , b) \times Id_A(b , c) \to Id_A(a , c)$ be concatenation of identities (i.e. [[transitivity]]), and $\mathrm{inv}_{a, b}: Id_A(a , b) \to Id_A(b , a)$ be the inverse of identities (i.e. [[symmetry]]).

First the proof constructs a function $k:A \to (\mathbb{I} \to B)$ from a dependent function $h:\prod_{x:A} Id_B\big(f(x) , g(x)\big)$, inductively defined by

* $\beta_{k(x)}^0 : Id_B\big(k(x)(0) , f(x)\big)$

* $\beta_{k(x)}^1 : Id_B\big( k(x)(1) , g(x) \big)$

* $\beta_{k(x)}^p : Id_{Id_B\big(k(x)(0) , k(x)(1)\big)}\big(\mathrm{ap}_{k(x)}(p) , \mathrm{concat}_{k(x)(0), f(x), k(x)(1)}(\mathrm{concat}_{k(x)(0), f(x), g(x)}(\beta_{k(x)}^0, h(x)), \mathrm{inv}_{k(x)(1), g(x)}(\beta_{k(x)}^1))\big)$

Then it uses the properties of function types, product types, currying, uncurrying, and the symmetry of products $A \times B \simeq B \times A$, to construct a function $k':\mathbb{I} \to (A \to B)$, inductively defined by

* $\beta_{k'}^0(x): Id_B\big( k'(0)(x) , f(x)\big)$

* $\beta_{k'}^1(x): Id_B\big( k'(1)(x) , g(x) \big)$

* $\beta_{k'}^p(x):\mathrm{ap}_{k'}(p)(x) =_{Id_B\big( k'(0)(x) , k'(1)(x) \big)} \mathrm{concat}_{k'(0)(x), f(x), k'(1)(x)}(\mathrm{concat}_{k'(0)(x), f(x), g(x)}(\beta_{k'}^0(x), h(x)), \mathrm{inv}_{k'(1)(x), g(x)}(\beta_{k'}^1(x)))$

If the interval type has judgmental computation rules for the point constructors, then $k'(x)(0) \equiv f(x)$ and $k'(x)(1) \equiv g(x)$ for all $x:A$, which implies that $k'(0)(x) \equiv f(x)$ and $k'(1)(x) \equiv g(x)$ for all $x:A$, and subsequently that $k'(0) \equiv f$ and $k'(1) \equiv g$. This means that there are identities $\beta_{k'}^0:k'(0) =_{A \to B} f$ and $\beta_{k'}^1:k'(1) =_{A \to B} g$, and an identity

$$\mathrm{concat}_{f, k'(1), g}(\mathrm{concat}_{f, k'(0), k'(1)}(\mathrm{inv}_{k'(0), g}(\beta_{k'}^0), \mathrm{ap}_{k'}(p), \beta_{k'}^1): Id_{(A \to B)}(f , g)$$

thus proving function extensionality.

An interval type with only typal computation rules for the point constructors does not imply function extensionality. This is because the proof with the judgmental computation rules uses the fact that $k'(0)(x) \equiv f(x)$ and $k'(1)(x) \equiv g(x)$ for all $x:A$ implies that $k'(0) \equiv f$ and $k'(1) \equiv g$. However, if the computation rules are typal, then the equivalent statement is that having identities $\beta_{k'}^0(x): Id_B\big(k'(0)(x) , f(x)\big)$ and $\beta_{k'}^1(x): Id_B\big(k'(1)(x) , g(x)\big)$ for all $x:A$ implies that there are identities $\beta_{k'}^0: Id_{(A \to B)}\big(k'(0) , f\big)$ and $\beta_{k'}^1 : Id_{A \to B}\big(k'(1) , g\big)$, which is precisely function extensionality, and so cannot be used to prove function extensionality.

### Relation to equality reflection

To do: write how [[extensional type theory]] automatically satisfies function extensionality.

...

### Relation to propositional logic

To do: write how requiring all types to be [[mere propositions]] in [[dependent type theory]], such as in [[propositional logic as a dependent type theory]] automatically satisfies function extensionality.

...

### Categorical semantics
 {#CategoricalSemantics}

Under the standard [[relation between type theory and category theory]], the [[categorical semantics]] of the [[type]]
$
  \underset{x \colon X}{\prod} Id_Y\big( f(x),\, g(x) \big)
$
of pointwise [[identity type|identifications]] between a [[pair]] of [[parallel morphism|parallel]] [[functions]] $f,g \;\colon\; X \to Y$ is the [[space of sections]] over (hence the right [[base change]] along) $X$ of the [[pullback]]

\begin{tikzcd}[sep=30pt]
  (f,g)^\ast \mathrm{Paths}(Y)
  \ar[r]
  \ar[d]
  \ar[dr, phantom, "{\lrcorner}"{pos=.1}]
  &
  \mathrm{Paths}(Y)
  \ar[d, "{ (\mathrm{ev}_0, \mathrm{ev}_1) }"]
  \\
  X
  \ar[r, "{(f,g)}"]
  &
  Y \times Y
  \mathrlap{\,,}
\end{tikzcd}

where

* $X,Y$ now denote [[objects]] in any given ambient [[categorical model of dependent types]] which serve as the [[categorical semantics]] for the [[types]] of the same name,

* $Paths(Y)$ denotes any "very good" [[path space object]] (see [there](path+space+object#InModelCategories)) of $Y$.

Since the right [[base change]] is [[right adjoint]] to [[pullback]], this means that the [[categorical semantics]] of [[global elements]] of $\underset{x \colon X}{\prod} Id_Y\big( f(x),\, g(x) \big)$, whose immediate categorical semantics is as [[maps]] out of the [[terminal object]] (to be denoted "$\ast$"):

\begin{tikzcd}[sep=20pt]
  \ast
  \ar[r, dashed]
  &
  \underset{x \colon X}{\prod}
  (f,g)^\ast \mathrm{Paths}(X)
  \mathrlap{\,,}
\end{tikzcd}

is [equivalently](adjoint+functor#InTermsOfHomIsomorphism) given by [[maps]] of the form

\begin{tikzcd}[sep=30pt]
  X
  \ar[rr, dashed]
  \ar[dr, equals]
  &&
  (f,g)^\ast \mathrm{Paths}(Y)
  \ar[dl]
  \\
  &
  X
  \mathrlap{\,.}
\end{tikzcd}

These in turn (now by the defining [[universal property]] of the [[pullback]]) are equivalent to maps of the form

\begin{tikzcd}[sep=30pt]
  X
  \ar[rr, dashed]
  \ar[dr, "{(f,g)}"{swap}]
  &&
  \mathrm{Paths}(Y)
  \ar[dl, "{(\mathrm{ev}_0, \mathrm{ev}_1)}"]
  \\
  &
  Y \times Y
  \mathrlap{\,,}
\end{tikzcd}

hence to [[lifts]] of $(f,g)$ through the [[path fibration]] [[display map]].

In contrast, the [[categorical semantics]] of the global type of identifications $Id_{(X \to Y)}(f,g)$ is by maps of the form

\begin{tikzcd}[
  column sep=-30pt,
  row sep=30pt
]
  \ast
  \ar[rr, dashed]
  \ar[dr, "{(f,g)}"{swap}]
  &&
  \mathrm{Paths}\big(\mathrm{Maps}(X,Y)\big)
  \ar[dl, "{(\mathrm{ev}_0, \mathrm{ev}_1)}"]
  \\
  &
  \mathrm{Maps}(X,Y)
  \times
  \mathrm{Maps}(X,Y)
  \,,
\end{tikzcd}

where

* $Maps(X,Y)$ denotes the [[internal hom]] in the ambient [[categorical model of dependent types]] ---

  if one assumes a [[cartesian closed category|cartesian closure]], then this is equivalently denoted as an [[exponential objects]]: $Y^X$.

So the [[categorical semantics]] of function extensionality (eq:FunctionExtensionalityInTypeTheory) says in particular that there is a map

$$
  \phi
  \;\colon\;
  Paths\big(Maps(X,Y)\big)
  \longrightarrow
  Maps\big(X, Paths(Y) \big)
$$

which serves to lift [[global elements]] as above.

Of course we are not just interested in [[global element|global elements]] here. What we really want is an actual [[section]] $Maps\big(X, Paths(Y)\big) \to Paths\big(Maps(X,Y)\big)$ of $\phi$ in the [[slice category|slice]] over $Maps\big(X, (Y \times Y)\big)$ (although this can be derived from the global element formulation by using the [[Yoneda lemma]] together with [[currying]] and uncurrying tricks), such that this exhibits a [[weak equivalence]].

+-- {: .num_prop #FunExtInFibrationCat}
###### Proposition

Function extensionality holds in the [[internal language|internal]] [[type theory]] of a [[type-theoretic fibration category]] precisely if [[dependent products]] (i.e. right [[base change]]) along [[fibrations]] preserve [[acyclic fibrations]].

=--

([Shulman 12, lemma 5.9](#Shulman12))

+-- {: .num_example #EveryPresentableLocallyCartesinClosedInfinityCatInterpretsHoTTPlusFunExt}
###### Example

The condition in prop. \ref{FunExtInFibrationCat} holds in particular in [[right proper model category|right proper]] [[Cisinski model structures]], since in these right [[base change]] along fibrations is a [[right Quillen functor]] (see e.g. the proof here).

Notice that every [[presentable (∞,1)-category|presentable]] [[locally Cartesian closed (∞,1)-category]] (by the discussion there) has a presentation by a [[right proper model category|right proper]] [[Cisinski model category]]. Accordingly we may say that every [[presentable (∞,1)-category|presentable]] [[locally Cartesian closed (∞,1)-category]] interprets [[HoTT]]+FunExt.

=--

## See also

* [[extensionality]]

* [[homotopy]]

* [[concrete category]]

* [[prefunction]]

* [[weak function extensionality]]

* [[sequence extensionality]]

* [[equivalence extensionality]]

## References
 {#References}

### General
 {#ReferencesGeneral}

Discussion of variants of function extensionality in [[Martin-Löf type theory]], and their relation:

* [[Richard Garner]], *On the strength of dependent products in the type theory of Martin-Löf*, Annals of Pure and Applied Logic **160** 1 (2009) 1-12 [[arXiv:0803.4466](https://arxiv.org/abs/0803.4466), [doi:10.1016/j.apal.2008.12.003](https://doi.org/10.1016/j.apal.2008.12.003)]

* [[Peter LeFanu Lumsdaine]], *Strong functional extensionality from weak* (2011) [[blog post](http://homotopytypetheory.org/2011/12/19/strong-funext-from-weak)]

* [Rijke (2022), §13.1](#Rijke22)

Proofs of function extensionality from an [[interval type]] with [[judgmental equality|judgmental]] [[computation rules]]:

* {#Shulman11} [[Mike Shulman]], _An interval type implies functional extensionality_ (2011) [[blog post](http://homotopytypetheory.org/2011/04/04/an-interval-type-implies-function-extensionality/)]

### In homotopy type theory
 {#ReferencesInHomotopyTypeTheory}

Discussion of function extensionality in [[homotopy type theory]] and proof that it is implied by [[univalence]]:

Original announcement in:

* {#Voevodsky10} [[Vladimir Voevodsky]], p. 8 of: *Univalent Foundations Project* (2010) [[pdf](http://www.math.ias.edu/~vladimir/Site3/Univalent_Foundations_files/univalent_foundations_project.pdf), [[Voevodsky-UFP2010.pdf:file]]]

Textbook accounts:

* {#UFP13} [[Univalent Foundations Project]], §2.9 & §4.9 *[[Homotopy Type Theory -- Univalent Foundations of Mathematics]]* (2013) [[web](http://homotopytypetheory.org/book/), [pdf](http://hottheory.files.wordpress.com/2013/03/hott-online-323-g28e4374.pdf)]

* {#Rijke22} [[Egbert Rijke]], §13 in: *[[Introduction to Homotopy Type Theory]]*, Cambridge Studies in Advanced Mathematics, Cambridge University Press [[arXiv:2212.11082](https://arxiv.org/abs/2212.11082)]

Exposition:

* {#Angiuli11} [[Carlo Angiuli]], *Univalence implies function extensionality* (2011) [[blog post](http://homotopytypetheory.org/2011/12/05/hott-in-prose/), [pdf](http://hottheory.files.wordpress.com/2011/12/hott2.pdf)]

Tutorial for formalization in [[Coq]]:

* {#BauerLumsdaine} [[Andrej Bauer]], [[Peter LeFanu Lumsdaine]], *[[Oberwolfach HoTT-Coq tutorial]]* (2011)

Formalization in cubical [[Agda]]:

* [[1lab]], *[$\Pi$-types and function extensionality](https://1lab.dev/HoTT.html#%CF%80-types-and-function-extensionality)*

Discussion of the [[categorical semantics]] in the context of [[homotopy type theory]]:

* {#Shulman12} [[Michael Shulman]], _Univalence for inverse diagrams and homotopy canonicity_, Mathematical Structures in Computer Science, Volume 25, Issue 5 ( _From type theory and homotopy theory to Univalent Foundations of Mathematics_ ) June 2015 ([arXiv:1203.3253](https://arxiv.org/abs/1203.3253), [doi:/10.1017/S0960129514000565](https://doi.org/10.1017/S0960129514000565))

On definitional function extensionality in [[higher observational type theory]]:

* [[Mike Shulman]], *Towards Third-Generation HOTT -- Part 1* (2022) [[slides](https://www.cmu.edu/dietrich/philosophy/hott/slides/shulman-2022-04-28.pdf), [video](https://www.youtube.com/watch?v=FrxkVzItMzA)]

[[!redirects function extensionality]]
[[!redirects functional extensionality]]

[[!redirects external function extensionality]]
[[!redirects external functional extensionality]]

[[!redirects internal function extensionality]]
[[!redirects internal functional extensionality]]

[[!redirects FunExt]]

[[!redirects morphism extensionality]]


function field

## Definition

Let $X$ be an [[affine variety]] over a field $k$ with the ring of [[regular function]]s $\mathcal{O}(X)$. A __function field__ is the [[field of fractions]] of $\mathcal{O}(X)$.

## Function field analogy

[[!include function field analogy -- table]]

* Wikipedia, _[Function field analogy](https://en.wikipedia.org/wiki/Function_field_analogy)_

## Related concepts

* [[number field]]

## References

* Wikipedia (English): [Function field of an algebraic variety](http://en.wikipedia.org/wiki/Function_field_of_an_algebraic_variety)

* Caterina Consani and [[Matilde Marcolli]], _Quantum statistical mechanics over function fields_, [math.QA/0607363](http://arxiv.org/abs/math/0607363)

* Wikipedia, _[Algebraic function field](https://en.wikipedia.org/wiki/Algebraic_function_field)_

[[!redirects function field]]
[[!redirects function fields]]


function field analogy

+-- {: .rightHandSide}
+-- {: .toc .clickDown tabindex="0"}
###Context###
#### Arithmetic geometry
+--{: .hide}
[[!include arithmetic geometry - contents]]
=--
#### Analytic geometry
+--{: .hide}
[[!include analytic geometry -- contents]]
=--
#### Complex geometry
+--{: .hide}
[[!include complex geometry - contents]]
=--
=--
=--

#Contents#
* table of contents
{:toc}

## Idea

There is a noticeable [[analogy]] between phenomena ([[theorems]]) in the theory of [[number fields]] and those in the theory of [[function fields]] over [[finite fields]] ([Weil 39](#Weil39), [Iwasawa 69](#Iwasaw69), [Mazur-Wiles 83](#MazurWiles83)), hence between the theories of the two kinds of _[[global fields]]_. When regarding [[number theory]] dually as [[arithmetic geometry]], then one may see that this analogy extends further to include [[complex analytic geometry]], the theory of [[complex curves]] (e.g. [Frenkel 05](#Frenkel05)).

At a very basic level the analogy may be plausible from the fact that both the [[integers]] $\mathbb{Z}$ as well as the [[polynomial rings]] $\mathbb{F}_q[x]$ (over [[finite fields]] $\mathbb{F}_q$) are [[principal ideal domains]] with [[finite group|finite]] [[group of units]], all [[quotients]] being finite rings and with infinitely many [[prime ideals]], which already implies that a lot of [[arithmetic]] over these rings is similar. Since [[number fields]] are the [[finite number|finite]] [[dimension|dimensional]] [[field extensions]] of the [[field of fractions]] of $\mathbb{Z}$, namely the [[rational numbers]] $\mathbb{Q}$, and since [[function fields]] are just the finite-dimensional field extensions of the fields of fractions $\mathbb{F}_q(x)$ of $\mathbb{F}_q[x]$, this similarity plausibly extends to these extensions.

The [[entire function|entire]] [[holomorphic functions]] on the [[complex plane]] are, while not quite an principal ideal domain, still a [[Bézout domain]], but in [[constructive mathematics]] the [[integers]] and the [[polynomial rings]] over [[finite fields]] are only Bézout domains as well.

But the analogy ranges much deeper than this similarity alone might suggest.
For instance ([Weil 39](#Weil39)) defined an invariant of a [[number field]] -- the _[[genus of a number field]]_-- which is analogous to the [[genus of a curve|genus]] of the [[algebraic curve]] on which a given [[function field]] is the [[rational functions]]. This is such as to make the statement of the [[Riemann-Roch theorem]] for [[algebraic curves]] extend to [[arithmetic geometry]] ([Neukirch 92, chapter II, prop.(3.6)](#Neukirch92)).

Another notable part of the analogy is the fact that there are natural analogs of the [[Riemann zeta function]] in all three columns of the analogy. This aspect has found attention notably through the lens of regarding [[number fields]] as [[rational functions]] on "[[arithmetic curves]] over the would-be [[field with one element]] $\mathbb{F}_1$".

The analogy between [[p-adic numbers]] and [[Laurent series]] over $\mathbb{F}_p$  is strengthened by ([Fontaine-Winterberger 79](#FontaineWinterberger79)), which shows that the absolute [[Galois groups]] of the [[perfect field|perfection]] of $\mathbb{F}_p((t))$ and of $\mathbb{Q}_p[p^{\frac{1}{p^\infty}}]$ are [[isomorphism|isomorphic]]. For more review of this see also ([Hartl 06](#Hartl06)). (The generalization of this to higher dimensions is the topic of [[perfectoid spaces]].)

It is also the function field analogy which induces the conjecture of the [[geometric Langlands correspondence]] by analogy from the number-theoretic [[Langlands correspondence]]. Here one finds that the [[moduli stack of bundles]] over a [[complex curve]] is analogous in absolute [[arithmetic geometry]] to the [[coset space]] of the [[general linear group]] with coefficients in the [[ring of adeles]] of a number field, on which [[unramified]] [[automorphic representations]] are functions. Under this analogy the [[Weil conjecture on Tamagawa numbers]] may be regarded as giving the [[groupoid cardinality]] of the [[moduli stack of bundles]] in [[arithmetic geometry]].

In summary then the analogy says that the theories of [[number fields]] and of [[function fields]] both look much like a [[global analytic geometry]]-version of the theory of [[complex curves]].

## Formalizations
 {#Formalizations}

To date the function field analogy remains just that, an [[analogy]], though various research programs may be thought of as trying to provide a context in which the analogy would become a consequence of a systematic theory (see e.g. the introduction of [v.d. Geer et al 05](#vdGeer05)). This includes

* [[Arakelov geometry]];

* [[global analytic geometry]].

* geometry "over [[F1]]".

Regarding the last point, in particular [[Borger's absolute geometry]] ([Borger 09](#Borger09)) makes precise the analogy between [[Spec(Z)]] and the [[polynomial ring]] $k[z]$/[[entire holomorphic function]]-ring $\mathcal{O}_{\mathbb{C}}$ by interpreting the analog of the canonical [[derivation]] $\frac{\partial}{\partial z}$ on the latter two as the [[Fermat quotient]] operation, and more generally by interpreting the lift of this to arithmetic spaces over ${Spec}(\mathbb{Z})$ as lifts of [[Frobenius homomorphisms]] as given by [[Lambda-ring]] structures. See at _[Borger's absolute geometry -- Motivation](Borger%27s+absolute+geometry#Motivation)_ for more on this.

  In this context the analogy between geometry over [[number fields]] and over [[function fields]] is made precise by showing ([Borger 09, section 7](#Borger09)) that for any smooth connected curve $S/\mathbb{F}_q$ over a [[finite field]] $\mathbb{F}_q$ the standard [[geometric morphism]] of ("big") [[toposes]]

  $$
    Spec(S/\mathbb{F}_q)\longrightarrow Spec(\mathbb{F}_q)
  $$

  factors through an alternative base topos $\widetilde Spec(\mathbb{F}_q)$

  $$
    Spec(S/\mathbb{F}_q)\longrightarrow \widetilde Spec(\mathbb{F}_q) \longrightarrow Spec(\mathbb{F}_q)
  $$

  which, while different from $Spec(\mathbb{F}_q)$ is "close" to $Spec(\mathbb{F}_q)$ in some precise sense, but which has the advantage that its construction does exist for $q = 1$ in that there is directly analogous

  $$
    Spec(\mathbb{Z}) \longrightarrow \widetilde Spec(\mathbb{F}_1)
    \,,
  $$

  where the notation $\widetilde Spec(\mathbb{F}_1)$ here stands for Borger's the topos over [[Lambda-rings]], see at _[[Borger's absolute geometry]]_ for the actual details.

## Overview
 {#Overview}

[[!include function field analogy -- table]]

$\,$

[[!include Langlands analogies -- table]]

## Related concepts

* [[MKR analogy]] in [[arithmetic topology]]

## References

Original articles includes

* {#Weil39} [[André Weil]], _Sur l'analogie entre les corps de nombres algébrique et les corps de fonctions algébrique_, Revue Scient. 77, 104-106, 1939

* {#Iwasaw69} [[Kenkichi Iwasawa]], _Analogies between number fields and function fields_, in _Some Recent Advances in the Basic Sciences_, Vol. 2 (Proc. Annual Sci. Conf., Belfer Grad. School Sci., Yeshiva Univ., New York, 1965-1966), Belfer Graduate School of Science, Yeshiva Univ., New York, pp. 203–208, [MR 0255510](http://www.ams.org/mathscinet-getitem?mr=0255510)

  for more on this see: Wikipedia, _[Main conjecture of Iwasawa theory](http://en.wikipedia.org/wiki/Main_conjecture_of_Iwasawa_theory)_

* {#FontaineWinterberger79} [[Jean-Marc Fontaine]], [[Jean-Pierre Wintenberger]], _Extensions algébrique et corps des normes des extensions APF des corps locaux_, C. R. Acad. Sci. Paris Sér. A–B 288(8) (1979), A441–A444

* {#MazurWiles83} [[Barry Mazur]], [[Andrew Wiles]], _Analogies between function fields and number fields_, American Journal of Mathematics Vol. 105, No. 2 (Apr., 1983), pp. 507-521 ([JStor](http://www.jstor.org/stable/2374266))

Textbook accounts include

* {#Neukirch92} [[Jürgen Neukirch]], _Algebraische Zahlentheorie_ (1992), English translation _Algebraic Number Theory_,  Grundlehren der Mathematischen Wissenschaften 322, 1999 ([pdf](http://www.plouffe.fr/simon/math/Algebraic%20Number%20Theory.pdf))

* {#Rosen02} Michael Rosen, _Number theory in function fields_, Graduate texts in mathematics, 2002

Tables showing the parallels between number fields and function fields are in

* {#Goss92} [[David Goss]] _Dictionary_, in David Goss, David R. Hayes, Michael Rosen (eds.) _The Arithmetic of Function Fields_, Ohio State Univ. Math. Res. Inst. Publ., 2, de Gruyter, Berlin, 1992,  pp. 475-482,

* {#Poonen06} [[Bjorn Poonen]], section 2.6 of _Lectures on rational points on curves_, 2006 ([pdf](http://math.mit.edu/~poonen/papers/curves.pdf))

* {#Hartl06} [[Urs Hartl]], _A Dictionary between Fontaine-Theory and its Analogue in Equal Characteristic_ ([arXiv:math/0607182](http://arxiv.org/abs/math/0607182))

See also

* M. Blickle,[[Hélène Esnault]], K. Rülling, _Characteristic $0$ and $p$ analogies, and somemotivic cohomology_ ([[EsnaultAnalogy.pdf:file]])

A collection of more recent developments is in

* {#vdGeer05} van der Geer et al (eds.) _Number Fields and Function Fields – Two Parallel Worlds_, Birkhäuser 2005 ([publisher page](http://www.springer.com/birkhauser/mathematics/book/978-0-8176-4397-3))

Discussion including also the complex-analytic side includes

* {#Frenkel05} [[Edward Frenkel]], section 2 of _Lectures on the Langlands Program and Conformal Field Theory_ ([arXiv:hep-th/0512172](http://arxiv.org/abs/hep-th/0512172)).

and a comparison of the number theory to that of [[foliations]] is in

* {#Deninger07} [[Christopher Deninger]], _Analogies between analysis on foliated spaces and arithmetic geometry_ ([arXiv:0709.2801](http://arxiv.org/abs/0709.2801))

An actual formalization of the analogy between geometry over number fields and function fields is in

* {#Borger09} [[James Borger]], section 7 of _Lambda-rings and the field with one element_ ([arXiv/0906.3146](http://arxiv.org/abs/0906.3146))


function field analogy -- table

**[[function field analogy]]**

|   | [[number fields]] ("[[function fields]] of [[curves]] over [[F1]]")  |  [[function fields]] of [[curves]] over [[finite fields]] $\mathbb{F}_q$ ([[arithmetic curves]])  | [[Riemann surfaces]]/[[complex curves]] |
|----|-------------------|----------------------|----|
| **[[affine line|affine]] and [[projective line]]**  |  |  |  |
|   | $\mathbb{Z}$ ([[integers]]) | $\mathbb{F}_q[z]$ ([[polynomials]], [[polynomial algebra]] on [[affine line]] $\mathbb{A}^1_{\mathbb{F}_q}$) |  $\mathcal{O}_{\mathbb{C}}$ ([[holomorphic functions]] on [[complex plane]]) |
|   | $\mathbb{Q}$ ([[rational numbers]]) | $\mathbb{F}_q(z)$ ([[rational fractions]]/[[rational function on an affine variety|rational function on affine line]] $\mathbb{A}^1_{\mathbb{F}_q}$)  | [[meromorphic functions]] on [[complex plane]] |
|   | $p$ ([[prime number]]/non-archimedean [[place]])  |  $x \in \mathbb{F}_p$, where $z - x \in \mathbb{F}_q[z]$ is the [[irreducible element|irreducible]] [[monic polynomial]] of [[degree of a polynomial|degree]] one | $x \in \mathbb{C}$, where $z - x \in \mathcal{O}_{\mathbb{C}}$ is the [[function]] which [[subtracts]] the [[complex number]] $x$ from the [[variable]] $z$ |
|   | $\infty$ ([[place at infinity]])  |   |  $\infty$  |
|   | $Spec(\mathbb{Z})$ ([[Spec(Z)]])  |  $\mathbb{A}^1_{\mathbb{F}_q}$ ([[affine line]]) |  [[complex plane]]  |
|   | $Spec(\mathbb{Z}) \cup place_{\infty}$   | $\mathbb{P}_{\mathbb{F}_q}$ ([[projective line]])  |  [[Riemann sphere]]  |
|  | $\partial_p \coloneqq \frac{(-)^p - (-)}{p}$ ([[Fermat quotient]]) | $\frac{\partial}{\partial z}$ ([[coordinate]] [[derivation]])  |  " |
|   | [[genus of a number field|genus of the rational numbers]] = 0 |  |  [[genus of a surface|genus of the Riemann sphere]] = 0 |
| **[[formal neighbourhoods]]**  |   |   |   |
|   | $\mathbb{Z}/(p^n \mathbb{Z})$ ([[prime power local ring]]) |  $\mathbb{F}_q [z]/((z-x)^n \mathbb{F}_q [z])$ ($n$-th order univariate [[local Artinian ring|local Artinian $\mathbb{F}_q$-algebra]])  |  $\mathbb{C}[z]/((z-x)^n \mathbb{C}[z])$ ($n$-th order univariate [[Weil algebra|Weil $\mathbb{C}$-algebra]])  |
|   | $\mathbb{Z}_p$ ([[p-adic integers]]) |  $\mathbb{F}_q[ [ z -x ] ]$ ([[power series]] around $x$)  |  $\mathbb{C}[ [z-x] ]$ ([[holomorphic functions]] on [[formal disk]] around $x$)  |
|   |  $Spf(\mathbb{Z}_p)\underset{Spec(\mathbb{Z})}{\times} X$ ("$p$-[[arithmetic jet space]]" of $X$ at $p$) |  |  [[formal disks]] in $X$  |
|   | $\mathbb{Q}_p$ ([[p-adic numbers]]) | $\mathbb{F}_q((z-x))$ ([[Laurent series]] around $x$) |  $\mathbb{C}((z-x))$ ([[holomorphic functions]] on punctured [[formal disk]] around $x$) |
|   | $\mathbb{A}_{\mathbb{Q}} = \underset{p\; place}{\prod^\prime}\mathbb{Q}_p$ ([[ring of adeles]])  | $\mathbb{A}_{\mathbb{F}_q((t))}$  ( [adeles of function field](ring%20of%20adeles#ForAGlobalField) ) |  $\underset{x \in \mathbb{C}}{\prod^\prime} \mathbb{C}((z-x))$ ([[restricted product]] of holomorphic functions on all punctured formal disks, finitely of which do not extend to the unpunctured disks) |
|   | $\mathbb{I}_{\mathbb{Q}} = GL_1(\mathbb{A}_{\mathbb{Q}})$ ([[group of ideles]])  | $\mathbb{I}_{\mathbb{F}_q((t))}$  ( [[group of ideles|ideles of function field]] ) |  $\underset{x \in \mathbb{C}}{\prod^\prime} GL_1(\mathbb{C}((z-x)))$   |
| **[[theta functions]]**  |  |  |  |
|   |  [[Jacobi theta function]] |  |  |  |
| **[[zeta functions]]**  |  |  |  |
|   |  [[Riemann zeta function]] | [[Goss zeta function]] | |
|    |  |  |  |
| **[[branched covering]] curves**  |  |  |  |
|   | $K$ a [[number field]] ($\mathbb{Q} \hookrightarrow K$ a possibly [[ramified]] [[finite set|finite]] [[dimension|dimensional]] [[field extension]]) |  $K$ a [[function field]] of an [[algebraic curve]] $\Sigma$ over $\mathbb{F}_p$ |  $K_\Sigma$  ([[sheaf of rational functions]] on [[complex curve]] $\Sigma$)  |
|   | $\mathcal{O}_K$ ([[ring of integers]]) |   | $\mathcal{O}_{\Sigma}$ ([[structure sheaf]])  |
|   | $Spec_{an}(\mathcal{O}_K) \to Spec(\mathbb{Z})$ ([[spectrum of a commutative ring|spectrum]] with archimedean [[places]])   | $\Sigma$ ([[arithmetic curve]]) |   $\Sigma \to \mathbb{C}P^1$ ([[complex curve]] being [[branched cover of Riemann sphere]])  |
|   | $\frac{(-)^p - \Phi(-)}{p}$ (lift of [[Frobenius morphism]]/[[Lambda-ring]] structure) | $\frac{\partial}{\partial z}$ | "  |
|   | [[genus of a number field]] |  [[genus of an algebraic curve]] | [[genus of a surface]] |
| **[[formal neighbourhoods]]**  |   |    |    |
|   | $v$ prime ideal in [[ring of integers]] $\mathcal{O}_K$ | $x \in \Sigma$ | $x \in \Sigma$ |
|   | $K_v$ ([[formal completion]] at $v$)  |   | $\mathbb{C}((z_x))$ ([[function algebra]] on punctured [[formal disk]] around $x$) |
|   | $\mathcal{O}_{K_v}$ ([[ring of integers]] of [[formal completion]]) |    |  $\mathbb{C}[ [ z_x ] ]$ ([[function algebra]] on [[formal disk]] around $x$) |
|   | $\mathbb{A}_K$ ([[ring of adeles]]) |   |  $\prod^\prime_{x\in \Sigma} \mathbb{C}((z_x))$ ([[restricted product]] of [[function rings]] on all punctured [[formal disks]] around all points in $\Sigma$)  |
|   | $\mathcal{O}$ |  | $\prod_{x\in \Sigma} \mathbb{C}[ [z_x] ] $ (function ring on all [[formal disks]] around all points in $\Sigma$) |
|   | $\mathbb{I}_K = GL_1(\mathbb{A}_K)$ ([[group of ideles]]) |  | $\prod^\prime_{x\in \Sigma} GL_1(\mathbb{C}((z_x)))$ |
| **[[Galois theory]]** |   |   |   |
|   |  [[Galois group]] |  " | $\pi_1(\Sigma)$ [[fundamental group]]  |
|   |  [[Galois representation]] |  " | [[flat connection]] ("[[local system]]") on $\Sigma$ |
| **[[class field theory]]** |   |   |   |
|  | [[class field theory]] | " | [[geometric class field theory]] |
|    | [[Hilbert reciprocity law]] | [[Artin reciprocity law]] | [[Weil reciprocity law]] |
|  | $GL_1(K)\backslash GL_1(\mathbb{A}_K)$ ([[idele class group]]) | " |   |
|  | $GL_1(K)\backslash GL_1(\mathbb{A}_K)/GL_1(\mathcal{O})$  | " |  $Bun_{GL_1}(\Sigma)$ ([[moduli stack of bundles|moduli stack of line bundles]], by [[Weil uniformization theorem]])  |
| **non-abelian class field theory and automorphy**  |   |  |  |  |
|   | number field [[Langlands correspondence]] |  function field [[Langlands correspondence]] | [[geometric Langlands correspondence]] |
|   | $GL_n(K) \backslash GL_n(\mathbb{A}_K)//GL_n(\mathcal{O})$ ([[constant sheaves]] on this [[stack]] form [[unramified]] [[automorphic representations]]) |  " | $Bun_{GL_n(\mathbb{C})}(\Sigma)$ ([moduli stack of bundles on the curve](moduli+space+of+bundles#OverCurvesAndTheLanglandsCorrespondence) $\Sigma$, by [[Weil uniformization theorem]])   |
|   | [Tamagawa-Weil for number fields](Weil+conjecture+on+Tamagawa+numbers#NumberFieldCase)  | [Tamagawa-Weil for function fields](Weil+conjecture+on+Tamagawa+numbers#FunctionFieldCase)  |   |
| **[[theta functions]]**  |  |  |  |
|  |  [[Hecke theta function]]  |  | [[functional determinant]] [[determinant line bundle|line bundle]] of [[Dirac operator]]/chiral [[Laplace operator]] on $\Sigma$ |
| **[[zeta functions]]**  |  |  |  |
|   |  [[Dedekind zeta function]] | [[Weil zeta function]] | [[zeta function of a Riemann surface]]/[[zeta function of an elliptic differential operator|of the Laplace operator]] on $\Sigma$ |
|   |   |  |  |  |
| **[[higher dimensional arithmetic geometry|higher dimensional spaces]]**  |   |  |  |  |
| **[[zeta functions]]**  | [[Hasse-Weil zeta function]]  |  |  |  |


function field of a variety

## Related concepts

* [[meromorphic function]]

* [[sheaf of rational functions]]

## References

* Wikipedia, _[Function field of an algebraic variety](http://en.wikipedia.org/wiki/Function_field_of_an_algebraic_variety)_

[[!redirects functions fields of varieties]]


function limit space

[[!redirects function limit spaces]]
[[!redirects Hausdorff function limit space]]
[[!redirects Hausdorff function limit spaces]]

+-- {: .rightHandSide}
+-- {: .toc .clickDown tabindex="0"}
### Context
#### Analysis
+-- {: .hide}
[[!include analysis - contents]]
=--
=--
=--

#Contents#
* table of contents
{:toc}

## Idea ##

The term "function limit space" is used for instance by  [Petrakis (2016, p. 9)](#Petrakis16).

## See also ##

* [[limit of a function]]

* [[pointwise continuous function]]

* [[algebraic limit field]]

## References

* {#Petrakis16} Iosif Petrakis: *Limit spaces with approximations*, Annals of Pure and Applied Logic **167** 9 (2016) 737-752 [[doi:10.1016/j.apal.2016.04.013](https://doi.org/10.1016/j.apal.2016.04.013), [pdf](https://www.math.lmu.de/~petrakis/LSA.pdf)]


function machine

#Contents#
* table of contents
{:toc}

## Idea

A **function machine** is a generalization of [[neural networks]] to potentially infinite dimensional layers, motivated by the study of universal approximation of [[operators]] and [[functionals]] over abstract [[Banach spaces]].

## Definition
 {#Definition}
A function machine's layers is defined by the type of layers it is composed with.
+-- {: .num_defn}
###### Definition
Let $K \subset \mathbb{R}^d, K' \subset \mathbb{R}^{d'}$ both compact, $T$ is some affine map.

* (Operator layer) When $T:\mathcal{L}^1(K, \mu)\to \mathcal{L}^1(K', \mu)$, $T = T^\mathfrak{o}$ is said to be an **operator layer** if there is some continuous family of measures $(W_t \ll \mu)$ indexed by $t \in K'$ and a function $b \in \mathcal{L}^1(K, \mu)$ such that:

$$T^\mathfrak{o}: f \mapsto \left(t \mapsto \int_K f dW_t  + b(t)\right)$$

* (Functional layer) When $T:\mathcal{L}^1(K, \mu) \to \mathbb{R}^{d'}$, $T = T^\mathfrak{f}$ is said to be a **functional layer** if there is some measure $W \ll \mu$ and a vector $b \in \mathbb{R}^d$ such that:

$$T^\mathfrak{f}: f \mapsto \int f dW + b$$

* (Basis layer) When $T:\mathbb{R}^d \to \mathcal{L}^1(K',\mu)$, $T=T^\mathfrak{b}$ is said to be a **basis layer** if there is some function $w:K'\to\mathbb{R}^d$ and $b \in \mathcal{L}^1(K', \mu)$ such that:
    $$T^\mathfrak{b} : y \mapsto \left(t \mapsto \sum_{i=1}^d y_i[w(t)]_i + b(t) \right)$$

* (Fully-connected layer) When the inputs and outputs of a layer are finite dimensional, we yield the standard **fully-connected layer**, denoted $T^\mathfrak{n}$

=--

One can now, for instance, define an 1-hidden layer operator network to be the composition of two operator layers:

$$F[f] = (T^\mathfrak{o}\circ g \circ T^\mathfrak{o})[f] = s \mapsto b'(s) + \int_{K''}g\left(\int_K f dW_t + b(t) \right)dW_s$$

where $(W_t \ll \mu)_{t \in K''}$, $(W_s\ll\mu)_{s \in K'}$ are families of absolutely continuous measures w.r.t. the Lebesgue measure $\mu$, $b$ and $b'$ are measurable bias functions over compact domains $K''$ and $K'$ respectively, and $g$ an activation function.

## Related concepts

* [[neural network]]

* [[tensor network]]

## References

* {#Guss2017} William Guss, _Deep Function Machines: Generalized Neural Networks for Topological Layer Expression_,([arXiv:1612.04799](https://arxiv.org/abs/1612.04799)

* {#GussSalakhutdinov2019} William Guss, Ruslan Salakhutdinov, _On Universal Approximation by Neural Networks with Uniform Guarantees on Approximation of Infinite Dimensional Maps_,([arXiv:1910.01545](https://arxiv.org/abs/1910.01545)


function monad

[[!redirects reader monad]]

+-- {: .rightHandSide}
+-- {: .toc .clickDown tabindex="0"}
### Context
#### Categorical algebra
+-- {: .hide}
[[!include categorical algebra -- contents]]
=--
#### Mapping space
+--{: .hide}
[[!include mapping space - contents]]
=--
#### Type theory
+-- {: .hide}
[[!include type theory - contents]]
=--
=--
=--

#Contents#
* table of contents
{:toc}

## Idea

In a [[cartesian closed category]]/[[type theory]] $\mathcal{C}$, given any [[object]]/[[type]] $B$ there is a [[monad]]

$$
  Maps(B,-) \colon \mathcal{C} \to \mathcal{C}
$$

given by forming the [[internal hom]] out of $B$, hence the "space of functions" out of $B$. This is sometimes called the _function monad_.  Its [[unit of a monad|unit]] is given by sending values to [[constant functions]] with that value, and the monad operation is given by evaluating on the [[diagonal]].

In the context of [[monads in computer science]] this monad is called the _reader monad_ or _environment monad_. It serves to write programs in which all operations may "read in" a state of type $B$ (an "environment" variable).

## Definition
 {#Definition}

We first describe the reader monad explicitly

* [in components](#DefinitionInComponents)

as a monad on $\mathcal{C} =$ [[Sets]].

Then we describe it, more generally as the monad induced by a right [[base change]] [[adjoint functor|adjunction]]

* [via base change](#DefinitionViaBaseChange).

In this form the construction makes sense more generally (see for instance the *[[quantum reader monad]]*).

We write

$$
  Maps(-,-)
    \;\colon\;
  \mathcal{C}^{op}
    \times
  \mathcal{C}
    \longrightarrow
  \mathcal{C}
$$

for the corresponding [[internal hom]]. In [[Sets]] this is the operation of forming [[function sets]].

\linebreak

Fix $B \in \mathcal{C}$.

### In components
 {#DefinitionInComponents}

1. The [[underlying]]-[[functor]] of the $B$-reader monad is

   $$
     \bigcirc_B \;\colon\; D \;\mapsto\; Maps(B,D)
     \,.
   $$

1. The [[unit of a monad|unit of the monad]] is given by constructing [[constant functions]]:

   $$
     \begin{array}{ccc}
       D
       &
         \xrightarrow{
           \;\;
           \eta^{\bigcirc_B}_D
           \;\;
         }
       &
       Maps(B,D)
       \\
       d
       &\mapsto&
      \big(
         b \;\mapsto\; d
      \big)
      \mathrlap{ \;=\; const_d }
     \end{array}
   $$

1. The monad [[multiplication]] is given by "evaluating [[diagonal map|diagonally]]:

   $$
     \begin{array}{ccc}
       Maps\big(
         B ,\,
         Maps(B,D)
       \big)
       &\xrightarrow{\;\;\;
          \mu^{\bigcirc_B}
       \;\;\;}&
       Maps(B,D)
       \\
       f(-)(-)
       &\mapsto&
       \big(
         b
         \;\mapsto\;
         f(b)(b)
       \big)
       \mathrlap{\,.}
     \end{array}
   $$

To check that this definition satisfies the [[monad]]-[[axioms]]:

**[[unitality]]**:

$$
  \begin{array}{ccc}
  Maps(B,D)
  &\xrightarrow{\;\;\;
     \eta^{\bigcirc_B}_{Maps(D,B)}
  \;\;\;}&
  Maps\big(
    B, Maps(B,D)
  \big)
  &\xrightarrow{\;\;\;
    \mu^{ \bigcirc_B }_{D}
  \;\;\;}&
  Maps(B,D)
  \\
  \big(
    b' \mapsto f(b')
  \big)
  &\mapsto&
  \Big(
    b \mapsto
    \big(
      b' \mapsto f(b')
    \big)
  \Big)
  &\mapsto&
  \big(
    b \mapsto f(b)
  \big)
  \end{array}
$$

and

$$
  \begin{array}{ccc}
  Maps(B,D)
  &\xrightarrow{\;\;\;
     Maps\big(
       B,
       \eta^{\bigcirc_B}_{D}
     \big)
  \;\;\;}&
  Maps\big(
    B, Maps(B,D)
  \big)
  &\xrightarrow{\;\;\;
    \mu^{ \bigcirc_B }_{D}
  \;\;\;}&
  Maps(B,D)
  \\
  \big(
    b \mapsto f(b)
  \big)
  &\mapsto&
  \Big(
    b \mapsto
    \big(
      b' \mapsto f(b)
    \big)
  \Big)
  &\mapsto&
  \big(
    b \mapsto f(b)
  \big)
  \end{array}
$$

**[[associativity]]**:

$$
  \begin{array}{ccc}
    Maps\Big(
      B,
      Maps\big(B,
        Maps(B,D)
      \big)
    \Big)
    &\xrightarrow{\;\;\;
      \mu^{\bigcirc_B}_{
        Maps(B,D)
      }
    \;\;\;}&
    Maps\big(B,
      Maps(B,D)
    \big)
    &\xrightarrow{\;\;\;
      \mu^{\bigcirc_B}_{
        D
      }
    \;\;\;}&
    Maps(B,D)
    \\
    \Big(
      b \mapsto
      \big(
        b' \mapsto
        (b'' \mapsto f(b, b', b''))
      \big)
    \Big)
    &\mapsto&
    \big(
      b' \mapsto
      (b'' \mapsto f(b', b', b''))
    \big)
    &\mapsto&
    \big(
      b'' \mapsto f(b'', b'', b'')
    \big)
  \end{array}
$$

and

$$
  \begin{array}{ccc}
    Maps\Big(
      B,
      Maps\big(B,
        Maps(B,D)
      \big)
    \Big)
    &\xrightarrow{\;\;\;
      Maps\big(
        B,
        \mu^{\bigcirc_B}_{
          D
        }
      \big)
    \;\;\;}&
    Maps\big(B,
      Maps(B,D)
    \big)
    &\xrightarrow{\;\;\;
      \mu^{\bigcirc_B}_{
        D
      }
    \;\;\;}&
    Maps(B,D)
    \\
    \Big(
      b \mapsto
      \big(
        b' \mapsto
        (b'' \mapsto f(b, b', b''))
      \big)
    \Big)
    &\mapsto&
    \big(
      b' \mapsto
      (b'' \mapsto f(b', b'', b''))
    \big)
    &\mapsto&
    \big(
      b'' \mapsto f(b'', b, b)
    \big)
  \end{array}
$$

### Via base change
 {#DefinitionViaBaseChange}

For $B \in Sets$, write $\mathcal{C}_B$ for the category of $B$-[[indexed sets]] $(D_b)_{b \colon B}$ of [[objects]] of $\mathcal{C}$. (More generally, if $\mathcal{C}$ is a [[locally cartesian closed category]] ([[categorical semantics for dependent type theory]]), take $\mathcal{C}_B$ be the [[slice category]] over $B$.)

The right [[base change]] [[adjoint functor|adjunction]] ([[context extension]] $\dashv$ [[dependent product]]) is

$$
  \begin{array}{ccc}
    \mathcal{C}_B
    &
      \underoverset
        {\underset{(p_B)_\ast = \prod_{B}}{\longrightarrow}}
        {\overset{ (p_B)^\ast }{\longleftarrow}}
        {\;\;\; \bot \;\;\;}
    &
    \mathcal{C}
    \\
    (D_b)_{b \colon B}
    &\mapsto&
    \prod_{b \colon B} D_b
  \end{array}
$$

Under the evident identification of [[maps]] $f \colon B \to D$ with [[tuples]] $\big( f(b) \big)_{b \colon B}$, the reader monad is the monad induced from this [[adjoint pair|adjunction]]:

$$
  \bigcirc_B
  \;\simeq\;
  (p_B)_\ast
  (p_B)^\ast
  \,.
$$

\begin{remark}
One may also think of this as being the [[polynomial functor]] associated with this span:

$$
  \ast \leftarrow B \rightarrow \ast \rightarrow \ast
  \,.
$$
\end{remark}
\begin{remark}
The [[comonad]] obtained by composing the other way around, $(p_B)^\ast (p_B)_\ast$, is the [[modal operator]] usually called _[[necessity]]_
\end{remark}

From the [[universal property]] of the [[Cartesian product]], one finds that:

The **[[adjunction unit]]** is

$$
  \begin{array}{ccc}
    b \colon B
    \; \vdash \;
    &
    D
    &\xrightarrow{\;\;\;
      id_D
    \;\;\;}&
    D
    \\
    && \updownarrow
    \\
    &
    D
    &\xrightarrow{\;\;\;
      \eta^{ \bigcirc_B }_D
    \;\;\;}&
    \prod_{b \colon B} D
    \\
    &
    d &\mapsto& (d, \cdots, d)
  \end{array}
$$

The **[[adjunction counit]]** is:

$$
  \begin{array}{ccc}
    &
    \prod_{b' \colon B}
    D_{b'}
    &\xrightarrow{\;\;\;
      id
    \;\;\;}&
    \prod_{b' \colon B}
    D_{b'}
    \\
    && \updownarrow
    \\
    b \colon B
    \;\dashv\;
    &
    \prod_{b' \colon B}
    D_{b'}
    &\xrightarrow{\;\;\;
      \epsilon^{ \star_B }_D
    \;\;\;}&
    D_{b}
    \\
    &
    (d_{b'})_{b' \colon B}
    &\mapsto&
    d_{b}
  \end{array}
$$

The adjunction unit is clearly the [[unit of a monad|monad unit]].

The adjunction counit gives the [[multiplication]] on the monad:

$$
  \begin{array}{ccc}
    \prod_{b \colon B}
    (p_B)^\ast
    \prod_{b' \colon B}
    (p_B)^\ast
    D
    &\xrightarrow{\;\;\;
      \prod_{b \colon B}
      \big(
         \epsilon^{\star_B}
      \big)
      (p_B)^\ast
    \;\;\;}&
    \prod_{b' \colon B}
    (p_B)^\ast
    C
    \\
    \big(
      (f_{b'})_{b}
    \big)_{b', b \colon B}
    &\mapsto&
    \big(
      (f_{b})_{b}
    \big)_{b \colon B}
  \end{array}
$$

## Properties

### Relation to coreader- and state monad
 {#RelationToCoreaderAndState}

In a [[cartesian closed category]]/[[type theory]] $\mathcal{C}$, the reader monad $[B,-] \colon \mathcal{C}\to \mathcal{C}$ is [[right adjoint]] to the [[coreader comonad]] $B\times (-)$.

The composite of [[coreader comonad]] followed by [[reader monad]] is the *[[state monad]]* $[B,B \times (-)]$
This monad models the situation where a program may not only depend on a immutable parameter $b \colon B$ but may be allowed to *change* it.

Just as the [[coreader comonad]] canonically becomes a monad when $B$ is a [[monoid]], so the reader monad becomes a comonad in that case, and then it is sometimes called the "traced comonad".

### Relation to random variables in probability theory
 {#RelationToRandomVariables}

It makes sense to think of $[B,-]$ as producing spaces of [[random variables]] ([Verdier 14](#Verdier14)) depending on [[possible worlds]] $b \in B$ [[Toronto & McCarthy 10b, slide 24](#TorontoMcCarthy10b)].

(While, from the perspective of [[modal type theory]], its siblings $W^\ast \prod_W$ and $W^\ast \sum_W$ may be called _[[necessity]]_ and _[[possibility]]_, respectively).

>  The intuition behind the Reader monad, for a mathematician, is perhaps stochastic variables. A stochastic variable is a function from a probability space to some other space. So we see a stochastic variable as a monadic value. [[Verdier 14](#Verdier14)]

> you could interpret this by regarding random variables as reader monad computations. [[Toronto & McCarthy 10b, slide 35](#TorontoMcCarthy10b)]

[Toronto & McCarthy 10a, 2.2](#TorontoMcCarthy10a), [Toronto 14, 6.2](#Toronto14) call the function monad the _random variable idiom_.

This is also brought out by the relation of *linear* reader algebras to [[quantum measurement]], see [below](#QuantumReaderMonad). For more see also at *[[nondeterministic computation]]* the section *[Via indefiniteness effects](nondeterministic+computation#FormalizationViaIndefinitenessEffects)*.

### Free modules over the reader monad
 {#FreeModules}

For $B$ a [[set]], the [[Kleisli category]] for the $B$-reader monad has $B$-[[tuples]] of [[functions]] as [[morphisms]]:

\begin{imagefromfile}
    "file_name": "KleisliCatOfReaderMonad-221108.jpg",
    "width": "600",
    "unit": "px",
    "margin": {
        "top": -20,
        "bottom": 20,
        "right": 0,
        "left": 10
    }
\end{imagefromfile}

(On the left we are showing the situation of the [[comparison functor]] and on the right we are using the ["bind"-notation](monad+in+computer+science#BasicIdea) from [[monads in computer science]].)

### General modules over the reader monad
 {#AlgebrasForTheReaderMonad}

The reader monad on [[Set]] (and similar) does not generally arise from a [[monadic adjunction]] and its general [[algebra over a monad|algebras]] may not be easily characterizable. (See also [MO:a/868317](https://math.stackexchange.com/a/868317/58526).)

A special case is when $W$ is a 2 element set, where the $W$-reader algebras on $Set$ correspond to [[idempotent]] [[semigroups]], also known as _[[rectangular band|rectangular bands]]_.

But the definition of the reader monad makes sense also for other [[hyperdoctrines]] such as for [[dependent linear types]]: For the resulting "linear" or "quantum" version of the reader monad the situation is different, see  [below](#QuantumReaderMonad).

## Examples

### Quantum reader monad
 {#QuantumReaderMonad}

As remarked [above](#AlgebrasForTheReaderMonad), while the $B$-[[reader monad]] on [[toposes]] such as [[Set]] is induced from the [[base change]] [[adjunction]] as $\bigcirc_B(-) \,\coloneqq\, \underset{B}{\prod} \big( B \times (-) \big)$, the functor $\underset{B}{\prod} \;\colon\; Set_{/B} \xrightarrow{\phantom{--}} Set$ is *not* in general a [[monadic functor]], so that $B$-reader-[[algebras over a monad|algebras]] are not in general [[equivalence of categories|equivalent]] to $B$-[[indexed sets]].

However, this situation changes for $B$-readers analogously defined in other [[hyperdoctrines]].

We discuss the example of the reader monad induced by  $B$-[[dependent linear types]] which have [[biproducts]], such as $B$-[[indexed sets]]  of [[vector spaces]] (these we may think of as "[[quantum reader monad|quantum reader monads]]", see the discussion at *[Quantum Modal Logic](necessity+and+possibility#ModalQuantumLogic)*). We follow [CQTS (2022)](#CQTS22):

\begin{proposition}
\label{QuantumBReaderAlgebrasAreBDependentLinearTypes}
**(quantum $\bigcirc_B$-algebras are $B$-[[dependent linear types]])**
\linebreak
For $B \;\in\;$ [[FiniteSets]], the [[category]] of [[algebra over a monad|algebras]] for the $B$-[[reader monad]]

$$
  \array{
    \bigcirc_B
    \colon
    &
    Vect
    &\xrightarrow{\phantom{---}}&
    Vect
    \\
    &
    \mathscr{H}
    &\mapsto&
    Maps\big(B, \mathscr{H} \big)
    \mathrlap{
      \;
      \simeq
      \;
      \underset{b \colon B}{\bigoplus}
      \mathscr{H}
    }
  }
$$

on the category [[Vect]] of [[vector spaces]] (over any given [[ground field]]) is [[equivalence of categories|equivalent]] to that of [[vector bundles]] over $B$ (hence to $B$-[[indexed sets]] of [[vector spaces]]):
$$
  EM\big(
    \bigcirc_B
  \big)
  \;\;\simeq\;\;
  Vect_B
  \,.
$$

\end{proposition}
\begin{proof}
 We state first an abstract proof and then a concrete proof.

Abstractly, observe that [[Vect]] has (finite) [[biproducts]] (given by the [[direct sum]] of vector spaces) which together with the assumption that $B$ is [[finite set|finite]] implies that $\underset{B}{\prod} \;\colon\; Vect_B \xrightarrow{\;} Vect$:

1. is not only a [[right adjoint]] but also a [[left adjoint]] (hence an [[ambidextrous adjunction|ambidextrous adjoint]] to [[pullback of vector bundles]] along $B \to \ast$), [[left adjoints preserve colimits|hence]] in particular it [[preserved colimit|preserves]] all [[colimits]];

1. is a [[conservative functor]] (since the $B$-components of any morphism of vector bundles over $V$ can still be extracted via ([[coprojection|co-]])[[projections]] from their image under forming the [[biproduct]] over $B$).

Therefore the conditions for the [[monadicity theorem]] are met (see [there](monadicity+theorem#CrudeMonadicityTheorem)), implying that the functor is [[monadic functor]], which in turn implies the claim.

\linebreak

Alternatively, we now check the claim more concretely by unwinding what it means for a vector space to carry $\bigcirc_B$-algebra structure and for a linear map between vector spaces to be a [[homomorphism]] for this structure:

First observe that the $\bigcirc_B$-[[monad]] product $\mu \;\colon\; \bigcirc_B \bigcirc_B \xrightarrow{\mu} \bigcirc_B$ on a [[vector space]] $\mathscr{H} \,\in\, Vect$ is explicitly given by:

$$
  \array{
  \underset{b \colon B}{\bigoplus}
  \;
  \underset{b' \colon B}{\bigoplus}
  \;
  \mathscr{H}
  &
  \xrightarrow{\;\; \mu^{\bigcirc}_{\mathscr{H}} \;\;}
  &
  \underset{b'' \colon B}{\bigoplus}
  \mathscr{H}
  \\
  \big(
     \psi_{b,b'}
  \big)_{b,b' \colon B}
  &\mapsto&
  \big(
    \psi_{b'' ,b''}
  \big)_{b'' \colon B}
  }
$$

and that a $\bigcirc_B$-algebra structure on $\mathscr{H}$ is a [[linear map]] of this form:

\[
  \label{MapsUnderlyingAlgebraStructureOverLinearReaderMonad}
  \rho^\bigcirc_{\mathscr{H}}
  \;\colon\;
  \underset{b \colon B}{\oplus}
  \mathscr{H}
  \xrightarrow{\phantom{-}(P_b)_{b \colon B}\phantom{-}}
  \mathscr{H}
  \,.
\]

Of such maps, the $\bigcirc_B$-action property ([here](algebra+over+a+monad#eq:ActionProperty)) demands that the following two linear maps are equal:

$$
  \array{
    &
    \underset{b \colon B}{\bigoplus}
    \;
    \underset{b' \colon B}{\bigoplus}
    \;
    \mathscr{H}
      &\xrightarrow{\; \mu^\bigcirc_{\mathscr{H}}  \;}&
    \underset{b'' \colon B}{\bigoplus}
    \mathscr{H}
      &\xrightarrow{\; \rho^\bigcirc_{\mathscr{H}} \;}&
    \mathscr{H}
    \\
    &
    \big(
       \psi_{b,b'}
    \big)_{b,b' \colon B}
    &\mapsto&
    \big(
       \psi_{b'',b''}
    \big)_{b'',b'' \colon B}
    &\mapsto&
    \underset{b'' \colon B}{\sum}
    P_{b''}(\psi_{b'',b''})
    \\
    \text{and}
    &
    \\
    &
    \underset{b \colon B}{\bigoplus}
    \;
    \underset{b' \colon B}{\bigoplus}
    \;
    \mathscr{H}
      &\xrightarrow{\; \bigcirc \rho^\bigcirc_{\mathscr{H}}  \;}&
    \underset{b'' \colon B}{\bigoplus}
    \mathscr{H}
      &\xrightarrow{\; \rho^\bigcirc_{\mathscr{H}} \;}&
    \mathscr{H}
    \\
    &
    \big(
       \psi_{b,b'}
    \big)_{b,b' \colon B}
    &\mapsto&
    \big(
       \underset{b \colon B}{\sum}
       P_{b}(\psi_{b,b'})
    \big)_{b' \colon B}
    &\mapsto&
    \underset{b, b' \colon B}{\sum}
    P_{b'}\big(P_{b}(\psi_{b,b'})\big)
    \mathrlap{\,.}
  }
$$

By considering the value of these maps on [[tuples]] of [[vectors]] $\big(\psi_{b,b'}\big)_{b,b' \colon B}$ which are non-[[zero]] only for single elements $(b,b') \in B \times B$ one finds that the above condition is equivalent to the following condition:

$$
  \underset{
    b, b' \colon B
  }{
    \forall
  }
  \;\;\;\;
    P_b \circ P_{b'}
  \;=\;
  \left\{
    \array{
      P_b &\text{if} \; b = b'
      \\
      0  & \text{otherwise}
      \,.
    }
  \right.
$$

Moreover, the $\bigcirc_B$-[[unit of a monad|unit]] $\id \xrightarrow{\;\; \eta^{\bigcirc_B} \;\;} \bigcirc_B$ is given by the [[diagonal map]] into the [[biproduct]]

$$
  \array{
    \mathscr{H}
    &\xrightarrow{\;\;
      \eta^{\bigcirc_B}_{\mathscr{H}}
    \;\;}
    &
    \underset{b \colon B}{\bigoplus}
    \mathscr{H}
    \\
    \psi
    &\mapsto&
    (\psi_b \coloneqq \psi)_{b \colon B}
  }
$$

so that the unitality property ([here](algebra+over+a+monad#eq:UnitProperty)) of the $\bigcirc_B$-algebra structure $(P_b)_{b \colon B}$ demands equivalently that the [[composition|composite]]

$$
  \array{
    \mathscr{H}
    &\xrightarrow{\; \eta^{\bigcirc_B}_{\mathscr{H}} \;}&
    \underset{b \colon B}{\bigoplus}
    \mathscr{H}
    &\xrightarrow{\; \rho^{\bigcirc_B}_{\mathscr{H}} \;}&
    \mathscr{H}
    \\
    \psi
    &\mapsto&
    \big(
      \psi
    \big)_{b \colon B}
    &\mapsto&
    \underset{b \colon B}{\sum}
    \;
    P_b(\psi)
  }
$$

is the [[identity function]] on $\mathscr{H}$, hence that this system of [[projection operators]] is "complete" in that

$$
  \underset{b \colon B}{\bigoplus} P_b
  \;=\;
  id_{\mathscr{H}}
  \,.
$$

In summary, this means that for $B$-[[tuples]] of [[linear maps]] $(P_b \colon \mathscr{H} \to \mathscr{H})_{b \colon B}$ as in (eq:MapsUnderlyingAlgebraStructureOverLinearReaderMonad) to constitute a $\bigcirc_B$-module structure is equivalent to them being
systems of orthogonal linear [[projection operators]], whose [[images]]

$$
  \mathscr{H}_b \;\coloneqq\; im(P_b) \;\subset\; \mathscr{H}
$$

[[linear span|span]]$\;$ $\mathscr{H}$ under [[direct sum]]:

$$
  \mathscr{H}
  \;\simeq\;
  \underset{b \colon B}{\bigoplus}
  \mathscr{H}_b
  \,.
$$

Such structures, of course, are exactly the images under the right [[base change]] $\underset{B}{\prod} \;\colon\; Vect_B \longrightarrow{\;} Vect$ of $B$-[[indexed sets]] of vector spaces.

Finally, the [[homomorphism]]-property on a [[linear map]] $\mathscr{H} \xrightarrow{\phi} \mathscr{H}'$ between the underlying vector spaces of two such $\bigcirc_B$-modules demands that the following [[commuting diagram|diagram commutes]]:

$$
  \array{
    \underset{b \colon B}{\bigoplus}
    \mathscr{H}
    &\xrightarrow{\;\;\;
      \underset{b \colon B}{\oplus}
    \;\;\;}&
    \underset{b \colon B}{\bigoplus}
    \mathscr{H}
    \\
    \mathllap{
      {}^{
      \big(
        P_b
      \big)_{b \colon B}
      }
    }
    \big\downarrow
    &&
    \big\downarrow
    \mathrlap{
      {}^{
      \big(
        P'_b
      \big)_{b \colon B}
      }
    }
    \\
    \mathscr{H}
    &
    \underset{\phantom{---} \phi \phantom{---} }
      {\longrightarrow}
    &
    \mathscr{H}'
    \,.
  }
$$

The $B$-indexed components of this condition require that $\phi$ [[commutator|commutes]] with all these [[projection operators]], in that

$$
  b \colon B
  \;\;\;\;
  \vdash
  \;\;\;\;
  P'_b \circ \phi
  \;=\;
  \phi \circ P_b
  \,.
$$

But this evidently means that $\phi$ itself is the image under the [[direct sum]]-[[functor]]
$$
  \phi
  \;=\;
  \underset{b \colon}{\oplus}
  \phi_b
$$
of a $B$-[[tuple]] of [[linear maps]] between the $B$-indexed component spaces:
$$
  b \colon B
  \;\;\;
  \colon
  \;\;\;
  \mathscr{H}_b \longrightarrow \mathscr{H}'
  \,.
$$
This is the defining property of morphisms in $Vect_B$ and hence shows that $\bigcirc_B$-algebra homomorphisms are equivalently morphisms of $B$-[[indexed sets]] of vector spaces, hence that the two [[categories]] are [[equivalence of categories|agree]].
\end{proof}

\begin{example}\label{FreeQuantumReaderAlgebras}
**(free quantum $\bigcirc_B$-algebras and quantum measurement bases)**
\linebreak
  The *[free](algebra+over+a+monad#FreeAlgebras)* $\bigcirc_B$-algebras in [[Vect]] are those whose underlying vector space is of the form $\bigcirc_B \mathscr{B} = \underset{b \colon B}{\bigoplus} \mathscr{B}$ for any $\mathscr{B} \,\in \, Vect$, hence, under the equivalence of Prop. \ref{QuantumBReaderAlgebrasAreBDependentLinearTypes}, are those $B$-[[dependent linear types]] which happen to assign the same vector space $\mathscr{B}$ for all $b \colon B$.

But [[homomorphisms]] of such free $\bigcirc_B$-algebras are still allowed to be non-trivially $B$-dependent families of linear maps. This is directly a special case of Prop. \ref{QuantumBReaderAlgebrasAreBDependentLinearTypes} but is also immediate under the [Kleisli equivalence](Kleisli+category#KleisliEquivalence) from observing that $\bigcirc_B$-[[Kleisli morphisms]] are of the following form:
$$
  \array{
    \mathscr{B}
    &\xrightarrow{
      \big(
        \phi_b
      \big)_{b \colon B}
    }&
    \underset{b \colon B}{\bigoplus}
    \mathscr{B}'
    \,.
  }
$$

In [[quantum information theory]] the $\bigcirc_B$-algebras in [[complex vector spaces]] which are free on the [[tensor unit]] $\mathbb{C} \,\in\, \mathbb{C} Vect$ (the [[dimension of a vector space|1-dimensional]] [[complex vector space]]) play the role of  ([[finite dimensional vector space|finite dimensional]] [[complex vector spaces]] [[underlying]]) [[Hilbert space]] [[space of quantum states|of quantum states]] which are [[linear space|spanned]] by the set $B$ regarded as a "[[quantum measurement]] [[linear basis|basis]]".

For example, the [[dependent linear type]] of [[qbits]] is the free $\bigcirc_B$-algebra $\bigcirc_{Bool} \mathbb{C}$ spanned by the [[intuitionistic type theory|classical type]] [[Bool]] $= \{0,1\}$ of [[bits]], reflecting the two canonical [[quantum measurement]]-outcomes ($\vert 0\rangle$, $\vert 1 \rangle$) of [[qbits]].

{#QuantumMeasurementAsIndefinitenessHandling} Curiously, from this one finds that *[[quantum measurement]] is exactly indefiniteness handling*

where

* "indefiniteness" is understood as the the effect/[[modality]] expressed by the reader monad $\bigcirc_B$ (see [here](necessity+and+possibility#RelationToPotentiality)),

* "handling" is understood as *effect handling* in the sense of effect-[[monads in computer science]] (see [here](monad+in+computer+science#MonadModulesInIdeaSection));

namely:

\begin{imagefromfile}
    "file_name": "QMeasurementViaIndefinitenessHandling-221109c.jpg",
    "width": "730",
    "unit": "px",
    "margin": {
        "top": -20,
        "bottom": 20,
        "right": 0,
        "left": 10
    }
\end{imagefromfile}

Notice that this process may be understood as the "[[dynamic lifting]]" of [[quantum measurement]]-results into the [[context]] (here: $B = $ [[Bool]]) of the ambient [[dependent linear type theory]].

For more on this see at *[[quantum circuits via dependent linear types]]*.
\end{example}

\linebreak

This naturally relates to the discussion of [[quantum measurement]] via [[Frobenius algebra]]-structures which is popular in the context of [[quantum information theory via dagger-compact categories]] -- as follows:

\begin{remark}\label{QuantumrReaderMonadIsFrobenius}
**(quantum reader monad is Frobenius)**
\linebreak
Since the [[direct sum]] of [[vector spaces]] is a [[biproduct]] and using our running assumption that $B$ is a [[finite set]], it follows that the [[underlying]] [[functor]] of the quantum [[reader monad]] from Prop. \ref{QuantumBReaderAlgebrasAreBDependentLinearTypes} coincides with that of the [[coreader comonad]], and hence that the quantum reader monad is a *[[Frobenius monad]]* (see there).
\end{remark}

\begin{remark}\label{QuantumReaderMonadIsSpecialFrobeniusWriterMonad}
**(quantum reader monad is special Frobenius writer monad)**
\linebreak
  Consider the $B$-[[indexed set|indexed]] the [[direct sum]] $k^{\otimes^B}$ of the [[ground field]] with itself as a $k$-[[associative algebra|algebra]] and write

$$
  {k^{\otimes^B}}\text{-}Writer
  \;\colon\;
  Vect \to Vect
$$

for the [[writer monad]] corresponding to this [[monoid object]] in [[Vect]]: The monad which acts by forming the [[tensor product]] $Writer_{k^{\otimes^B}}(V) \;\coloneqq\; V \otimes \big( k^{\otimes^B} \big) $ and whose monad multiplication and [[unit of a monad]] are induced from the [[multiplication]] and [[unit]] in this monoid.

The above proof of Prop. \ref{QuantumBReaderAlgebrasAreBDependentLinearTypes} shows at once that this [[writer monad]] is [[isomorphism|isomorphic]] to the $B$-reader monad:
$$
  \bigcirc_B
  \;\simeq\;
  Writer_{k^{\otimes^B}}
  \,.
$$
Now the [[module over a monad|monad modules]] over a [[writer monad]] are just the ordinary [[modules]] over the corresponding [[monoid]], so that
$$
  \bigcirc_B Mod(Vect)
  \;\simeq\;
  \big(
    k^{\otimes^B}
  \big)Mod(Vect)
  \,.
$$
This provides a rather transparent re-derivation of and alternative perspective on Example \ref{FreeQuantumReaderAlgebras}.

[[formal duality|Dually]], as in Prop. \ref{QuantumReaderMonadIsFrobenius}, the quantum [[coreader comonad]] is isomorphic to the [[coreader comonad]] corresponding to the [[coalgebra]]-[[structure]] on $k^{\otimes^B}$.
Hence, as a [[Frobenius monad]] (Prop. \ref{QuantumReaderMonadIsFrobenius}), the quantum reader corresponds to $k^{\otimes^B}$ regarded as a [[Frobenius algebra]], in fact as a commutative and special Frobenius algebra. In this form the quantum  reader monad is prominent in the literature on [[quantum information theory via dagger-compact categories]] [[Coecke & Pavlović (2008), §1.5.1](#CoeckePavlović08), [Coecke & Paquette (2008), §2.3](#CoeckePaquette08)].
\end{remark}

\[
  \label{EquivalencesOfTheQuantumReaderMonad}
\]
\begin{imagefromfile}
    "file_name": "QuantumReaderFrobeniusMonad-221112.jpg",
    "width": "600",
    "unit": "px",
    "margin": {
        "top": -20,
        "bottom": 20,
        "right": 0,
        "left": 10
    }
\end{imagefromfile}

## Related concepts

[[!include reader-writer (co)monads -- table]]

* [[state monad]]

* [[quantum reader monad]]

* [[maybe monad]]

* [[continuation monad]]

## References

### General

As a [[monad in computer science]]:

* {#Verdier14} [[Olivier Verdier]], _[The Reader and Writer Monads and Comonads](http://www.olivierverdier.com/posts/2014/12/31/reader-writer-monad-comonad/)_, 2014

* {#Milewski19} [[Bartosz Milewski]] §21.2.3 in: *Category Theory for Programmers*, Blurb (2019) [[pdf](https://github.com/hmemcpy/milewski-ctfp-pdf/releases/download/v1.3.0/category-theory-for-programmers.pdf), [github](https://github.com/hmemcpy/milewski-ctfp-pdf), [webpage](https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/), [ISBN:9780464243878](https://www.blurb.com/b/9621951-category-theory-for-programmers-new-edition-hardco)]

* [[Tarmo Uustalu]], p.22 of: *Monads and Interaction Lecture 1* [[pdf](https://cs.ioc.ee/~tarmo/mgs21/mgs1.pdf), [[Uustalu-Monads1.pdf:file]]], lecture notes for [MGS 2021](https://staffwww.dcs.shef.ac.uk/people/G.Struth/mgs21.html) (2021):

See also:

* Wikipedia, _[Environment monad](http://en.wikipedia.org/wiki/Monad_%28functional_programming%29#Environment_monad)_.

* {#TorontoMcCarthy10a} [[Neil Toronto]], [[Jay McCarthy]], _From Bayesian notation to pure Racket, via measuretheoretic probability_ , in _Implementation and Application of Functional Languages_, 2010 ([web](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.298.4274))

* {#TorontoMcCarthy10b} [[Neil Toronto]], [[Jay McCarthy]], _From Bayesian Notation to Pure Racket_, talk notes 2010 ([pdf](http://jeapostrophe.github.io/home/static/toronto-2010ifl-slides.pdf))

* {#Toronto14} [[Neil Toronto]], _Useful Languages for Probabilistic Modeling and Inference_, PhD Thesis, 2014 ([pdf](http://cs.umd.edu/~ntoronto/papers/toronto-2014diss.pdf), [slides](http://cs.umd.edu/~ntoronto/papers/toronto-2014diss-slides.pdf))

A treatment of _opacity_ in [[linguistics]] via the function monad

* [[Gianluca Giorgolo]], [[Ash Asudeh]], _Monads as a Solution for Generalized Opacity_, [paper](https://www.aclweb.org/anthology/W14-1403/)

* [[Gianluca Giorgolo]], [[Ash Asudeh]], _Perspectives_, Semantics and Pragmatics, vol. 9, [paper](http://semprag.org/article/view/sp.9.21)

### On linear types
 {#ReferencesOnLinearTypes}

The [[quantum reader monad]] -- implicitly, in its incarnation as the $k^B$-DualWriter monad -- is highlighted in the literature [[quantum information theory via dagger-compact categories]] as formalizing "classical structures" (namely linear bases for [[quantum measurement]]):

* {#CoeckePavlović08} [[Bob Coecke]], [[Duško Pavlović]], §1.5.1 of: *Quantum measurements without sums*, in [[Louis Kauffman]], [[Samuel Lomonaco]] (eds.), *Mathematics of Quantum Computation and Quantum Technology*, Taylor & Francis (2008) 559-596 [[arXiv:quant-ph/0608035](https://arxiv.org/abs/quant-ph/0608035), [doi:10.1201/9781584889007](https://doi.org/10.1201/9781584889007)]

* {#CoeckePaquette08} [[Bob Coecke]], [[Eric Oliver Paquette]], §2.3 in: *POVMs and Naimark's theorem without sums*, Electronic Notes in Theoretical Computer Science **210** (2008) 15-31 [[arXiv:quant-ph/0608072](https://arxiv.org/abs/quant-ph/0608072), [doi:10.1016/j.entcs.2008.04.015](https://doi.org/10.1016/j.entcs.2008.04.015)]

* [[Bob Coecke]], [[Eric Paquette]], [[Dusko Pavlovic]], Def. 2.8 in: *Classical and quantum structures* (2008) [[pdf](http://www.comlab.ox.ac.uk/files/627/RR-08-02.pdf), [[Coecke-Paquette-Pavlovic-CQS.pdf:file]]]

The account above follows:

* {#CQTS22} [[CQTS]], *[Quantum Data Types via Linear HoTT](https://ncatlab.org/schreiber/show/QDataInLHoTT#QTML2022)*, talk at *[Workshop on Quantum Software](https://quasar.unina.it/qtml2022/workshop.php)* @ *[QTML 2022](https://quasar.unina.it/qtml2022.html)* (Nov 2022) [[pdf](/schreiber/files/QuantumDataInLHoTT-221117.pdf)]

[[!redirects reader monads]]

[[!redirects function monad]]
[[!redirects function monads]]

[[!redirects environment monad]]
[[!redirects environment monads]]


function of positive type

## Definition

Given an [[inhabited set]] $Z$, a [[binary function]] $f:Z \times Z \to \mathbb{C}$ is **of positive type** over $Z$ if for every natural number $n:\mathbb{N}$ and finite [[list]] of length $n$ in $Z$ $z:Fin(n) \to Z$, the complex [[linear map]] $G:\mathbb{C}^n \to \mathbb{C}^n$ whose [[matrix]] representation $G'$ has entries $G'_{ij} = f(z_i,z_j)$ is Hermitan and positive semidefinite.

## See also

* [[coherent product]]

## References

* [[Arnold Neumaier]], *Introduction to coherent spaces*, ([arXiv:1804.01402](https://arxiv.org/abs/1804.01402))

* [[Arnold Neumaier]], *Coherent Quantum Physics: A Reinterpretation of the Tradition*, 1st edition, De Gruyter, 2019. ISBN:9783110667295


function realizability

+-- {: .rightHandSide}
+-- {: .toc .clickDown tabindex="0"}
### Context
#### Constructivism, Realizability, Computability
+-- {: .hide}
[[!include constructivism - contents]]
=--
=--
=--

# Contents
* table of contents
{: toc}

## Related concepts

* [[realizability]]

* [[Kleene's second algebra]]

The subcategory on the effectively computable morphisms of the [[function realizability topos]] $RT(\mathcal{K}_2)$ is the [[Kleene-Vesley topos]] $KV$. The category of "admissible representations" $AdmRep$ (whose morphisms are [[computable functions (analysis)]], see there) is a [[reflective subcategory]] of $RT(\mathcal{K}_2)$ ([BSS 07](#BSS07)) and the restriction of that to $KV$ is $AdmRep_{eff}$

$$
  \array{
     AdmRep_{eff} &\hookrightarrow& KV
     \\
     \downarrow && \downarrow
     \\
     AdmRep &\hookrightarrow& RT(\mathcal{K}_2)
  }
$$

[[!include computable mathematics -- table]]

## References

* {#Streicher07} [[Thomas Streicher]], around p. 17 of  _Realizability_ (2017/18) ([pdf](https://www2.mathematik.tu-darmstadt.de/~streicher/REAL/REAL.pdf))

* {#vanOosten08} [[Jaap van Oosten]], _Realizability: an introduction to its categorical side_, Studies in Logic and the Foundations of Mathematics, vol. 152, Elsevier, 2008 ([preface pdf](http://www.staff.science.uu.nl/~ooste110/boekbegin.pdf))

* {#BSS07} [[Ingo Battenfeld]], Matthias Schröder, [[Alex Simpson]], _A convenient category of domains_, in L. Cardelli, M. Fiore and G. Winskel (eds.), _Computation, Meaning and Logic_, Articles dedicated to Gordon Plotkin  Electronic Notes in Computer Science, 34 pp., to appear, 2007  ([[BattenfeldDomains.pdf:file]])

[[!redirects function realizability]]
[[!redirects function realizability topos]]
[[!redirects function ralizability]]


function set

+-- {: .rightHandSide}
+-- {: .toc .clickDown tabindex="0"}
### Context
#### Mapping space
+--{: .hide}
[[!include mapping space - contents]]
=--
=--
=--

# Function sets
* table of contents
{: toc}

## Definitions

Given [[sets]] $A$ and $B$, the __function set__ $A^B$ is the set of all [[functions]] from $B$ to $A$.  In the [[foundations]] of mathematics, the existence of such a set may be taken to follow from the existence of [[power sets]], from the axiom of [[subset collection]], or as an axiom (the __axiom of function sets__) in its own right.

## Generalisations

Thinking of [[Set]] as a [[locally small category]], this is a special case of a [[hom-set]].  Thinking of $\Set$ as a [[cartesian closed category]], this is a special case of an [[exponential object]], which is a special case of an [[internal hom]].

## Related concepts

* [[function type]]

* [[internal hom]]

* [[bijection set]]

category: foundational axiom

[[!redirects function set]]
[[!redirects function sets]]
[[!redirects function-set]]
[[!redirects function-sets]]

[[!redirects axiom of function sets]]

[[!redirects set of functions]]


function space

* [[function set]]

* [[internal hom]]

* [[exponential object]]

* [[topological vector space]]

[[!redirects function space]]
[[!redirects function spaces]]