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 #
Complexity.headFlag_mem_FP— the leading-bit test is inFP
@[implicit_reducible]
@[implicit_reducible]
Equations
- Complexity.instFintypeHeadPhase = { elems := {Complexity.HeadPhase.skip, Complexity.HeadPhase.test, Complexity.HeadPhase.done}, complete := ⋯ }
theorem
Complexity.headFlagTM_computesInTime
(target : Bool)
:
(headFlagTM target).ComputesInTime (headFlag target) fun (x : ℕ) => 2
headFlagTM target computes headFlag target in two steps.