Binary encodings of finite relational structures #
A finite structure is given to a machine as a bit string. Fix a vocabulary
(Cslib.Logic.Vocabulary): a relational language L together with an enumeration of its relation
symbols, which fixes the order of their truth tables. A finite L-structure M is encoded, along
a numbering e : M ≃ Fin n of its elements, as its cardinality n followed by one truth table per
relation symbol (Cslib.Logic.Vocabulary.encode): the table of a symbol of arity k lists the
truth values of the relation on the n ^ k tuples of Fin n, in the order of their index
Cslib.Logic.tupleIndex, the order of finFunctionFinEquiv. The cardinality is written in unary
and the tables as raw bit strings, framed as a pair and a list
(Cslib.Logic.encStructure), so that the input has polynomial length in the number of
tuples and polynomial-time programs can read its components.
Conversely, every input (n, tables) decodes to an L-structure on Fin n
(Cslib.Logic.Vocabulary.decode), a missing table entry reading as false. The input is well
formed (Cslib.Logic.Vocabulary.WellFormed) when it has exactly one table of the right length
per symbol; the well-formed inputs are exactly the encodings of their decoded structures
(Cslib.Logic.Vocabulary.wellFormed_iff). The empty structure, n = 0, is included: its tables
are empty except for those of nullary symbols, which hold a single truth value.
The query language of a class K of finite structures (Cslib.Logic.Vocabulary.queryLanguage)
is the set of well-formed inputs whose decoded structure belongs to K; malformed inputs never
belong to it. When K is closed under isomorphism, whether an encoding of M belongs to the
query language does not depend on the numbering (Cslib.Logic.Vocabulary.mem_queryLanguage_encode).
This is the convention of Immerman, Section 2.1 and
Fagin, Section 3, with the order of tuples and the treatment of malformed inputs
spelled out.
Main definitions #
Cslib.Logic.Vocabulary: an enumeration of the relation symbols of a language.Cslib.Logic.EncodedStructure,Cslib.Logic.encStructure: inputs and their binary encoding.Cslib.Logic.Vocabulary.decode,Cslib.Logic.Vocabulary.WellFormed,Cslib.Logic.Vocabulary.checkShape,Cslib.Logic.Vocabulary.encode: decoding, well-formedness and its check, and encoding along a numbering.Cslib.Logic.Vocabulary.queryLanguage: the inputs encoding the members of a class.
Main results #
Cslib.Logic.Vocabulary.encode_congr: encodings agree when a size cast preserves every relation.Cslib.Logic.Vocabulary.decodeEncodeEquiv: decoding an encoding ofMgives a structure isomorphic toM.Cslib.Logic.Vocabulary.wellFormed_iff: an input is well formed exactly when it is the encoding of its decoded structure.Cslib.Logic.Vocabulary.mem_queryLanguage_encode: for a class closed under isomorphism, an encoding ofMbelongs to the query language exactly whenMbelongs to the class.
References #
Vocabularies and inputs #
A vocabulary: an enumeration of the relation symbols of a language, with their arities. It fixes the order of the truth tables in encoded structures.
- count : ℕ
The number of relation symbols.
The enumeration of the relation symbols.
Instances For
An input over finite structures: a cardinality and a list of truth tables.
Instances For
The binary encoding of inputs: the cardinality in unary, then the framed list of raw truth tables.
Instances For
The cardinality is at most the length of the encoded input.
The position of the table of a relation symbol.
Instances For
The arity of the relation symbol at a position.
Instances For
The truth table of a relation symbol in an input, empty if the input has none.
Instances For
Decoding #
The structure decoded from an input: a relation holds of a tuple when its table has true at
the index of the tuple; a missing entry reads as false.
Instances For
The decoded structure, bundled.
Instances For
An input is well formed when it has exactly one table per relation symbol, of length the number of tuples of the arity of the symbol.
Instances For
The program checking that an input is well formed.
Instances For
Encoding #
The truth table of a relation on a numbered finite structure: the truth values on all tuples, in the order of their index.
Instances For
The encoding of a finite structure along a numbering of its elements: the cardinality and the truth tables of the relation symbols, in the order of the vocabulary.
Instances For
Encodings are well formed.
Encodings agree when the numberings have equal sizes and the size cast preserves every relation.
The structure decoded from an encoding of M interprets a relation of the tuples numbering
the elements related in M.
Decoding an encoding of M along e gives a structure isomorphic to M, by e.
Instances For
An input is well formed exactly when it is the encoding of its decoded structure, numbered by itself.
Query languages #
The query language of a class K of finite structures: the well-formed inputs whose
decoded structure belongs to K. Malformed inputs never belong to it.
Instances For
For a class closed under isomorphism, an encoding of M belongs to the query language exactly
when M belongs to the class, whatever the numbering.