---
layout: default
file: "src/Setoid/Varieties/Maltsev/Basic.lagda.md"
title: "Setoid.Varieties.Maltsev.Basic module"
date: "2026-06-15"
author: "the agda-algebras development team"
---
### The Maltsev condition as a theory interpretation
This is the [Setoid.Varieties.Maltsev.Basic][] module of the [Agda Universal Algebra Library][].
A **Maltsev condition** is a property of a variety equivalent to the existence of
terms satisfying prescribed identities. The three most basic concern the shape of
the congruence lattices of the algebras in the variety:
+ **congruence permutability** (CP) β composition of congruences is commutative;
+ **congruence distributivity** (CD) β every congruence lattice is distributive;
+ **congruence modularity** (CM) β every congruence lattice is modular.
A **Maltsev term** for a variety `π±` is a ternary term `m` satisfying
m(x, x, y) β y and m(x, y, y) β x,
and a variety has such a term exactly when it is CP.
This is the original *Maltsev condition* and it is quintessential universal algebra β
a property of an arbitrary variety, phrased over an arbitrary signature, with no
commitment to any particular structure.
This module fixes the abstract data of the condition and frames it as a theory
interpretation ([Setoid.Varieties.Interpretation][]): the one-ternary-symbol
signature `Sig-Maltsev`, the two-equation theory `Th-Maltsev`, and the predicate
`HasMaltsevTerm β° = Th-Maltsev βΌ β°`. "`β°` admits a Maltsev term" is exactly
"the Maltsev theory interprets into `β°`".
A *worked* example β that `x β (y β»ΒΉ β z)` is a Maltsev term for the variety
of groups β is structure-specific (it consumes the group operations and laws), so it
lives one layer up, in [Classical.Interpretations.Maltsev][].
<!--
```agda
{-# OPTIONS --cubical-compatible --exact-split --safe #-}
module Setoid.Varieties.Maltsev.Basic where
open import Agda.Primitive using () renaming ( Set to Type )
open import Data.Bool.Base using ( Bool ; true ; not )
open import Data.Fin.Base using ( Fin )
open import Data.Fin.Patterns using ( 0F ; 1F ; 2F )
open import Data.Nat.Base using ( β ; zero ; suc )
open import Data.Product using ( _Γ_ ; _,_ ; projβ )
open import Level using ( Level ; 0β ; _β_ ) renaming ( suc to lsuc )
open import Overture.Signatures using ( π ; π₯ ; Signature )
open import Setoid.Algebras.Basic using ( Algebra ; π»[_] ; π[_] )
open import Setoid.Congruences.Basic using ( Con ; is-compatible )
open import Setoid.Terms.Basic using ( _[_] ; module Environment )
open import Setoid.Varieties.Interpretation using ( module Interpret )
import Overture.Terms as Terms
open import Function using ( Func )
open Func using () renaming ( to to _β¨$β©_ )
private variable Ξ± Ο Ο β : Level
```
-->
#### The Maltsev signature and theory
`Sig-Maltsev` has a single ternary operation symbol; `Th-Maltsev` carries the two
Maltsev equations over the variable carrier `Fin 3` (`0F` for `x`, `1F` for `y`).
```agda
data Op-Maltsev : Type where
m-Op : Op-Maltsev
ar-Maltsev : Op-Maltsev β Type
ar-Maltsev m-Op = Fin 3
Sig-Maltsev : Signature 0β 0β
Sig-Maltsev = Op-Maltsev , ar-Maltsev
tri : {β : Level} {A : Type β} β A β A β A β Fin 3 β A
tri a b c 0F = a
tri a b c 1F = b
tri a b c 2F = c
module _ where
open Terms {π = Sig-Maltsev} using ( Term ; β ; node )
m : {X : Type} β Term X β Term X β Term X β Term X
m a b c = node m-Op (tri a b c)
private
x y z : Term (Fin 3)
x = β 0F ; y = β 1F ; z = β 2F
data Eq-Maltsev : Type where
mxxyβy mxyyβx : Eq-Maltsev
Th-Maltsev : Eq-Maltsev β Term (Fin 3) Γ Term (Fin 3)
Th-Maltsev mxxyβy = m x x y , y
Th-Maltsev mxyyβx = m x y y , x
```
#### The Maltsev condition
A theory `β°` (equivalently, its variety) *has a Maltsev term* (equivalently, is
congruence-permutable) exactly when the Maltsev theory interprets into it. This is
the clean, signature-agnostic statement of the condition; a concrete variety
satisfies it by exhibiting an interpretation `Th-Maltsev βΌ β°`, that is, an `β°`-term
witnessing the two Maltsev equations.
The target theory's signature is fixed at `(0β , 0β)`, matching `Sig-Maltsev` (the
interpretability relation `βΌ` relates theories over a common level pair); this is
no restriction for the finitary algebraic theories the Maltsev condition concerns.
```agda
module _
{Ξ± Ο Ο ΞΉ : Level}
{π : Signature 0β 0β}
{X : Type Ο}
{Idx : Type ΞΉ}
where
open Terms {π = π} using (Term)
HasMaltsevTerm : (Idx β Term X Γ Term X) β Type (lsuc (Ξ± β Ο) β Ο β ΞΉ)
HasMaltsevTerm β° = Th-Maltsev βΌ β°
where open Interpret Ξ± Ο
```
#### Miscellaneous prerequisites
Maltsev arguments rely on the fact that the chosen Maltsev *term operation*
respects every congruence. This is an instance of a fundamental fact, which we prove
once in full generality: Given an algebra `π©` and a term `t` in the signature of `π©`,
every congruence `Ο` of `π©` is compatible with the evaluation of `t` β if two
environments are pointwise `Ο`-related at the leaves, the values of `t` are
`Ο`-related. The proof is the obvious structural induction.
```agda
module _
{π : Signature π π₯}
{π© : Algebra {π = π} Ξ± Ο}
where
open Environment π© using ( β¦_β§ )
open Terms {π = π} using (Term ; β ; node)
term-compatible : {V : Type Ο } ((_Ο_ , _) : Con π© β )
(t : Term V ) {Ξ· Ξ·β² : V β π[ π© ] }
β (β v β (Ξ· v) Ο (Ξ·β² v)) β (β¦ t β§ β¨$β© Ξ·) Ο (β¦ t β§ β¨$β© Ξ·β²)
term-compatible _ (β v) h = h v
term-compatible Ο (node f ts) h = is-compatible (Ο .projβ) f (Ξ» i β term-compatible Ο (ts i) h)
```
Finally, a function indicating the parity of a natural number is needed to split the
JΓ³nsson/Day "fork" identities by index in [Setoid.Varieties.Maltsev.Distributivity][]
and [Setoid.Varieties.Maltsev.Modularity][].
```agda
even? : β β Bool
even? zero = true
even? (suc m) = not (even? m)
```