Total decoders #
A decoder for an encoding enc : α ↪ List Bool (Turing.MultiTapeTM.Decoder) is a function on
all words that inverts enc on its image and is tidily computable within bounds of fixed degrees.
On a malformed word it still returns a value, whose encoding has polynomial length.
Decoders are built along the structure of an encoding: unary numbers by their length, binary
numbers by reading their digits up to the last true (Turing.MultiTapeTM.ofBits), Booleans by
their first symbol, options by testing for the empty word, pairs by reading the framed first
component (Turing.MultiTapeTM.unframe) and what follows it (Turing.MultiTapeTM.dropFrame), and
lists by splitting a word into framed words (Turing.MultiTapeTM.frames) and decoding each. The
splitting is done by a finite-state transducer that closes a final incomplete frame, so that every
word yields a valid encoded list, and the framed words of an encoded list are its encoded
elements.
Main definitions #
Turing.MultiTapeTM.frames: the framed words one after another in a word.Turing.MultiTapeTM.ofBits: binary digits, least significant first, read as a number.Turing.MultiTapeTM.Decoder: total decoders with tidy certificates of fixed degrees.Turing.MultiTapeTM.Decoder.bits,.unary,.nat,.bool,.option,.pair,.list,.map: decoders of bit strings, unary and binary numbers, Booleans, options, pairs and lists, and transport along an equivalence of encodings.
Main results #
Turing.MultiTapeTM.frames_encList: the framed words of an encoded list are its encoded elements.Turing.MultiTapeTM.computableTidilyInDegree_frames: splitting into framed words is linear.Turing.MultiTapeTM.bits_ofBits: the binary digits of a word read as a number are the word up to its lasttrue.
Framed words one after another #
The states of the transducer splitting a word into framed words: between frames, inside a frame after a marker, and inside a frame after a symbol.
- between : FramesState
- marker : FramesState
- symbol : FramesState
Instances For
Splits a word into framed words, closing a final incomplete frame.
Instances For
Inside a frame, the transducer completes the frame at the start of its input and continues with what follows.
Splitting a word into framed words is linear.
Binary digits #
Binary digits, least significant first, read as a number.
Instances For
The binary digits of a word read as a number are the word up to its last true.
Drops the falses at the start of a word.
Instances For
Decoders #
A total decoder for the encoding enc: a function on all words that inverts enc and is
tidily computable within time, space and output length of fixed degrees in the length of the
word.
The decoded value of any word.
Decoding inverts the encoding.
- computable : ∃ (d : ℕ) (e : ℕ), ComputableTidilyInDegree self.decode encBits enc d e
Decoding is tidily computable within bounds of fixed degrees.
Instances For
Bit strings are their own encoding.
Instances For
Unary numbers are decoded by the length of the word.
Instances For
Binary numbers are decoded from their digits up to the last true.
Instances For
Booleans are decoded from the first symbol.
Instances For
Transport a decoder to an encoding enc' agreeing with enc along f, where g is a right
inverse of f.