Documentation

CslibFrontier.Computability.Circuit.Boolean.AffineDisperserCore.Operations

Generic state operations and validity transport for gate elimination #

Shared state operations, parameter-map transport, and validity-preservation lemmas shared by the 3.5n (AffineDisperser) and 4n (AffineDisperser4n) gate-elimination developments:

Main results #

theorem Cslib.Circuits.Boolean.AffineDisperserCore.isAffine_lit_eval {α : Type u_1} [Add α] {τ : α → ℕ → Bool} (hτ : BitString.IsAffine τ) (ℓ : SemiCircuit.Lit) :
BitString.IsAffine fun (u : α) => ℓ.eval (τ u)

Evaluating a literal ℓ along an affine family of assignments τ defines an affine Boolean function.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.isAffine_add_add_sum {α : Type u_1} [Add α] {τ : α → ℕ → Bool} (hτ : BitString.IsAffine τ) (Q : ℕ) (c : Bool) (R : Finset ℕ) :
BitString.IsAffine fun (u : α) => τ u Q + c + ∑ j ∈ R, τ u j

Adding coordinate Q, constant c, and a sum over R of an affine family preserves affinity.

Transporting validity #

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.of_phi {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S S' : State cfg n} (hS : S.Valid f) (hparams : S'.params = S.params) (hpairs : S'.pairs = S.pairs) (hphi : S'.phi = S.phi) (hwf : S'.WellFormed) (hcomp : ∀ (val : ℕ → Bool), S'.Consistent val → S'.Locus val → S'.out.eval val = f (S'.phi val)) :
S'.Valid f

A state with the parameters, pairs, parameter map, and admissibility of a valid state is valid when its semi-circuit is well formed and computes f on admissible assignments.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.of_liftsTo {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S S' : State cfg n} (hS : S.Valid f) (hparams : S'.params = S.params) (hpairs : S'.pairs = S.pairs) (hphi : S'.phi = S.phi) (hwf : S'.WellFormed) (hlift : ∀ (val : ℕ → Bool), S'.Consistent val → S'.Locus val → ∃ (w : ℕ → Bool), S.Consistent w ∧ (∀ j ∈ S.params, w j = val j) ∧ S'.out.eval val = S.out.eval w) :
S'.Valid f

A state with the parameters, pairs, and parameter map of a valid state is valid when its semi-circuit is well formed and its consistent admissible assignments lift to S.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.of_semiCircuit_liftsTo {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S S' : State cfg n} (hS : S.Valid f) (hparams : S'.params = S.params) (hpairs : S'.pairs = S.pairs) (hphi : S'.phi = S.phi) (hwf : S'.WellFormed) (hlift : S'.LiftsTo S.toSemiCircuit) :
S'.Valid f

Validity from an unconditional SemiCircuit.LiftsTo.

structure Cslib.Circuits.Boolean.AffineDisperserCore.State.Transport {cfg : Config} {n : ℕ} (S S' : State cfg n) (σ : (ℕ → Bool) → ℕ → Bool) :

The obligations for transporting validity from S to S' along a map σ from the assignments of S' to those of S.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.of_transport {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S S' : State cfg n} (hS : S.Valid f) {σ : (ℕ → Bool) → ℕ → Bool} (hwf : S'.WellFormed) (h : S.Transport S' σ) :
S'.Valid f

Validity transported along a map σ from the assignments of a new, well-formed state to those of a valid state.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.not_reads_self {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {J : ℕ} (hJ : J ∈ S.gates) :
¬(S.gate J).Reads J

A gate does not read itself.

Restrictions (UF) and (PF) #

Restrict the parameter x to the literal ℓ, keeping the pairs P.

@[simp]

Restricting x removes x from the parameters of S.

@[simp]
theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.restrict_pairs {cfg : Config} {n : ℕ} (S : State cfg n) (x : ℕ) (ℓ : SemiCircuit.Lit) (P : Finset cfg.Pair) :
(S.restrict x ℓ P).pairs = P

The pairs of S.restrict x ℓ P are P.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.restrict_children {cfg : Config} {n : ℕ} (S : State cfg n) (x : ℕ) (ℓ : SemiCircuit.Lit) (P : Finset cfg.Pair) (z : ℕ) :
(S.restrict x ℓ P).children z = (S.subst x ℓ).children z

The children of z in S.restrict x ℓ P are its children after substituting x with ℓ.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.restrict_size {cfg : Config} {n : ℕ} (S : State cfg n) (x : ℕ) (ℓ : SemiCircuit.Lit) (P : Finset cfg.Pair) :
(S.restrict x ℓ P).size = S.size

Restricting a parameter preserves the size of the state.

@[simp]
theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.restrict_gate {cfg : Config} {n : ℕ} (S : State cfg n) (x : ℕ) (ℓ : SemiCircuit.Lit) (P : Finset cfg.Pair) (J : ℕ) :
(S.restrict x ℓ P).gate J = (S.gate J).subst x ℓ

Restricting x to ℓ substitutes x with ℓ in every gate.

@[simp]
theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.restrict_eqn {cfg : Config} {n : ℕ} (S : State cfg n) (x : ℕ) (ℓ : SemiCircuit.Lit) (P : Finset cfg.Pair) (e : ℕ) :
(S.restrict x ℓ P).eqn e = (S.eqn e).subst x ℓ

Restricting x to ℓ substitutes x with ℓ in every equation.

Fix the parameter w to the constant b, retaining the pairs avoiding w.

@[simp]

Fixing w to a constant removes w from S.params.

@[simp]

Fixing w to a constant retains the pairs avoiding w.

Fixing a parameter to a constant preserves the size of the state.

@[simp]
theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.fixConst_gate {cfg : Config} {n : ℕ} (S : State cfg n) (w : ℕ) (b : Bool) (J : ℕ) :

Fixing w to b substitutes w with Lit.const b in every gate.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.fixConst_children {cfg : Config} {n : ℕ} (S : State cfg n) {w : ℕ} (b : Bool) {z : ℕ} (hz : z ≠ w) :
(S.fixConst w b).children z = S.children z

Fixing w to a constant preserves the children of every z ≠ w.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.restrict_of {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {x : ℕ} {ℓ : SemiCircuit.Lit} {P : Finset cfg.Pair} (hmem : x ∈ S.params) (hreads : ∀ (y : ℕ), ℓ.Reads y → y ∈ S.params ∧ y ≠ x) (hsub : P ⊆ S.pairs) (hav : ∀ pr ∈ P, ¬cfg.Contains pr x) (hphi : cfg.phiOK P (S.restrict x ℓ P).phi) (hlocus : ∀ (val : ℕ → Bool), (S.restrict x ℓ P).Locus val → S.Locus (Function.update val x (ℓ.eval val))) :
(S.restrict x ℓ P).Valid f

Generic validity transport for S.restrict x ℓ P given phiOK and locus preservation.

Pair creation (PC) #

def Cslib.Circuits.Boolean.AffineDisperserCore.State.addPair {cfg : Config} {n : ℕ} (S : State cfg n) (pr : cfg.Pair) :
State cfg n

Add a pair pr to the state, leaving the semi-circuit and parameter map unchanged.

The hypotheses of pair creation (PC): both members are distinct unpaired parameters.

  • fst_unpaired : cfg.fst pr ∈ S.unpaired

    The first endpoint is an unpaired parameter.

  • snd_unpaired : cfg.snd pr ∈ S.unpaired

    The second endpoint is an unpaired parameter.

  • ne : cfg.fst pr ≠ cfg.snd pr

    The two endpoints are distinct.

@[simp]

Pair creation preserves the parameters.

@[simp]

Pair creation inserts pr into S.pairs.

Pair creation preserves the size of the state.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.addPair_children {cfg : Config} {n : ℕ} (S : State cfg n) (pr : cfg.Pair) (z : ℕ) :
(S.addPair pr).children z = S.children z

Pair creation preserves the children of every variable.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.addPair_q {cfg : Config} {n : ℕ} {S : State cfg n} {pr : cfg.Pair} (h : S.AddPairOK pr) :
(S.addPair pr).q = S.q + 1

Pair creation increases q by 1.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.addPair_of {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {pr : cfg.Pair} (h : S.AddPairOK pr) (hphi : cfg.phiOK (insert pr S.pairs) S.phi) (hlocus : ∀ (val : ℕ → Bool), (S.addPair pr).Locus val → S.Locus val) :
(S.addPair pr).Valid f

Generic validity preservation for pair creation (PC) given phiOK and locus weakening.

Deleting a gate (D1) and (D2) #

Delete the gate J, rerouting its uses to the literal ℓ.

Hypotheses for deleting gate J with replacement ℓ relative to S.Locus.

@[simp]

Deleting a gate preserves the parameters of the state.

@[simp]

Deleting a gate preserves the pairs of the state.

@[simp]

Deleting a gate preserves the parameter map phi.

@[simp]
theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.deleteGate_gate {cfg : Config} {n : ℕ} (S : State cfg n) (J : ℕ) (ℓ : SemiCircuit.Lit) (K : ℕ) :
(S.deleteGate J ℓ).gate K = (S.gate K).subst J ℓ

Deleting gate J with replacement ℓ substitutes J with ℓ in every gate.

@[simp]
theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.deleteGate_eqn {cfg : Config} {n : ℕ} (S : State cfg n) (J : ℕ) (ℓ : SemiCircuit.Lit) (e : ℕ) :
(S.deleteGate J ℓ).eqn e = (S.eqn e).subst J ℓ

Deleting gate J with replacement ℓ substitutes J with ℓ in every equation.

@[simp]

Deleting gate J removes J from S.gates.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.deleteGate_size {cfg : Config} {n : ℕ} {S : State cfg n} {J : ℕ} {ℓ : SemiCircuit.Lit} (hJ : J ∈ S.gates) :
(S.deleteGate J ℓ).size + 1 = S.size

Deleting a gate decreases the size of the state by 1.

After deleting gate J with replacement ℓ, the children of z are contained in the children of z after substituting J with ℓ with .inl J removed.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.deleteGate_children_of_ne {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {J : ℕ} {ℓ : SemiCircuit.Lit} (hJ : J ∈ S.gates) {z : ℕ} (hz : z ∈ S.params) (hzℓ : ¬ℓ.Reads z) :
(S.deleteGate J ℓ).children z ⊆ (S.children z).erase (Sum.inl J)

Deleting a gate removes it from the children of every parameter other than the target of ℓ.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.deleteGate {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {J : ℕ} {ℓ : SemiCircuit.Lit} (h : S.DeleteGateLocusOK J ℓ) :
(S.deleteGate J ℓ).Valid f

Deleting a gate preserves validity on admissible assignments.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.deleteGate_of_ok {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {J : ℕ} {ℓ : SemiCircuit.Lit} (h : S.DeleteGateOK J ℓ) :
(S.deleteGate J ℓ).Valid f

Deleting a gate from an unconditional SemiCircuit.DeleteGateOK preserves validity.

Deleting and dropping equations (D3) and (D4) #

Delete the equation e, which reads v = ℓ, and the auxiliary variable v, rerouting v to ℓ.

@[simp]

Deleting an equation preserves the parameters of the state.

@[simp]

Deleting an equation preserves the pairs of the state.

@[simp]
theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.deleteEqn_phi {cfg : Config} {n : ℕ} (S : State cfg n) (e v : ℕ) (ℓ : SemiCircuit.Lit) :
(S.deleteEqn e v ℓ).phi = S.phi

Deleting an equation preserves the parameter map phi.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.deleteEqn_size {cfg : Config} {n : ℕ} {S : State cfg n} {e v : ℕ} {ℓ : SemiCircuit.Lit} (h : S.DeleteEqnOK e v ℓ) :
(S.deleteEqn e v ℓ).size + 1 = S.size

Deleting an equation decreases the size of the state by 1.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.deleteEqn_children_subset {cfg : Config} {n : ℕ} {S : State cfg n} {e v : ℕ} {ℓ : SemiCircuit.Lit} (z : ℕ) :
(S.deleteEqn e v ℓ).children z ⊆ ((S.subst v ℓ).children z).erase (Sum.inr e)

After deleting equation e and auxiliary variable v with replacement ℓ, the children of z are contained in the children of z after substituting v with ℓ with .inr e removed.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.deleteEqn_children_of_ne {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {e v : ℕ} {ℓ : SemiCircuit.Lit} (h : S.DeleteEqnOK e v ℓ) {z : ℕ} (hz : z ∈ S.params) (hzℓ : ¬ℓ.Reads z) :
(S.deleteEqn e v ℓ).children z ⊆ (S.children z).erase (Sum.inr e)

Deleting an equation removes it from the children of every parameter other than the target of ℓ.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.deleteEqn {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {e v : ℕ} {ℓ : SemiCircuit.Lit} (h : S.DeleteEqnOK e v ℓ) :
(S.deleteEqn e v ℓ).Valid f

Deleting an equation v = ℓ with its auxiliary variable preserves validity.

Delete the equation e together with an auxiliary variable v occurring nowhere else.

@[simp]

Dropping an equation preserves the parameters of the state.

@[simp]

Dropping an equation preserves the pairs of the state.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.dropEqn_size {cfg : Config} {n : ℕ} {S : State cfg n} {e v : ℕ} (h : S.DropEqnOK e v) :
(S.dropEqn e v).size + 1 = S.size

Dropping an equation decreases the size of the state by 1.

Dropping equation e removes .inr e from the children of z.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.dropEqn {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {e v : ℕ} (h : S.DropEqnOK e v) :
(S.dropEqn e v).Valid f

Dropping an equation with an auxiliary variable occurring only there preserves validity.

Delete an equation without terms.

@[simp]

Dropping a trivial equation preserves the parameters of the state.

@[simp]

Dropping a trivial equation preserves the pairs of the state.

Dropping a trivial equation decreases the size of the state by 1.

Dropping trivial equation e removes .inr e from the children of z.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.dropTrivialEqn {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {e : ℕ} (he : e ∈ S.eqns) (hterms : (S.eqn e).terms = ∅) :

Deleting an equation without terms preserves validity.

Moving and rewiring gates #

Move the affine gate J into the affine system as auxiliary variable J with equation e.

@[simp]

Moving an affine gate into the affine system preserves the parameters of the state.

@[simp]

Moving an affine gate into the affine system preserves the pairs of the state.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.moveAffine_size {cfg : Config} {n : ℕ} {S : State cfg n} {J e : ℕ} (h : S.MoveOK J e) :
(S.moveAffine J e).size = S.size

Moving an affine gate into the affine system preserves the size of the state.

Moving an affine gate into the affine system decreases the number of gates by 1.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.moveAffine_deg_le {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {J e : ℕ} (h : S.MoveOK J e) {z : ℕ} (hz : z ∈ S.params) :
(S.moveAffine J e).deg z ≤ S.deg z

Moving a gate into the affine system does not increase the degree of any parameter.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.moveAffine {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {J e : ℕ} (h : S.MoveOK J e) :
(S.moveAffine J e).Valid f

Moving an affine gate reading no gates into the affine system preserves validity.

Replace the gate J by the gate g.

@[simp]

Rewiring a gate preserves the parameters of the state.

@[simp]

Rewiring a gate preserves the pairs of the state.

Rewiring a gate preserves the size of the state.

Rewiring a gate preserves the set of gate names.

A gate K is a child of z in S.rewire J g iff K ∈ S.gates and the gate at K (which is g when K = J) reads z.

Rewiring a gate preserves the equation children of every variable.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.rewire {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {J : ℕ} {g : SemiCircuit.Gate} (h : S.RewireOK J g) :
(S.rewire J g).Valid f

Rewiring a gate preserves validity.

Affine reparameterisation (AR) #

def Cslib.Circuits.Boolean.AffineDisperserCore.State.swap {cfg : Config} {n : ℕ} (S : State cfg n) (x Q : ℕ) (c : Bool) (T : Finset ℕ) :
State cfg n

Exchange the unpaired parameter x with the auxiliary variable Q = c + ∑ j ∈ T, u j depending on it.

structure Cslib.Circuits.Boolean.AffineDisperserCore.State.SwapOK {cfg : Config} {n : ℕ} (S : State cfg n) (x Q : ℕ) (c : Bool) (T : Finset ℕ) :

The hypotheses of the affine reparameterisation (AR).

  • mem : x ∈ S.params

    x is a parameter of S.

  • unpaired : ¬S.Paired x

    x is not paired.

  • aux : Q ∈ S.aux

    Q is an auxiliary variable of S.

  • affine : SemiCircuit.AffineIn Q c T

    Q has affine representation c + ∑ j ∈ T, val j.

  • mem_T : x ∈ T

    x occurs in T.

@[simp]
theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.swap_params {cfg : Config} {n : ℕ} (S : State cfg n) (x Q : ℕ) (c : Bool) (T : Finset ℕ) :
(S.swap x Q c T).params = insert Q (S.params.erase x)

Exchanging x and Q replaces x with Q in S.params.

@[simp]
theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.swap_pairs {cfg : Config} {n : ℕ} (S : State cfg n) (x Q : ℕ) (c : Bool) (T : Finset ℕ) :
(S.swap x Q c T).pairs = S.pairs

Exchanging x and Q preserves the pairs of the state.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.swap_size {cfg : Config} {n : ℕ} (S : State cfg n) (x Q : ℕ) (c : Bool) (T : Finset ℕ) :
(S.swap x Q c T).size = S.size

Exchanging x and Q preserves the size of the state.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.swap_children {cfg : Config} {n : ℕ} (S : State cfg n) (x Q : ℕ) (c : Bool) (T : Finset ℕ) (z : ℕ) :
(S.swap x Q c T).children z = S.children z

Exchanging x and Q preserves the children of every variable.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.swap_of {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {x Q : ℕ} {c : Bool} {T : Finset ℕ} (h : S.SwapOK x Q c T) (hphi : cfg.phiOK S.pairs (S.swap x Q c T).phi) :
(S.swap x Q c T).Valid f

Generic validity preservation for (AR) given cfg.phiOK on (S.swap x Q c T).phi.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.swap_m {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {x Q : ℕ} {c : Bool} {T : Finset ℕ} (h : S.SwapOK x Q c T) :
(S.swap x Q c T).m = S.m

An affine reparameterisation (AR) preserves m.

theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.swap_W_le_of {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {x Q : ℕ} {c : Bool} {T : Finset ℕ} (h : S.SwapOK x Q c T) {lossX gainQ : ℕ} (hloss : lossX ≤ S.wt x) (hgain : (S.swap x Q c T).wt Q ≤ gainQ) :
(S.swap x Q c T).W + lossX ≤ S.W + gainQ

Potential comparison helper for (AR): if replacing x by Q increases weight on Q by at most gainQ and lossX ≤ S.wt x, then (S.swap x Q c T).W + lossX ≤ S.W + gainQ.