Documentation

CslibFrontier.Algorithms.WordRAM.Refuter4n.TruthTable

Absorbing operand negations into a four-bit truth table #

A gate row of the packed state of the 4n - 9d refuter (issue #4322, Milestone 4) stores the operation of a gate as its four-bit truth table ttOf. When an operand of the gate is replaced by a negated literal, the negation moves into the table: negating the second input swaps the bits 0 ↔ 1 and 2 ↔ 3 (swapLo), negating the first input swaps 0 ↔ 2 and 1 ↔ 3 (swapHi). absorbNeg t x₀ x₁ does both, reading the two negations from the low bits of the words x₀ and x₁, so it applies to literal codes (litCode, whose low bit is the negation) and to negation bits alike.

This is the one word operation for that step. The input decoder of InputLayout certifies its machine block against it, and the packed substitution substRow of PackedOps is defined with it; another instruction sequence can be certified against the same operation.

Main definitions #

Main results #

Swap the truth-table bits 0 ↔ 1 and 2 ↔ 3 (negate the second input).

Swap the truth-table bits 0 ↔ 2 and 1 ↔ 3 (negate the first input).

Absorb the negations of the operand words x₀, x₁ (their low bits) into the truth table t.

theorem Cslib.Algorithms.WordRAM.Refuter4n.absorbNeg_ttOf (op : Bool → Bool → Bool) (x₀ x₁ : ℕ) :
absorbNeg (ttOf op) x₀ x₁ = ttOf fun (a b : Bool) => op (a ^^ x₀.testBit 0) (b ^^ x₁.testBit 0)

Absorbing into the table of op gives the table of op with the first input negated when the low bit of x₀ is set and the second input negated when the low bit of x₁ is set.

Absorbing negations fixes the zero table.

Negating the second input keeps a table within four bits.

Negating the first input keeps a table within four bits.

theorem Cslib.Algorithms.WordRAM.Refuter4n.absorbNeg_lt {t : ℕ} (ht : t < 16) (x₀ x₁ : ℕ) :
absorbNeg t x₀ x₁ < 16

Absorbing negations keeps a table within four bits.