Documentation

CslibFrontier.Computability.Complexity.Classes.Oracle.BinarySearch

Binary search with a language oracle #

A total deterministic program recovers F < 2^N from threshold requests k ≤ F in N rounds. The strict polynomial-time certificate charges constructing requests, reading replies, and the binary search state; N is supplied by a polynomial-time unary computation. This general search is shared by ordinary and relativized counting clients.

Main results #

One round of binary search for a number F: in the state (lo, j) with j > 0 bits left, test whether lo + 2 ^ (j - 1) ≤ F, and keep the half containing F.

theorem Cslib.Complexity.BinarySearch.fst_iterate_step {F N : ℕ} (hF : F < 2 ^ N) :
((step F)^[N] (0, N)).1 = F

Binary search finds F < 2 ^ N in N rounds.

Binary search with an oracle #

One round of binary search with the oracle: in the state (lo, j) with j > 0, ask about the code encPair encBits encNat (u, lo + 2 ^ (j - 1)), and keep the half selected by the reply.

Binary search in N rounds with the oracle, about the codes encPair encBits encNat (u, k).