Documentation

CslibFrontier.Computability.Complexity.Classes.LogSpace.Randomized.ConfigurationMatrix

The configuration matrix of a fair-coin machine #

A fair-coin machine moves each running view (Turing.FiniteCfg, the configuration with its work tapes stored relative to their heads and its output summarized) to one of two views, selected by the coin (Turing.MultiTapePTM.viewCoinStep); a halted view stays put. On a finite set V of views closed under these steps, this gives two matrices indexed by V:

With e the indicator of the accepting halted views (Turing.FiniteCfg.acceptVec), the number of accepting coin strings of length t is the entry at the initial view of N ^ t *ᵥ e (Turing.MultiTapePTM.acceptCoins_eq_configMatrix_pow_mulVec), so the acceptance probability is ((N / 2) ^ t *ᵥ e)(start). Splitting the coin strings by the time they halt gives the substochastic form ∑ t ≤ T, ((S / 2) ^ t *ᵥ e)(start) (Turing.MultiTapePTM.acceptCoins_div_eq_sum_liveConfigMatrix). When every view of V is reachable and every branch halts within T steps, S / 2 is nilpotent, and the acceptance probability is ((1 - S / 2)⁻¹ *ᵥ e)(start) (Turing.MultiTapePTM.acceptCoins_div_eq_inv_mulVec).

The reachable views form such a set (Turing.MultiTapePTM.exists_finset_reachable), with at most 2 ^ (2 * coreLengthBound k State n s + 1) elements under a space bound s, polynomially many under a logarithmic one. So a BPL language is decided by the entry at the initial view of (1 - S / 2)⁻¹ *ᵥ e for a polynomial-size matrix S (Cslib.Complexity.exists_configMatrix_of_mem_BPL). This is the Markov chain of a probabilistic machine on its configurations Gill. Borodin, Cook and Pippenger compute its powers and inverse in parallel Borodin, Cook and Pippenger, which gives BPSPACE(S) ⊆ DSPACE(S²) Hoza, Section 4.3; the inverse of 1 - W as the sum W⁰ + W¹ + … of transition-matrix powers is the picture of Hoza, Section 3.2. Exact evaluation of the polynomial-size matrix also gives BPL ⊆ P. The parallel algorithms are not formalized; a sequential exact evaluation, which gives Cslib.Complexity.BPL_subset_P, is in CslibFrontier.Computability.Complexity.Classes.LogSpace.Randomized.PolyTime.

The matrices are indexed by an arbitrary closed set of views rather than a set of configurations of bounded size, and have no time layers: the model of Cslib.Complexity.BPL requires every branch to halt, which already makes the live matrix nilpotent on the reachable views. The form N ^ t with absorbing halted views is the one repeated squaring computes; the form (1 - S / 2)⁻¹ with a nilpotent substochastic matrix is the one of matrix inversion.

Main definitions #

Main results #

References #

noncomputable def Turing.FiniteCfg.acceptVec {k : ℕ} {State : Type} (R : Type u_1) [Zero R] [One R] (V : Finset (FiniteCfg k Bool State)) :
↥V → R

The indicator of the accepting halted views in a set V of views: 1 at the halted views with output [true], 0 elsewhere.

