InformationTheory.Shannon.Kolmogorov.PrefixMachine
A self-delimiting (prefix-free) universal machine for prefix complexity #
The plain universal machine universalEval is not self-delimiting: the echo
program false :: encodeNat x is prefix-closed, so its valid-program set is not
prefix-free and the Kraft-McMillan inequality does not apply. This file builds a
separate machine prefixUniversalEval whose valid-program set is prefix-free.
Every valid program has the shape selfDelimit bs = replicate |bs| true ++ false :: bs
(a unary length prefix followed by the payload). The machine reads the unary
prefix with parseUnary, accepts only when the recovered length matches the
payload length (full self-delimited consumption), and then decodes the payload
in the same two modes as the plain machine (literal echo / interpret). Because
the accepted set is contained in the prefix-free image of selfDelimit, the
Kraft-McMillan inequality applies to each of its finite subsets.
Main definitions #
PrefixFree— a set of bit-string codewords is prefix-free.selfDelimit— the unary length-prefix self-delimiting wrapper.prefixUniversalEval— the fixed self-delimiting universal machine.prefixComplexity— prefix Kolmogorov complexityK(x).universalProb— the universal probabilityP_U(x)inℝ≥0∞.
Main statements #
PrefixFree.uniquelyDecodable— prefix-free (with no empty codeword) implies uniquely decodable, bridging tokraft_mcmillan_inequality.PrefixFree.kraft/PrefixFree.tsum_inv_two_pow_length_le_one— the finite and infinite Kraft bounds∑ 2^{-|p|} ≤ 1for an arbitrary prefix-free set of codewords with no empty codeword.prefixUniversalEval_kraft— every finite set of valid programs satisfies the Kraft bound∑ 2^{-|p|} ≤ 1.tsum_inv_two_pow_length_le_one— the infinite form of the Kraft bound, for any set of valid programs.
InformationTheory.Kolmogorov.PrefixFree
sourceA set of bit-string codewords is prefix-free (self-delimiting): no codeword is a prefix of a distinct codeword.
Equations
- InformationTheory.Kolmogorov.PrefixFree S = ∀ a ∈ S, ∀ b ∈ S, a <+: b → a = b
Instances For
Used by
InformationTheory.Kolmogorov.PrefixFree.mono
sourceUsed by
InformationTheory.Kolmogorov.PrefixFree.uniquelyDecodable
sourcePrefix-free codes with no empty codeword are uniquely decodable. Not in
Mathlib; bridges to kraft_mcmillan_inequality.
@audit:ok
Used by
InformationTheory.Kolmogorov.uniquelyDecodable_mono
sourceUsed by
InformationTheory.Kolmogorov.selfDelimit
sourceThe unary length-prefix self-delimiting wrapper: bs.length in unary
(a run of trues terminated by false) followed by the payload bs. Its image
over all payloads is prefix-free.
Equations
Instances For
Used by
InformationTheory.Kolmogorov.parseUnary_snd_eq_nil_of_not_mem
sourceUsed by
InformationTheory.Kolmogorov.parseUnary_reconstruct
sourceUsed by
InformationTheory.Kolmogorov.parseUnary_selfDelimit
sourceUsed by
InformationTheory.Kolmogorov.selfDelimit_length
sourceUsed by
InformationTheory.Kolmogorov.range_selfDelimit_prefixFree
sourceUsed by
InformationTheory.Kolmogorov.decodePayload
sourceDecode a self-delimited payload. false :: bs echoes decodeNat bs;
true :: bs interprets bs as a code index (unary) plus a description,
delegating to Mathlib's universal interpreter eval.
Equations
- One or more equations did not get rendered due to their size.
- InformationTheory.Kolmogorov.decodePayload [] = Part.none
- InformationTheory.Kolmogorov.decodePayload (false :: bs) = Part.some (Computability.decodeNat bs)
Instances For
Used by
InformationTheory.Kolmogorov.prefixUniversalEval
sourceThe fixed self-delimiting universal machine. A program is accepted only if
its unary length prefix matches the payload length (so its domain lies in the
prefix-free image of selfDelimit), then the payload is decoded.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
InformationTheory.Kolmogorov.decodePayload_dom_ne_nil
sourceUsed by
InformationTheory.Kolmogorov.prefixUniversalEval_nil_not_dom
sourceUsed by
InformationTheory.Kolmogorov.dom_imp_mem_range
sourceUsed by
InformationTheory.Kolmogorov.prefixUniversalEval_dom_prefixFree
sourceUsed by
InformationTheory.Kolmogorov.prefixLiteralProg
sourceThe prefix echo program describing x: x's binary payload wrapped by the
literal mode flag and the self-delimiting length prefix.
Equations
Instances For
Used by
InformationTheory.Kolmogorov.prefixUniversalEval_literal
sourceUsed by
InformationTheory.Kolmogorov.PrefixFree.kraft
sourceThe Kraft-McMillan bound ∑ 2^{-|p|} ≤ 1 for a finite subset of an arbitrary
prefix-free set of codewords with no empty codeword.
@audit:ok
Used by
InformationTheory.Kolmogorov.prefixUniversalEval_kraft
sourceEvery finite set of valid programs of the self-delimiting machine satisfies
the Kraft-McMillan bound ∑ 2^{-|p|} ≤ 1.
@audit:ok
Used by
InformationTheory.Kolmogorov.PrefixFree.tsum_inv_two_pow_length_le_one
sourceThe infinite Kraft bound for an arbitrary prefix-free set of codewords: the
total weight ∑ 2^{-|p|} is at most 1. Every finite subsum is a Kraft sum, and
ℝ≥0∞-valued sums are suprema of those.
@audit:ok
Used by
InformationTheory.Kolmogorov.tsum_inv_two_pow_length_le_one
sourceThe infinite Kraft bound: any set of valid programs of the self-delimiting
machine, cut out by a predicate P, has total weight ∑ 2^{-|p|} ≤ 1. This is
PrefixFree.tsum_inv_two_pow_length_le_one specialized to the machine's domain,
which is prefix-free and contains no empty codeword.
@audit:ok
Used by
InformationTheory.Kolmogorov.prefixComplexity
sourcePrefix Kolmogorov complexity K(x): the length of the shortest
self-delimiting program producing x. The literal echo makes the set nonempty,
so this infimum is attained (prefixComplexity_spec).
Equations
Instances For
Used by
InformationTheory.Kolmogorov.prefixComplexity_set_nonempty
sourceUsed by
InformationTheory.Kolmogorov.prefixComplexity_spec
sourceUsed by
InformationTheory.Kolmogorov.universalProb
sourceUniversal probability P_U(x) = ∑_{p : U_prefix p = x} 2^{-|p|} in ℝ≥0∞.
The tsum is always defined; P_U(x) ≤ 1 follows from Kraft on finite subsets.