Encoding finite structures as bit strings #
To connect descriptive complexity to the machine model, a finite structure must be
presented as an input to a Turing machine — a bit string. The standard encoding
(for an ordered universe Fin card) lists, for each relation, its truth
table: the values over all tuples in the canonical order. This module builds the
relational part of that encoding and computes its length; it is step 5 (structure
→ bit-string encoding) of the Fagin decomposition on roadmap track L6.
Main definitions and results #
DescriptiveComplexity.encodeRel,encodeRel_length— a relation's truth table (lengthcard ^ arity).DescriptiveComplexity.encodeRels,encodeRels_length— the relational part of a structure's encoding, and its total length.DescriptiveComplexity.encodeConstC,encodeConstsC— computable one-hot encodings of the distinguished constants.DescriptiveComplexity.allTuples,encodeRelC— a computable tuple enumeration and a computable truth-table encoding (needed for the machine-side Fagin bridge).
The computable encoding also has length card ^ k.
The computable relational encoding of a decidable structure: the computable truth tables of all its relations, concatenated.
Equations
- Complexity.DescriptiveComplexity.encodeRelsC A = List.flatMap (fun (i : Fin V.numRels) => Complexity.DescriptiveComplexity.encodeRelC (A.rel i)) (List.finRange V.numRels)
Instances For
The computable relational encoding has the expected total length.
Encode a distinguished constant as the truth table of its singleton unary
relation. The resulting one-hot block has exactly card bits.
Equations
- Complexity.DescriptiveComplexity.encodeConstC c = List.map (fun (i : Fin card) => i == c) (List.finRange card)
Instances For
A one-hot constant block determines the distinguished element.
Encode all distinguished constants as consecutive one-hot blocks.
Equations
- Complexity.DescriptiveComplexity.encodeConstsC A = List.flatMap (fun (i : Fin V.numConsts) => Complexity.DescriptiveComplexity.encodeConstC (A.const i)) (List.finRange V.numConsts)
Instances For
The full computable encoding of a decidable structure: the cardinality in
unary (a block of card trues terminated by a false), followed by the
relational truth tables and one one-hot block per distinguished constant.
The unary prefix makes card self-delimiting.
Equations
Instances For
The cardinality is recoverable from the encoding as the length of the leading
run of trues.
Constant-free vocabularies retain the prior cardinality-plus-relations wire format.
The full encoding has one unary cardinality block, all relation tables, and
one card-bit block for each constant symbol.
The relational part of a decidable structure's encoding: the truth tables of all its relations, concatenated.
Equations
- Complexity.DescriptiveComplexity.encodeRels A = List.flatMap (fun (i : Fin V.numRels) => Complexity.DescriptiveComplexity.encodeRel (A.rel i)) (List.finRange V.numRels)
Instances For
The relational encoding's length is the sum of the per-relation truth-table
sizes card ^ (arity).