Documentation

Complexity.Computability.Kolmogorov.Basic

Kolmogorov complexity relative to a description method #

A description method runs binary programs: M.run p is the computation of the program p, a Mathlib Computation, which may or may not terminate with an object. The computation comes with a clock: (M.run p).runFor t is the output of p after t steps, or none if p has not halted by then. A computation has at most one result, so every program describes at most one object. The plain Kolmogorov complexity M.ecomplexity x of an object x is the length of a shortest program that eventually outputs x, and its time-bounded Kolmogorov complexity M.etimeBoundedComplexity t x is the length of a shortest program that outputs x within t steps Li and Vitányi, Chapters 2 and 7. Both take values in ℕ∞, and are ⊤ when no program describes x; as for cslib's circuit complexity Cslib.Circuits.ecomplexity, the prefix e stands for "extended".

Nothing here depends on a machine model. A multi-tape Turing machine gives a description method (Cslib.Kolmogorov.DescriptionMethod.ofMultiTapeTM), and so does any other model with a clocked semantics. The usual machine-independent complexity is the complexity of a method that simulates every other one with constant program overhead (Cslib.Kolmogorov.DescriptionMethod.Simulation); for the partial recursive description methods, Cslib.Kolmogorov.DescriptionMethod.universal is such a method.

Main definitions #

Main results #

References #

structure Cslib.Kolmogorov.DescriptionMethod (α : Type u_1) :
Type u_1

A description method for objects of type α: run p is the computation of the binary program p, which may or may not terminate with an object. Its clock is that of the computation: (run p).runFor t is the output of p after t steps, if p has halted by then. This is the clocked analogue of a partial function from programs to objects Li and Vitányi, Chapter 2.

Instances For

    The program p eventually outputs x.

    Instances For
      noncomputable def Cslib.Kolmogorov.DescriptionMethod.ecomplexity {α : Type u_1} (M : DescriptionMethod α) (x : α) :

      The plain Kolmogorov complexity C_M(x) of x: the length of a shortest program that outputs x, or ⊤ if there is none Sipser, Section 6.4.

      Instances For
        noncomputable def Cslib.Kolmogorov.DescriptionMethod.etimeBoundedComplexity {α : Type u_1} (M : DescriptionMethod α) (t : ℕ) (x : α) :

        The time-bounded Kolmogorov complexity C_M^t(x) of x: the length of a shortest program that outputs x within t steps, or ⊤ if there is none Li and Vitányi, Chapter 7.

        Instances For
          noncomputable def Cslib.Kolmogorov.DescriptionMethod.complexity {α : Type u_1} (M : DescriptionMethod α) (x : α) :

          The plain complexity C_M(x) as a natural number. It is 0 for an object without a description, so it is the plain complexity only when M.ecomplexity x ≠ ⊤ (natCast_complexity).

          Instances For

            Programs and their outputs #

            theorem Cslib.Kolmogorov.DescriptionMethod.Produces.of_mem_runFor {α : Type u_1} {M : DescriptionMethod α} {p : List Bool} {t : ℕ} {x : α} (h : x ∈ (M.run p).runFor t) :
            M.Produces p x
            theorem Cslib.Kolmogorov.DescriptionMethod.eq_of_mem_runFor {α : Type u_1} {M : DescriptionMethod α} {p : List Bool} {x y : α} {t₁ t₂ : ℕ} (hx : x ∈ (M.run p).runFor t₁) (hy : y ∈ (M.run p).runFor t₂) :
            x = y

            Two outputs of the same program, at any two times, are equal.

            theorem Cslib.Kolmogorov.DescriptionMethod.Produces.unique {α : Type u_1} {M : DescriptionMethod α} {p : List Bool} {x y : α} (hx : M.Produces p x) (hy : M.Produces p y) :
            x = y

            A program describes at most one object.

            Plain complexity #

            theorem Cslib.Kolmogorov.DescriptionMethod.ecomplexity_lt_iff {α : Type u_1} {M : DescriptionMethod α} {x : α} {r : ℕ∞} :
            M.ecomplexity x < r ↔ ∃ (p : List Bool), ↑p.length < r ∧ M.Produces p x

            The complexity is below r exactly when a program shorter than r describes the object.

            theorem Cslib.Kolmogorov.DescriptionMethod.ecomplexity_lt_natCast_iff {α : Type u_1} {M : DescriptionMethod α} {x : α} {k : ℕ} :
            M.ecomplexity x < ↑k ↔ ∃ (p : List Bool), p.length < k ∧ M.Produces p x

            The complexity is below k exactly when a program of length below k describes the object.

            Threshold characterization. The complexity is at most k exactly when a program of length at most k describes the object.

            A finite complexity is the length of a describing program.

            Time-bounded complexity #

            Threshold characterization. The time-bounded complexity C_M^t(x) is at most k exactly when a program of length at most k outputs x within t steps.

            A finite time-bounded complexity is the length of a program outputting the object in time.

            Monotonicity in the time bound. More time cannot increase the time-bounded complexity.

            Dropping the time bound cannot increase the complexity.

            A large enough time bound attains the plain complexity.

            The plain complexity is the limit of the time-bounded complexities.

            The literal description method #

            The description method for binary strings in which every program prints itself, taking one step per bit.

            Instances For

              A literal program halts after exactly one step per bit.

              @[simp]

              Every string is its own shortest literal description.

              Mapping outputs #

              def Cslib.Kolmogorov.DescriptionMethod.map {α : Type u_1} {β : Type u_2} (f : α → β) (M : DescriptionMethod α) :

              Mapping a function over the outputs of a description method, taking no steps of its own.

              Instances For
                @[simp]
                theorem Cslib.Kolmogorov.DescriptionMethod.runFor_map {α : Type u_1} {β : Type u_2} (f : α → β) (M : DescriptionMethod α) (p : List Bool) (t : ℕ) :
                ((map f M).run p).runFor t = Option.map f ((M.run p).runFor t)
                theorem Cslib.Kolmogorov.DescriptionMethod.mem_map_runFor_iff {α : Type u_1} {β : Type u_2} {f : α → β} {M : DescriptionMethod α} {p : List Bool} {t : ℕ} {y : β} :
                y ∈ ((map f M).run p).runFor t ↔ ∃ x ∈ (M.run p).runFor t, f x = y
                @[simp]
                theorem Cslib.Kolmogorov.DescriptionMethod.map_produces_iff {α : Type u_1} {β : Type u_2} {f : α → β} {M : DescriptionMethod α} {p : List Bool} {y : β} :
                (map f M).Produces p y ↔ ∃ (x : α), M.Produces p x ∧ f x = y
                theorem Cslib.Kolmogorov.DescriptionMethod.ecomplexity_map_le {α : Type u_1} {β : Type u_2} (f : α → β) (M : DescriptionMethod α) (x : α) :
                (map f M).ecomplexity (f x) ≤ M.ecomplexity x

                Mapping f over the outputs does not increase complexity: f x has complexity under M.map f at most that of x under M.

                theorem Cslib.Kolmogorov.DescriptionMethod.etimeBoundedComplexity_map_le {α : Type u_1} {β : Type u_2} (f : α → β) (M : DescriptionMethod α) (t : ℕ) (x : α) :
                theorem Cslib.Kolmogorov.DescriptionMethod.ecomplexity_map_eq_of_injective {α : Type u_1} {β : Type u_2} {f : α → β} (hf : Function.Injective f) (M : DescriptionMethod α) (x : α) :
                (map f M).ecomplexity (f x) = M.ecomplexity x

                Mapping an injective f over the outputs preserves complexity: f x has the same complexity under M.map f as x under M.