Documentation

Complexity.Computability.Machines.Turing.MultiTape.Internal.PolyTimeNatFrontends

Direct unary comparison and bit-access frontends #

These canonical interfaces retain the original word folds: unary subtraction folds predecessor, unary-to-binary conversion folds the binary successor, and indexed access folds the word tail before using the existing head codec. No higher tidy calculus supplies a plain primitive.

Truncated subtraction of unary naturals.

Strict comparison of unary naturals.

theorem Turing.MultiTapeTM.ComputableInPolyTime.unary_le' {α : Type} {input : α ↪ List Bool} {left right : α → ℕ} (hleft : ComputableInPolyTime left input encUnary) (hright : ComputableInPolyTime right input encUnary) :
ComputableInPolyTime (fun (a : α) => decide (left a ≤ right a)) input encBool

Compare computed unary values, with both operand encodings fixed.

theorem Turing.MultiTapeTM.ComputableInPolyTime.unary_lt' {α : Type} {input : α ↪ List Bool} {left right : α → ℕ} (hleft : ComputableInPolyTime left input encUnary) (hright : ComputableInPolyTime right input encUnary) :
ComputableInPolyTime (fun (a : α) => decide (left a < right a)) input encBool

Strictly compare computed unary values, with both operand encodings fixed.

Convert a unary natural to its binary encoding.

Read a bit at a unary index with a fixed fallback. Fixing the raw encoding avoids guessing a list-encoding instance during compositional proof search.

theorem Turing.MultiTapeTM.ComputableInPolyTime.binary_testBit {α : Type} {input : α ↪ List Bool} {n i : α → ℕ} (hn : ComputableInPolyTime n input encNat) (hi : ComputableInPolyTime i input encUnary) :
ComputableInPolyTime (fun (a : α) => (n a).testBit (i a)) input encBool

Read the bit of a computed binary number at a computed unary position.

theorem Turing.MultiTapeTM.ComputableInPolyTime.unary_testBit' {α : Type} {input : α ↪ List Bool} {n i : α → ℕ} (hn : ComputableInPolyTime n input encUnary) (hi : ComputableInPolyTime i input encUnary) :
ComputableInPolyTime (fun (a : α) => (n a).testBit (i a)) input encBool

Read the bit of a computed unary number at a computed unary position.