Skip to content

Design of identType #21

@anton-trunov

Description

@anton-trunov

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.

  1. 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
  1. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest For Comment

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions