Documentation

Complexitylib.Classes.P.Cobham.Internal.MulLen

Multiplying the block lengths of a pair — proof internals #

This module builds the one quadratic-output transducer needed by Cobham's soundness direction: from pair A B it emits |A| · |B| copies of false, which is exactly the length behaviour of Complexity.smash. The soundness proof then applies unaryLength_mem_FP to turn this internal zero-filled ruler into Cobham's all-one smash word.

The machine mulLenTM is self-contained (one work tape, eight control states):

  1. scan — parse the leading self-delimiting block two symbols at a time, writing one unary mark on the work tape per payload bit, so the work tape ends up holding |A| in unary;
  2. outer loop — for every remaining input symbol (i.e. |B| times) run the emit pass, which walks the |A| marks writing one false per mark, and the rewind pass, which returns the work head to cell one.

Malformed input halts with empty output, matching unpair? = none.

Main results #

The function computed by the scanner #

The remaining output of the length-multiplication scanner when k payload bits of the leading block have already been counted and w is the unread part of the input: |A| · |B| copies of false for a well-formed remainder, and nothing at all when the block framing is broken.

Equations
Instances For

    Emit |A| · |B| copies of false from a pair pair A B; the empty string on input that is not a valid pair encoding.

    Equations
    Instances For
      @[simp]

      Reaching the separator ends the block: only the suffix remains.

      theorem Complexity.Cobham.mulAux_double (k : ) (b : Bool) (z : List Bool) :
      mulAux k (b :: b :: z) = mulAux (k + 1) z

      A doubled payload bit increments the counted length.

      @[simp]

      A broken doubling halts the scan with no output.

      On a genuine pair the scanner emits |A| · |B| copies of false.

      The scanner #

      Control states of mulLenTM.

      • skip : MulPhase

        Move every head off the left-end marker.

      • scanA : MulPhase

        Read the first symbol of a doubled payload bit.

      • scanB0 : MulPhase

        The first symbol of the pair was 0.

      • scanB1 : MulPhase

        The first symbol of the pair was 1.

      • outer : MulPhase

        Consume one symbol of the suffix, or halt at its end.

      • emit : MulPhase

        Walk the unary marks, emitting one false per mark.

      • rew : MulPhase

        Rewind the work head to cell one.

      • done : MulPhase

        Halt.

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

        The length-multiplication scanner. Parses the leading self-delimiting block into |A| unary marks on its work tape, then emits |A| zeros for each of the |B| remaining input symbols. Computes mulUnpair.

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

          Correctness of the scanner #

          mulUnpair is polynomial-time, via the mulLenTM scanner.