Numbering tuples over finite universes #
These generic helpers number finite tuples without depending on machine encodings. The index
uses the first coordinate as the least significant digit, as in Mathlib's finFunctionFinEquiv.
The public names and numbering convention are unchanged from their original location in
Complexity.Logics.FirstOrder.Encoding, which publicly imports this module.
Main definitions #
Cslib.Logic.tupleIndex: the colexicographic index of a tuple of natural-number digits.Cslib.Logic.tupleEquiv: number tuples along an enumeration of their coordinates.
Main results #
Cslib.Logic.tupleIndex_lt_iff: numerical order agrees with the highest differing coordinate.Cslib.Logic.tupleIndex_lt_pow_iff: indices below a power have zero higher digits.
References #
- N. Immerman, Descriptive Complexity, Remark 1.32, for the distinct lexicographic convention required by ordered first-order queries.
Tuples #
The index of a tuple of Fin n in the truth table of a relation of arity k: the number
∑ i, x i * n ^ i below n ^ k, the order of finFunctionFinEquiv.
Instances For
The tuple with a given index.
Separate the highest-weight digit (x (Fin.last k) : ℕ) * n ^ k of tupleIndex x.
When all coordinates of x : Fin k → Fin n at indices ≥ a are zero, tupleIndex x equals
the index of its prefix of length a.
The numerical order on tupleIndex is the colexicographic order on Fin k → Fin n
(comparing at the most significant coordinate where the tuples differ).