Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Encodings.Decoder.Partial

Strict partial decoders #

PartialDecoder enc decodes precisely the image of the explicitly chosen embedding enc. It returns none on every other word and supplies a native polynomial-time machine certificate. The value type may be empty. The certificate is an additional resource assumption on a scalar codec; an arbitrary embedding alone supplies no decoder or resource bound.

The constructors unit, empty, pair, sum, and list follow the existing encoding layouts. Pairs frame their first field; sums add one Boolean tag; lists frame every element in order. The existing frames parser supplies list splitting. Reencoding checks reject incomplete frames, noncanonical scalar words, and unconsumed bits. Syntax-level rejection of extra complete tokens belongs to the prefix parser using the resulting token-list codec.

checked upgrades a certified candidate decoder with a round-trip law to a strict decoder. ofDecoder and ofOptionDecoder reuse existing total decoders; the latter supports an empty value type because only its option type must have a total decoder. Every composition carries a native polynomial time and space certificate; no claim about arbitrary recursive functions is made.

A strict decoder with a native polynomial-time certificate on every input word.

  • decode : List Bool → Option α

    The decoded value, or none on a word outside the encoding's image.

  • decode_eq_some_iff (word : List Bool) (value : α) : self.decode word = some value ↔ enc value = word

    Successful decoding characterizes exactly the chosen word layout.

  • Native polynomial time and space, with the decoded output charged in encOption enc.

@[simp]
theorem Turing.MultiTapeTM.PartialDecoder.decode_enc {α : Type} {enc : α ↪ List Bool} (D : PartialDecoder enc) (value : α) :
D.decode (enc value) = some value

Every encoded value is accepted and recovered.

theorem Turing.MultiTapeTM.PartialDecoder.decode_eq_none_iff {α : Type} {enc : α ↪ List Bool} (D : PartialDecoder enc) (word : List Bool) :
D.decode word = none ↔ ¬∃ (value : α), enc value = word

A word is rejected exactly when it is outside the image of the chosen embedding.

def Turing.MultiTapeTM.PartialDecoder.checked {α : Type} {enc : α ↪ List Bool} (candidate : List Bool → Option α) (roundtrip : ∀ (value : α), candidate (enc value) = some value) (computable : ComputableInPolyTime candidate encBits (encOption enc)) :

Add a canonical-word check to a certified candidate decoder. The supplied law is only a round trip; arbitrary malformed candidate outputs are checked before acceptance.

Make an existing total decoder strict by checking the complete encoded word.

Use a total decoder of optional values without requiring an inhabitant of the value type. The added true bit is the existing encOption tag and is not part of the scalar layout.

The unit word is the empty word; every nonempty word is rejected.

An empty scalar type rejects every word, without choosing a fallback value.

def Turing.MultiTapeTM.PartialDecoder.pair {α β : Type} {enc : α ↪ List Bool} {enc' : β ↪ List Bool} (left : PartialDecoder enc) (right : PartialDecoder enc') :

Decode a framed first field followed by the second field, retaining scalar order.

def Turing.MultiTapeTM.PartialDecoder.sum {α β : Type} {enc : α ↪ List Bool} {enc' : β ↪ List Bool} (left : PartialDecoder enc) (right : PartialDecoder enc') :

Decode the existing one-bit sum tag and the selected scalar payload.

Decode every framed element with the supplied scalar codec and check the complete list word. Empty element types are supported, and malformed final frames are rejected.