Unary integer square root and unpairing in polynomial time #
On unary naturals (Turing.MultiTapeTM.encUnary), the integer floor square root Nat.sqrt is
found by searching 0, …, m for the least s with m < (s + 1) * (s + 1), and Mathlib's inverse
pairing function Nat.unpair : ℕ → ℕ × ℕ follows by unfolding its definition in terms of
Nat.sqrt.
Main results #
Turing.MultiTapeTM.ComputableInPolyTime.unary_sqrt:Nat.sqrton unary naturals.Turing.MultiTapeTM.ComputableInPolyTime.unary_unpair,.unary_unpair':Nat.unpairon unary naturals.
Integer floor square root Nat.sqrt, with input and output in unary.
Mathlib's inverse pairing function Nat.unpair, with input and both components in unary.
theorem Turing.MultiTapeTM.ComputableInPolyTime.unary_unpair' {α : Type} {input : α ↪ List Bool} {f : α → ℕ} (hf : ComputableInPolyTime f input encUnary) :
Apply Nat.unpair to a computed unary value.