The closure library, part V: the binary successor, and unary to binary #
The successor on binary numerals (incBitsProg, PolyTimeFun.inc: flip the leading 1s and the
first 0, in two passes as decProg), the conversion of a unary numeral to binary
(PolyTimeFun.unaryToBin, a fold of the successor), data as its own encoding, the bits of a
number, and the tagging combinator (PolyTimeFun.tagged) for constructors of encoded
inductive types (planning/succinct-cook-levin.md, S3).
Data as data #
Data encode as themselves.
Equations
- MIPRE.Cost.instSizedEncodingData = { encode := id, decode := some, decode_encode := MIPRE.Cost.instSizedEncodingData._proof_1 }
Bit strings #
The bits of a number, as a polynomial-time function: the encoding is the same.
Equations
Instances For
A number as its encoding.
Equations
Instances For
A program as its encoding.
Equations
Instances For
The binary successor #
The successor of a binary numeral (least significant bit first).
Equations
Instances For
Body of the successor loop: on cons xs acc, if xs is empty stop with (acc, [1]); if
its head is 0 stop with (acc, 1 · tail); if its head is 1 continue with
(tail, 0 · acc). Reversing the first component onto the second then gives the successor.
Equations
Instances For
The stop on a head 0: (acc, 1 · tail).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The continuation on a head 1: (tail, 0 · acc).
Equations
Instances For
The body of the successor loop.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The successor loop on 1^j · rest (with rest empty or starting with 0) from the
accumulator acc stops with (0^j · acc, incTail rest).
The successor of a binary numeral: incBitsProg on encode l computes encode (incBits l).
Equations
Instances For
The successor on binary numerals, in polynomial time.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A unary numeral to binary, by a fold of the successor.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Tagged constructors #
A constructor whose encoding pairs a unary tag with the encoding of its argument.
Equations
- One or more equations did not get rendered due to their size.