Documentation

DescriptiveComplexity.Decoding

Well-formed instances and computable decodings #

The decoding direction of an encoding (DescriptiveComplexity.Encoding): membership results transfer to the concrete problem along a faithful encoding for free, but reading a hardness theorem back to concrete data needs a converse – the abstract problem must not be hard only on junk structures the encoding never produces. This file makes that converse checkable, in two independent, composable pieces designed to keep the user-facing work minimal.

Well-formedness is a decision problem. The junk-free structures are cut out by an isomorphism-invariant property W – typically a plain first-order sentence, bundled by DescriptiveComplexity.DecisionProblem.ofSentence so that invariance comes for free. Hardness on well-formed instances then needs no new framework at all: it is ordinary hardness of the conjunction W ⊓ P (pointwise , the Min instance below), and the library's existing machinery applies to it unchanged. A user upgrades an existing completeness proof with two one-liners:

The choice of W is self-policing: chosen too narrow, the hardness reduction cannot land in it; chosen too wide, the decoding below cannot handle it. Both failure modes are proofs that do not close, never silent unsoundness.

Decodings are computations. The lesson of DescriptiveComplexity.Encoding.CoversUpTo's removal is that an existential decoding statement (∀ A, ∃ i, Conc i ↔ P A) is classically near-vacuous: casing on P A discharges it with no decoding whatsoever, whenever the concrete type has one yes- and one no-instance. The honest content is a function, so DescriptiveComplexity.Decoding bundles one, with the same computability hygiene as encoders: a plain def

Because dec is Option-valued and computable, it can be run: #guards can test a decoder on small presentations exactly as they test encoders, and the compiler rejects a decoder whose data decides an undecidable predicate. The residual gap is also the same as for encoders: computability is enforced, a complexity bound is not (a decoder may brute-force the answer); that would need the machine bridge (ROADMAP.md §7).

The Prop-level consequence – every well-formed finite structure is semantically a concrete instance – is DescriptiveComplexity.Decoding.exists_conc_iff; unlike its removed predecessor it cannot be established by classical casing, because it is derived from the bundled function.

Worked decoders are in the two tutorials (DescriptiveComplexity.Examples.ConjunctiveQueries, DescriptiveComplexity.Examples.GraphCrawling); the crawling one exists only thanks to well-formedness – on structures marking several roots no honest decoder can choose without computing reachability, and W (“exactly one root”) is what removes them.

Main declarations #

Well-formedness as a decision problem #

The conjunction of two decision problems: a structure is a yes-instance when it is one of both. Written W ⊓ P (through the Min instance below); with W a well-formedness condition, W ⊓ P is “P, on well-formed instances”.

Equations
Instances For
    Dependency graph
    Dependency graph
    Dependency graph

    A first-order sentence, read as a decision problem: the structures satisfying it. Isomorphism-invariance is automatic, which makes this the cheapest way to state a well-formedness condition W.

    Equations
    Instances For
      Dependency graph
      Dependency graph

      Reductions with an image invariant #

      A reduction into P whose images all satisfy W is a reduction into W ⊓ P – so hardness of the restricted problem costs one image lemma on top of the reduction already at hand. Only the last hop of a reduction chain needs the lemma: composing any further reduction in front leaves the images unchanged.

      Strengthen the target of a reduction by an invariant its images satisfy.

      Equations
      Instances For
        Dependency graph

        Strengthen the target of an ordered reduction by an invariant its images satisfy.

        Equations
        Instances For
          Dependency graph

          Conjoining a sentence into a second-order definition #

          Dependency graph

          A sentence of the base language, lifted to the language of a kernel: the symbols are unchanged, only their address in the iterated sum grows.

          Equations
          Instances For
            Dependency graph

            Conjoining a first-order sentence preserves Σₖ-definability: the sentence joins the kernel, lifted along the block languages. This is the membership half of restricting a problem to its well-formed instances.

            Dependency graph

            Faithfulness for the restricted problem #

            theorem DescriptiveComplexity.Encoding.Faithful.inf {L : FirstOrder.Language} [L.IsRelational] {ι : Type u_1} {e : Encoding L ι} {Conc : ιProp} {P : DecisionProblem L} (hf : e.Faithful Conc P) (W : DecisionProblem L) (hW : ∀ (i : ι), W.Holds (e.Univ i)) :
            e.Faithful Conc (WP)

            A faithful encoding whose images are all well-formed is faithful for the restricted problem: the completeness theorem for W ⊓ P reads back to the same concrete predicate.

            Dependency graph

            Concretely presented structures and computable decodings #

            A concretely presented finite L-structure: a size and a computable relation table. This is the input type of decoders – the “raw bytes” a decoding computation reads.

            Instances For
              Dependency graph
              @[instance_reducible]

              The L-structure a presentation presents.

              Equations
              Dependency graph
              Dependency graph

              Any nonempty finite structure, presented concretely (classically: the presentation decides the relations by choice, which is fine for the Prop-level transport below – actual decoders never see it).

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                Dependency graph

                The presented structure is isomorphic to the original one.

                Equations
                Instances For
                  Dependency graph
                  structure DescriptiveComplexity.Decoding (L : FirstOrder.Language) [L.IsRelational] {ι : Type u_1} (W : DecisionProblem L) (Conc : ιProp) (P : DecisionProblem L) :
                  Type u_1

                  A computable decoding of well-formed structures into concrete instances: the converse of an encoding, with the same hygiene. dec is a plain computation from presented structures to Option ι – returning none is the junk case, so there are no proof-carrying arguments and the decoder can be run and #guard-tested; sound says decoded instances are equidecided with the structure they came from; total says well-formed nonempty presentations always decode. See the module docstring for why the bundled function, and not a ∀∃ statement, is the meaningful notion.

                  Instances For
                    Dependency graph
                    theorem DescriptiveComplexity.Decoding.exists_conc_iff {L : FirstOrder.Language} [L.IsRelational] {ι : Type u_1} {W : DecisionProblem L} {Conc : ιProp} {P : DecisionProblem L} (d : Decoding L W Conc P) (A : Type) [L.Structure A] [Finite A] [Nonempty A] (hW : W.Holds A) :
                    ∃ (i : ι), Conc i P.Holds A

                    Well-formed structures are semantically concrete: along a decoding, every well-formed nonempty finite structure is decided by the abstract problem exactly as some concrete instance is by the concrete semantics. This is the honest form of the removed Encoding.CoversUpTo – honest because it is derived from the bundled computation, not established by casing on P A.

                    Dependency graph