Reading a framed bit block

DefinitionMachine step reading one framed payload pair#✓fully proved

Consume one framed-payload pair or its terminator.

def read (a b : K) (d : Γ a → Option Bool) (g : Bool → Γ b)
    (self good bad : Λ) : TM2.Stmt Γ Λ Bool :=
  .peek a (fun _ o => isBit d o) <| .branch id
    (.pop a (fun _ o => bitOf d o) <| .branch id
      (.peek a (fun _ o => isBit d o) <| .branch id
        (.pop a (fun _ o => bitOf d o) <| .push b g <|
          .goto fun _ => self)
        (.goto fun _ => bad))
      (.goto fun _ => good))
    (.goto fun _ => bad)
Uses 2 · Used by 11

TheoremReading a complete framed block#✓fully proved

Read a complete block, preserving an arbitrary suffix and all stacks other than the input and reversed-payload destination.

theorem run_delimit {M : Λ → TM2.Stmt Γ Λ Bool}
    {a b : K} {d : Γ a → Option Bool} {g : Bool → Γ b}
    {self good bad : Λ} (hM : M self = read a b d g self good bad)
    (hab : a ≠ b) (ga : Bool → Γ a) (hga : ∀ c, d (ga c) = some c)
    (payload : List Bool) : ∀ (tail : List (Γ a)) (v : Bool)
      (S : ∀ k, List (Γ k)),
      S a = (delimit payload).map ga ++ tail →
      ∃ S', Run M (payload.length + 1) ⟨some self, v, S⟩
        ⟨some good, false, S'⟩ ∧ S' a = tail ∧
        S' b = (payload.map g).reverse ++ S b ∧
        ∀ k, k ≠ a → k ≠ b → S' k = S k
Uses 4 · Used by 6

TheoremFramed block reader fails on truncated framing#✓fully proved

Truncated framing reaches the failure branch within input length plus one, without assuming that the input is an encoder image. The destination may contain a partial payload on failure; the caller must discard or clear it before using that stack again.

theorem run_none {M : Λ → TM2.Stmt Γ Λ Bool}
    {a b : K} {d : Γ a → Option Bool} {g : Bool → Γ b}
    {self good bad : Λ} (hM : M self = read a b d g self good bad)
    (hab : a ≠ b) (ga : Bool → Γ a) (hga : ∀ c, d (ga c) = some c)
    (input : List Bool) (v : Bool) (S : ∀ k, List (Γ k))
    (hS : S a = input.map ga) (hn : undelimit input = none) :
    ∃ v' S', RunLe M (input.length + 1) ⟨some self, v, S⟩
      ⟨some bad, v', S'⟩
Uses 5 · Used by 4
3 fully proved

The dependency explorer needs JavaScript and its graph data.

Download the complete graph data.