Documentation

Complexitylib.Classes.P.Cobham.Internal.HeadFlag

Testing a leading bit — proof internals #

Every other FP primitive the Cobham proof uses — Complexity.takeLen, List.reverse, Complexity.pair, Cobham.mulUnpair — fixes its output's length from its inputs' lengths alone, so none of them can react to a bit's value. Complexity.headFlag closes that gap by turning a bit test into a length: the answer is carried by whether the result is empty. Its two-state transducer moves off the left-end marker, then emits one bit exactly when the first input bit matches.

Main results #

def Complexity.headFlag (target : Bool) (x : List Bool) :

[false] when x begins with target, and [] otherwise: a bit test whose answer is carried by the length of the result.

Equations
Instances For

    Control states of the head-bit flag machine.

    Instances For
      @[implicit_reducible]
      Equations
      def Complexity.headFlagTM (target : Bool) :
      TM 0

      Read the first input bit and emit one output bit exactly when it is target. Two steps: skip moves off the left-end markers, test reads the bit and either writes or not.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem Complexity.headFlagTM_computesInTime (target : Bool) :
        (headFlagTM target).ComputesInTime (headFlag target) fun (x : ) => 2

        headFlagTM target computes headFlag target in two steps.

        theorem Complexity.headFlag_mem_FP (target : Bool) :
        headFlag target FP

        A bit test, as a length.