noncomputable def Turing.MultiTapePTM.viewCoinStep {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (finite : FiniteCfg k Bool State) (bit : Bool) :
FiniteCfg k Bool State

The view reached under one coin: a halted view stays put; a running view takes the action selected by the coin, and its output is summarized.

noncomputable def Turing.MultiTapePTM.configMatrix {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (R : Type u_1) [CommSemiring R] (V : Finset (FiniteCfg k Bool State)) :
Matrix (↥V) (↥V) R

The configuration matrix on a set V of views: the entry at (x, y) counts the coins that move x to y. Half of it is the stochastic matrix of the run, with halted views absorbing.

noncomputable def Turing.MultiTapePTM.liveConfigMatrix {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (R : Type u_1) [CommSemiring R] (V : Finset (FiniteCfg k Bool State)) :
Matrix (↥V) (↥V) R

The live configuration matrix: the rows of Turing.MultiTapePTM.configMatrix at running views, and zero rows at halted views. Half of it is substochastic.

theorem Turing.MultiTapePTM.viewCoinStep_of_halted {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} {finite : FiniteCfg k Bool State} (h : finite.state = none) (bit : Bool) :
machine.viewCoinStep finite bit = finite

A halted view stays put.

theorem Turing.MultiTapePTM.viewRep_viewCoinStep {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} {input : List Bool} {finite : FiniteCfg k Bool State} {cfg : Cfg k Bool State input} (h : MultiTapeNTM.ViewRep finite cfg) (bit : Bool) :

Coin steps of views follow coin steps of configurations.

theorem Turing.MultiTapePTM.viewRep_foldl_viewCoinStep {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} {input : List Bool} {finite : FiniteCfg k Bool State} {cfg : Cfg k Bool State input} (h : MultiTapeNTM.ViewRep finite cfg) (coins : List Bool) :
MultiTapeNTM.ViewRep (List.foldl machine.viewCoinStep finite coins) (machine.stepCoins coins cfg)

Coin strings replay on views as on configurations.

theorem Turing.MultiTapePTM.viewStep_toNTM_iff {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} {finite next : FiniteCfg k Bool State} :
machine.toNTM.ViewStep finite next ↔ ∃ (bit : Bool), machine.viewCoinStep finite bit = next

The steps of the views of the nondeterministic view are the coin steps.

theorem Turing.MultiTapePTM.reflTransGen_viewStep_toNTM_iff {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} {finite next : FiniteCfg k Bool State} :
Relation.ReflTransGen machine.toNTM.ViewStep finite next ↔ ∃ (coins : List Bool), List.foldl machine.viewCoinStep finite coins = next

The reachable views are those reached by coin strings.

theorem Turing.MultiTapePTM.stepCoins_accepts_iff_foldl_viewCoinStep {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} (input coins : List Bool) :
(machine.stepCoins coins (machine.toNTM.initCfg input)).Halted ∧ (machine.stepCoins coins (machine.toNTM.initCfg input)).output = [true] ↔ (List.foldl machine.viewCoinStep (machine.toNTM.initView input) coins).state = none ∧ (List.foldl machine.viewCoinStep (machine.toNTM.initView input) coins).output = [true]

A coin string is accepted exactly when its replay on views is: the replay of coins from the initial configuration on input ends halted with output [true] exactly when the replay of coins on views from the initial view ends in an accepting halted view.

theorem Turing.MultiTapePTM.acceptCoins_eq_configMatrix_pow_mulVec {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} (R : Type u_1) [CommSemiring R] {input : List Bool} {V : Finset (FiniteCfg k Bool State)} (hV : ∀ finite ∈ V, ∀ (bit : Bool), machine.viewCoinStep finite bit ∈ V) (hinit : machine.toNTM.initView input ∈ V) (t : ℕ) :
↑(machine.acceptCoins input t) = (machine.configMatrix R V ^ t).mulVec (FiniteCfg.acceptVec R V) ⟨machine.toNTM.initView input, hinit⟩

Accepting coin strings are an entry of a power of the configuration matrix: on a set V of views that contains the initial view and is closed under coin steps, the number of accepting coin strings of length t is the entry at the initial view of N ^ t *ᵥ e.

theorem Turing.MultiTapePTM.acceptCoins_div_eq_configMatrix_pow_mulVec {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} (R : Type u_1) [Field R] {input : List Bool} {V : Finset (FiniteCfg k Bool State)} (hV : ∀ finite ∈ V, ∀ (bit : Bool), machine.viewCoinStep finite bit ∈ V) (hinit : machine.toNTM.initView input ∈ V) (t : ℕ) :
↑(machine.acceptCoins input t) / 2 ^ t = ((2⁻¹ • machine.configMatrix R V) ^ t).mulVec (FiniteCfg.acceptVec R V) ⟨machine.toNTM.initView input, hinit⟩

The acceptance probability is an entry of a power of the stochastic matrix: with P = N / 2 the stochastic matrix of the run, acceptCoins input t / 2 ^ t is the entry at the initial view of P ^ t *ᵥ e.

theorem Turing.MultiTapePTM.acceptCoins_div_eq_sum_liveConfigMatrix {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} (R : Type u_1) [Field R] [CharZero R] {input : List Bool} {V : Finset (FiniteCfg k Bool State)} (hV : ∀ finite ∈ V, ∀ (bit : Bool), machine.viewCoinStep finite bit ∈ V) (hinit : machine.toNTM.initView input ∈ V) (T : ℕ) :
↑(machine.acceptCoins input T) / 2 ^ T = ∑ t ∈ Finset.range (T + 1), ((2⁻¹ • machine.liveConfigMatrix R V) ^ t).mulVec (FiniteCfg.acceptVec R V) ⟨machine.toNTM.initView input, hinit⟩

The substochastic form: splitting the coin strings by the time the run halts, acceptCoins input T / 2 ^ T is the entry at the initial view of ∑ t ≤ T, (S / 2) ^ t *ᵥ e, with S the live configuration matrix. No halting time is needed.

theorem Turing.MultiTapePTM.liveConfigMatrix_pow_eq_zero {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} (R : Type u_1) [CommSemiring R] {input : List Bool} {T : ℕ} (ht : machine.toNTM.RunsInTime input T) {V : Finset (FiniteCfg k Bool State)} (hV : ∀ finite ∈ V, ∀ (bit : Bool), machine.viewCoinStep finite bit ∈ V) (hreach : ∀ finite ∈ V, Relation.ReflTransGen machine.toNTM.ViewStep (machine.toNTM.initView input) finite) :
machine.liveConfigMatrix R V ^ (T + 1) = 0

The live matrix is nilpotent on reachable views: if every view of V is reachable and every branch halts within T steps, then S ^ (T + 1) = 0.

theorem Turing.MultiTapePTM.acceptCoins_div_eq_inv_mulVec {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} (R : Type u_1) [Field R] [CharZero R] {input : List Bool} {T : ℕ} (ht : machine.toNTM.RunsInTime input T) {V : Finset (FiniteCfg k Bool State)} (hV : ∀ finite ∈ V, ∀ (bit : Bool), machine.viewCoinStep finite bit ∈ V) (hreach : ∀ finite ∈ V, Relation.ReflTransGen machine.toNTM.ViewStep (machine.toNTM.initView input) finite) (hinit : machine.toNTM.initView input ∈ V) :
↑(machine.acceptCoins input T) / 2 ^ T = (1 - 2⁻¹ • machine.liveConfigMatrix R V)⁻¹.mulVec (FiniteCfg.acceptVec R V) ⟨machine.toNTM.initView input, hinit⟩

The acceptance probability is an entry of (1 - S / 2)⁻¹ *ᵥ e: if every view of V is reachable and every branch halts within T steps, then acceptCoins input T / 2 ^ T is the entry at the initial view of (1 - S / 2)⁻¹ *ᵥ e, with S the live configuration matrix.

theorem Turing.MultiTapePTM.exists_finset_reachable {k : ℕ} {State : Type} {machine : MultiTapePTM k Bool State} [Finite State] {input : List Bool} {s : ℕ} (hs : machine.toNTM.RunsInSpace input s) :
∃ (V : Finset (FiniteCfg k Bool State)), (∀ (finite : FiniteCfg k Bool State), finite ∈ V ↔ Relation.ReflTransGen machine.toNTM.ViewStep (machine.toNTM.initView input) finite) ∧ (∀ finite ∈ V, ∀ (bit : Bool), machine.viewCoinStep finite bit ∈ V) ∧ V.card ≤ 2 ^ (2 * MultiTapeNTM.coreLengthBound k State input.length s + 1)

The reachable views form a small closed set: under a space bound s, the views reachable from the initial view form a finite set, closed under coin steps, with at most 2 ^ (2 * coreLengthBound k State n s + 1) elements.

theorem Cslib.Complexity.exists_configMatrix_of_mem_BPL {α : Type} {enc : α ↪ List Bool} {A : Set α} (h : A ∈ BPL enc) :
∃ (k : ℕ) (State : Type) (_ : Finite State) (M : Turing.MultiTapePTM k Bool State) (d : ℕ), ∀ (a : α), ∃ (V : Finset (Turing.FiniteCfg k Bool State)) (hinit : M.toNTM.initView (enc a) ∈ V), V.card ≤ Turing.polyClock d (enc a).length ∧ (∀ finite ∈ V, ∀ (bit : Bool), M.viewCoinStep finite bit ∈ V) ∧ (∀ finite ∈ V, Relation.ReflTransGen M.toNTM.ViewStep (M.toNTM.initView (enc a)) finite) ∧ M.toNTM.RunsInTime (enc a) (Turing.polyClock d (enc a).length) ∧ M.liveConfigMatrix ℚ V ^ (Turing.polyClock d (enc a).length + 1) = 0 ∧ (a ∈ A → 2 / 3 ≤ (1 - 2⁻¹ • M.liveConfigMatrix ℚ V)⁻¹.mulVec (Turing.FiniteCfg.acceptVec ℚ V) ⟨M.toNTM.initView (enc a), hinit⟩) ∧ (a ∉ A → (1 - 2⁻¹ • M.liveConfigMatrix ℚ V)⁻¹.mulVec (Turing.FiniteCfg.acceptVec ℚ V) ⟨M.toNTM.initView (enc a), hinit⟩ ≤ 1 / 3)

BPL through polynomial-size configuration matrices: a BPL machine has, on every encoded instance of length n, a set V of at most T = polyClock d n views, all reachable from the initial view and closed under coin steps, such that every branch halts within T steps, the live configuration matrix S on V satisfies S ^ (T + 1) = 0, and the entry at the initial view of (1 - S / 2)⁻¹ *ᵥ e is at least 2/3 on members and at most 1/3 on non-members, with e the indicator of the accepting halted views.