(** - The setoid of natural numbers - not really necessary but it's nice to have a
 uniform approach *)

Definition Nat : Setoid.(** - In this formalisation, we often need the sets $\{0...n-1\}$ 
 We use these for finite sequences: $(a_1...a_n)$ is represented 
 as a setoid function $a:\{0...n-1\}\to A$; also these elements are used as 
 indices into these sequences. Since we use a function type to 
 represent a sequence, we can just type [(a i)] for $a_i$. 
 - finiteT will serve as the Type on which we base our finite 
 setoids [(fin N)] = $\{0...N-1\} = \{ n \in N | n<N \}$. *)

Record finiteT (N : Nat) : Type :=  {index : nat; in_range_prf : index < N}.(** - In this formalisation, we often need the sets $\{0...n-1\}$ 
 We use these for finite sequences: $(a_1...a_n)$ is represented 
 as a setoid function $a:\{0...n-1\}\to A$; also these elements are used as 
 indices into these sequences. Since we use a function type to 
 represent a sequence, we can just type [(a i)] for $a_i$. 
 - finiteT will serve as the Type on which we base our finite 
 setoids [(fin N)] = $\{0...N-1\} = \{ n \in N | n<N \}$. *)

Record finiteT (N : Nat) : Type :=  {index : nat; in_range_prf : index < N}.(** - In this formalisation, we often need the sets $\{0...n-1\}$ 
 We use these for finite sequences: $(a_1...a_n)$ is represented 
 as a setoid function $a:\{0...n-1\}\to A$; also these elements are used as 
 indices into these sequences. Since we use a function type to 
 represent a sequence, we can just type [(a i)] for $a_i$. 
 - finiteT will serve as the Type on which we base our finite 
 setoids [(fin N)] = $\{0...N-1\} = \{ n \in N | n<N \}$. *)

Record finiteT (N : Nat) : Type :=  {index : nat; in_range_prf : index < N}.(** - The setoid itself is called [(fin N)]. [n:(finiteT N)] is really a pair <n,H>;
 <n,H> and <n',H'> will be deemed equal if n and n' are; the proofs H of n<N and 
 H' of n'(=n)<N may differ. 

 - %\bf% Useful knowledge: if [H:(lt i n)] then [(Build_finiteT H):(fin n)]

%\label{fin}% *)


Definition fin : Nat -> Setoid.

Lemma fin_O_nonexistent : fin 0 -> False.