Documentation

Complexity.Computability.Circuit.Boolean.SemiCircuit

Fair semi-circuits over the full binary basis #

Following Mishra and Santhanam, Section 2.3, a fair semi-circuit is an affine system of equations over 𝔽₂ followed by an acyclic circuit over the full binary basis B₂. Its internal values are parameters, auxiliary variables and gates, all named by natural numbers. The affine system consists of equations ∑ terms = rhs in the parameters and auxiliary variables, each with at most three terms; it is fair when every assignment to the parameters extends to exactly one assignment of the auxiliary variables satisfying all equations (SemiCircuit.WellFormed.solvable, SemiCircuit.WellFormed.unique), which is equivalent to the invertibility of the auxiliary matrix of the source. Each gate applies an arbitrary operation Bool → Bool → Bool to two arguments, each a constant or an internal value with a smaller name, so the order of names is a topological order. The output is a literal.

Equations are named separately from internal values. A child of an internal value t is a gate reading t or an equation containing t (SemiCircuit.children); a gate reading t twice is a single child. The degree of t is its number of children (SemiCircuit.deg).

Rerouting replaces every occurrence of an internal value v by a literal (SemiCircuit.subst), absorbing negations into the operations of gates and the right-hand sides of equations. It preserves the value of every gate and the truth of every equation on assignments giving v the value of the literal (Gate.eval_subst, Equation.holds_subst), and it changes no child of any value other than v and the target of the literal (SemiCircuit.children_subst).

A gate with a constant argument or two equal arguments is degenerate and computes a constant or a literal of an argument (Gate.eval_lit). Of the sixteen operations of B₂, the affine ones (IsAffineOp) have no product term; every other operation has the form (a + α)(b + β) + γ (exists_and_form). An affine gate whose arguments are parameters or auxiliary variables can be moved into the affine system as an equation (affEqn_holds).

Main definitions #

Main results #

References #

Semi-circuits #

A semi-circuit: parameters, auxiliary variables and gates named by natural numbers, the gates and the equations of the affine system, and an output literal. Only the gates in gates and the equations in eqns belong to the semi-circuit; gate and eqn are arbitrary elsewhere.

  • params : Finset ℕ

    The parameters.

  • aux : Finset ℕ

    The auxiliary variables of the affine system.

  • gates : Finset ℕ

    The gates of the acyclic part.

  • gate : ℕ → Gate

    The gate with each name.

  • eqns : Finset ℕ

    The names of the equations of the affine system.

  • eqn : ℕ → Equation

    The equation with each name.

  • out : Lit

    The output.

