Documentation

CslibFrontier.Computability.Circuit.Frontier.TensorNetwork.PacketTerms

The native packet evaluator #

The native packet evaluator (Cslib.Circuits.Frontier.NativePacket) computes the entries of the packet vertices of the child networks of the contraction algorithm of [OAI26k] on coefficient lists (§D.4.6, p. 63). This file makes it one native machine with the source's bounds: time exp(O(L log s)) and polynomial space.

Main definitions #

Main results #

References #

The 2-adic valuation by halving #

The valuation by halving is multiplicity 2 whenever the fuel exceeds the valuation.

The valuation of a nonzero natural is below its bit length.

The valuation needs only size |n| halvings.

One step of the valuation by halving, on the value, the count and whether it has stopped.

The valuation by halving as a fold over size |n| steps.

Residues of integers #

The odd part of an integer in sign-magnitude form.

The residue of an integer power of two.

The residue of a natural number.

The residue modulo 2 ^ p of a binary integer, with p in unary.

An integer as a constant coefficient list, from its residue.

Sums and products of lists #

Kernel values and cross ratios #

@[reducible, inline]

Ports with the bits on them, such as the column ports of a packet context: each port is the pair (slot, b) of its slot in binary and the bit b on it. The pairs are framed and concatenated in port order, each with its slot framed.

Mode coefficients are polynomial-time, with the slots in binary and the exponent b in unary.

theorem Cslib.Circuits.Frontier.NativePacket.rowTermList_polyTime {α : Type} {encIn : α ↪ List Bool} {p : α → ℕ} {fl : α → List ℕ} {a L i nb : α → ℕ} {t : α → ℤ} {differ : α → Bool} {cols : α → List (ℕ × Bool)} {ζ : α → List ℕ} {r : α → ℕ × Bool} {o : α → Option ℕ} (hp : Turing.MultiTapeTM.ComputableInPolyTime p encIn Turing.MultiTapeTM.encUnary) (hfl : Turing.MultiTapeTM.ComputableInPolyTime fl encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) (ha : Turing.MultiTapeTM.ComputableInPolyTime a encIn Turing.MultiTapeTM.encUnary) (hL : Turing.MultiTapeTM.ComputableInPolyTime L encIn Turing.MultiTapeTM.encUnary) (hi : Turing.MultiTapeTM.ComputableInPolyTime i encIn Turing.MultiTapeTM.encUnary) (ht : Turing.MultiTapeTM.ComputableInPolyTime t encIn Turing.MultiTapeTM.encIntBin) (hnb : Turing.MultiTapeTM.ComputableInPolyTime nb encIn Turing.MultiTapeTM.encUnary) (hdiffer : Turing.MultiTapeTM.ComputableInPolyTime differ encIn Turing.MultiTapeTM.encBool) (hcols : Turing.MultiTapeTM.ComputableInPolyTime cols encIn encPortBits) (hζ : Turing.MultiTapeTM.ComputableInPolyTime ζ encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) (hr : Turing.MultiTapeTM.ComputableInPolyTime r encIn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encNat Turing.MultiTapeTM.encBool)) (ho : Turing.MultiTapeTM.ComputableInPolyTime o encIn (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encNat)) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (z : α) => rowTermList (p z) (fl z) (a z) (L z) (i z) (t z) (nb z) (differ z) (cols z) (ζ z) (r z) (o z)) encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)

Row terms are polynomial-time, with nb in unary and the mode index in binary.

Coefficient extraction for a packet #

The context of a packet entry: the precision p and the coefficients fl of f, the bit counts a and i, the number of slots L = 2 ^ a and of tiles tiles = 2 ^ (i + 1), the grid point t, the number nb of exponents per tile, whether the two symbols of the packet are the group (e₁, e₂) and whether they differ, the column ports, and ζ.

  • p : ℕ

    The precision.

  • fl : List ℕ

    The coefficients of f below the leading one.

  • a : ℕ

    The number of slot bits.

  • L : ℕ

    The number of slots, 2 ^ a.

  • i : ℕ

    The digit of the tiles.

  • tiles : ℕ

    The number of tiles, 2 ^ (i + 1).

  • t : ℤ

    The grid point.

  • nb : ℕ

    The number of exponents per tile.

  • e₁ : Bool

    Whether the first symbol is the group.

  • e₂ : Bool

    Whether the second symbol is the group.

  • differ : Bool

    Whether the two symbols differ.

  • cols : List (ℕ × Bool)

    The column ports: slots and bits.

  • ζ : List ℕ

    The interpolation value.

