Local formulas and basic local sentences
Lax185574.LocalFormulas · concepts/Lax185574/LocalFormulas.lean · lax-185574
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural 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
In the paper
- page 62 of this submission's paper
Lean source view on GitHub
| 1 | import Lax185574.GaifmanGraph |
| 2 | import Mathlib.ModelTheory.Satisfiability |
| 3 | import Mathlib.Logic.Equiv.Fin.Basic |
| 4 | |
| 5 | /-! |
| 6 | --- |
| 7 | title: Local formulas and basic local sentences |
| 8 | type: definition |
| 9 | --- |
| 10 | Fix a finite relational signature σ of arity α. Two σ-formulas φ(x̄) |
| 11 | and ψ(x̄) are *equivalent* if for every σ-structure A and every tuple |
| 12 | ā ∈ V(A)^{|x̄|}, A ⊨ φ(ā) if and only if A ⊨ ψ(ā). |
| 13 | |
| 14 | The formula adj_σ(x₁, x₂) tests whether x₁ and x₂ are adjacent in the |
| 15 | Gaifman graph. For every relation R ∈ σ of arity β ≤ α it tests whether |
| 16 | there are elements x₃, …, x_β such that some permutation of x₁, …, x_β |
| 17 | satisfies R. Its quantifier rank is at most α − 2. From it one derives |
| 18 | the formula dist(x₁, x₂) ≤ r, which checks whether x₁ and x₂ have |
| 19 | distance at most r in the Gaifman graph. It quantifies the candidate |
| 20 | vertices of a path and checks the required adjacencies in parallel, so |
| 21 | its quantifier rank is at most r + α. |
| 22 | |
| 23 | A σ-formula φ(x̄) is *r-local* if every quantifier appearing in φ(x̄) is |
| 24 | of the form ∀y ∈ Ball_s(x̄) or ∃y ∈ Ball_s(x̄) for some s ≤ r, where the |
| 25 | ball checks are implemented using the dist formulas, which are exempt |
| 26 | from this condition. A sentence ψ is *basic r-local* if there is some |
| 27 | r' ≤ 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 | |
| 31 | for an r'-local formula φ. |
| 32 | |
| 33 | # Formalization notes |
| 34 | |
| 35 | Formulas are mathlib's, `L.Formula (Fin k)` for formulas with free |
| 36 | variables x₁, …, x_k, and `L.BoundedFormula (Fin k) n` for their |
| 37 | subformulas with n further bound variables. A finite relational |
| 38 | signature is a relational language with finitely many relation symbols |
| 39 | in total. The arity bound α plays no role in the definitions. |
| 40 | |
| 41 | Equivalence quantifies over all structures whose domain lies in one |
| 42 | universe, which is an explicit parameter of the definition. The domains |
| 43 | may be empty or infinite. |
| 44 | |
| 45 | adj_σ is the conjunction of x₁ ≠ x₂ with the disjunction, over the |
| 46 | relation symbols R of arity β ≥ 2, of ∃x₃ … ∃x_β ⋁_π R(x_{π(1)}, …, |
| 47 | x_{π(β)}), where π ranges over the permutations of the β positions. The |
| 48 | quantified variables may coincide with x₁, x₂ or each other, so this is |
| 49 | exactly adjacency in the Gaifman graph. Symbols of arity at most one |
| 50 | contribute nothing. Its quantifier rank is at most α − 2. |
| 51 | |
| 52 | dist(x₁, x₂) ≤ r quantifies the r vertices v₁, …, v_r of a walk |
| 53 | x₁ = v₀, v₁, …, v_r, requires v_r = x₂, and requires every step to be |
| 54 | an equality or an adjacency. So it holds exactly if a walk of length at |
| 55 | most r joins x₁ and x₂, as in `GaifmanGraph.WithinDist`. Its quantifier |
| 56 | rank is at most r plus that of adj_σ, so at most r + α. For r = 0 it is |
| 57 | equivalent to the equality x₁ = x₂. |
| 58 | |
| 59 | Finite disjunctions and conjunctions are mathlib's `iSup` and `iInf`. |
| 60 | They fix some order of the members, which affects neither the meaning |
| 61 | nor the quantifier rank. A formula over the variables x₁, x₂ is placed |
| 62 | at given terms by substitution. |
| 63 | |
| 64 | The guard of a quantifier over Ball_s(x̄) is the disjunction over i of |
| 65 | dist(xᵢ, y) ≤ s, where y is the newly bound variable. For a formula |
| 66 | without free variables, the ball is empty and the guard is falsum. A |
| 67 | local formula is built from atoms by falsum and implication, which give |
| 68 | all Boolean connectives, and by the guarded quantifiers |
| 69 | ∀y (guard → φ) and ∃y (guard ∧ φ). The inner formulas of a local |
| 70 | formula may have more free variables than x̄, namely the bound |
| 71 | variables, but the balls are always taken around x̄. The dist formulas |
| 72 | inside the guards are exempt, exactly as in the paper. |
| 73 | |
| 74 | In a basic local sentence the m witnesses are the m bound variables of |
| 75 | an existential block, and "dist(xᵢ, xⱼ) > 2r'" is the negation of the |
| 76 | dist formula of radius 2r'. The case m = 0 is allowed and gives a true |
| 77 | sentence. |
| 78 | -/ |
| 79 | |
| 80 | namespace Lax185574.LocalFormulas |
| 81 | |
| 82 | open FirstOrder FirstOrder.Language |
| 83 | |
| 84 | universe u v w a |
| 85 | |
| 86 | variable {L : Language.{u, v}} |
| 87 | |
| 88 | /-- Two formulas are *equivalent* if they hold of the same tuples in |
| 89 | every structure whose domain lies in the universe `w`. -/ |
| 90 | def 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 |
| 94 | the same tuples in every finite structure whose domain lies in the |
| 95 | universe `w`. -/ |
| 96 | def 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. -/ |
| 101 | def 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_σ`: |
| 106 | positions `0` and `1` are `x₁` and `x₂`, and position `m ≥ 2` is the |
| 107 | bound variable `x_{m+1}`. -/ |
| 108 | def 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 |
| 114 | otherwise. -/ |
| 115 | noncomputable 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 | |
| 122 | variable (L) in |
| 123 | /-- `adj_σ(x₁, x₂)`: the formula stating that `x₁` and `x₂` are adjacent |
| 124 | in the Gaifman graph. -/ |
| 125 | noncomputable 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. -/ |
| 131 | def 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 | |
| 135 | variable (L) in |
| 136 | /-- `dist(x₁, x₂) ≤ r`: there are `v₁, …, v_r` with `v_r = x₂` such that |
| 137 | each step of `x₁ = v₀, v₁, …, v_r` is an equality or an adjacency. -/ |
| 138 | noncomputable 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 | |
| 146 | variable (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 |
| 149 | over `i` of `dist(xᵢ, y) ≤ s`. -/ |
| 150 | noncomputable 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` |
| 156 | and `n` further bound variables in scope is `r`-local. It is built from |
| 157 | atoms by falsum, implication and quantifiers guarded by `Ball_s(x̄)` for |
| 158 | some `s ≤ r`. -/ |
| 159 | inductive 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 | |
| 179 | variable (L) in |
| 180 | /-- The sentence `∃x₁, …, x_m (⋀_{i < j} dist(xᵢ, xⱼ) > 2r' ∧ ⋀_i φ(xᵢ))`. -/ |
| 181 | noncomputable 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. -/ |
| 190 | def 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 | |
| 194 | end Lax185574.LocalFormulas |
| 195 |
Formalization notes
Formulas are mathlib's, for formulas with free variables x₁, …, x_k, and 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 . 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 and . 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.
0 comments