Instances For

    The internal values: parameters, auxiliary variables and gates.

    Instances For

      All equations of the affine system hold.

      Instances For

        Every gate has the value of its operation on its arguments.

        Instances For

          A consistent assignment of the internal values satisfies every equation and every gate.

          Instances For

            The size: the number of gates plus the number of equations.

            Instances For

              The gates reading t.

              Instances For

                The equations containing t.

                Instances For

                  The children of t: the gates reading it (on the left) and the equations containing it (on the right).

                  Instances For

                    The degree of t: its number of children.

                    Instances For

                      A semi-circuit is well formed when its roles are disjoint, gates read constants or internal values (gates only with smaller names), equations have at most three terms among the parameters and auxiliary variables, the output reads a constant or an internal value, and the affine system is fair: every assignment of the parameters extends to a solution, whose auxiliary values are unique.

                      • disjoint_params_aux : Disjoint C.params C.aux

                        Parameters and auxiliary variables are distinct.

                      • disjoint_params_gates : Disjoint C.params C.gates

                        Parameters and gates are distinct.

                      • disjoint_aux_gates : Disjoint C.aux C.gates

                        Auxiliary variables and gates are distinct.

                      • reads_lt (J : ℕ) : J ∈ C.gates → ∀ i ∈ C.gates, (C.gate J).Reads i → i < J

                        A gate reads only gates with smaller names.

                      • reads_live (J : ℕ) : J ∈ C.gates → ∀ (i : ℕ), (C.gate J).Reads i → i ∈ C.live

                        A gate reads only constants and internal values.

                      • terms_subset (e : ℕ) : e ∈ C.eqns → (C.eqn e).terms ⊆ C.params ∪ C.aux

                        Equations contain only parameters and auxiliary variables.

                      • card_terms_le (e : ℕ) : e ∈ C.eqns → (C.eqn e).terms.card ≤ 3

                        Every equation has at most three terms.

                      • out_live (i : ℕ) : C.out.arg = Arg.node i → i ∈ C.live

                        The output reads a constant or an internal value.

                      • solvable (u : ℕ → Bool) : ∃ (val : ℕ → Bool), (∀ j ∈ C.params, val j = u j) ∧ C.EqnsHold val

                        Every assignment of the parameters extends to a solution of the affine system.

                      • unique (val val' : ℕ → Bool) : (∀ j ∈ C.params, val j = val' j) → C.EqnsHold val → C.EqnsHold val' → ∀ v ∈ C.aux, val v = val' v

                        The solution determines the auxiliary variables (fairness).

                      Instances For

                        Gates do not occur in equations.

                        A gate does not read itself.

                        Rerouting #

                        Reroute the internal value v to the literal ℓ in every gate, equation and the output.

                        Instances For
                          theorem Cslib.Circuits.Boolean.SemiCircuit.eqnsHold_subst {C : SemiCircuit} {v : ℕ} {ℓ : Lit} {val : ℕ → Bool} (h : val v = ℓ.eval val) :
                          (C.subst v ℓ).EqnsHold val ↔ C.EqnsHold val
                          theorem Cslib.Circuits.Boolean.SemiCircuit.gatesHold_subst {C : SemiCircuit} {v : ℕ} {ℓ : Lit} {val : ℕ → Bool} (h : val v = ℓ.eval val) :
                          (C.subst v ℓ).GatesHold val ↔ C.GatesHold val
                          theorem Cslib.Circuits.Boolean.SemiCircuit.consistent_subst {C : SemiCircuit} {v : ℕ} {ℓ : Lit} {val : ℕ → Bool} (h : val v = ℓ.eval val) :
                          (C.subst v ℓ).Consistent val ↔ C.Consistent val
                          theorem Cslib.Circuits.Boolean.SemiCircuit.children_subst {C : SemiCircuit} {v : ℕ} {ℓ : Lit} {z : ℕ} (hzv : z ≠ v) (hzℓ : ℓ.arg ≠ Arg.node z) :
                          (C.subst v ℓ).children z = C.children z

                          Rerouting v changes no child of any internal value other than v and the target of the literal.

                          After rerouting v to t, the children of t are among the former children of t and v.

                          Solutions of the affine system #

                          theorem Cslib.Circuits.Boolean.SemiCircuit.Equation.holds_add_add {E : Equation} {val val' val'' : ℕ → Bool} (h : E.Holds val) (h' : E.Holds val') (h'' : E.Holds val'') :
                          E.Holds (val + val' + val'')
                          theorem Cslib.Circuits.Boolean.SemiCircuit.eqnsHold_add_add {C : SemiCircuit} {val val' val'' : ℕ → Bool} (h : C.EqnsHold val) (h' : C.EqnsHold val') (h'' : C.EqnsHold val'') :
                          C.EqnsHold (val + val' + val'')
                          theorem Cslib.Circuits.Boolean.SemiCircuit.eqnsHold_congr {C : SemiCircuit} {val val' : ℕ → Bool} (hC : C.WellFormed) (h : ∀ i ∈ C.params ∪ C.aux, val i = val' i) :
                          C.EqnsHold val ↔ C.EqnsHold val'
                          theorem Cslib.Circuits.Boolean.SemiCircuit.WellFormed.exists_consistent {C : SemiCircuit} (hC : C.WellFormed) (u : ℕ → Bool) :
                          ∃ (val : ℕ → Bool), (∀ j ∈ C.params, val j = u j) ∧ C.Consistent val

                          Every assignment of the parameters of a well-formed semi-circuit extends to a consistent assignment of all internal values: solve the affine system, then evaluate the gates in the order of their names.

                          On the solutions of the affine system, the internal value t is the affine function c + ∑ j ∈ T, u j of the parameters u.

                          Instances For

                            Every parameter is an affine function of the parameters.

                            theorem Cslib.Circuits.Boolean.SemiCircuit.AffineIn.unique {C : SemiCircuit} (hC : C.WellFormed) {t : ℕ} {c c' : Bool} {T T' : Finset ℕ} (h : AffineIn t c T) (h' : AffineIn t c' T') :
                            c = c' ∧ T = T'

                            The affine expression of an internal value in the parameters is unique.

                            Affine functions of finitely many bits #

                            theorem Cslib.Circuits.Boolean.SemiCircuit.exists_affine_of_add_add {M : Finset ℕ} {g : (ℕ → Bool) → Bool} (hcongr : ∀ (u u' : ℕ → Bool), (∀ j ∈ M, u j = u' j) → g u = g u') (hadd : ∀ (u u' u'' : ℕ → Bool), g (u + u' + u'') = g u + g u' + g u'') :
                            ∃ T ⊆ M, ∀ (u : ℕ → Bool), g u = g 0 + ∑ j ∈ T, u j

                            A function of bits that depends only on the coordinates in M and preserves sums of three points is affine: a constant plus the sum of the coordinates in some T ⊆ M.

                            Every auxiliary variable of a well-formed semi-circuit is an affine function of the parameters on the solutions of the affine system.

                            theorem Cslib.Circuits.Boolean.SemiCircuit.AffineIn.mem_terms {C : SemiCircuit} {t : ℕ} {c : Bool} {T : Finset ℕ} (hC : C.WellFormed) (h : AffineIn t c T) (ht : t ∉ C.params) {x : ℕ} (hx : x ∈ T) :
                            ∃ e ∈ C.eqns, x ∈ (C.eqn e).terms

                            An auxiliary variable can depend only on parameters occurring in the affine system.

                            theorem Cslib.Circuits.Boolean.SemiCircuit.exists_affineIn_of_mem_terms {C : SemiCircuit} (hC : C.WellFormed) {x e : ℕ} (hx : x ∈ C.params) (he : e ∈ C.eqns) (hxe : x ∈ (C.eqn e).terms) :
                            ∃ Q ∈ C.aux, ∃ (c : Bool) (T : Finset ℕ), AffineIn Q c T ∧ x ∈ T

                            A parameter occurring in the affine system is a summand of some auxiliary variable.

                            Changing unread values #

                            theorem Cslib.Circuits.Boolean.SemiCircuit.consistent_update_iff {C : SemiCircuit} {x : ℕ} (hxg : x ∉ C.gates) (hgate : ∀ J ∈ C.gates, ¬(C.gate J).Reads x) (heqn : ∀ e ∈ C.eqns, x ∉ (C.eqn e).terms) (val : ℕ → Bool) (b : Bool) :

                            Changing the value of a name that no gate or equation reads and that is not a gate keeps consistency.

                            theorem Cslib.Circuits.Boolean.SemiCircuit.consistent_of_subst {C : SemiCircuit} {x : ℕ} {ℓ : Lit} (hxg : x ∉ C.gates) (hℓ : ℓ.arg ≠ Arg.node x) {val : ℕ → Bool} (h : (C.subst x ℓ).Consistent val) :
                            C.Consistent (Function.update val x (ℓ.eval val))

                            After rerouting x, which is not a gate, to a literal not reading it, a consistent assignment gives a consistent assignment of the original semi-circuit once x takes the value of the literal.

                            Lifting consistent assignments #

                            Every consistent assignment of C' agrees on the parameters of C with a consistent assignment of C having the same output.

                            Instances For