Documentation

CslibFrontier.Computability.MCSP.MultiNPHard.Window

Window templates #

The reduction of Ilango, Loff and Oliveira [IlangoLoffOliveira2020, §4.2, pp. 22:20–22:21] gives a circuit minimizer a random truth table T on p input bits together with, for each set A_i of a set system, a circuit whose gates depend only on the entries of T inside A_i; its last gate computes T restricted to A_i. Covering the inputs with c of the sets, T is the OR of c such windows, which costs c - 1 further gates (completeness, [p. 22:22, Lemma 15]).

This file builds such a family in the constant-free De Morgan basis, as one program template A T on p inputs, and proves the facts the reduction uses about it. The source writes each window as a canonical DNF [pp. 22:19–22:20]; here all windows share the p negations, a constant-zero gate and the p · 2^p gates of prefix conjunctions, and window i is an OR chain: its gate window i y is the OR of the accepted inputs of A i up to y, in the order of BitString.equivFin. This is a construction choice internal to the proof: like the source's, its gates depend on T only through the entries inside the window they belong to.

Main definitions #

Main results #

References #

The gates of a window template on p inputs with t windows: a negation of each input, a constant-zero gate, a prefix conjunction grid y k of the first k + 1 literals of each input y, and a gate window i y of window i for each input y.

  • neg {p t : ℕ} (i : Fin p) : Gate p t

    The negation of input i.

  • zero {p t : ℕ} : Gate p t

    The constant zero.

  • grid {p t : ℕ} (y : Fin (2 ^ p)) (k : Fin p) : Gate p t

    Whether the first k + 1 input bits agree with those of y.

  • window {p t : ℕ} (i : Fin t) (y : Fin (2 ^ p)) : Gate p t

    Whether the input is at most y, lies in window i and is accepted by the table.

@[instance_reducible]
def Cslib.MultiMCSP.Window.instDecidableEqGate.decEq {p✝ t✝ : ℕ} (x✝ x✝¹ : Gate p✝ t✝) :
Decidable (x✝ = x✝¹)

The number of gates of a window template: p negations, one zero, 2^p · p prefix conjunctions and t · 2^p window gates.

theorem Cslib.MultiMCSP.Window.gateCount_eq (p t : ℕ) :
gateCount p t = p + (1 + (2 ^ p * p + t * 2 ^ p))

The numbering of the gates: negations, then zero, then the prefix conjunctions of each input in turn, then the gates of each window in turn.

@[simp]
theorem Cslib.MultiMCSP.Window.Gate.val_equivFin_neg {p t : ℕ} (i : Fin p) :
↑((equivFin p t) (neg i)) = ↑i
@[simp]
theorem Cslib.MultiMCSP.Window.Gate.val_equivFin_grid {p t : ℕ} (y : Fin (2 ^ p)) (k : Fin p) :
↑((equivFin p t) (grid y k)) = p + (1 + (↑k + p * ↑y))
@[simp]
theorem Cslib.MultiMCSP.Window.Gate.val_equivFin_window {p t : ℕ} (i : Fin t) (y : Fin (2 ^ p)) :
↑((equivFin p t) (window i y)) = p + (1 + (2 ^ p * p + (↑y + 2 ^ p * ↑i)))

The window a gate belongs to: i for the gates window i y, none for the shared gates.

@[simp]
theorem Cslib.MultiMCSP.Window.Gate.set_window {p t : ℕ} (i : Fin t) (y : Fin (2 ^ p)) :
(window i y).set = some i

The operation of each gate: NOT for the negations, AND for zero and the prefix conjunctions, OR for the window gates.

def Cslib.MultiMCSP.Window.value {p t : ℕ} (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) :
Gate p t → (Fin p → Bool) → Bool

The function each gate computes, in closed form; A i is window i and T the truth table.

