Local formulas and basic local sentences

Lax185574.LocalFormulas · concepts/Lax185574/LocalFormulas.lean · lax-185574

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    Fix a finite relational signature σ of arity α. Two σ-formulas φ(x̄) and ψ(x̄) are equivalent if for every σ-structure A and every tuple ā ∈ V(A)^{|x̄|}, A ⊨ φ(ā) if and only if A ⊨ ψ(ā).

    The formula adj_σ(x₁, x₂) tests whether x₁ and x₂ are adjacent in the Gaifman graph. For every relation R ∈ σ of arity β ≤ α it tests whether there are elements x₃, …, x_β such that some permutation of x₁, …, x_β satisfies R. Its quantifier rank is at most α − 2. From it one derives the formula dist(x₁, x₂) ≤ r, which checks whether x₁ and x₂ have distance at most r in the Gaifman graph. It quantifies the candidate vertices of a path and checks the required adjacencies in parallel, so its quantifier rank is at most r + α.

    A σ-formula φ(x̄) is r-local if every quantifier appearing in φ(x̄) is of the form ∀y ∈ Ball_s(x̄) or ∃y ∈ Ball_s(x̄) for some s ≤ r, where the ball checks are implemented using the dist formulas, which are exempt from this condition. A sentence ψ is basic r-local if there is some r' ≤ r such that ψ is of the form

    ∃x₁, …, x_m ( ⋀{1 ≤ i < j ≤ m} dist(xᵢ, xⱼ) > 2r' ∧ ⋀{1 ≤ i ≤ m} φ(xᵢ) )

    for an r'-local formula φ.

    Concept map
    2 concepts; 2 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    In the paper

    • page 62 of this submission's paper

    Lean source view on GitHub

    1import Lax185574.GaifmanGraph
    2import Mathlib.ModelTheory.Satisfiability
    3import Mathlib.Logic.Equiv.Fin.Basic
    4
    5/-!
    6---
    7title: Local formulas and basic local sentences
    8type: definition
    9---
    10Fix a finite relational signature σ of arity α. Two σ-formulas φ(x̄)
    11and ψ(x̄) are *equivalent* if for every σ-structure A and every tuple
    12ā ∈ V(A)^{|x̄|}, A ⊨ φ(ā) if and only if A ⊨ ψ(ā).
    13
    14The formula adj_σ(x₁, x₂) tests whether x₁ and x₂ are adjacent in the
    15Gaifman graph. For every relation R ∈ σ of arity β ≤ α it tests whether
    16there are elements x₃, …, x_β such that some permutation of x₁, …, x_β
    17satisfies R. Its quantifier rank is at most α − 2. From it one derives
    18the formula dist(x₁, x₂) ≤ r, which checks whether x₁ and x₂ have
    19distance at most r in the Gaifman graph. It quantifies the candidate
    20vertices of a path and checks the required adjacencies in parallel, so
    21its quantifier rank is at most r + α.
    22
    23A σ-formula φ(x̄) is *r-local* if every quantifier appearing in φ(x̄) is
    24of the form ∀y ∈ Ball_s(x̄) or ∃y ∈ Ball_s(x̄) for some s ≤ r, where the
    25ball checks are implemented using the dist formulas, which are exempt
    26from this condition. A sentence ψ is *basic r-local* if there is some
    27r' ≤ r such that ψ is of the form
    28
    29 ∃x₁, …, x_m ( ⋀_{1 ≤ i < j ≤ m} dist(xᵢ, xⱼ) > 2r' ∧ ⋀_{1 ≤ i ≤ m} φ(xᵢ) )
    30
    31for an r'-local formula φ.
    32
    33# Formalization notes
    34
    35Formulas are mathlib's, `L.Formula (Fin k)` for formulas with free
    36variables x₁, …, x_k, and `L.BoundedFormula (Fin k) n` for their
    37subformulas with n further bound variables. A finite relational
    38signature is a relational language with finitely many relation symbols
    39in total. The arity bound α plays no role in the definitions.
    40
    41Equivalence quantifies over all structures whose domain lies in one
    42universe, which is an explicit parameter of the definition. The domains
    43may be empty or infinite.
    44
    45adj_σ is the conjunction of x₁ ≠ x₂ with the disjunction, over the
    46relation symbols R of arity β ≥ 2, of ∃x₃ … ∃x_β ⋁_π R(x_{π(1)}, …,
    47x_{π(β)}), where π ranges over the permutations of the β positions. The
    48quantified variables may coincide with x₁, x₂ or each other, so this is
    49exactly adjacency in the Gaifman graph. Symbols of arity at most one
    50contribute nothing. Its quantifier rank is at most α − 2.
    51
    52dist(x₁, x₂) ≤ r quantifies the r vertices v₁, …, v_r of a walk
    53x₁ = v₀, v₁, …, v_r, requires v_r = x₂, and requires every step to be
    54an equality or an adjacency. So it holds exactly if a walk of length at
    55most r joins x₁ and x₂, as in `GaifmanGraph.WithinDist`. Its quantifier
    56rank is at most r plus that of adj_σ, so at most r + α. For r = 0 it is
    57equivalent to the equality x₁ = x₂.
    58
    59Finite disjunctions and conjunctions are mathlib's `iSup` and `iInf`.
    60They fix some order of the members, which affects neither the meaning
    61nor the quantifier rank. A formula over the variables x₁, x₂ is placed
    62at given terms by substitution.
    63
    64The guard of a quantifier over Ball_s(x̄) is the disjunction over i of
    65dist(xᵢ, y) ≤ s, where y is the newly bound variable. For a formula
    66without free variables, the ball is empty and the guard is falsum. A
    67local formula is built from atoms by falsum and implication, which give
    68all Boolean connectives, and by the guarded quantifiers
    69∀y (guard → φ) and ∃y (guard ∧ φ). The inner formulas of a local
    70formula may have more free variables than x̄, namely the bound
    71variables, but the balls are always taken around x̄. The dist formulas
    72inside the guards are exempt, exactly as in the paper.
    73
    74In a basic local sentence the m witnesses are the m bound variables of
    75an existential block, and "dist(xᵢ, xⱼ) > 2r'" is the negation of the
    76dist formula of radius 2r'. The case m = 0 is allowed and gives a true
    77sentence.
    78-/
    79
    80namespace Lax185574.LocalFormulas
    81
    82open FirstOrder FirstOrder.Language
    83
    84universe u v w a
    85
    86variable {L : Language.{u, v}}
    87
    88/-- Two formulas are *equivalent* if they hold of the same tuples in
    89every structure whose domain lies in the universe `w`. -/
    90def Equivalent {α : Type a} (φ ψ : L.Formula α) : Prop :=
    91 ∀ (M : Type w) [L.Structure M] (x : α → M), φ.Realize x ↔ ψ.Realize x
    92
    93/-- Two formulas are *equivalent on finite structures* if they hold of
    94the same tuples in every finite structure whose domain lies in the
    95universe `w`. -/
    96def FinitelyEquivalent {α : Type a} (φ ψ : L.Formula α) : Prop :=
    97 ∀ (M : Type w) [Finite M] [L.Structure M] (x : α → M), φ.Realize x ↔ ψ.Realize x
    98
    99/-- The formula `φ(x₁, …, x_j)` with each `xᵢ` replaced by the term
    100`t i`, as a subformula with `n` bound variables in scope. -/
    101def instantiate {β : Type*} {j n : ℕ} (φ : L.Formula (Fin j))
    102 (t : Fin j → L.Term (β ⊕ Fin n)) : L.BoundedFormula β n :=
    103 (φ.subst t).relabel id
    104
    105/-- The variable term in position `m` of a relation atom in `adj_σ`:
    106positions `0` and `1` are `x₁` and `x₂`, and position `m ≥ 2` is the
    107bound variable `x_{m+1}`. -/
    108def adjSlot {l : ℕ} (m : Fin l) : L.Term (Fin 2 ⊕ Fin (l - 2)) :=
    109 if h : m.val < 2 then Term.var (Sum.inl ⟨m.val, h⟩)
    110 else Term.var (Sum.inr ⟨m.val - 2, by omega⟩)
    111
    112/-- The part of `adj_σ` for one relation symbol `R` of arity `l`:
    113`∃x₃ … ∃x_l ⋁_π R(x_{π(1)}, …, x_{π(l)})` if `l ≥ 2`, and falsum
    114otherwise. -/
    115noncomputable def adjVia {l : ℕ} (R : L.Relations l) : L.Formula (Fin 2) :=
    116 if 2 ≤ l then
    117 BoundedFormula.exs
    118 (BoundedFormula.iSup fun π : Equiv.Perm (Fin l) =>
    119 BoundedFormula.rel R fun m => adjSlot (π m))
    120 else ⊥
    121
    122variable (L) in
    123/-- `adj_σ(x₁, x₂)`: the formula stating that `x₁` and `x₂` are adjacent
    124in the Gaifman graph. -/
    125noncomputable def adjFormula [Finite (Σ l, L.Relations l)] : L.Formula (Fin 2) :=
    126 ∼((Term.var (Sum.inl 0)).bdEqual (Term.var (Sum.inl 1))) ⊓
    127 BoundedFormula.iSup fun R : Σ l, L.Relations l => adjVia R.2
    128
    129/-- The vertex `v_i` of the walk quantified in `dist(x₁, x₂) ≤ r`:
    130`v₀ = x₁`, and `v_i` for `i ≥ 1` is the `i`-th bound variable. -/
    131def walkVertex {r : ℕ} (i : Fin (r + 1)) : L.Term (Fin 2 ⊕ Fin r) :=
    132 Fin.cases (motive := fun _ => L.Term (Fin 2 ⊕ Fin r))
    133 (Term.var (Sum.inl 0)) (fun j => Term.var (Sum.inr j)) i
    134
    135variable (L) in
    136/-- `dist(x₁, x₂) ≤ r`: there are `v₁, …, v_r` with `v_r = x₂` such that
    137each step of `x₁ = v₀, v₁, …, v_r` is an equality or an adjacency. -/
    138noncomputable def distFormula [Finite (Σ l, L.Relations l)] (r : ℕ) :
    139 L.Formula (Fin 2) :=
    140 BoundedFormula.exs
    141 (((walkVertex (L := L) (Fin.last r)).bdEqual (Term.var (Sum.inl 1))) ⊓
    142 BoundedFormula.iInf fun i : Fin r =>
    143 ((walkVertex (L := L) i.castSucc).bdEqual (walkVertex i.succ)) ⊔
    144 instantiate (adjFormula L) ![walkVertex i.castSucc, walkVertex i.succ])
    145
    146variable (L) in
    147/-- The guard `y ∈ Ball_s(x̄)` of a local quantifier, where `x̄` are the
    148`k` free variables and `y` is the newly bound variable: the disjunction
    149over `i` of `dist(xᵢ, y) ≤ s`. -/
    150noncomputable def ballGuard [Finite (Σ l, L.Relations l)] (k s n : ℕ) :
    151 L.BoundedFormula (Fin k) (n + 1) :=
    152 BoundedFormula.iSup fun i : Fin k =>
    153 instantiate (distFormula L s) ![Term.var (Sum.inl i), Term.var (Sum.inr (Fin.last n))]
    154
    155/-- `IsLocal r φ`: the formula `φ` with free variables `x̄ = x₁, …, x_k`
    156and `n` further bound variables in scope is `r`-local. It is built from
    157atoms by falsum, implication and quantifiers guarded by `Ball_s(x̄)` for
    158some `s ≤ r`. -/
    159inductive IsLocal [Finite (Σ l, L.Relations l)] (r : ℕ) {k : ℕ} :
    160 {n : ℕ} → L.BoundedFormula (Fin k) n → Prop
    161 /-- Falsum is local. -/
    162 | falsum {n : ℕ} : IsLocal r (BoundedFormula.falsum : L.BoundedFormula (Fin k) n)
    163 /-- Equality atoms are local. -/
    164 | equal {n : ℕ} (t₁ t₂ : L.Term (Fin k ⊕ Fin n)) :
    165 IsLocal r (BoundedFormula.equal t₁ t₂)
    166 /-- Relation atoms are local. -/
    167 | rel {n l : ℕ} (R : L.Relations l) (ts : Fin l → L.Term (Fin k ⊕ Fin n)) :
    168 IsLocal r (BoundedFormula.rel R ts)
    169 /-- Implications of local formulas are local. -/
    170 | imp {n : ℕ} {φ ψ : L.BoundedFormula (Fin k) n} :
    171 IsLocal r φ → IsLocal r ψ → IsLocal r (φ.imp ψ)
    172 /-- `∀y ∈ Ball_s(x̄) φ`, that is `∀y (y ∈ Ball_s(x̄) → φ)`, for `s ≤ r`. -/
    173 | all {n s : ℕ} {φ : L.BoundedFormula (Fin k) (n + 1)} :
    174 s ≤ r → IsLocal r φ → IsLocal r (∀' (ballGuard L k s n ⟹ φ))
    175 /-- `∃y ∈ Ball_s(x̄) φ`, that is `∃y (y ∈ Ball_s(x̄) ∧ φ)`, for `s ≤ r`. -/
    176 | ex {n s : ℕ} {φ : L.BoundedFormula (Fin k) (n + 1)} :
    177 s ≤ r → IsLocal r φ → IsLocal r (∃' (ballGuard L k s n ⊓ φ))
    178
    179variable (L) in
    180/-- The sentence `∃x₁, …, x_m (⋀_{i < j} dist(xᵢ, xⱼ) > 2r' ∧ ⋀_i φ(xᵢ))`. -/
    181noncomputable def basicLocalSentence [Finite (Σ l, L.Relations l)] (r' m : ℕ)
    182 (φ : L.Formula (Fin 1)) : L.Sentence :=
    183 BoundedFormula.exs
    184 ((BoundedFormula.iInf fun p : {p : Fin m × Fin m // p.1 < p.2} =>
    185 ∼(instantiate (distFormula L (2 * r'))
    186 ![Term.var (Sum.inr p.1.1), Term.var (Sum.inr p.1.2)])) ⊓
    187 BoundedFormula.iInf fun i : Fin m => instantiate φ ![Term.var (Sum.inr i)])
    188
    189/-- `IsBasicLocal r ψ`: the sentence `ψ` is basic `r`-local. -/
    190def IsBasicLocal [Finite (Σ l, L.Relations l)] (r : ℕ) (ψ : L.Sentence) : Prop :=
    191 ∃ r' ≤ r, ∃ (m : ℕ) (φ : L.Formula (Fin 1)),
    192 IsLocal r' φ ∧ ψ = basicLocalSentence L r' m φ
    193
    194end Lax185574.LocalFormulas
    195
    Formalization notes

    Formulas are mathlib's, L.Formula(Fink)L.Formula (Fin k) for formulas with free variables x₁, …, x_k, and L.BoundedFormula(Fink)nL.BoundedFormula (Fin k) n for their subformulas with n further bound variables. A finite relational signature is a relational language with finitely many relation symbols in total. The arity bound α plays no role in the definitions.

    Equivalence quantifies over all structures whose domain lies in one universe, which is an explicit parameter of the definition. The domains may be empty or infinite.

    adj_σ is the conjunction of x₁ ≠ x₂ with the disjunction, over the relation symbols R of arity β ≥ 2, of ∃x₃ … ∃x_β ⋁π R(x{π(1)}, …, x_{π(β)}), where π ranges over the permutations of the β positions. The quantified variables may coincide with x₁, x₂ or each other, so this is exactly adjacency in the Gaifman graph. Symbols of arity at most one contribute nothing. Its quantifier rank is at most α − 2.

    dist(x₁, x₂) ≤ r quantifies the r vertices v₁, …, v_r of a walk x₁ = v₀, v₁, …, v_r, requires v_r = x₂, and requires every step to be an equality or an adjacency. So it holds exactly if a walk of length at most r joins x₁ and x₂, as in GaifmanGraph.WithinDistGaifmanGraph.WithinDist. Its quantifier rank is at most r plus that of adj_σ, so at most r + α. For r = 0 it is equivalent to the equality x₁ = x₂.

    Finite disjunctions and conjunctions are mathlib's iSupiSup and iInfiInf. They fix some order of the members, which affects neither the meaning nor the quantifier rank. A formula over the variables x₁, x₂ is placed at given terms by substitution.

    The guard of a quantifier over Ball_s(x̄) is the disjunction over i of dist(xᵢ, y) ≤ s, where y is the newly bound variable. For a formula without free variables, the ball is empty and the guard is falsum. A local formula is built from atoms by falsum and implication, which give all Boolean connectives, and by the guarded quantifiers ∀y (guard → φ) and ∃y (guard ∧ φ). The inner formulas of a local formula may have more free variables than x̄, namely the bound variables, but the balls are always taken around x̄. The dist formulas inside the guards are exempt, exactly as in the paper.

    In a basic local sentence the m witnesses are the m bound variables of an existential block, and "dist(xᵢ, xⱼ) > 2r'" is the negation of the dist formula of radius 2r'. The case m = 0 is allowed and gives a true sentence.

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…