Pairing and relation predicates #
This file defines a simple injective pairing pair : List Bool → List Bool → List Bool
used to encode (x, y) as a single binary string for verification by a TM, along with
the shared predicates PolyBalanced and pairLang used by FNP, FNL, and other
search-problem classes.
Encode a pair of binary strings as a single binary string.
Each bit of x is doubled (false ↦ [false, false], true ↦ [true, true]),
followed by the separator [false, true], followed by y verbatim.
This encoding is injective and computable in linear time.
Instances For
Partial inverse to pair. It scans doubled bits until the first
separator [false, true], returning the decoded left component together
with the remaining suffix. Invalid doubled prefixes return none.
Equations
- Complexity.unpair? [] = none
- Complexity.unpair? (false :: true :: y) = some ([], y)
- Complexity.unpair? (false :: false :: z) = Option.map (fun (xy : List Bool × List Bool) => (false :: xy.1, xy.2)) (Complexity.unpair? z)
- Complexity.unpair? (true :: true :: z) = Option.map (fun (xy : List Bool × List Bool) => (true :: xy.1, xy.2)) (Complexity.unpair? z)
- Complexity.unpair? x✝ = none
Instances For
A binary relation is polynomially balanced if witness length is bounded by a polynomial in the input length. This is the standard "short witness" condition used in the definitions of NP, FNP, FNL, etc.
Equations
- Complexity.PolyBalanced R = ∃ (p : Polynomial ℕ), ∀ (x y : List Bool), R x y → y.length ≤ Polynomial.eval x.length p
Instances For
The pair language (verification language) of a binary relation R:
the set of encoded pairs pair(x, y) such that R x y holds.