Finite Relational Structures
Lax496464.WH_B1_Structures · concepts/Lax496464/WH_B1_Structures.lean · lax-496464
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A relational structure consists of a finite universe and, for each symbol of a finite vocabulary , a relation on of the symbol's arity [FG06, Section 4.2]. The parameterized problems that define the W- and A-hierarchies take structures as input.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.Data.Finset.Card |
| 2 | import Mathlib.Algebra.BigOperators.Group.Finset.Defs |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: Finite Relational Structures |
| 7 | type: definition |
| 8 | --- |
| 9 | A *relational structure* consists of a finite universe and, for each symbol of a |
| 10 | finite vocabulary , a relation on of the symbol's arity [FG06, Section 4.2]. The |
| 11 | parameterized problems that define the W- and A-hierarchies take structures as input. |
| 12 | |
| 13 | # Formalization Notes |
| 14 | |
| 15 | **Structures.** The universe is ; the vocabulary is the list |
| 16 | `arities`, symbol having arity `arities[i]` . Both the universe and the vocabulary may |
| 17 | be empty. A relation is a finite set of tuples, each a list of elements. A formula that mentions a |
| 18 | symbol outside the vocabulary does not fit the structure (`WH_B2_FirstOrder.Formula.Fits`) and is |
| 19 | false in it [FG06, p. 76]. |
| 20 | |
| 21 | **Words.** The word of a structure (`Encodes`) lists the number of symbols, the arities, the size |
| 22 | of the universe, and then, for each symbol, the number of its tuples followed by their entries. |
| 23 | The tuples of a relation may be listed in any order without repetition; the yes-instances of every |
| 24 | problem are independent of the order. The encoding is self-delimiting, so a structure may be |
| 25 | followed by further entries, as in an instance . |
| 26 | |
| 27 | **Size.** The size of the universe is written as a single number. The word therefore has |
| 28 | entries, whereas the size |
| 29 | [FG06, p. 74] (`Structure.norm`) counts the universe in unary. A reduction that ranges over the |
| 30 | universe first restricts it to the elements occurring in the relations together with a bounded |
| 31 | number of further elements. This preserves the answer, since elements that occur in no relation |
| 32 | are interchangeable. |
| 33 | -/ |
| 34 | |
| 35 | namespace Lax496464.WH_B1_Structures |
| 36 | |
| 37 | open scoped BigOperators |
| 38 | |
| 39 | /-- A finite relational structure. -/ |
| 40 | structure Structure where |
| 41 | /-- The vocabulary: the arities of the relation symbols `0, 1, …`. -/ |
| 42 | arities : List ℕ |
| 43 | /-- The universe is `{0, …, size - 1}`. -/ |
| 44 | size : ℕ |
| 45 | /-- The relation of each symbol, as a set of tuples. -/ |
| 46 | rel : ℕ → Finset (List ℕ) |
| 47 | /-- Every arity is at least one. -/ |
| 48 | arity_pos : ∀ a ∈ arities, 1 ≤ a |
| 49 | /-- The tuples of symbol `i` have its arity and entries in the universe; other symbols have no |
| 50 | tuples. -/ |
| 51 | wf : ∀ i, ∀ t ∈ rel i, i < arities.length ∧ t.length = arities.getD i 0 ∧ ∀ a ∈ t, a < size |
| 52 | |
| 53 | /-- The size `‖A‖ = |τ| + |A| + Σ_R |R^A| · arity(R)` of a structure [FG06, p. 74]. -/ |
| 54 | def Structure.norm (A : Structure) : ℕ := |
| 55 | A.arities.length + A.size + |
| 56 | ∑ i ∈ Finset.range A.arities.length, (A.rel i).card * A.arities.getD i 0 |
| 57 | |
| 58 | /-- The block of one relation: the number of its tuples, then the tuples, in some order without |
| 59 | repetition. -/ |
| 60 | def EncodesRel (R : Finset (List ℕ)) (blk : List ℕ) : Prop := |
| 61 | ∃ ts : List (List ℕ), ts.Nodup ∧ ts.toFinset = R ∧ blk = ts.length :: ts.flatten |
| 62 | |
| 63 | /-- The word `x` is an encoding of the structure `A`: the number of symbols, the arities, the size |
| 64 | of the universe, and one block per symbol. -/ |
| 65 | def Encodes (x : List ℕ) (A : Structure) : Prop := |
| 66 | ∃ blocks : List (List ℕ), blocks.length = A.arities.length ∧ |
| 67 | (∀ i < A.arities.length, EncodesRel (A.rel i) (blocks.getD i [])) ∧ |
| 68 | x = A.arities.length :: (A.arities ++ A.size :: blocks.flatten) |
| 69 | |
| 70 | end Lax496464.WH_B1_Structures |
| 71 |
Formalization Notes
Structures. The universe is ; the vocabulary is the list , symbol having arity . Both the universe and the vocabulary may be empty. A relation is a finite set of tuples, each a list of elements. A formula that mentions a symbol outside the vocabulary does not fit the structure () and is false in it [FG06, p. 76].
Words. The word of a structure () lists the number of symbols, the arities, the size of the universe, and then, for each symbol, the number of its tuples followed by their entries. The tuples of a relation may be listed in any order without repetition; the yes-instances of every problem are independent of the order. The encoding is self-delimiting, so a structure may be followed by further entries, as in an instance .
Size. The size of the universe is written as a single number. The word therefore has entries, whereas the size [FG06, p. 74] () counts the universe in unary. A reduction that ranges over the universe first restricts it to the elements occurring in the relations together with a bounded number of further elements. This preserves the answer, since elements that occur in no relation are interchangeable.
Builds on
none
Used by
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments