Documentation

CslibFrontier.Computability.Circuit.Boolean.AffineDisperserCore.State

Pair-type-generic states and potential bookkeeping for gate elimination #

Shared state representation, pair/partner accounting, spread and affine helpers, and potential bookkeeping shared by the 3.5n (AffineDisperser) and 4n (AffineDisperser4n) gate elimination developments.

A configuration Config supplies:

Main definitions #

Main results #

Configuration of pair representation, degree weights, potential coefficients, and invariants shared by gate-elimination developments (3.5n and 4n).

  • Pair : Type

    Carrier type of parameter pairs.

  • fst : self.Pair → ℕ

    First parameter of a pair.

  • snd : self.Pair → ℕ

    Second parameter of a pair.

  • decEq : DecidableEq self.Pair

    Decidable equality on pairs.

  • cs : ℕ

    Coefficient of circuit size s in W.

  • cq : ℕ

    Coefficient of pair count q in W.

  • ca : ℕ

    Coefficient of a in the potential invariant ΔW ≤ ca * Δa.

  • weight : ℕ → ℕ

    Degree weight of an unpaired parameter.

  • weight_mono {k l : ℕ} : k ≤ l → self.weight k ≤ self.weight l

    Monotonicity of weight.

  • weight_zero : self.weight 0 = 0

    Unused parameters have weight 0.

  • weightBound : ℕ

    Upper bound on weight k.

  • weight_le (k : ℕ) : self.weight k ≤ self.weightBound

    Every degree weight is at most weightBound.

  • locus : Finset self.Pair → (ℕ → Bool) → Prop

    Admissibility predicate on assignments relative to pairs.

  • locus_congr {P : Finset self.Pair} {val val' : ℕ → Bool} : (∀ pr ∈ P, val (self.fst pr) = val' (self.fst pr) ∧ val (self.snd pr) = val' (self.snd pr)) → self.locus P val → self.locus P val'

    Admissibility depends only on coordinates occurring in pairs.

  • phiOK {n : ℕ} : Finset self.Pair → ((ℕ → Bool) → BitString n) → Prop

    Parameter-map affinity invariant parameterized by n, pairs, and phi.

@[reducible]

Whether x is one of the two parameters of the pair pr.

Instances For

    A generic state of gate elimination for a Boolean function on n bits.

    Admissibility of an assignment under cfg.locus and S.pairs.

    x belongs to one of the pairs of S.

    Instances For

      The unpaired parameters of S.

      The number of parameters.

      The number of pairs.

      The effective affine dimension a = m - q.

      The size of the semi-circuit: gates plus equations.

      The potential W = cs * s + cq * q + ∑_{x ∈ unpaired} weight (deg x).

      Validity of a gate-elimination state S for a Boolean function f.

      Spreading bits over a finite set of names and affinity helpers #

      The assignment reading the bits of u on the elements of F, in increasing order, and false elsewhere.

      Spreading a k-bit string over F defines an affine family of assignments.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.spread_of_notMem {F : Finset ℕ} {k : ℕ} (h : F.card = k) (u : BitString k) {i : ℕ} (hi : i ∉ F) :
      spread F h u i = false

      spread F h u assigns false to every index outside F.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.spread_orderIsoOfFin {F : Finset ℕ} {k : ℕ} (h : F.card = k) (u : BitString k) (i : Fin k) :
      spread F h u ↑((F.orderIsoOfFin h) i) = u i

      At the i-th element of F in increasing order, spread F h u equals u i.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.eq_of_spread {F : Finset ℕ} {k : ℕ} (h : F.card = k) {u v : BitString k} (huv : ∀ i ∈ F, spread F h u i = spread F h v i) :
      u = v

      Two k-bit strings whose spread assignments agree on F are equal.

      The identity map on an additive group is affine.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.isAffine_update {α : Type u_1} [Add α] {σ : α → ℕ → Bool} (hσ : BitString.IsAffine σ) (x : ℕ) {ψ : α → Bool} (hψ : BitString.IsAffine ψ) :
      BitString.IsAffine fun (u : α) => Function.update (σ u) x (ψ u)

      Updating an affine family at one name by an affine function keeps it affine.

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

      A constant plus a sum of coordinates of an affine family is affine.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.isAffine_xor_const {α : Type u_1} [Add α] {σ : α → ℕ → Bool} (hσ : BitString.IsAffine σ) (base : ℕ → Bool) :
      BitString.IsAffine fun (u : α) (i : ℕ) => σ u i ^^ base i

      Adding a fixed offset assignment preserves affinity of a family.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.locus_congr {cfg : Config} {n : ℕ} {S : State cfg n} {f : BooleanFunction n} (hS : S.Valid f) {val val' : ℕ → Bool} (hagree : ∀ j ∈ S.params, val j = val' j) (hlocus : S.Locus val) :
      S.Locus val'

      Admissibility of an assignment is preserved when two assignments agree on S.params.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.card_sdiff_image {cfg : Config} {n : ℕ} {S : State cfg n} {f : BooleanFunction n} (hS : S.Valid f) (rep : cfg.Pair → ℕ) (hrep : ∀ pr ∈ S.pairs, cfg.Contains pr (rep pr)) :

      Choosing one representative rep pr from every pair leaves a other parameters.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.out_not_affine_of {cfg : Config} {n : ℕ} {S : State cfg n} (hfix : ∀ {x : ℕ}, x ∈ S.params → ∀ (c : Bool), ∀ R ⊆ S.params, x ∉ R → ∀ (b : Bool), (∀ (val : ℕ → Bool), S.Consistent val → S.Locus val → val x = c + ∑ j ∈ R, val j → S.out.eval val = b) → False) (ha0 : S.params.Nonempty) (c : Bool) {T : Finset ℕ} (hT : T ⊆ S.params) :
      ¬∀ (val : ℕ → Bool), S.Consistent val → S.Locus val → S.out.eval val = c + ∑ j ∈ T, val j

      Helper deriving out_not_affine from false_of_fix.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.not_out_reads_param_of {cfg : Config} {n : ℕ} {S : State cfg n} {x : ℕ} (hout : ¬∀ (val : ℕ → Bool), S.Consistent val → S.Locus val → S.out.eval val = S.out.neg + ∑ j ∈ {x}, val j) :

      Helper deriving ¬ S.out.Reads x from out_not_affine.

      Bookkeeping for the potential #

      The weight contributed by the name x: cfg.weight (S.deg x) if it is an unpaired parameter, and 0 otherwise.

      The weight S.wt x of any name x is at most cfg.weightBound.

      A name x belongs to S.unpaired iff it is an unpaired parameter of S.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.wt_of_mem {cfg : Config} {n : ℕ} {S : State cfg n} {x : ℕ} (hx : x ∈ S.unpaired) :
      S.wt x = cfg.weight (S.deg x)

      For an unpaired parameter x, S.wt x is cfg.weight (S.deg x).

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.wt_of_notMem {cfg : Config} {n : ℕ} {S : State cfg n} {x : ℕ} (hx : x ∉ S.unpaired) :
      S.wt x = 0

      For a name x outside S.unpaired, S.wt x = 0.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.wt_of_paired {cfg : Config} {n : ℕ} {S : State cfg n} {x : ℕ} (hx : S.Paired x) :
      S.wt x = 0

      A paired parameter contributes weight 0.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.wt_of_notMem_params {cfg : Config} {n : ℕ} {S : State cfg n} {x : ℕ} (hx : x ∉ S.params) :
      S.wt x = 0

      A name outside S.params contributes weight 0.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.sum_wt {cfg : Config} {n : ℕ} (S : State cfg n) {N : Finset ℕ} (hN : S.params ⊆ N) :
      ∑ x ∈ N, S.wt x = ∑ x ∈ S.unpaired, cfg.weight (S.deg x)

      Summing S.wt over any superset N of S.params equals the sum of cfg.weight (S.deg x) over S.unpaired.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.W_eq_sum {cfg : Config} {n : ℕ} (S : State cfg n) {N : Finset ℕ} (hN : S.params ⊆ N) :
      S.W = cfg.cs * S.s + cfg.cq * S.q + ∑ x ∈ N, S.wt x

      Expressing the potential S.W with the weight sum taken over any superset N of S.params.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.W_add_le {cfg : Config} {n : ℕ} {S S' : State cfg n} {N : Finset ℕ} (hN : S.params ⊆ N) (hN' : S'.params ⊆ N) (loss gain : ℕ → ℕ) (h : ∀ x ∈ N, S'.wt x + loss x ≤ S.wt x + gain x) :
      S'.W + cfg.cs * S.s + cfg.cq * S.q + ∑ x ∈ N, loss x ≤ S.W + cfg.cs * S'.s + cfg.cq * S'.q + ∑ x ∈ N, gain x

      Potentials compare name by name: if every name of a common set loses loss x and gains at most gain x in weight, the sums of losses and gains bound the change of potential.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.mem_unpaired_of {cfg : Config} {n : ℕ} {S S' : State cfg n} {x : ℕ} (hx : x ∈ S'.unpaired) (hp : x ∈ S.params) (hpairs : S.pairs ⊆ S'.pairs) :

      Unpaired parameters of a state with the same pairs and fewer parameters were unpaired.

      A step of gate elimination from S to S': S' is valid, m + s decreases, Δa ∈ {0, -1, -2}, and ΔW ≤ cfg.ca * Δa, written without subtraction.

      • valid : S'.Valid f

        The new state is valid.

      • lt : S'.m + S'.s < S.m + S.s

        m + s decreases.

      • a_le : S'.a ≤ S.a

        a does not increase.

      • le_a : S.a ≤ S'.a + 2

        a decreases by at most two.

      • potential : S'.W + cfg.ca * S.a ≤ S.W + cfg.ca * S'.a

        ΔW ≤ cfg.ca * Δa.

      A preparatory operation of gate elimination from S to S': S' is valid, with the same m, s and q as S and no larger potential.

      • valid : S'.Valid f

        The new state is valid.

      • m_eq : S'.m = S.m

        The number of parameters is kept.

      • s_eq : S'.s = S.s

        The size is kept.

      • q_eq : S'.q = S.q

        The number of pairs is kept.

      • W_le : S'.W ≤ S.W

        The potential does not increase.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Preparation.a_eq {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S S' : State cfg n} (h : Preparation f S S') :
      S'.a = S.a

      A preparatory operation preserves a = m - q.

      theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Step.of_preparation {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S S₁ S' : State cfg n} (hp : Preparation f S S₁) (h : Step f S₁ S') :
      Step f S S'

      A preparatory operation followed by a step is a step.

      Pairs and partners #

      r is the partner of w: they form a pair.

      Instances For
        @[instance_reducible]

        Decidability of State.IsPartner.

        The pairs avoiding w.

        The pairs with a member in F.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.paired_congr {cfg : Config} {n : ℕ} {S S' : State cfg n} (h : S'.pairs = S.pairs) {x : ℕ} :
        S'.Paired x ↔ S.Paired x

        Two states with the same pairs have the same paired names.

        Two states with the same parameters and pairs have the same unpaired parameters.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.isPartner_of_contains {cfg : Config} {n : ℕ} {S : State cfg n} {pr : cfg.Pair} (hpr : pr ∈ S.pairs) {p r : ℕ} (hp : cfg.Contains pr p) (hr : cfg.Contains pr r) (hne : p ≠ r) :
        S.IsPartner p r

        If pr ∈ S.pairs contains p and r with p ≠ r, then r is the partner of p.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.mem_params_of_contains {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {pr : cfg.Pair} (hpr : pr ∈ S.pairs) {p : ℕ} (hp : cfg.Contains pr p) :

        Any name contained in a pair of a valid state is a parameter.

        Every paired name of a valid state is a parameter.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.pair_unique {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {w : ℕ} {pr pr' : cfg.Pair} (hpr : pr ∈ S.pairs) (hpr' : pr' ∈ S.pairs) (h : cfg.Contains pr w) (h' : cfg.Contains pr' w) :
        pr = pr'

        A pair containing w is unique.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.exists_partner {cfg : Config} {n : ℕ} {S : State cfg n} {p : ℕ} (hp : S.Paired p) :
        ∃ (r : ℕ), S.IsPartner p r

        Every paired parameter has a partner.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.IsPartner.symm {cfg : Config} {n : ℕ} {S : State cfg n} {p r : ℕ} (h : S.IsPartner p r) :
        S.IsPartner r p

        The partner relation State.IsPartner is symmetric.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.IsPartner.paired {cfg : Config} {n : ℕ} {S : State cfg n} {w r : ℕ} (h : S.IsPartner w r) :
        S.Paired w

        A parameter that has a partner is paired.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.partner_ne {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {p r : ℕ} (h : S.IsPartner p r) :
        r ≠ p

        In a valid state, a parameter is distinct from its partner.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.partner_mem {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {p r : ℕ} (h : S.IsPartner p r) :

        In a valid state, the partner of a parameter is a parameter.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.isPartner_unique {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {w r r' : ℕ} (h : S.IsPartner w r) (h' : S.IsPartner w r') :
        r = r'

        A partner is unique.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.isPartner_unique_right {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {u p r : ℕ} (hup : S.IsPartner u r) (hpr : S.IsPartner p r) :
        u = p

        Two parameters sharing the same partner are equal.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.sum_partner_le {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) (w : ℕ) (N : Finset ℕ) (c : ℕ) :
        (∑ x ∈ N, if S.IsPartner w x then c else 0) ≤ c

        The partners of w contribute at most one summand.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.paired_filter_iff {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {F : Finset ℕ} {u : ℕ} (huF : u ∉ F) :
        (∃ pr ∈ {pr ∈ S.pairs | ¬(cfg.fst pr ∈ F ∨ cfg.snd pr ∈ F)}, cfg.Contains pr u) ↔ S.Paired u ∧ ∀ x ∈ F, ¬S.IsPartner u x

        A paired parameter outside F is in a pair meeting F exactly when its partner is in F.

        The parameters of a valid state are at least as many as its pairs.

        At most |F| pairs meet a set F of parameters.

        The number of pairs meeting {w} is 1 if w is paired and 0 otherwise.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.Valid.card_pairsMeeting_insert {cfg : Config} {n : ℕ} {f : BooleanFunction n} {S : State cfg n} (hS : S.Valid f) {F : Finset ℕ} {x : ℕ} (hx : x ∉ F) (hpart : ∀ y ∈ F, ¬S.IsPartner x y) :

        Adding to F a parameter that is not the partner of a member of F adds its pair, if any.

        theorem Cslib.Circuits.Boolean.AffineDisperserCore.State.children_eq_singleton {cfg : Config} {n : ℕ} {S : State cfg n} {x : ℕ} {H : ℕ ⊕ ℕ} (hle : S.deg x ≤ 1) (hH : H ∈ S.children x) :

        A parameter of degree at most 1 containing H among its children has {H} as its set of children.