Conjunctive query evaluation and containment are NP-complete

lax-420092·formalized by Pierre Senellart @PierreSenellart · Claude (Anthropic)·registered·created ·GitHub @597970b·Lean v4.33.0 epoch · mathlib db584cd6d46c

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this submission may be incorrect.

No flags have been submitted.

    Community review

    Flag this submission

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    Abstract

    The two classical decision problems about Boolean conjunctive queries, evaluation and containment, from the descriptive-complexity library's worked example on database theory, built on the NP core registered as lax-904597 and on the catalog registered as lax-799700. The schema is a single binary relation, that of graph databases, which loses no complexity-theoretic generality. An evaluation instance is a query and a database over a shared universe, a containment instance a pair of queries over shared constants.

    Both problems are NP-complete in the core's sense, the results of Chandra and Merlin (1977): evaluation is definable in existential second-order logic and 3-colorability reduces to it by a quantifier-free first-order reduction, assumed from the catalog's statement; containment reduces to evaluation by the Chandra–Merlin theorem in reduction form, containment holding exactly when the right query maps homomorphically into the canonical database of the left one, and evaluation reduces to containment, a database being a variable-free query. The Chandra–Merlin theorem itself is a statement of the submission, as are the two reductions, so the archive's proof network shows containment's completeness resting on evaluation's.

    As in the graph-crawling submission, the problem is also stated on packaged instances: concrete queries and databases, encoded faithfully and size-honestly, and decoded back from any raw relation table with a constant, with evaluation on such well-formed instances NP-complete too.

    The proofs are those of version 1.2.2 of the library, sliced to what these statements use. The library and its documentation are at https://github.com/PierreSenellart/descriptive-complexity and https://pierresenellart.github.io/descriptive-complexity/DescriptiveComplexity.html. The Lean code was written with the assistance of several Claude models; the design and the statements are the author's.

    Concepts

    Concept map
    18 concepts
    100%
    Proven claimDefinitionThis submissionOther submissionA → B: B builds on A

    Proofs

    Proof networkview on GitHub

    100%
    assumptions conclusionProven claimStatement 1, 2, … of a claim with several statementsClaim from this submission / another submissionProof — open large view for details
    Proof list

    Lean sources for these proofs: proofs/ on GitHub

    Proof code is not displayed; the archive records each proof's checked relationship between claims.

    Related submissions

    Submission map

    100%
    This submissionOther submissionA → B: B's concepts build on A

    Cite this

    This is only the formalizers. The authors of the formalized results may be different (see References).

    @misc{lax-420092,
      author = {Pierre Senellart and Claude (Anthropic)},
      title = {Conjunctive query evaluation and containment are NP-complete},
      year = {2026},
      howpublished = {Lax Archive, lax-420092},
      url = {https://laxarchive.org/lax-420092/},
    }

    References

    1. Ashok K. Chandra and Philip M. Merlin. Optimal Implementation of Conjunctive Queries in Relational Data Bases. In Proceedings of the 9th Annual ACM Symposium on Theory of Computing, May 4-6, 1977, Boulder, Colorado, USA 77–90, 1977. doi:10.1145/800105.803397
    2. Pierre Senellart and Anton Gnatenko. Descriptive Complexity in Lean: Completeness by First-Order Reductions. 2026. arXiv:2609.18261
    3. Pierre Senellart. DescriptiveComplexity: Completeness by First-Order Reductions in Lean. 2026. doi:10.5281/zenodo.21678423 · github.com/PierreSenellart/descriptive-complexity

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…