A universal prefix machine: KB, the prefix complexity KE is about #
Extends CodeLayer/AdditiveComplexity.lean (E, elen, KE) and CodeLayer/BinaryKraft.lean.
What this establishes #
A description is a machine c : Code, serialized by E, followed by a binary argument p; the
machine is made prefix-free the standard way (prefix-free-ification by stages) rather than assumed
so.
bitsToNat,natToBits: a bit-string/natural bijection,[] ↦ 0, defined inCodeLayer/BitStringPrimrec.lean; here its two inverse laws and its length law.PrefixFree: no member of a set of bit-strings is a proper prefix of another — Mathlib'sInformationTheory.IsPrefixFreeat the binary alphabet (prefixFree_iff_isPrefixFree).isUniquelyDecodable_of_prefixFree,kraft_of_prefixFree: a prefix-free set of bit-strings is uniquely decodable and satisfies Kraft's inequality — Mathlib's two theorems, specialized to bit-strings.pfy: the prefix-free-ification of a code by stages;pfy_prefixFree,pfy_sub,pfy_eq_of_prefixFree.KB: prefix complexity — leastelen c + p.lengthover a serialized machine and a binary argument;KB_le_KE(KBis additively belowKE);kraft_KB(KBis a semimeasure).
What this does NOT establish (flagged) #
- The algorithmic probability
QB, its lower-semicomputability, and the coding theorem itself (general or instance form) are not attempted here.
pfy_partrec (Partrec₂ pfy, uniformity in c) — the boundary this module once flagged — is
established in CodeLayer/BitStringPrimrec.lean, over the bit-string computability layer it adds.
Hypotheses: standard vs added #
- Standard: a universal prefix machine over binary programs (a finite program is a binary string for a reference machine).
- Added / modeling: the concrete prefix-free-ification by stages (a fixed effective enumeration);
the machine-plus-binary-argument description shape (
E c ++ p).
A bit-string / natural bijection #
decide (x = 1) recovers a bit from its Bool.toNat.
Prefix-free sets of bit-strings #
PrefixFree is Mathlib's InformationTheory.IsPrefixFree at the binary alphabet
(prefixFree_iff_isPrefixFree). Mathlib proves that a prefix-free set without the empty word is
uniquely decodable and Kraft's inequality for an arbitrary prefix-free set over a finite alphabet;
the two theorems below are those, specialized to bit-strings and to the base 1 / 2 of KB's
series.
No member is a proper prefix of another. (A prefix-free set containing [] is forced, by this
very property, down to {[]}, Mathlib's IsPrefixFree.eq_singleton_empty_of_empty_mem; unique
decodability needs the extra hypothesis [] ∉ S ruling that degenerate case out.)
Equations
- PrefixMachine.PrefixFree S = ∀ p ∈ S, ∀ q ∈ S, p <+: q → p = q
Instances For
The local predicate is Mathlib's IsPrefixFree at the binary alphabet.
A prefix-free set not containing the empty word is uniquely decodable.
Prefix-free-ification of a code, by stages #
accepted c s greedily accepts, at each stage, the inputs newly halting there whose bit-strings
are comparable to nothing accepted so far — the standard effective enumeration of prefix machines,
with E c (via pfy's caller) in place of the usual index prefix. Input 0 (the empty
bit-string []) is a candidate like any other: if it halts, prefix-freeness ([] a prefix of
everything) forces it to be the ONLY thing ever accepted, which is exactly the guard-code
construction KB_le_KE needs.
The inputs newly halting at stage s + 1.
Equations
- PrefixMachine.newlyHalting c s = List.filter (fun (n : ℕ) => (Nat.Partrec.Code.evaln (s + 1) c n).isSome && !(Nat.Partrec.Code.evaln s c n).isSome) (List.range (s + 1))
Instances For
The accepted inputs at stage s: greedily, by foldStep, over what newly halts at each
earlier stage.
Equations
Instances For
Once accepted, an input stays accepted at every later stage.
Anything accepted at stage s + 1 has halted by then.
The prefix-free-ification of c. n's output is evaln s c n at the first stage s
where n is accepted, if any.
Equations
- PrefixMachine.pfy c n = if h : ∃ (s : ℕ), n ∈ PrefixMachine.acceptedList c s then Part.some ((Nat.Partrec.Code.evaln (Nat.find h) c n).get ⋯) else Part.none
Instances For
pfy c's domain, read as bit-strings, is prefix-free.
pfy reproduces eval exactly, once eval's halting domain is already prefix-free.
KB: prefix complexity over the universal prefix machine pfy #
A description is a serialized machine E c, followed by a binary argument p; KB x is the
least total length elen c + p.length over descriptions decoding, via pfy, to x.
Prefix complexity: least elen c + p.length over a serialized machine and a binary
argument decoding to x via pfy.
Equations
- PrefixMachine.KB x = sInf {l : ℕ | ∃ (c : Nat.Partrec.Code) (p : List Bool), x ∈ PrefixMachine.pfy c (PrefixMachine.bitsToNat p) ∧ AdditiveComplexity.elen c + p.length = l}
Instances For
Its binary argument.
Equations
Instances For
The counting bound on KB: at most finitely many naturals are describable within a fixed
budget — KB's twin of AdditiveComplexity.finite_KE_le, over E c ++ q (injective by
E_append_inj) in place of E c alone, since a KB-description carries an argument too.
The Kraft weight of a description, zeroed out unless its argument is genuinely in pfy c's
domain (read as a bit-string). A nonnegative function on Code × List Bool whose row sums (fixed
c) are Kraft-bounded by kraft_of_prefixFree, and whose column sum over c (kraft_KP_E)
bounds the whole.
Equations
- PrefixMachine.kbWeight cp = if cp.2 ∈ PrefixMachine.natToBits '' (PrefixMachine.pfy cp.1).Dom then (1 / 2) ^ (AdditiveComplexity.elen cp.1 + cp.2.length) else 0
Instances For
KB's Kraft series is summable. Each x contributes the weight of its own shortest
description (min_desc_spec), and the descriptions are pairwise distinct (min_desc_injective), so
the series is dominated, along that injection, by summable_kbWeight. Hoisted out of kraft_KB so
the counting bound (AIT/PrefixCounting.lean) can cite it without re-deriving kraft_KB
itself.
Kraft's inequality for KB: ∑ₓ 2⁻ᴷᴮ⁽ˣ⁾ ≤ 1 — KB is a semimeasure. Each x contributes
the weight of its own shortest description; the descriptions are pairwise distinct
(min_desc_injective), and for a fixed machine c the arguments range over pfy c's domain,
prefix-free by pfy_prefixFree, hence Kraft-summable by kraft_of_prefixFree.