@[simp]
theorem Cslib.MultiMCSP.Window.value_neg {p t : ℕ} (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) (i : Fin p) (x : Fin p → Bool) :
value A T (Gate.neg i) x = !x i
@[simp]
theorem Cslib.MultiMCSP.Window.value_zero {p t : ℕ} (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) (x : Fin p → Bool) :
theorem Cslib.MultiMCSP.Window.value_grid {p t : ℕ} (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) (y : Fin (2 ^ p)) (k : Fin p) (x : Fin p → Bool) :
value A T (Gate.grid y k) x = decide (∀ b ≤ k, x b = (↑y).testBit ↑b)
theorem Cslib.MultiMCSP.Window.value_window {p t : ℕ} (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) (i : Fin t) (y : Fin (2 ^ p)) (x : Fin p → Bool) :
def Cslib.MultiMCSP.Window.template {p t : ℕ} (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) :
(Fin p → Bool) → Fin (gateCount p t) → Bool

The window template: the functions of all gates, in the order of Gate.equivFin.

theorem Cslib.MultiMCSP.Window.template_apply {p t : ℕ} (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) (x : Fin p → Bool) (j : Fin (gateCount p t)) :
template A T x j = value A T ((Gate.equivFin p t).symm j) x
@[simp]
theorem Cslib.MultiMCSP.Window.template_equivFin {p t : ℕ} (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) (κ : Gate p t) (x : Fin p → Bool) :
template A T x ((Gate.equivFin p t) κ) = value A T κ x
def Cslib.MultiMCSP.Window.tableFun {p : ℕ} (T : Fin (2 ^ p) → Bool) :
(Fin p → Bool) → Bool

The function whose truth table is T, inputs read in the order of BitString.equivFin.

@[simp]
theorem Cslib.MultiMCSP.Window.tableFun_apply {p : ℕ} (T : Fin (2 ^ p) → Bool) (x : Fin p → Bool) :

Locality #

theorem Cslib.MultiMCSP.Window.value_congr {p t : ℕ} (A : Fin t → Finset (Fin (2 ^ p))) {T T' : Fin (2 ^ p) → Bool} (κ : Gate p t) (h : ∀ (i : Fin t), κ.set = some i → ∀ y ∈ A i, T y = T' y) :
value A T κ = value A T' κ

Locality. A gate of window i computes a function that depends on T only through its entries in A i; the other gates compute the same function for every T.

The last input 2^p - 1, whose window gates compute the windows of T.

theorem Cslib.MultiMCSP.Window.value_window_last {p t : ℕ} (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) (i : Fin t) (x : Fin p → Bool) :

The window identity. The last gate of window i computes T restricted to A i.

The program #

theorem Cslib.MultiMCSP.Window.exists_program {p t : ℕ} [NeZero p] (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) :

The template as a program. For p ≥ 1, a program over the constant-free De Morgan basis with one gate for each gate of the layout computes the window template, and its gate Gate.equivFin p t κ performs the operation κ.op.

Cost #

Exact cost of the template. For p ≥ 1, over any De Morgan basis, computing all gate functions of a window template costs exactly the number of distinct ones that are not input projections. This is the analogue for this template of [IlangoLoffOliveira2020, Proposition 14, pp. 22:21–22:22].

theorem Cslib.MultiMCSP.Window.ecomplexityGiven_tableFun_le {p t : ℕ} {σ : Circuits.Signature} {I : Circuits.Interpretation σ Bool} [Circuits.Boolean.DeMorganBasis I] (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) (C : Finset (Fin t)) (hC : ∀ (y : Fin (2 ^ p)), ∃ i ∈ C, y ∈ A i) :

The table given the template. If the windows C cover every input, then T costs at most #C - 1 gates given the template: it is the OR of the last gates of those windows. This is the analogue for this template of [IlangoLoffOliveira2020, Lemma 15, p. 22:22], with the sharper bound #C - 1.

theorem Cslib.MultiMCSP.Window.ecomplexity_append_le {p t : ℕ} {σ : Circuits.Signature} {I : Circuits.Interpretation σ Bool} [Circuits.Boolean.DeMorganBasis I] [NeZero p] (A : Fin t → Finset (Fin (2 ^ p))) (T : Fin (2 ^ p) → Bool) (C : Finset (Fin t)) (hC : ∀ (y : Fin (2 ^ p)), ∃ i ∈ C, y ∈ A i) :

Completeness. For p ≥ 1, if the windows C cover every input, the template followed by T costs at most the number of distinct non-input gate functions plus #C - 1. This is the analogue for this template of [IlangoLoffOliveira2020, Lemma 15, p. 22:22].