Documentation

CslibFrontier.Computability.Circuit.Frontier.TensorNetwork.Recursion

The contraction recursion and its correctness #

This file assembles the recursive contraction algorithm of [OAI26k] (§D.4.7, p. 64) from its active calls, and proves it correct by induction from the leaves.

One node (TensorNetwork.nodeSplitting). For a network whose edges run from rows to columns, a packing Q of its edges into packets of 2 ^ a slots, and a nonzero grid point t of valuation i < a, group the vertices by their symbol in coordinate i of Q (packingGroup). The packing bridge packingGroup_src_tgt orients the groups, so the Cauchy matrix at T = t + α ζ has the mode splitting TensorNetwork.cauchyModeSplitting (§D.4.5, p. 62). At a call with input precision p, TensorNetwork.callSplitting is this splitting for the network reduced modulo 2 ^ p_t, p_t = p + 8 h D_t + 8 M (a + 1): the schedule's ContractionSchedule.nodePrecision at the valuation of t, the precision of Lemma D.5.

One call from its children. If every value v t k reduces modulo 2 ^ p_t to the sum over the mode tuples of the products of the contractions of the children (the right side of (D.16)), then interpolation and tapered recovery return the contraction modulo 2 ^ p (TensorNetwork.exists_recoverFromValues_eq_add_of_children). The children's contractions may come from any contraction oracle (TensorNetwork.ContractionOracle) that is correct modulo the precision it is given: a child over B ⧸ (2 ^ p_t) is lifted to B along a section of the reduction and renumbered by Fin (TensorNetwork.finLift, TensorNetwork.ContractionOracle.evalLift), and the oracle's value then reduces to its contraction (TensorNetwork.ContractionOracle.mk_evalLift). The value of an active node is TensorNetwork.nodeValue, the values of a call are TensorNetwork.callValues, and the recovered value is TensorNetwork.callValue (TensorNetwork.exists_callValue_eq_add).

The recursion (TensorNetwork.contractRec). A call receives a network on Fin n vertices and Fin m edges, its sides, its depth d and its precision p. A schedule gives the parameters a, u, h and the degree bound Δ of a call from its depth and its number of edges (CallParams), or none at a leaf; the manuscript's schedule is ContractionSchedule.callParams. The call is active when its guard holds (CallParams.Guard): the parameters meet the hypotheses of Lemma D.5 (CallParams.Admissible, with u ≤ a and enough interpolation points), and the network runs from rows to columns with at most Δ ports at each end of each vertex (TensorNetwork.RowsToColumnsLE). It packs the edges with PacketPacking.packing (Lemma D.3, r = 64), takes the first M (2 L - 1) + 1 of a fixed family of interpolation points, and evaluates each child by a recursive call at depth d + 1 and precision p_t. A leaf, an inactive call, and a child that does not have fewer edges than its parent are evaluated by the contraction itself, the direct summation of the manuscript's leaves. The recursion is well founded on the number of edges.

Correctness (TensorNetwork.exists_contractRec_eq_add). For interpolation points with unit differences, every call returns the contraction modulo 2 ^ p, for every schedule: the manuscript's "induction from the leaves" (p. 64) becomes strong induction on the number of edges. So the parameter schedule (D.4)–(D.6) matters only for the running time, which this file does not treat. Under the first inequality of (D.6), every child has at most M / 16 edges (TensorNetwork.mul_card_edges_child_callSplitting_le, from Lemma D.3 (3)), so an active call with an edge never falls back for its children, and when 2 L ≤ Δ the lifted children again run from rows to columns within the degree bound (TensorNetwork.rowsToColumnsLE_finLift_child). In the manuscript's ring B = O = ℤ_(2)[U] / (f), the binary-coordinate lifts are such points (AdjoinRoot.isUnit_integerDigitLift_sub).

Main definitions #

Main results #

References #

Node precisions #

A node of positive multiplicity has valuation below u.

theorem Cslib.Circuits.Frontier.padicValInt_lt_of_taperMult_pos {u h a : ℕ} {t : ℤ} (hq : 0 < taperMult u h t) (hua : u ≤ a) :

