Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Probabilistic.ExplicitBlockNetwork.Graph

The graph of an explicit block-counting network, on numbers #

The explicit block-counting network of a schedule (Turing.MultiTapePTM.explicitBlockNetwork) is defined through structured types: schedules, edges Turing.MultiTapePTM.BlockEdge, and the next appearance of a block in windows (Turing.MultiTapePTM.firstAfter). This module computes its graph, the ports of every vertex, by arithmetic on natural numbers, the form in which a polynomial-time construction produces it.

Main definitions #

Main results #

Numbering the schedules #

The signs numbered -1 ↦ 0, 0 ↦ 1, 1 ↦ 2.

theorem Turing.MultiTapePTM.coe_signEquiv_symm (δ : Fin 3) :
↑(signEquiv.symm δ) = (if ↑δ = 2 then 1 else 0) - if ↑δ = 0 then 1 else 0

The sign numbered δ is δ - 1: one for the digit 2, minus one for the digit 0.

The digit position of the entry of interval i and head head in a schedule number: head + (k + 1) i, numbering the input head 0 and work head h as h + 1.

theorem Turing.MultiTapePTM.val_scheduleIndexEquiv {k q : ℕ} (i : Fin q) (head : Option (Fin k)) :
↑((scheduleIndexEquiv k q) (i, head)) = ↑((finSuccEquiv k).symm head) + (k + 1) * ↑i
def Turing.MultiTapePTM.scheduleEquiv (k q : ℕ) :
Schedule k q ≃ Fin (3 ^ ((k + 1) * q))

The schedules numbered by their (k + 1) q entries as digits in base 3: the entry of interval i and head head is the digit at position head + (k + 1) i (Turing.MultiTapePTM.scheduleIndexEquiv), numbered by Turing.MultiTapePTM.signEquiv.

The schedule of a number: its entry for interval i and head head is named by the digit of σ in base 3 at position head + (k + 1) i. Every natural number names a schedule; below 3 ^ ((k + 1) q) this is the numbering Turing.MultiTapePTM.scheduleEquiv.

theorem Turing.MultiTapePTM.scheduleOfNat_eq_symm {k q σ : ℕ} (hσ : σ < 3 ^ ((k + 1) * q)) :

Below 3 ^ ((k + 1) q), the schedule of a number is the numbered one.

theorem Turing.MultiTapePTM.sum_range_scheduleOfNat {k q : ℕ} {M : Type u_1} [AddCommMonoid M] (f : Schedule k q → M) :
∑ σ ∈ Finset.range (3 ^ ((k + 1) * q)), f (scheduleOfNat k q σ) = ∑ σ : Schedule k q, f σ

Summing over schedule numbers is summing over the schedules.

Block indices, windows and next appearances on numbers #

The number of intervals i' < i in which the digit of σ at position c + (k + 1) i' is δ. For c the number of a head, these are the intervals of scheduleOfNat k q σ moving that head by δ - 1 blocks.

theorem Turing.MultiTapePTM.scheduleBlock_scheduleOfNat {k q : ℕ} (σ : ℕ) {i : ℕ} (hi : i ≤ q) (head : Option (Fin k)) :
scheduleBlock (scheduleOfNat k q σ) i head = ↑(digitCount k σ (↑((finSuccEquiv k).symm head)) 2 i) - ↑(digitCount k σ (↑((finSuccEquiv k).symm head)) 0 i)

Block indices are digit counts: at the start of interval i ≤ q, a head is in block #{2} - #{0}, counting its digits 2 and 0 in the earlier intervals.

def Turing.MultiTapePTM.inWindowNum (k σ c i δ i' : ℕ) :

Whether the block j = b(i) + δ - 1 of interval i's window lies in the window of interval i', from the digit counts P (digits 2) and N (digits 0) of the head at i and i': |b(i') - j| ≤ 1 for b = P - N, compared in natural numbers.

