Documentation

Complexity.Computability.Machines.Turing.MultiTape.Encodings.Decoder

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 #

Main results #

Framed words one after another #

Dropping a frame does not lengthen a word.

Dropping a frame shortens a nonempty word.

@[irreducible]

The words framed one after another in w. A final incomplete frame is closed.

Instances For

    A framed word followed by another word.

    theorem Turing.MultiTapeTM.frames_encList {α : Type u_1} (enc : α ↪ List Bool) (l : List α) :
    frames ((encList enc) l) = List.map (⇑enc) l

    The framed words of an encoded list are its encoded elements.

    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.

    Instances For

      Splits a word into framed words, closing a final incomplete frame.

      Instances For
        @[simp]
        theorem Turing.MultiTapeTM.framesT_final (x✝ : FramesState) :
        framesT.final x✝ = match x✝ with | FramesState.between => [] | x => [false]

        Inside a frame, the transducer completes the frame at the start of its input and continues with what follows.

        The transducer emits the encoded list of framed words.

        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 #

            structure Turing.MultiTapeTM.Decoder {α : Type} (enc : α ↪ List Bool) :

            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.

            Instances For

              Every total decoder has a native polynomial-time certificate.

              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

                      Options are decoded as none from the empty word, and otherwise from the tail.

                      Instances For
                        def Turing.MultiTapeTM.Decoder.pair {β₁ β₂ : Type} {enc₁ : β₁ ↪ List Bool} {enc₂ : β₂ ↪ List Bool} (D₁ : Decoder enc₁) (D₂ : Decoder enc₂) :
                        Decoder (encPair enc₁ enc₂)

                        Pairs are decoded from the framed first component and what follows it.

                        Instances For
                          def Turing.MultiTapeTM.Decoder.list {α : Type} {enc : α ↪ List Bool} (D : Decoder enc) :

                          Lists are decoded element by element from the framed words of a word.

                          Instances For
                            def Turing.MultiTapeTM.Decoder.map {α β : Type} {enc : α ↪ List Bool} {enc' : β ↪ List Bool} (D : Decoder enc) (f : α → β) (g : β → α) (hfg : ∀ (b : β), f (g b) = b) (henc : ∀ (a : α), enc' (f a) = enc a) :
                            Decoder enc'

                            Transport a decoder to an encoding enc' agreeing with enc along f, where g is a right inverse of f.

                            Instances For