Instances For
    @[reducible, inline]

    The encoding of the nested pairs of a packet context.

    The encoding of a packet context: the counts in unary, t in binary sign-magnitude form, and the lists in binary.

    theorem Cslib.Circuits.Frontier.NativePacket.PacketCtx.mk_polyTime {δ : Type} {encIn : δ ↪ List Bool} {p a L i tiles nb : δ → ℕ} {fl ζ : δ → List ℕ} {t : δ → ℤ} {e₁ e₂ differ : δ → Bool} {cols : δ → List (ℕ × Bool)} (hp : Turing.MultiTapeTM.ComputableInPolyTime p encIn Turing.MultiTapeTM.encUnary) (hfl : Turing.MultiTapeTM.ComputableInPolyTime fl encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) (ha : Turing.MultiTapeTM.ComputableInPolyTime a encIn Turing.MultiTapeTM.encUnary) (hL : Turing.MultiTapeTM.ComputableInPolyTime L encIn Turing.MultiTapeTM.encUnary) (hi : Turing.MultiTapeTM.ComputableInPolyTime i encIn Turing.MultiTapeTM.encUnary) (htiles : Turing.MultiTapeTM.ComputableInPolyTime tiles encIn Turing.MultiTapeTM.encUnary) (ht : Turing.MultiTapeTM.ComputableInPolyTime t encIn Turing.MultiTapeTM.encIntBin) (hnb : Turing.MultiTapeTM.ComputableInPolyTime nb encIn Turing.MultiTapeTM.encUnary) (he₁ : Turing.MultiTapeTM.ComputableInPolyTime e₁ encIn Turing.MultiTapeTM.encBool) (he₂ : Turing.MultiTapeTM.ComputableInPolyTime e₂ encIn Turing.MultiTapeTM.encBool) (hdiffer : Turing.MultiTapeTM.ComputableInPolyTime differ encIn Turing.MultiTapeTM.encBool) (hcols : Turing.MultiTapeTM.ComputableInPolyTime cols encIn encPortBits) (hζ : Turing.MultiTapeTM.ComputableInPolyTime ζ encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) :
    Turing.MultiTapeTM.ComputableInPolyTime (fun (x : δ) => { p := p x, fl := fl x, a := a x, L := L x, i := i x, tiles := tiles x, t := t x, nb := nb x, e₁ := e₁ x, e₂ := e₂ x, differ := differ x, cols := cols x, ζ := ζ x }) encIn enc

    Construct a packet context from polynomial-time fields, using its existing encoding: counts are unary, the grid point is in binary sign-magnitude form, and list entries are binary.

    The dense indices of the modes of a packet whose tiles target the group.

    Coefficient extraction for a packet: the precision, the target modes and the row terms.

    theorem Cslib.Circuits.Frontier.NativePacket.val_packetTerms_value (c : PacketCtx) (htiles : c.tiles = 2 ^ (c.i + 1)) (rows : List (ℕ × Bool)) (γ : List ℕ) :
    GaloisRingArith.val c.p c.fl (packetTerms.value c rows γ) = GaloisRingArith.val c.p c.fl (listCoeffList c.p c.fl (List.filter (fun (k : ℕ) => TensorNetwork.modeTargets c.i c.e₁ c.e₂ (k / c.nb)) (List.range (2 ^ (c.i + 1) * c.nb))) (List.map (rowTermList c.p c.fl c.a c.L c.i c.t c.nb c.differ c.cols c.ζ) rows) fun (k : ℕ) => γ.getD k 0)

    Coefficient extraction for a packet is correct: with tiles = 2 ^ (i + 1), the value of the recursion in A_p is that of the coefficient extraction of packetEntryList.

    Packet entries natively #

    The dense indices of the modes of a packet whose tiles have the group as source.

    The product of the powers of the values of the source modes, at the exponents of a dense list.

    A packet entry, natively: coefficient extraction by the stack recursion, at the exponents of the dense list β, times the product of the powers of the source mode values.

    theorem Cslib.Circuits.Frontier.NativePacket.val_packetEntryNative (c : PacketCtx) (htiles : c.tiles = 2 ^ (c.i + 1)) (rows : List (ℕ × Bool)) (β : List ℕ) :
    GaloisRingArith.val c.p c.fl (packetEntryNative c rows β) = GaloisRingArith.val c.p c.fl (packetEntryList c.p c.fl c.a c.L c.i c.t c.nb c.e₁ c.e₂ c.differ (fun (k : ℕ) => β.getD k 0) rows c.cols c.ζ)

    The native packet entry is packetEntryList in A_p, when tiles = 2 ^ (i + 1).

    theorem Cslib.Circuits.Frontier.NativePacket.val_packetEntryNative_eq (c : PacketCtx) (hL : c.L = 2 ^ c.a) (hia : c.i < c.a) (htiles : c.tiles = 2 ^ (c.i + 1)) (ht : c.t ∈ cauchyGrid (2 ^ c.a)) (hti : 2 ^ c.i ∣ c.t) (hti' : ¬2 ^ (c.i + 1) ∣ c.t) {rows : List (ℕ × Bool)} (hrows : ∀ r ∈ rows, r.1 < 2 ^ c.a) (hcols : ∀ r ∈ c.cols, r.1 < 2 ^ c.a) (β : List ℕ) :
    GaloisRingArith.val c.p c.fl (packetEntryNative c rows β) = TensorNetwork.packetEntry (scalarHom c.p c.fl) (GaloisRingArith.val c.p c.fl c.ζ) c.a c.i c.t c.e₁ c.e₂ c.differ (fun (Z : Fin (2 ^ (c.i + 1)) × Fin c.nb) => β.getD (↑(finProdFinEquiv Z)) 0) rows c.cols

    The native packet entry is the packet entry (§D.4.6, p. 63): for a grid point t of valuation i < a, L = 2 ^ a, tiles = 2 ^ (i + 1) and ports in slots below L, its value in A_p is packetEntry at the reduction of ℤ_(2), the value of ζ, and the exponents of β at the dense indices of the modes.

    theorem Cslib.Circuits.Frontier.NativePacket.map_val_packetEntryNative {S : Type u_1} [CommRing S] (c : PacketCtx) (ψ : GaloisRingArith.Ring c.p c.fl →+* S) {n : ℕ} (hn : 2 ^ n = 0) (κ : ↥(Rat.padicValuation 2).integer →+* S) (hL : c.L = 2 ^ c.a) (hia : c.i < c.a) (htiles : c.tiles = 2 ^ (c.i + 1)) (ht : c.t ∈ cauchyGrid (2 ^ c.a)) (hti : 2 ^ c.i ∣ c.t) (hti' : ¬2 ^ (c.i + 1) ∣ c.t) {rows : List (ℕ × Bool)} (hrows : ∀ r ∈ rows, r.1 < 2 ^ c.a) (hcols : ∀ r ∈ c.cols, r.1 < 2 ^ c.a) (β : List ℕ) :
    ψ (GaloisRingArith.val c.p c.fl (packetEntryNative c rows β)) = TensorNetwork.packetEntry κ (ψ (GaloisRingArith.val c.p c.fl c.ζ)) c.a c.i c.t c.e₁ c.e₂ c.differ (fun (Z : Fin (2 ^ (c.i + 1)) × Fin c.nb) => β.getD (↑(finProdFinEquiv Z)) 0) rows c.cols

    The native packet entry in every ring receiving A_p. Along a ring map ψ : A_p → S with 2 nilpotent in S, the value of the native entry is packetEntry over S at any ring map κ : ℤ_(2) → S and at the image of ζ; with child_tensor_inr_cauchyModeSplitting, it is the entry of a packet vertex of a child network over S.

    @[reducible, inline]

    The input of the native packet evaluator: a context, the row ports and the dense exponents, the exponents in unary.

    The native packet evaluator: one native machine for packetEntryNative on every context, row ports and dense exponents (in unary). Its time is that of the stack recursion of coefficient extraction (CoeffScheme.Terms.valueCertificate_le, exp(O(L log m)) times a polynomial), plus polynomial time.

    theorem Cslib.Circuits.Frontier.NativePacket.reduced_value {C Rw : Type} (S : CoeffScheme.Terms C Rw) (x : C) (rows : List Rw) (γ : List ℕ) :
    SumOps.galois.Reduced (S.prec x) (S.value x rows γ)

    The value of coefficient extraction is reduced.

    The resources of the native packet evaluator. There is K such that on an input of length n with m target modes and L row ports, if the reduced coefficient lists of its precision are at most Rv bits long, then with Z = n + m + Rv + 2 the time is at most K (m + 2) ^ L Z ^ K and the space at most K Z ^ K: the exp(O(L log s)) time and polynomial space of §D.4.6 (p. 63).

    Descriptors of packet vertices #

    @[reducible, inline]

    The descriptor of a packet vertex: a packet context, whose column ports are read from the bits instead, the ports of the vertex in its port order, each (isRow, slot), and the dense exponents of the modes of the packet.

    The ports of one side, with the bits on them: the slots of the ports with isRow = side, paired with their bits, in port order.

    The entry of a packet vertex at the bits on its ports: the native packet entry, with the row ports and the column ports read from the bits.

    @[reducible, inline]

    The encoding of a packet descriptor: the context, the ports in binary, and the exponents in unary.

    theorem Cslib.Circuits.Frontier.NativePacket.entryInput_polyTime :
    Turing.MultiTapeTM.ComputableInPolyTime (fun (q : PacketDesc × List Bool) => (have __src := q.1.1; { p := __src.p, fl := __src.fl, a := __src.a, L := __src.L, i := __src.i, tiles := __src.tiles, t := __src.t, nb := __src.nb, e₁ := __src.e₁, e₂ := __src.e₂, differ := __src.differ, cols := sidePorts q.1.2.1 q.2 false, ζ := __src.ζ }, sidePorts q.1.2.1 q.2 true, q.1.2.2)) (Turing.MultiTapeTM.encPair encPacketDesc Turing.MultiTapeTM.encBits) encEntryInput

    The input of the native packet evaluator from a descriptor and the bits on its ports.

    The native packet evaluator on descriptors: one native machine for the entry of a packet vertex at the bits on its ports, the ev of the direct summation of Cslib.Circuits.Frontier.DescribedNetwork at coefficient lists (SumOps.galois).

    The resources of the native packet evaluator on descriptors. There is K such that on a descriptor and bits of total length n, with m target modes and L row ports, if the reduced coefficient lists of its precision are at most Rv bits long, then with Z = n + m + Rv + 2 the time is at most K (m + 2) ^ L Z ^ K and the space at most K Z ^ K.

    theorem Cslib.Circuits.Frontier.NativePacket.val_packetVertexEntry (d : PacketDesc) (bs : List Bool) (hL : d.1.L = 2 ^ d.1.a) (hia : d.1.i < d.1.a) (htiles : d.1.tiles = 2 ^ (d.1.i + 1)) (ht : d.1.t ∈ cauchyGrid (2 ^ d.1.a)) (hti : 2 ^ d.1.i ∣ d.1.t) (hti' : ¬2 ^ (d.1.i + 1) ∣ d.1.t) (hports : ∀ x ∈ d.2.1, x.2 < 2 ^ d.1.a) :
    GaloisRingArith.val d.1.p d.1.fl (packetVertexEntry d bs) = TensorNetwork.packetEntry (scalarHom d.1.p d.1.fl) (GaloisRingArith.val d.1.p d.1.fl d.1.ζ) d.1.a d.1.i d.1.t d.1.e₁ d.1.e₂ d.1.differ (fun (Z : Fin (2 ^ (d.1.i + 1)) × Fin d.1.nb) => d.2.2.getD (↑(finProdFinEquiv Z)) 0) (sidePorts d.2.1 bs true) (sidePorts d.2.1 bs false)

    The entry of a packet vertex is the packet entry at the row and column ports read from its bits.