Canonical encoding of width-five branching programs #
This module exposes the machine-facing codec used by the uniform Barrington
track. Every S₅ permutation is ranked in a fixed computable table and stored
in seven bits. Instructions add a terminated-unary variable index, and a
program adds a terminated-unary instruction count.
The exact decoder is a left inverse, serialization is injective, nonempty trailing data is rejected, and the code length is explicit. Consequently the remaining uniformity proof can target one stable bit format without carrying finite permutation proofs on the machine tape.
Main results #
BPCode.Perm5.decodePrefix?_encode_append-- permutation-field round trip.BPCode.Instr.decodePrefix?_encode_append-- instruction round trip.BPCode.Program.decode?_encode-- whole-program round trip.BPCode.Program.encode_injective-- canonical codes are unambiguous.BPCode.Program.length_encode-- exact serialization length.
The explicit permutation table has exactly 5! = 120 entries.
Every permutation of Fin 5 occurs in the fixed table.
Every canonical table position fits in the seven-bit field.
Every encoded permutation field has the fixed width of seven bits.
Decoding an encoded permutation in front of any suffix recovers both.
Fixed-count decoding consumes exactly the requested encoded instructions.
Canonical program serialization is injective.
If all variable indices are bounded, serialization has the corresponding linear-in-program-length bound.