Documentation

CslibFrontier.Computability.Circuit.Boolean.BitBlast

Bit-blasting circuits over a finite carrier #

Let enc : F → BitString w and decode : BitString w → F satisfy Function.LeftInverse decode enc. The encoding need only be injective: unused bit strings may be decoded arbitrarily. Thus the carrier need not have exactly 2 ^ w elements. A circuit over the full binary basis of F (fullInterpretation (k := 2), where every constant and every operation with at most two arguments is a gate) is simulated on valid encodings. Each gate is replaced by w circuits, one per output bit, each a Boolean function of at most 2 * w argument bits. Its disjunctive normal form costs 2 ^ (2 * w) * (4 * w + 2) + 1 gates by Cslib.Circuits.Synthesis.selected, giving per-symbol cost bitBlastCost w = w * (2 ^ (2 * w) * (4 * w + 2) + 1). The bound is unchanged from the bijective-encoding case. No semantics on malformed input encodings are claimed.

The simulation is stated as a synthesis bound (Cslib.Circuits.Synthesis.bitBlast): if the bits of the F-valued functions feeding the circuit's inputs are available, then the bits of all its outputs can be made available with size * bitBlastCost w further gates.

Main definitions #

Main results #

References #

def Cslib.Circuits.bitsOf {F : Type u_1} {w n : ℕ} (enc : F → BitString w) (φ : (Fin n → Bool) → F) (j : Fin w) :

The j-th bit, under the encoding enc, of an F-valued function φ of the inputs.

The number of De Morgan gates that simulate one gate of the full binary basis on w-bit symbols: each of the w bits of the value is a function of the 2 * w bits of the arguments.

theorem Cslib.Circuits.Synthesis.bitBlast_program {F : Type u_1} {w n : ℕ} (enc : F → BitString w) (decode : BitString w → F) (hdecode : Function.LeftInverse decode enc) {s : Set (BooleanFunction n)} {N g : ℕ} (p : Program (fullSignature 2 F) N g) (φ : Fin N → (Fin n → Bool) → F) (hφ : ∀ (i : Fin N) (j : Fin w), bitsOf enc (φ i) j ∈ s) :
Synthesis Boolean.interpretation s (Set.range fun (wj : Wire N g × Fin w) => bitsOf enc (fun (x : Fin n → Bool) => p.trace fullInterpretation (fun (i : Fin N) => φ i x) wj.1) wj.2) (g * bitBlastCost w)

Bit-blasting a program. If the bits of the functions φ i feeding the inputs of a program over the full binary basis of F are available, then the bits of the values of all its wires can be made available with bitBlastCost w De Morgan gates for each of its gates.

theorem Cslib.Circuits.Synthesis.bitBlast {F : Type u_1} {w n : ℕ} (enc : F → BitString w) (decode : BitString w → F) (hdecode : Function.LeftInverse decode enc) {s : Set (BooleanFunction n)} {N M : ℕ} (c : Circuit (fullSignature 2 F) N M) (φ : Fin N → (Fin n → Bool) → F) (hφ : ∀ (i : Fin N) (j : Fin w), bitsOf enc (φ i) j ∈ s) :
Synthesis Boolean.interpretation s (Set.range fun (oj : Fin M × Fin w) => bitsOf enc (fun (x : Fin n → Bool) => c.eval fullInterpretation (fun (i : Fin N) => φ i x) oj.1) oj.2) (c.size * bitBlastCost w)

Bit-blasting a circuit. If the bits of the functions φ i feeding the inputs of a circuit over the full binary basis of F are available, then the bits of all its outputs can be made available with c.size * bitBlastCost w De Morgan gates.

theorem Cslib.Circuits.Synthesis.bitBlast_synthesis {F : Type u_1} {w n : ℕ} (enc : F → BitString w) (decode : BitString w → F) (hdecode : Function.LeftInverse decode enc) {N : ℕ} {ι : Type u_2} [Finite ι] (Ψ : ι → (Fin N → F) → F) {cost : ℕ} (h : Synthesis fullInterpretation (inputs N) (Set.range Ψ) cost) {s : Set (BooleanFunction n)} (φ : Fin N → (Fin n → Bool) → F) (hφ : ∀ (i : Fin N) (j : Fin w), bitsOf enc (φ i) j ∈ s) :
Synthesis Boolean.interpretation s (Set.range fun (oj : ι × Fin w) => bitsOf enc (fun (x : Fin n → Bool) => Ψ oj.1 fun (i : Fin N) => φ i x) oj.2) (cost * bitBlastCost w)

Bit-blasting a synthesis bound. If a family Ψ of functions of N field inputs is synthesized over the full binary basis from the input projections with cost gates, and the bits of the functions φ i feeding the inputs are available, then the bits of all Ψ o (φ ·) can be made available with cost * bitBlastCost w De Morgan gates.