Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Nat.Unpair

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 #

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.

Apply Nat.unpair to a computed unary value.