PLFA: Relations

Mar 3 2023 · LastMod: Mar 3 2023

Programming Language Foundations in Agda, Relations: Inductive definition of relations.

Dependent types are introduced in a very confusing way. Here is some explanation. The definition of is given by

1data _≤_ : ℕ → ℕ → Set where
2  z≤n : ∀ {n : ℕ} → zero ≤ n
3  s≤s : ∀ {m n : ℕ} → m ≤ n → suc m ≤ suc n
4s

Note the implicit argument marked by the apperance of curly brackets {}. Here zero ≤ n, m ≤ n, suc m ≤ suc n are all dependent types, or family of types (remember Curry-Howard). z≤n and s≤s are type constructors. For fixed n:ℕ, zero ≤ n is a type.

The proof of _ : 2 ≤ 4, given by

1_ : 2 ≤ 4
2_ = s≤s (s≤s z≤n)

is really

1_ = s≤s {1} {3} (s≤s {0} {2} (z≤n {2}))

where

18a6930dc3745953-b0810daf7da7e872b4943ef4-b0f79c33ac2d84e3f366f9e3e3ecd376db0b3a03cfef5686d6d2952caf474ebfe75b06af6304dd77b0c418924202283564e525924b5c6ed04fd5be64077d1bc63f1da7a738af49839b4c2e1c636885a70fc2831332f4dda1a88a3d2e07c3f1aa