Documentation

Complexitylib.DescriptiveComplexity.Encoding

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 #

A computable enumeration of all k-tuples over Fin card, built by prepending each element to each shorter tuple.

Equations
Instances For

    The enumeration has length card ^ k.

    theorem Complexity.DescriptiveComplexity.mem_allTuples (card k : ) (t : Fin kFin card) :
    t allTuples card k

    Every tuple appears in the enumeration.

    def Complexity.DescriptiveComplexity.encodeRelC {card k : } (r : (Fin kFin card)Bool) :

    A computable truth-table encoding of a relation, using allTuples.

    Equations
    Instances For
      theorem Complexity.DescriptiveComplexity.encodeRelC_length {card k : } (r : (Fin kFin card)Bool) :
      (encodeRelC r).length = card ^ k

      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
      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
        Instances For

          A one-hot constant block determines the distinguished element.

          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.

            noncomputable def Complexity.DescriptiveComplexity.encodeRel {card k : } (r : (Fin kFin card)Bool) :

            Encode a Bool-valued arity-k relation on Fin card as its truth table: the list of its values over all k-tuples, in the canonical Fintype order.

            Equations
            Instances For
              theorem Complexity.DescriptiveComplexity.encodeRel_length {card k : } (r : (Fin kFin card)Bool) :
              (encodeRel r).length = card ^ k

              The truth-table encoding of an arity-k relation has length card ^ k.

              The relational part of a decidable structure's encoding: the truth tables of all its relations, concatenated.

              Equations
              Instances For

                The relational encoding's length is the sum of the per-relation truth-table sizes card ^ (arity).