A definition for finite sets in Agda

假装没事ソ 提交于 2019-12-04 00:16:50
data Fin : Nat -> Set where

Fin is a data type parametrized by a natural number (or: Fin is a type-level function which takes a Nat and returns a Set (basic type), i.e. for any natural number n Fin n is a Set).

    fzero : {n : Nat} -> Fin (succ n)

For all natural numbers n fzero is a member of the type/set Fin (succ n) (from which follows that for all positive numbers (i.e. all naturals except zero) n fzero is a member of Fin n).

    fsucc : {n : Nat} -> Fin n -> Fin (succ n)

For all natural numbers n and all values m of type Fin n, fsucc m is a member of type Fin (succ n).


So fzero is a member of Fin n for all n except zero and fsucc m is a member of Fin n for all n which represent a number greater than fsucc m.

Basically Fin n represents the Set of all natural numbers smaller than n, i.e. of all valid indices for lists of size n.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!