---
layout: default
title : "Overture.Signatures module (Agda Universal Algebra Library)"
date : "2021-04-23"
author: "agda-algebras development team"
---
### Signatures
This is the [Overture.Signatures][] module of the [Agda Universal Algebra Library][].
<!--
```agda
{-# OPTIONS --cubical-compatible --exact-split --safe #-}
module Overture.Signatures where
open import Agda.Primitive using () renaming ( Set to Type )
open import Data.Product using ( Ξ£-syntax ; projβ ; projβ )
open import Level using ( Level ; _β_ ) renaming ( suc to lsuc )
```
-->
```agda
variable π π₯ : Level
```
The variables `π` and `π₯` are not private since, throughout the [agda-algebras][] library,
`π` denotes the universe level of *operation symbol* types, while `π₯` denotes the universe
level of *arity* types.
#### Theoretical background
In [model theory](https://en.wikipedia.org/wiki/Model_theory), the *signature*
`π = (πΆ, πΉ, π
, Ο)` of a structure consists of three (possibly empty) sets `πΆ`, `πΉ`,
and `π
`---called *constant symbols*, *function symbols*, and *relation symbols*,
respectively---along with a function `Ο : πΆ + πΉ + π
β π` that assigns an
*arity* to each symbol.
Often (but not always) `π = β`, the natural numbers.
As our focus here is universal algebra, we are more concerned with the restricted
notion of an *algebraic signature* (or *signature* for algebraic structures), by
which we mean a pair `π = (πΉ, Ο)` consisting of a collection `πΉ` of *operation
symbols* and an *arity function* `Ο : πΉ β π` that maps each operation symbol to
its arity; here, π denotes the *arity type*.
Heuristically, the arity `Ο π` of an operation symbol `π β πΉ` may be thought of as
the "number of arguments" that `π` takes as "input".
If the arity of `π` is `n`, then we call `π` an `n`-*ary* operation symbol. In
case `n` is 0 (or 1 or 2 or 3, respectively) we call the function *nullary* (or
*unary* or *binary* or *ternary*, respectively).
If `A` is a set and `π` is a (`Ο π`)-ary operation on `A`, we often indicate this
by writing `π : A`<sup>Ο π</sup> `β A`. On the other hand, the arguments of such
an operation form a (`Ο π`)-tuple, say, `(a 0, a 1, β¦, a (Οf-1))`, which may be
viewed as the graph of the function `a : Οπ β A`.
When the codomain of `Ο` is `β`, we may view `Ο π` as the finite set `{0, 1, β¦, Οπ - 1}`.
Thus, by identifying the `Οπ`-th power `A`<sup>Ο π</sup> with the type `Ο π β A` of
functions from `{0, 1, β¦, Οπ - 1}` to `A`, we identify the type
`A`<sup>Ο f</sup> `β A` with the function type `(Οπ β A) β A`.
**Example**.
Suppose `π : (m β A) β A` is an `m`-ary operation on `A`.
Let `a : m β A` be an `m`-tuple on `A`.
Then `π a` may be viewed as `π (a 0, a 1, β¦, a (m-1))`, which has type `A`.
Suppose further that `π : (Οπ β B) β B` is a `Οπ`-ary operation on `B`.
Let `a : Οπ β A` be a `Οπ`-tuple on `A`, and let `h : A β B` be a function.
Then the following typing judgments obtain:
`h β a : Οπ β B` and `π (h β a) : B`.
#### The signature type
In the [agda-algebras][] library we represent the *signature* of an algebraic
structure using the following type.
```agda
Signature : (π π₯ : Level) β Type (lsuc (π β π₯))
Signature π π₯ = Ξ£[ F β Type π ] (F β Type π₯)
```
Occasionally it is useful to obtain the universe level of a given signature.
```agda
Level-of-Signature : {π π₯ : Level} β Signature π π₯ β Level
Level-of-Signature {π}{π₯} _ = lsuc (π β π₯)
```
A signature is a Ξ£-type, so its two components are recovered by the standard
projections `projβ` and `projβ` (from `Data.Product`, re-exported by
[Overture.Basic][]).
Consequently, if `π : Signature π π₯` is a signature, then
* `projβ π` denotes the set of operation symbols, and
* `projβ π` denotes the arity function.
If `π : projβ π` is an operation symbol in the signature `π`, then `projβ π π`
is the arity of `π`.
#### Self-documenting projections
Bare `projβ` / `projβ` read opaquely at signature use sites. The following
long-form aliases are definitionally identical to the projections and are the
canonical way to name a signature's components throughout the library. See
[ADR-002][] Β§1 for the rationale and the per-tree policy.
```agda
OperationSymbolsOf : Signature π π₯ β Type π
OperationSymbolsOf π = projβ π
ArityOf : (π : Signature π π₯) β OperationSymbolsOf π β Type π₯
ArityOf π f = projβ π f
```
The bracket projections `β£_β£` / `β₯_β₯` are deprecated as of v3.0 (they carry a
`WARNING_ON_USAGE` in [Overture.Basic][]); new code uses `OperationSymbolsOf` /
`ArityOf` for signature components and `projβ` / `projβ` elsewhere.