Documentation

Complexitylib.Classes.PCP.Internal.DataScanSpec

What the bracket scan computes #

A model of the left-to-right pass over a serialized Data value: a bracket depth, a count of the top-level children already passed, and the bits collected while inside the child that was asked for. This file is about the model alone — that it really does extract the requested child — and says nothing about computability.

Two facts drive everything. The depth and the count evolve without looking at the collected bits, and the collected bits only ever grow at the end (runSpec_append_acc); and a serialized value read at any depth returns to that depth, having contributed exactly its own serialization when it was the child being sought (runSpec_toBits).

Main definitions #

Main results #

One step of the pass: false opens a bracket, true closes one, and the bit joins the output exactly when the count matches the child sought.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    The pass over a whole string.

    Equations
    Instances For
      @[simp]
      theorem Complexity.DataScan.runSpec_append (i : ) (st : × × List Bool) (s t : List Bool) :
      runSpec i st (s ++ t) = runSpec i (runSpec i st s) t
      theorem Complexity.DataScan.runSpec_cons (i : ) (st : × × List Bool) (b : Bool) (s : List Bool) :
      runSpec i st (b :: s) = runSpec i (stepSpec i st b) s
      theorem Complexity.DataScan.runSpec_append_acc (i : ) (s : List Bool) (d c : ) (pre acc : List Bool) :
      runSpec i (d, c, pre ++ acc) s = ((runSpec i (d, c, acc) s).fst, (runSpec i (d, c, acc) s).snd.fst, pre ++ (runSpec i (d, c, acc) s).snd.snd)

      The collected bits only grow at the end. A prefix already present in the output is carried through untouched, and the depth and count do not see it.

      theorem Complexity.DataScan.runSpec_toBits (i : ) (y : Data) (d c : ) (acc : List Bool) :
      runSpec i (d, c, acc) y.toBits = (d, if d = 0 then c + 1 else c, if c = i then acc ++ y.toBits else acc)

      Reading one serialized value. Starting at depth d with c children already passed, the pass over y.toBits returns to depth d; it counts one more child exactly when it was at the top level, and it contributes y.toBits to the output exactly when y is the child sought.

      A run of children #

      The child a pass looking for index i picks out of xs, having already passed c children.

      Equations
      Instances For
        theorem Complexity.DataScan.runSpec_flatten (i : ) (xs : List Data) (c : ) (acc : List Bool) :
        runSpec i (0, c, acc) (List.map Data.toBits xs).flatten = (0, c + xs.length, acc ++ selFrom xs i c)

        Reading a run of children. At the top level the pass counts every child and contributes exactly the one it was asked for.

        The pass over a serialized list. Reading the bits strictly between the outer brackets returns the requested child's own serialization.