Copying a bit block without consuming the source
DefinitionTwo-destination bit-block transfer#✓fully proved
Pop a bit block onto two distinct destinations, reversing both copies.
def splitB (a b c : K) (d : Γ a → Option Bool)
(gb : Bool → Γ b) (gc : Bool → Γ c) (self next : Λ) :
TM2.Stmt Γ Λ Bool :=
.peek a (fun _ o => isBit d o) <| .branch id
(.pop a (fun _ o => bitOf d o) <|
.push b gb <| .push c gc <| .goto fun _ => self)
(.goto fun _ => next)
def isBit {α : Type} (d : α → Option Bool) (o : Option α) : Bool := (o.bind d).isSome
MathlibExt/Computability/TuringMachine/BitOps.lean:47
def bitOf {α : Type} (d : α → Option Bool) (o : Option α) : Bool := (o.bind d).getD false
MathlibExt/Computability/TuringMachine/BitOps.lean:50
TheoremTwo-destination bit transfer takes one step per bit plus one#✓fully proved
Two-destination bit transfer takes one step per bit plus one, with exact suffix and unrelated-stack preservation.
theorem splitB_run {M : Λ → TM2.Stmt Γ Λ Bool}
{a b c : K} {d : Γ a → Option Bool}
{gb : Bool → Γ b} {gc : Bool → Γ c} {self next : Λ}
(hM : M self = splitB a b c d gb gc self next)
(hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c)
(ga : Bool → Γ a) (hga : ∀ bit, d (ga bit) = some bit)
(p : List Bool) : ∀ (tail : List (Γ a)) (v : Bool)
(S : ∀ k, List (Γ k)), EndsBitBlock d tail →
S a = p.map ga ++ tail →
∃ S', Run M (p.length + 1) ⟨some self, v, S⟩
⟨some next, false, S'⟩ ∧ S' a = tail ∧
S' b = (p.map gb).reverse ++ S b ∧
S' c = (p.map gc).reverse ++ S c ∧
∀ k, k ≠ a → k ≠ b → k ≠ c → S' k = S k
def splitB (a b c : K) (d : Γ a → Option Bool)
(gb : Bool → Γ b) (gc : Bool → Γ c) (self next : Λ) :
TM2.Stmt Γ Λ Bool :=
.peek a (fun _ o => isBit d o) <| .branch id
(.pop a (fun _ o => bitOf d o) <|
.push b gb <| .push c gc <| .goto fun _ => self)
(.goto fun _ => next)
CSLibExt/Computability/Complexity/PolynomialEncoding/Copy.lean:30
def EndsBitBlock {α : Type} (d : α → Option Bool) (A : List α) : Prop := A.head?.bind d = none
MathlibExt/Computability/TuringMachine/BitOps.lean:57
def Run (n : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
(flip bind (TM2.step M))^[n] (some c) = some d
MathlibExt/Computability/TuringMachine/Program.lean:84
Uses 6 · Used by 1
TheoremBit-block copy keeps the order and restores source and scratch#✓fully proved
Copy a bit block in its original order, restoring both the source
and scratch, in exactly 2 * p.length + 2 steps.
Cslib.Complexity.PolynomialEncoding.copyB_run · 16 lines
theorem copyB_run {M : Λ → TM2.Stmt Γ Λ Bool}
{a b t : K} {da : Γ a → Option Bool} {dt : Γ t → Option Bool}
{ga : Bool → Γ a} {gb : Bool → Γ b} {gt : Bool → Γ t}
{first second next : Λ}
(h₁ : M first = moveB a t da gt first second)
(h₂ : M second = splitB t a b dt ga gb second next)
(hab : a ≠ b) (hat : a ≠ t) (hbt : b ≠ t)
(hga : ∀ bit, da (ga bit) = some bit)
(hgt : ∀ bit, dt (gt bit) = some bit)
(p : List Bool) (tail : List (Γ a)) (v : Bool)
(S : ∀ k, List (Γ k)) (ha : S a = p.map ga ++ tail)
(htail : EndsBitBlock da tail) (ht : EndsBitBlock dt (S t)) :
∃ S', Run M (2 * p.length + 2) ⟨some first, v, S⟩
⟨some next, false, S'⟩ ∧ S' a = S a ∧ S' t = S t ∧
S' b = p.map gb ++ S b ∧
∀ k, k ≠ a → k ≠ b → k ≠ t → S' k = S k
def moveB (a b : K) (d : Γ a → Option Bool) (g : Bool → Γ b) (self next : Λ) :
TM2.Stmt Γ Λ σ :=
.peek a (fun _ o => Flag.tag (isBit d o))
(.branch Flag.untag
(.pop a (fun _ o => Flag.tag (bitOf d o))
(.branch Flag.untag
(.push b (fun _ => g true) (.goto fun _ => self))
(.push b (fun _ => g false) (.goto fun _ => self))))
(.goto fun _ => next))
MathlibExt/Computability/TuringMachine/BitOps.lean:86
def splitB (a b c : K) (d : Γ a → Option Bool)
(gb : Bool → Γ b) (gc : Bool → Γ c) (self next : Λ) :
TM2.Stmt Γ Λ Bool :=
.peek a (fun _ o => isBit d o) <| .branch id
(.pop a (fun _ o => bitOf d o) <|
.push b gb <| .push c gc <| .goto fun _ => self)
(.goto fun _ => next)
CSLibExt/Computability/Complexity/PolynomialEncoding/Copy.lean:30
def EndsBitBlock {α : Type} (d : α → Option Bool) (A : List α) : Prop := A.head?.bind d = none
MathlibExt/Computability/TuringMachine/BitOps.lean:57
def Run (n : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
(flip bind (TM2.step M))^[n] (some c) = some d
MathlibExt/Computability/TuringMachine/Program.lean:84
Uses 7 · Used by 1
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.