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 #
Turing.MultiTapeTM.ComputableInPolyTime.int_natCast,.int_negSucc: constructing signed integers from unary naturals.Turing.MultiTapeTM.ComputableInPolyTime.int_natCast_sub: the signed difference of unary naturals.Turing.MultiTapeTM.ComputableInPolyTime.int_succ,.int_pred,.int_pos,.int_neg: unit shifts and sign tests.Turing.MultiTapeTM.ComputableInPolyTime.int_toNat,.int_natAbs,.int_equivNat: nonnegative truncation, absolute value and the standard numbering of integers, in unary.Turing.MultiTapeTM.ComputableInPolyTime.int_sub: subtraction of signed unary integers.Turing.MultiTapeTM.ComputableInPolyTime.int_sub_sign,.int_abs_le_nat: fixed tape moves and membership in a unary-bounded window.Turing.MultiTapeTM.ComputableInPolyTime.int_abs_le_nat': window membership for computed positions and bounds.
References #
Interpret a unary natural as a nonnegative signed integer.
Construct -(n + 1) from a unary natural n.
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 two signed unary integers.
Subtract a fixed tape direction from a signed unary position.
Compare a signed unary position's magnitude with a unary window bound.
Test window membership after computing the signed position and unary bound.
Number signed integers by 0, -1, 1, -2, …, returning the index in unary.