Unary coding of natural numbers #
The delimiter-terminated unary code unaryCode n = 1ⁿ 0 encodes natural numbers as Boolean words
such that concatenations of encoded words are uniquely decodable (flatMap_unaryCode_injective).
Main definitions #
List.unaryCode:ncopies oftruefollowed byfalse.
Main results #
List.flatMap_unaryCode_injective: concatenated unary codes uniquely determine the sequence of numbers.List.primrec_unaryCode: the unary encoding is primitive recursive.List.getD_replicate_true_append_false_of_le,List.getD_replicate_true_append_false_add: the bits of a unary block followed byfalse, and of what follows it.
The unary code of a natural number: n letters true followed by false. Distinct
sequences of numbers have distinct concatenated codes.
theorem List.flatMap_unaryCode_injective :