Documentation

CslibFrontier.Computability.Circuit.Frontier.TensorNetwork.FastContractionSize

The encoded sizes of the calls of the native contraction recursion #

Bounds on the encoded lengths of the calls (FastContraction.encCall) of the native recursion from bounds on their numbers: the length of an encoded call is at most 64 (B + 1) ^ 3 + 2 B R when its numbers, lists and ports are at most B and its descriptors at most R long (FastContraction.length_encCall_le), and a bounded packet descriptor is at most 200 (B + 1) ^ 2 long (FastContraction.length_enc_inr_le). The values are reduced at their precision (FastContraction.reducedAt_value), and the frames of an active call with at most m edges at scale m and precision p are at most 64 (B + 1) ^ 3 long for B = 256 (m + 1) ^ 5 (p + 1) + e (FastContraction.length_encFrame_frameAt_le): the accumulator stays reduced at the common precision and stores at most one value per node and point.

Main results #

A number at most b has at most b binary digits.

A list of numbers at most 1 has encoded length at most 3 k for k numbers.

theorem Cslib.Circuits.Frontier.FastContraction.length_enc_packetCtx_le (c : NativePacket.PacketCtx) {B : ℕ} (hp : c.p ≤ B) (hfl : c.fl.length ≤ B) (hfl1 : ∀ z ∈ c.fl, z ≤ 1) (ha : c.a ≤ B) (hL : c.L ≤ B) (hi : c.i ≤ B) (htl : c.tiles ≤ B) (ht : c.t.natAbs ≤ B) (hnb : c.nb ≤ B) (hcols : c.cols = []) (hζ : c.ζ.length ≤ B) (hζ1 : ∀ z ∈ c.ζ, z ≤ 1) :

A packet context with fields at most B and no column list has encoded length at most 64 (B + 1).

2 ^ a ≤ m for a ≤ ⌊log₂ m⌋ and m ≠ 0.

theorem Cslib.Circuits.Frontier.FastContraction.length_enc_inr_le {T : Type} {encT : T ↪ List Bool} {fl : List ℕ} {m P k : ℕ} {d : NativePacket.PacketDesc} (h : PacketBound fl m P k d) {B : ℕ} (hB : 2 * (m + 1) * (P + 1) ≤ B) (hfl : fl.length ≤ B) (hfl1 : ∀ z ∈ fl, z ≤ 1) (hk : k ≤ B) :
((VertexDesc.enc encT) (Sum.inr d)).length ≤ 200 * (B + 1) ^ 2

A bounded packet descriptor has encoded length at most 200 (B + 1) ^ 2, when 2 (m + 1) (P + 1), the modulus's length and the number of ports are at most B and the modulus has 0/1 coefficients.

theorem Cslib.Circuits.Frontier.FastContraction.length_encCall_le {T : Type} {encT : T ↪ List Bool} {x : Call T} {B R : ℕ} (hs : x.scale ≤ B) (hd : x.depth ≤ B) (hb : x.bound ≤ B) (hp : x.prec ≤ B) (hfl : x.fl.length ≤ B) (hfl1 : ∀ z ∈ x.fl, z ≤ 1) (hr : (Turing.MultiTapeTM.encNat x.rows).length ≤ B) (hE : x.edges ≤ B) (hV : x.net.vertices.length ≤ B) (hports : ∀ v ∈ x.net.vertices, v.1.length ≤ B ∧ ∀ i ∈ v.1, i ≤ B) (hdesc : ∀ v ∈ x.net.vertices, ((VertexDesc.enc encT) v.2).length ≤ R) :
((encCall encT) x).length ≤ 64 * (B + 1) ^ 3 + 2 * B * R

The encoded length of a call is at most 64 (B + 1) ^ 3 + 2 B R when its scale, depth, bound, precision, number of edges, number of vertices, modulus length, the binary length of its rows and its ports are at most B, the modulus has 0/1 coefficients, and its descriptors are at most R long.

Values #

A reduced coefficient list: e coordinates, each at most 2 ^ p.

A reduced list at precision p has encoded length at most e (2 (p + 1) + 1).

The values of the calls are reduced at their precision, for every child builder.

