Documentation

CslibFrontier.Computability.Complexity.Classes.NP.WitnessTree

Binary witness trees, prefix sets and left sets #

A binary witness tree (Cslib.Complexity.WitnessTree) for a problem A : Set α encoded by enc gives each instance x a polynomial-time unary witness length len x and a polynomial-time verifier verify such that x ∈ A iff some bit string of length len x is accepted. Every NP verifier (p, V) induces a binary witness tree (Cslib.Complexity.WitnessTree.ofIsVerifier).

The binary prefixes of length at most len x form a depth-len x search tree ordered lexicographically (false < true). Two canonical derived sets live on α × List Bool:

Searching the tree level by level in decreasing lexicographic order (expand, searchWith, acceptsWith) with a polynomial-time pruning rule that keeps the largest valid prefix of every level and polynomially many nodes decides A in polynomial time (Cslib.Complexity.WitnessTree.acceptsWith_iff_of_isLargest_mem_prune, Cslib.Complexity.WitnessTree.computableInPolyTime_acceptsWith), powering Arvind–Köbler–Mundhenk's bounded truth-table theorem (CslibFrontier/Computability/Complexity/Classes/Sparse/BoundedTruthTable.lean).

Main definitions #

Main results #

References #

structure Cslib.Complexity.WitnessTree {α : Type} (enc : α ↪ List Bool) (A : Set α) :

A binary witness tree for a problem A : Set α encoded by enc: each instance x has binary witnesses of polynomial-time unary length len x, checked by a polynomial-time verifier verify.

Lexicographic padding #

The all-false word is lexicographically least among words of its length.

A word padded with false is lexicographically at most a word v of the same length exactly when it is at most the prefix of v of its own length.

Construction from an NP verifier #

Every NP verifier (p, V) induces a binary witness tree with witness length p.eval (enc x).length.

Prefix sets and left sets #

def Cslib.Complexity.WitnessTree.prefixSet {α : Type} {enc : α ↪ List Bool} {A : Set α} (T : WitnessTree enc A) :

The prefix set of T: pairs (x, u) with u.length ≤ T.len x such that u is a prefix of some witness of x.

def Cslib.Complexity.WitnessTree.leftSet {α : Type} {enc : α ↪ List Bool} {A : Set α} (T : WitnessTree enc A) :

The left set of T [Arvind, Köbler and Mundhenk, Definition 2.3] [AKM92]: pairs (x, w) of length T.len x lexicographically at most some witness of x.

Pad a prefix u with false bits to length n.

Padding a prefix to witness length is polynomial-time.

def Cslib.Complexity.WitnessTree.IsLargestPrefix {α : Type} {enc : α ↪ List Bool} {A : Set α} (T : WitnessTree enc A) (x : α) (c : List Bool) :

c is the lexicographically largest prefix of x at its depth that extends to a witness.

theorem Cslib.Complexity.WitnessTree.pad_mem_leftSet_iff_le {α : Type} {enc : α ↪ List Bool} {A : Set α} (T : WitnessTree enc A) {x : α} {c u : List Bool} (hc : T.IsLargestPrefix x c) (hu : u.length = c.length) :
(x, pad (T.len x) u) ∈ T.leftSet ↔ u ≤ c

Left-set membership on a level. For a level containing the largest valid prefix c, the padded nodes in T.leftSet are exactly those lexicographically at most c.

theorem Cslib.Complexity.WitnessTree.exists_child_mem_prefixSet {α : Type} {enc : α ↪ List Bool} {A : Set α} (T : WitnessTree enc A) {x : α} {u : List Bool} (hu : (x, u) ∈ T.prefixSet) (hlt : u.length < T.len x) :
∃ (b : Bool), (x, u ++ [b]) ∈ T.prefixSet

A valid prefix below witness length has a valid one-bit child.

Expand a level of prefixes in decreasing lexicographic order: each node u is followed by u ++ [true] and u ++ [false].

Search the binary prefix tree for n levels, pruning each expanded level with prune.

def Cslib.Complexity.WitnessTree.acceptsWith {α : Type} (len : α → ℕ) (verify : α × List Bool → Bool) (prune : List (List Bool) → List (List Bool)) (x : α) :

Search the witness tree of x of depth len x with the pruning rule prune, and accept when a surviving leaf is accepted by verify.

theorem Cslib.Complexity.WitnessTree.acceptsWith_iff_of_isLargest_mem_prune {α : Type} {enc : α ↪ List Bool} {A : Set α} (T : WitnessTree enc A) {prune : List (List Bool) → List (List Bool)} {x : α} (hsub : ∀ (l : List (List Bool)), (prune l).Sublist l) (hkeep : ∀ {k : ℕ}, k ≤ T.len x → ∀ {l : List (List Bool)}, (∀ u ∈ l, u.length = k) → List.Pairwise (fun (a b : List Bool) => b < a) l → ∀ {c : List Bool}, c ∈ l → T.IsLargestPrefix x c → c ∈ prune l) :
acceptsWith T.len T.verify prune x = true ↔ x ∈ A

Correctness of a pruned search that keeps the largest valid prefix. If prune returns a sublist of every level and keeps the largest valid prefix of every decreasing level of depth k ≤ T.len x, then acceptsWith T.len T.verify prune decides A.

Polynomial time #

theorem Cslib.Complexity.WitnessTree.computableInPolyTime_acceptsWith {α : Type} {enc : α ↪ List Bool} {A : Set α} (T : WitnessTree enc A) {π : Type} {encP : π ↪ List Bool} {par : α → π} (hpar : Turing.MultiTapeTM.ComputableInPolyTime par enc encP) {prune : π → List (List Bool) → List (List Bool)} (hprune : Turing.MultiTapeTM.ComputableInPolyTime (fun (q : π × List (List Bool)) => prune q.1 (expand q.2)) (Turing.MultiTapeTM.encPair encP (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encBits)) (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encBits)) (hsub : ∀ (p : π) (l : List (List Bool)), ∀ u ∈ prune p l, u ∈ l) {width : α → ℕ} (hwidth : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (enc x).length) width) (hlen : ∀ (x : α) (l : List (List Bool)), (prune (par x) l).length ≤ width x) :

A pruned search is polynomial-time when expanding and pruning one level is polynomial-time uniformly in a polynomial-time parameter par x, the pruning rule keeps a subset of its input, and each pruned level has at most width x nodes for a polynomially bounded width.