Binary numbers carried by a relation #
The layer between DescriptiveComplexity.Numbers.Binary, which decodes a set of bits
sitting on a genuine LinearOrder, and the problems carrying binary numbers,
whose order is a relation symbol of the vocabulary and therefore an
arbitrary binary relation until the yes-instances say otherwise.
DescriptiveComplexity.IsLinOrd– being a linear order, as a property of a relation, first-order and foldable into the yes-instances;DescriptiveComplexity.bitRank– the rank of a position, the number of positions strictly below it, defined for an arbitrary relation;DescriptiveComplexity.binNum– the decoding∑ 2 ^ rank, over a set of positions viafinsum, so that it is total and needs no finiteness to be stated.
Everything transports along equivalences commuting with the relations, which
is what the DecisionProblem.iso_invariant proofs of the group need.
The arithmetic the Σ₁ definitions need – that a bitwise ripple-carry chain
computes an addition – is built on DescriptiveComplexity.binNum_peel_min, which
peels the lowest position off a decoded number: binNum = bit at the bottom + 2 * (the rest), the recursion binary numbers actually satisfy. The same
recursion gives the two facts a kernel needs about whole numbers rather than
their bits: DescriptiveComplexity.binNum_inj_on, two numbers are equal exactly when
their bits agree, and DescriptiveComplexity.binNum_lt_iff, one is smaller exactly
when they differ and the higher bit is the second's – both bitwise, hence
first-order, which is why a kernel can compare numbers it has guessed.
Linear orders, as a property of a relation #
A binary relation is a linear order: reflexive, transitive, antisymmetric and total.
Equations
Instances For
Dependency graph
Linearity transports along an equivalence.
Dependency graph
Building linear orders #
Reductions into a problem carrying binary numbers have to construct the
order of the instance they produce, and a Σ₁ certificate sometimes has to
exhibit one. Both do it the same way: read the elements through a key into a
lexicographic product of orders already at hand.
The lexicographic product of two relations.
Instances For
Dependency graph
The lexicographic product of two linear orders is a linear order.
Dependency graph
A relation read through an injective key into a linear order is a linear order.
Dependency graph
A relation that is a linear order induces a LinearOrder structure,
which is what Mathlib's order library asks for. Guessed orders – a schedule, a
circuit – arrive as relations, so this is the bridge to it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The natural order of a linear order, as a relation.
Dependency graph
Decoding a set of positions #
The rank of a position: the number of positions strictly below it. This is the place value's exponent.
Instances For
Dependency graph
The number encoded by the set b of positions: ∑ 2 ^ rank.
Equations
Instances For
Dependency graph
Dependency graph
Only the bits at positions matter.
Dependency graph
The value of the empty set of positions is zero.
Dependency graph
The rank of a position transports along an equivalence commuting with the two relations.
Dependency graph
The decoded number transports along an equivalence commuting with the three relations.
Dependency graph
Peeling the lowest position #
Removing the lowest position lowers every other rank by one.
Dependency graph
The recursion binary numbers satisfy: the value is the lowest bit plus twice the value of the rest.
Dependency graph
The full adder #
The majority of three propositions: the carry produced by a full adder.
Instances For
Dependency graph
The full-adder identity: the sum bit plus twice the carry is the sum of the three input bits.
Dependency graph
Ripple-carry addition #
p is a lowest position.
Equations
- DescriptiveComplexity.MinPos Le Posn p = (Posn p ∧ ∀ (q : A), Posn q → Le p q)
Instances For
Dependency graph
p is a highest position.
Equations
- DescriptiveComplexity.MaxPos Le Posn p = (Posn p ∧ ∀ (q : A), Posn q → Le q p)
Instances For
Dependency graph
q is the next position above p.
Equations
Instances For
Dependency graph
A nonempty set of positions has a lowest one: minimize the rank.
Dependency graph
Rank is strictly monotone: a lower position has a smaller rank.
Dependency graph
The element immediately below a given one is unique.
Dependency graph
The reverse of a linear order is a linear order.
Dependency graph
A nonempty set of positions has a highest one.
Dependency graph
Every position that is not the lowest has one immediately below it.
Dependency graph
Ripple-carry addition is addition. If s is the bitwise sum of a
and b with carries c – each bit the exclusive or of the three, each carry
the majority of the three below – then the decoded numbers add up, the carry
in at the bottom and the carry out at the top accounting for the
difference.
Dependency graph
A decoded number is smaller than 2 to the number of positions.
Dependency graph
A ripple-carry certificate exists. Whenever the sum fits in the
available positions, the bitwise sum and the carries that witness it can be
produced – this is the certificate that the Σ₁ definition of a
binary-weighted problem guesses.
Dependency graph
Every number that fits can be written: a value below 2 to the number
of positions is decoded from some set of bits.
Dependency graph
The decoding is injective on the positions: two sets of bits with the same value agree wherever it matters.
Dependency graph
Comparison by the highest differing position: one decoded number is
smaller than another exactly when there is a position carrying 0 in the
first and 1 in the second above which the two agree. Unlike the value
itself, this is a first-order reading of <, which is what a kernel
comparing two guessed numbers writes.