---
layout: default
title : "Setoid.Varieties.Invariants module (The Agda Universal Algebra Library)"
date : "2026-05-10"
author: "agda-algebras development team"
---
### Algebraic invariants for setoid algebras
This is the [Setoid.Varieties.Invariants][] module of the [Agda Universal Algebra Library][].
A property `P` of (setoid) algebras is called an **algebraic invariant** when it is stable under isomorphism: whenever `๐จ โ
๐ฉ`, the proposition `P ๐จ` implies `P ๐ฉ`. Equivalently, an algebraic invariant is a predicate that factors through the isomorphism-type of `๐จ` โ a property of the algebra qua structure, independent of its concrete carrier. The notion is the foundational guard rail of universal algebra: the structurally meaningful properties of an algebra (satisfying an identity, being subdirectly irreducible, generating a given variety, being free over a set of generators, and so on) are all algebraic invariants, and a property that fails to be invariant is, almost by definition, not a property of the algebra but of one particular presentation of it.
The canonical example available in this library is the modelling relation `๐จ โง (p โฬ q)`. Its algebraic invariance is the content of [`Setoid.Varieties.Properties.โง-I-invar`][Setoid.Varieties.Properties], which states precisely that `ฮป ๐จ โ ๐จ โง (p โฬ q)` satisfies the `AlgebraicInvariant` predicate defined below. More generally, each closure operator `H`, `S`, `P`, `V` of the variety theory is built from operations that respect `_โ
_`, so class membership `_โ H ๐ฆ`, `_โ S ๐ฆ`, `_โ P ๐ฆ`, and `_โ V ๐ฆ` is itself an algebraic invariant.
<!--
```agda
{-# OPTIONS --cubical-compatible --exact-split --safe #-}
open import Overture using ( ๐ ; ๐ฅ ; Signature )
module Setoid.Varieties.Invariants {๐ : Signature ๐ ๐ฅ} where
open import Agda.Primitive using () renaming ( Set to Type )
open import Level using ( Level )
open import Relation.Unary using ( Pred )
open import Setoid.Algebras {๐ = ๐} using ( Algebra )
open import Setoid.Homomorphisms {๐ = ๐} using ( _โ
_ )
private variable ฮฑ ฯแต โ : Level
```
-->
A predicate `P : Pred (Algebra ฮฑ ฯแต) โ` is an *algebraic invariant* when, given any two algebras `๐จ` and `๐ฉ` at the same universe levels and an isomorphism `๐จ โ
๐ฉ`, the property `P ๐จ` entails `P ๐ฉ`. The same-level restriction is forced by Agda's `Pred` type and matches the legacy `Base.Varieties.Invariants` definition; a level-heterogeneous variant could be obtained by parametrizing over a level-indexed family of predicates, but no current consumer requires it.
```agda
AlgebraicInvariant : Pred (Algebra ฮฑ ฯแต) โ โ Type _
AlgebraicInvariant P = โ ๐จ ๐ฉ โ P ๐จ โ ๐จ โ
๐ฉ โ P ๐ฉ
```