Documentation

CslibFrontier.Computability.Circuit.Boolean.Combinators

Complexity of circuit combinators #

Size bounds for building a De Morgan circuit from circuits for its parts, stated with complexity in the style of complexity_and_le: a multiplexer, a finite conjunction or disjunction, and reading one block of a tuple of BitString blocks with the other blocks fixed to constants. The bounds are on size only.

Main definitions #

Main results #

Multiplexer: choosing between two outputs by a third costs four gates beyond the three outputs.

theorem Cslib.Circuits.Boolean.complexity_decide_forall_mem_le {n : ℕ} {ι : Type u_1} (s : Finset ι) (F : ι → BooleanFunction n) [dec : (x : BitString n) → Decidable (∀ i ∈ s, F i x = true)] {c : ℕ} (hF : ∀ i ∈ s, complexity interpretation (single (F i)) ≤ c) :
complexity interpretation (single fun (x : Fin n → Bool) => decide (∀ i ∈ s, F i x = true)) ≤ s.card * (c + 1) + 1

Finite conjunction: the conjunction of the tests F i over i ∈ s, each costing at most c gates, costs at most #s (c + 1) + 1 gates. The lemma takes the Decidable instance of the caller's statement, such as Nat.decidableForallFin when ι = Fin k, so it applies directly.

theorem Cslib.Circuits.Boolean.complexity_decide_exists_mem_le {n : ℕ} {ι : Type u_1} (s : Finset ι) (F : ι → BooleanFunction n) [dec : (x : BitString n) → Decidable (∃ i ∈ s, F i x = true)] {c : ℕ} (hF : ∀ i ∈ s, complexity interpretation (single (F i)) ≤ c) :
complexity interpretation (single fun (x : Fin n → Bool) => decide (∃ i ∈ s, F i x = true)) ≤ s.card * (c + 1) + 1

Finite disjunction: the disjunction of the tests F i over i ∈ s, each costing at most c gates, costs at most #s (c + 1) + 1 gates. As in complexity_decide_forall_mem_le, the lemma takes the Decidable instance of the caller's statement.

def Cslib.Circuits.Boolean.blockInputs {n k : ℕ} (z : Fin k → BitString n) (j : Fin k) :
Fin (k * n) → Fin n ⊕ Bool

The substitution that feeds block j of a flat tuple of k blocks from the input and fixes every other block to the corresponding bits of z.

@[simp]

Substituting blockInputs z j and cutting into blocks puts x at block j of z.

theorem Cslib.Circuits.Boolean.complexity_single_block_le {n k : ℕ} (G : (Fin k → BitString n) → Bool) (z : Fin k → BitString n) (j : Fin k) :

Reading one block: fixing every block but block j to the bits of z costs at most two more gates than reading all of them.