| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Finite sets defined using the reflexive-transitive closure, Star |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --with-K --safe #-} |
| 8 |
|
| 9 |
module Data.Star.Fin where |
| 10 |
|
| 11 |
open import Data.Star.Nat as ℕ using (ℕ) |
| 12 |
open import Data.Star.Pointer using (Any; this; that) |
| 13 |
open import Data.Unit.Base using (⊤; tt) |
| 14 |
|
| 15 |
-- Finite sets are undecorated pointers into natural numbers. |
| 16 |
|
| 17 |
Fin : ℕ → Set |
| 18 |
Fin = Any (λ _ → ⊤) (λ _ → ⊤) |
| 19 |
|
| 20 |
-- "Constructors". |
| 21 |
|
| 22 |
zero : ∀ {n} → Fin (ℕ.suc n) |
| 23 |
zero = this tt |
| 24 |
|
| 25 |
suc : ∀ {n} → Fin n → Fin (ℕ.suc n) |
| 26 |
suc = that tt |