Documentation

CslibFrontier.Logics.FirstOrder.FiniteVariable.Basic

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 #

Main results #

References #

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.

  • eval : Q → (M → Prop) → Prop

    Whether the predicate p : M → Prop satisfies the quantifier q.

  • eval_congr (q : Q) {p p' : M → Prop} : (∀ (c : M), p c ↔ p' c) → (eval q p ↔ eval q p')

    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 ∃.

      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.

        Instances For

          Existential quantification of the variable xᵢ.

          Universal quantification of the variable xᵢ, as ¬∃ xᵢ ¬φ.

          @[instance_reducible]
          @[instance_reducible]
          @[instance_reducible]
          @[instance_reducible]
          noncomputable def Cslib.Logic.FO.FiniteVariable.GenFormula.iInf {Q : Type} {L : FirstOrder.Language} {k : ℕ} {β : Type u_1} [Finite β] (f : β → GenFormula Q L k) :

          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.

          noncomputable def Cslib.Logic.FO.FiniteVariable.GenFormula.iSup {Q : Type} {L : FirstOrder.Language} {k : ℕ} {β : Type u_1} [Finite β] (f : β → GenFormula Q L k) :

          The disjunction of a finite family of formulas, as the negation of the conjunction of the negations.

          Semantics #

          def Cslib.Logic.FO.FiniteVariable.GenFormula.Realize {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] :
          GenFormula Q L k → (Fin k → M) → Prop

          Truth of a formula in M under the assignment a of elements to the k variables.

          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_equal {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] (i j : Fin k) (a : Fin k → M) :
          (equal i j).Realize a ↔ a i = a j
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_rel {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] {l : ℕ} (R : L.Relations l) (f : Fin l → Fin k) (a : Fin k → M) :
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_imp {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] (φ ψ : GenFormula Q L k) (a : Fin k → M) :
          (φ.imp ψ).Realize a ↔ φ.Realize a → ψ.Realize a
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_quant {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] (q : Q) (i : Fin k) (φ : GenFormula Q L k) (a : Fin k → M) :
          (quant q i φ).Realize a ↔ Quantifier.eval q fun (c : M) => φ.Realize (Function.update a i c)
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_not {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] (φ : GenFormula Q L k) (a : Fin k → M) :
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_ex {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] [ExQuantTag Q] [LawfulExQuant Q M] (i : Fin k) (φ : GenFormula Q L k) (a : Fin k → M) :
          (ex i φ).Realize a ↔ ∃ (c : M), φ.Realize (Function.update a i c)
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_all {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] [ExQuantTag Q] [LawfulExQuant Q M] (i : Fin k) (φ : GenFormula Q L k) (a : Fin k → M) :
          (all i φ).Realize a ↔ ∀ (c : M), φ.Realize (Function.update a i c)
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_inf {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] (φ ψ : GenFormula Q L k) (a : Fin k → M) :
          (φ ⊓ ψ).Realize a ↔ φ.Realize a ∧ ψ.Realize a
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_sup {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] (φ ψ : GenFormula Q L k) (a : Fin k → M) :
          (φ ⊔ ψ).Realize a ↔ φ.Realize a ∨ ψ.Realize a
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_iInf {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] {β : Type u_1} [Finite β] (f : β → GenFormula Q L k) (a : Fin k → M) :
          (iInf f).Realize a ↔ ∀ (b : β), (f b).Realize a
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_iSup {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] {β : Type u_1} [Finite β] (f : β → GenFormula Q L k) (a : Fin k → M) :
          (iSup f).Realize a ↔ ∃ (b : β), (f b).Realize a

          Quantifier rank #

          The quantifier rank of a formula: the maximal nesting depth of its quantifiers.

          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.quantifierRank_iInf_le {Q : Type} {L : FirstOrder.Language} {k : ℕ} {β : Type u_1} [Finite β] {f : β → GenFormula Q L k} {m : ℕ} (h : ∀ (b : β), (f b).quantifierRank ≤ m) :

          A finite conjunction has quantifier rank at most m when each conjunct does.

          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.quantifierRank_iSup_le {Q : Type} {L : FirstOrder.Language} {k : ℕ} {β : Type u_1} [Finite β] {f : β → GenFormula Q L k} {m : ℕ} (h : ∀ (b : β), (f b).quantifierRank ≤ m) :

          A finite disjunction has quantifier rank at most m when each disjunct does.

          Free variables #

          The free variables of a formula.

          @[simp]
          @[simp]
          @[simp]
          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.freeVars_iInf_subset {Q : Type} {L : FirstOrder.Language} {k : ℕ} {β : Type u_1} [Finite β] {f : β → GenFormula Q L k} {S : Set (Fin k)} (h : ∀ (b : β), ↑(f b).freeVars ⊆ S) :
          ↑(iInf f).freeVars ⊆ S

          The free variables of a finite conjunction lie in S when those of each conjunct do.

          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.freeVars_iSup_subset {Q : Type} {L : FirstOrder.Language} {k : ℕ} {β : Type u_1} [Finite β] {f : β → GenFormula Q L k} {S : Set (Fin k)} (h : ∀ (b : β), ↑(f b).freeVars ⊆ S) :
          ↑(iSup f).freeVars ⊆ S

          The free variables of a finite disjunction lie in S when those of each disjunct do.

          theorem Cslib.Logic.FO.FiniteVariable.GenFormula.realize_congr {Q : Type} {L : FirstOrder.Language} {k : ℕ} {M : Type w} [L.Structure M] [Quantifier Q M] {φ : GenFormula Q L k} {a a' : Fin k → M} (h : ∀ i ∈ φ.freeVars, a i = a' i) :
          φ.Realize a ↔ φ.Realize a'

          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_{∞ω}.

          Instances For
            @[simp]
            @[reducible, inline]

            Formulas of the k-variable fragment FO^k over the relation symbols of L. The variables are Fin k, and ex i φ / all i φ quantify the variable i, which may already be bound or free in an enclosing formula.

            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 φ.

            @[simp]

            The translation of a formula holds of an assignment exactly when the formula does.