A node of positive multiplicity has valuation below u, so below a when u ≤ a.

@[reducible, inline]

The ideal (2 ^ n) of a commutative ring.

2 ^ n = 0 modulo 2 ^ n.

@[reducible, inline]
noncomputable abbrev Cslib.Circuits.Frontier.nodeIdeal (B : Type u_1) [CommRing B] (M a h p : ℕ) (t : ℤ) :

The ideal (2 ^ p_t) of the node t of a call with M edges, packets of 2 ^ a slots, multiplicity step h and input precision p.

Networks from rows to columns #

structure Cslib.Circuits.Frontier.TensorNetwork.RowsToColumnsLE {R : Type u_1} {U : Type u_2} {V : Type u_3} {E : Type u_4} [Fintype E] [DecidableEq V] (N : TensorNetwork R U V E) (side : V → Bool) (Δ : ℕ) :

Every edge of N runs from a row (side v = true) to a column, and every vertex has at most Δ ports at each end: the bipartite form and the degree bound Δ of the networks of the recursion (§D.4.2, p. 58).

  • side_src (e : E) : side (N.src e) = true

    Edges start at rows.

  • side_tgt (e : E) : side (N.tgt e) = false

    Edges end at columns.

  • src_le (v : V) : {e : E | N.src e = v}.card ≤ Δ

    Every vertex is the source of at most Δ edges.

  • tgt_le (w : V) : {e : E | N.tgt e = w}.card ≤ Δ

    Every vertex is the target of at most Δ edges.

