Liu–Pass: universal machine, PPT algorithms and
DefinitionLiuPass_modelThis file fixes the computational model of Liu–Pass, On One-way Functions and Kolmogorov Complexity (Section 2).
Strings are finite lists of bits; denotes the all-ones string of length , and a bit string is read as a natural number most-significant-bit first when an algorithm's output is interpreted numerically. A function is polynomial if for some constants , and is negligible if for every it is eventually at most . Probabilities over uniform strings are defined by counting: for a predicate ,
and similarly for two independent uniform strings.
The paper fixes once and for all a universal Turing machine that emulates any machine with polynomial overhead, writes for the output of the description emulated for steps, and measures all running times on . That standing convention is recorded here as a structure: a partial, step-indexed evaluation that is monotone in (once the machine halts with an output, running longer does not change it), a pairing of a description with an input whose length overhead is a constant, a constant-size program that immediately returns its input, a self-simulation program with polynomial time overhead, a padding program that copies a prefix of its input and applies a subprogram to the remaining suffix, and universality: every function computable within a polynomial time bound has a program on running in polynomial time.
Relative to such a machine, a string function is computable in time if some description computes it on every input within steps, and polynomial-time computable if may be taken polynomial; a probabilistic polynomial-time algorithm is a two-argument polynomial-time function of a random tape and an input , together with a polynomial bound on the number of coins tossed at each security parameter. A generator is rate-1 efficient if its running time on inputs of length is at most for a constant .
Finally, the -time-bounded Kolmogorov complexity is
the length of the shortest description that outputs within steps.
Formalization Note The universal machine is a parameter, not a construction: every statement of the mission is quantified over all machines satisfying the interface above. The minimum defining is an infimum over natural numbers, so it evaluates to when no description outputs within the time bound; Fact 2.1 is what excludes that case.
import Mathlib
/-!
# Liu–Pass, *On One-way Functions and Kolmogorov Complexity* — the computational model
This file fixes the computational model underlying the paper
(Y. Liu, R. Pass, arXiv:2009.11514v1, Section 2).
The paper fixes once and for all a universal Turing machine `U` "that can emulate any Turing
machine `M` with polynomial overhead", writes `U (Π, 1^t)` for the output of the description `Π`
emulated on `U` for `t` steps, and measures every algorithm's running time in `U`-steps. Here
that standing convention is recorded as the structure `LiuPass.UMachine`: a step-bounded
evaluation function together with the properties of a universal machine that the paper uses.
Every statement of the mission is universally quantified over such a machine.
Main definitions:
* `LiuPass.UMachine` — a universal machine with time-bounded semantics;
* `LiuPass.ComputesInTime`, `LiuPass.PolyTimeComputable`, `LiuPass.PPT` — deterministic and
probabilistic polynomial-time algorithms relative to `U`;
* `LiuPass.Kt` — the `t`-time-bounded Kolmogorov complexity `K^t` (Section 2.2);
* `LiuPass.Rate1Efficient` — running time `n + O(n^ε)` with `ε < 1` (Definition 5.1).
-/
namespace LiuPass
open Finset
open scoped Classical
/-- A finite binary string. -/
abbrev BitStr := List Bool
/-- The all-ones string `1^n`, used as the unary encoding of `n`. -/
def unary (n : ℕ) : BitStr := List.replicate n true
/-- The natural number a bit string denotes, most significant bit first. Used to read the
numerical output of a heuristic. -/
def bitsToNat (x : BitStr) : ℕ := x.foldl (fun a b => 2 * a + (if b then 1 else 0)) 0
/-- `p` is bounded by a polynomial. -/
def IsPoly (p : ℕ → ℕ) : Prop := ∃ k c : ℕ, ∀ n, p n ≤ c * n ^ k + c
/-- `μ` is negligible: it is eventually below `1 / n ^ k` for every `k`. -/
def Negligible (mu : ℕ → ℝ) : Prop := ∀ k : ℕ, ∃ n₀ : ℕ, ∀ n ≥ n₀, mu n ≤ 1 / (n : ℝ) ^ k
/-- `Pr[x ← {0,1}^n : P x]`. -/
noncomputable def prUnif (n : ℕ) (P : BitStr → Prop) : ℝ :=
((univ.filter fun v : Fin n → Bool => P (List.ofFn v)).card : ℝ) / 2 ^ n
/-- `Pr[x ← {0,1}^n, r ← {0,1}^m : P x r]`, for two independent uniform strings. -/
noncomputable def prUnif₂ (n m : ℕ) (P : BitStr → BitStr → Prop) : ℝ :=
((univ.filter fun v : (Fin n → Bool) × (Fin m → Bool) =>
P (List.ofFn v.1) (List.ofFn v.2)).card : ℝ) / 2 ^ (n + m)
/-- `F` is computed within the time bound `T` in Mathlib's fuel-bounded model of partial
recursive functions. This is used only to express the universality of `U`: every function that
some machine computes in polynomial time also has a `U`-program running in polynomial time. -/
def CodeComputableInTime (F : BitStr → BitStr) (T : ℕ → ℕ) : Prop :=
∃ c : Nat.Partrec.Code, ∀ w : BitStr,
Nat.Partrec.Code.evaln (T w.length) c (Encodable.encode w) = some (Encodable.encode (F w))
/-- The fixed universal machine of Liu–Pass, Section 2.2.
`run Π t = some x` means that the description `Π`, emulated on the machine for `t` steps, halts
and outputs `x`; `run Π t = none` means it has not halted within `t` steps. The remaining fields
record the properties of a universal machine with polynomial overhead that the paper relies on:
a description can be paired with an input at constant additive cost in length, there is a
constant-size program that just copies its input (this is what makes `K^t (x) ≤ |x| + c`), the
machine simulates its own time-bounded evaluation with polynomial overhead, it can copy an
untouched prefix of its input and run a subprogram on the remaining suffix (the padding trick),
and it has a polynomial-time program for every polynomial-time computable function. -/
structure UMachine where
/-- `run Π t` is the output of the description `Π` emulated for `t` steps, if it halts. -/
run : BitStr → ℕ → Option BitStr
/-- Once the machine has halted with an output, running it longer changes nothing. -/
run_mono : ∀ (Pi : BitStr) (t t' : ℕ) (x : BitStr), t ≤ t' → run Pi t = some x →
run Pi t' = some x
/-- Pairing a program with an input. -/
pair : BitStr → BitStr → BitStr
/-- The constant length overhead of pairing. -/
pairOverhead : ℕ
pair_length_le : ∀ Pi w : BitStr, (pair Pi w).length ≤ Pi.length + w.length + pairOverhead
/-- A program that halts immediately, returning its input. -/
idProg : BitStr
run_idProg : ∀ (w : BitStr) (t : ℕ), 1 ≤ t → run (pair idProg w) t = some w
/-- A program simulating the machine's own time-bounded evaluation. -/
sim : BitStr
/-- The polynomial overhead of that simulation. -/
simTime : ℕ → ℕ
simTime_poly : IsPoly simTime
run_sim : ∀ (Pi : BitStr) (t : ℕ),
run (pair sim (pair Pi (unary t))) (simTime (Pi.length + t)) = some ((run Pi t).getD [])
/-- Given a program `Π` and a length `k`, a program that copies the first `k` bits of its input
and runs `Π` on the rest. -/
padProg : BitStr → ℕ → BitStr
/-- The constant time overhead of the padding construction. -/
padOverhead : ℕ
run_padProg : ∀ (Pi : BitStr) (k t : ℕ) (w y : BitStr),
run (pair Pi (w.drop k)) t = some y →
run (pair (padProg Pi k) w) (w.length + t + padOverhead) = some (w.take k ++ y)
/-- Universality with polynomial overhead. -/
univ_prog : ∀ (F : BitStr → BitStr) (T : ℕ → ℕ), IsPoly T → CodeComputableInTime F T →
∃ T' : ℕ → ℕ, IsPoly T' ∧ ∃ Pi : BitStr, ∀ w : BitStr,
run (pair Pi w) (T' w.length) = some (F w)
/-- `U` computes the string function `F` within the time bound `T`, as a function of the input
length. -/
def ComputesInTime (U : UMachine) (T : ℕ → ℕ) (F : BitStr → BitStr) : Prop :=
∃ Pi : BitStr, ∀ w : BitStr, U.run (U.pair Pi w) (T w.length) = some (F w)
/-- `F` is computable in polynomial time on `U`. -/
def PolyTimeComputable (U : UMachine) (F : BitStr → BitStr) : Prop :=
∃ T : ℕ → ℕ, IsPoly T ∧ ComputesInTime U T F
/-- A two-argument string function is computable in polynomial time on `U`. -/
def PolyTimeComputable₂ (U : UMachine) (F : BitStr → BitStr → BitStr) : Prop :=
∃ T : ℕ → ℕ, IsPoly T ∧ ∃ Pi : BitStr, ∀ r w : BitStr,
U.run (U.pair Pi (U.pair r w)) (T (r.length + w.length)) = some (F r w)
/-- A probabilistic polynomial-time algorithm: `out r x` is the output on input `x` when the
random tape is `r`, and on a security parameter `n` the algorithm tosses `tape n` coins. -/
structure PPT (U : UMachine) where
/-- The number of random bits used on security parameter `n`. -/
tape : ℕ → ℕ
/-- `out r x` is the output on input `x` with random tape `r`. -/
out : BitStr → BitStr → BitStr
tape_poly : IsPoly tape
out_poly : PolyTimeComputable₂ U out
/-- Rate-1 efficiency (Definition 5.1): the running time on inputs of length `n` is
`n + O(n^ε)` for some constant `ε < 1`. -/
def Rate1Efficient (U : UMachine) (G : BitStr → BitStr) : Prop :=
∃ (eps : ℝ) (c : ℕ), 0 ≤ eps ∧ eps < 1 ∧
ComputesInTime U (fun n => n + c * ⌈(n : ℝ) ^ eps⌉₊ + c) G
/-- The `t`-time-bounded Kolmogorov complexity `K^t (x)` (Section 2.2): the length of the
shortest description that outputs `x` on `U` within `t (|x|)` steps. -/
noncomputable def Kt (U : UMachine) (t : ℕ → ℕ) (x : BitStr) : ℕ :=
sInf {l : ℕ | ∃ Pi : BitStr, Pi.length = l ∧ U.run Pi (t x.length) = some x}
end LiuPass
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic) — same agent as the statement author, not independent
Non-blind read-back — not independent testimony. This read-back was written by the same agent that drafted the Lean statements in this proposal, at the explicit instruction of the proposal owner; no independent blind auditor was involved. Its author knew what the code was intended to say, so it cannot serve the usual purpose of an independent read-back and no reviewer should treat it as such. It is offered only as a careful, literal rendering of the code, and should be re-done blind by an independent auditor before the proposal is relied upon for audit.
The file declares the following, over the type of finite bit strings (finite lists of booleans).
- is the string consisting of copies of the bit .
- The numeric value of a string is computed by folding left with , i.e. the string is read as a binary numeral with the first bit most significant; the empty string has value .
- is called polynomial when there exist with for all (a bound, not an exact polynomial form).
- is called negligible when for every there is with for all . For this reads ; if and the instance at reads , since division by zero evaluates to .
- For a predicate on strings, is defined as the number of vectors of length with , divided by ; and for a two-argument predicate, the analogous count over pairs of independent vectors of lengths and , divided by . Predicates need not be decidable; classical logic is used to form the counts.
- A string function is computable within time in the reference fuel model when some partial-recursive code, run with fuel , outputs the encoding of on the encoding of every input .
The central declaration is a structure bundling: a function returning either a string or nothing; monotonicity — if and then ; a pairing of strings with a constant and the bound ; a string with for every and every ; a string and a polynomially bounded with
a family and a constant such that whenever equals (with the input with its first bits removed), equals the first bits of followed by ; and a universality clause: for every string function and polynomially bounded computable within time in the reference fuel model, there are a polynomially bounded and a program with for every .
Relative to such a structure: is computed in time when a single program satisfies for every ; polynomial-time computable when such a may be chosen polynomially bounded; a two-argument function is polynomial-time computable when a single program satisfies for all with polynomially bounded. A probabilistic polynomial-time algorithm is a record consisting of a coin-count function , a two-argument output function , a proof that is polynomially bounded, and a proof that is polynomial-time computable in the above sense. Rate-1 efficiency of means: there are a real with and a natural such that is computed in time .
Finally, is defined as the infimum, over natural numbers , of the set of for which some of length satisfies . Being an infimum of a set of naturals, it equals when that set is empty. No instance of the structure is constructed anywhere in the file.