Finite-variable first-order logic #
The k-variable fragment FO^k of first-order logic consists of the formulas that use at most k
distinct variable names, each of which may be quantified again inside its own scope. Reusing names
gives these formulas more power than their number of variables suggests: on linear orders, a
formula with two variables can say that there are at least n elements, for every n
([Lib04], formula (11.4)).
Mathlib's FirstOrder.Language.BoundedFormula gives every quantifier a fresh de Bruijn index, so
it cannot say that two quantifiers bind the same variable. This file introduces a quantifier-generic
syntax Cslib.Logic.FO.FiniteVariable.GenFormula Q L k whose variables are Fin k and whose
single-variable quantifiers come from Q (Quantifier), and instantiates it at ExistentialQuant
to obtain Cslib.Logic.FO.FiniteVariable.Formula L k (FO^k). In Counting.lean, instantiating
the same syntax at CountingQuant yields CountingFormula L k (C^k) without duplicating derived
connectives, semantics, quantifier rank, free variables or congruence. The translation
Formula.toFormula into Mathlib's L.Formula (Fin k) preserves truth (Formula.realize_toFormula)
and quantifier rank (Formula.quantifierRank_toFormula), so FO^k is a fragment of ordinary
first-order logic.
As in [Lib04] and [Imm99], the vocabulary is relational: atomic formulas are equations
between variables and relation symbols applied to variables. Function and constant symbols of L
are simply not used, so the language need not be relational.
Main definitions #
Cslib.Logic.FO.FiniteVariable.Quantifier: extensional semantics for single-variable quantifiers.Cslib.Logic.FO.FiniteVariable.GenFormula:k-variable formulas parameterized by a quantifier kindQ, withGenFormula.Realize,GenFormula.quantifierRank,GenFormula.freeVars,GenFormula.not,GenFormula.ex,GenFormula.all,GenFormula.iInf, andGenFormula.iSup.Cslib.Logic.FO.FiniteVariable.Formula: formulas ofFO^kover the relation symbols ofL.Cslib.Logic.FO.FiniteVariable.Formula.toFormula: the translation ofFormulato Mathlib's formulas.
Main results #
Cslib.Logic.FO.FiniteVariable.GenFormula.realize_congr: truth depends only on the values of the free variables.Cslib.Logic.FO.FiniteVariable.Formula.realize_toFormula,Cslib.Logic.FO.FiniteVariable.Formula.quantifierRank_toFormula: the translation preserves truth and quantifier rank.
References #
- L. Libkin, Elements of Finite Model Theory, Section 11.1, Definition 11.1.
- N. Immerman, Descriptive Complexity, Definition 6.9.
Extensional single-variable quantifiers #
Semantics of a single-variable quantifier kind Q over a domain M. Each quantifier
evaluates a unary predicate on M and respects extensionality.
Whether the predicate
p : M → Propsatisfies the quantifierq.Quantifiers depend only on the extension of the predicate.
Instances
Distinguished existential quantifier tag equipping GenFormula Q L k and
InfinitaryGenFormula Q L k with ex and all.
- exQuant : Q
The quantifier tag representing
∃.
Instances
Semantic lawfulness for ExQuantTag: exQuant evaluates as ∃.
ExQuantTag.exQuantholds ofpiff some element satisfiesp.
Instances
Quantifier-parameterized k-variable syntax #
Formulas of a k-variable relational logic over L with single-variable quantifiers Q.
Variables are Fin k, and quant q i φ rebinds xᵢ inside its scope.
- falsum {Q : Type} {L : FirstOrder.Language} {k : ℕ} : GenFormula Q L k
Falsity.
- equal {Q : Type} {L : FirstOrder.Language} {k : ℕ} (i j : Fin k) : GenFormula Q L k
The equation
xᵢ = xⱼ. - rel {Q : Type} {L : FirstOrder.Language} {k l : ℕ} (R : L.Relations l) (f : Fin l → Fin k) : GenFormula Q L k
The relation
Rapplied to the variablesx_{f 0}, …, x_{f (l - 1)}. - imp {Q : Type} {L : FirstOrder.Language} {k : ℕ} (φ ψ : GenFormula Q L k) : GenFormula Q L k
Implication.
- quant {Q : Type} {L : FirstOrder.Language} {k : ℕ} (q : Q) (i : Fin k) (φ : GenFormula Q L k) : GenFormula Q L k
Quantification of
xᵢbyq : Q.
Instances For
Negation.
Existential quantification of the variable xᵢ.
Universal quantification of the variable xᵢ, as ¬∃ xᵢ ¬φ.
The conjunction of a finite family of formulas. Like Mathlib's
FirstOrder.Language.BoundedFormula.iInf, it is defined through an arbitrary enumeration of the
index type, so only its truth, rank and free variables are determined.
The disjunction of a finite family of formulas, as the negation of the conjunction of the negations.
Semantics #
Truth of a formula in M under the assignment a of elements to the k variables.
Quantifier rank #
The quantifier rank of a formula: the maximal nesting depth of its quantifiers.
A finite conjunction has quantifier rank at most m when each conjunct does.
A finite disjunction has quantifier rank at most m when each disjunct does.
Free variables #
The free variables of a formula.
The free variables of a finite conjunction lie in S when those of each conjunct do.
The free variables of a finite disjunction lie in S when those of each disjunct do.
The truth of a formula depends only on the values of its free variables.
FO^k: finite-variable first-order logic #
The single existential quantifier tag of FO^k and L^k_{∞ω}.
- ex : ExistentialQuant
Existential quantification
∃.
Instances For
Translation of FO^k to Mathlib's first-order formulas #
The translation of a formula of FO^k into Mathlib's L.Formula (Fin k): the variable i
becomes the free variable i, and ex i φ quantifies over a fresh bound variable which replaces
i in the translation of φ.
The translation of a formula holds of an assignment exactly when the formula does.
The translation preserves quantifier rank.