First-order interpretations and FO reductions #
Complexity theory is essentially absent from Mathlib because formalizing a
machine model of computation (and resource bounds on it) is hard. However, many
classical NP-hardness reductions do not need the full power of polynomial-time
computation: the reduction is first-order expressible – the output structure
can be described by fixed first-order formulas evaluated in the input
structure. Such FO reductions are computable in AC⁰ ⊆ LOGSPACE ⊆ PTIME, so
exhibiting an FO reduction is (much) stronger than exhibiting a Karp
reduction (Karp 1972), while being completely
machine-model-free and therefore easy to
formalize on top of Mathlib's ModelTheory library.
This file defines:
DescriptiveComplexity.DecisionProblem L: a “problem” over the vocabularyL, i.e. a property ofL-structures;DescriptiveComplexity.FOInterpretation L L' Tag dim: a tagged,dim-dimensional first-order interpretation of a relational languageL'in a languageL, mapping everyL-structureAto anL'-structureI.Map Awith universeTag × (Fin dim → A);DescriptiveComplexity.FOInterpretation.IsQuantifierFree: interpretations all of whose defining formulas are quantifier-free (an even weaker reduction notion);DescriptiveComplexity.FOReduction P Q: an FO reduction from problemPto problemQ, i.e. an interpretation mapping yes-instances ofPexactly to yes-instances ofQ.
Design notes #
The textbook notion of FO reduction maps a structure A to a structure with
universe a definable subset of A^k, using a linear order on A to encode
constantly many “sorts” of elements. To stay order-free and subset-free we
instead tag tuples with elements of a finite type Tag, and use the full
universe Tag × A^dim: junk elements are harmless in practice because the
defining formulas can exclude them from all relations. Every tagged
interpretation can be converted into a textbook k-ary FO reduction on
ordered structures (using the order to encode constantly many tags), so the
notion formalized here is a genuine form of FO reducibility.
The universe of I.Map A is Tag × (Fin dim → A), which is finite whenever
A and Tag are (FOInterpretation.map_finite): FO reductions map finite
structures to finite structures, as required for reductions between decision
problems on finite structures.
Following the usual convention of finite model theory, reductions are only required to be correct on nonempty structures (and their tag types are required to be nonempty, so that nonempty structures map to nonempty structures). Empty structures are degenerate: no fixed-dimension interpretation can produce a nonempty structure from an empty one, so e.g. no problem that is false on an empty structure could reduce to SAT (whose empty instance is trivially satisfiable), and hardness results would fail for spurious reasons.
A decision problem in the sense of descriptive complexity: an
isomorphism-closed property of L-structures, whose yes-instances are the
L-structures satisfying it. Isomorphism-invariance is part of the notion –
a decision problem cannot distinguish isomorphic presentations of the same
structure.
The predicate:
P A(through the function coercion) states that the structureAis a yes-instance.- iso_invariant {A B : Type} [L.Structure A] [L.Structure B] : ∀ (a : L.Equiv A B), self.Holds A ↔ self.Holds B
Decision problems do not distinguish isomorphic structures.
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Transport of relations along isomorphisms #
Proving the iso_invariant field of a DecisionProblem always starts the
same way: the semantic property is phrased in terms of RelMap r ![a] /
RelMap r ![a, b], and one must know that these transport along an
L-isomorphism. The two lemmas below package this step once and for all
(Mathlib's StrongHomClass.map_rel states it with e ∘ ![a, b], which
must first be normalized to ![e a, e b]).
A unary relation transports along an L-isomorphism.
Dependency graph
A binary relation transports along an L-isomorphism.
Dependency graph
A ternary relation transports along an L-isomorphism.
Dependency graph
Realization of an atom of arity 3, the shape Mathlib's
Formula.realize_rel₁ and Formula.realize_rel₂ stop short of.
Dependency graph
Realization of an atom of arity 4.
Dependency graph
A tagged dim-dimensional first-order interpretation of the relational
language L' in the language L. It maps an L-structure A to the
L'-structure with universe Tag × A^dim in which an n-ary relation symbol
R holds of tagged tuples (t₁, ā₁), …, (tₙ, āₙ) iff the first-order
L-formula relFormula R (t₁, …, tₙ) – whose free variable (i, j) stands
for the j-th coordinate āᵢ j of the i-th argument – holds in A.
The defining
L-formula of each relation symbol ofL', for each tuple of tags; the free variable(i, j)is thej-th coordinate of thei-th argument tuple.
Instances For
Dependency graph
The universe of the structure interpreted in A: tagged dim-tuples.
This is a plain def (not an abbrev) so that the L'.Structure instance on
it can be found by instance search, while rcases-style destructuring still
sees through it.
Instances For
Dependency graph
The L'-structure interpreted in the L-structure A.
Equations
- One or more equations did not get rendered due to their size.
Dependency graph
Dependency graph
FO interpretations map finite structures to finite structures.
Dependency graph
FO interpretations with nonempty tags map nonempty structures to nonempty structures.
Dependency graph
An interpretation is quantifier-free if all its defining formulas are. Quantifier-free reductions are the weakest reduction notion in common use in descriptive complexity; SAT remains NP-complete under them.
Equations
- I.IsQuantifierFree = ∀ {n : ℕ} (R : L'.Relations n) (t : Fin n → Tag), FirstOrder.Language.BoundedFormula.IsQF (I.relFormula R t)
Instances For
Dependency graph
A first-order reduction from the problem P (on L-structures) to the
problem Q (on L'-structures): a first-order interpretation mapping
yes-instances of P exactly to yes-instances of Q.
Since FO interpretations are computable in AC⁰ ⊆ PTIME on (encodings of)
finite structures, an FOReduction P Q is in particular a Karp reduction from
P to Q: any NP-hardness argument for P transfers to Q, without any
formalized machine model.
- Tag : Type
The tags (copies of
A^dim) used by the underlying interpretation. Tags are finite, so that finite structures map to finite structures.
Tags are nonempty, so that nonempty structures map to nonempty structures.
- dim : ℕ
The dimension of the underlying interpretation.
- toInterpretation : FOInterpretation L L' self.Tag self.dim
The underlying first-order interpretation.
- correct (A : Type) [L.Structure A] [Finite A] [Nonempty A] : P.Holds A ↔ Q.Holds (self.toInterpretation.Map A)
Yes-instances map exactly to yes-instances, on the finite nonempty structures: membership and hardness read a problem only there (
DescriptiveComplexity.ComplexityClass), so asking anything of the infinite ones would be an obligation nothing consumes. The ordered and relativized notions restrict the same way.
Instances For
Dependency graph
A first-order reduction from the problem P (on L-structures) to the
problem Q (on L'-structures): a first-order interpretation mapping
yes-instances of P exactly to yes-instances of Q.
Since FO interpretations are computable in AC⁰ ⊆ PTIME on (encodings of)
finite structures, an FOReduction P Q is in particular a Karp reduction from
P to Q: any NP-hardness argument for P transfers to Q, without any
formalized machine model.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
For a one-dimensional interpretation with a single tag, the interpreted universe is equivalent, as a plain type, to the original universe.
Equations
Instances For
Dependency graph
Interpretations are functorial on isomorphisms: an L-isomorphism of the
base structures induces an L'-isomorphism of the interpreted structures.
Equations
- One or more equations did not get rendered due to their size.