So far we have an idea that identType is a type T with a function fresh : seq T -> T with the property (fresh xs) \notin xs.
This, however, presents an issue: the fresh function needs to traverse its input list to generate a fresh value but if we need to call it repeatedly to generate a sequence of fresh identifiers, this resulting algorithm is going to be quadratic.
Instead, we could change the type of fresh to T -> T, i.e. we can generate a new fresh ident given the previous one. (So, for example, an instance of identType for nat would have succn as its fresh function.)
Let me outline several property statements that seem to be useful.
- One of the most general ones (it only requires
T to be eqType) could look like this (traject lives in Mathcomp's path module):
forall (n : nat) (x : T), unique (traject fresh x n)
Basically, this says that all powers of fresh function produce distinct elements.
2. Another option (this would require T to be ordType) is to say
forall x : T, x < fresh x
- And yet another option would be to make
fresh of type nat -> seq T generating an n-tuple of unique identifiers:
forall n, size (fresh n) = n;
forall n, unique (fresh n).
So far we have an idea that
identTypeis a typeTwith a functionfresh : seq T -> Twith the property(fresh xs) \notin xs.This, however, presents an issue: the
freshfunction needs to traverse its input list to generate a fresh value but if we need to call it repeatedly to generate a sequence of fresh identifiers, this resulting algorithm is going to be quadratic.Instead, we could change the type of
freshtoT -> T, i.e. we can generate a new fresh ident given the previous one. (So, for example, an instance ofidentTypefornatwould havesuccnas itsfreshfunction.)Let me outline several property statements that seem to be useful.
Tto beeqType) could look like this (trajectlives in Mathcomp'spathmodule):forall (n : nat) (x : T), unique (traject fresh x n)Basically, this says that all powers of
freshfunction produce distinct elements.2. Another option (this would require
Tto beordType) is to sayforall x : T, x < fresh xfreshof typenat -> seq Tgenerating an n-tuple of unique identifiers:forall n, size (fresh n) = n;forall n, unique (fresh n).