Documentation

CslibFrontier.Computability.Circuit.Frontier.TensorNetwork.FastContractionLeaf

The leaves of the fast contraction algorithm #

The cost of the leaves of the native recursion of Theorem D.1 of [OAI26k] (Cslib.Circuits.Frontier.FastContraction.leafCertificate ce, for a native certificate ce of the entry procedure of the roots), the leaf clause of the resource analysis Cslib.Complexity.CountingSimulation.FastAnalysis. A leaf sums directly over the 2 ^ M edge assignments of a call with M edges, with polynomially many entry evaluations each (§D.4.7, p. 64). The entry of a packet vertex costs (m + 2) ^ L for m target modes and L row ports, the source's exp(O(L log s)) (§D.4.6, p. 63), and the entry of a root costs what ce costs.

The cost of a leaf (FastContraction.leafCertificate_le): with at most R target modes and Λ row ports per vertex, and roots costing time at most E and space at most ES in ce, time K (n + R + ES + 1) ^ K 2 ^ M ((R + 2) ^ Λ + E) and space K (n + R + ES + 1) ^ K on a call of encoded length n, from the bounds of direct summation (DescribedNetwork.contractionCertificate_le) and of the evaluator of descriptors (VertexDesc.entryCertificate_le). A root's output is at most a constant times ES + 1 long, since a native certificate charges its output to its space bound. For tables the root costs are polynomial, which gives time K (n + 1) ^ K 2 ^ M (A p + 2) ^ A with the packet shape (FastContraction.leafCertificate_tableEntry_le_of_packetShape).

The packet shape (FastContraction.PacketShape). Every packet vertex of a call of the recursion has i < a ≤ ⌊log₂ s⌋ / 32768, 2 ^ (i + 1) tiles, at most p exponents per tile, and row ports in distinct slots below 2 ^ a. So, with A = 2 ^ (⌊log₂ s⌋ / 32768), it has at most A p target modes and A row ports. The root has no packets, and the shape passes to the native children of a well-formed active call (FastContraction.packetShape_child): a retained vertex keeps its descriptor, and the row ports of a new packet are edges of one packet of the packing, in distinct slots (NativeChild.desc_of_mem_nativeChild).

The leaf bound (FastContraction.exists_leafCertificate_le). For s ≤ m ≤ C s, a leaf with the packet shape and at most 2 m edges takes time K (n + 1) ^ K 2 ^ (K s / √⌊log₂ s⌋) and space K (n + 1) ^ K, provided that from some s₀ on it has at most leafSize m edges and precision at most m ^ c: then 2 ^ M ≤ 2 ^ (C s / √⌊log₂ s⌋), and (A p + 2) ^ A is 2 ^ O(s ^ (1 / 32768) log s) (FastContraction.exists_packetFactor_le). Below s₀ everything but a polynomial in n is a constant (FastContraction.exists_leafFactor_le). With an entry procedure whose roots cost time E and space ES, the leaf takes time K (n + ES + 1) ^ K 2 ^ (K s / √⌊log₂ s⌋) (E + 1) and space K (n + ES + 1) ^ K (FastContraction.exists_leafCertificate_le_of_entry).

Main definitions #

Main results #

References #

Encoded lengths #

The scale, the precision and the coefficients of the modulus are at most the encoded length of a call.

The network of a call is at most its encoded length.

The number of vertices of a call is at most its encoded length.

The cost of a leaf #

