Field arithmetic for the decoder of the succinct tableau #
The first stage of the decoder of the tableau formula on bit-field labels
(CslibFrontier/Computability/Circuit/Boolean/Tableau/Succinct.lean). Its inputs are the bits of a
clause number: two bits of the clause, two bits of the tag, then a payload of P = s + cb + tb
bits made of the slot (s bits), the column c (cb bits) and the block t (tb bits). It is an
explicit De Morgan gate list (fieldGates) of
- two constants and the negations of the inputs;
- fourteen comparison chains of
Pgates each (chainGate): bit-serial comparisons of a field with a constant, least significant bit first, one gate per bit. They compare the column with0,1,n,n + 1,2 TandT, the block with0andT, the payload with0,1and the length ofx, and give the borrows and carries ofc - 1,c + 1andt - 1; - a decoder tree of
2 ^ (m + 1) - 1gates (treeGates), whose last level is the indicator of the lowm = Nat.size x.lengthbits of the payload, and a chain ofx.lengthdisjunctions (orGate) that looks up the bit of the hardwiredxat the payload.
There are 2 + (4 + P) + 14 P + (2 ^ (m + 1) - 1) + x.length gates, linear in the field widths and
in the length of x; in particular there is no carry-lookahead adder, whose size is not linear.
Correctness is proved wire by wire: the intended value of every wire (fieldVal) is consistent
with its gate (allGates_consistentAt_fieldGates), so it is the value the list computes
(getD_evalCode_of_allGates).
Main definitions #
Cslib.Circuits.Boolean.Tableau.Decoder.AllGates: a property of every gate of a list at its wire.Cslib.Circuits.Boolean.Tableau.Decoder.cmp: the comparison computed by a chain.Cslib.Circuits.Boolean.Tableau.Decoder.Chain,Cslib.Circuits.Boolean.Tableau.Decoder.chain: the fourteen comparison chains.Cslib.Circuits.Boolean.Tableau.Decoder.fieldGates: the gate list.Cslib.Circuits.Boolean.Tableau.Decoder.fieldVal: the intended values of its wires.
Main results #
Cslib.Circuits.Boolean.Tableau.Decoder.getD_evalCode_of_allGates: a valuation consistent with every gate of a well-formed list is its evaluation.Cslib.Circuits.Boolean.Tableau.Decoder.getD_evalCode_fieldGates: the gate list computes the intended values.Cslib.Circuits.Boolean.Tableau.Decoder.length_fieldGates: its number of gates.
Gate lists checked gate by gate #
A list of well-formed gates is the code of a program.
A valuation consistent with every gate is the evaluation of a well-formed gate list.
A conjunction (false) or a disjunction (true).
Bit-serial comparison #
One step of a comparison chain: comparing one more bit is a disjunction or a conjunction of the literal of the bit with the comparison of the lower bits, by the bit of the constant.
The layout #
The fourteen comparison chains, for slot, column and block widths s, cb and tb, an
input bound n, a step bound T and a hardwired prefix of length X: the offset and the width
of the field read, the direction, the constant and the tie value. Chains 0, 1 and 2 give
the borrows of c - 1, the carries of c + 1 and the borrows of t - 1.
The start of the comparison chains, after the N inputs, the two constants and the N
negations.
The start of the decoder tree, after the fourteen chains of P gates.
The start of the lookup chain, after the 2 ^ (m + 1) - 1 gates of the tree.
Gate i of chain k, comparing the field of width w at input offset off, padded with
zeros to P bits, with the constant K: its literal is the bit of the field (gt) or its
negation, and it combines it with the previous gate of the chain (or the tie value init).
The intended values #
The comparison of chain spec after j bits, on the clause number idx.
The intended value of each wire of the field stage on the bits of the clause number
idx: the inputs, the constants, the negations, the chains after each bit, the indicators of
the low bits of the payload p = idx / 16, and the lookup of x at p.
Correctness #
The gates of the field stage, region by region.
The field stage computes the intended values of its wires on the bits of a clause number.