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:
- hardness: a reduction into
Pwhose images are all well-formed is a reduction intoW ⊓ P–DescriptiveComplexity.FOReduction.withInvariant/DescriptiveComplexity.OrderedFOReduction.withInvariantturn the existing reduction plus an image lemma into the strengthened one; - membership:
DescriptiveComplexity.SigmaSODefinable.inf_ofSentenceconjoins the sentenceWinto the existingΣ₁kernel.
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
dec : FinPresentation L → Option ι– from concretely presented finite structures (DescriptiveComplexity.FinPresentation: a size and aBool-valued relation table) to concrete instances,nonebeing the junk case, so no proof-carrying arguments and no partiality tricks;sound– whateverdecreturns is decided byConcexactly as the presented structure is byP;total– on well-formed (nonempty) presentations,decreturns something.
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 #
DescriptiveComplexity.DecisionProblem.ofSentence: a first-order sentence as a decision problem, the usual shape of a well-formedness condition;- the
Mininstance onDescriptiveComplexity.DecisionProblem, giving the restrictionW ⊓ P; DescriptiveComplexity.FOReduction.withInvariantandDescriptiveComplexity.OrderedFOReduction.withInvariant: strengthen a reduction's target by an invariant its images satisfy;DescriptiveComplexity.SigmaSODefinable.inf_ofSentence: conjoin a first-order sentence into aΣₖdefinition;DescriptiveComplexity.Encoding.Faithful.inf: encoded instances that are well-formed are faithful for the restricted problem;DescriptiveComplexity.FinPresentationandDescriptiveComplexity.Decoding: concretely presented structures and computable decodings, withDescriptiveComplexity.Decoding.exists_conc_iffas theProp-level consequence.
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
- f.withInvariant W h = { Tag := f.Tag, tagFinite := ⋯, tagNonempty := ⋯, dim := f.dim, toInterpretation := f.toInterpretation, correct := ⋯ }
Instances For
Dependency graph
Strengthen the target of an ordered reduction by an invariant its images satisfy.
Equations
- f.withInvariant W h = { Tag := f.Tag, tagFinite := ⋯, tagNonempty := ⋯, dim := f.dim, toInterpretation := f.toInterpretation, correct := ⋯ }
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
- DescriptiveComplexity.soLift [] x✝ = x✝
- DescriptiveComplexity.soLift (head :: Bs) x✝ = DescriptiveComplexity.soLift Bs (FirstOrder.Language.LHom.sumInl.onSentence x✝)
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 #
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.
- card : ℕ
The number of elements.
Instances For
Dependency graph
The L-structure a presentation presents.
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
- DescriptiveComplexity.FinPresentation.equivOfStructure A = { toEquiv := Fintype.equivFin A, map_fun' := ⋯, map_rel' := ⋯ }
Instances For
Dependency graph
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.
- dec : FinPresentation L → Option ι
The decoder: a computation from presented structures to concrete instances,
noneon junk. Keep it a plaindef-legible field, as forEncoding.relBool. Decoded instances are decided by the concrete semantics exactly as the presented structure is by the abstract problem.
Well-formed nonempty presentations always decode.
Instances For
Dependency graph
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.