Documentation

CslibFrontier.Computability.Circuit.Frontier.TensorNetwork.EntryContraction

Contraction with entry procedures: the interface #

Theorem D.1 of [OAI26k] (p. 53) contracts Boolean tensor networks whose entries are not given as tables but computed: it assumes, uniformly over the vertices and the Boolean choices of their ports, that each entry is computable from the description in time (s + L) ^ b 2 ^ (A s ^ (9/10)) and space (s + L) ^ b (a paraphrase), with maximum degree at most ⌈s ^ (9/10)⌉. At that degree a table has 2 ^ ⌈s ^ (9/10)⌉ entries, so Lemma D.2 (p. 56), which applies the theorem with entries computed by procedures, needs this form for its polynomial-space bound. This file states the interface that the contraction algorithm provides for such networks, milestone E1 of #1538.

Entry procedures. A network is a described network DescribedNetwork T (the record shared with explicit networks), with descriptors in a type T encoded by encT. An entry procedure is a function entry : T → List Bool → List ℕ, the coefficient list over A_P = (ℤ / 2 ^ P)[U] / (f) of the entry of a descriptor at the bits on its ports, with a native certificate ce on encPair encT encBits. This is the evaluator of direct summation (DescribedNetwork.contractionCertificate). Explicit networks are the case of tables, and the specialized networks of the truncation-order reduction (#1538, E2) are another instance.

Admissible networks (EntryAdmissible). Theorem D.1's hypotheses with one constant C for the theorem's C, A and b: rows-first bipartite, between s and C s edges, maximum degree at most ⌈s ^ (9/10)⌉ (ceilNineTenths), and every entry within time C (s + L + 1) ^ C 2 ^ (C ⌈s ^ (9/10)⌉) and space C (s + L + 1) ^ C, where L is the encoded length of the network. Entry outputs need no separate size condition, because a native certificate's space bound charges its encoded output. As for explicit networks (Cslib.Complexity.CountingSimulation.ExplicitAdmissible), admissibility asks for at least s edges; a caller can pad with disjoint edges whose row tensor is [x = 0] and column tensor 1, which leave the contraction unchanged. The number of vertices is not bounded separately: the encoded length bounds it.

The interface (EntryContractionAlgorithm). One native certificate maps an input (P, fl, r, G), with the precision P in unary and the coefficients fl of a modulus, to a coefficient list whose value in A_P at the modulus FastContraction.modulus m, for m the number of edges, is the contraction of the entries' values, on every input. The admissibility predicate is a parameter; Theorem D.1 takes it to be EntryAdmissible ce. On the inputs the predicate selects at a size s ≥ 2, at that modulus and precision 1 ≤ P ≤ D s (⌊log₂ s⌋ + 1), for each fixed D, it runs in time K (n + 1) ^ K 2 ^ (K s / √⌊log₂ s⌋) and space K (n + 1) ^ K. The original linear-precision bound is a corollary (EntryContractionAlgorithm.bound). The input format is that of the truncation-order reduction's contractions of specialized networks.

Direct summation (EntryContraction.directCore). Summing over all edge assignments with the entry procedure computes the contraction on every input (EntryContraction.val_directCore), in time (2 ^ m (k + 1) + 1) (K (n + ES + 1) ^ K + 2 E) and space K (n + ES + 1) ^ K + ES when the procedure takes time E and space ES on the vertices (EntryContraction.directCore_le). On admissible inputs that is K (n + 1) ^ K 2 ^ (K s) and polynomial space (EntryContraction.exists_directCore_le): the fallback of the contraction algorithm for small s.

Instances. A polynomial-time entry procedure meets the entry bounds from some constant on (EntryContraction.exists_entryAdmissible_of_isPolynomial), so admissibility reduces to the shape of the network. Tables are the entry procedure tableEntry (VertexDesc.lean), and direct summation with it is the contraction of the explicit network (EntryContraction.val_directCore_tableEntry).

Main definitions #

Main results #

References #

The nine-tenths power #

s ^ 9 ≤ s ^ 10.

Some x has s ^ 9 ≤ x ^ 10.

⌈s ^ (9/10)⌉, the least x with s ^ 9 ≤ x ^ 10.

s ^ 9 ≤ ⌈s ^ (9/10)⌉ ^ 10.

⌈s ^ (9/10)⌉ ≤ x whenever s ^ 9 ≤ x ^ 10.

theorem Cslib.Circuits.Frontier.le_ceilNineTenths_iff {s x : ℕ} (hs : 1 ≤ s) :
x ≤ ceilNineTenths s ↔ (x - 1) ^ 10 < s ^ 9

x ≤ ⌈s ^ (9/10)⌉ iff (x - 1) ^ 10 < s ^ 9: the condition of a degree at most ⌈s ^ (9/10)⌉, for s ≥ 1.

theorem Cslib.Circuits.Frontier.le_ceilNineTenths_of_pow_le {x s : ℕ} (hs : 1 ≤ s) (h : x ^ 10 ≤ s ^ 9) :

x ≤ ⌈s ^ (9/10)⌉ whenever x ^ 10 ≤ s ^ 9 and s ≥ 1.

The degree bound of the schedule is at least ⌈s ^ (9/10)⌉ (ContractionSchedule.pow_nine_le_degreeBound_pow_ten).

theorem Cslib.Circuits.Frontier.exists_mul_ceilNineTenths_le (A : ℕ) :
∃ (s₀ : ℕ), ∀ (s : ℕ), s₀ ≤ s → A * ceilNineTenths s ≤ s / (Nat.log 2 s).sqrt

Entry costs fit the budget: for every A, from some size on, A ⌈s ^ (9/10)⌉ ≤ s / √⌊log₂ s⌋. So the entry time 2 ^ (A s ^ (9/10)) allowed by Theorem D.1 is within the 2 ^ O(s / √log s) budget of a leaf (§D.4.7, p. 64).

The interface #

@[reducible, inline]

The encoding of an input (P, fl, r, G): the precision P in unary, the coefficients of the modulus and the number of rows in binary, then the network.

Admissible networks with an entry procedure at size s with constant C (Theorem D.1's hypotheses, with C for its constants C, A and b): the network G with r row vertices is rows-first bipartite, has between s and C s edges, every vertex has at most ⌈s ^ (9/10)⌉ ports, and on every vertex and bits on its ports the entry procedure's certificate takes time at most C (s + L + 1) ^ C 2 ^ (C ⌈s ^ (9/10)⌉) and space at most C (s + L + 1) ^ C, for L the encoded length of G.

structure Cslib.Circuits.Frontier.EntryContractionAlgorithm {T : Type} (encT : T ↪ List Bool) (entry : T → List Bool → List ℕ) (Admissible : ℕ → ℕ → ℕ × DescribedNetwork T → Prop) :

The contraction interface for entry procedures, extending Theorem D.1 at ℓ = 1 to logarithmic root precision, with entries in A_P. A native certificate maps (P, fl, r, G) to a coefficient list core (P, fl, r, G). At the modulus fl = FastContraction.modulus m, for m the number of edges of G, its value in A_P is the contraction of the values of the entries, on every input. For all constants C and D there is K such that on every (r, G) with Admissible C s (r, G) at a size s ≥ 2, and every precision 1 ≤ P ≤ D s (⌊log₂ s⌋ + 1), at that modulus the certificate takes time at most K (n + 1) ^ K 2 ^ (K s / √⌊log₂ s⌋) and space at most K (n + 1) ^ K, for n the encoded length of the input. The predicate Admissible is a parameter; Theorem D.1's interface is the case Admissible = EntryAdmissible ce for a native certificate ce of the entry procedure, which Cslib.Complexity.CountingSimulation.entryContractionAlgorithm implements.

theorem Cslib.Circuits.Frontier.EntryContractionAlgorithm.bound {T : Type} {encT : T ↪ List Bool} {entry : T → List Bool → List ℕ} {Admissible : ℕ → ℕ → ℕ × DescribedNetwork T → Prop} (alg : EntryContractionAlgorithm encT entry Admissible) (C D : ℕ) :
∃ (K : ℕ), ∀ (s P r : ℕ) (G : DescribedNetwork T), 2 ≤ s → 1 ≤ P → P ≤ D * s → Admissible C s (r, G) → alg.certificate.time (P, FastContraction.modulus G.numEdges, r, G) ≤ K * (((EntryContraction.encInput encT) (P, FastContraction.modulus G.numEdges, r, G)).length + 1) ^ K * 2 ^ (K * s / (Nat.log 2 s).sqrt) ∧ alg.certificate.space (P, FastContraction.modulus G.numEdges, r, G) ≤ K * (((EntryContraction.encInput encT) (P, FastContraction.modulus G.numEdges, r, G)).length + 1) ^ K

The original linear-precision bound follows from the logarithmic-precision bound of the same algorithm.

Direct summation #

Direct summation with an entry procedure: on (P, fl, r, G), the sum over all edge assignments of the products of the entries, with the operations of A_P at the modulus fl.

Direct summation is correct: at every modulus, the value is the contraction.

The time of direct summation: the input of the sum, then the sum.

theorem Cslib.Circuits.Frontier.EntryContraction.directCore_le {T : Type} {encT : T ↪ List Bool} {entry : T → List Bool → List ℕ} (ce : GenericRAM.NativeCertificate (fun (q : T × List Bool) => entry q.1 q.2) (Turing.MultiTapeTM.encPair encT Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) :
∃ (K : ℕ), ∀ (P : ℕ) (fl : List ℕ) (r : ℕ) (G : DescribedNetwork T) (E ES : ℕ), (∀ v ∈ G.vertices, ∀ (bs : List Bool), bs.length = v.1.length → ce.time (v.2, bs) ≤ E ∧ ce.space (v.2, bs) ≤ ES) → (directCore entry ce).time (P, fl, r, G) ≤ (2 ^ G.numEdges * (G.vertices.length + 1) + 1) * (K * (((encInput encT) (P, fl, r, G)).length + ES + 1) ^ K + 2 * E) ∧ (directCore entry ce).space (P, fl, r, G) ≤ K * (((encInput encT) (P, fl, r, G)).length + ES + 1) ^ K + ES

The resources of direct summation with an entry procedure. There is K such that on an input (P, fl, r, G) of encoded length n, with m edges and k vertices in G, if the entry procedure takes time at most E and space at most ES on every vertex and bits on its ports, then direct summation takes time at most (2 ^ m (k + 1) + 1) (K (n + ES + 1) ^ K + 2 E) and space at most K (n + ES + 1) ^ K + ES.

Direct summation on admissible inputs takes time K (n + 1) ^ K 2 ^ (K s) and space K (n + 1) ^ K, at the modulus of the number of edges, for K depending only on the constants: the fallback of the contraction algorithm for small sizes.

Polynomial-time entry procedures and tables #

Polynomial-time entry procedures meet the entry bounds. For a polynomial certificate of the entry procedure there is C₀ such that, for every C ≥ C₀, a rows-first network with between s and C s edges and degree at most ⌈s ^ (9/10)⌉ is admissible at size s with constant C.

Direct summation of a table network is its contraction, in A_P at every modulus.