Polynomial-time bit-list operations #
Raw bit strings and framed lists share the list and iteration calculus. Captured traversals, Boolean folds, pointwise operations, majority and selected mask sums have compositional certificates. Runtime dimensions are computed in unary. Enumeration additionally requires a polynomial bound on the complete encoded output. The operations are total on empty and short lists.
Main results #
Turing.MultiTapeTM.ofBits_reverse: agreement of the two binary-word conventions.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsBinaryValue: binary-valued word decoding.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsLow: fixed-width low-order binary digits.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsToList,.listToBits: encoding conversion.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsFlatten: concatenate computed raw words.Turing.MultiTapeTM.ComputableTidilyInPolyTime.flatMapToBitsWithInput: concatenate captured words over a framed list.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsFrame,.bitsPadWord: self-delimiting framing and bounded padding, including arbitrary encoded inputs and overlong words.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsGetElem?: optional lookup in raw bits.Turing.MultiTapeTM.ComputableTidilyInPolyTime.mapToBitsWithInput,.bitsFilterWithInput,.bitsAnyWithInput,.bitsFoldlWithInput,.bitsZipWithInput, andTuring.MultiTapeTM.ComputableInPolyTime.bitsAllWithInput: compositional bit operations.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsStrictMajority,.bitsSingle,.bitsSingles,.bitsXorSelected,.bitsXorWithInput: finite-mask algorithms.Turing.MultiTapeTM.ComputableInPolyTime.bitsCountPWithInput,Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsCountWithInput: unary counts under captured predicates or computed labels.Turing.MultiTapeTM.ComputableInPolyTime.bitsNonpositiveMarginWithInput: compare the correct-vote count with the word length.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsEnumList: output-bounded enumeration.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsBoundedBinaryValue: capped binary decoding to unary, with every intermediate accumulator bounded by the supplied cap.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsReplicate: repeat a fixed bit.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsWordLt: lexicographic word comparison.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsRowWithInput: read one fixed-width row.Turing.MultiTapeTM.ComputableTidilyInPolyTime.bitsRowsWithInput: read a runtime number of rows.
References #
Adapted from Computability/Probabilistic/BitString.lean and
Computability/Probabilistic/UniformNat.lean and
Crypto/Computational/GoldreichLevin/WordDecoder.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8, using the tidy machine calculus.
Reversing a most-significant-first word gives its little-endian binary decoding.
Frame the existing input encoding, charging every delimiter.
Saturating binary decoding to unary is polynomial time on arbitrary input words.
Decode computed bits under a computed unary cap, fixing both intermediate encodings.
Convert a binary value to unary under a computed unary bound.
Convert a raw bit string to the framed list encoding.
Optional lookup in a raw bit string, fixing the representation of the returned bit.
Remove the framing from a list of bits.
Repeat a fixed bit a unary number of times.
Concatenate computed raw words, fixing the intermediate list encoding before proof search.
Self-delimiting padding uses ordinary framing and unary arithmetic.
Map a captured Boolean-valued function over a framed list, emitting a raw bit string.
Concatenate captured raw bit strings over a framed list. The complete intermediate words
and their framing are charged before concatenation. Apply this rule explicitly: registering both
raw and framed flatMap outputs makes existing enumeration proof search exceed its limit.
Emit a computed unary number of low-order digits of a computed binary natural. The width charges every output bit, including leading zero digits.
Map a captured Boolean operation over a raw bit string.
Filter a raw bit string with a predicate that may capture its original input.
Count occurrences of a computed bit in a raw bit string.
Test whether any bit satisfies a captured predicate.
A Boolean fold has constant-sized state, so no separate state bound is needed.
Pointwise operations on computed words, with both intermediate encodings fixed.
Strict majority uses filtering, length, unary multiplication and comparison.
Strict majority of computed votes fixes the intermediate raw-word encoding.
Generate one coordinate mask from its unary width and index.
Generate all coordinate masks, charging for their quadratic total size.
Sum selected rows with a shrinking selector and an accumulator that never grows.
Enumerate words only when their complete encoded size is polynomially bounded. This does not claim polynomial time in the number of enumerated bits.
Read a row of a computed word, including the cost of padding a short word.
Extract rows from a word with polynomial-time unary dimensions.
Variable-width XOR uses runtime lookup and ordinary Boolean folds.
Lexicographic comparison of equal-length words is polynomial-time.
Decode arbitrary most-significant-first bit words to binary naturals.
Plain polynomial-time automation #
Test whether any bit satisfies a captured predicate.
Self-delimiting padding uses ordinary framing and unary arithmetic.
Repeat a fixed bit a unary number of times, including zero repetitions.
Apply a fixed Boolean operation pointwise to two computed raw words. The result stops at whichever word ends first; the two certificates retain their raw bit-string encoding.
Read a row of a computed word, charging padding and both computed unary indices.
Frame the existing input encoding, charging every delimiter.
Saturating binary decoding to unary is polynomial time on arbitrary input words.
Decode computed bits under a computed unary cap, fixing both intermediate encodings.
Convert a binary value to unary under a computed unary bound.
Convert a raw bit string to the framed list encoding.
Optional lookup in a raw bit string, fixing the representation of the returned bit.
Concatenate computed raw words, fixing the intermediate list encoding before proof search.
Map a captured Boolean-valued function over a framed list, emitting a raw bit string.
Concatenate captured raw bit strings over a framed list. The complete intermediate words
and their framing are charged before concatenation. Apply this rule explicitly: registering both
raw and framed flatMap outputs makes existing enumeration proof search exceed its limit.
Emit a computed unary number of low-order digits of a computed binary natural. The width charges every output bit, including leading zero digits.
Map a captured Boolean operation over a raw bit string.
Filter a raw bit string with a predicate that may capture its original input.
Count predicate matches in a raw bit string, including a captured input.
Count occurrences of a computed bit in a raw bit string.
Test whether every bit satisfies a captured predicate.
A Boolean fold has constant-sized state, so no separate state bound is needed.
Strict majority uses filtering, length, unary multiplication and comparison.
Strict majority of computed votes fixes the intermediate raw-word encoding.
The training test is polynomial time in the vote list and its supplied label.
Generate one coordinate mask from its unary width and index.
Generate all coordinate masks, charging for their quadratic total size.
Sum selected rows with a shrinking selector and an accumulator that never grows.
Enumerate words only when their complete encoded size is polynomially bounded. This does not claim polynomial time in the number of enumerated bits.
Extract rows from a word with polynomial-time unary dimensions.
Variable-width XOR uses runtime lookup and ordinary Boolean folds.
Lexicographic comparison of equal-length words is polynomial-time.
Decode arbitrary most-significant-first bit words to binary naturals.