Type trees and their canonical representation
Lax185574.TypeTrees · concepts/Lax185574/TypeTrees.lean · lax-185574
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
Let G be a partial graph, k, q ∈ ℕ and ā a tuple of ℓ vertices. The atomic (k, q)-type atp_{k,q}(ā) is the set of atomic distFO formulas of distance rank (k, q) with free variables among x₁, …, x_ℓ that ā satisfies in G. The (k, q)-type tree of ā is
tree_{k,q}(ā) = (atp_{k,q}(ā), 𝓔_{k,q}(ā)),
where 𝓔_{k,0}(ā) = ∅ and, for q ≥ 1,
𝓔_{k,q}(ā) = {(i, tree_{k+1,q−1}(ā b)) | i ∈ [ℓ], b ∈ V(G), dist(aᵢ, b) ≤ ρ⁺(k+1, q−1)}.
The members of 𝓔_{k,q}(ā) are the extensions, and i is the guard of the extension. The number ℓ is the arity and (k, q) is the rank of the tree.
Type trees are represented on the RAM in a canonical form, with all sets sorted and free of duplicates, so that two trees are equal exactly when their representations are. The size ‖τ‖ of a tree is the size of its representation, which includes k, q and ℓ.
For a type tree ν of arity one, [ν]^G is the set of vertices b with tree_{k,q}(b) = ν, where (k, q) is the rank of ν.
Concept map
Lean source view on GitHub
| 1 | import Lax185574.DistanceLogic |
| 2 | import Mathlib.Data.Fin.VecNotation |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: Type trees and their canonical representation |
| 7 | type: definition |
| 8 | --- |
| 9 | Let G be a partial graph, k, q ∈ ℕ and ā a tuple of ℓ vertices. The |
| 10 | *atomic (k, q)-type* atp_{k,q}(ā) is the set of atomic distFO formulas |
| 11 | of distance rank (k, q) with free variables among x₁, …, x_ℓ that ā |
| 12 | satisfies in G. The *(k, q)-type tree* of ā is |
| 13 | |
| 14 | tree_{k,q}(ā) = (atp_{k,q}(ā), 𝓔_{k,q}(ā)), |
| 15 | |
| 16 | where 𝓔_{k,0}(ā) = ∅ and, for q ≥ 1, |
| 17 | |
| 18 | 𝓔_{k,q}(ā) = {(i, tree_{k+1,q−1}(ā b)) | i ∈ [ℓ], b ∈ V(G), |
| 19 | dist(aᵢ, b) ≤ ρ⁺(k+1, q−1)}. |
| 20 | |
| 21 | The members of 𝓔_{k,q}(ā) are the *extensions*, and i is the *guard* |
| 22 | of the extension. The number ℓ is the *arity* and (k, q) is the *rank* |
| 23 | of the tree. |
| 24 | |
| 25 | Type trees are represented on the RAM in a canonical form, with all sets |
| 26 | sorted and free of duplicates, so that two trees are equal exactly when |
| 27 | their representations are. The size ‖τ‖ of a tree is the size of its |
| 28 | representation, which includes k, q and ℓ. |
| 29 | |
| 30 | For a type tree ν of arity one, [ν]^G is the set of vertices b with |
| 31 | tree_{k,q}(b) = ν, where (k, q) is the rank of ν. |
| 32 | |
| 33 | # Formalization notes |
| 34 | |
| 35 | A type tree is a Lean object of type `TypeTree`. It records its rank |
| 36 | (k, q), its arity ℓ and its root, an element of `Node q ℓ`. A root of |
| 37 | depth 0 is its root label, the finite set of its atoms. A root of depth |
| 38 | q + 1 is its root label together with the finite set of its extensions, |
| 39 | pairs of a guard and a root of depth q and arity ℓ + 1. The trees inside |
| 40 | a tree carry no rank and arity, since these are determined by the |
| 41 | enclosing tree. Equality of type trees in the paper is equality of |
| 42 | these objects. |
| 43 | |
| 44 | The canonical representation of a type tree is its encoding, in the |
| 45 | sense of `Lax185574.Encoding`. It is the header k, q, ℓ, followed by the |
| 46 | encoding of the set of atoms of the root and, at depth at least one, the |
| 47 | encoding of the set of extensions. An atom is encoded as a formula of |
| 48 | `Lax185574.DistanceLogic`, and an extension (i, μ) by i followed by the |
| 49 | encoding of μ. Finite sets are encoded sorted and without repetitions, |
| 50 | so the encoding is determined by the tree. The size ‖τ‖ is the length of |
| 51 | the encoding, `wordLength τ`. The operations of the paper are computed |
| 52 | by word RAM programs on these encodings. |
| 53 | |
| 54 | The algorithms of the model-checking procedure receive and return the |
| 55 | family (tree_{k,q}(a) : a ∈ V(G)) of the type trees of all vertices of a |
| 56 | partial graph on `Fin n`. It is `family G k q`, a function on `Fin n`, |
| 57 | encoded as the list of its members in the order of the vertices. |
| 58 | |
| 59 | Sets are turned into finite sets by `finsetOf`. On an infinite set it |
| 60 | returns the empty set. This case does not occur for partial graphs on a |
| 61 | finite vertex type, where all the sets involved are finite. In |
| 62 | particular, only finitely many colors occur, and an atom with a color |
| 63 | that does not occur is false. |
| 64 | -/ |
| 65 | |
| 66 | namespace Lax185574.TypeTrees |
| 67 | |
| 68 | open Lax185574.PartialGraphs Lax185574.GaifmanGraph Lax185574.Encoding |
| 69 | open Lax185574.DistanceLogic Lax185574.DistanceLogic.DistFO |
| 70 | open Lax3.DistFO (rhoMinus rhoPlus) |
| 71 | |
| 72 | /-- `Node q ℓ`: the roots of the type trees of depth `q` and arity `ℓ`. |
| 73 | A root of depth `0` is its set of atoms. A root of depth `q + 1` is its |
| 74 | set of atoms together with its set of extensions, pairs of a guard and |
| 75 | a root of depth `q` and arity `ℓ + 1`. -/ |
| 76 | def Node : ℕ → ℕ → Type |
| 77 | | 0, ℓ => Finset (DistFO ℓ) |
| 78 | | q + 1, ℓ => Finset (DistFO ℓ) × Finset (Fin ℓ × Node q (ℓ + 1)) |
| 79 | |
| 80 | /-- A root of depth `0` is encoded by its set of atoms. A root of depth |
| 81 | `q + 1` is encoded by its set of atoms followed by its set of |
| 82 | extensions. `Node` is defined by recursion on the depth and is not an |
| 83 | inductive type, so its encoding is given by the same recursion. -/ |
| 84 | @[instance_reducible] def Node.instEncode : (q ℓ : ℕ) → Encode (Node q ℓ) |
| 85 | | 0, ℓ => inferInstanceAs (Encode (Finset (DistFO ℓ))) |
| 86 | | q + 1, ℓ => |
| 87 | letI := Node.instEncode q (ℓ + 1) |
| 88 | inferInstanceAs (Encode (Finset (DistFO ℓ) × Finset (Fin ℓ × Node q (ℓ + 1)))) |
| 89 | |
| 90 | instance {q ℓ : ℕ} : Encode (Node q ℓ) := Node.instEncode q ℓ |
| 91 | |
| 92 | /-- A type tree: its rank `(k, q)`, its arity `ℓ` and its root. -/ |
| 93 | structure TypeTree where |
| 94 | /-- The first component of the rank. -/ |
| 95 | k : ℕ |
| 96 | /-- The depth, the second component of the rank. -/ |
| 97 | q : ℕ |
| 98 | /-- The arity. -/ |
| 99 | ℓ : ℕ |
| 100 | /-- The root. -/ |
| 101 | root : Node q ℓ |
| 102 | deriving Encode |
| 103 | |
| 104 | variable {V : Type*} |
| 105 | |
| 106 | /-- The finite set with the elements of `S`, and `∅` if `S` is |
| 107 | infinite. -/ |
| 108 | noncomputable def finsetOf {α : Type*} (S : Set α) : Finset α := |
| 109 | open Classical in if h : S.Finite then h.toFinset else ∅ |
| 110 | |
| 111 | /-- `atp_{k,q}(a)`: the atoms of distance rank `(k, q)` satisfied by the |
| 112 | tuple `a`. -/ |
| 113 | def atp (G : PartialGraph V) (k q : ℕ) {ℓ : ℕ} (a : Fin ℓ → V) : Set (DistFO ℓ) := |
| 114 | {φ | IsAtom φ ∧ DRank k q φ ∧ Sat G a φ} |
| 115 | |
| 116 | /-- The root of `tree_{k,q}(a)`: the atoms of `atp_{k,q}(a)` and, for |
| 117 | `q ≥ 1`, the extensions `(i, tree_{k+1,q−1}(a b))`. -/ |
| 118 | noncomputable def node (G : PartialGraph V) : (k q : ℕ) → {ℓ : ℕ} → (Fin ℓ → V) → Node q ℓ |
| 119 | | k, 0, _, a => finsetOf (atp G k 0 a) |
| 120 | | k, q + 1, ℓ, a => |
| 121 | (finsetOf (atp G k (q + 1) a), |
| 122 | finsetOf {e | ∃ (i : Fin ℓ) (b : V), |
| 123 | WithinDist G.resolved (rhoPlus (k + 1) q) (a i) b ∧ |
| 124 | e = (i, node G (k + 1) q (Fin.snoc a b))}) |
| 125 | |
| 126 | /-- `tree_{k,q}(a)`. -/ |
| 127 | noncomputable def tree (G : PartialGraph V) (k q : ℕ) {ℓ : ℕ} (a : Fin ℓ → V) : TypeTree := |
| 128 | ⟨k, q, ℓ, node G k q a⟩ |
| 129 | |
| 130 | /-- `[ν]^G`: the vertices whose type tree is `ν`. The rank is read off |
| 131 | `ν`, which records it. -/ |
| 132 | def realizations (G : PartialGraph V) (ν : TypeTree) : Set V := |
| 133 | {b | tree G ν.k ν.q ![b] = ν} |
| 134 | |
| 135 | /-- The family `(tree_{k,q}(a) : a ∈ V(G))` of the type trees of all |
| 136 | vertices. -/ |
| 137 | noncomputable def family {n : ℕ} (G : PartialGraph (Fin n)) (k q : ℕ) : Fin n → TypeTree := |
| 138 | fun a => tree G k q ![a] |
| 139 | |
| 140 | /-- The largest size of a tree of the family. -/ |
| 141 | noncomputable def maxTreeSize {n : ℕ} (G : PartialGraph (Fin n)) (k q : ℕ) : ℕ := |
| 142 | Finset.univ.sup fun a : Fin n => wordLength (family G k q a) |
| 143 | |
| 144 | end Lax185574.TypeTrees |
| 145 |
Formalization notes
A type tree is a Lean object of type . It records its rank (k, q), its arity ℓ and its root, an element of . A root of depth 0 is its root label, the finite set of its atoms. A root of depth q + 1 is its root label together with the finite set of its extensions, pairs of a guard and a root of depth q and arity ℓ + 1. The trees inside a tree carry no rank and arity, since these are determined by the enclosing tree. Equality of type trees in the paper is equality of these objects.
The canonical representation of a type tree is its encoding, in the sense of . It is the header k, q, ℓ, followed by the encoding of the set of atoms of the root and, at depth at least one, the encoding of the set of extensions. An atom is encoded as a formula of , and an extension (i, μ) by i followed by the encoding of μ. Finite sets are encoded sorted and without repetitions, so the encoding is determined by the tree. The size ‖τ‖ is the length of the encoding, . The operations of the paper are computed by word RAM programs on these encodings.
The algorithms of the model-checking procedure receive and return the family (tree_{k,q}(a) : a ∈ V(G)) of the type trees of all vertices of a partial graph on . It is , a function on , encoded as the list of its members in the order of the vertices.
Sets are turned into finite sets by . On an infinite set it returns the empty set. This case does not occur for partial graphs on a finite vertex type, where all the sets involved are finite. In particular, only finitely many colors occur, and an atom with a color that does not occur is false.
Builds on
Used by
From Mathlib
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments