Initial commit with readme and basic definitions

This commit is contained in:
Nathan van Doorn 2024-06-19 19:16:22 +02:00
commit 1188fb505a
3 changed files with 55 additions and 0 deletions

5
README.md Normal file
View File

@ -0,0 +1,5 @@
# Thinnings
Inspired by Conor McBride's paper Everybody's Got To Be Somewhere.
This is exploration and not currently intended to be used as a library.

47
src/Thinning.agda Normal file
View File

@ -0,0 +1,47 @@
{-# OPTIONS --safe --without-K #-}
module Thinning where
open import Data.List.Base using (List; []; _∷_)
open import Level using (Level)
open import Relation.Binary.Core using (Rel)
private
variable
a : Level
A : Set a
xs ys zs : List A
-- The type of a Thinning
------------------------------------------------------------------------
-- A thinning is a way of saying how we can find every element of a list in
-- another list, in the right order.
data Thinning (A : Set a) : Rel (List A) a where
-- We can certainly find every element of the empty list in the empty list.
-- This is generally the base case for recursion on thinnings.
end : Thinning A [] []
-- It's possible we'll find the first element of the smaller list at the head
-- of the larger list.
include : {x : A} Thinning A xs ys Thinning A (x xs) (x ys)
-- It's also possible that we won't, and have to look deeper in the larger
-- list.
exclude : {x : A} Thinning A xs ys Thinning A xs (x ys)
-- Operations on Thinnings
------------------------------------------------------------------------
-- I'm choosing the names here to emphasize that there is a category of
-- Thinnings.
-- There is always a Thinning from the list to itself. We include at every step.
id : Thinning A xs xs
id {xs = []} = end
id {xs = x xs} = include id
-- We can compose two Thinnings!
_∘_ : Thinning A ys zs Thinning A xs ys Thinning A xs zs
end end = end
include α include β = include (α β)
include α exclude β = exclude (α β)
exclude α β = exclude (α β)

3
thinnings.agda-lib Normal file
View File

@ -0,0 +1,3 @@
name: thinnings
include: src
depend: standard-library-2.0 agda-categories