theorem Cslib.Circuits.Frontier.FastContraction.leafCertificate_le {T : Type} {encT : T ↪ List Bool} {ev : T → List Bool → List ℕ} (ce : GenericRAM.NativeCertificate (fun (q : T × List Bool) => ev q.1 q.2) (Turing.MultiTapeTM.encPair encT Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) :
∃ (K : ℕ), ∀ (mk : Call T → ChildCursor.State → ℕ × DescribedNetwork (VertexDesc T)) (x : Call T) (R Λ E ES : ℕ), (∀ v ∈ x.net.vertices, v.2.modes ≤ R ∧ ∀ (bs : List Bool), bs.length = v.1.length → v.2.rowPorts bs ≤ Λ) → (∀ v ∈ x.net.vertices, ∀ (t : T), v.2 = Sum.inl t → ∀ (bs : List Bool), bs.length = v.1.length → ce.time (t, bs) ≤ E ∧ ce.space (t, bs) ≤ ES) → (leafCertificate ce mk).time x ≤ K * (((encCall encT) x).length + R + ES + 1) ^ K * 2 ^ x.edges * ((R + 2) ^ Λ + E) ∧ (leafCertificate ce mk).space x ≤ K * (((encCall encT) x).length + R + ES + 1) ^ K

The cost of a leaf. For a native certificate ce of the entry procedure of the roots, there is K such that, on a call of encoded length n with M edges whose vertices have at most R target modes and at most Λ row ports on every bit list on their ports, and whose roots take time at most E and space at most ES in ce on every bit list on their ports, direct summation takes time at most K (n + R + ES + 1) ^ K 2 ^ M ((R + 2) ^ Λ + E) and space at most K (n + R + ES + 1) ^ K, whatever the child builder.

The shape of the packets #

The shape of the packets of a call: every packet vertex has i < a ≤ ⌊log₂ s⌋ / 32768, 2 ^ (i + 1) tiles and at most p exponents per tile, and the slots of its ports are below 2 ^ a and distinct among its row ports. So it has at most 2 ^ (⌊log₂ s⌋ / 32768) p target modes and at most 2 ^ (⌊log₂ s⌋ / 32768) row ports (modes_le_of_packetShape, rowPorts_le_of_packetShape).

A call on a root network has no packets: its descriptors are those of a network G, by rootNet G.

The packet shape passes to the native children of a well-formed active call: a retained vertex keeps its descriptor, at a precision that only grows, and a new packet has a slot bits (slotBits_le), i < a (the valuation of its node), 2 ^ (i + 1) tiles, the child's precision as its number of exponents per tile, and the slots of the packing, distinct within a packet.

2 ^ (⌊log₂ s⌋ / 32768) is at most s + 1.

The target modes of a call with the packet shape: at most 2 ^ (⌊log₂ s⌋ / 32768) p.

The row ports of a call with the packet shape: at most 2 ^ (⌊log₂ s⌋ / 32768), since the slots of the row ports of a packet are distinct and below 2 ^ a.

theorem Cslib.Circuits.Frontier.FastContraction.leafCertificate_le_of_packetShape {T : Type} {encT : T ↪ List Bool} {ev : T → List Bool → List ℕ} (ce : GenericRAM.NativeCertificate (fun (q : T × List Bool) => ev q.1 q.2) (Turing.MultiTapeTM.encPair encT Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) :
∃ (K : ℕ), ∀ (mk : Call T → ChildCursor.State → ℕ × DescribedNetwork (VertexDesc T)) (x : Call T) (E ES : ℕ), PacketShape x → (∀ v ∈ x.net.vertices, ∀ (t : T), v.2 = Sum.inl t → ∀ (bs : List Bool), bs.length = v.1.length → ce.time (t, bs) ≤ E ∧ ce.space (t, bs) ≤ ES) → (leafCertificate ce mk).time x ≤ K * (((encCall encT) x).length + ES + 1) ^ K * 2 ^ x.edges * ((2 ^ (Nat.log 2 x.scale / 32768) * x.prec + 2) ^ 2 ^ (Nat.log 2 x.scale / 32768) + E) ∧ (leafCertificate ce mk).space x ≤ K * (((encCall encT) x).length + ES + 1) ^ K

The cost of a leaf with the packet shape. For a native certificate ce of the entry procedure of the roots, there is K such that, on a call of encoded length n with M edges, scale s and precision p with the packet shape, whose roots take time at most E and space at most ES in ce on every bit list on their ports, writing A = 2 ^ (⌊log₂ s⌋ / 32768), direct summation takes time at most K (n + ES + 1) ^ K 2 ^ M ((A p + 2) ^ A + E) and space at most K (n + ES + 1) ^ K.

The cost of a leaf over tables with the packet shape. The entry procedure of tables is polynomial, so there is K such that, on a call over tables of encoded length n with M edges, scale s and precision p with the packet shape, writing A = 2 ^ (⌊log₂ s⌋ / 32768), direct summation takes time at most K (n + 1) ^ K 2 ^ M (A p + 2) ^ A and space at most K (n + 1) ^ K.

The leaf bound of the analysis #

theorem Cslib.Circuits.Frontier.FastContraction.exists_packetFactor_le (C c : ℕ) :
∃ (K : ℕ), ∀ (s m p : ℕ), 2 ≤ s → s ≤ m → m ≤ C * s → p ≤ m ^ c → (2 ^ (Nat.log 2 m / 32768) * p + 2) ^ 2 ^ (Nat.log 2 m / 32768) ≤ 2 ^ (K * s / (Nat.log 2 s).sqrt)

The packet factor is subexponential. For s ≤ m ≤ C s and p ≤ m ^ c, with A = 2 ^ (⌊log₂ m⌋ / 32768), (A p + 2) ^ A ≤ 2 ^ (K s / √⌊log₂ s⌋) for a constant K depending only on C and c: A ≤ 2 ^ O(1) s ^ (1 / 32768), against s / √⌊log₂ s⌋.

theorem Cslib.Circuits.Frontier.FastContraction.exists_leafFactor_le (C c s₀ : ℕ) :
∃ (K : ℕ), ∀ (s m M p n : ℕ), 2 ≤ s → s ≤ m → m ≤ C * s → M ≤ 2 * m → p ≤ n → (s₀ ≤ s → M ≤ ContractionSchedule.leafSize m ∧ p ≤ m ^ c) → 2 ^ M * (2 ^ (Nat.log 2 m / 32768) * p + 2) ^ 2 ^ (Nat.log 2 m / 32768) ≤ K * (n + 1) ^ K * 2 ^ (K * s / (Nat.log 2 s).sqrt)

The leaf factor is subexponential. For all constants C, c and s₀ there is K such that, for s ≤ m ≤ C s, M ≤ 2 m and p ≤ n, writing A = 2 ^ (⌊log₂ m⌋ / 32768), 2 ^ M (A p + 2) ^ A ≤ K (n + 1) ^ K 2 ^ (K s / √⌊log₂ s⌋), provided that from s₀ on M ≤ leafSize m and p ≤ m ^ c. Below s₀, m is bounded, so the packet factor is polynomial in n and 2 ^ M is a constant; from s₀ on, 2 ^ M ≤ 2 ^ (C s / √⌊log₂ s⌋) and the packet factor is subexponential (exists_packetFactor_le). This is the factor of the cost of a leaf with the packet shape (leafCertificate_le_of_packetShape) that is not polynomial.

The leaf bound of the resource analysis. For all constants C, c and s₀ there is K such that a call with the packet shape, scale m with s ≤ m ≤ C s and at most 2 m edges takes time at most K (n + 1) ^ K 2 ^ (K s / √⌊log₂ s⌋) and space at most K (n + 1) ^ K at a leaf, provided that from s₀ on it has at most leafSize m edges and precision at most m ^ c: the cost of a leaf over tables with the packet shape (leafCertificate_tableEntry_le_of_packetShape), with its factor 2 ^ M (A p + 2) ^ A bounded by exists_leafFactor_le.

theorem Cslib.Circuits.Frontier.FastContraction.exists_leafCertificate_le_of_entry {T : Type} {encT : T ↪ List Bool} {ev : T → List Bool → List ℕ} (ce : GenericRAM.NativeCertificate (fun (q : T × List Bool) => ev q.1 q.2) (Turing.MultiTapeTM.encPair encT Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) (C c s₀ : ℕ) :
∃ (K : ℕ), ∀ (mk : Call T → ChildCursor.State → ℕ × DescribedNetwork (VertexDesc T)) (s : ℕ) (x : Call T) (E ES : ℕ), 2 ≤ s → s ≤ x.scale → x.scale ≤ C * s → PacketShape x → x.edges ≤ 2 * x.scale → (s₀ ≤ s → x.edges ≤ ContractionSchedule.leafSize x.scale ∧ x.prec ≤ x.scale ^ c) → (∀ v ∈ x.net.vertices, ∀ (t : T), v.2 = Sum.inl t → ∀ (bs : List Bool), bs.length = v.1.length → ce.time (t, bs) ≤ E ∧ ce.space (t, bs) ≤ ES) → (leafCertificate ce mk).time x ≤ K * (((encCall encT) x).length + ES + 1) ^ K * 2 ^ (K * s / (Nat.log 2 s).sqrt) * (E + 1) ∧ (leafCertificate ce mk).space x ≤ K * (((encCall encT) x).length + ES + 1) ^ K

The leaf bound with the costs of the root entries. For a native certificate ce of the entry procedure and all constants C, c and s₀ there is K such that a call with the packet shape, scale m with s ≤ m ≤ C s and at most 2 m edges, whose root entries take time at most E and space at most ES, takes time at most K (n + ES + 1) ^ K 2 ^ (K s / √⌊log₂ s⌋) (E + 1) and space at most K (n + ES + 1) ^ K at a leaf, provided that from s₀ on it has at most leafSize m edges and precision at most m ^ c: the cost of a leaf with the packet shape (leafCertificate_le_of_packetShape), with its factor 2 ^ M (A p + 2) ^ A bounded as for tables by exists_leafFactor_le.