Idea
In constructive type theory, a relation is well-founded if every element of the domain is accessible. Accessibility is defined inductively: an element is accessible if all elements “smaller” than it are accessible. This definition enables the principle of well-founded induction (recursion) without assuming LEM or requiring a decreasing measure to naturals.
Definition
Let be a type and be a binary relation on (i.e., ).
The accessibility predicate, , is defined inductively. The single constructor is:
The relation is well-founded if every element of is accessible:
Well-Founded Induction
The induction principle derived from well-foundedness states that to prove a predicate for all , it suffices to show that for any , if holds for all , then holds.
In type theory, this corresponds to the recursor on the Acc type.
Well-Founded Recursion
Well-founded recursion generalizes well-founded induction by allowing to be a family of types that is generated by the recursion procedure. See Distinction from well-founded induction below.
Agda Implementation
The definition translates directly to an inductive family.
module WellFounded where
open import Agda.Primitive
data Acc {ℓ ℓ'} {A : Set ℓ} (_<_ : A → A → Set ℓ') (x : A) : Set (ℓ ⊔ ℓ') where
acc : ((y : A) → y < x → Acc _<_ y) → Acc _<_ x
WellFounded : {ℓ ℓ' : Level} {A : Set ℓ} → (A → A → Set ℓ') → Set (ℓ ⊔ ℓ')
WellFounded _<_ = ∀ x → Acc _<_ x
-- Induction principle (dependent eliminator)
wfInd : {ℓ ℓ' ℓ'' : Level} {A : Set ℓ} {_<_ : A → A → Set ℓ'}
→ (P : A → Set ℓ'')
→ ((x : A) → ((y : A) → y < x → P y) → P x)
→ (x : A) → Acc _<_ x → P x
wfInd P step x (acc rs) = step x (λ y y<x → wfInd P step y (rs y y<x))Remarks
Distinction from well-founded induction
The primary distinction between well-founded induction and recursion lies in the universe level of the motive. Induction targets a predicate to establish validity, whereas recursion targets a family of types to compute data. Computationally, wfRec functions as a fixpoint combinator that performs structural recursion on the accessibility witness . This allows the definition of total functions on domains that are not inductively defined, provided the relation is well-founded, without requiring a decreasing natural number measure.
A critical subtlety in intensional type theory is the function’s dependence on the specific witness . Because Acc is an inductive type in , distinct derivation trees of accessibility could theoretically result in distinct values for . To ensure the function is extensionally determined solely by , one typically requires that Acc x be a mere proposition (proof irrelevance), which is often provable in Homotopy Type Theory or Cubical Agda given the extensionality of the underlying relation.
- Induction: The motive is a predicate (or a subsingleton type). The goal is to construct a witness of truth. Since propositions are proof-irrelevant, the specific structure of the
Accderivation is computationally irrelevant to the resulting truth value. - Recursion: The motive is a family of types . The goal is to compute a value. The resulting function is defined by structural recursion on the proof .
Accessibility Witnesses
In well-founded recursion, an accessibility witness is a proof that an element is accessible. The structure of this witness determines the computational behavior of functions defined by well-founded recursion.
In intensional type theory, functions may depend on the specific derivation tree of the accessibility proof, requiring proof irrelevance to ensure extensionality.