Numbering a structured index #
The index types of Dinur's construction are built from a few formers: a pair of
indices, a choice between two, an optional one, a tuple. Fintype numbers such
a type too, but by an enumeration no algorithm can follow. This module numbers
them explicitly instead: a pair is numbered by mixed radix, a choice by
offsetting the second summand, a tuple by its digits.
The decoding is partial — a number out of range names nothing — which is what makes the numbering compose without needing any type to be inhabited.
Main definitions #
Complexity.NumEnc— an explicit numbering of a finite type
Main results #
An explicit numbering of a finite type: every value has a number below
card, and every number below card names a value.
- card : ℕ
How many values there are.
- enc : α → ℕ
The number of a value.
The value a number names, if any.
Numbers are below the count.
Decoding a number back gives the value.
And a number in range is the number of what it names.
Every number below the count names something.
Instances
The value a number in range names.
Equations
Instances For
The count is the number of values.
The numbering, as an equivalence with Fin of the type's own cardinality —
a drop-in replacement for Fintype.equivFin that an algorithm can follow.
Equations
Instances For
The formers #
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Any finite type is numbered by its own enumeration. For a type whose size is a constant, that is all an algorithm needs: the numbering is a lookup on a bounded key.
Equations
- One or more equations did not get rendered due to their size.