theorem Turing.MultiTapePTM.inWindowNum_iff {k q : ℕ} (σ : ℕ) (i i' : Fin q) (h : Fin k) (δ : Fin 3) :
inWindowNum k σ (↑h + 1) ↑i ↑δ ↑i' = true ↔ InWindow (scheduleOfNat k q σ) h (portBlock (scheduleOfNat k q σ) i h δ) i'

Windows on numbers.

The next interval after i whose window contains the block δ of interval i's window, for the head with digit offset c, found by searching the intervals in order.

theorem Turing.MultiTapePTM.firstAfterNum_eq {k q : ℕ} (σ : ℕ) (i : Fin q) (h : Fin k) (δ : Fin 3) :
firstAfterNum k q σ (↑h + 1) ↑i ↑δ = Option.map Fin.val (firstAfter (InWindow (scheduleOfNat k q σ) h (portBlock (scheduleOfNat k q σ) i h δ)) i)

Next appearances on numbers.

Edge targets and endpoints on numbers #

theorem Turing.MultiTapePTM.val_blockEdgeEquiv_inr {k q : ℕ} (i : Fin q) (h : Fin k) (δ : Fin 3) :
↑((blockEdgeEquiv k q) (Sum.inr (i, h, δ))) = q + (↑δ + 3 * ↑h + k * 3 * ↑i)

The number of the block edge (i, h, δ): after the q control edges, in lexicographic order.

theorem Turing.MultiTapePTM.val_blockEdgeEquiv_inl {k q : ℕ} (i : Fin q) :
↑((blockEdgeEquiv k q) (Sum.inl i)) = ↑i

The number of the control edge leaving interval i.

The number of an interval as a vertex of the explicit network.

theorem Turing.MultiTapePTM.val_explicitVertexEquiv_sink {k q : ℕ} (m : ℕ) (e : BlockEdge k q) :
↑((explicitVertexEquiv k q m) (Sum.inl (Sum.inr e))) = q + ↑((blockEdgeEquiv k q) e)

The number of the sink of an edge as a vertex of the explicit network.

theorem Turing.MultiTapePTM.val_explicitVertexEquiv_inr {k q : ℕ} (m : ℕ) (e : BlockEdge k q) (j : Fin m) :
↑((explicitVertexEquiv k q m) (Sum.inr (e, j))) = q * (3 * k + 2) + (↑j + m * ↑((blockEdgeEquiv k q) e))

The number of the subdivision vertex of copy j of an edge.

theorem Turing.MultiTapePTM.val_explicitEdgeEquiv_inl {k q : ℕ} (m : ℕ) (e : BlockEdge k q) (j : Fin m) :
↑((explicitEdgeEquiv k q m) (Sum.inl (e, j))) = ↑j + m * ↑((blockEdgeEquiv k q) e)

The number of the source half of copy j of an edge.

theorem Turing.MultiTapePTM.val_explicitEdgeEquiv_inr {k q : ℕ} (m : ℕ) (e : BlockEdge k q) (j : Fin m) :
↑((explicitEdgeEquiv k q m) (Sum.inr (e, j))) = q * (3 * k + 1) * m + (↑j + m * ↑((blockEdgeEquiv k q) e))

The number of the target half of copy j of an edge.

The number of the vertex at which the block edge numbered n ends (edgeTarget): the next interval for a control edge (n < q), and for a block edge the next interval whose window contains its block; the sink q + n of the edge when there is none.

theorem Turing.MultiTapePTM.edgeTargetNum_blockEdgeEquiv {k q : ℕ} (σ m : ℕ) (e : BlockEdge k q) :
edgeTargetNum k q σ ↑((blockEdgeEquiv k q) e) = ↑((explicitVertexEquiv k q m) (Sum.inl (edgeTarget (scheduleOfNat k q σ) e)))

Edge targets on numbers.

The number of the interval that the block edge numbered n leaves.

The interval an edge leaves, on numbers.

The number of the vertex at which the explicit edge numbered j starts: the interval of its edge for a source half (j < q (3 k + 1) m), and the target of its edge for a target half.

The number of the vertex at which the explicit edge numbered j ends: the subdivision vertex of its copy.

theorem Turing.MultiTapePTM.explicitSrcNum_explicitEdgeEquiv {k q : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) {m : ℕ} (code : BlockLetter k State b → Fin m → Bool) (σ : ℕ) (p : BlockEdge k q × Fin m ⊕ BlockEdge k q × Fin m) :
explicitSrcNum k q m σ ↑((explicitEdgeEquiv k q m) p) = ↑((explicitVertexEquiv k q m) (((machine.blockNetwork input b (scheduleOfNat k q σ)).binarize code).subdivide.src p))

The sources of the explicit edges on numbers.

theorem Turing.MultiTapePTM.explicitTgtNum_explicitEdgeEquiv {k q : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) {m : ℕ} (code : BlockLetter k State b → Fin m → Bool) (σ : ℕ) (p : BlockEdge k q × Fin m ⊕ BlockEdge k q × Fin m) :
explicitTgtNum k q m ↑((explicitEdgeEquiv k q m) p) = ↑((explicitVertexEquiv k q m) (((machine.blockNetwork input b (scheduleOfNat k q σ)).binarize code).subdivide.tgt p))

The targets of the explicit edges on numbers.

Ports on numbers #

The ports of the vertex numbered v: the numbers of the explicit edges starting or ending at it, in increasing order.

theorem Turing.MultiTapePTM.map_val_explicitPorts {k q : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) {m : ℕ} (code : BlockLetter k State b → Fin m → Bool) (σ : ℕ) (w : (Fin q ⊕ BlockEdge k q) ⊕ BlockEdge k q × Fin m) :

The ports of a vertex on numbers: for any letter code, the ports of the vertex w of the binarized and subdivided network, numbered by explicitEdgeEquiv, are explicitPortsNum at the number of w.

theorem Turing.MultiTapePTM.map_fst_vertices_explicitBlockNetwork {k q : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) [NeZero b] {s : ℕ} (e : State ≃ Fin s) (σ : ℕ) :
List.map Prod.fst (machine.explicitBlockNetwork input b (scheduleOfNat k q σ) e).vertices = List.map (explicitPortsNum k q (letterBits k s b) σ) (List.range (q * (3 * k + 2) + q * (3 * k + 1) * letterBits k s b))

The ports of the explicit network on numbers: vertex v of the explicit network of the schedule of σ has the ports explicitPortsNum k q (letterBits k s b) σ v.