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.
The decoded value, or
noneon 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.
Every encoded value is accepted and recovered.
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.
Decode a framed first field followed by the second field, retaining scalar order.
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.