I am new to Agda. I’m reading the paper “Dependent Types at Work” by Ana Bove and Peter Dybjer. I don’t understand the discussion of Finite Sets (on page 15 in my copy).
The paper defines a Fin type:
data Fin : Nat -> Set where
fzero : {n : Nat} -> Fin (succ n)
fsucc : {n : Nat} -> Fin n -> Fin (succ n)
I must be missing something obvious. I don’t understand how this definition works. Could someone simply translate the definition of Fin into everyday English? That might be all I need to understand this part of the paper.
Thanks for taking the time to read my question. I appreciate it.
Fin is a data type parametrized by a natural number (or:
Finis a type-level function which takes aNatand returns aSet(basic type), i.e. for any natural numbern,Fin nis aSet).For all natural numbers
n,fzerois a member of the type/setFin (succ n), from which follows that for all positive numbersn(i.e. all naturals except zero),fzerois a member ofFin n.For all natural numbers
nand all valuesmof typeFin n,fsucc mis a member of typeFin (succ n).So
fzerois a member ofFin nfor allnexcept zero andfsucc mis a member ofFin nfor allnthat represent a number greater thanfsucc m.Basically
Fin nrepresents the Set of all natural numbers smaller thann, i.e. of all valid indices for lists of sizen.