Binary representation of numbers in finite structures #
The binary encoding: a number carried by an instance is given by a set of
bit positions, the positions being linearly ordered elements of the
structure. This is the honest encoding for problems whose numbers must be
exponential in the instance size (SubsetSum, Partition, Knapsack…), where the
unary representation of DescriptiveComplexity.Numbers.Unary would change the
complexity.
DescriptiveComplexity.posRank: the rank of a position in the increasing enumeration (viamonoEquivOfFin, so positions need not literally beFin m);DescriptiveComplexity.binValue b: the number∑ 2 ^ rank pover set bits – the decoding function;DescriptiveComplexity.binEncode k: the canonical encoding, viaNat.testBit;- round-trips
DescriptiveComplexity.binValue_binEncode(fork < 2 ^ #positions) andDescriptiveComplexity.testBit_binValue; - range bound
DescriptiveComplexity.binValue_lt_two_pow; - invariance under order-isomorphisms (
DescriptiveComplexity.binValue_orderIso), for theDecisionProblem.iso_invariantproof of a problem carrying binary numbers; - the most-significant-differing-bit comparison
DescriptiveComplexity.binValue_lt_binValue_iff– the Lean counterpart of the FO(≤) formula comparing two binary numbers.
The problems of the catalog reach this layer through
DescriptiveComplexity.Numbers.BinRel, which decodes the same bits when the
order on positions is a relation symbol of the vocabulary rather than a
LinearOrder instance: Knapsack, Partition, Job Sequencing and 0-1 Integer
Programming. The choice between this encoding and the unary one is argued in
DescriptiveComplexity.Numbers.
Sums of powers of two over a bit predicate #
Positions, decoding and encoding #
The rank of a bit position: its index in the increasing enumeration of the positions.
Equations
- DescriptiveComplexity.posRank P p = ↑((monoEquivOfFin P ⋯).symm p)
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
The number represented in binary by a set of positions: the sum of
2 ^ rank over the set bits. This is the decoding function of the binary
representation.
Equations
- DescriptiveComplexity.binValue P b = ∑ p : P, if b p then 2 ^ DescriptiveComplexity.posRank P p else 0
Instances For
Dependency graph
The canonical binary encoding of a number as a set of positions.
Equations
- DescriptiveComplexity.binEncode P k p = (k.testBit (DescriptiveComplexity.posRank P p) = true)
Instances For
Dependency graph
The bits of a set of positions, as a function of the rank.
Equations
- DescriptiveComplexity.posBits P b i = decide (∃ (p : P), DescriptiveComplexity.posRank P p = i ∧ b p)
Instances For
Dependency graph
Dependency graph
Dependency graph
The decoded number is smaller than 2 ^ #positions.
Dependency graph
Decoding after encoding is the identity, for numbers within range.
Dependency graph
The bits of the decoded number are the original set of positions.
Dependency graph
The decoded number is invariant under order-isomorphisms of the positions.
Dependency graph
binValue only depends on the extension of the bit predicate.
Dependency graph
Most-significant-bit comparison: one binary number is smaller than
another iff at some position the first has bit 0 and the second bit 1,
all higher positions agreeing. This is the Lean counterpart of the FO(≤)
formula comparing binary numbers.