Instances For
    @[instance_reducible]
    instance Cslib.Circuits.Frontier.TensorNetwork.instDecidableRowsToColumnsLEFin {R : Type u_1} {U : Type u_2} {n m : ℕ} (N : TensorNetwork R U (Fin n) (Fin m)) (side : Fin n → Bool) (Δ : ℕ) :

    The modes of an active node #

    noncomputable def Cslib.Circuits.Frontier.TensorNetwork.nodeSplitting {R : Type u_1} {V : Type u_2} {E : Type u_3} [CommRing R] {a r : ℕ} (N : TensorNetwork R Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) (Q : PacketPacking.Packing N.src N.tgt a r) (κ : ↥(Rat.padicValuation 2).integer →+* R) (ζ : R) {p : ℕ} (hp : 2 ^ p = 0) {t : ℤ} (ht : t ∈ recoveryNodes a) (hia : padicValInt 2 t < a) :
    N.ModeSplitting (cauchyValueMatrix κ ζ a t Q.packet fun (e : E) => ↑(Q.slot e)) (Fin r) (Fin Q.numPackets) (Fin Q.numPackets × Fin (2 ^ (padicValInt 2 t + 1)) × Fin p)

    The modes of an active node (§D.4.5). For a network whose edges run from rows to columns, a packing Q of its edges, and a nonzero grid point t of valuation i < a, the mode splitting of the Cauchy matrix at T = t + α ζ with the vertices grouped by their symbol in coordinate i of Q (cauchyModeSplitting, oriented by packingGroup_src_tgt).

    theorem Cslib.Circuits.Frontier.TensorNetwork.deformedContraction_eq_sum_nodeSplitting {R : Type u_1} {V : Type u_2} {E : Type u_3} [CommRing R] [Fintype E] {a r : ℕ} [Fintype V] [DecidableEq V] [DecidableEq E] (N : TensorNetwork R Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) (Q : PacketPacking.Packing N.src N.tgt a r) (κ : ↥(Rat.padicValuation 2).integer →+* R) (ζ : R) {p : ℕ} (hp : 2 ^ p = 0) {t : ℤ} (ht : t ∈ recoveryNodes a) (hia : padicValInt 2 t < a) :
    N.deformedContraction side (cauchyValueMatrix κ ζ a t Q.packet fun (e : E) => ↑(Q.slot e)) = ∑ β ∈ modeBudget (fun (Z : Fin Q.numPackets × Fin (2 ^ (padicValInt 2 t + 1)) × Fin p) => ↑Z.2.2 + 1) p, ∏ g : Fin r, ((N.nodeSplitting side hsrc htgt Q κ ζ hp ht hia).child β g).contraction

    The child identity at an active node ((D.16)): the deformed contraction along the Cauchy matrix at T = t + α ζ is the sum, over the mode tuples of weight below p, of the products over the groups of the contractions of the children of nodeSplitting.

    One call from its children #

    noncomputable def Cslib.Circuits.Frontier.TensorNetwork.callSplitting {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype E] (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) (p u h : ℕ) (hua : u ≤ a) {t : ℤ} (ht : t ∈ recoveryNodes a) (hq : 0 < taperMult u h t) (z : ↥B) :
    (map (Ideal.Quotient.mk (nodeIdeal (↥B) (Fintype.card E) a h p t)) N).ModeSplitting (cauchyValueMatrix ((Ideal.Quotient.mk (nodeIdeal (↥B) (Fintype.card E) a h p t)).comp (integerHom B hB)) ((Ideal.Quotient.mk (nodeIdeal (↥B) (Fintype.card E) a h p t)) z) a t Q.packet fun (e : E) => ↑(Q.slot e)) (Fin r) (Fin Q.numPackets) (Fin Q.numPackets × Fin (2 ^ (padicValInt 2 t + 1)) × Fin (ContractionSchedule.nodePrecision p h a (Fintype.card E) (padicValInt 2 t)))

    The mode splitting at the active node t and the point z of a call with input precision p: nodeSplitting for the network reduced modulo 2 ^ p_t, at the reduction of z.

    @[simp]
    theorem Cslib.Circuits.Frontier.TensorNetwork.callSplitting_side {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype E] (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) (p u h : ℕ) (hua : u ≤ a) {t : ℤ} (ht : t ∈ recoveryNodes a) (hq : 0 < taperMult u h t) (z : ↥B) :
    (callSplitting B hB N side hsrc htgt Q p u h hua ht hq z).side = side

    The rows of the splitting at an active node are the rows of the call.

    @[simp]
    theorem Cslib.Circuits.Frontier.TensorNetwork.callSplitting_group {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype E] (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) (p u h : ℕ) (hua : u ≤ a) {t : ℤ} (ht : t ∈ recoveryNodes a) (hq : 0 < taperMult u h t) (z : ↥B) :
    (callSplitting B hB N side hsrc htgt Q p u h hua ht hq z).group = packingGroup side Q ⟨padicValInt 2 t, ⋯⟩

    The groups at an active node of valuation i are the symbols in coordinate i of the packing.

    @[simp]
    theorem Cslib.Circuits.Frontier.TensorNetwork.callSplitting_packet {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype E] (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) (p u h : ℕ) (hua : u ≤ a) {t : ℤ} (ht : t ∈ recoveryNodes a) (hq : 0 < taperMult u h t) (z : ↥B) :
    (callSplitting B hB N side hsrc htgt Q p u h hua ht hq z).packet = Q.packet

    The packets of the splitting at an active node are the packets of the packing.

    theorem Cslib.Circuits.Frontier.TensorNetwork.exists_recoverFromValues_eq_add_of_children {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype V] [DecidableEq V] [Fintype E] [DecidableEq E] (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) {u h p : ℕ} (hu : 1 ≤ u) (huM : u ≤ Fintype.card E) (hua : u ≤ a) (hh : 3 * Fintype.card E ≤ h * u) (hh' : h * u ≤ 3 * Fintype.card E + u) {n : ℕ} (ζ : Fin n → ↥B) (hζ : Pairwise fun (k l : Fin n) => IsUnit (ζ k - ζ l)) (hn : Fintype.card E * (2 * 2 ^ a - 1) < n) (v : ℤ → Fin n → ↥B) (hv : ∀ (t : ℤ) (ht : t ∈ recoveryNodes a) (hq : 0 < taperMult u h t) (k : Fin n), (Ideal.Quotient.mk (nodeIdeal (↥B) (Fintype.card E) a h p t)) (v t k) = ∑ β ∈ modeBudget (fun (Z : Fin Q.numPackets × Fin (2 ^ (padicValInt 2 t + 1)) × Fin (ContractionSchedule.nodePrecision p h a (Fintype.card E) (padicValInt 2 t))) => ↑Z.2.2 + 1) (ContractionSchedule.nodePrecision p h a (Fintype.card E) (padicValInt 2 t)), ∏ g : Fin r, ((callSplitting B hB N side hsrc htgt Q p u h hua ht hq (ζ k)).child β g).contraction) :
    ∃ b ∈ B, recoverFromValues B a u h ζ v = ↑N.contraction + 2 ^ p * b

    Correctness of one active call from its children ([OAI26k], §D.4.4–§D.4.7). Let N have entries in B, edges from rows to columns, and a packing Q into packets of 2 ^ a slots. Let 1 ≤ u ≤ M, u ≤ a and 3 M ≤ h u ≤ 3 M + u for M edges, and let the n > M (2 L - 1) points ζ k have unit differences. If at every node t of positive multiplicity each value v t k reduces modulo 2 ^ p_t to the sum, over the mode tuples of weight below p_t, of the products over the groups of the contractions of the children of callSplitting at ζ k (the right side of (D.16)), then the recovered value agrees with the contraction modulo 2 ^ p.

    Lifting child networks #

    noncomputable def Cslib.Circuits.Frontier.TensorNetwork.finLift {B : Type u_1} [CommRing B] {V : Type u_2} {E : Type u_3} [Fintype V] [Fintype E] {p : ℕ} (N : TensorNetwork (B ⧸ twoPowIdeal B p) Bool V E) :

    A network over B ⧸ (2 ^ p) on finite types, lifted to B along a section of the reduction (TensorNetwork.mapFun) and numbered by Fin (TensorNetwork.reindex): the network that a child call receives.

    The contraction of a lifted network reduces to the contraction.

    theorem Cslib.Circuits.Frontier.TensorNetwork.RowsToColumnsLE.finLift {B : Type u_1} [CommRing B] {V : Type u_2} {E : Type u_3} [Fintype V] [Fintype E] {p : ℕ} [DecidableEq V] {N : TensorNetwork (B ⧸ twoPowIdeal B p) Bool V E} {side : V → Bool} {Δ : ℕ} (h : N.RowsToColumnsLE side Δ) :

    Lifting keeps a network running from rows to columns, with its degree bound.

    Contraction oracles #

    @[reducible, inline]

    A contraction oracle: a value for every Boolean tensor network on the vertices Fin n and the edges Fin m, with its sides, at every precision. A call of the recursion evaluates its children through an oracle.

    An oracle is correct when each of its values agrees with the contraction modulo the precision 2 ^ p it is given.

    noncomputable def Cslib.Circuits.Frontier.TensorNetwork.ContractionOracle.evalLift {B : Type u_1} [CommRing B] (rec : ContractionOracle B) {V : Type u_2} {E : Type u_3} [Fintype V] [Fintype E] {p : ℕ} (N : TensorNetwork (B ⧸ twoPowIdeal B p) Bool V E) (side : V → Bool) :
    B

    The value of an oracle on a network over B ⧸ (2 ^ p) on finite types, at precision p: the query on the lifted network finLift N.

    theorem Cslib.Circuits.Frontier.TensorNetwork.ContractionOracle.mk_evalLift {B : Type u_1} [CommRing B] {rec : ContractionOracle B} (hrec : rec.Correct) {V : Type u_2} {E : Type u_3} [Fintype V] [Fintype E] [DecidableEq E] {p : ℕ} (N : TensorNetwork (B ⧸ twoPowIdeal B p) Bool V E) (side : V → Bool) :

    A correct oracle evaluates a lifted network: its value reduces modulo 2 ^ p to the contraction.

    One call from an oracle #

    noncomputable def Cslib.Circuits.Frontier.TensorNetwork.nodeValue {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype V] [DecidableEq V] [Fintype E] [DecidableEq E] (rec : ContractionOracle ↥B) (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) (p u h : ℕ) (hua : u ≤ a) {t : ℤ} (ht : t ∈ recoveryNodes a) (hq : 0 < taperMult u h t) (z : ↥B) :
    ↥B

    The value at an active node ((D.16)): the sum, over the mode tuples of weight below p_t, of the products over the groups of the oracle's values on the children of callSplitting at z. A child has its old vertices as rows and its packets as columns.

    theorem Cslib.Circuits.Frontier.TensorNetwork.mk_nodeValue {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype V] [DecidableEq V] [Fintype E] [DecidableEq E] {rec : ContractionOracle ↥B} (hrec : rec.Correct) (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) (p u h : ℕ) (hua : u ≤ a) {t : ℤ} (ht : t ∈ recoveryNodes a) (hq : 0 < taperMult u h t) (z : ↥B) :
    (Ideal.Quotient.mk (nodeIdeal (↥B) (Fintype.card E) a h p t)) (nodeValue B hB rec N side hsrc htgt Q p u h hua ht hq z) = ∑ β ∈ modeBudget (fun (Z : Fin Q.numPackets × Fin (2 ^ (padicValInt 2 t + 1)) × Fin (ContractionSchedule.nodePrecision p h a (Fintype.card E) (padicValInt 2 t))) => ↑Z.2.2 + 1) (ContractionSchedule.nodePrecision p h a (Fintype.card E) (padicValInt 2 t)), ∏ g : Fin r, ((callSplitting B hB N side hsrc htgt Q p u h hua ht hq z).child β g).contraction

    For a correct oracle, the value at an active node reduces modulo 2 ^ p_t to the right side of (D.16).

    noncomputable def Cslib.Circuits.Frontier.TensorNetwork.callValues {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype V] [DecidableEq V] [Fintype E] [DecidableEq E] (rec : ContractionOracle ↥B) (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) (p u h : ℕ) (hua : u ≤ a) {n : ℕ} (ζ : Fin n → ↥B) (t : ℤ) (k : Fin n) :
    ↥B

    The values of an active call at the nodes and interpolation points: nodeValue at the nodes of positive multiplicity, and zero elsewhere.

    noncomputable def Cslib.Circuits.Frontier.TensorNetwork.callValue {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype V] [DecidableEq V] [Fintype E] [DecidableEq E] (rec : ContractionOracle ↥B) (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) (p u h : ℕ) (hua : u ≤ a) {n : ℕ} (ζ : Fin n → ↥B) :
    ↥B

    One active call (§D.4.7): interpolate and recover (recoverFromValues) the values callValues computed from the oracle. The call returns the recovered value when it lies in B, and zero when it does not. For a correct oracle, and parameters and points meeting the hypotheses of exists_callValue_eq_add, the recovered value lies in B and the call returns the contraction modulo 2 ^ p.

    theorem Cslib.Circuits.Frontier.TensorNetwork.exists_callValue_eq_add {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype V] [DecidableEq V] [Fintype E] [DecidableEq E] {rec : ContractionOracle ↥B} (hrec : rec.Correct) (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) {u h p : ℕ} (hu : 1 ≤ u) (huM : u ≤ Fintype.card E) (hua : u ≤ a) (hh : 3 * Fintype.card E ≤ h * u) (hh' : h * u ≤ 3 * Fintype.card E + u) {n : ℕ} (ζ : Fin n → ↥B) (hζ : Pairwise fun (k l : Fin n) => IsUnit (ζ k - ζ l)) (hn : Fintype.card E * (2 * 2 ^ a - 1) < n) :
    ∃ (c : ↥B), callValue B hB rec N side hsrc htgt Q p u h hua ζ = N.contraction + 2 ^ p * c

    Correctness of one active call for a correct oracle: under the hypotheses of exists_recoverFromValues_eq_add_of_children, the call returns the contraction modulo 2 ^ p.

    The children of an active call #

    theorem Cslib.Circuits.Frontier.TensorNetwork.ModeSplitting.rowsToColumnsLE_child {R : Type u_1} {V : Type u_2} {E : Type u_3} {G : Type u_4} {P : Type u_5} {M : Type u_6} [CommRing R] [Fintype M] {N : TensorNetwork R Bool V E} {W : Matrix E E R} (S : N.ModeSplitting W G P M) [Fintype E] [DecidableEq E] [DecidableEq P] [DecidableEq G] [DecidableEq M] [DecidableEq V] {Δ a : ℕ} {slot : E → ℕ} (hrow : ∀ (v : V), {e : E | N.src e = v}.card ≤ Δ) (hcol : ∀ (w : V), {e : E | N.tgt e = w}.card ≤ Δ) (hslot : ∀ (e : E), slot e < 2 ^ a) (hinj : ∀ (e e' : E), S.packet e = S.packet e' → slot e = slot e' → e = e') (hL : 2 * 2 ^ a ≤ Δ) (β : M → ℕ) (g : G) :

    Children run from rows to columns within the degree bound. If every vertex of N has at most Δ ports at each end, and the packets have 2 ^ a slots with 2 · 2 ^ a ≤ Δ, then each child runs from its old vertices to its packets with at most Δ ports at each vertex: old vertices keep their degrees, and a packet vertex has at most 2 L ports (§D.4.6, p. 63).

    theorem Cslib.Circuits.Frontier.TensorNetwork.mul_card_edges_child_callSplitting_le {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [DecidableEq V] [FinEnum V] [Fintype E] [LinearOrder E] (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a Δ : ℕ} (hrow : ∀ (v : V), {e : E | N.src e = v}.card ≤ Δ) (hcol : ∀ (w : V), {e : E | N.tgt e = w}.card ≤ Δ) (hM : 2 * Δ * (64 ^ (2 * a)) ^ 2 ≤ Fintype.card E) (p u h : ℕ) (hua : u ≤ a) {t : ℤ} (ht : t ∈ recoveryNodes a) (hq : 0 < taperMult u h t) (z : ↥B) (g : Fin 64) :
    64 * Fintype.card ({ e : E // (callSplitting B hB N side hsrc htgt (PacketPacking.packing N.src N.tgt a 64) p u h hua ht hq z).group (N.src e) = g } ⊕ { e : E // (callSplitting B hB N side hsrc htgt (PacketPacking.packing N.src N.tgt a 64) p u h hua ht hq z).group (N.tgt e) = g }) ≤ 4 * Fintype.card E

    Children have at most M / 16 edges under the size hypothesis 2 Δ D² ≤ M of (D.6), D = 64 ^ (2 a), for the packing of Lemma D.3 with r = 64 and maximum degree Δ: each group has at most 2 M / 64 ports on each side (PacketPacking.row_ports_packing_le), and a child has one edge per port of its group. The source (§D.4.6, p. 63) bounds a child by 6M/r = 3M/32 < M/8 edges from the 3M/r port bound of Lemma D.3 (3); PacketPacking.packing has the sharper port bound 2M/r.

    theorem Cslib.Circuits.Frontier.TensorNetwork.rowsToColumnsLE_finLift_child {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) {V : Type u_2} {E : Type u_3} [Fintype V] [DecidableEq V] [Fintype E] [DecidableEq E] (N : TensorNetwork (↥B) Bool V E) (side : V → Bool) (hsrc : ∀ (e : E), side (N.src e) = true) (htgt : ∀ (e : E), side (N.tgt e) = false) {a r : ℕ} (Q : PacketPacking.Packing N.src N.tgt a r) (p u h : ℕ) (hua : u ≤ a) {t : ℤ} (ht : t ∈ recoveryNodes a) (hq : 0 < taperMult u h t) (z : ↥B) {Δ : ℕ} (hrow : ∀ (v : V), {e : E | N.src e = v}.card ≤ Δ) (hcol : ∀ (w : V), {e : E | N.tgt e = w}.card ≤ Δ) (hL : 2 * 2 ^ a ≤ Δ) (β : Fin Q.numPackets × Fin (2 ^ (padicValInt 2 t + 1)) × Fin (ContractionSchedule.nodePrecision p h a (Fintype.card E) (padicValInt 2 t)) → ℕ) (g : Fin r) :
    ((callSplitting B hB N side hsrc htgt Q p u h hua ht hq z).child β g).finLift.RowsToColumnsLE (Sum.isLeft ∘ ⇑(Fintype.equivFin ({ v : V // (callSplitting B hB N side hsrc htgt Q p u h hua ht hq z).group v = g } ⊕ Fin Q.numPackets)).symm) Δ

    The lifted children of an active call run from rows to columns within the degree bound Δ, when the call does and its packets have 2 · 2 ^ a ≤ Δ slots: the networks the child calls receive meet the network part of their guard (CallParams.Guard).

    The recursion #

    The parameters of an active call: packets of L = 2 ^ a slots, the tapered multiplicities q_t = h max(0, u - v₂ t) of Lemma D.5, and the degree bound Δ of (D.6).

    • a : ℕ

      The packets have 2 ^ a slots.

    • u : ℕ

      The number of levels of positive multiplicity.

    • h : ℕ

      The step of the multiplicities between levels.

    • degree : ℕ

      The degree bound Δ.

    The parameters of a call with M edges and n interpolation points are admissible when they meet the hypotheses of Lemma D.5, 1 ≤ u ≤ M, u ≤ a and 3 M ≤ h u ≤ 3 M + u, and there are more than M (2 L - 1) points.

    • one_le_u : 1 ≤ θ.u

      1 ≤ u.

    • u_le_edges : θ.u ≤ M

      u ≤ M.

    • u_le_a : θ.u ≤ θ.a

      u ≤ a.

    • le_h_mul : 3 * M ≤ θ.h * θ.u

      3 M ≤ h u.

    • h_mul_le : θ.h * θ.u ≤ 3 * M + θ.u

      h u ≤ 3 M + u, as for h = ⌈3 M / u⌉.

    • points_lt : M * (2 * 2 ^ θ.a - 1) < n

      There are more than M (2 L - 1) interpolation points.

    Instances For
      structure Cslib.Circuits.Frontier.TensorNetwork.CallParams.Guard (θ : CallParams) {R : Type u_1} {n m : ℕ} (N : TensorNetwork R Bool (Fin n) (Fin m)) (side : Fin n → Bool) (N₀ : ℕ) extends N.RowsToColumnsLE side θ.degree :

      The guard of an active call on a network N with m edges, its sides side and n interpolation points: the parameters θ are admissible, and N runs from rows to columns with at most Δ = θ.degree ports at each end of each vertex, the degree bound under which Lemma D.3 makes the children smaller (mul_card_edges_child_callSplitting_le). Correctness does not use the degree bound.

      Instances For
        @[instance_reducible]
        instance Cslib.Circuits.Frontier.TensorNetwork.instDecidableGuard (θ : CallParams) {R : Type u_1} {n m : ℕ} (N : TensorNetwork R Bool (Fin n) (Fin m)) (side : Fin n → Bool) (N₀ : ℕ) :
        Decidable (θ.Guard N side N₀)
        @[irreducible]
        noncomputable def Cslib.Circuits.Frontier.TensorNetwork.contractRec {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) (sched : ℕ → ℕ → Option CallParams) {N₀ : ℕ} (pts : Fin N₀ → ↥B) (d n m : ℕ) (N : TensorNetwork (↥B) Bool (Fin n) (Fin m)) (side : Fin n → Bool) (p : ℕ) :
        ↥B

        The contraction recursion ([OAI26k], §D.4.7). A call at depth d on a network N with m edges, sides side and precision p asks the schedule for its parameters. When there are none, or the guard fails (CallParams.Guard), it returns the contraction (direct summation). Otherwise it is an active call (callValue) with the packing of Lemma D.3 (r = 64) and the first M (2 L - 1) + 1 points of pts, whose children are recursive calls at depth d + 1; a child that does not have fewer edges returns its contraction.

        theorem Cslib.Circuits.Frontier.TensorNetwork.contractRec_eq_callValue {K : Type u_1} [CommRing K] [Algebra ℚ K] {B : Subring K} {hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B} {sched : ℕ → ℕ → Option CallParams} {N₀ : ℕ} {pts : Fin N₀ → ↥B} {d n m : ℕ} {N : TensorNetwork (↥B) Bool (Fin n) (Fin m)} {side : Fin n → Bool} {θ : CallParams} (hs : sched d m = some θ) (hθ : θ.Guard N side N₀) (p : ℕ) :
        contractRec B hB sched pts d n m N side p = callValue B hB (fun (n' m' : ℕ) (N' : TensorNetwork (↥B) Bool (Fin n') (Fin m')) (side' : Fin n' → Bool) (p' : ℕ) => if m' < m then contractRec B hB sched pts (d + 1) n' m' N' side' p' else N'.contraction) N side ⋯ ⋯ (PacketPacking.packing N.src N.tgt θ.a 64) p θ.u θ.h ⋯ fun (k : Fin (m * (2 * 2 ^ θ.a - 1) + 1)) => pts (Fin.castLE ⋯ k)

        An active call of the recursion: when the schedule gives parameters whose guard holds, the call is callValue with the packing of Lemma D.3, the first M (2 L - 1) + 1 points, and recursive calls at depth d + 1 for the children with fewer edges.

        theorem Cslib.Circuits.Frontier.TensorNetwork.contractRec_of_sched_eq_none {K : Type u_1} [CommRing K] [Algebra ℚ K] {B : Subring K} {hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B} {sched : ℕ → ℕ → Option CallParams} {N₀ : ℕ} {pts : Fin N₀ → ↥B} {d n m : ℕ} {N : TensorNetwork (↥B) Bool (Fin n) (Fin m)} {side : Fin n → Bool} (hs : sched d m = none) (p : ℕ) :
        contractRec B hB sched pts d n m N side p = N.contraction

        A leaf of the recursion, where the schedule gives no parameters, is evaluated directly.

        theorem Cslib.Circuits.Frontier.TensorNetwork.exists_contractRec_eq_add {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) (sched : ℕ → ℕ → Option CallParams) {N₀ : ℕ} (pts : Fin N₀ → ↥B) (hpts : Pairwise fun (k l : Fin N₀) => IsUnit (pts k - pts l)) (d n m : ℕ) (N : TensorNetwork (↥B) Bool (Fin n) (Fin m)) (side : Fin n → Bool) (p : ℕ) :
        ∃ (c : ↥B), contractRec B hB sched pts d n m N side p = N.contraction + 2 ^ p * c

        Correctness of the recursion ([OAI26k], §D.4.7, p. 64: correctness "by induction from the leaves"). For interpolation points with unit differences, every call returns the contraction modulo 2 ^ p, for every schedule and depth.

        theorem Cslib.Circuits.Frontier.TensorNetwork.mk_contractRec {K : Type u_1} [CommRing K] [Algebra ℚ K] (B : Subring K) (hB : ∀ c ∈ (Rat.padicValuation 2).integer, (algebraMap ℚ K) c ∈ B) (sched : ℕ → ℕ → Option CallParams) {N₀ : ℕ} (pts : Fin N₀ → ↥B) (hpts : Pairwise fun (k l : Fin N₀) => IsUnit (pts k - pts l)) (d n m : ℕ) (N : TensorNetwork (↥B) Bool (Fin n) (Fin m)) (side : Fin n → Bool) (p : ℕ) :
        (Ideal.Quotient.mk (twoPowIdeal (↥B) p)) (contractRec B hB sched pts d n m N side p) = (Ideal.Quotient.mk (twoPowIdeal (↥B) p)) N.contraction

        The recursion computes the contraction modulo 2 ^ p.