The encoded length of a tagged value of a call.

Frames #

An accumulator whose product, sum and stored values are reduced at precision N.

The accumulator stays reduced along the children, and its stored values only grow.

theorem Cslib.Circuits.Frontier.FastContraction.length_encFrame_le {N : ℕ} {fl : List ℕ} {o : Option ChildCursor.State} {acc : ChildCursor.Acc (List ℕ)} {B : ℕ} (hst : ∀ (s : ChildCursor.State), o = some s → s.1 ≤ B ∧ s.2.1 ≤ B ∧ s.2.2.1.length ≤ B ∧ (∀ b ∈ s.2.2.1, b ≤ B) ∧ s.2.2.2 ≤ B) (hacc : AccReduced N fl acc) (hst' : acc.2.2.length ≤ B) (hN : N + 1 ≤ B) (he : fl.length ≤ B) :
(encFrame (o, acc)).length ≤ 64 * (B + 1) ^ 3

The encoded length of a frame is at most 64 (B + 1) ^ 3 when its cursor state's numbers and exponents, the number of stored values, N + 1 and e are at most B, and its accumulator is reduced at precision N.

The frames of an active call #

The bound 256 (m + 1) ^ 5 (p + 1) + e on the numbers of the frames of an active call at scale m with precision p.

theorem Cslib.Circuits.Frontier.FastContraction.active_numbers {T : Type} {x : Call T} (ha : active x = true) (hM : x.edges ≤ x.scale) :
(nodes x).length ≤ 2 * x.scale ∧ numPoints x ≤ 2 * x.scale ^ 2 + 1 ∧ (packing x).2.1 ≤ x.scale ^ 2 ∧ shift x ≤ 48 * (x.scale + 1) ^ 4 ∧ ∀ (j : ℕ), nodePrec x j ≤ x.prec + 40 * x.scale ^ 2 ∧ 2 ^ (level x ((nodes x).getD j 0) + 1) ≤ 4 * x.scale

The numbers of an active call with at most m edges at scale m.

The frames of an active call with at most m edges at scale m have encoded length at most 64 (B + 1) ^ 3 for B = frameBound x.

The sizes along the recursion #

theorem Cslib.Circuits.Frontier.FastContraction.Shape.length_le {T : Type} {encT : T ↪ List Bool} {x₀ x : Call T} (ev : T → List Bool → List ℕ) (h₀s : x₀.scale = x₀.edges) (h₀b : x₀.bound = x₀.edges + 1) (h₀d : x₀.depth = 0) (h : Shape x₀ x) {Z : ℕ} (hZ1 : 256 * (x₀.edges + 1) ^ 5 * (x₀.prec + (x₀.edges + 1) * (40 * x₀.edges ^ 2) + 1) + x₀.fl.length ≤ Z) (hZ2 : x₀.net.vertices.length + (x₀.edges + 1) * x₀.edges ^ 2 + (Turing.MultiTapeTM.encNat x₀.rows).length ≤ Z) (hfl1 : ∀ z ∈ x₀.fl, z ≤ 1) (hR₀ : ∀ w ∈ x₀.net.vertices, ((VertexDesc.enc encT) w.2).length ≤ 200 * (Z + 1) ^ 2) :
((encCall encT) x).length ≤ 1000 * (Z + 1) ^ 3 ∧ (encValue (x.depth, value ev nativeMk x)).length ≤ 1000 * (Z + 1) ^ 3 ∧ (active x = true → ∀ (vals : ChildCursor.State → List ℕ) (c : ℕ), ((Turing.MultiTapeTM.encPair (encCall encT) encFrame) (x, frameAt x vals c)).length ≤ 1000 * (Z + 1) ^ 3)

The sizes of a call of a given shape: from a root x₀ at depth 0, at scale its number m of edges, with bound m + 1, a 0/1 modulus and descriptors at most 200 (Z + 1) ^ 2 long, a call of its shape, its tagged value and, if it is active, its frames are at most 1000 (Z + 1) ^ 3 long, once Z dominates 256 (m + 1) ^ 5 (P + 1) + e for the precision bound P = p₀ + 40 m² (m + 1) and the vertices, rows and their growth.