-
Notifications
You must be signed in to change notification settings - Fork 1
Description
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
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 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
freshof typenat -> seq Tgenerating an n-tuple of unique identifiers:forall n, size (fresh n) = n;forall n, unique (fresh n).