Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Int

Polynomial-time operations on signed unary integers #

Operations on Christian Reitwiessner's encIntUnary: the sign bit is followed by n unary bits for Int.ofNat n or Int.negSucc n. In the negative case the magnitude is n + 1. Natural inputs and outputs use encUnary, so these rules support polynomially bounded tape positions and their indices in a computation tableau.

Main results #

References #

Interpret a unary natural as a nonnegative signed integer.

Subtract unary naturals without truncating at zero.

Shift a signed unary integer one cell to the right.

Shift a signed unary integer one cell to the left.

Test whether a signed unary integer is positive.

Test whether a signed unary integer is negative.

Truncate a signed integer at zero and return the result in unary.

Return the magnitude in unary, accounting for the offset in negative encodings.

Subtract a fixed tape direction from a signed unary position.

Compare a signed unary position's magnitude with a unary window bound.

theorem Turing.MultiTapeTM.ComputableInPolyTime.int_abs_le_nat' {α : Type} {input : α ↪ List Bool} {position : α → ℤ} {bound : α → ℕ} (hposition : ComputableInPolyTime position input encIntUnary) (hbound : ComputableInPolyTime bound input encUnary) :
ComputableInPolyTime (fun (a : α) => decide (|position a| ≤ ↑(bound a))) input encBool

Test window membership after computing the signed position and unary bound.

Number signed integers by 0, -1, 1, -2, …, returning the index in unary.