Documentation

Complexity.Computability.Kolmogorov.TimeBounded

Time-bounded Kolmogorov complexity (K^t) and Levin's Kt #

This module defines the universal multi-tape Turing machine description method Cslib.Kolmogorov.DescriptionMethod.universalTM for binary strings, the corresponding plain and time-bounded Kolmogorov complexities Cslib.Kolmogorov.plain (K), Cslib.Kolmogorov.timeBoundedAt, and Cslib.Kolmogorov.timeBounded (K^t), and Levin's time-bounded Kolmogorov complexity Cslib.Kolmogorov.levinKt (Kt).

Modeling conventions #

Main definitions #

Main results #

References #

The universal multi-tape description method (universalTM) #

Clocked evaluation of a binary program p for t steps of the described multi-tape machine: parses p into the machine description decodeDesc (unframe p) and the input string dropFrame p, simulates the described machine for t steps, and maps the output symbol numbers to bits via (· != 0).

Instances For
    theorem Cslib.Kolmogorov.DescriptionMethod.universalTMRunFor_mono (p : List Bool) {t₁ t₂ : ℕ} (ht : t₁ ≤ t₂) {x : List Bool} (h : x ∈ universalTMRunFor p t₁) :

    The universal multi-tape Turing machine description method for binary strings (Liu and Pass, Section 2.2). A binary program p encodes the machine description decodeDesc (unframe p) and the input string dropFrame p. The clock counts steps of the described multi-tape machine, and the output is the global output tape contents upon halting.

    Instances For
      @[simp]

      At 0 steps, universalTM.etimeBoundedComplexity 0 x = ⊤.

      Polynomial-time and partial-recursive evaluation of universalTM #

      Mapping any computable decoder dec : List Bool → ℕ over universalTM yields a partial recursive description method.

      Partrec's universal description method universal is at most an additive constant worse than universalTM under any computable decoder dec : List Bool → ℕ.

      Clock-preserving simulation of every binary MultiTapeTM #

      Every finite-state binary MultiTapeTM is simulated by universalTM with constant program overhead and zero time overhead.

      Plain Kolmogorov complexity under universalTM is at most an additive constant worse than under any finite-state binary MultiTapeTM.

      Clock-preserving time-bounded optimality of universalTM over MultiTapeTM: for every finite-state binary MultiTapeTM, universalTM is at most an additive constant worse at the exact same step count t.

      Time-bounded complexity transfer from a single-tape Turing machine SingleTapeTM Bool to universalTM.

      universalTM simulates the literal description method with constant program overhead and one extra step (t + 1).

      Plain and time-bounded Kolmogorov complexity (plain, timeBoundedAt, timeBounded) #

      noncomputable def Cslib.Kolmogorov.plain (x : List Bool) :

      Plain Kolmogorov complexity $K(x)$ of a binary string $x$ under universalTM, in ℕ∞.

      Instances For
        noncomputable def Cslib.Kolmogorov.plainNat (x : List Bool) :

        Plain Kolmogorov complexity $K(x)$ of a binary string $x$ under universalTM, as a natural number. Since every string has a finite description (plain_ne_top), (plainNat x : ℕ∞) = plain x (natCast_plainNat).

        Instances For
          noncomputable def Cslib.Kolmogorov.timeBoundedAt (t : ℕ) (x : List Bool) :

          Step-indexed time-bounded Kolmogorov complexity $K^t(x)$ of a binary string $x$ at a concrete step budget $t : \mathbb{N}$ (Ko; Liu and Pass, Section 2.2): the length of a shortest binary program that outputs $x$ within $t$ steps of the described multi-tape machine under universalTM, in ℕ∞.

          Instances For
            noncomputable def Cslib.Kolmogorov.timeBounded (t : ℕ → ℕ) (x : List Bool) :

            Time-bounded Kolmogorov complexity $K^t(x)$ of a binary string $x$ with respect to the time bound $t : \mathbb{N} \to \mathbb{N}$ (Ko; Liu and Pass, Section 2.2): the length of a shortest binary program that outputs $x$ within $t(|x|)$ steps of the described multi-tape machine, in ℕ∞.

            Instances For
              noncomputable def Cslib.Kolmogorov.timeBoundedNat (t : ℕ → ℕ) (x : List Bool) :

              Time-bounded Kolmogorov complexity $K^t(x)$ as a natural number. Whenever a program outputs $x$ within $t(|x|)$ steps (timeBounded t x ≠ ⊤), (timeBoundedNat t x : ℕ∞) = timeBounded t x (natCast_timeBoundedNat).

              Instances For

                Equivalence bridges between ℕ∞ and finite (ℕ) formulations #

                @[simp]

                At 0 steps, timeBoundedAt 0 x = ⊤.

                timeBoundedAt t x ≤ k iff some program of length at most k outputs x within t steps.

                timeBoundedAt t x < k iff some program of length strictly less than k outputs x within t steps.

                timeBoundedAt t x = ⊤ iff no program outputs x within t steps.

                timeBoundedAt t x ≠ ⊤ iff some program outputs x within t steps.

                timeBounded t x ≤ k iff some program of length at most k outputs x within t |x| steps.

                timeBounded t x < k iff some program of length strictly less than k outputs x within t |x| steps.

                timeBounded t x = ⊤ iff no program outputs x within t |x| steps.

                timeBounded t x ≠ ⊤ iff some program outputs x within t |x| steps.

                Whenever timeBounded t x ≠ ⊤, the natural-number wrapper timeBoundedNat t x casts back to timeBounded t x.

                Whenever timeBounded t x ≠ ⊤, the ℕ-valued inequality timeBoundedNat t x ≤ k is equivalent to timeBounded t x ≤ k.

                Whenever timeBounded t x ≠ ⊤, timeBoundedNat t x is the exact length of a shortest program outputting x within t |x| steps.

                Whenever a witness program exists (timeBounded t x ≠ ⊤), timeBoundedNat t x equals the ℕ-infimum sInf {p.length | x ∈ (universalTM.run p).runFor (t x.length)}, matching the source definition $K^t(x) = \min\{|\Pi| : U(\Pi, 1^{t(|x|)}) = x\}$ in Liu and Pass, Section 2.2.

                Basic properties of K^t: monotonicity, upper bound, and relation to plain K #

                Antitonicity in the step bound. Giving more steps cannot increase timeBoundedAt t x.

                theorem Cslib.Kolmogorov.timeBoundedAt_anti {t₁ t₂ : ℕ} {x : List Bool} (h : t₁ ≤ t₂) :

                If t₁ ≤ t₂, then timeBoundedAt t₂ x ≤ timeBoundedAt t₁ x.

                Antitonicity in the time function. More time cannot increase K^t(x).

                theorem Cslib.Kolmogorov.timeBounded_anti_of_le {t₁ t₂ : ℕ → ℕ} {x : List Bool} (h : t₁ x.length ≤ t₂ x.length) :

                Monotonicity in the time bound at |x|. Giving more time at input length |x| cannot increase K^t(x).

                theorem Cslib.Kolmogorov.timeBounded_anti {t₁ t₂ : ℕ → ℕ} (h : t₁ ≤ t₂) (x : List Bool) :

                Monotonicity in the time function. If t₁ ≤ t₂ pointwise, then K^{t₂}(x) ≤ K^{t₁}(x).

                The fixed program overhead of the identity machine simulating literal in universalTM.

                Instances For

                  Under universalTM, every string x can be printed by a program of length at most |x| + copyOverhead within |x| + 1 steps.

                  Trivial upper bound (Liu and Pass, Fact 2.1 under multi-tape global output): if $t(|x|) \ge |x| + 1$, then $K^t(x) \le |x| + \mathrm{copyOverhead}$.

                  theorem Cslib.Kolmogorov.timeBounded_le {t : ℕ → ℕ} (ht : ∀ (n : ℕ), n + 1 ≤ t n) (x : List Bool) :

                  Trivial upper bound for all inputs (Liu and Pass, Fact 2.1): if $t(n) \ge n + 1$ for all $n$, then $K^t(x) \le |x| + \mathrm{copyOverhead}$ for all $x$.

                  theorem Cslib.Kolmogorov.exists_timeBounded_le :
                  ∃ (c : ℕ), ∀ {t : ℕ → ℕ}, (∀ (n : ℕ), n + 1 ≤ t n) → ∀ (x : List Bool), timeBounded t x ≤ ↑(x.length + c)

                  Existential form of the trivial upper bound $K^t(x) \le |x| + O(1)$ for $t(n) \ge n + 1$.

                  theorem Cslib.Kolmogorov.timeBounded_ne_top {t : ℕ → ℕ} {x : List Bool} (ht : x.length + 1 ≤ t x.length) :

                  If x.length + 1 ≤ t x.length, then timeBounded t x ≠ ⊤.

                  Natural-number upper bound timeBoundedNat t x ≤ x.length + copyOverhead when x.length + 1 ≤ t x.length.

                  Relation to plain complexity (K(x) ≤ K^t(x) at step budget t). Dropping the step bound cannot increase Kolmogorov complexity under universalTM.

                  Relation to plain complexity (K(x) ≤ K^t(x)). Dropping the time bound cannot increase Kolmogorov complexity under universalTM.

                  Trivial upper bound plain x ≤ x.length + copyOverhead for plain complexity.

                  Plain Kolmogorov complexity plain x is always finite.

                  @[simp]

                  Casting plainNat x to ℕ∞ yields plain x.

                  Plain complexity plain x is the infimum of timeBoundedAt t x over all step bounds t : ℕ.

                  Relation to Partrec.universal (K_U(dec x) ≤ K^t(x) + O(1)). For any computable decoder dec : List Bool → ℕ, the plain complexity of dec x under DescriptionMethod.universal (Partrec.lean) is at most timeBounded t x + c.

                  Using Nat.bits and List.foldr Nat.bit 0, universal.ecomplexity n ≤ timeBounded t n.bits + c for all t and n.

                  Counting and incompressibility facts for K^t #

                  Fewer than $2^r$ strings of length $n$ have $K^t(x) < r$.

                  theorem Cslib.Kolmogorov.exists_length_eq_forall_le_timeBounded (n : ℕ) :
                  ∃ (x : List Bool), x.length = n ∧ ∀ (t : ℕ → ℕ), ↑n ≤ timeBounded t x

                  Existence of $K^t$-incompressible strings. For every $n$ and every time bound $t$, some string $x \in \{0, 1\}^n$ has $K^t(x) \ge n$ (in fact, a single string works for all $t$ simultaneously).

                  For every time bound t and length n, there exists a string x of length n with n ≤ timeBounded t x.

                  Counting nearly $K^t$-incompressible strings. All but fewer than $2^{n - c}$ of the $2^n$ strings of length $n$ satisfy $K^t(x) \ge n - c$.

                  Levin's time-bounded Kolmogorov complexity (Kt) #

                  noncomputable def Cslib.Kolmogorov.levinKt (x : List Bool) :

                  Levin's time-bounded Kolmogorov complexity $\mathrm{Kt}(x)$ (Levin; Levin; Allender et al.; Liu and Pass, Section 2.2): $$\mathrm{Kt}(x) = \inf_{s \in \mathbb{N}} \bigl(K^s(x) + \lceil \log_2 s \rceil\bigr).$$ Because timeBoundedAt 0 x = ⊤ (timeBoundedAt_zero), the $s = 0$ term is $\top$ and the infimum over $s : \mathbb{N}$ coincides with the infimum over $s \ge 1$. Here $s$ counts steps of the described multi-tape machine (universalTM); relative to a fixed universal simulator with polynomial step overhead (Universal.universal), this changes the $\lceil \log_2 s \rceil$ term by a constant factor rather than an $O(1)$ additive term.

                  Instances For
                    noncomputable def Cslib.Kolmogorov.levinKtNat (x : List Bool) :

                    Levin's $\mathrm{Kt}(x)$ as a natural number.

                    Instances For
                      theorem Cslib.Kolmogorov.levinKt_eq_iInf_pos (x : List Bool) :
                      levinKt x = ⨅ (s : ℕ), ⨅ (_ : 0 < s), timeBoundedAt s x + ↑(Nat.clog 2 s)

                      Restricting the infimum in levinKt to positive step counts $s > 0$ gives the exact same value, since no program halts in $0$ steps (timeBoundedAt_zero).

                      For every step count s, levinKt x ≤ timeBoundedAt s x + Nat.clog 2 s.

                      For every time bound t : ℕ → ℕ, levinKt x ≤ timeBounded t x + Nat.clog 2 (t x.length).

                      Plain complexity bounds Levin's Kt from below (K(x) ≤ Kt(x)).

                      Trivial upper bound for Levin's Kt: $\mathrm{Kt}(x) \le |x| + \mathrm{copyOverhead} + \lceil \log_2(|x| + 1) \rceil$.

                      Levin's levinKt x is always finite.

                      @[simp]

                      Casting levinKtNat x to ℕ∞ yields levinKt x.

                      Threshold characterization of levinKt. $\mathrm{Kt}(x) \le k$ iff some program $p$ outputs $x$ within $s$ steps with $|p| + \lceil \log_2 s \rceil \le k$.

                      ℕ-valued threshold characterization of levinKtNat.