Documentation

CslibFrontier.Computability.Complexity.Fagin.Converse

NP classes are existential second-order definable (Fagin's theorem) #

The converse direction of Fagin's theorem Fagin, Theorem 6, Immerman, Theorem 7.8, Papadimitriou, Theorem 8.3: for an isomorphism-closed class K of finite relational structures over a language L with a finite vocabulary v : Vocabulary L, if v.queryLanguage K ∈ NP encStructure, then K is existential second-order definable (Cslib.Logic.ESO.Definable.of_queryLanguage_mem_NP). Combined with Cslib.Logic.ESO.Definable.queryLanguage_mem_NP from CslibFrontier/Computability/Complexity/Fagin/Verifier.lean, this gives Fagin's characterization Cslib.Logic.ESO.definable_iff_queryLanguage_mem_NP (Cslib.Logic.ESO.Definable K ↔ v.queryLanguage K ∈ NP encStructure).

Given an NP verifier V with certificate-length polynomial p, we wrap V in Cslib.Complexity.strictVerifier encStructure p V so that any accepting run has a certificate of length p |encStructure a|. Let tm be a deterministic multi-tape Turing machine computing strictVerifier encStructure p V within a polynomial time bound t₀.

We choose an exponent k ≥ 1 bounding all relation arities of v such that on every well-formed input a of cardinality n = a.1 ≥ 2, the power-domain size B = n ^ k exceeds both the framed input plus certificate length and tm's time bound (Cslib.Logic.Vocabulary.exists_pow_bound from CslibFrontier/Logics/FirstOrder/Encoding/PowerBound.lean). On Fin B equipped with v.powerStructure a B, we conjoin v.layoutESOSentence and v.tableauESOSentence tm and existentially project the intermediate input-tape relations (uLenSym, uBitSym) via Cslib.Logic.ESO.Sentence.project to obtain v.npPowerSentence tm : ESO.Sentence v.powerLanguage. Pulling this sentence back to (M, <) along the first-order interpretation v.powerInterpretation k har and existentially quantifying the linear order < via Cslib.Logic.ESO.Definable.of_powerLanguage (which handles cardinalities 0 and 1 by finite truth-table disjunction in CslibFrontier/Computability/Complexity/Fagin/Small.lean) yields the defining ESO sentence over L.

Main definitions #

Main results #

References #

Combined ESO sentence on the power structure #

The existential second-order sentence over v.powerLanguage that existentially guesses the framed input-tape relations (uLenSym and uBitSym), checks that they represent frame (encStructure a) via v.layoutESOSentence, and asserts via v.tableauESOSentence tm that tm accepts frame (encStructure a) ++ w for some certificate w.

Correctness of v.npPowerSentence on Fin B. On (Fin B, v.powerStructure a B) for a well-formed input a with (frame (encStructure a)).length + 1 < B, (v.npPowerSentence tm) holds if and only if CookLevin.tableau tm (frame (encStructure a)) L (B - 1) is satisfiable for some certificate length L with (frame (encStructure a)).length + L + 1 < B.

theorem Cslib.Logic.Vocabulary.exists_powerSentence_of_mem_NP {L : FirstOrder.Language} (v : Vocabulary L) {K : Set EncodedStructure} (hNP : K ∈ Complexity.NP encStructure) :
∃ (k : ℕ), 1 ≤ k ∧ (∀ (i : Fin v.count), v.arity i ≤ k) ∧ ∃ (Ψ : ESO.Sentence v.powerLanguage), ∀ (a : EncodedStructure), v.WellFormed a → 2 ≤ a.1 → (a ∈ K ↔ Ψ.Realize (Fin (a.1 ^ k)))

An NP language of encoded structures has a single ESO definition on canonical power structures of sufficiently large fixed dimension. Only well-formed inputs of size at least two are considered; no invariance under renumbering is assumed.

NP classes of finite structures are existential second-order definable (the converse direction of Fagin's theorem): for an isomorphism-closed class K of finite relational structures over a language L with a finite vocabulary v, if v.queryLanguage K ∈ NP encStructure, then K is existential second-order definable Fagin, Theorem 6, Immerman, Theorem 7.8, Papadimitriou, Theorem 8.3.

Fagin's theorem: an isomorphism-closed class K of finite relational structures over a language L with a finite vocabulary v is existential second-order definable if and only if its query language v.queryLanguage K belongs to NP encStructure Fagin, Theorem 6, Immerman, Theorem 7.8, Papadimitriou, Theorem 8.3.

Fagin's theorem (hypothesis-free form): a class K of finite relational structures over a language L with a finite vocabulary v is existential second-order definable if and only if K is closed under isomorphism and its query language v.queryLanguage K belongs to NP encStructure Fagin, Theorem 6, Immerman, Theorem 7.8.