- Boxes
- definitions
- Ellipses
- theorems and lemmas
- Blue border
- the statement of this result is ready to be formalized; all prerequisites are done
- Orange border
- the statement of this result is not ready to be formalized; the blueprint needs more work
- Blue background
- the proof of this result is ready to be formalized; all prerequisites are done
- Green border
- the statement of this result is formalized
- Green background
- the proof of this result is formalized
- Dark green background
- the proof of this result and all its ancestors are formalized
- Dark green border
- this is in Mathlib
For a finite field \(\mathbb {F}_q\) and \(n \in \mathbb {N}\), the symplectic space is the vector space \(V = \mathbb {F}_q^n \times \mathbb {F}_q^n\), equipped with the symplectic form
A subspace \(S \le V\) is isotropic if \(\omega (u,v)=0\) for all \(u,v\in S\).
Classical codes \(C_Z, C_X \le \mathbb {F}_q^n\) satisfy the CSS condition if
Given \(C_Z \perp C_X\), the CSS stabilizer is the subspace of \(V\) generated by the \(X\)-type vectors \((x,0)\) for \(x \in C_Z\) and \(Z\)-type vectors \((0,z)\) for \(z \in C_X\).
The CSS stabilizer is isotropic if and only if the CSS condition holds.
If \(C_Z \perp C_X\), then \(\dim (\mathrm{cssStabilizer}) = \dim (C_Z) + \dim (C_X)\).
The CSS code \(Q(C_Z, C_X)\) encodes \(k = n - \dim (C_Z) - \dim (C_X)\) logical qudits, and has distance \(d = \min (d_Z, d_X)\) where \(d_Z\) (resp. \(d_X\)) is the minimum weight of a vector in \(C_Z^\perp \setminus C_X\) (resp. \(C_X^\perp \setminus C_Z\)).
Every gate operation in \(\texttt{ACP.ACp\_ GateOps}\) is one of the following: the identity gate on a single input, the NOT gate \(x \mapsto 1 - x_0\), an unbounded AND gate \(x \mapsto \prod _i x_i\) of some arity \(n\), or a \(\texttt{ACP.modGateOp}\) of some arity \(n\).
Fix an evaluation point \(y\). The number of seeds \(S\) for which \(\texttt{ACP.approxAnd}\, (P,S)\) evaluated at \(y\) differs from \(\prod _k \bigl(1 - (1 - P_k(y))^{p-1}\bigr)\), multiplied by \(2^\ell \), is at most \(2^{\mathrm{width}\cdot \ell }\).
Given polynomials \(P_1,\dots ,P_{\mathrm{width}}\) over \(\mathbb {Z}/p\) and a random seed consisting of \(\ell \) subsets \(S_1,\dots ,S_\ell \) of the input positions, the approximator is
For \(v : \mathrm{Fin}\, \mathrm{width} \to \mathbb {Z}/p\) and a seed \(S\), the value-level approximator differs from the OR detector if and only if \(v \ne 0\) and every seed subset has vanishing sum, i.e. \(\sum _{i \in S_k} v_i = 0\) for all \(k\).
Fix an evaluation point \(y\). The number of seeds \(S\) for which \(\texttt{ACP.approxOr}\, (P,S)\) evaluated at \(y\) differs from \(1 - \prod _k \bigl(1 - P_k(y)^{p-1}\bigr)\), multiplied by \(2^\ell \), is at most \(2^{\mathrm{width}\cdot \ell }\); that is, at most a \(2^{-\ell }\) fraction of seeds fail at \(y\).
For every input \(x\), every layer index \(m\) with \(0 \lt m\) and every node \(v\) of layer \(m\) of \(C.\texttt{toFeedForward}\), the value of \(v\) is \(C.\texttt{toFeedForward}.\texttt{evalNode}\ v\ x = C.\texttt{eval}\ x\).
For a nonzero \(v\), the number of seeds \(S : \mathrm{Fin}\, \ell \to \mathrm{Finset} (\mathrm{Fin}\, \mathrm{width})\) on which the value-level approximator disagrees with the OR detector, multiplied by \(2^\ell \), is at most the total number of seeds.
If all values \(\mathrm{inputs}_i\) lie in \(\{ 0,1\} \subseteq \mathbb {Z}/p\), then \(\prod _i \bigl(1 - (1 - \mathrm{inputs}_i)^{p-1}\bigr)\) equals the cast into \(\mathbb {Z}/p\) of \(\prod _i \texttt{ACP.bitify}\, (\mathrm{inputs}_i)\), the Boolean AND of the booleanized inputs.
If all values \(\mathrm{inputs}_i\) lie in \(\{ 0,1\} \subseteq \mathbb {Z}/p\), then \(1 - \bigl(\sum _i \mathrm{inputs}_i\bigr)^{p-1}\) equals the cast into \(\mathbb {Z}/p\) of the output of the \(\mathrm{MOD}_p\) gate applied to the booleanized inputs \(i \mapsto \texttt{ACP.bitify}\, (\mathrm{inputs}_i)\).
There is a list \(Ps\) of polynomials, namely \(\texttt{ACP.approxAndPolyList}\, (P)\), of length \(2^{\mathrm{width}\cdot \ell }\), every entry of which has total degree at most \((p-1)\ell \cdot \sup _i \deg (P_i)\), and such that for every evaluation point \(y\) the number of seeds failing to compute the AND value at \(y\), times \(2^\ell \), is at most the length of \(Ps\).
There is a list \(Ps\) of polynomials, namely \(\texttt{ACP.approxOrPolyList}\, (P)\), of length \(2^{\mathrm{width}\cdot \ell }\), every entry of which has total degree at most \((p-1)\ell \cdot \sup _i \deg (P_i)\), and such that for every evaluation point \(y\) the number of seeds failing to compute the OR value at \(y\), times \(2^\ell \), is at most the length of \(Ps\).
Let \(\alpha ,\beta \) be finite types with \(\beta \) nonempty and let \(\mathrm{Fail} : \alpha \to \beta \to \mathrm{Prop}\) be decidable. If for every \(a\) the number of \(b\) with \(\mathrm{Fail}\, a\, b\) satisfies \(\left\lvert \{ b : \mathrm{Fail}\, a\, b\} \right\rvert \cdot C \le B\cdot \left\lvert \beta \right\rvert \), then there is a single \(b\) with \(\left\lvert \{ a : \mathrm{Fail}\, a\, b\} \right\rvert \cdot C \le B\cdot \left\lvert \alpha \right\rvert \).
The same statement for a circuit with a unique output node: there is a nonempty finite seed type and polynomials \(P(s)\) of total degree at most \(\mathrm{circuitDegreeBound}(p,\ell ,F.\mathrm{depth})\) such that for every Boolean input \(x\),
Same statement for a circuit with a unique output node: there exist a finite nonempty seed type \(\mathrm{Seed}\) and polynomials \(P : \mathrm{Seed} \to \mathbb {Z}/p[X_1,\dots ,X_n]\), each of total degree at most \(\mathrm{circuitDegreeBound}\, p\, \ell \, F.\mathrm{depth}\), such that for every Boolean input \(x\) the number of seeds \(s\) with \(P_s(\mathrm{boolInput}_p(x)) \ne F.\mathrm{eval}_1(x)\) obeys
Let \(F\) be a feed-forward circuit over \(\mathrm{Fin}\, 2\) with finite node sets, finite output type \(\mathrm{out}\), using only \(\mathrm{AC}^0[p]\) gates, and let \(\ell \) be an error parameter. Then there is a nonempty finite seed type and a family \(P\) of polynomials \(P(s,o)\) over \(\mathbb {Z}/p\) such that every \(P(s,o)\) has total degree at most \(\mathrm{circuitDegreeBound}(p,\ell ,F.\mathrm{depth})\) and, for each Boolean input \(x\),
Let \(p\) be prime and let \(F\) be a feed-forward circuit with finite node layers and a finite output type, all of whose gates lie in the \(\mathrm{AC}^0[p]\) gate set. For every \(\ell \) there exist a finite nonempty seed type \(\mathrm{Seed}\) and polynomials \(P : \mathrm{Seed} \to \mathrm{out} \to \mathbb {Z}/p[X_1,\dots ,X_n]\) such that every \(P_{s,o}\) has total degree at most \(\mathrm{circuitDegreeBound}\, p\, \ell \, F.\mathrm{depth}\), and for every Boolean input \(x\) the seeds on which some output node is computed incorrectly, i.e. \(P_{s,o}(\mathrm{boolInput}_p(x)) \ne F.\mathrm{eval}(x)(o)\) for some \(o\), satisfy
Let \(\mathrm{op}\) be a gate in \(\texttt{ACP.ACp\_ GateOps}\) and let \(P_i\) be polynomials over \(\mathbb {Z}/p\) computing its inputs. Then there exist a nonempty finite seed type \(\mathrm{Seed}\) with decidable equality and a family \(P : \mathrm{Seed} \to \mathrm{MvPolynomial}(\mathrm{Fin}\, n, \mathbb {Z}/p)\) such that every \(P(s)\) has total degree at most \((p-1)\ell \cdot \sup _i \deg (P_i)\), and for every Boolean input \(x\), writing \(y_j = x_j\) cast into \(\mathbb {Z}/p\) and \(\mathrm{inputs}_i = P_i(y)\), if all \(\mathrm{inputs}_i\) lie in \(\{ 0,1\} \) then the number of seeds \(s\) with \(P(s)(y)\) different from the gate value \(\mathrm{op}.\mathrm{func}(i \mapsto \texttt{ACP.bitify}(\mathrm{inputs}_i))\), multiplied by \(2^\ell \), is at most \(\left\lvert \mathrm{Seed}\right\rvert \).
The single-output theorem restated with the seed distribution presented as a nonempty list \(Ps\) of polynomials with multiplicity, one entry per seed: every \(P \in Ps\) has total degree at most \(\mathrm{circuitDegreeBound}(p,\ell ,F.\mathrm{depth})\), and for every Boolean input \(x\) the number of entries of \(Ps\) disagreeing with \(F.\mathrm{eval}_1\, x\), multiplied by \(2^{\ell }\), is at most \(\mathrm{gateCountBefore}\, F\, F.\mathrm{depth} \cdot \left\lvert Ps\right\rvert \).
The list formulation of the previous theorem: for a circuit \(F\) with a unique output node whose gates all lie in the \(\mathrm{AC}^0[p]\) gate set, there is a nonempty list \(Ps\) of polynomials in \(\mathbb {Z}/p[X_1,\dots ,X_n]\), each of total degree at most \(\mathrm{circuitDegreeBound}\, p\, \ell \, F.\mathrm{depth}\), such that for every Boolean input \(x\) the sublist of \(P \in Ps\) with \(P(\mathrm{boolInput}_p(x)) \ne F.\mathrm{eval}_1(x)\) satisfies
Let \(F\) be a feed-forward circuit with a unique output that only uses \(\mathrm{AC}^0[p]\) gate operations. Then there exists a polynomial \(P\) over \(\mathbb {Z}/p\) with \(\deg P \le \mathrm{circuitDegreeBound}\, p\, \ell \, (\mathrm{depth}\, F)\) whose bad-input count against the function computed by \(F\) satisfies \(\mathrm{badInputCount}\cdot 2^{\ell } \le \left\lvert F\right\rvert \cdot 2^{n}\), where \(\left\lvert F\right\rvert \) is the circuit size.
Let \(P\) be a family of polynomials over \(\mathbb {Z}/p\) indexed by a nonempty finite seed type. If for every Boolean input \(x\) the number of seeds \(s\) with \((P_s)(\mathrm{boolInput}(x)) \neq f(x)\), times \(2^{\ell }\), is at most \(B\cdot \left\lvert \mathrm{Seed}\right\rvert \), then some seed \(s\) satisfies \(\mathrm{badInputCount}(f, P_s)\cdot 2^{\ell } \le B\cdot 2^{n}\).
Every function \(f : \{ 1,\omega \} ^n \to K\) on the root cube is represented by a squarefree (multilinear) polynomial: there are coefficients \(c\) indexed by finsets of \(\mathrm{Fin}\, n\) such that \((\texttt{ACP.squarefreePolynomial}\ c)(x) = f(x)\) for all \(x\) in the root cube.
A feedforward circuit from inp to out over \(\alpha \) consists of a depth \(d \in \mathbb {N}\), a family of node types indexed by the layers \(\mathrm{Fin}\, (d+1)\), and, for every layer \(i \lt d\), a gate for each node of layer \(i+1\) whose inputs are wired to nodes of layer \(i\). Layer \(0\) is required to be the input type inp and the last layer the output type out.
For an input assignment \(xs : \texttt{inp} \to \alpha \), the value of a node at layer \(d\) is defined by recursion on \(d\): a layer-\(0\) node is read off directly from \(xs\), and a node at layer \(n+1\) evaluates its gate on the values of the layer-\(n\) nodes.
Given a gate \(g\) and an assignment \(xs\) of values to the nodes of its input domain, the value of \(g\) is \(g.\texttt{op}.\texttt{func}\, (xs \circ g.\texttt{inputs})\), i.e. the gate operation applied to the values read along the input wires.
Given a Boolean feedforward circuit \(F\), a flag \(\texttt{isAnd}\) on each non-input node and a finiteness witness \(\texttt{gfin}\) for each gate’s arity, \(F.\texttt{IsAndOrGate}\) asserts that every gate operation is the conjunction of its inputs when the flag is true and their disjunction when it is false, the inputs being enumerated by \(\texttt{gfin}\). This is the gate restriction under which \(F\) can be converted into a BoolCircuit.Circuit.
Let \(\alpha , \beta , \mathrm{Cand}\) be finite and let \(\mathrm{center} : \mathrm{Cand} \to (\alpha \to \beta )\). If every ball \(\{ f : \left\lvert \{ a : \mathrm{center}\, c\, a \neq f(a)\} \right\rvert \le e\} \) has at most \(B\) elements, and every \(f : \alpha \to \beta \) lies in one of these balls, then \(\left\lvert \alpha \to \beta \right\rvert \le \left\lvert \mathrm{Cand}\right\rvert \cdot B\).
For finite types \(\alpha , \beta \), a center function \(\mathrm{center} : \alpha \to \beta \) and a radius \(e\), the number of functions \(f : \alpha \to \beta \) that differ from the center on at most \(e\) coordinates is bounded by
This is a slightly coarser form of the usual bound, which carries \((\left\lvert \beta \right\rvert -1)^t\) in place of \(\left\lvert \beta \right\rvert ^t\).
A gate over alphabet \(\alpha \) with input domain domain consists of a gate operation op (an arity type \(\iota \) together with a function \((\iota \to \alpha ) \to \alpha \)) and a wiring map \(\iota \to \texttt{domain}\) that assigns to each input slot the node it reads from.
For a circuit \(F\) with finite node sets, \(\mathrm{gateCountBefore}\, F\, d\) counts the non-input gates in layers \(1,\dots ,d\): it is \(0\) for \(d = 0\) and, recursively, the count for \(d\) plus the number of nodes at layer \(d+1\).
Let \(F\) be a feed-forward circuit with all node layers finite. Then for every \(d\) with \(d \le F.\mathrm{depth}\),
that is, the number of non-input gates in the first \(d\) layers is the sum of the cardinalities of those layers.
For a feed-forward circuit \(F\), a bound \(d \le F.\mathrm{depth}\) and an index \(j : \mathrm{Fin}\, d\), the layer index \(\mathrm{gateLayerIdx}\, F\, h_d\, j \in \mathrm{Fin}(F.\mathrm{depth}+1)\) is \(j+1\), i.e. the \((j+1)\)-st node layer of \(F\). It packages the non-input layers \(1, \dots , d\) as indices into \(F.\mathrm{nodes}\) so that they can be summed over.
A GatePolyFamily for a gate operation \(\mathrm{op}\) packages a nonempty finite seed type together with, for each tuple of incoming polynomials and each seed, an approximating polynomial in \(n\) variables over \(\mathbb {Z}/p\) subject to two guarantees: its total degree is at most \((p-1)\ell \cdot \sup _i \deg (\text{polys}_i)\), and for every Boolean input \(x\) at which all incoming polynomials evaluate into \(\{ 0,1\} \), the number of seeds on which the approximator disagrees with the true gate value, multiplied by \(2^{\ell }\), is at most the number of seeds. Crucially the seed type depends only on the gate, not on the incoming polynomials.
A LayerPolyFamily for a circuit \(F\) at layer \(d\) consists of a nonempty finite seed type and, for each seed, a polynomial for every node of layer \(d\), such that each polynomial has total degree at most \(\mathrm{circuitDegreeBound}(p,\ell ,d)\) and, for every Boolean input \(x\), the number of seeds for which some layer-\(d\) node is mispredicted, multiplied by \(2^{\ell }\), is at most \(\mathrm{gateCountBefore}\, F\, d\) times the number of seeds.
Assume \(\omega \ne 1\). Every polynomial \(Q\) with \(\deg Q \le D\) agrees on the root cube \(\{ 1,\omega \} ^n\) with a low-degree squarefree polynomial: there are coefficients \(c\) on \(\texttt{ACP.LowDegreeSupport}\ n\ D\) such that \((\texttt{ACP.lowDegreeSquarefreePolynomial}\ c)(x) = Q(x)\) for all \(x\) in the cube.
Given coefficients \(c\) indexed by \(\texttt{ACP.LowDegreeSupport}\ n\ D\), the multivariate polynomial
i.e. the sum of the squarefree monomials \(\texttt{ACP.squarefreeMonomial}\ s\) weighted by \(c\), with the terms of support size \(\gt D\) set to \(0\).
For \(n, D \in \mathbb {N}\), the type of supports of squarefree monomials of degree at most \(D\): the subtype of finsets \(s \subseteq \mathrm{Fin}\, n\) with \(\left\lvert s\right\rvert \le D\). In the displays below this type is written \(\mathcal{S}_{n,D}\).
The map sending a low-degree support \(s\) to the pair consisting of its exact cardinality \(\left\lvert s\right\rvert \in \mathrm{Fin}(D+1)\) together with \(s\) itself, viewed as an element of \(\{ t : \mathrm{Finset}(\mathrm{Fin}\, n) \mid \left\lvert t\right\rvert = \left\lvert s\right\rvert \} \). It is used as an injection for the binomial-sum bound rather than as a full equivalence.
Assume \(\omega \ne 1\). If a monomial \(a\, X^m\) has total exponent sum \(\sum _i m_i \le D\), then it agrees on the root cube \(\{ 1,\omega \} ^n\) with a squarefree polynomial built only from supports of size at most \(D\): there exist coefficients \(c\) on \(\texttt{ACP.LowDegreeSupport}\ n\ D\) with \((\texttt{ACP.lowDegreeSquarefreePolynomial}\ c)(x) = (a\, X^m)(x)\) for every \(x\) in the cube.
Assume \(\omega \neq 0\), that every function on \(\{ 1,\omega \} ^n\) has a squarefree representative, and the counting hypothesis that not every function on the cube admits a degree-\(\le n/2 + d\) approximant with at most \(e\) bad points. Then no polynomial of total degree at most \(d\) approximates the top monomial \(x \mapsto \prod _i x_i\) within \(e\) bad points.
Let \(K\) be finite, \(\omega \ne 0\), \(\omega \ne 1\). Suppose \(\sum _{t=0}^{e} \binom {2^n}{t}\, \left\lvert K\right\rvert ^{\, t} \le B\) and
Then no polynomial \(P\) with \(\deg P \le d\) approximates the product \(x \mapsto \prod _i x_i\) on the root cube with at most \(e\) errors, i.e. there is no such \(P\) with \(\texttt{ACP.rootCubeBadCount}\ (\prod _i x_i)\ P \le e\).
The same conclusion as the previous theorem, with the abstract counting hypothesis replaced by explicit data: a finite candidate family representing all degree-\(\le n/2 + d\) polynomials on the cube, a bound \(B\) on the size of each Hamming ball of radius \(e\), and the strict inequality \(\left\lvert \{ 1,\omega \} ^n \to K\right\rvert \gt \left\lvert \mathrm{Cand}\right\rvert \cdot B\).
Recursively expands a node \(v\) of layer \(m\) of a Boolean feedforward circuit into a tree-shaped \(\texttt{Circuit}\ n\): a layer-\(0\) node becomes the positive literal of the corresponding input variable, and a node at a higher layer becomes an AND/OR node whose children are the unrollings of the nodes on its input wires. Nodes feeding several downstream gates are duplicated.
If every gate of \(F\) is an AND or OR gate as recorded by \(\texttt{isAnd}\) and \(\texttt{gfin}\), then for every node \(v\) at layer \(m\) and every input \(x : \mathrm{Fin}\, n \to \{ 0,1\} \),
Fix a coordinate \(i\) and a decidable predicate \(\mathrm{Bad}\) on \(\beta _i\), and suppose \(\left\lvert \{ b : \mathrm{Bad}(b)\} \right\rvert \cdot C \le \left\lvert \beta _i\right\rvert \). Then the number of dependent functions \(f\) with \(\mathrm{Bad}(f_i)\) satisfies
Given for each coordinate \(i\) a decidable predicate \(\mathrm{Bad}_i\) on \(\beta _i\) with \(\left\lvert \{ b : \mathrm{Bad}_i(b)\} \right\rvert \cdot C \le \left\lvert \beta _i\right\rvert \), the number of dependent functions bad at some coordinate obeys
For an index \(i\) with decidable equality on the index type, the equivalence
sending a dependent function to its value at \(i\) together with its restriction to the remaining coordinates.
Let \(\mathrm{Bad}\) be a finite set of elements of \(\alpha \), let \(\mathrm{Fail} : \alpha \to \beta \to \mathrm{Prop}\) be decidable with \(\beta \) finite and nonempty, and let \(C\) be a natural number. If for every \(a \in \mathrm{Bad}\) we have \(\left\lvert \{ b : \mathrm{Fail}(a,b)\} \right\rvert \cdot C \le \left\lvert \beta \right\rvert \), then there exists a single \(b \in \beta \) with \(\left\lvert \{ a \in \mathrm{Bad} : \mathrm{Fail}(a,b)\} \right\rvert \cdot C \le \left\lvert \mathrm{Bad}\right\rvert \).
Let \(P\) be a predicate on \(\alpha \), \(Q\) a predicate on \(\alpha \times \beta \), and \(C, B\) natural numbers such that for every \(a\) with \(P(a)\) the fiber count satisfies \(\left\lvert \{ b : Q(a,b)\} \right\rvert \cdot C \le B\). Then
For finite types \(\alpha ,\beta \) and a decidable predicate \(P\) on \(\alpha \), the number of pairs \(z \in \alpha \times \beta \) with \(P(z_1)\) equals \(\left\lvert \{ a : P(a)\} \right\rvert \cdot \left\lvert \beta \right\rvert \).
Suppose a finite family \((\mathrm{poly}\, c)_{c \in \mathrm{Cand}}\) represents, on the cube, every polynomial of total degree at most \(D\); suppose each Hamming ball of radius \(e\) around such a candidate has at most \(B\) elements; and suppose \(\left\lvert \{ 1,\omega \} ^n \to K\right\rvert \gt \left\lvert \mathrm{Cand}\right\rvert \cdot B\). Then it is not the case that every function on the cube has a degree-\(\le D\) approximant with at most \(e\) bad points.
Let \(K\) be finite and \(\omega \ne 1\). Suppose the ball bound \(\sum _{t=0}^{e} \binom {2^n}{t}\, \left\lvert K\right\rvert ^{\, t} \le B\) holds and the counting is strict,
Then it is not the case that every function \(f : \{ 1,\omega \} ^n \to K\) admits a polynomial \(Q\) with \(\deg Q \le D\) and \(\texttt{ACP.rootCubeBadCount}\ f\ Q \le e\).
For any center function on the root cube and any radius \(e\), the Hamming ball \(\texttt{ACP.rootCubeBall}\) of radius \(e\) around it satisfies
Assume \(\omega \neq 0\) and that every function on \(\{ 1,\omega \} ^n\) is represented on the cube by a squarefree polynomial. If \(P\) has total degree at most \(d\) and approximates the top monomial \(x \mapsto \prod _i x_i\) with at most \(e\) bad points, then every function \(f\) on the cube has a polynomial \(Q\) with \(\deg Q \le n/2 + d\) and at most \(e\) bad points.
For a feed-forward circuit \(F\) with all node layers finite,
so the total number of non-input gates equals the sum of the cardinalities of all non-input layers.
If a feed-forward circuit \(F\) over the \(\mathrm{AC}^0[p]\) gate set computes \(\mathrm{MOD}_q\) on all Boolean inputs, and if \(\mathrm{MOD}_q\) (viewed in \(\mathbb {Z}/p\)) admits the lower bound \(\mathrm{LowDegreeBadCountLB}\) with parameters \((\mathrm{circuitDegreeBound}\, p\, \ell \, (\mathrm{depth}\, F), E)\), then \(E \cdot 2^{\ell } \le \left\lvert F\right\rvert \cdot 2^{n}\).
Let \(\omega \neq 0\) and let \(c\) be a coefficient family. Then there are polynomials \(P_1, P_2\) of total degree at most \(n/2\) such that for every \(x \in \{ 1,\omega \} ^n\),
Let \(\omega \neq 0\) and let \(c\) be a coefficient family. Then there are polynomials \(P_1, R\) of total degree at most \(n/2\) such that for every \(x \in \{ 1,\omega \} ^n\),
so that the second factor is already evaluated at \(x\) itself rather than at the affine substitution.
Given a circuit \(F\) using only \(\mathrm{AC}^0[p]\) gates and a LayerPolyFamily at layer \(d\), this produces a LayerPolyFamily at layer \(d+1\). Its seed type is the product of the previous seed type with one gate seed per node of layer \(d+1\), and each node polynomial is the gate approximator applied to the layer-\(d\) polynomials of its inputs.
For a nonzero vector \(v : \mathrm{Fin}\, n \to \mathbb {Z}/p\), the number of subsets \(s \subseteq \mathrm{Fin}\, n\) with \(\sum _{i \in s} v_i = 0\) is at most half of all \(2^n\) subsets; formally, twice that count is at most the total number of subsets.
For a finite index type \(\iota \), a finite type \(\beta \) and a decidable predicate \(P\) on \(\beta \), the number of functions \(f : \iota \to \beta \) with \(P(f(i))\) for all \(i\) equals \(\left\lvert \{ b : P(b)\} \right\rvert ^{\left\lvert \iota \right\rvert }\).
An \(\texttt{AdaptiveAdversary}\ N\) is an online strategy for the adversary: it provides a loss-selection function \(\mathrm{loss} : (t : \mathbb {N}) \to \texttt{LossHistory}\ N\ t \to (\mathrm{Fin}\, N \to \mathbb {R}) \to \mathrm{Fin}\, N \to \mathbb {R}\) that maps the current round index, the past loss history, and the learner’s current mixed strategy to a loss vector, subject to the validity condition that every coordinate of the chosen loss vector lies in \([0, 1]\).
The \((i,j)\) entry of \(A\) counts arcs, i.e. walks of length one; matrix multiplication sums over an intermediate vertex, and every walk of length \(k\) decomposes uniquely as a shorter walk plus a final arc. This is the directed counterpart of exercise 1.6.2, and it is what makes §10.7’s ranking work: the \(i\)-th level score vector is \(A^{i}J\), counting directed walks of length \(i\) out of each player. Theorem 10.7 consumes it directly.
! Restated for a \(0/1\) matrix, Digraph having no arc multiplicities; for the strict digraphs of §10.7 this is no loss. The right-hand side is Nat.card of a subtype of Quiver.Path, which is finite because the length is pinned — but that finiteness may need to be supplied for Nat.card to behave.
For any finite zero-sum game \(G\) with \(M \ge 2\) rows and any \(\varepsilon \gt 0\), there exist mixed strategies \(p\) (row) and \(q\) (column) forming an \(\varepsilon \)-approximate saddle point: for all pure \(i \in \mathrm{Fin}\, M\) and \(j \in \mathrm{Fin}\, N\),
A social welfare function \(f\) is acyclic if no profile of transitive voter orderings produces a Condorcet cycle in society’s preferences. A cycle occurs when \(f(\mathrm{abVotes}(p)) = f(\mathrm{bcVotes}(p)) = f(\mathrm{caVotes}(p)) = 1\) (the cycle \(a\gt b\gt c\gt a\)) or all equal \(-1\) (the reverse cycle).
If \(f\) is \(\pm 1\)-valued and acyclic, then \(\mathrm{corr}(f) = -1/3\).
Proof sketch:
For any \(\pm 1\) triple \((a,b,c)\) avoiding the two all-equal cycles, \(ab + bc + ac = -1\).
Summing over all \(6^n\) profiles: \(\sum _p (f_{\! ab}\cdot f_{\! bc} + f_{\! bc}\cdot f_{\! ca} + f_{\! ab}\cdot f_{\! ca}) = -6^n\).
Each pairwise expected product equals \(\mathrm{corr}(f)\), so \(3\cdot \mathrm{corr}(f) = -1\), giving \(\mathrm{corr}(f) = -1/3\).
Let \(f:\{ 0,1\} ^n\to \mathbb {R}\) be a social welfare function that is odd (antisymmetric), \(\pm 1\)-valued, unanimous, and acyclic. Then \(f\) is a dictatorship: there exists a voter \(i_0\) such that \(f = \mathrm{dict}_{i_0}\).
Proof:
Acyclicity \(\Rightarrow \) \(\mathrm{corr}(f) = -1/3\) (Lemma ArrowTheorem.acyclic_implies_corrFunc).
\(\mathrm{corr}(f) = -1/3\) \(\Rightarrow \) \(\hat f(S) = 0\) for \(|S|\ne 1\) (Lemma ArrowTheorem.corrFunc_eq_neg_third_of_weight_one).
Degree-1 + unanimous + \(\pm 1\)-valued \(\Rightarrow \) dictator (Lemma ArrowTheorem.degree_one_implies_dictator).
For any odd \(\pm 1\)-valued function,
Proof sketch: For odd \(|S|\ge 1\) we have \((-1/3)^{|S|}\ge -1/3\). Even-level coefficients vanish by oddness. Hence \(\mathrm{corr}(f) \ge (-1/3)\sum _S \hat f(S)^2 = -1/3\).
Suppose \(f\) is \(\pm 1\)-valued, unanimous, and \(\hat f(S) = 0\) for all \(|S|\ne 1\). Then \(f\) is a dictator.
Proof sketch: Write \(f = \sum _i a_i\chi _{\{ i\} }\) where \(a_i = \hat f(\{ i\} )\).
Parseval: \(\sum _i a_i^2 = 1\).
Unanimity: \(f(\mathbf{0}) = \sum _i a_i = 1\).
For each \(j\), the value \(f(e_j) = 1 - 2a_j \in \{ -1,1\} \) forces \(a_j\in \{ 0,1\} \).
From \(a_j\in \{ 0,1\} \) and \(\sum a_j^2 = \sum a_j = 1\): exactly one \(a_{j_0} = 1\) and the rest are \(0\).
Hence \(f = \chi _{\{ j_0\} } = \mathrm{dict}_{j_0}\).
Let \(f:\{ 0,1\} ^n\to \mathbb {R}\) and let \(\mathrm{votes}_1,\mathrm{votes}_2\) map each profile to a Boolean cube point. If the pair satisfies the kernel identity \(\bigl(\tfrac 16\bigr)^n\sum _p \chi _S(\mathrm{votes}_1(p))\, \chi _T(\mathrm{votes}_2(p)) = [S = T]\, (-1/3)^{|S|}\) for all \(S,T\), then
For \(A\subseteq \mathrm{Fin}\, n\) and \(g:\mathrm{Fin}\, n\to \mathbb {R}\),
rewriting a product over a finset as a product over all of \(\mathrm{Fin}\, n\) with an indicator.
Specialization of the general kernel to the \(ab\)–\(bc\) vote pair: for all \(S,T\subseteq [n]\),
Specialization of the general kernel to the \(ab\)–\(ca\) vote pair: for all \(S,T\subseteq [n]\),
Specialization of the general kernel to the \(bc\)–\(ca\) vote pair: for all \(S,T\subseteq [n]\),
Let \(\mathrm{xPref},\mathrm{yPref}:\mathrm{Fin}\, 6\to \mathrm{Bool}\) be two preference assignments with balanced marginals \(\sum _k s(\mathrm{xPref}(k)) = \sum _k s(\mathrm{yPref}(k)) = 0\) and cross-sum \(\sum _k s(\mathrm{xPref}(k))\, s(\mathrm{yPref}(k)) = -2\). Then for all \(S,T\subseteq [n]\),
Summing pairwise sign products over all 6 orderings:
Hence \(\mathbb {E}[s_{ab}\cdot s_{bc}] = -2/6 = -1/3\).
*\(D(G)\) is \(k\)-arc-connected if and only if \(G\) is \(k\)-edge-connected.*
The associated digraph faithfully preserves connectivity, so the directed notion generalises the undirected one. Contrast §10.6, where the question is which orientations — not the doubling — preserve it; there the answer is much more delicate (Robbins, Nash-Williams).
"\(G\) is \(k\)-edge-connected" is spelled k \(\le \) edgeConnectivity G, per §3.1. Step 2 needs that a minimal edge cut is \([S, S^{c}]\) for a component \(S\), which is the same fact the local IsEdgeCut docstring notes when reconciling the book’s shape-based definition with the deletion-based one used here.
+ Statement repaired — [Nontrivial V] added. The \(\leftrightarrow \) was false on a one-vertex carrier. Take card V = 1, so \(G = \bot \), and \(k = 1\). Left side: there is no nonempty proper S : Finset V, so IsKArcConnected 1 holds vacuously. *Right side:* \(\bot \) on one vertex is Connected, so nothing disconnects it, \(G\) has no edge cut at all, and edgeConnectivity G = 0; the claim \(1 \le 0\) fails.
[Nontrivial V] excludes exactly that carrier and is the hypothesis the book’s "nontrivial digraph" convention supplies implicitly (compare diconnected_iff_isKArcConnected_one above, which already carries it). ! Both Menger statements in Networks.lean consume this lemma, so their hypotheses must be checked against the added Nontrivial when they are proved.
Given \(T\) distributions \(p_0, \dots , p_{T-1}\) over \(\mathrm{Fin}\, n\) (each presented as non-negative weights summing to \(1\)) and \(T \gt 0\), the average strategy is the mixed strategy with weights
Given a \(k \times d\) matrix \(A\) and a finite set \(V \subseteq \mathbb {R}^d\), BadPair \(\varepsilon \; V\; A\) holds when there exists some ordered pair \((u, v) \in V \times V\) whose images under \(A\) fail the distortion predicate, i.e. the projection distorts that pair by more than a factor of \(\varepsilon \).
For a parameter \(\varepsilon \in \mathbb {R}\), a matrix \(A\), and a vector \(x\in \mathbb {R}^d\), the predicate \(\texttt{BadSingle}\, \varepsilon \, A\, x\) holds when the squared-norm distortion is strictly too large:
This is the “bad event” whose probability must be controlled by the JL concentration argument.
For \(L \in [0,1]\) and any \(\eta \in \mathbb {R}\),
The bound is established by showing that the function \(\varphi (\eta ) = -L\eta + \eta ^2/8 - \ln (1-L+Le^{-\eta })\) is convex with \(\varphi (0) = 0\) and \(\varphi '(0) = 0\).
For \(0 \le p \le 1\) and any event, the Bernoulli\((p)\) restriction probability decomposes according to the number of free variables:
because conditioning \(R_p\) on having exactly \(k\) free variables yields exactly the model \(R_k\).
Let \(0 \lt p \le 1\), \(w, s \gt 0\), and \(\varepsilon \gt 0\). Then there exists \(N\) such that for every \(n \ge N\) with \(n \gt 0\) and every event satisfying \(\mathrm{fixedSizeRestrProb}\, (\mathrm{event})\, k \le (5kw/n)^s\) for all \(k \le n\), one has \(\Pr _{R_p}[\mathrm{event}] \le (10pw)^s + \varepsilon \). Asymptotically the exponential tail vanishes, leaving only the leading bound \((10pw)^s\).
Let \(n \gt 0\), \(0 \lt p \le 1\), and \(w, s \gt 0\). If the event satisfies \(\mathrm{fixedSizeRestrProb}\, (\mathrm{event})\, k \le (5kw/n)^s\) for every \(k \le n\), then under the Bernoulli model,
For \(0 \lt p \le 1\), the upper tail of the binomial distribution beyond \(2np\) is exponentially small: summing \(\mathrm{binomialPMF}\, n\, p\, k\) over those \(k \in \{ 0, \dots , n\} \) with \(k \gt 2np\) is at most \(e^{-np/3}\).
The probability of an event under the fixed-size restriction model \(R_k\), which is uniform over restrictions with exactly \(k\) free variables. It is defined as the fraction of restrictions with exactly \(k\) free variables that satisfy the event.
Fact 4.2 (lower half). Under the same hypotheses \(n \gt 0\), \(q \gt 0\), \(q \le \ell \), \(2\ell \le n\) and \(2q \le n\),
with the binomial coefficients again read in \(\mathbb {R}\) via \(\texttt{chooseR}\).
Fact 4.2 (upper half). Let \(n, \ell , q\) be naturals with \(n \gt 0\), \(q \gt 0\), \(q \le \ell \), \(2\ell \le n\) and \(2q \le n\). Then
where both binomial coefficients are taken in \(\mathbb {R}\) via \(\texttt{chooseR}\).
The key algebraic inequality driving the inductive step of the Bonami lemma: for \(a, b, A, B, C \ge 0\) (with \(a, b, B, C\) nonnegative) satisfying \(A \le 9^{m+1} a^2\), \(B \le 9^m b^2\), and \(C^2 \le A\cdot B\), one has
The half-difference \(\mathrm{diffLast}\, f\) of \(f\) over its last coordinate is the function on \(n\) variables given by \(\tfrac 12\bigl(\mathrm{restrictLast}\, f\, \mathrm{false} - \mathrm{restrictLast}\, f\, \mathrm{true}\bigr)\).
The expectation of \(\varphi \) on the cube of dimension \(n+1\) is the average of the expectations of its two restrictions:
For each \(S \subseteq \mathrm{Fin}\, n\), the Fourier coefficient of \(\mathrm{avgLast}\, f\) at \(S\) equals the Fourier coefficient of \(f\) at the image of \(S\) under castSucc: \(\widehat{\mathrm{avgLast}\, f}(S) = \widehat{f}(\mathrm{castSucc}(S))\).
For each \(S \subseteq \mathrm{Fin}\, n\), the Fourier coefficient of \(\mathrm{diffLast}\, f\) at \(S\) equals the Fourier coefficient of \(f\) at the image of \(S\) under castSucc together with the last index: \(\widehat{\mathrm{diffLast}\, f}(S) = \widehat{f}\bigl(\mathrm{castSucc}(S) \cup \{ \mathrm{last}\, n\} \bigr)\).
Let \(Z \ge 0\) be a nonnegative random variable with finite first and second moments and positive mean. For every \(\theta \) with \(0 \le \theta \le 1\),
For any \(\varphi \) on the cube of dimension \(n+1\), the total sum decomposes according to the value of the last coordinate:
The BLR acceptance probability of \(f : \{ 0,1\} ^n \to \{ 0,1\} \) is
where \(x, y\) are drawn uniformly from \(\{ 0,1\} ^n\).
For any \(f : \{ 0,1\} ^n \to \{ 0,1\} \),
Let \(f : \{ 0,1\} ^n \to \{ 0,1\} \) satisfy \(f(x \oplus y) = f(x) \oplus f(y)\) for all \(x, y\), and write \(g = \texttt{BoolBLR.lift\_ pm1}\, f\). Then \(g\) is multiplicative on XOR:
If \(f : \{ 0,1\} ^n \to \{ 0,1\} \) is \(\varepsilon \)-far from linear, then
That is, a function that is \(\varepsilon \)-far from every linear function causes the BLR test to reject with probability at least \(\varepsilon \).
If \(f : \{ 0,1\} ^n \to \{ 0,1\} \) is \(\varepsilon \)-far from linear, then the sum of cubed Fourier coefficients of \(\texttt{BoolBLR.lift\_ pm1}\, f\) satisfies
This follows by combining the per-coefficient bound \(\hat{f}(S) \le 1-2\varepsilon \) with the Parseval identity \(\sum _S \hat{f}(S)^2 = 1\).
Let \(f : \{ 0,1\} ^n \to \{ 0,1\} \) be \(\varepsilon \)-far from linear and write \(g = \texttt{BoolBLR.lift\_ pm1}\, f\). Then for every \(S \subseteq [n]\),
Let \(f, g : \{ 0,1\} ^n \to \{ 0,1\} \), let \(S \subseteq [n]\), and suppose \(\texttt{BoolBLR.lift\_ pm1}\, g = \chi _S\) and \(\operatorname{dist}(f, g) \ge \varepsilon \). Then the Fourier coefficient of \(\texttt{BoolBLR.lift\_ pm1}\, f\) at \(S\) satisfies \(\widehat{\texttt{BoolBLR.lift\_ pm1}\, f}(S) \le 1 - 2\varepsilon \).
Let \(f : \{ 0,1\} ^n \to \{ 0,1\} \) satisfy \(\texttt{BoolBLR.lift\_ pm1}\, f = \chi _S\) for some \(S \subseteq [n]\), and let \(x, y \in \{ 0,1\} ^n\). Assuming the multiplicativity identity \(\chi _S(x \oplus y) = \chi _S(x)\chi _S(y)\), one has
If \(\texttt{BoolBLR.lift\_ pm1}\, f = \chi _S\) for some \(S \subseteq [n]\), then for all \(x, y \in \{ 0,1\} ^n\),
This is the previous lemma with the multiplicativity hypothesis discharged.
Restatement of the support formula in the exact form used inside the proof of the character criterion: for linear \(f\) and any \(x \in \{ 0,1\} ^n\), \(f(x)\) is the parity of the number of coordinates \(i\) with \(x_i = \texttt{true}\) and \(f(e_i) = \texttt{true}\).
Let \(f : \{ 0,1\} ^n \to \{ 0,1\} \) be linear. Then for every \(s \subseteq [n]\), writing \(\mathbf{1}_s\) for the indicator vector of \(s\) and \(e_i\) for the \(i\)-th basis vector, the value \(f(\mathbf{1}_s)\) is false when
and true otherwise; that is, \(f(\mathbf{1}_s)\) is the parity of the number of \(i \in s\) with \(f(e_i) = \texttt{true}\).
Specialization of the previous lemma to the support of an arbitrary point: if \(f : \{ 0,1\} ^n \to \{ 0,1\} \) is linear, then for every \(x \in \{ 0,1\} ^n\) the value \(f(x)\) is the parity of the number of coordinates \(i\) with \(x_i = \texttt{true}\) and \(f(e_i) = \texttt{true}\).
For any \(f : \{ 0,1\} ^n \to \{ 0,1\} \), letting \(\hat{g}(S)\) denote the Fourier coefficient of \(g = \texttt{BoolBLR.lift\_ pm1}\, f\),
Write \(g = \texttt{BoolBLR.lift\_ pm1}\, f\) and assume \((g * g)(x) = \sum _S \hat{g}(S)^2 \chi _S(x)\) for all \(x\). Then
A Boolean circuit on \(n\) variables is a tree whose leaves are literals (lit \(l\)) and whose internal nodes (node \(isAnd\) \(children\)) are AND gates when \(isAnd = \mathrm{true}\) and OR gates when \(isAnd = \mathrm{false}\), applied to a list of child circuits. No alternation or deduplication constraint is imposed.
An induction principle for Circuit stating that to prove a predicate \(\mathrm{motive}\) holds for every circuit it suffices to prove it for every literal and, in the node case, to prove \(\mathrm{motive}(\texttt{node}\, isAnd\, cs)\) assuming \(\mathrm{motive}\, c\) for every child \(c \in cs\). This works around the lack of native support for nested inductives.
Given a circuit \(c\) on \(m\) variables and a function \(f : \mathrm{Fin}\, m \to \mathrm{Fin}\, m'\), the re-indexed circuit \(\mathrm{reidx}(c, f)\) on \(m'\) variables is obtained by replacing each literal index \(i\) by \(f(i)\) (keeping its sign) and recursing structurally through the \(\mathrm{And}/\mathrm{Or}\) nodes.
For every circuit \(c\) on \(m\) variables, every \(f : \mathrm{Fin}\, m \to \mathrm{Fin}\, m'\), and every assignment \(g : \mathrm{Fin}\, m' \to \mathrm{Bool}\), evaluating the re-indexed circuit under \(g\) equals evaluating \(c\) under the pulled-back assignment \(g \circ f\), i.e. \(\mathrm{eval}(\mathrm{reidx}(c, f), g) = \mathrm{eval}(c, g \circ f)\).
Turns a circuit \(C\) on \(n\) inputs into a feedforward circuit \(\texttt{FeedForward}\ \texttt{Bool}\ (\mathrm{Fin}\, n)\ \mathrm{Unit}\) of depth \(C.\texttt{depth} + 1\): layer \(0\) carries the \(n\) input variables and every higher layer carries a single wire. The gate from layer \(0\) to layer \(1\) computes \(C.\texttt{eval}\) from all inputs at once, and all later gates are identity wires that pass the single Boolean value upward.
Converts a general circuit into a normal-form AND circuit: a literal becomes a singleton clause; an AND node maps its children through \(\mathrm{toNOr}\); and an OR node is wrapped as a single OR node built from the children’s \(\mathrm{toNAnd}\) images, enforcing alternation.
Converts a general circuit into a normal-form OR circuit: a literal becomes a singleton clause; an OR node maps its children through \(\mathrm{toNAnd}\); and an AND node is wrapped as a single AND node built from the children’s \(\mathrm{toNOr}\) images, enforcing alternation.
For any list of literals \(lits\) and input \(x\), the right fold of \(\& \& \) over the literal evaluations (starting from \(\mathrm{true}\)) equals the term evaluation \(\texttt{Term.eval}\, (lits.\mathrm{map}\, \texttt{Lit.toLiteral})\, x\).
For any list of literals \(lits\) and input \(x\), the right fold of \(||\) over the literal evaluations (starting from \(\mathrm{false}\)) equals the CNF clause evaluation \(\texttt{CNF.evalClause}\, (lits.\mathrm{map}\, \texttt{Lit.toLiteral})\, x\).
For a literal \(l\) on \(n\) variables and an assignment \(x : \mathrm{Fin}\, n \to \mathbb {F}_2\), the value \(l.\mathrm{eval}\, x\) is \(x_{l.\mathrm{idx}}\) when \(l\) is positive (\(l.\mathrm{sign} = \mathrm{true}\)) and \(\lnot x_{l.\mathrm{idx}}\) when \(l\) is negated.
A normal-form AND circuit on \(n\) variables: either a base clause given by a list of literals whose variable indices are pairwise distinct (a Nodup proof on \(lits.\mathrm{map}\; \mathrm{Lit.idx}\)), or a node that ANDs together a list of normal-form OR circuits. Together with \(\mathrm{NOrCircuit}\) this forms a strictly alternating AND/OR normal form.
If every child \(c\) of an \(\texttt{NAndCircuit}.\mathrm{node}\, cs\) is an OR-clause, then for all \(x\) the circuit evaluation \((\texttt{NAndCircuit}.\mathrm{node}\, cs).\mathrm{eval}\, x\) equals the CNF evaluation \(\texttt{CNF.eval}\, ((\texttt{NAndCircuit}.\mathrm{node}\, cs).\mathrm{toCNF})\, x\).
If every child \(c\) of an \(\texttt{NOrCircuit}.\mathrm{node}\, cs\) is an AND-clause, then for all \(x\) the circuit evaluation \((\texttt{NOrCircuit}.\mathrm{node}\, cs).\mathrm{eval}\, x\) equals the DNF evaluation \(\texttt{DNF.eval}\, ((\texttt{NOrCircuit}.\mathrm{node}\, cs).\mathrm{toDNF})\, x\).
The Walsh–Fourier character associated to \(S\subseteq [n]\) is
The family \(\{ \chi _S\} _{S\subseteq [n]}\) forms an orthonormal basis for \(L^2(\{ 0,1\} ^n,\mathrm{uniform})\).
Let \(P\) be a probability measure on \(\{ 0,1\} ^n\) that assigns the uniform weight to each singleton. Then for any Boolean function \(f\) and \(p\in \mathbb {N}\), the \(p\)-th moment of \(f\) under \(P\) equals the uniform expectation of \(f^p\):
The noise operator \(T_\rho \) with parameter \(\rho \in [-1,1]\), defined via the Fourier domain by
Probabilistically, \(T_\rho f(x) = \mathbb {E}_y[f(y)]\) where each bit of \(y\) agrees with \(x_i\) with probability \(\tfrac {1+\rho }{2}\) and is flipped with probability \(\tfrac {1-\rho }{2}\), independently.
For a non-empty \(S \subseteq [n]\), the uniform expectation of the character \(\chi _S\) factorises over the coordinates of \(S\):
Let \(f, g : \{ 0,1\} ^n \to \mathbb {R}\), let \(S \subseteq [n]\), assume the Fubini interchange for the convolution coefficient, and let \(y \in \{ 0,1\} ^n\). Then translating the argument of \(g\) by \(y\) only multiplies the character-weighted sum by \(\chi _S(y)\):
For all \(f, g : \{ 0,1\} ^n \to \mathbb {R}\) and \(S \subseteq [n]\), the double sum defining the unnormalised convolution coefficient may be reordered:
For all \(x, y \in \{ 0,1\} ^n\) and \(S \subseteq [n]\),
expressing that \(\chi _S\) is a character of the group \((\mathbb {F}_2)^n\). The statement also carries the (unused) Fubini hypothesis of the enclosing proof.
The partial inverse \(\mathrm{PM1ToBool?} : \mathbb {R} \to \mathrm{Option}\, \mathrm{Bool}\) returns \(\mathtt{some}\, \mathtt{true}\) on \(-1\), \(\mathtt{some}\, \mathtt{false}\) on \(1\), and \(\mathtt{none}\) on all other real numbers.
Let \(x \in \{ 0,1\} ^n\) with \(x \ne \mathbf{0}\) and let \(i\) be a coordinate with \(x_i = \mathtt{true}\). Then the sum of all characters at \(x\) equals the sum of their negations:
For a function \(f\), an index \(k \le n\), and assignments \(acc, x\) agreeing on all coordinates below \(k\) (i.e. \(acc\, i = x\, i\) whenever \(i.\mathrm{val} \lt k\)), the complete decision tree \(\mathrm{buildFullDTree}\, f\, k\, acc\) evaluates to \(f\, x\) on \(x\).
An orientation is a choice, independently for each edge, of one of its two directions; with \(\varepsilon \) edges and two choices each the product rule gives \(2^\varepsilon \). These are labelled objects: two orientations differing only by a symmetry of \(G\) still count separately.
Step 1 is the whole exercise and the Sym2 bookkeeping is the only fiddly part — the natural first move is to prove a helper turning IsOrientationOf into "for each edge, exactly one of the two directions".
For natural numbers \(n, m \gt 0\) and reals \(\mathrm{val}_f, \mathrm{val}_{f_{L,R}}\), if
then
This is the normalised form of the Cauchy–Schwarz step relating the value of the \(3\)-XOR polynomial \(f_b\) to the value of the derived \(4\)-XOR polynomial \(f_{L,R}\).
Let \((\Omega ,\mu )\) be a probability space, \(k\gt 0\), and let \(Y:\Omega \to \mathbb {R}\) be measurable with \(Y_*\mu = N(0,1/k)\). For every \(t\in \mathbb {R}\) with \(|t|\le k/4\), the map \(\omega \mapsto \exp \bigl(t(Y(\omega )^2-1/k)\bigr)\) is \(\mu \)-integrable and
The proof combines the Gaussian quadratic MGF closed form (integral_exp_mul_sq_gaussianReal_zero) with the Taylor inequality (neg_log_one_sub_two_mul_le_two_sq) applied at \(s := t/k\).
Let \(Y_1,\dots ,Y_k:\Omega \to \mathbb {R}\) be i.i.d. with law \(N(0,1/k)\) under a probability measure \(\mu \), and let \(0\lt \varepsilon \lt 1\). Then
The proof applies the Bernstein tail bound to the i.i.d. sum of centered chi-squared summands, using hasBernsteinMGF_centered_chi_squared and the generic sum and tail-bound lemmas from the Bernstein framework.
(Chvátal and Komlós). Let \(D\) be a digraph with \(\chi \gt mn\), and let \(f\) be a real-valued function on \(V\). Then \(D\) has either a directed path \((u_{0}, \dots , u_m)\) with \(f(u_{0}) \le f(u_{1}) \le \dots \le f(u_m)\), or a directed path \((v_{0}, \dots , v_n)\) with \(f(v_{0}) \gt f(v_{1}) \gt \dots \gt f(v_n)\).*
Theorem 10.1 says a high chromatic number forces a long directed path; this refines it by controlling how \(f\) behaves along that path. A large enough chromatic number forces a monotone directed path — weakly increasing of length \(m\), or strictly decreasing of length \(n\). Part (b) reads off Erdős–Szekeres.
Paths are List V with two IsChains — one for adjacency, one for the \(f\)-comparison — plus Nodup, rather than Quiver.Paths, so that the monotonicity condition can be stated alongside. Note the asymmetry \(\le \) versus \(\gt \) is the book’s and is essential: with two weak orders step 3 would fail on an arc where \(f u = f w\).
(Chvátal and Lovász, 1974). *A loopless digraph \(D\) has an independent set \(S\) such that each vertex of \(D\) not in \(S\) is reachable from a vertex in \(S\) by a directed path of length at most two.*
Such a set is called a semi-kernel. The independence requirement is what makes it non-trivial — one wants mutually non-adjacent "dominators" from which everything else is within two steps. Corollary 10.2 is the tournament case, where independence forces \(|S| = 1\).
The \(u = v\) disjunct in the goal covers the reflexive case and is not in the book, which says "each vertex not in \(S\)"; it is harmless and makes the statement easier to instantiate. hloop : Irreflexive D.Adj is B&M’s "loopless". IsIndepSet is taken in toSimpleGraphInclusive, matching "independent set" for the underlying graph.
Converts a CNF \(\psi \) to its De Morgan dual DNF by negating every literal, so each clause (a disjunction) becomes a term (a conjunction) of negated literals: \(\lnot \bigl(\bigwedge _i \bigvee _j l_{ij}\bigr) = \bigvee _i \bigl(\bigwedge _j \lnot l_{ij}\bigr)\).
For naturals \(n\) and \(d\), \(A(n,d)\) is the supremum of the cardinalities \(k\) for which there is a finite set \(C\) of binary codewords \(\mathrm{Fin}\, n \to \mathrm{Bool}\) with \(|C| = k\) and such that any two distinct \(x, y \in C\) differ in at least \(d\) coordinates.
Assume \(n \gt 0\), \(1 \le d\) and \(2d \le n\). If \(C\) is a finite set of binary words of length \(n\) whose distinct elements are at Hamming distance at least \(d\), whose weights are all at most \(w\), and if \(w \le J_2(n,d)\), then \(\left\lvert C\right\rvert \le 2n\).
Let \(n \gt 0\) and let \(C\) be a finite set of binary words of length \(n\) with pairwise Hamming distance at least \(d\) and all weights at most \(w\). If \(\alpha \ge 0\) is such that \(\hat{x}^\alpha \neq 0\) for all \(x \in C\) and \((n - 2d) + \alpha ^2 n + 2\alpha (2w - n) \le 0\), then \(\left\lvert C\right\rvert \le 2n\).
Let \(V\) be a real inner product space, \(u \in V\) a unit vector, and \(x,y \in V\) with \(\langle x,u\rangle \le 0\), \(\langle y,u\rangle \le 0\) and \(\langle x,y\rangle \le 0\). Then the components of \(x\) and \(y\) orthogonal to \(u\) satisfy \(\langle x - \langle x,u\rangle u,\ y - \langle y,u\rangle u\rangle \le 0\).
For all \(\alpha \in \mathbb {R}\) and binary words \(x,y\),
Given a unit vector \(u\), this packages the normalized projection \(\lVert \mathrm{orthProj}(u,v)\rVert ^{-1}\mathrm{orthProj}(u,v)\) together with its membership proof as an element of the subspace \((\mathrm{span}_{\mathbb {R}}\{ u\} )^{\perp }\).
Let \(u,v,w\) be unit vectors with \(\langle v,u\rangle \le 0\), \(\langle w,u\rangle \le 0\), \(\langle v,w\rangle \le 0\), with \(v,w \notin \{ u,-u\} \) and \(v \neq w\). Then the normalized projections \(\lVert \mathrm{orthProj}(u,v)\rVert ^{-1}\mathrm{orthProj}(u,v)\) and \(\lVert \mathrm{orthProj}(u,w)\rVert ^{-1}\mathrm{orthProj}(u,w)\) cannot be equal (the statement derives a contradiction from their equality).
Under \(\lVert u\rVert = 1\), \(\langle v,w\rangle \le 0\), \(\langle v,u\rangle \le 0\) and \(\langle w,u\rangle \le 0\) (with both projections nonzero), the normalized projections of \(v\) and \(w\) also have non-positive inner product.
For any two \(n\)-bit strings \(x\) and \(y\), the agreement count satisfies
as an equality of integers (after casting the natural numbers to \(\mathbb {Z}\)).
Given two \(n\)-bit strings \(x, y : \mathrm{Fin}\, n \to \mathrm{Bool}\), their signed inner product is the integer
Each coordinate where \(x\) and \(y\) agree contributes \(+1\), and each disagreeing coordinate contributes \(-1\).
For any \(n\)-bit strings \(x\) and \(y\) and any \(a : \mathbb {N}\),
Repeating both inputs \(a\) times multiplies the signed inner product by \(a\).
For strings \(x_1, y_1 : \mathrm{Fin}\, m \to \mathrm{Bool}\) and \(x_2, y_2 : \mathrm{Fin}\, n \to \mathrm{Bool}\),
Concatenating both pairs of bit strings adds their signed inner products.
If \(m = n\) and \(x, y : \mathrm{Fin}\, n \to \mathrm{Bool}\), then
Reindexing both inputs along a \(\mathrm{Fin.cast}\) does not change the signed inner product.
For any two \(n\)-bit strings \(x\) and \(y\),
That is, the signed inner product equals the number of agreeing coordinates minus the number of disagreeing coordinates.
For all \(a, b : \mathrm{Bool}\),
In other words, the product of two \(\pm 1\) signs equals \(1\) when the bits agree and \(-1\) when they disagree.
For a finite type \(\alpha \), a finite set \(s : \mathrm{Finset}\, \alpha \), and a function \(f : \alpha \to \mathrm{Bool}\),
For all \(a, b : \mathrm{Bool}\),
That is, \(\texttt{boolSign}\) is a group homomorphism from \((\mathrm{Bool}, \oplus )\) to \((\{ \pm 1\} , \cdot )\).
For a word \(u\), a set \(S\) of positions, and a position \(i\), the support fiber over \(\{ i\} \cup S\) is partitioned by the value chosen at position \(i\):
The density positive integral is \(\mathrm{densityPositiveIntegral}(\mu ,\nu ) := \int _{\mathrm{densityPositiveSet}} (\mathrm{rnDensity}(\mu ,\nu )(x)-1)\, d\nu \), the excess mass of \(\mu \) over \(\nu \) on the region where \(\mu \) dominates.
The deterministic communication complexity of \(f : X \to Y \to \alpha \) is defined as
The infimum is taken over all deterministic protocols \(p\) that compute \(f\), and the result lives in \(\mathrm{ENat}\) to accommodate the case where no finite protocol exists.
For finite, nonempty types \(X\) and \(Y\) and any function \(f : X \to Y \to \alpha \), the deterministic communication complexity satisfies
This bound is achieved by the protocol in which Alice sends her entire input to Bob and Bob then sends his entire input to Alice.
For finite, nonempty types \(X\) and \(\alpha \) and any function \(f : X \to Y \to \alpha \), the deterministic communication complexity satisfies
This bound is achieved by the protocol in which Alice sends her input \(x\) to Bob, and Bob computes and sends back the output \(f(x, y)\).
For finite, nonempty types \(Y\) and \(\alpha \) and any function \(f : X \to Y \to \alpha \), the deterministic communication complexity satisfies
This bound is achieved by the protocol in which Bob sends his input \(y\) to Alice, and Alice computes and sends back the output \(f(x, y)\).
For \(f : X \to Y \to \alpha \) and \(n : \mathbb {N}\), we have \(D(f) \le n\) if and only if there exists a protocol \(p : \mathrm{Protocol}\; X\; Y\; \alpha \) such that \(p\) computes \(f\) and \(p.\mathrm{complexity} \le n\).
For \(f : X \to Y \to \alpha \) and \(n : \mathbb {N}\), we have \(D(f) \le n\) if and only if there exists a finite-message protocol \(p : \mathrm{FiniteMessage.Protocol}\; X\; Y\; \alpha \) such that \(p.\mathrm{run} = f\) and \(p.\mathrm{complexity} \le n\). This equivalence follows from the mutual simulation between general protocols and their finite-message counterparts.
A generalized deterministic two-party communication protocol over input types \(X\), \(Y\) and output type \(\alpha \). At each step a player sends an element of an arbitrary finite nonempty type \(\beta \): the alice constructor takes a function \(f : X \to \beta \) and a continuation \(P : \beta \to \mathrm{Protocol}\, X\, Y\, \alpha \), and dually for bob. The output constructor terminates the protocol with a value in \(\alpha \). This inductive type is equivalent to the binary Deterministic.Protocol up to complexity, where a \(\beta \)-valued message costs \(\lceil \log _2 |\beta | \rceil \) bits.
Given a protocol \(p : \mathrm{Protocol}\, X\, Y\, \alpha \) and a continuation \(q : \alpha \to \mathrm{Protocol}\, X\, Y\, \beta \), bind \(p\) \(q\) sequentially composes them: each output leaf \(a\) of \(p\) is replaced by the sub-protocol \(q\, a\), giving a protocol of type \(\mathrm{Protocol}\, X\, Y\, \beta \).
Given maps \(f_X : X' \to X\) and \(f_Y : Y' \to Y\), the pullback \(p.\mathrm{comap}\, f_X\, f_Y\) is the finite-message protocol over \(X'\), \(Y'\) obtained by precomposing every message function with \(f_X\) or \(f_Y\) respectively, leaving the protocol tree structure unchanged.
An auxiliary construction: given \(d\) binary query functions \(\mathrm{query}_i : X \to \mathrm{Bool}\) and a family of binary protocols \(Q : (\mathrm{Fin}\, d \to \mathrm{Bool}) \to \mathrm{Protocol}\, X\, Y\, \alpha \), builds a single binary protocol that reads each query bit from Alice in sequence and then runs \(Q\) on the collected bit pattern.
The complexity of completeTreeAlice equals \(d\) plus the supremum of the complexities of all leaf protocols: \((\mathrm{completeTreeAlice}\, d\, \mathrm{query}\, Q).\mathrm{complexity} = d + \sup _{\mathrm{bits}} (Q\, \mathrm{bits}).\mathrm{complexity}\).
For all inputs \(x : X\) and \(y : Y\), executing completeTreeAlice gives the same output as running \(Q\) applied to the bit pattern \(i \mapsto \mathrm{query}_i(x)\), i.e. \((\mathrm{completeTreeAlice}\, d\, \mathrm{query}\, Q).\mathrm{run}\, x\, y = (Q\, (\lambda i,\, \mathrm{query}_i\, x)).\mathrm{run}\, x\, y\).
The worst-case communication cost of a finite-message protocol, measured in bits. An output node costs \(0\); an alice or bob node with message type \(\beta \) costs \(\lceil \log _2 |\beta | \rceil \) plus the maximum complexity over all continuations, i.e. \(\lceil \log _2 |\beta | \rceil + \sup _{b \in \beta } \mathrm{complexity}(P\, b)\).
Given a finite nonempty type \(\beta \), a function \(f : X \to \beta \), and a family of binary protocols \(Q : \beta \to \mathrm{Protocol}\, X\, Y\, \alpha \), there exists a binary protocol \(R\) such that \(R.\mathrm{run}\, x\, y = (Q(f(x))).\mathrm{run}\, x\, y\) for all \(x,y\), and whose complexity satisfies \(R.\mathrm{complexity} = \lceil \log _2 |\beta | \rceil + \sup _{b \in \beta }(Q\, b).\mathrm{complexity}\), constructed via a complete binary tree encoding of \(\beta \).
For any finite nonempty type \(\iota \), function \(f : \iota \to \mathbb {N}\), and constant \(c \in \mathbb {N}\),
This is a technical arithmetic lemma used in complexity calculations.
Given a function \(g : \alpha \to \beta \) and a protocol \(p : \mathrm{Protocol}\, X\, Y\, \alpha \), CommunicationComplexity.Deterministic.FiniteMessage.Protocol.map \(g\) \(p\) is the protocol that runs \(p\) and then applies \(g\) to the output, yielding a protocol of type \(\mathrm{Protocol}\, X\, Y\, \beta \) with the same communication structure as \(p\).
Embeds a binary protocol into the generalized finite-message framework by treating each Boolean message as an element of \(\beta = \mathrm{Bool}\), giving a CommunicationComplexity.Deterministic.Protocol \(X\, Y\, \alpha \) with the same tree structure.
For every binary protocol \(p\), there exists a finite-message protocol \(P\) with \(P.\mathrm{run} = p.\mathrm{run}\) and \(P.\mathrm{complexity} = p.\mathrm{complexity}\). Together with toProtocol_exists, this shows the two models are equivalent up to complexity.
Given a family of protocols \(p_i : \mathrm{Protocol}\, X_i\, Y_i\, \alpha _i\) for \(i \in \mathrm{Fin}\, k\), pi \(p\) is the protocol of type \(\mathrm{Protocol}\, (\Pi _i\, X_i)\, (\Pi _i\, Y_i)\, (\Pi _i\, \alpha _i)\) that runs each \(p_i\) on the \(i\)-th components and collects all outputs into a tuple. It is defined by induction on \(k\), using bind, comap, and map.
Given \(p_1 : \mathrm{Protocol}\, X_1\, Y_1\, \alpha _1\) and \(p_2 : \mathrm{Protocol}\, X_2\, Y_2\, \alpha _2\), their product \(p_1.\texttt{prod}\; p_2 : \mathrm{Protocol}\, (X_1 \times X_2)\, (Y_1 \times Y_2)\, (\alpha _1 \times \alpha _2)\) runs \(p_1\) on the first components and \(p_2\) on the second components, pairing the outputs.
Given a finite-message protocol \(p\) and inputs \(x : X\), \(y : Y\), run executes \(p\) recursively: at an alice node it evaluates \(f(x)\) and follows the corresponding continuation, at a bob node it evaluates \(f(y)\), and at an output node it returns the stored value.
Given a deterministic finite-message protocol \(p\), the operation CommunicationComplexity.Deterministic.FiniteMessage.Protocol.toPrivateCoin converts it into a private-coin finite-message protocol over arbitrary coin spaces \(\Omega _X\) and \(\Omega _Y\) by ignoring both coin inputs (via comap with \(\mathrm{Prod.snd}\)).
For any inputs \(x : X\), \(y : Y\) and any coin draws \(\omega _X : \Omega _X\), \(\omega _Y : \Omega _Y\), the randomised run of \(p.\mathrm{toPrivateCoin}\) equals the deterministic run of \(p\): \(\mathrm{rrun}(p.\mathrm{toPrivateCoin})\, x\, y\, \omega _X\, \omega _Y = p.\mathrm{run}\, x\, y\).
A noncomputable function that converts a finite-message protocol \(p\) into a binary protocol CommunicationComplexity.Deterministic.FiniteMessage.Protocol.toProtocol \(p\) with the same run behavior and the same communication complexity, encoding each \(\beta \)-valued message as \(\lceil \log _2 |\beta | \rceil \) bits.
For \(f : X \to Y \to \alpha \) and \(n : \mathbb {N}\), we have \(n \le D(f)\) (in \(\mathbb {N}_\infty \)) if and only if every protocol \(p : \mathrm{Protocol}\; X\; Y\; \alpha \) that computes \(f\) satisfies \(n \le p.\mathrm{complexity}\).
To prove \(\mathrm{CC}(g) \geq n + 1\), it suffices to show that every monochromatic rectangle partition of \(g\) has more than \(2^n\) parts: if every \(\texttt{IsMonoPartition}\, P\, g\) satisfies \(2^n \lt |P|\), then \((n+1) \leq \mathrm{CC}(g)\).
If the one-way communication complexity of \(f : X \to Y \to \alpha \) is at most \(n\), then the (interactive) deterministic communication complexity of \(f\) is at most \(n + \lceil \log _2 |\alpha | \rceil \), with the additive term accounting for Bob’s cost of transmitting the decoded output in the interactive model.
For a Boolean function \(f : X \to Y \to \mathtt{Bool}\), if the one-way complexity of \(f\) is at most \(n\), then the deterministic complexity of \(f\) is at most \(n + 1\); this specializes the general bound using \(\lceil \log _2 |\mathtt{Bool}| \rceil = 1\).
A one-way deterministic communication protocol for inputs \(x \in X\), \(y \in Y\), and output type \(\alpha \) is a structure consisting of a finite, nonempty message codebook Message, Alice’s encoder \(\mathtt{send} : X \to \mathtt{Message}\) that selects a codeword from the codebook based solely on her input, and Bob’s decoder \(\mathtt{decode} : \mathtt{Message} \times Y \to \alpha \) that produces the final output from the received message and his own input.
Given a deterministic one-way protocol \(p\) computing a function \(f : X \to Y \to \alpha \), and a finite probability distribution \(\mu \) on \(X \times Y\), the distributional error of \(p\) with respect to \(\mu \) and \(f\) is the real number
i.e. the \(\mu \)-measure of the set of inputs on which the protocol’s output disagrees with \(f\).
Given a one-way protocol \(p\) with finite output type \(\alpha \), one obtains an interactive finite-message protocol by having Alice send her one-way message and then having Bob encode the decoded output as an index in \(\{ 0,\ldots ,|\alpha |-1\} \) and transmit it.
For any one-way protocol \(p\) and inputs \((x, y)\), running \(p\)’s embedding in the finite-message model yields the same output as running \(p\) directly: \(\mathtt{FiniteMessage.Protocol.run}(p.\mathtt{toFiniteMessage},\, x,\, y) = p.\mathtt{run}(x, y)\).
A deterministic two-party communication protocol over input types \(X\) (Alice) and \(Y\) (Bob) producing a value of type \(\alpha \) is an inductive type with three constructors: an output node carrying the final value, an alice node in which Alice applies a function \(f : X \to \mathrm{Bool}\) to her input and branches on the resulting bit, and a bob node in which Bob does the same with a function \(g : Y \to \mathrm{Bool}\).
For any alice-rooted protocol \(\texttt{alice}\; f\; P\) over \(X \times Y\), there exists a protocol \(q\) over \(Y \times X\) such that \(q.\texttt{run}\; y\; x = (\texttt{alice}\; f\; P).\texttt{run}\; x\; y\) for all \(x, y\), and \(q.\texttt{complexity} = (\texttt{alice}\; f\; P).\texttt{complexity}\). This allows reducing the bob case to the alice case in inductive arguments.
Given a protocol \(p\) with \(3 \cdot p.\mathrm{numLeaves} \ge 2n\) and \(n \gt 1\), there exists a subprotocol \(s\) of \(p\) satisfying \(n \le 3 \cdot s.\mathrm{numLeaves} \lt 2n\). This is the inductive step used to prove the balanced subprotocol theorem.
If a protocol \(p\) has more than one leaf (i.e. \(p.\mathrm{numLeaves} \gt 1\)), then there exists a subprotocol \(s\) of \(p\) satisfying
In other words, \(s\) contains between one-third and two-thirds of \(p\)’s leaves.
For any bob-rooted protocol \(\texttt{bob}\; g\; P\) over \(X \times Y\), there exists a protocol \(q\) over \(Y \times X\) such that \(q.\texttt{run}\; y\; x = (\texttt{bob}\; g\; P).\texttt{run}\; x\; y\) for all \(x, y\), and \(q.\texttt{complexity} = (\texttt{bob}\; g\; P).\texttt{complexity}\). This allows reducing the alice case to the bob case in inductive arguments.
Given functions \(f_X : X' \to X\) and \(f_Y : Y' \to Y\), comap pulls back a protocol \(p\) over \(X \times Y\) to a protocol over \(X' \times Y'\) by pre-composing every message function with \(f_X\) or \(f_Y\) as appropriate, leaving output nodes unchanged.
The communication complexity of a protocol \(p\) is the worst-case total number of bits exchanged: an output node costs \(0\), while an alice or bob node costs \(1\) plus the maximum complexity of the two sub-protocols reached by the bit \(\mathtt{false}\) and the bit \(\mathtt{true}\).
If a protocol \(p\) has exactly one leaf (i.e. \(p.\mathrm{numLeaves} = 1\)), then its communication complexity satisfies \(p.\mathrm{complexity} = 0\). The only protocol with a single leaf is an immediate output node, which requires no communication.
Given a deterministic protocol \(p : \mathrm{Protocol}\, X\, Y\, \alpha \), a finite probability space \(\mu \) on \(X \times Y\), and a target function \(f : X \to Y \to \alpha \), the distributional error \(p.\mathrm{distributionalError}(\mu , f) \in \mathbb {R}\) is the \(\mu \)-probability that the output of \(p\) disagrees with \(f\), i.e. \(\mu \bigl(\{ (x,y) \mid p.\mathrm{run}(x,y) \ne f(x,y)\} \bigr)\).
For every deterministic protocol \(p : \mathrm{Protocol}\; X\; Y\; \alpha \) there exists a protocol \(q\) such that \(q.\mathrm{run} = p.\mathrm{run}\) (i.e. \(q\) computes the same function as \(p\)) and
where \(c(q)\) denotes the communication complexity of \(q\).
The inductive proposition \(\texttt{IsSubprotocol}\; s\; p\) asserts that protocol \(s\) is a rooted subtree of protocol \(p\). It is generated by: reflexivity (\(s\) is a subtree of itself), and three step cases recording that \(s\) is a subtree of one of the two children of an Alice-node or the false-child of a Bob-node, and hence a subtree of the parent.
The leaf rectangles of a protocol \(p : \texttt{Protocol}\, X\, Y\, \alpha \) form the collection \(\texttt{leafRectangles}(p) = \texttt{leafRectanglesAux}(p, X, Y)\), i.e. the set of input rectangles induced by the leaves of \(p\) over the full input space \(X \times Y\).
If \(p\) computes \(g : X \to Y \to \alpha \), then the collection \(\texttt{leafRectangles}(p)\) is a monochromatic rectangle partition of \(X \times Y\) with respect to \(g\): every element is a rectangle, the elements are pairwise disjoint, their union is all of \(X \times Y\), and each element is \(g\)-monochromatic.
For a protocol \(p\) and sets \(A \subseteq X\), \(B \subseteq Y\), \(\texttt{leafRectanglesAux}(p, A, B)\) is the collection of rectangles induced by the leaves of \(p\) when the reachable inputs are constrained to \(A \times B\). It is defined by structural recursion: an output node yields \(\{ A \times B\} \), while Alice (resp. Bob) nodes split \(A\) (resp. \(B\)) according to the branching function and recurse.
Assuming \(\gamma \gt 0\) and \(1 - 2 \cdot p.\mathrm{distributionalError}_\mu (g) \gt 0\), if every rectangle has discrepancy at most \(\gamma \) then
Let \(m, n \in \mathbb {N}\) with \(3m \le 2n\) and \(3(n - m) \le 2n\). Then \(9 \cdot \max (m^2,\, (n-m)^2) \le 4n^2\). This arithmetic inequality captures the key quantitative gain obtained when a split is balanced: neither piece exceeds \(\tfrac {2}{3}\) of the total.
If \(s\) is a subprotocol of \(p\) (i.e. IsSubprotocol \(s\; p\) holds), then the type CommunicationComplexity.Deterministic.Protocol.SubprotocolPath \(s\; p\) is nonempty. That is, every propositional subprotocol embedding has at least one data-carrying path witness.
Given maps \(f_X : X' \to X\) and \(f_Y : Y' \to Y\) and a set \(R \subseteq X \times Y\), \(\texttt{preimageInputSet}(f_X, f_Y, R)\) is the set \(\{ (x', y') \in X' \times Y' \mid (f_X(x'), f_Y(y')) \in R\} \), the pullback of \(R\) along the product map \(f_X \times f_Y\).
If \(R \in \texttt{leafRectanglesAux}(p, A, B)\) and \(f_X : X' \to X\), \(f_Y : Y' \to Y\), then \(\texttt{preimageInputSet}(f_X, f_Y, R) \in \texttt{leafRectanglesAux}(p.\texttt{comap}(f_X, f_Y),\, f_X^{-1}(A),\, f_Y^{-1}(B))\). This is an internal auxiliary result proved by structural induction.
The noncomputable variant of prunePath taking an IsSubprotocol proof: prune hsp hlt applies CommunicationComplexity.Deterministic.Protocol.prunePath to the classically chosen path for hsp, given the strictness condition \(s.\mathrm{numLeaves} \lt p.\mathrm{numLeaves}\).
\(\texttt{reachesPath}\; \texttt{hsp}\; x\; y\) is the proposition that the input pair \((x, y)\) causes protocol \(p\) to reach the subprotocol \(s\) indicated by the path hsp; that is, \(x \in \texttt{reachXPath}\; \texttt{hsp}\) and \(y \in \texttt{reachYPath}\; \texttt{hsp}\).
Given a subprotocol path \(\texttt{hsp} : \texttt{SubprotocolPath}\, s\, p\), the set of input pairs \((x, y) \in X \times Y\) that reach \(s\) along that path is a combinatorial rectangle \(\texttt{reachXPath}(\texttt{hsp}) \times \texttt{reachYPath}(\texttt{hsp})\).
If two input pairs \(xy\) and \(xy'\) produce the same syntactic transcript under \(p\), then they also produce the same protocol output: \(p.\mathrm{transcript}(xy) = p.\mathrm{transcript}(xy')\) implies \(p.\mathrm{run}(xy.1, xy.2) = p.\mathrm{run}(xy'.1, xy'.2)\).
Given a deterministic communication protocol \(p\) over input types \(X\) and \(Y\) with output type \(\alpha \), shape maps \(p\) to its underlying binary tree of type Tree Unit. An output node becomes a leaf (Tree.nil), while an Alice or Bob branching node becomes an internal node (Tree.node) whose two children are the shapes of the two sub-protocols reached by the bit \(\mathtt{false}\) and \(\mathtt{true}\), respectively.
The inductive type \(\texttt{SubprotocolPath}\; s\; p\) is a data-carrying witness that \(s\) is a rooted subtree of \(p\), recording the sequence of left/right choices made from the root of \(p\) down to the root of \(s\). It mirrors the constructors of IsSubprotocol but lives in Type rather than Prop, enabling structural recursion over the path.
For every point \((x,y) \in X \times Y\), the sum over all leaf rectangles \(R\) of \(\mathbf{1}_{R}(x,y) \cdot \mathrm{rectangleSign}(p,R)\) equals \(\sigma (p.\mathrm{run}(x,y))\). This uses the fact that the leaf rectangles form a partition of \(X \times Y\).
If \(R \in \texttt{leafRectanglesAux}(p, A, B)\), then \(\texttt{swapInputSet}(R) \in \texttt{leafRectanglesAux}(p.\texttt{swap}, B, A)\). This is an internal auxiliary result proved by structural induction on the protocol.
Given that \(s\) is a subprotocol of \(p\) and two protocols qIn and qOut, testSubprotocol hsp qIn qOut is a noncomputable protocol that uses two bits of communication to determine whether the input reaches \(s\), then routes to qIn if it does and to qOut otherwise.
For a deterministic protocol \(p\) over input types \(X\) and \(Y\) with output type \(\alpha \), the type \(\mathrm{Transcript}(p)\) records the full message sequence of an execution path: a terminal protocol has a single transcript (unit), while a communication node contributes one Boolean bit together with the transcript of the chosen child protocol.
For a syntactic transcript \(t\) of \(p\), the input set \(\mathrm{inputSet}(t) \subseteq X \times Y\) is the set of all input pairs \((x, y)\) whose execution of \(p\) follows exactly the path described by \(t\). It is defined recursively: for a terminal protocol it is \(X \times Y\), and for a communication node it is the subset of pairs where the current player’s Boolean function matches the bit recorded in \(t\) and the remaining pair belongs to the child transcript’s input set.
Given maps \(f_X : X' \to X\) and \(f_Y : Y' \to Y\) and a syntactic transcript \(t\) of \(p\), transcriptComap \(p\) \(f_X\) \(f_Y\) \(t\) is the corresponding transcript of the pulled-back protocol \(p.\mathrm{comap}(f_X, f_Y)\), obtained by preserving the Boolean message sequence while re-routing through the input maps.
For every protocol \(p\) and input maps \(f_X : X' \to X\), \(f_Y : Y' \to Y\), the map CommunicationComplexity.Deterministic.Protocol.transcriptComap \(p\) \(f_X\) \(f_Y\) from \(\mathrm{Transcript}(p)\) to \(\mathrm{Transcript}(p.\mathrm{comap}(f_X, f_Y))\) is injective.
For every protocol \(p\), maps \(f_X : X' \to X\), \(f_Y : Y' \to Y\), and inputs \(x' \in X'\), \(y' \in Y'\), pulling back the transcript of \(p\) on \((f_X(x'), f_Y(y'))\) equals the transcript of the comapped protocol on \((x', y')\): \(\mathrm{transcriptComap}(p,f_X,f_Y,p.\mathrm{transcript}(f_X(x'),f_Y(y'))) = (p.\mathrm{comap}(f_X,f_Y)).\mathrm{transcript}(x',y')\).
Given a syntactic transcript \(t\) of \(p\), transcriptSwap \(t\) is the corresponding transcript of the swapped protocol \(p.\mathrm{swap}\) (where Alice and Bob exchange roles), obtained by preserving the Boolean message sequence while reinterpreting each node as the opposite player.
For every protocol \(p\) and inputs \(x \in X\), \(y \in Y\), swapping the transcript of \(p\) on \((x, y)\) equals the transcript of the swapped protocol on the reversed pair \((y, x)\): \(\mathrm{transcriptSwap}(p.\mathrm{transcript}(x, y)) = p.\mathrm{swap}.\mathrm{transcript}(y, x)\).
If \(\mathcal{P}\) is a monochromatic rectangle partition of a Boolean function \(f : X \to Y \to \mathrm{Bool}\), then \(\mathrm{rank}(f) \le |\mathcal{P}|\). The proof decomposes \(M_f\) as a sum of the indicator matrices of the \(1\)-coloured rectangles in \(\mathcal{P}\) and applies subadditivity of rank together with the fact that each such rectangle matrix has rank at most \(1\).
For any Boolean function \(f : X \to Y \to \mathrm{Bool}\) (with \(X\) finite and \(Y\) a Fintype),
where \(\mathrm{DC}(f)\) is the deterministic communication complexity of \(f\), taken as an element of \(\mathbb {N}_\infty \).
If \(R \subseteq X \times Y\) is a combinatorial rectangle, i.e. \(R = A \times B\) for some \(A \subseteq X\) and \(B \subseteq Y\), then \(\mathrm{rank}(M_R) \le 1\). This follows because \(M_R\) is an outer product of the indicator vectors of \(A\) and \(B\).
Let \(\mu \) be a finite probability space on \(X \times Y\), let \(g : X \to Y \to \mathrm{Bool}\), and let \(S \subseteq X \times Y\). The discrepancy of \(g\) on \(S\) with respect to \(\mu \) is
where \(\sigma : \mathrm{Bool} \to \{ -1,1\} \) is the sign map CommunicationComplexity.boolSign.
The discrepancy of \(g\) on \(S\) equals the \(\mu \)-probability mass of the set where \(g\) outputs \(\mathrm{false}\) inside \(S\), minus the \(\mu \)-probability mass of the set where \(g\) outputs \(\mathrm{true}\) inside \(S\):
For any \(g : X \to Y \to \mathrm{Bool}\), \(S \subseteq X \times Y\), and point \((x,y) \in X \times Y\), the pointwise integrand \(\mathbf{1}_{S}(x,y)\cdot \sigma (g(x,y))\) equals the indicator of \(\{ (x,y)\in S \mid g(x,y)=\mathrm{false}\} \) minus the indicator of \(\{ (x,y)\in S \mid g(x,y)=\mathrm{true}\} \) evaluated at \((x,y)\).
A typeclass for a measurable space \(\Omega \) that is simultaneously finite (carries a Fintype instance) and discrete (every subset is measurable). It deliberately does not bundle a measure, so that a single type can be equipped with many different measures.
Let \(Z : \Omega \to \alpha \) be a measurable map from a finite measurable space to a finite discrete type, \(\mu \) a finite measure on \(\Omega \), and \(f : \alpha \to \mathbb {R}\). Then
Let \(\Omega \) be a finite measurable space and let \(\mu , \nu \) be finite measures on \(\Omega \). Then
Let \(\Omega \) be a finite measurable space and let \(\mu , \nu \) be finite measures on \(\Omega \). Then
Let \(\Omega \) be a finite measurable space and let \(\mu , \nu \) be probability measures on \(\Omega \). If \(\nu \) has full support (i.e. \(\nu .\mathrm{toPMF}(\omega ) \neq 0\) for all \(\omega \)), then \(D_{\mathrm{KL}}(\mu \, \| \, \nu ) \neq \infty \).
Let \(Z : \Omega \to \alpha \) be a finite-valued random variable on a finite measurable space with finite measure \(\mu \), and let \(S \subseteq \Omega \). Then
This is the law of total probability expressed in real-valued measure notation.
Let \(\Omega \) be a finite measurable space, \(\mu \) a finite measure on it, and \(S \subseteq \Omega \) any set. Then
In other words, a finite measure on a finite measurable space is determined by and recovers as a finite sum over its singleton masses.
Let \(Z : \Omega \to \alpha \) be a function from a finite measurable space to a finite type, \(\mu \) a finite measure on \(\Omega \), and \(P\) a predicate on \(\alpha \). Then
Let \(\Omega \) be a finite measurable space and let \(p, q\) be PMFs on \(\Omega \). Then
Let \(\Omega \) be a finite measurable space and let \(p, q\) be PMFs on \(\Omega \). Then
A typeclass bundling a MeasureSpace structure on \(\Omega \) together with a CommunicationComplexity.FiniteMeasureSpace witness and an IsProbabilityMeasure instance for the canonical volume measure. This makes \(\Omega \) simultaneously a finite discrete measurable space and a probability space.
Let \(\Omega \) be a finite probability space, \(\iota \) a finite index type, and \(f : \Omega \to \mathbb {R}\). For any coordinate \(i \in \iota \), integrating \(\omega _{\bullet } \mapsto f(\omega _i)\) over the product space \((j : \iota ) \to \Omega \) (with the product measure) equals \(\int _\Omega f\).
For a finite probability space \(\Omega \) and \(S \subseteq \Omega \), \(\mathrm{volume}^{\mathbb {R}}(S) = \int _\Omega \mathbf{1}_S(\omega )\, d\omega \), where \(\mathbf{1}_S\) denotes the indicator of \(S\) as an element of \(\Omega \to \mathbb {R}\).
If \((A_i)_{i \in \iota }\) is a pairwise-disjoint family of sets indexed by a finite type \(\iota \) in a finite probability space \(\Omega \), then
For a finite index type \(\iota \), finite probability spaces \(\Omega _i\) for each \(i\), and sets \(s_i \subseteq \Omega _i\),
For a map \(\varphi : \Xi \to \Omega \) from a finite probability space and a finite set \(T \subseteq \Omega \),
For finite probability spaces \(\Omega _1\) and \(\Omega _2\) and sets \(A \subseteq \Omega _1\), \(B \subseteq \Omega _2\),
Given a type \(\Omega \) already equipped with a MeasureSpace, Fintype, DiscreteMeasurableSpace, and IsProbabilityMeasure instance for volume, this helper packages all of those into a CommunicationComplexity.FiniteProbabilitySpace record.
For a finite probability space \(\Omega \), toPMF converts the canonical volume measure to a probability mass function \(\mathrm{PMF}\, \Omega \), assigning to each \(\omega \) the real weight \(\mu (\{ \omega \} )\).
The collection \(\{ (X, X^c) \mid X \subseteq [n]\} \) is a fooling set for \(\mathrm{disjointness}(n)\): every pair \((X, X^c)\) evaluates to \(\mathtt{true}\), and for any monochromatic rectangle \(R\) with \(\mathrm{disjointness} = \mathtt{true}\) that contains two distinct fooling-set pairs, those pairs must coincide.
For \(n \ge 1\), the deterministic communication complexity of \(\mathrm{disjointness}(n)\) is at least \(n + 1\). The proof uses the fooling set of size \(2^n\) together with an additional input \((x_0, y_0)\) with \(x_0 \cap y_0 \ne \emptyset \) to show that any monochromatic partition of the input space into rectangles requires more than \(2^n\) pieces.
Headline theorem: public-coin randomized communication complexity of disjointness is linear at fixed error \(1 / 32\), with a concrete conservative constant. The cutoff is the floor of the real number \(n / 2^{32}\), so the asymptotic constant is stated over the reals.
The hard sample distribution is the product distribution on the independent fields \(T\), \(X_{T}\), \(Y_{T}\), and other. This rectangle form is the most convenient way to compute probabilities of events depending separately on the four fields.
Alice Pinsker/information step under \(D ∧ Y_{T}=false\): the squared one-bit marginal distance has average at most \(γ^{4}\). This is the KL-to-information comparison from the inequality \((2/3) I(X_{T} : M | T, X_{\lt T}, Y_{≥T}, Y_{T}=0, D) ≤ I(X_{T} : M | T, X_{\lt T}, Y_{≥T}, D)\).
Identification of the average Alice one-bit fiber KL with the conditional mutual information under \(Y_{T}=false\). This packages the step \(p(x_{t} | z) = p(x_{t} | z, y_{t}=0) = p(x_{t} | z, y_{t}=0, D)\) coming from independence and the rectangle property of the transcript.
On a good \(Z\) fiber, the conditional protocol-error probability is at least \(1 / 4 - 2 * γ\). If the protocol output on the fiber is true, then the \((true, true)\) special bit-pair witnesses errors; otherwise \((false, false)\) witnesses errors.
Alice-side reweighting: \((2/3) I(X_{T} : M | T, X_{\lt } T, Y_{≥T}, Y_{T}=0, D) ≤ I(X_{T} : M | T, X_{\lt } T, Y_{≥T}, D)\). The factor is \(Pr[Y_{T}=false | D] = 2/3\), and the event \(Y_{T}=false\) is determined by the conditioning variable because \(Y_{≥T}\) contains \(Y_{T}\).
For a natural number \(n\), CommunicationComplexity.Functions.Equality.equality is the Boolean function \(\mathrm{equality}_n : \mathrm{BoolInput}\, n \times \mathrm{BoolInput}\, n \to \mathrm{Bool}\) that returns true if and only if Alice’s input \(x\) equals Bob’s input \(y\).
\(\mathrm{equalityHashProtocol}(n, k)\) is the standard public-coin protocol for equality in which, given a shared random hash \(h \in \mathrm{HashSpace}(n, k)\), Alice sends \(h(x) \in \mathrm{Fin}(2^k)\) and Bob replies with \(\mathtt{decide}(h(y) = h(x))\).
For every \(n \ge 1\),
The key argument is that any monochromatic rectangle that contains a diagonal pair \((x, x)\) must equal the singleton \(\{ (x,x)\} \), so any valid partition of the input matrix into monochromatic rectangles contains at least \(2^n + 1\) pieces, requiring \(n + 1\) bits to index.
If \(\varepsilon \gt 0\) and \(1/2^k \lt \varepsilon \), then the public-coin communication complexity of \(\mathrm{equality}_n\) with error at most \(\varepsilon \) satisfies
The error bound follows from the collision probability of the random hash family.
Let \(\alpha \) be a finite type, \(k \ge 1\), and let \(x \ne y \in \alpha \). For a uniformly random hash function \(h : \alpha \to \mathrm{Fin}\, k\),
That is, \(\mu _{\mathbb {R}}\bigl(\{ h \in \texttt{HashSpace}\, \alpha \, k \mid h(x) = h(y)\} \bigr) \le 1/k\).
For \(x, y : \alpha \) and \(a : \mathrm{Fin}\, k\), \(\texttt{collisionPiece}\, k\, x\, y\, a\) is the set of hash functions \(h \in \texttt{HashSpace}\, \alpha \, k\) satisfying \(h(x) = a\) and \(h(y) = a\), i.e. the subset of the product space where both \(x\) and \(y\) are mapped to the fixed value \(a\). These pieces partition the collision event \(\{ h \mid h(x) = h(y)\} \).
Let \(\alpha \) be a finite type, \(k \ge 1\), \(x \ne y \in \alpha \), and \(a : \mathrm{Fin}\, k\). Under the product measure on \(\texttt{HashSpace}\, \alpha \, k\),
For any \(x, y : \alpha \) and \(k\), the sets \(\texttt{collisionPiece}\, k\, x\, y\, a\) for \(a : \mathrm{Fin}\, k\) are pairwise disjoint: if \(a \ne b\) then \(\texttt{collisionPiece}\, k\, x\, y\, a \cap \texttt{collisionPiece}\, k\, x\, y\, b = \emptyset \).
\(\texttt{HashSpace}\, \alpha \, k\) is the type of all functions \(\alpha \to \mathrm{Fin}\, k\), i.e. the space of hash functions on \(\alpha \) with output range \(\{ 0,\dots ,k-1\} \). Equipped with the product probability measure (uniform over each coordinate), it serves as the ambient probability space for the random-hash argument.
Every combinatorial rectangle \(R \subseteq \mathrm{BoolInput}\, n \times \mathrm{BoolInput}\, n\) has discrepancy at most \(2^{-n/2}\) for the mod-2 inner product function under the uniform distribution:
For all \(x, y, z : \mathrm{BoolInput}\, n\),
The Walsh character for the inner product is multiplicative in its second argument under coordinatewise XOR.
For sets \(A, B \subseteq \mathrm{BoolInput}\, n\), the discrepancy of the rectangle \(A \times B\) for the inner product function equals
\(\mathrm{innerProduct}(n, x, y) : \mathrm{Bool}\) is the mod-2 inner product of two \(n\)-bit vectors \(x\) and \(y\): it returns true exactly when the number of coordinates where both inputs are true is odd, i.e. when \(\bigoplus _{i=1}^{n} (x_i \wedge y_i) = 1\).
For any set \(B \subseteq \mathrm{BoolInput}\, n\),
This is the key second-moment estimate used in the discrepancy bound.
If \(k, n \in \mathbb {N}\) and \(\varepsilon \in \mathbb {R}\) satisfy \(2^k \cdot \sqrt{1/2^n} \lt 1 - 2\varepsilon \), then
providing a public-coin communication complexity lower bound for the inner product function via the discrepancy method.
If \(z : \mathrm{BoolInput}\, n\) has a coordinate \(i\) with \(z_i = \mathtt{true}\), then
This is the orthogonality of Walsh characters for the inner product function.
For all \(y, z : \mathrm{BoolInput}\, n\),
For a finite type \(\alpha \) with decidable equality, a function \(h : \alpha \to \alpha \to \mathbb {R}\), and a scalar \(c \in \mathbb {R}\),
where \([\! [\cdot ]\! ]\) denotes the indicator of the condition.
For finite types \(\alpha \) and \(\beta \) and \(f : \alpha \to \beta \to \mathbb {R}\),
For any \(b : \mathrm{BoolInput}\, n \to \mathbb {R}\),
Let \(\phi : \alpha \to \beta \to \mathbb {R}\) be a family of functions satisfying the orthogonality condition \(\sum _{x:\alpha } \phi (x,y)\, \phi (x,z) = c \cdot [\! [y=z]\! ]\) for a constant \(c\). Then for any weights \(b : \beta \to \mathbb {R}\),
If \(\mu \ll \nu \) and the log-likelihood ratio \(\mathrm{llr}(\mu ,\nu )\) is \(\mu \)-integrable, then
Let \(f : \Omega \to \mathbb {R}\) with \(f \ge 0\), \(\int f\, d\mu = 1\), \(f\) integrable, and \(\mathrm{klFun}(f)\) integrable. Then
Let \(\mu \) be a probability measure, \(X : \Omega \to \mathbb {R}\) and \(t \in \mathbb {R}\). If \(e^{tX}\) is \(\mu \)-integrable, then \(\int e^{t X(x) - \Lambda _\mu (t)}\, d\mu = 1\), where \(\Lambda _\mu (t) = \log \int e^{tX}\, d\mu \) is the cumulant generating function.
Let \(\mu \) be a finite measure and \(g : \Omega \to \mathbb {R}\) measurable, integrable, and mean-zero (\(\int g\, d\mu = 0\)). Then
Given a probability mass function \(p\) on \(\mathrm{Fin}\, m\) and a natural number \(n\), \(\mathrm{cdf}(p, n)\) is the cumulative probability \(\sum _{j \lt n} p(j)\), computed as an extended non-negative real (\(\mathbb {R}_{\ge 0}^\infty \)).
Let \(\iota \) be a type and \(f : \iota \to \mathbb {N}_\infty \) an \(\mathbb {N}_\infty \)-valued family. Then \(\inf _{i} f(i) \le n\) if and only if there exists an index \(i\) such that \(f(i) \le n\). Here \(n : \mathbb {N}\) is coerced into \(\mathbb {N}_\infty = \mathrm{ENat}\).
Given a PMF \(p\) on \(\mathrm{Fin}\, m\) (with \(m \ge 1\)) and a value \(x \in \mathbb {R}_{\ge 0}^\infty \), \(\mathrm{invCdf}(p, x)\) is the largest index \(i \in \mathrm{Fin}\, m\) satisfying \(\mathrm{cdf}(p, i) \le x\), i.e. the generalized inverse (quantile) of the CDF.
Let \(p\) be a PMF on \(\mathrm{Fin}\, m\) with \(m \ge 1\), let \(x \lt 1\) in \(\mathbb {R}_{\ge 0}^\infty \), and let \(i \in \mathrm{Fin}\, m\). Then \(\mathrm{invCdf}(p, x) = i\) if and only if \(\mathrm{cdf}(p, i) \le x \lt \mathrm{cdf}(p, i+1)\).
For any two finite probability spaces \(\Omega _X\) and \(\Omega _Y\) and any \(\delta \gt 0\), there exist \(n_X, n_Y \in \mathbb {N}\) and maps \(\varphi _X : \mathrm{CoinTape}(n_X) \to \Omega _X\), \(\varphi _Y : \mathrm{CoinTape}(n_Y) \to \Omega _Y\) such that for every set \(S \subseteq \Omega _X \times \Omega _Y\),
For any finite probability space \(\Omega \) and any \(\delta \gt 0\), there exist \(n \in \mathbb {N}\) and a map \(\varphi : \mathrm{CoinTape}(n) \to \Omega \) such that for every set \(S \subseteq \Omega \),
Given a PMF \(p\) on \(\mathrm{Fin}\, m\) and a positive integer \(n\), the map \(\mathrm{uniformApprox}(p, n) : \mathrm{Fin}\, n \to \mathrm{Fin}\, m\) sends \(j \mapsto \mathrm{invCdf}(p, j/n)\), discretizing the unit interval into \(n\) equally spaced points and mapping each through the quantile function of \(p\).
For any PMF \(p\) on \(\mathrm{Fin}\, m\), positive \(n\), and index \(i \in \mathrm{Fin}\, m\), the empirical frequency with which \(\mathrm{uniformApprox}(p, n)\) outputs \(i\) satisfies
Let \(\alpha \) be a finite type, \(p, q : \alpha \to \mathbb {R}\), and \(g : \alpha \to \mathbb {R}\) with \(0 \le g(a) \le 1\) for all \(a\). If \(\sum _{a \in T} p(a) \le \sum _{a \in T} q(a) + \delta \) for every finite set \(T\), then \(\sum _a p(a)\, g(a) \le \sum _a q(a)\, g(a) + \delta \).
Let \(\Omega \) be a finite measurable space and let \(\mu , \nu \) be finite measures on \(\Omega \) with \(\mu \ll \nu \). Then
where \(\mathrm{llr}(\mu ,\nu ,\omega ) = \log \frac{d\mu }{d\nu }(\omega )\) is the log-likelihood ratio at \(\omega \).
For any two probability measures \(\mu \) and \(\nu \) on \(\Omega \),
where the inequality is in \(\mathbb {R}_{\ge 0}^\infty \) and KL divergence uses natural logarithms.
If \(\mu \ll \nu \) and \(\mathrm{llr}(\mu ,\nu )\) is \(\mu \)-integrable, then
in \(\mathbb {R}_{\ge 0}^\infty \).
The \(\varepsilon \)-error private-coin randomized communication complexity of \(f : X \to Y \to \alpha \) is the extended natural number
i.e. the minimum worst-case number of bits exchanged over all private-coin randomized protocols that compute \(f\) with error at most \(\varepsilon \) on every input.
For any function \(f : X \to Y \to \alpha \) and any error parameter \(\varepsilon \ge 0\), the private-coin communication complexity satisfies
The inequality holds because every deterministic protocol can be viewed as a private-coin protocol with zero error by embedding it via toPrivateCoin.
For any \(n \in \mathbb {N}\), we have \(R_\varepsilon (f) \le n\) if and only if there exist coin-tape sizes \(n_X, n_Y \in \mathbb {N}\) and a protocol \(p : \mathrm{Protocol}(\{ 0,1\} ^{n_X}, \{ 0,1\} ^{n_Y}, X, Y, \alpha )\) such that \(p\) \(\varepsilon \)-approximately computes \(f\) and \(p.\mathrm{complexity} \le n\).
For any \(n \in \mathbb {N}\), \(R_\varepsilon (f) \le n\) if and only if there exist coin-tape sizes \(n_X, n_Y \in \mathbb {N}\) and a finite-message protocol \(p : \mathrm{FiniteMessage.Protocol}(\{ 0,1\} ^{n_X}, \{ 0,1\} ^{n_Y}, X, Y, \alpha )\) such that \(p\) \(\varepsilon \)-approximately computes \(f\) and \(p.\mathrm{complexity} \le n\). This establishes that passing to the finite-message variant does not change the complexity measure.
Let \(\Omega _X\) and \(\Omega _Y\) be finite probability spaces and let \(p : \mathrm{FiniteMessage.Protocol}(\Omega _X, \Omega _Y, X, Y, \alpha )\) be a finite-message protocol that \(\varepsilon '\)-approximately computes \(f\). If \(\varepsilon ' \lt \varepsilon \), then \(R_\varepsilon (f) \le p.\mathrm{complexity}\). This is the key reduction step showing that protocols over arbitrary finite probability spaces witness upper bounds on the private-coin complexity.
If \(\varepsilon ' \le \varepsilon \), then \(R_\varepsilon (f) \le R_{\varepsilon '}(f)\). In other words, the private-coin communication complexity is monotone decreasing in the error parameter: permitting more error can only reduce (or preserve) the required communication.
A private-coin finite-message protocol over input types \(X\), \(Y\) with private randomness types \(\Omega _X\), \(\Omega _Y\) and output type \(\alpha \) is defined as a deterministic finite-message protocol whose effective input for Alice is \(\Omega _X \times X\) and for Bob is \(\Omega _Y \times Y\).
Given a function \(f : X \to \Omega _X \to \beta \) (Alice’s message function depending on her public input and private randomness) and a continuation \(P : \beta \to \mathsf{Protocol}\), constructs a protocol node at which Alice sends a \(\beta \)-valued message and execution branches on it.
A protocol \(p\) \(\varepsilon \)-computes a function \(f : X \to Y \to \alpha \) if for every input pair \((x, y)\),
For any protocol \(p\), function \(f\), and \(\varepsilon \in \mathbb {R}\), \(p.\texttt{ApproxComputes}\, f\, \varepsilon = p.\texttt{ApproxSatisfies}\, (\lambda \, x\, y\, a \Rightarrow a = f\, x\, y)\, \varepsilon \). That is, \(\varepsilon \)-computing \(f\) is exactly \(\varepsilon \)-satisfying the pointwise equality predicate.
A protocol \(p\) \(\varepsilon \)-satisfies a predicate \(Q : X \to Y \to \alpha \to \mathrm{Prop}\) if for every input pair \((x, y)\),
Given a protocol \(p\) with output type \(\alpha \) and a family \(q : \alpha \to \mathrm{Protocol}\; \Omega _X\; \Omega _Y\; X\; Y\; \beta \), CommunicationComplexity.Deterministic.FiniteMessage.Protocol.bind \(p\) \(q\) is the protocol that runs \(p\), observes its output \(a\), and then executes \(q\, a\) on the same inputs using the same randomness spaces.
For all \(x, y, \omega _x, \omega _y\), the randomised run of the bound protocol satisfies
Given a function \(f : Y \to \Omega _Y \to \beta \) (Bob’s message function depending on his public input and private randomness) and a continuation \(P : \beta \to \mathsf{Protocol}\), constructs a protocol node at which Bob sends a \(\beta \)-valued message and execution branches on it.
Given functions \(hX : \Omega _X' \to \Omega _X\) and \(hY : \Omega _Y' \to \Omega _Y\), CommunicationComplexity.PrivateCoin.FiniteMessage.Protocol.comapRandomness \(hX\) \(hY\) \(p\) reindexes the randomness spaces of \(p\), yielding a protocol over \(\Omega _X'\) and \(\Omega _Y'\) that maps coins through \(hX\) and \(hY\) before passing them to \(p\).
Given a function \(g : \alpha \to \beta \) and a private-coin protocol \(p\) over randomness spaces \(\Omega _X, \Omega _Y\) with output type \(\alpha \), map \(g\) \(p\) is the protocol that runs \(p\) and then applies \(g\) to its output, yielding a protocol with output type \(\beta \) and the same communication tree.
For any inputs \(x : X\), \(y : Y\) and random coins \(\omega _x : \Omega _X\), \(\omega _y : \Omega _Y\), the randomised run of the mapped protocol satisfies
For every binary private-coin protocol \(p\), there exists a finite-message protocol \(P\) such that \(P.\texttt{rrun}\, x\, y\, \omega _x\, \omega _y = p.\texttt{rrun}\, x\, y\, \omega _x\, \omega _y\) for all inputs and coins, and \(P.\texttt{complexity} = p.\texttt{complexity}\). The witness is \(P = \texttt{ofProtocol}\, p\).
Given a family of protocols \(p : (i : \mathrm{Fin}\, k) \to \mathrm{Protocol}\; (\Omega _{Xf}\, i)\; (\Omega _{Yf}\, i)\; X\; Y\; (\alpha _f\, i)\) with heterogeneous randomness and output types, pi \(p\) runs all \(k\) protocols in parallel on the same inputs using independent randomness from the product spaces \((\prod _i \Omega _{Xf}\, i,\, \prod _i \Omega _{Yf}\, i)\), returning the tuple of outputs \((i : \mathrm{Fin}\, k) \to \alpha _f\, i\).
Given protocols \(p_1\) and \(p_2\) with potentially distinct randomness spaces \((\Omega _{X_1}, \Omega _{Y_1})\) and \((\Omega _{X_2}, \Omega _{Y_2})\), CommunicationComplexity.Deterministic.FiniteMessage.Protocol.prod \(p_1\) \(p_2\) runs them in parallel on the same inputs using independent randomness drawn from \(\Omega _{X_1} \times \Omega _{X_2}\) and \(\Omega _{Y_1} \times \Omega _{Y_2}\), returning the pair of their outputs in \(\alpha _1 \times \alpha _2\).
For all \(x, y, \omega _x : \Omega _{X_1} \times \Omega _{X_2}, \omega _y : \Omega _{Y_1} \times \Omega _{Y_2}\),
Given a private-coin protocol \(p_1\) and a deterministic protocol \(p_2\), CommunicationComplexity.PrivateCoin.FiniteMessage.Protocol.prodDet \(p_1\) \(p_2\) runs both on the same inputs and pairs their outputs in \(\alpha _1 \times \alpha _2\), with \(p_2\) contributing no additional randomness.
Given a protocol \(p\) over randomness \((\Omega _X, \Omega _Y)\) and a family \(q : \alpha \to \mathrm{Protocol}\; \Omega _X'\; \Omega _Y'\; X\; Y\; \beta \), CommunicationComplexity.PrivateCoin.FiniteMessage.Protocol.rbind \(p\) \(q\) runs \(p\) with the first component of the coin pair, obtains its output \(a\), then runs \(q\, a\) using a fresh, independent second component, yielding a protocol over \((\Omega _X \times \Omega _X', \Omega _Y \times \Omega _Y')\).
For all \(x, y, \omega _x : \Omega _X \times \Omega _X', \omega _y : \Omega _Y \times \Omega _Y'\),
\(\texttt{rrun}\, p\, x\, y\, \omega _x\, \omega _y\) executes the protocol \(p\) on public inputs \(x : X\), \(y : Y\) with Alice’s private coin \(\omega _x : \Omega _X\) and Bob’s private coin \(\omega _y : \Omega _Y\), returning an element of \(\alpha \). It is defined by running the underlying deterministic protocol on the paired inputs \((\omega _x, x)\) and \((\omega _y, y)\).
Given a finite-message private-coin protocol \(p\) over finite probability spaces \(\Omega _X\) and \(\Omega _Y\), and a tolerance \(\delta \gt 0\), \(\mathrm{toCoinTape}(p, \delta )\) produces \(n_X\), \(n_Y\), and a new finite-message protocol over \(\mathrm{CoinTape}(n_X) \times \mathrm{CoinTape}(n_Y)\) obtained by precomposing \(p\) with the inverse-CDF approximating maps \(\varphi _X\) and \(\varphi _Y\).
If a protocol \(p\) approximately satisfies a predicate \(Q\) with error at most \(\varepsilon \), then the coin-tape conversion \(\mathrm{toCoinTape}(p, \delta , h_\delta )\) approximately satisfies \(Q\) with error at most \(\varepsilon + \delta \).
The coin-tape conversion \(\mathrm{toCoinTape}(p, \delta , h_\delta )\) produces a protocol of the same communication complexity as \(p\), i.e. \(\mathrm{toCoinTape}(p, \delta , h_\delta )\mathtt{.snd.snd.complexity} = p\mathtt{.complexity}\).
For any \(n \in \mathbb {N}\), we have \(n \le R_\varepsilon (f)\) (in \(\mathbb {N}_\infty \)) if and only if every private-coin protocol \(p\) over coin tapes of any size that \(\varepsilon \)-approximately computes \(f\) satisfies \(n \le p.\mathrm{complexity}\).
A private-coin protocol with randomness spaces \(\Omega _X\) and \(\Omega _Y\), input spaces \(X\) and \(Y\), and output type \(\alpha \) is defined as a deterministic protocol \(\texttt{Deterministic.Protocol}\; (\Omega _X \times X)\; (\Omega _Y \times Y)\; \alpha \). Alice’s message function receives the pair \((\omega _x, x)\) and Bob’s receives \((\omega _y, y)\), so each player’s coin flip is invisible to the other.
Given a function \(f : X \to \Omega _X \to \mathrm{Bool}\) and a continuation \(P : \mathrm{Bool} \to \mathrm{Protocol}\; \Omega _X\; \Omega _Y\; X\; Y\; \alpha \), constructs the protocol node at which Alice sends the bit \(f\, x\, \omega _x\) and execution continues with \(P(\text{bit})\).
A private-coin protocol \(p\) \(\varepsilon \)-computes a function \(f : X \to Y \to \alpha \) if for every input pair \((x, y)\),
This formalises the standard notion of bounded-error private-coin randomized communication complexity.
For any private-coin protocol \(p\), function \(f : X \to Y \to \alpha \), and error bound \(\varepsilon \in \mathbb {R}\),
In other words, \(\varepsilon \)-computing \(f\) is the same as \(\varepsilon \)-satisfying the equality predicate \(a = f\, x\, y\).
A private-coin protocol \(p\) \(\varepsilon \)-satisfies a predicate \(Q : X \to Y \to \alpha \to \mathrm{Prop}\) if for every input pair \((x, y)\),
where \(\mu \) is the product measure on \(\Omega _X \times \Omega _Y\).
Given a function \(f : Y \to \Omega _Y \to \mathrm{Bool}\) and a continuation \(P : \mathrm{Bool} \to \mathrm{Protocol}\; \Omega _X\; \Omega _Y\; X\; Y\; \alpha \), constructs the protocol node at which Bob sends the bit \(f\, y\, \omega _y\) and execution continues with \(P(\text{bit})\).
\(\texttt{rrun}\; p\; x\; y\; \omega _x\; \omega _y\) executes the private-coin protocol \(p\) on inputs \(x \in X\) and \(y \in Y\) with Alice’s private coin \(\omega _x \in \Omega _X\) and Bob’s private coin \(\omega _y \in \Omega _Y\), returning the output \(\alpha \). It is defined by \(p.\mathrm{run}\, (\omega _x, x)\, (\omega _y, y)\).
For any private-coin protocol \(p\) and any inputs \(x\), \(y\), \(\omega _x\), \(\omega _y\), we have \(p.\mathrm{rrun}\; x\; y\; \omega _x\; \omega _y = p.\mathrm{run}\, (\omega _x, x)\, (\omega _y, y)\). This is a definitional equality used as a simp lemma to unfold the randomized execution to the underlying deterministic run.
The \(\varepsilon \)-error public-coin randomized communication complexity of \(f : X \to Y \to \alpha \) is defined as
the infimum (in \(\mathbb {N}_\infty \)) of the worst-case bit complexity over all public-coin randomized protocols that compute \(f\) with error at most \(\varepsilon \) on every input.
For \(f : X \to Y \to \alpha \), \(\varepsilon \in \mathbb {R}\), and \(m \in \mathbb {N}\), we have \(\mathrm{R}^{\mathrm{pub}}_\varepsilon (f) \le m\) if and only if there exist \(n \in \mathbb {N}\) and a public-coin protocol \(p\) on \(\mathrm{CoinTape}(n)\) such that \(p\) \(\varepsilon \)-approximates \(f\) and \(p.\mathrm{complexity} \le m\).
For \(f : X \to Y \to \alpha \), \(\varepsilon \in \mathbb {R}\), and \(m \in \mathbb {N}\), we have \(\mathrm{R}^{\mathrm{pub}}_\varepsilon (f) \le m\) if and only if there exist \(n \in \mathbb {N}\) and a finite-message public-coin protocol \(p\) on \(\mathrm{CoinTape}(n)\) such that \(p\) \(\varepsilon \)-approximates \(f\) and \(p.\mathrm{complexity} \le m\). This shows that the binary-message and finite-message formulations of public-coin complexity coincide.
Let \(\Omega \) be a finite probability space, \(f : X \to Y \to \alpha \), and \(\varepsilon ' \lt \varepsilon \). If a finite-message public-coin protocol \(p\) over \(\Omega \) computes \(f\) with error at most \(\varepsilon '\), then \(\mathrm{R}^{\mathrm{pub}}_\varepsilon (f) \le p.\mathrm{complexity}\). This allows one to transfer upper bounds from protocols over arbitrary finite probability spaces to the coin-tape formulation.
Public-coin communication complexity is monotone in the error parameter: if \(\varepsilon ' \le \varepsilon \), then \(\mathrm{R}^{\mathrm{pub}}_\varepsilon (f) \le \mathrm{R}^{\mathrm{pub}}_{\varepsilon '}(f)\). Allowing more error can only make computation easier.
Let \(\mu \) be a finite probability space on \(X \times Y\), let \(m \in \mathbb {N}\), and let \(p\) be a public-coin protocol with coin tape of length \(m\). For any \(f : X \to Y \to \alpha \),
obtained by swapping the order of integration via Fubini’s theorem applied to the failure-indicator function.
A public-coin finite-message protocol over shared-randomness space \(\Omega \), private input sets \(X\) and \(Y\), and output type \(\alpha \) is a deterministic finite-message protocol in which Alice’s effective input is \(\Omega \times X\) and Bob’s effective input is \(\Omega \times Y\).
Given a message function \(f : X \to \Omega \to \beta \) and a continuation \(P : \beta \to \mathrm{Protocol}\), this constructs the protocol node in which Alice sends a \(\beta \)-valued message determined by her private input \(x\) and the shared randomness \(\omega \), then continues with \(P\).
For any protocol \(p\), function \(f\), and error bound \(\varepsilon \), \(p.\mathrm{ApproxComputes}\, f\, \varepsilon = p.\mathrm{ApproxSatisfies}\, (\lambda \, x\, y\, a,\; a = f\, x\, y)\, \varepsilon \). Thus approximate computation is a special case of approximate predicate satisfaction.
A protocol \(p\) \(\varepsilon \)-satisfies a predicate \(Q : X \to Y \to \alpha \to \mathrm{Prop}\) if for every input pair \((x, y)\),
Given a protocol \(p : \mathrm{Protocol}\; \Omega \; X\; Y\; \alpha \) and a family \(q : \alpha \to \mathrm{Protocol}\; \Omega \; X\; Y\; \beta \), the protocol \(p.\mathrm{bind}\; q\) replaces each output \(a\) of \(p\) with the protocol \(q\; a\), both sharing the same randomness \(\Omega \).
For any \(p\), \(q\), inputs \(x \in X\), \(y \in Y\), and shared randomness \(\omega \in \Omega \), running the bound protocol satisfies \((p.\mathrm{bind}\; q).\mathrm{rrun}\; x\; y\; \omega = (q\, (p.\mathrm{rrun}\; x\; y\; \omega )).\mathrm{rrun}\; x\; y\; \omega \).
Given a message function \(f : Y \to \Omega \to \beta \) and a continuation \(P : \beta \to \mathrm{Protocol}\), this constructs the protocol node in which Bob sends a \(\beta \)-valued message determined by his private input \(y\) and the shared randomness \(\omega \), then continues with \(P\).
Given \(h : \Omega ' \to \Omega \) and a protocol \(p : \mathrm{Protocol}\; \Omega \; X\; Y\; \alpha \), the protocol \(\mathrm{comapRandomness}\; h\; p\) is a \(\mathrm{Protocol}\; \Omega '\; X\; Y\; \alpha \) that runs \(p\) after pre-composing the shared randomness with \(h\).
For any \(h : \Omega ' \to \Omega \), protocol \(p\), inputs \(x \in X\), \(y \in Y\), and \(\omega \in \Omega '\), running the reindexed protocol satisfies \((\mathrm{comapRandomness}\; h\; p).\mathrm{rrun}\; x\; y\; \omega = p.\mathrm{rrun}\; x\; y\; (h\; \omega )\).
Given finite types \(X\) and \(Y\) and real parameters \(\varepsilon , c\), the number of random samples required for derandomization via Chernoff and union bound is
where \(\lceil \cdot \rceil _{+}\) denotes the natural-number ceiling.
Let \(\Omega \) be a finite probability space, let \(p\) be a public-coin protocol on \(X \times Y\) with output type \(\alpha \), and let \(f : X \to Y \to \alpha \). Suppose \(c \gt 1\) and \(p\) \(\varepsilon \)-computes \(f\) (i.e. for every \((x, y)\), the probability that \(p\) produces an incorrect output is at most \(\varepsilon \)). Then there exist \(t = \texttt{CommunicationComplexity.PublicCoin.FiniteMessage.Protocol.derandomizationSamples}(X, Y, \varepsilon , c)\) random seeds \(\omega _0, \dots , \omega _{t-1} \in \Omega \) such that for every \((x, y)\),
Given a function \(g : \alpha \to \beta \) and a public-coin protocol \(p : \mathrm{Protocol}\; \Omega \; X\; Y\; \alpha \), the protocol \(p.\mathrm{map}\; g\) is a \(\mathrm{Protocol}\; \Omega \; X\; Y\; \beta \) that applies \(g\) to the output of \(p\) after every run, without changing the communication structure.
For any \(g : \alpha \to \beta \), protocol \(p\), inputs \(x \in X\), \(y \in Y\), and randomness \(\omega \in \Omega \), running the mapped protocol satisfies \((p.\mathrm{map}\; g).\mathrm{rrun}\; x\; y\; \omega = g\, (p.\mathrm{rrun}\; x\; y\; \omega )\).
Given a public-coin finite-message protocol \(p\) over a probability space \(\Omega \) that \(\varepsilon \)-computes \(f : X \to Y \to \alpha \), and a constant \(c \gt 1\), the Newman protocol is a private-coin finite-message protocol in which Alice draws a random index \(i\) from \(\mathtt{newmanIndexSpace}\; X\; Y\; \varepsilon \; c\) and sends it to Bob; both players then run the \(i\)-th seed from a fixed table of good randomness values (obtained via a Chernoff and union-bound argument) through the original public-coin protocol deterministically.
If \(p\) is a public-coin finite-message protocol that \(\varepsilon \)-computes \(f\), and \(c \gt 1\), then the Newman protocol \((p.\mathtt{newmanProtocol}\; f\; \varepsilon \; c)\) is a private-coin protocol that \((c \cdot \varepsilon )\)-computes \(f\), i.e. for all inputs \(x \in X\) and \(y \in Y\) the probability that the protocol’s output differs from \(f(x, y)\) is at most \(c \cdot \varepsilon \).
If \(p\) is a public-coin finite-message protocol that \(\varepsilon \)-computes \(f\), and \(c \gt 1\), then the communication complexity of the Newman protocol equals \(\lceil \log _2(\mathtt{derandomizationSamples}\; X\; Y\; \varepsilon \; c) \rceil + p.\mathtt{complexity}\), i.e. the original complexity plus the number of bits needed to index the seed table.
For any binary public-coin protocol \(p\), there exists a finite-message protocol \(P\) such that \(P.\mathrm{rrun}\, x\, y\, \omega = p.\mathrm{rrun}\, x\, y\, \omega \) for all \(x\), \(y\), \(\omega \), and \(P.\mathrm{complexity} = p.\mathrm{complexity}\).
Given a family of protocols \(p : (i : \mathrm{Fin}\; k) \to \mathrm{Protocol}\; (\Omega _i)\; X\; Y\; (\alpha _i)\) with heterogeneous randomness and output types, the \(\pi \)-protocol \(\mathrm{pi}\; p\) is a \(\mathrm{Protocol}\; (\prod _i \Omega _i)\; X\; Y\; (\prod _i \alpha _i)\) that runs each \(p_i\) independently using its own component of the shared randomness tuple.
For a family \(p\), inputs \(x \in X\), \(y \in Y\), and randomness tuple \(\omega : (i : \mathrm{Fin}\; k) \to \Omega _i\), running the \(\pi \)-protocol satisfies \((\mathrm{pi}\; p).\mathrm{rrun}\; x\; y\; \omega = \lambda i,\; (p\; i).\mathrm{rrun}\; x\; y\; (\omega \; i)\).
Let \((\Omega ', \mu )\) be a probability space and let \(Y_0, \dots , Y_{t-1} : \Omega ' \to \mathbb {R}\) be mutually independent, a.e. \([0,1]\)-valued random variables satisfying \(\mathbb {E}[Y_i] \le \varepsilon \) for all \(i\), with \(\varepsilon \ge 0\) and \(c \gt 1\). Then
Given protocols \(p_1 : \mathrm{Protocol}\; \Omega _1\; X\; Y\; \alpha _1\) and \(p_2 : \mathrm{Protocol}\; \Omega _2\; X\; Y\; \alpha _2\), the product protocol \(\mathrm{prod}\; p_1\; p_2\) is a \(\mathrm{Protocol}\; (\Omega _1 \times \Omega _2)\; X\; Y\; (\alpha _1 \times \alpha _2)\) that runs \(p_1\) and \(p_2\) independently on the same inputs, using the first and second components of the shared randomness pair respectively.
For protocols \(p_1\), \(p_2\), inputs \(x \in X\), \(y \in Y\), and randomness \(\omega \in \Omega _1 \times \Omega _2\), running the product satisfies \((\mathrm{prod}\; p_1\; p_2).\mathrm{rrun}\; x\; y\; \omega = (p_1.\mathrm{rrun}\; x\; y\; \omega _1,\; p_2.\mathrm{rrun}\; x\; y\; \omega _2)\).
Given a public-coin protocol \(p_1 : \mathrm{Protocol}\; \Omega \; X\; Y\; \alpha _1\) and a deterministic protocol \(p_2 : \mathrm{Deterministic.FiniteMessage.Protocol}\; X\; Y\; \alpha _2\), the protocol \(\mathrm{prodDet}\; p_1\; p_2\) is a \(\mathrm{Protocol}\; \Omega \; X\; Y\; (\alpha _1 \times \alpha _2)\) that runs both protocols on the same inputs and pairs their outputs, reusing the same randomness \(\Omega \).
For any \(p_1\), \(p_2\), inputs \(x \in X\), \(y \in Y\), and randomness \(\omega \in \Omega \), running the mixed product satisfies \((\mathrm{prodDet}\; p_1\; p_2).\mathrm{rrun}\; x\; y\; \omega = (p_1.\mathrm{rrun}\; x\; y\; \omega ,\; p_2.\mathrm{run}\; x\; y)\).
Given \(p : \mathrm{Protocol}\; \Omega \; X\; Y\; \alpha \) and \(q : \alpha \to \mathrm{Protocol}\; \Omega '\; X\; Y\; \beta \), the protocol \(\mathrm{rbind}\; p\; q\) is a \(\mathrm{Protocol}\; (\Omega \times \Omega ')\; X\; Y\; \beta \) that first runs \(p\) using the \(\Omega \)-component of the shared randomness, then runs \(q\) on the result using the independent \(\Omega '\)-component.
For any \(p\), \(q\), inputs \(x \in X\), \(y \in Y\), and randomness pair \(\omega \in \Omega \times \Omega '\), running the fresh-randomness bound protocol satisfies \((\mathrm{rbind}\; p\; q).\mathrm{rrun}\; x\; y\; \omega = (q\, (p.\mathrm{rrun}\; x\; y\; \omega _1)).\mathrm{rrun}\; x\; y\; \omega _2\).
Given a public-coin finite-message protocol \(p\) over an arbitrary finite probability space \(\Omega \) and a slack \(\delta \gt 0\), this definition produces a natural number \(n\) together with a finite-message protocol over \(\mathrm{CoinTape}(n)\) that approximates \(p\). The construction works by pulling back \(p\) along a measure-approximating map \(\varphi : \mathrm{CoinTape}(n) \to \Omega \) provided by CommunicationComplexity.Internal.single_coin_approx.
Let \(p\) be a public-coin finite-message protocol over a finite probability space \(\Omega \), let \(Q : X \to Y \to \alpha \to \mathrm{Prop}\) be a correctness predicate, and let \(\varepsilon , \delta \gt 0\). If \(p\) approximately satisfies \(Q\) with error at most \(\varepsilon \) (i.e. \(p.\mathrm{ApproxSatisfies}\; Q\; \varepsilon \) holds), then the CoinTape approximation \((p.\mathrm{toCoinTape}\; \delta ).2\) approximately satisfies \(Q\) with error at most \(\varepsilon + \delta \).
For any finite-message protocol \(p\) over a finite probability space \(\Omega \) and any \(\delta \gt 0\), the complexity of the CoinTape approximation \((p.\mathrm{toCoinTape}\; \delta ).2\) equals the complexity of the original protocol \(p\).
Given a public-coin finite-message protocol \(p\) and a fixed randomness sample \(\omega : \Omega \), PublicCoin.FiniteMessage.Protocol.toDeterministic \(p~ \omega \) is the deterministic finite-message protocol obtained by substituting \(\omega \) for the shared randomness (via comap with \(\mathrm{Prod.mk}\, \omega \)).
For any inputs \(x : X\) and \(y : Y\), the deterministic run of \(p.\mathrm{toDeterministic}\, \omega \) equals the randomised run at \(\omega \): \((p.\mathrm{toDeterministic}\, \omega ).\mathrm{run}\, x\, y = p.\mathrm{rrun}\, x\, y\, \omega \).
For \(f : X \to Y \to \alpha \), \(\varepsilon \in \mathbb {R}\), and \(m \in \mathbb {N}\), we have \(m \le \mathrm{R}^{\mathrm{pub}}_\varepsilon (f)\) if and only if every public-coin protocol \(p\) on any \(\mathrm{CoinTape}(n)\) that \(\varepsilon \)-approximates \(f\) satisfies \(m \le p.\mathrm{complexity}\).
Let \(\mu \) be a distribution on \(X \times Y\), let \(g : X \to Y \to \mathrm{Bool}\), and let \(\varepsilon , \gamma \in \mathbb {R}\) and \(n \in \mathbb {N}\). If every combinatorial rectangle \(R\) satisfies \(|\mathrm{disc}_\mu (g,R)| \le \gamma \), and if \(2^n \cdot \gamma \lt 1 - 2\varepsilon \), then \(n \lt \mathrm{CC}(g,\varepsilon )\) (the public-coin \(\varepsilon \)-error communication complexity of \(g\)).
Let \(f : X \to Y \to \alpha \), \(\varepsilon \in \mathbb {R}\), \(n \in \mathbb {N}\), and let \(\mu \) be a finite probability distribution on \(X \times Y\). If every deterministic protocol \(p\) with \(p.\mathrm{complexity} \le n\) satisfies \(p.\mathrm{distributionalError}(\mu , f) \gt \varepsilon \), then the public-coin randomized communication complexity of \(f\) at error \(\varepsilon \) is strictly greater than \(n\). This is one direction of Yao’s minimax principle: a hard distribution for all small deterministic protocols certifies a lower bound on randomized complexity.
Let \(f : X \to Y \to \alpha \) with \(X, Y\) finite, let \(\varepsilon , \varepsilon ' \in \mathbb {R}\) and \(c \gt 1\) satisfy \(c \cdot \varepsilon \lt \varepsilon '\). Then the private-coin communication complexity of \(f\) at error \(\varepsilon '\) is at most the public-coin complexity at error \(\varepsilon \) plus \(\lceil \log _2(\mathtt{derandomizationSamples}\; X\; Y\; \varepsilon \; c) \rceil \):
In particular, switching from public-coin to private-coin randomness costs only \(O(\log (|X| \cdot |Y|) / \varepsilon ^2)\) additional bits.
Given finite input types \(X\) and \(Y\) and parameters \(\varepsilon , c \in \mathbb {R}\), the Newman index space is \(\mathrm{Fin}(\mathtt{derandomizationSamples}\; X\; Y\; \varepsilon \; c)\), i.e. the finite type indexing the table of random seeds that Alice samples from in the Newman reduction.
The \(\varepsilon \)-error one-way public-coin communication complexity of \(f : X \to Y \to \alpha \) is the infimum (in \(\mathbb {N}_\infty \)) of the one-way message cost \(p.\mathrm{cost}\) over all \(n \in \mathbb {N}\) and all protocols \(p\) over the coin-tape space \(\mathrm{CoinTape}(n)\) that \(\varepsilon \)-compute \(f\).
For \(f : X \to Y \to \alpha \), \(\varepsilon \in \mathbb {R}\), and \(m \in \mathbb {N}\), the complexity satisfies \(\mathrm{CC}(f,\varepsilon ) \le m\) if and only if there exist \(n \in \mathbb {N}\) and a protocol \(p\) over \(\mathrm{CoinTape}(n)\) such that \(p\) \(\varepsilon \)-computes \(f\) and \(p.\mathrm{cost} \le m\).
The \(\varepsilon \)-error one-way public-coin communication complexity of \(f\) is monotone non-increasing in \(\varepsilon \): if \(\varepsilon ' \le \varepsilon \) then \(\mathrm{CC}(f,\varepsilon ) \le \mathrm{CC}(f,\varepsilon ')\). Intuitively, a stricter error budget can only demand a larger protocol cost.
Let \(\mu \) be a finite probability measure on \(X \times Y\), let \(p\) be a one-way public-coin protocol with coin tape of length \(m\), and let \(f : X \to Y \to \alpha \). Then
i.e. the order of integration over the coin tape and the input distribution may be exchanged (Fubini’s theorem applied to the \(\{ 0,1\} \)-valued failure indicator).
For \(f : X \to Y \to \alpha \), \(\varepsilon \in \mathbb {R}\), and \(m \in \mathbb {N}\), the complexity satisfies \(m \le \mathrm{CC}(f,\varepsilon )\) (as extended naturals) if and only if every protocol \(p\) over any \(\mathrm{CoinTape}(n)\) that \(\varepsilon \)-computes \(f\) has \(p.\mathrm{cost} \ge m\).
Let \(f : X \to Y \to \alpha \), \(\varepsilon \in \mathbb {R}\), and \(n \in \mathbb {N}\). Suppose there exists a finite joint distribution \(\mu \) on \(X \times Y\) such that every deterministic one-way protocol \(p\) with \(p.\mathrm{cost} \le n\) satisfies \(p.\mathrm{distributionalError}(\mu , f) \gt \varepsilon \). Then the one-way public-coin communication complexity of \(f\) at error \(\varepsilon \) satisfies \(n \lt \mathrm{communicationComplexity}(f, \varepsilon )\). This is one direction of Yao’s minimax principle: a hard input distribution witnesses a lower bound on randomised complexity.
A one-way public-coin protocol over shared randomness type \(\Omega \) and input types \(X\), \(Y\) with output type \(\alpha \) is defined as a deterministic one-way protocol whose Alice-input is \(\Omega \times X\) and whose Bob-input is \(\Omega \times Y\). The shared randomness \(\omega \in \Omega \) is thus treated as a component of both players’ inputs.
A protocol \(p\) \(\varepsilon \)-computes a function \(f : X \to Y \to \alpha \) if for every input pair \((x, y)\) the measure of the set of shared strings on which \(p\) errs is at most \(\varepsilon \):
Given a protocol \(p\), inputs \(x \in X\), \(y \in Y\), and a shared random string \(\omega \in \Omega \), the execution \(\mathrm{rrun}(p, x, y, \omega )\) runs \(p\) on the joint inputs \((\omega , x)\) for Alice and \((\omega , y)\) for Bob, returning the decoded output \(p.\mathrm{decode}(p.\mathrm{send}(\omega , x),\, (\omega , y))\).
Given a one-way public-coin protocol \(p\) over a randomness space \(\Omega \) and a fixed coin outcome \(\omega \in \Omega \), toDeterministic \(p\) \(\omega \) is the deterministic one-way protocol obtained by substituting \(\omega \) for the public randomness: it uses the same message type and sends/decodes by fixing \(\omega \) in \(p\).
For any public-coin protocol \(p\), coin outcome \(\omega \), and inputs \(x \in X\), \(y \in Y\),
That is, running the derandomised protocol on \((x,y)\) agrees with running the randomised protocol on \((x,y)\) with fixed randomness \(\omega \).
A public-coin protocol over shared randomness \(\Omega \), with Alice’s private input in \(X\) and Bob’s in \(Y\) producing an output in \(\alpha \), is a deterministic protocol whose combined input types are \(\Omega \times X\) (for Alice) and \(\Omega \times Y\) (for Bob). In other words, both players observe the same random string \(\omega \in \Omega \) alongside their private inputs.
A public-coin protocol \(p\) \(\varepsilon \)-computes a function \(f : X \to Y \to \alpha \) if for every input pair \((x, y)\),
Here the volume is taken with respect to the measure on \(\Omega \) given by the MeasureSpace instance.
For any public-coin protocol \(p\), function \(f : X \to Y \to \alpha \), and \(\varepsilon \in \mathbb {R}\),
That is, \(\varepsilon \)-computing \(f\) is exactly \(\varepsilon \)-satisfying the pointwise equality predicate \(a = f\, x\, y\).
A public-coin protocol \(p\) \(\varepsilon \)-satisfies a predicate \(Q : X \to Y \to \alpha \to \mathrm{Prop}\) if for every input pair \((x, y)\),
Given a public-coin protocol \(p\), private inputs \(x \in X\), \(y \in Y\), and a shared random string \(\omega \in \Omega \), \(\texttt{rrun}\, p\, x\, y\, \omega \) executes the underlying deterministic protocol on the paired inputs \((\omega , x)\) and \((\omega , y)\) and returns the resulting output.
Given a public-coin protocol \(p\) over randomness space \(\Omega \) and a fixed outcome \(\omega : \Omega \), PublicCoin.Protocol.toDeterministic \(p~ \omega \) is the deterministic protocol obtained by substituting \(\omega \) for the shared randomness (implemented via comap with \(\mathrm{Prod.mk}\, \omega \)).
For any inputs \(x : X\) and \(y : Y\), running the deterministic protocol \((p.\mathrm{toDeterministic}\, \omega )\) on \((x, y)\) yields the same output as running the randomised protocol \(p\) on \((x, y, \omega )\), i.e. \((p.\mathrm{toDeterministic}\, \omega ).\mathrm{run}\, x\, y = p.\mathrm{rrun}\, x\, y\, \omega \).
A set \(S \subseteq X \times Y\) is a fooling set for \(g : X \to Y \to \alpha \) if every monochromatic rectangle with respect to \(g\) contains at most one point of \(S\), i.e., \(S \cap R\) is a subsingleton for every rectangle \(R\) that is monochromatic for \(g\).
A collection \(\mathcal{P}\) of subsets of \(X \times Y\) is a monochromatic rectangle partition for \(g : X \to Y \to \alpha \) if every member of \(\mathcal{P}\) is a rectangle, every member is monochromatic for \(g\), the members cover all of \(X \times Y\), and distinct members are disjoint.
For two probability measures \(\mu \) and \(\nu \) on a measurable space \(\Omega \), the Radon-Nikodym density \(\mathrm{rnDensity}(\mu ,\nu )(x) \in \mathbb {R}\) is the real part of the Radon-Nikodym derivative \(\frac{d\mu }{d\nu }(x)\), obtained by converting the extended non-negative real value \(\mu .\mathrm{rnDeriv}\, \nu \, x\) to a real number via ENNReal.toReal.
Let \(\Omega \) be a finite measurable space, \(\mu \ll \nu \) finite measures, and \(\omega \in \Omega \) with \(\nu \{ \omega \} \neq 0\). Then the real-valued Radon–Nikodym derivative satisfies
Let \(\Omega \) be a finite measurable space, \(\mu \ll \nu \) finite measures, and \(\omega \in \Omega \). Then
Every binary tree \(t\) with more than one leaf has a subtree \(s\) satisfying
where \(\lvert \cdot \rvert \) denotes the leaf count. Equivalently, \(s\) contains at least one third and strictly fewer than two thirds of the total leaves of \(t\).
Let \(t\) be a binary tree and \(n\) a natural number with \(n \gt 1\) and \(3 \cdot \lvert t \rvert \ge 2n\), where \(\lvert t \rvert \) denotes the number of leaves of \(t\). Then there exists a subtree \(s\) of \(t\) such that \(n \le 3\lvert s \rvert \lt 2n\).
TreeIsSubtree s t is an inductively defined proposition asserting that \(s\) is a subtree of \(t\). It has two constructors: reflexivity (\(s\) is a subtree of itself) and a descent rule (\(s\) is a subtree of the left child \(\ell \) of \(\texttt{node}(v,\ell ,r)\), hence a subtree of the whole node; an analogous right rule also exists in the implementation).
The total variation distance between two probability measures \(\mu \) and \(\nu \) on \(\Omega \) is defined as \(\tfrac {1}{2}\) times the total variation norm of the signed measure \(\mu - \nu \), i.e. \(\mathrm{TV}(\mu ,\nu ) = \tfrac {1}{2}\| \mu - \nu \| _{\mathrm{TV}}\).
For probability measures \(\mu _1, \nu _1\) on \(\alpha \) and \(\mu _2, \nu _2\) on \(\beta \) (both finite measurable spaces),
On a finite measurable space \(\Omega \), the supremum form of total variation distance satisfies
If \(\mathrm{KL}(\mu \| \nu ) \ne \infty \), then
providing a real-valued form of Pinsker’s inequality convenient when finiteness of the KL divergence is already known.
Let \(\Omega \) be a nonempty finite discrete type and let \(S \subseteq \Omega \). Under the uniform probability measure on \(\Omega \),
Under the uniform measure on a nonempty finite discrete type \(\Omega \), the real-valued measure of a set \(S\) equals \(|\{ S\} | / |\Omega |\) where \(|\{ S\} |\) denotes the cardinality of the subtype \(\{ \omega : \Omega \mid \omega \in S\} \).
Let \(f, X : \Omega \to \mathbb {R}\) with \(f \ge 0\) and \(\int f\, d\mu = 1\). Under suitable integrability conditions on \(f\), \(X\), and \(e^{tX}\),
For any probability measure \(\mu \) on \(\Omega \), any random matrix \(A\), and any \(\varepsilon \in \mathbb {R}\),
The bad event at \(x=0\) is always empty because \(\varepsilon \cdot 0 \lt |0-0|\) simplifies to \(0 \lt 0\), which is false.
A directed cycle among dicomponents would merge them into one, so contracting always produces an acyclic digraph — which by exercise 10.1.3(b) can be topologically ordered. §10.7 uses exactly this to rank the dicomponents of a non-diconnected tournament in a dominance-preserving order, and exercise 10.2.1 uses it on tournaments.
Step 3 is where Quiver.StronglyConnectedComponent’s defining property is consumed; the useful form is "same component \(\leftrightarrow \) mutually reachable", which should be extracted first. Note the statement quantifies over all base points \(c\), since IsDirectedCycle is stated for closed paths at a given vertex.
Reversing every arrow twice returns each to its original direction, so the converse is an involution. That is what makes it a genuine duality: any statement proved for all digraphs yields its mirror image for free, with in- and outdegrees and the direction of reachability exchanged — as parts (ii), (iii) and (b) then exploit.
The shortest item in the file; a good first fill to shake out the Digraph extensionality API.
An arc pointing into \(v\) in \(D\) points out of \(v\) in the converse, and vice versa. This is the workhorse of the duality: exercise 10.1.5(b) uses it to turn "acyclic \(\Longrightarrow \) \(\delta ^{-} = 0\)" into "acyclic \(\Longrightarrow \) \(\delta ^{+} = 0\)" without repeating the argument.
The open scoped Classical in on this declaration supplies decidability for D.converse.Adj; step 3 is where that shows up.
A directed path from \(u\) to \(v\) in the converse is exactly a directed path from \(v\) to \(u\) in \(D\), read backwards. A useful consequence: diconnection is self-dual — \(D\) is diconnected exactly when \(\breve{D}\) is — since diconnection demands reachability both ways.
This is the one place where defining Reachable as ReflTransGen rather than via Quiver.Path pays off directly: no Quiver instance is in play, so \(D\) and D.converse appear in the same statement without ambiguity.
For a finite set \(S\) and an unordered pair \(e\), the predicate \(\texttt{Crosses}\; S\; e\) holds when some element of \(e\) lies in \(S\) and some element of \(e\) lies outside \(S\). This is a membership-based formulation independent of a choice of representative.
For every finite set \(S\) and unordered pair \(e\), the predicate \(\texttt{Crosses}\; S\; e\) holds if and only if, writing \((x, y)\) for the chosen representative of \(e\), either \(x \in S\) and \(y \notin S\), or \(x \notin S\) and \(y \in S\).
A cycle of the underlying graph, traversed in one of its two directions; some arcs point along the direction of travel and some against it, which is what the sign in \(f_C\) records.
! Defective: this structure is degenerate. It carries only a nonempty list of arcs, with no closed-walk condition and no distinctness condition — the docstring’s "the closed/interior-distinct invariants are elided" understates the cost. As a result any nonempty list of arcs is an ArcCycle, and the derived predicate collapses:
IsArcAcyclic tail head S \(\leftrightarrow \) S = \(\emptyset \)
(for nonempty \(S\), pick \(a \in S\) and take the one-element list \([a]\)). Downstream, theorem 12.2(i) then reads "the columns of \(B | S\) are independent iff \(S = \emptyset \)" — false — and lemma 12.2.1 becomes trivially true for the wrong reason. This is not sorry, which makes it more dangerous: the definition looks honest.
The repair needs three fields beyond arcs and nonempty: closed walk — a vertex sequence verts : List V with verts.length = arcs.length such that consecutive arcs meet head-to-tail, cyclically: for each \(i\), {tail arcs[i], head arcs[i]} = {verts[i], verts[i+1 mod n]} (the set form allows an arc to be traversed against its direction, which is exactly what \(C^{+}\) records); interior distinctness — verts.Nodup; optionally no repeated arc — arcs.Nodup.
! SimpleGraph.Walk.IsCycle genuinely cannot serve, as the note says: the chapter’s digraphs admit loops (tail a = head a) and parallel arcs, which a SimpleGraph cannot express. But that argues for building the structure properly, not for omitting its invariants.
*Let \(B\) be a basis matrix of \(\mathcal{B}\). Then for any \(S \subseteq A\), the columns of \(B | S\) are linearly independent if and only if \(S\) is acyclic.*
The theorem converting a combinatorial question into a linear-algebraic one — and it holds over any field, which is why exercise 12.1.5 is subsumed by stating §12.1 over [Field F].
! Currently false. With ArcCycle degenerate, IsArcAcyclic S \(\leftrightarrow \) S = \(\emptyset \), so the right-hand side says \(S = \emptyset \) while the left is true for any independent column set. Repair ArcCycle first. Step 4 additionally needs cycleCirculation, also sorry-bodied.
*Let \(C\) be a basis matrix of \(\mathcal{C}\). Then for any \(S \subseteq A\), the columns of \(C | S\) are linearly independent if and only if \(S\) contains no bond.*
B&M dispatch this with "a similar argument", but it is genuinely a second theorem rather than a formal symmetry: \(\mathcal{C}\) is defined as a kernel and \(\mathcal{B}\) as a range, so step 2 has no counterpart in part (i).
Step 2 is the whole reason this deserves separate treatment; budget for it rather than expecting the (i) proof to transport.
Put every vertex of \(S\) at voltage \(1\) and every other at \(0\); the drops are \(+1\) on arcs leaving \(S\), \(-1\) on arcs entering, \(0\) on arcs with both ends on one side. These are the elementary potential differences, and they give the bond space its name.
Defined directly by the book’s \(\delta p\) formula with \(p\) the indicator of \(S\), rather than by the three-case rule — that makes membership in \(\mathcal{B}\) immediate and turns the book’s "it can be verified" into rfl. Note the definition takes an arbitrary S : Set V, not a bond, so \(g_B\) exists for any vertex set; the bond condition matters only for the basis claims.
Assign a voltage to every vertex and read off the drop across every wire. Theorem 12.1 identifies \(\mathcal{B}\) as the row space of \(M\) and \(\mathcal{C}\) as its orthogonal complement — the duality organising the whole chapter.
\(\delta p\) is \(M^{T} *_{v} p\), so \(\mathcal{B}\) is the range of that map. ! Note the asymmetry with cycleSpace: \(\mathcal{C}\) is a kernel and \(\mathcal{B}\) a range, which is why theorem 12.2(ii) is a genuinely separate argument rather than a formal dual of (i).
, first half. *Let \(M\) be the incidence matrix of a digraph \(D\). Then \(\mathcal{B}\) is the row space of \(M\).*
The drop across \(a\) is the signed combination of the vertex potentials, with \(m_v\) picking out the sign. So the bond space is exactly the row space of \(M\), and dim \(\mathcal{B}\) = rank M.
Submodule.span F (Set.range M) is the row space, \(M\) being read as a family of rows indexed by \(V\). Step 3’s identity is the only real content and is worth extracting, since theorem 12.1’s second half needs it too.
Send one unit of current round the cycle in the chosen direction; arcs pointing with the flow carry \(+1\), those against it \(-1\), everything else nothing. Conservation holds at every vertex because the cycle enters and leaves each of its vertices exactly once. These are the elementary circulations from which all others are built, and they give the cycle space its name.
! Defective: sorry body. \(f_C\) is an opaque function, so isBasisMatrix_cycleSpace_of_maximalForest — whose rows are these — asserts nothing.
The repair depends on repairing ArcCycle first: once a cycle carries its vertex sequence, \(C^{+}\) is definable (arc \(i\) is in \(C^{+}\) when tail arcs[i] = verts[i], i.e. it is traversed forwards), and
f_C a = if a \(\notin \) arcs then 0 else if a \(\in \) C\(^{+}\) then 1 else -1
! With arcs a List, \(a \in C^{+}\) needs the position, not just membership — an arc could in principle occur twice. Adding arcs.Nodup to ArcCycle removes that ambiguity and is the cleaner route.
Currents that flow round and round without accumulating anywhere. ! Contrast chapter 11, where conservation was imposed only at intermediate vertices; here it holds everywhere, so there is no net source or sink.
The conservation condition (12.1) is packaged as \(M *_{v} f = 0\), i.e. f \(\in \) ker M.mulVecLin — theorem 12.1’s second half is precisely the claim that this repackaging is faithful. Defining \(\mathcal{C}\) as a Submodule directly gives the vector-space structure the book verifies by hand.
, second half. …and \(\mathcal{C}\) is its orthogonal complement.
This duality is the organising idea of the chapter. It gives corollary 12.2’s dimension formula at once, it makes BC’ = 0 in corollary 12.4, and it is the source of the cycle/bond symmetry that, as B&M remark, *finds its proper setting in the theory of matroids*.
! Note this is orthogonality for a possibly degenerate form — over ZMod p a space need not be complementary to its orthogonal, which is exactly what exercise 12.2.4(b) exploits. So "orthogonal complement" here means BilinForm.orthogonal, not "complementary subspace"; do not silently use dim \(\mathcal{B}\) + dim \(\mathcal{C}\) = \(\varepsilon \) in characteristic \(p\).
\(f\) and \(g\) are orthogonal when \(\sum _{a \in A} f(a)g(a) = 0\). For real coefficients this is the usual inner product; but the chapter also needs it over fields of characteristic \(p\) (exercise 12.2.4), where the form is degenerate and a vector can be orthogonal to itself. That degeneracy is precisely why Shank’s result — dim(\(\mathcal{B}\)_F \(\cap \) \(\mathcal{C}\)_F) > 0 iff \(p \mid \tau (G)\) — is possible at all: over \(\mathbb {R}\) the two spaces meet only in zero.
! Not an inner product, and deliberately so. Used with LinearMap.BilinForm.orthogonal, which works over every field — in particular ZMod p — unlike Submodule.orthogonal/\(^{\perp }\), which needs RCLike and would make exercise 12.2.4 unstateable. The four \(mk_{2}\) obligations are bilinearity, all discharged by simp on sums.
The arcs crossing the boundary of \(S\), in either direction. The direction matters for the associated potential difference \(g_B\), which takes \(+1\) on arcs leaving \(S\) and \(-1\) on those entering it — the edge cut is undirected, its potential difference is not.
A Set A, not a Finset, matching IsBond’s quantification over arbitrary S : Set V.
*If \(f\) is a nonzero circulation, then \(\| f\| \) contains a cycle.*
Current cannot enter a dead end: anything that flows must flow round in a loop.
! Currently trivial for the wrong reason. Since ArcCycle has no closure condition, the goal is satisfied by the one-element list \([a]\) for any \(a \in \| f\| \) — so this is provable in two lines and means nothing. Repair ArcCycle before filling; the skeleton above is for the repaired statement.
*If \(g\) is a nonzero potential difference, then \(\| g\| \) contains a bond.*
The exact dual of lemma 12.2.1; the two together drive theorem 12.2.
Step 4 is where IsBond’s minimality is consumed — see that definition’s note about what "minimal among edge cuts" quantifies over.
, formula (12.3). dim \(\mathcal{B}\) = \(\nu \) - \(\omega \).
The bond space records the vertex potentials — \(\nu \) of them — modulo an additive constant on each of the \(\omega \) components, leaving \(\nu - \omega \) degrees of freedom.
! Stated over \(\mathbb {R}\) specifically, unlike the rest of §12.1 which is over a general [Field F]; the dimension count is in fact field-independent, so this could be generalised. Step 3 is the out-of-chapter import to budget for. Note the \(\mathbb {N}\)-subtraction card V - card ConnectedComponent never truncates, since \(\omega \le \nu \).
, formula (12.4). dim \(\mathcal{C}\) = \(\varepsilon \) - \(\nu \) + \(\omega \).
\(\varepsilon - \nu + \omega \) is the cycle rank or first Betti number — the number of independent cycles, and exactly the number of arcs outside a maximal forest. That count is realised concretely by the fundamental cycles, one per non-tree arc.
! B&M derive this from orthogonality (dim \(\mathcal{C}\) = \(\varepsilon \) - dim \(\mathcal{B}\)), which is valid over \(\mathbb {R}\) but not in characteristic \(p\), where the form is degenerate and the two spaces can overlap (exercise 12.2.4(b)). The rank–nullity route of step 1 is field-independent and therefore both simpler and more robust — prefer it.
(H. Shank). *Let \(F\) be a field of characteristic \(p\). Then dim(\(\mathcal{B}\)_F \(\cap \) \(\mathcal{C}\)_F) > 0 if and only if \(p \mid \tau (G)\).*
Over \(\mathbb {R}\) the two spaces are orthogonal complements and meet only in zero. In characteristic \(p\) the dot form is degenerate — a vector can be orthogonal to itself — so they may genuinely overlap, and Shank’s result says the overlap is nontrivial exactly when \(p \mid \tau (G)\). A purely arithmetic property of \(\tau (G)\) detected by a linear-algebraic degeneracy — a striking illustration of the chapter’s theme.
! Step 1 must not be derived from orthogonality (dim \(\mathcal{C}\) = \(\varepsilon \) - dim \(\mathcal{B}\)), which is exactly what fails here; use the rank–nullity argument recorded under finrank_cycleSpace. Getting this wrong would make the proof circular — the whole point is that the two spaces are not complementary.
Deleting \(a\) splits its tree in two, and \(S\) is the vertex set of one half; the arcs crossing between the halves form the fundamental bond. The \(\nu - \omega \) fundamental bonds, one per tree arc, give the tree-basis of the bond space, with \(B | T\) an identity matrix. The exact mirror of the fundamental cycle — theorem 2.6 is to bonds and cotrees as theorem 2.5 is to cycles and spanning trees.
! Defective: sorry body. Makes isBasisMatrix_bondSpace_of_maximalForest vacuous.
The repair: \(S\) is the set of vertices reachable from tail a in \(T \ {a}\) (using the underlying-graph reachability of IsConnectedDigraph’s repair). Then edgeCutSet tail head S is the fundamental bond, and bondPotentialDiff tail head S its potential difference — which is why the definition returns the vertex set rather than the bond, letting bondPotentialDiff be applied directly. ! Leans on B&M’s theorem 2.6, which is out of chapter and not in this repo.
The tree already provides a unique route between the ends of \(a\) (theorem 2.1), and adding \(a\) closes exactly one cycle. The \(\varepsilon - \nu + \omega \) fundamental cycles, one per non-tree arc, give the tree-basis of the cycle space — the matrix \(C\) is a basis matrix because \(C | \bar{T}\) is an identity matrix, so its rank is full.
! Defective: sorry body. An opaque ArcCycle, so isBasisMatrix_cycleSpace_of_maximalForest asserts nothing about it.
The repair. The lever noted in the source comment is right: IsAcyclic.path_unique gives the unique \(T\)-path between \(a\)’s ends, and the cycle is that path closed by \(a\). ! But it is stated for SimpleGraph, while this chapter’s carrier is tail, head : A \(\to \) V with loops and parallel arcs — so either transfer along the underlying graph (losing the multi-arc case) or redo the uniqueness argument on the arc carrier. The hT hypothesis is what makes "unique" true, and \(ha : a \notin T\) what makes the cycle exist.
*The incidence matrix of a simple graph \(G\) is totally unimodular if and only if \(G\) is bipartite.*
! Note this is the unoriented \(0/1\) incidence matrix of §1.3, not the signed one of this chapter — the signed version is always totally unimodular, for every graph. The classical characterisation underlying the integrality of bipartite matching linear programs, and it links back to theorem 1.2: bipartite means no odd cycle.
* Independent of every defective definition in this file — it mentions only SimpleGraph.incMatrix and IsBipartite, both Mathlib. Together with exercise 12.2.2(a), one of the two items that can be filled today. Step 2’s determinant computation is the concrete part.
No cycle of the digraph lies entirely inside \(S\). Theorem 12.2 makes this combinatorial property equivalent to a linear-algebraic one — the bridge that turns counting spanning trees into counting nonsingular submatrices.
! Defective by inheritance. Because ArcCycle has no closure or distinctness conditions, this predicate collapses to \(S = \emptyset \); see ArcCycle’s docstring for the one-line argument and the repair. The definition here is *correct given a correct ArcCycle* — nothing needs changing at this declaration.
Package a basis as the rows of a matrix, so questions about the space become questions about the matrix. This is what lets theorem 12.2 phrase acyclicity as linear independence of columns, and theorem 12.4 count spanning trees by a determinant.
"Rows form a basis" is unfolded into its two halves — LinearIndependent F M and span (range M) = W — rather than using Basis, which would require a chosen index equivalence. The row index \(n\) is a free Fintype, so the same predicate serves matrices indexed by \(T\), by \(T^{c}\), or by \({v // v \ne y}\).
The fundamental bond basis, realising the claim that every potential difference is a combination of bond potential differences.
! Currently vacuous — IsMaximalForest and fundamentalBondVertexSet both have sorry bodies. ! Step 2 also leans on B&M’s theorem 2.6, which is out of chapter and absent from this repo.
The fundamental cycle basis — the concrete realisation of the claim that every circulation is a combination of cycle circulations, which is what gave the cycle space its name.
! Currently vacuous. Three of the four ingredients — IsMaximalForest, fundamentalCycle, cycleCirculation — have sorry bodies.
Its defining feature is that \(B | T\) is an identity matrix — the fundamental bond of \(a\) contains \(a\) itself with coefficient \(1\) and no other tree arc. That is what pins down det(B | T) = 1 in the proof of theorem 12.3, and what makes exercise 12.1.2(b)’s change-of-basis identity readable.
! Defective: sorry body. This predicate is a hypothesis of theorems 12.3, 12.4, corollary 12.4 and exercises 12.2.1(b), 12.2.3(a), 12.2.4(a) — all of which therefore constrain nothing.
The repair: \(B\) is the tree-\(T\) basis matrix when its rows are the fundamental-bond potential differences, i.e.
B = fun a : a // a \(\in \) T => bondPotentialDiff tail head (fundamentalBondVertexSet tail head T a.1)
— exactly the matrix appearing in isBasisMatrix_bondSpace_of_maximalForest. ! Alternatively, characterise it axiomatically as *"a basis matrix of \(\mathcal{B}\) whose restriction \(B | T\) is the identity"*, which is weaker to state, enough for theorem 12.3, and does not depend on fundamentalBondVertexSet — probably the better choice, since it is the property every proof actually uses.
The cycle-side mirror of IsBasisMatrixOfTree: \(C | \bar{T}\) is the identity, because the fundamental cycle of \(a\) is the only one using \(a\).
! Defective: sorry body. Hypothesis of (12.8), corollary 12.4 and exercises 12.2.1(b), 12.2.4(a) — all vacuous as a result.
The repair: as for IsBasisMatrixOfTree, either concretely (rows are the fundamental-cycle circulations) or axiomatically (*a basis matrix of \(\mathcal{C}\) with \(C | \bar{T}\) the identity*). The axiomatic form is again preferable and is what the determinant arguments actually consume.
An edge cut with nothing to spare. Bonds are dual to cycles: lemma 12.2.2 says the support of a nonzero potential difference contains a bond, exactly as lemma 12.2.1 says the support of a nonzero circulation contains a cycle.
! Missing from Mathlib — and beware two false friends. Dart.lean uses "bond" for an unrelated half-edge notion, and the repo’s IsEdgeCut is a cut without the minimality clause, on a different carrier.
! The minimality clause here quantifies over subsets \(B' \subseteq B\) that are themselves edge cuts (\(\exists \) S’, B’ = edgeCutSet S’). That is the right reading of "minimal nonempty edge cut" and is stronger than minimality among arbitrary subsets; check it against use sites, since lemma 12.2.2 only produces an edge cut inside the support and then needs a bond inside that.
A maximal acyclic set of arcs — a spanning tree of each component. Its size \(\nu - \omega \) is exactly the rank of the bond space, which is how corollary 12.2 computes dim \(\mathcal{B}\).
! Defective: sorry body. Makes both tree-basis theorems (isBasisMatrix_cycleSpace_of_maximalForest, isBasisMatrix_bondSpace_of_maximalForest) vacuous, and is a hypothesis of fundamentalCycle.
The repair: IsArcAcyclic tail head T \(\land \) \(\forall \) a \(\notin \) T, \(\lnot \) IsArcAcyclic tail head (insert a T) — acyclic and maximally so. Note this is the forest notion, weaker than IsSpanningTree: it does not require connectivity, which is exactly why corollary 12.2 gets \(\nu - \omega \) rather than \(\nu - 1\).
\(G\) is recovered by forgetting directions. The point of §12.2 is that \(\tau (G)\) is an invariant of \(G\) alone, yet is most easily computed through the oriented incidence matrix of an arbitrarily chosen orientation — the signs cancel in the determinant, which is exactly what exercise 12.2.2(a) makes precise.
! Definitionally equal to IsUnderlyingGraph, so "orientation of \(G\)" here means only "has \(G\) as underlying graph" — it does not forbid \(D\) from having both \((u,v)\) and \((v,u)\), which chapter 10’s IsOrientationOf does. For this chapter that is deliberate and harmless: the results are about \(M\) and MM\(^{T}\), which tolerate digons and loops.
A maximal acyclic set of arcs touching every vertex. By theorem 12.2, spanning trees are exactly the \((\nu -1)\)-element subsets \(S\) for which \(B | S\) is nonsingular — which is what makes §12.2’s determinant formula count them.
! Defective: sorry body — the most damaging one in the file. tau counts the Finsets satisfying this predicate, so \(\tau (G)\) is an opaque natural number, and every §12.2 statement about it is vacuous: theorem 12.4, (12.8), corollary 12.4, the matrix-tree theorem, and exercises 12.2.1(b), 12.2.2(b), 12.2.4(a), (b).
The repair, once ArcCycle is fixed:
IsSpanningTree tail head T := IsArcAcyclic tail head T \(\land \) T.card + 1 = Fintype.card V \(\land \) (the underlying subgraph on T is connected)
or equivalently "acyclic and spanning", using the connectivity notion suggested for IsConnectedDigraph. Acyclic plus \(|T| = \nu - 1\) already forces connectivity for a graph on \(\nu \) vertices, so the middle clause plus acyclicity suffices — but only once IsArcAcyclic is genuine.
\(u\) and \(v\) are adjacent in \(G\) exactly when some arc runs between them in one direction or the other. The chapter’s counting results — dim \(\mathcal{B}\) = \(\nu \) - \(\omega \), dim \(\mathcal{C}\) = \(\varepsilon \) - \(\nu \) + \(\omega \), \(\tau (G)\) — are all statements about this underlying graph, the orientation being an auxiliary device that cancels out.
! A SimpleGraph underlying graph loses information the arc carrier has: loops (tail a = head a) and parallel arcs both vanish. That is harmless for the counting results, which are about \(G\), but means \(G\) does not determine (tail, head) — hence this is a relation, not a function.
(proof due to Tutte, 1965b). *The basis matrix \(B\) is unimodular.*
Exactly what theorem 12.4 needs: every full submatrix contributes \(0\) or a determinant of absolute value \(1\), so squaring and summing counts the spanning trees. The proof is due to Tutte (1965b).
! Currently vacuous — IsSpanningTree and IsBasisMatrixOfTree both have sorry bodies. Note step 4 is where the axiomatic reading of IsBasisMatrixOfTree ("basis matrix with \(B | T\) the identity") would pay off directly.
The chapter is organised around such dual pairs — cycles and bonds, kernels and ranges, trees and cotrees.
! Step 3 needs the cycle-side analogue of exercise 12.1.2(b), which is stated in this file only for \(\mathcal{B}\) (basisMatrix_eq_restrict_mul). The cycle version must be proved separately, and — as noted under theorem 12.2(ii) — the \(\mathcal{C}\)-side arguments are not formal transports of the \(\mathcal{B}\)-side ones.
. A matrix \(K\) obtained from \(M\) by deleting any one row is unimodular.*
The incidence-matrix counterpart of theorem 12.3, and what upgrades exercise 12.1.3 into the matrix-tree theorem \(\tau \)(G) = det KK’. Note it is proved directly, not via theorem 12.3 — \(K\) is not a tree-basis matrix.
! Step 3’s leaf induction is the real work and has no counterpart in theorem 12.3’s slick change-of-basis argument. ! The statement lacks a connectivity hypothesis, unlike isBasisMatrix_deleteRow; step 2 uses that \(K\) is a basis matrix, which does need hconn — so either add it or find a route through step 3 alone.
*The conductance matrix \(C\) of a loopless graph \(G\) satisfies C = MM’, where \(M\) is the incidence matrix of any orientation of \(G\).*
* The cheapest win in the file — a direct computation, no dependency on the defective definitions. This is what Mathlib calls the Laplacian; B&M call it the conductance matrix. Notably the orientation drops out — the signs cancel — so it is an invariant of the undirected graph, as it must be.
Step 3’s parallel-arc caveat is the one thing to pin down before starting; everything else is Finset.sum manipulation.
(implicit in Kirchhoff, 1847). *\(\tau \)(G) = det KK’, where \(K\) is obtained from the incidence matrix \(M\) by deleting any one row.*
The rows of \(M\) sum to zero — every arc contributes \(+1\) at its tail and \(-1\) at its head — so exactly one row is redundant, and discarding it leaves an independent spanning set of \(\mathcal{B}\). By exercise 12.2.2(a) the product MM’ is the
(B&M’s conductance matrix), so this says every cofactor of the Laplacian equals \(\tau (G)\) — the form in which the matrix-tree theorem is usually quoted, and the closed formula for \(\tau (G)\) promised back in §2.4.
! Currently vacuous — tau and IsConnectedDigraph both rest on sorry bodies. Step 3 is a genuine restructuring worth doing before any of §12.2 is filled.
Record, for each vertex and each arc, whether the arc leaves the vertex (\(+1\)), enters it (\(-1\)), or misses it (\(0\)). The signs make this the oriented incidence matrix, distinct from the \(0/1\) matrix of §1.3, and they encode the conservation condition exactly: \(M *_{v} f = 0\) says inflow balances outflow at every vertex.
! Missing from Mathlib: SimpleGraph.incMatrix is the unoriented \(0/1\) matrix, and the oriented version is one of Mathlib’s own open TODOs. B&M’s "if \(a\) is a link" clause (i.e. loops map to \(0\)) is automatic in this encoding: a loop has tail a = head a = v, so the two indicators cancel to \(1 - 1 = 0\). Stated over a general [Ring R] so the same definition serves the \(F\)-valued §12.1 and the \(\mathbb {Z}\)-valued §12.2.
The object §12.2 exists to compute. Theorem 2.8 gave a recursion and theorem 2.9 a closed formula for complete graphs; chapter 12 finally delivers the general determinant formula — the matrix-tree theorem, implicit in Kirchhoff (1847).
! Defective by inheritance. IsSpanningTree has a sorry body, so tau counts an opaque predicate and is itself opaque. This is the single most consequential defect in the file — every §12.2 result is a statement about tau. Nothing here needs changing; repairing IsSpanningTree repairs this.
\(\tau \)(G) = \(\pm \) det [B; C], the determinant of the square matrix obtained by stacking a tree-basis matrix of \(\mathcal{B}\) on top of one of \(\mathcal{C}\).
The stacked matrix is square because dim \(\mathcal{B}\) + dim \(\mathcal{C}\) = (\(\nu \) - \(\omega \)) + (\(\varepsilon \) - \(\nu \) + \(\omega \)) = \(\varepsilon \) — the two spaces are complementary, which is theorem 12.1’s orthogonality counted dimensionally.
The \(\lor \) in the conclusion is the book’s \(\pm \). The row index is \({a // a \in T} \oplus {a // a \notin T}\), reindexed to \(A\) by Equiv.sumCompl — that equiv is canonical here, unlike in exercise 12.2.1(b) where one must be supplied. ! Currently vacuous, resting on tau and both IsBasisMatrixOfTree predicates.
*All cofactors of the conductance matrix \(C\) are equal to \(\tau (G)\).*
The form in which the matrix-tree theorem is normally stated: *the number of spanning trees is any cofactor of the Laplacian*. It finally delivers, in full generality, the closed formula for \(\tau (G)\) that §2.4 promised and that theorem 2.9 gave only for complete graphs.
This states the principal \((y,y)\)-minor, which is what the matrix-tree theorem gives directly and what every application uses. B&M claim all cofactors equal \(\tau (G)\), including the non-principal ones; that full statement is tau_eq_lapMatrix_cofactor directly below, and this principal case is the one to prove first.
\(\tau \)(G) = det BB’ (12.6).
The chapter’s central computation: the number of spanning trees, a purely combinatorial quantity, is a determinant. Compare theorem 2.8’s deletion–contraction recursion, which B&M called impractical for large graphs, and theorem 2.9’s Cayley formula, valid only for complete graphs — this is general and efficiently computable.
! Currently vacuous — tau (via IsSpanningTree) and IsBasisMatrixOfTree both rest on sorry bodies. Step 1 is an additional, substantial import.
The spanning trees can be counted from either space — through the bonds or through the cycles. Corollary 12.4 combines the two computations into one determinant.
! Currently vacuous — tau and IsBasisMatrixOfTree’ both rest on sorry bodies; and Cauchy–Binet is still missing.
, full form. *All cofactors of the conductance matrix \(C\) are equal to \(\tau (G)\).*
tau_eq_det_lapMatrix_deleteRowCol above states only the principal \((y,y)\)-minor. The triage (log/graphtheory-EXERCISE_TRIAGE.md §A.11) recorded this as a fidelity gap and recommended stating the exercise as written. The general form is the one usually cited, because it is what licenses deleting any row and any column — the principal case alone does not.
! Deleting row \(i\) and column \(j\) for \(i \ne j\) leaves a matrix whose row and column index types are the different subtypes \({v // v \ne i}\) and \({v // v \ne j}\), so Matrix.det does not apply to it. A reindexing equiv \(e\) between the two is therefore threaded through explicitly — the same device tau_eq_det_fromBlocks_K uses further down this file for the same reason. Because \(e\) is not canonical it fixes the column order only up to a permutation, so the conclusion is stated up to sign, absorbing \((-1)^(i+j)\) and sign e together. Taking \(i = j\) and e = Equiv.refl recovers the principal case above.
! Currently vacuous via tau and IsConnectedDigraph, exactly as the principal case is.
A vertex is a window of \(n-1\) bits; following an arc shifts the window one place, dropping the leading bit and appending a new one. Each arc therefore corresponds to an \(n\)-bit string — its label — and a directed Euler tour reads off every \(n\)-bit string exactly once, giving a cyclic binary sequence of length \(2^{n}\) in which all \(2^{n}\) windows are distinct.
The application (§10.5). A rotating drum’s surface is divided into \(2^{n}\) insulating or conducting sections, read by \(k\) consecutive contacts. *First note that \(k\) contacts yield a \(k\)-digit binary number, and there are \(2^{k}\) such numbers. Therefore, if all \(2^{n}\) positions are to give different readings, we must have \(2^{k} \ge 2^{n}\), that is, \(k \ge n\)* — and the de Bruijn sequence shows \(n\) contacts suffice. For \(n = 4\) the tour of figure 10.10 gives \(0000111100101101\). Due to Good (1946).
! Missing from Mathlib and the Archive (0 hits). A vertex is a function Fin (n-1) \(\to \) Bool rather than a list, so the shift condition is indexed: p ⟨i+1, _⟩ = q i for every \(i\) with \(i + 1 \lt n - 1\), which is the book’s \(1 \le i \le n-2\) in 0-indexed form. The last coordinate of \(q\) is unconstrained, giving the two out-arcs. \(D_n\) has loops (the all-zeros and all-ones vertices) but no parallel arcs — so it is not strict, which is fine, as no §10.5 statement needs strictness. Arc labels are not modelled: the label is recoverable from the arc, and exists_deBruijn_sequence states the conclusion about the sequence directly.
From any binary string one can reach any other by shifting in the target’s bits one at a time; after \(n - 1\) shifts the window contains exactly the target. Together with the degree balance above, this is the second half of the Euler-tour criterion of exercise 10.3.2.
The explicit walk of step 1 is the whole content; a slick argument is unlikely to be shorter than just writing the \(n - 1\) intermediate vertices down as a function of the step index.
Each arc carries an \(n\)-bit label and the tour uses every arc exactly once, so reading off the first digit of each label in order produces a cyclic binary sequence of length \(2^{n}\) in which all \(2^{n}\) windows of length \(n\) are distinct.
The application. Divide a rotating drum’s surface into \(2^{n}\) sections according to that sequence; then \(n\) consecutive contacts read a different \(n\)-bit number at each of the \(2^{n}\) positions, so all positions are distinguishable — and \(n\) is optimal, since \(k\) contacts give only \(2^{k}\) readings. For \(n = 4\) the book’s tour gives \(0000111100101101\). Due to Good (1946).
! This is a three-line consequence of its two inputs, but it inherits both defects of exists_directedEulerTour_iff: that theorem is currently false as stated, and IsDirectedEulerTour is defined through the sorry-bodied arcsOf. Until those are repaired this statement is not the intended one. Note also that the labels are not modelled — the conclusion asserts a tour exists, and turning it into the binary sequence is left to exists_deBruijn_sequence.
A vertex is a window of \(n-1\) bits. Its out-neighbours drop the leading bit and append a new one — two choices; its in-neighbours drop the trailing bit and prepend a new one — again two. This is the balance condition exercise 10.3.2 needs, and is why \(D_n\) has a directed Euler tour.
\(hn : 2 \le n\) is load-bearing in step 3: for \(n = 1\) the carrier Fin 0 \(\to \) Bool is a singleton and the free coordinate does not exist, so the two neighbours coincide and the degree is \(1\), not \(2\).
The coefficient function \(\mathrm{coeffs}\, T : \mathcal{P}(\mathrm{Fin}\, n) \to \mathbb {R}\) defined by structural recursion on \(T\). A leaf labelled \(b\) assigns \(\mathrm{boolToSign}(b)\) to the empty frequency and \(0\) to all others; a branch on variable \(i\) with subtrees \(\mathrm{lo}, \mathrm{hi}\) assigns to \(S\) the value
Extracts a deepest root-to-leaf path from a decision tree, at each branch descending into the deeper subtree (ties broken toward the high subtree). It returns the list of \((\text{queried variable}, \text{branch direction})\) pairs along that path.
For every Boolean function \(f\), the \(\pm 1\)-encoding \(x \mapsto \mathrm{boolToSign}(f(x))\) has Fourier degree at most \(\mathrm{dtDepth}\, f\), the minimum depth of a decision tree computing \(f\). This is the implication \(\mathrm{DT}(f) \le k \Rightarrow \deg (f) \le k\) used as input to O’Donnell’s Lemma 4.21.
Let \(F(x) = \sum _{j=0}^{n} F_j K_j^{(n)}(x)\) for real coefficients \(F_j\). If \(F_0 \gt 0\), if \(F_j \ge 0\) for all \(1 \le j \le n\), and if \(F(x) \le 0\) for every integer \(x\) with \(d \le x \le n\), then
For any \(T \in \mathbb {N}\), there exist \(M_{\mathrm{alg}}, M^* \in \mathbb {N}\) with \(M_{\mathrm{alg}} = T\) and \(2 M^* \le T\). This witnesses that a deterministic learner facing two constant experts can be forced by an adversary to make \(T\) mistakes while the best expert makes at most \(T/2\), showing the factor of \(2\) in the Weighted Majority bound is unavoidable.
*A nontrivial digraph is diconnected if and only if it is 1-arc-connected.*
Diconnection is the \(k = 1\) case of arc-connectivity, exactly as connection is the \(k = 1\) case of edge-connectivity in §3.1.
[Nontrivial V] is the book’s "nontrivial digraph" and is load-bearing: on a one-vertex carrier there is no nonempty proper \(S\), so IsKArcConnected 1 is vacuously true while Diconnected — which is also true there — would make the \(\leftrightarrow \) hold only by accident. More importantly, its absence is what breaks associatedDigraph_isKArcConnected_iff below.
Record a \(1\) where an arrow runs from \(v_{i}\) to \(v_{j}\) and \(0\) otherwise. Unlike the undirected case (§1.3) this matrix is not symmetric — its asymmetry encodes the orientations. Exercise 10.1.8 shows \(A^{k}\) counts directed walks of length \(k\), and §10.7 uses the powers of \(A\) to rank tournament players via the level score vectors \(s_{i} = A^{i}J\).
! Restated: Digraph has no arc multiplicities, so entries are \(0\) or \(1\) rather than a count. For strict digraphs — which every §10.7 statement is about, tournaments being orientations — the two agree, so nothing is lost where it is used. The value type \(\alpha \) is left generic so the same matrix serves the \(\mathbb {N}\)-valued counting of exercise 10.1.8 and any later numeric work.
Count the ordered pairs \((u, v)\) for which an arc runs from \(u\) to \(v\). This is the \(\varepsilon \) of exercise 10.1.2’s handshake lemma and of exercise 10.1.1’s \(2^\varepsilon \) orientation count.
Since Digraph allows no parallel arcs in the same direction, \(\varepsilon \) is simply the size of the adjacency relation, counted as a Finset (V \(\times \) V). Note this differs from the book for multi-digraphs, which B&M permit — a point that also forces the restatement of adjMatrix below.
The arcs crossing from \(S\) into \(T\), counted with their direction. Unlike the undirected edge cut \([S, \bar{S}]\), the directed version splits into two generally unequal halves \((S, \bar{S})\) and \((\bar{S}, S)\) — which is precisely what \(k\)-arc-connectivity measures, and what theorem 10.6 has to balance.
A Finset (V \(\times \) V) obtained by filtering the product \(S \times ^{s} T\), so \(|(S, T)|\) is its card. Used in IsKArcConnected and in Moon’s theorem 10.3, where the book’s "\((S, T)\) must be nonempty" becomes a cardinality claim.
Reading off the arrows a directed walk uses, in order. This is what a trail condition quantifies over — a directed trail repeats no arc — and what a directed Euler tour must exhaust.
! Defective: this definition has a sorry body. It is declared List (V \(\times \) V) := sorry, so arcsOf is an opaque, unspecified function, not the arc list of anything. This is the most damaging defect in the file, because the opacity propagates: IsDirectedTrail and IsDirectedEulerTour are defined from it, so both are meaningless as stated; and therefore exists_directedEulerTour_iff (exercise 10.3.2), deBruijnDigraph_exists_directedEulerTour and exists_arcDisjoint_directedPaths (exercise 10.3.3) say nothing — which is the entire §10.5 computer-drum application plus the flow precursor to chapter 11. It also violates the project convention (.claude/CLAUDE.md): never sorry in a def* — a sorry-ed proof is an honest debt, a sorry-ed definition is a silent change of meaning.
The repair is a routine structural recursion on Quiver.Path, whose two constructors are nil : Path a a and cons : Path a b \(\to \) (b ⟶ c) \(\to \) Path a c:
arcsOf nil = [] arcsOf (cons p e) = arcsOf p ++ [(b, c)]
with \(b\), \(c\) the source and target of the arrow \(e\). Nothing about it is delicate; the outline simply left it unspecified. This is a change of meaning, not of annotation, so it has been flagged rather than made here.
Shrink each dicomponent to a single point and keep the arcs between them. Exercise 10.1.9 shows the condensation is acyclic — a directed cycle among dicomponents would merge them into one — so by exercise 10.1.3(b) the dicomponents can be topologically ordered, which is what §10.7 uses to rank the participants of a non-diconnected tournament, and what exercise 10.2.1 uses on tournaments.
! The \(a \ne b\) clause is a recorded correction, not a transcription. Taken literally the book’s condition puts an arc from \(w_{i}\) to \(w_{i}\) whenever \(D_{i}\) has any internal arc — a loop at every non-trivial dicomponent — which would make condensation_acyclic false, since a loop is a directed cycle of length \(1\). B&M plainly intend \(i \ne j\).
The vertex type is Quiver.StronglyConnectedComponent, Mathlib’s quotient by mutual reachability, which is exactly the set of dicomponents.
Turn every arrow around. It is an involution (\(\breve{\breve{D}} = D\)), it swaps indegree with outdegree, and it reverses reachability — so every theorem about digraphs comes with a free dual, obtained by applying it to the converse. Exercise 10.1.5(a) records exactly these three facts and (b) puts them to work.
A one-line Digraph.mk with the arguments of Adj swapped, so converse_converse should be rfl-adjacent. Because Reachable is defined from Adj and not through a Quiver instance, \(D\) and D.converse can appear in the same statement without ambiguity — see converse_reachable.
Wherever you start and wherever you want to go, some route respecting the arrows exists. In the road-network reading of §10.6 this is exactly the condition that a one-way system lets traffic flow freely — every junction remains reachable from every other, and Robbins’ theorem 10.5 says \(2\)-edge-connectivity is precisely what makes it achievable.
Stated directly as "every ordered pair is reachable" rather than via dicomponents, which avoids constructing the quotient. The two agree: one dicomponent means the equivalence relation is total. Note this is not symmetric by fiat — \(\forall \) u v, Reachable u v quantifies over ordered pairs, so both directions are demanded.
The worst case of the directed distance — how far apart two vertices can be when you must respect the arrows. Theorem 10.7 shows that for a diconnected tournament on at least five vertices \(A^{d+3}\) is entrywise positive, where \(d\) is this diameter, and corollary 10.7 turns that into the primitivity that makes the §10.7 ranking method converge.
A Finset.sup over all ordered pairs, so the diagonal \(\vec{d}(v,v) = 0\) is included harmlessly. Inherits dirDist’s sInf \(\emptyset \) = 0 caveat: on a non-diconnected digraph the diameter is silently too small.
\(\vec{d}(u,v)\). ! Nat.sInf \(\emptyset \) = 0 when \(v\) is unreachable from \(u\).
The fewest arrows you must follow to get from \(u\) to \(v\). Unlike the undirected distance of §1.6 this is not symmetric — \(\vec{d}(u,v)\) and \(\vec{d}(v,u)\) may differ, which is the whole reason §10.7 needs \(d + 3\) rather than something symmetric.
! Nat.sInf \(\emptyset \) = 0, so an unreachable \(v\) gets distance \(0\) rather than \(\infty \). The definition is therefore faithful only on diconnected digraphs — which is exactly where the book defines it, and both consumers (tournament_adjMatrix_pow_pos, dirDiameter) carry hdicon. Minimising over Quiver.Path lengths rather than over Reachable witnesses, since the length is what is wanted.
How many arrows point into \(v\). Exercise 10.1.2 gives the directed handshake lemma \(\sum d^{-}(v) = \varepsilon = \sum d^{+}(v)\) — each arc is counted once by its head and once by its tail, which is why the directed sum is \(\varepsilon \) and not \(2\varepsilon \).
! Missing from Mathlib (0 hits). Counts vertices \(u\) with D.Adj u v, not arcs — the same thing here, since Digraph is a bare relation and admits no parallel arcs. Needs [DecidableRel D.Adj] for the filter.
Keep only the vertices in \(S\) and the arcs with both ends there. The dicomponents of \(D\) are the induced subdigraphs \(D[V_{i}]\) on the diconnection classes, and theorem 10.2’s induction removes \({v} \cup N^{+}(v)\) this way.
Kept on the same carrier \(V\), with membership in \(S\) folded into Adj, rather than moving to a subtype. This avoids subtype juggling across the many statements that induce, at the cost that induce D S has isolated vertices outside \(S\) — harmless, since every consumer only asks about arcs.
Follow the arrows all the way round and return to where you started, never repeating a vertex en route. Directed cycles are the subject of §10.3: Moon (theorem 10.3) finds them of every length in a diconnected tournament, and Ghouila-Houri (theorem 10.4) finds a spanning one under a degree condition.
0 < length excludes nil; vertices.tail.Nodup allows the repeated basepoint at the two ends while forbidding any other repeat. Note a loop D.Adj v v counts as a directed cycle of length \(1\) under this definition, which is what makes the acyclicity hypotheses below (hacyc) automatically exclude loops — relied on by exists_topological_ordering.
The directed version of Euler’s problem — traverse every one-way street exactly once and return to the start. Exercise 10.3.2 gives the criterion: possible exactly when \(D\) is connected and \(d^{+}(v) = d^{-}(v)\) everywhere, the directed analogue of theorem 4.1’s even-degree condition, because every visit uses one arrow in and one out. §10.5 uses it to design an efficient computer drum via the de Bruijn digraph.
! Defective on two counts. 1. Inherits the arcsOf defect — both conjuncts are stated in terms of an opaque function, so the predicate currently means nothing. 2. Admits the null walk. B&M’s directed walks are explicitly non-null (§10.1), so nil is not a directed tour for them; here Quiver.Path.nil satisfies both conjuncts vacuously ([].Nodup, and no arc to exhaust when \(D\) has none). This is not cosmetic: it makes exists_directedEulerTour_iff false outright — see the counterexample there.
The repair for (2) is to add 0 < Quiver.Path.length p, matching "non-null". Both repairs change meaning, so they are flagged rather than made here.
Follow the arrows, never against them; a directed path additionally never revisits a vertex. The book stresses (figure 10.3) that there is *no close relationship between the lengths of paths and directed paths in a digraph* — the digraph there has arbitrarily long paths but no directed path of length above one. Theorem 10.1 is remarkable precisely because it recovers control of directed-path length from the chromatic number.
! Quiver.Path is the directed walk, so a directed path is a Quiver.Path with Nodup vertices. Note the book’s directed walks are non-null, whereas Quiver.Path.nil is available here; that mismatch is harmless for paths but bites for Euler tours (see IsDirectedEulerTour).
Follow the arrows, never using the same arrow twice, though you may revisit vertices. The directed analogue of §1.6’s trail, and the notion an Euler tour refines.
! Inherits the arcsOf defect: since arcsOf is sorry, this predicate is (opaque list).Nodup and means nothing. Repairing arcsOf repairs this automatically.
However you split the vertices in two, at least \(k\) arrows point from the first part to the second. Exercise 10.3.5 says \(1\)-arc-connected is the same as diconnected, and exercise 10.3.6(b) that \(D(G)\) is \(k\)-arc-connected exactly when \(G\) is \(k\)-edge-connected. Nash-Williams’ theorem — of which theorem 10.6 is the easy special case — says every \(2k\)-edge-connected graph has a \(k\)-arc-connected orientation.
! The book says nontrivial digraph, and this definition drops that. On a one-vertex carrier there is no nonempty proper \(S\), so the condition is vacuously true for every \(k\) — which is why statements consuming it must supply [Nontrivial V] themselves. diconnected_iff_isKArcConnected_one does; associatedDigraph_isKArcConnected_iff does not, and is false in consequence (see its docstring).
Make every edge one-way, choosing a direction for each. Orientations are the chapter’s central object: exercise 10.1.1 counts them (\(2^\varepsilon \)), the remark after theorem 10.1 builds one whose directed paths are short, exercise 10.1.10 one that is degree-balanced, and §10.6 asks which graphs admit diconnected ones — Robbins’ theorem 10.5.
Two clauses. The first, D.toSimpleGraphInclusive = G, says the underlying graph comes back out as \(G\). The second, \(\forall \) u v, \(\lnot \)(D.Adj u v \(\land \) D.Adj v u), forbids making an edge two-way — without it the associated digraph \(D(G)\) would count as an orientation of \(G\), which it is not. Taking \(u = v\) in the second clause also forces looplessness, so an orientation is automatically strict.
The directed analogue of "simple". Note a strict digraph may have both \((u,v)\) and \((v,u)\) — forbidding that is what makes an orientation, which is a strictly stronger condition. Strictness is the standing hypothesis of exercises 10.1.6, 10.1.7 and theorem 10.4, where it guarantees that \(\delta ^{+}\) out-neighbours are \(\delta ^{+}\) genuinely distinct vertices.
Since Digraph is a bare relation it already forbids repeated arcs in the same direction, so the book’s second clause is automatic and strictness reduces to looplessness — Irreflexive D.Adj.
Every pair of players meets exactly once and the arrow points from winner to loser. Tournaments are remarkably well behaved: every one has a directed Hamilton path (Rédei, corollary 10.1) and a "king" reaching everyone in at most two steps (corollary 10.2); diconnected ones are vertex-pancyclic (Moon, theorem 10.3) and hence have directed Hamilton cycles (Camion). §10.7 uses them to rank players.
Unfolded rather than defined as "IsOrientationOf some complete graph": Irreflexive D.Adj plus, for distinct \(u\), \(v\), exactly one of D.Adj u v, D.Adj v u. The \(\leftrightarrow \lnot \) phrasing packs both "at least one" (from completeness of the underlying graph) and "at most one" (from being an orientation) into a single clause.
Weaker than diconnected — you need only get one way between any two vertices, not both. Exercise 10.2.2 characterises it: \(D\) is unilateral exactly when it has a spanning directed walk.
The disjunction is over Reachable, which is reflexive, so the case \(u = v\) is automatic. Note "unilateral" sits strictly between "connected" (underlying graph) and "diconnected".
The least number of arrows pointing into any one vertex. Exercise 10.1.3(a) says an acyclic digraph must have \(\delta ^{-} = 0\), which is what makes topological ordering possible; exercises 10.1.6–10.1.7 turn a large \(\delta ^{-}\) into long directed paths and cycles.
! \(\bigsqcap \) over \(\mathbb {N}\) is Nat.sInf, and Nat.sInf \(\emptyset \) = 0, so on an empty carrier this silently returns \(0\) rather than being undefined. Every use site below carries [Nonempty V] for that reason. Only the minima are defined here; \(\Delta ^{-}\), \(\Delta ^{+}\) are never needed by a surviving statement.
The least number of arrows leaving any one vertex. By the converse symmetry of exercise 10.1.5, statements about \(\delta ^{-}\) transfer to \(\delta ^{+}\) and back — exactly how exercise 10.1.5(b) deduces \(\delta ^{+} = 0\) for acyclic digraphs from \(\delta ^{-} = 0\), without repeating the argument.
Same Nat.sInf \(\emptyset \) = 0 caveat as minIndegree.
How many arrows point out of \(v\). Together with the indegree this refines the single degree of an undirected graph into two numbers, and their interplay drives most of the chapter: Euler tours need them equal (exercise 10.3.2), Ghouila-Houri’s theorem 10.4 needs both large, and exercise 10.1.10 asks for an orientation making them nearly equal everywhere.
! Missing from Mathlib. The exact mirror of indegree under converse, which is the content of exercise 10.1.5(a)(ii).
You can get from \(u\) to \(v\) travelling only along arrows in their given direction. Reachability is not symmetric — that asymmetry is the whole point of directing a graph, and is what makes diconnection a strictly stronger condition than connection.
Relation.ReflTransGen D.Adj rather than an existential over Quiver.Path. The two agree (a path witnesses reachability and conversely), but ReflTransGen comes with induction principles and is reflexive, matching the book’s convention that every vertex reaches itself. Being defined directly from Adj, it needs no Quiver instance, so \(D\) and D.converse coexist freely — which converse_reachable relies on.
A quiver is a vertex set together with, for each ordered pair, a type of arrows. Taking that type to be a Prop — arrow or no arrow — recovers exactly a digraph, and Mathlib’s Quiver.Path then supplies directed walks for free, which Digraph (a bare Adj with a lattice API) does not.
! Deliberately not an instance. The chapter routinely handles several digraphs on one vertex type at once — \(D\) and its converse \(\breve{D}\), \(D\) and a reorientation of one arc (exercise 10.2.1) — and a global instance would make Quiver.Path ambiguous between them. The cost is that every use site must write @Quiver.Path V D.toQuiver u v explicitly, which is why the statements below are visually heavy.
The decision-tree depth of \(f : (\mathrm{Fin}\, n \to \mathrm{Bool}) \to \mathrm{Bool}\) is the least \(d\) such that some decision tree of depth at most \(d\) computes \(f\); it is well defined since the full tree computes \(f\) at depth \(n\).
Let \(C_0\) be a minimum cut of \(G_0\) and let \(i \lt \left\lvert V(G_0)\right\rvert - 1\). Then
the invariant maintained after \(i\) contraction steps.
The least number of edges one must cut to break \(G\) apart. "\(G\) is \(k\)-edge-connected" is spelled k \(\le \) edgeConnectivity G throughout this file — see robbins_orientation (\(k = 2\)) and exists_kArcConnected_orientation_of_eulerian.
Mathlib has no edge-connectivity, so this is the repo’s notion restated locally. sInf \(\emptyset \) = 0 in \(\mathbb {N}\) reproduces the book’s trivial-graph convention automatically — but it also means a graph with no edge cut (a one-vertex graph) gets \(\kappa ' = 0\), which is the source of the [Nontrivial V] gap in associatedDigraph_isKArcConnected_iff below.
Given \(T \gt 0\) rounds of play in which the row player uses mixed strategy \(p_t\) and the column player uses \(q_t\), the empirical joint distribution assigns to each profile \((i,j)\) the time-averaged probability \(\frac{1}{T}\sum _{t=1}^{T} (p_t)_i \cdot (q_t)_j\).
The column player’s deviation utility for pure action \(j'\) in the empirical distribution equals the time-average utility of always playing \(j'\):
The column player’s expected utility under the empirical joint distribution equals the time-average of the per-round bilinear column utilities:
Let \(G\) be a two-player game, \(T \gt 0\), and let \(p_t\), \(q_t\) be the mixed strategies played at round \(t\) by the row and column players respectively. Suppose that for every pure row deviation \(i'\),
and similarly for every column deviation \(j'\) using \(u_c\). Then the empirical joint distribution is an \(\varepsilon \)-CCE of \(G\).
The row player’s deviation utility for pure action \(i'\) in the empirical distribution equals the time-average utility of always playing \(i'\):
The row player’s expected utility under the empirical joint distribution equals the time-average of the per-round bilinear utilities:
For any function \(f : \mathrm{Fin}\, M \to \mathrm{Fin}\, N \to \mathbb {R}\), the sum \(\sum _{i,j} \sigma _{ij} \cdot f(i,j)\) over the empirical joint distribution equals the time-average \((1/T)\sum _{t}\sum _{i,j}(p_t)_i(q_t)_j f(i,j)\).
Given \(T \gt 0\) pure actions \(a_0, \dots , a_{T-1} \in \mathrm{Fin}\, n\), the empirical strategy is the mixed strategy assigning to each \(i\) the fraction of rounds on which action \(i\) was played:
An \(\texttt{Episode}\ N\ T\) packages a learner policy, an adaptive adversary, and a finite loss sequence of length \(T\) for \(N\) experts, together with a consistency proof that the stored loss sequence equals the one generated by running \(\texttt{episodeLossSeq}\ T\ \mathrm{learner}\ \mathrm{adversary}\).
\(\texttt{Episode.generated}\ \mathrm{learner}\ \mathrm{adversary}\) is the canonical \(\texttt{Episode}\ N\ T\) constructed by taking the loss sequence to be exactly \(\texttt{episodeLossSeq}\ T\ \mathrm{learner}\ \mathrm{adversary}\); the consistency condition is satisfied by reflexivity.
\(\texttt{episodeLossNat}\ \mathrm{learner}\ \mathrm{adversary}\ t : \mathrm{Fin}\, N \to \mathbb {R}\) is the loss vector produced at round \(t\) when the learner and adversary interact adaptively: the adversary sees the prefix of losses from rounds \(0, \ldots , t-1\) and the learner’s mixed strategy for round \(t\), then returns the loss vector for round \(t\). The definition is well-founded because the recursion only refers to strictly earlier rounds.
\(\texttt{episodeLossSeq}\ T\ \mathrm{learner}\ \mathrm{adversary} : \texttt{LossSeq}\ N\ T\) is the finite loss sequence realized over \(T\) rounds by running the learner against the adaptive adversary, obtained by restricting \(\texttt{episodeLossNat}\) to the first \(T\) rounds.
For any learner policy and adaptive adversary, the generated loss sequence \(\texttt{episodeLossSeq}\ T\ \mathrm{learner}\ \mathrm{adversary}\) is valid, meaning every entry lies in \([0, 1]\). Validity is inherited directly from the adversary’s range condition.
(Erdős and Szekeres). Deduce that any sequence of \(mn + 1\) distinct integers contains either an increasing subsequence of \(m\) terms or a decreasing subsequence of \(n\) terms.*
The classical Erdős–Szekeres theorem, obtained as a special case of a statement about digraphs — a good illustration of the chapter’s theme that chromatic number controls directed-path structure.
! Restated: Mathlib’s Archive version is not importable, so the statement is spelled out here and derived from (a) as the book intends. \(g\) is \(\mathbb {Z}\)-valued (the book’s "integers") while part (a) needs \(\mathbb {R}\), hence the cast in step 2. hN : m * n < N is the book’s "\(mn + 1\) terms", generalised to any longer sequence.
If the ball volume \(V\) and code size \(M\) satisfy the counting inequality
then there exists a code \(C\) of size \(M\) that is \((p,L)\)-list-decodable.
Let \(a,b,n\in \mathbb {N}\) with \(a,b\gt 0\), \(a+b=n\), and let \(c\gt 0\). Suppose the Stirling-type bound
holds. Then
If \(x\neq 0\) and \(k\ge 1\), then for a uniformly random \(n\times k\) matrix \(G\) over \(\alpha \), the product \(Gx\) is uniformly distributed over \(\alpha ^n\):
Let \(q\) be even with \(q \ge 2\), let \(k \gt 0\) and \(n \ge 2\), and let \(\delta , \varepsilon \gt 0\). Then there is a constant \(C \gt 0\) with
Placeholder — the statement carries no lower-bound content. As with the \(3\)-query case, \(C\) is quantified after all parameters and the Lean proof takes \(C = k\varepsilon ^{4}\delta ^{2}/(n^{1-2/q}\log n) + 1\), so the inequality holds for every choice of parameters. Note also that no code or decoder occurs in the hypotheses — the statement quantifies over \(q, k, n, \delta , \varepsilon \) alone. Theorem 10.1 of Alrabiah–Guruswami–Kothari–Manohar is not formalised here.
*Let \(D\) be a digraph such that (i) \(d^{+}(x) - d^{-}(x) = l = d^{-}(y) - d^{+}(y)\) and (ii) \(d^{+}(v) = d^{-}(v)\) for \(v \in V \ {x, y}\). Show, using exercise 10.3.2, that there exist \(l\) arc-disjoint directed \((x, y)\)-paths in \(D\).*
The degree conditions say \(x\) has an excess of \(l\) outgoing arcs, \(y\) an excess of \(l\) incoming ones, and everything else is balanced — so \(l\) units of "flow" must run from \(x\) to \(y\). A small precursor of the max-flow min-cut machinery of chapter 11.
! Two obstructions to the intended route, both recorded rather than resolved. (i) Digraph admits no parallel arcs, so step 1’s "\(l\) copies of \((y,x)\)" is not expressible on \(D\); the construction has to move to Digraph (V \(\oplus \) Fin l), routing each extra arc through its own new vertex. The statement stays on \(D\) and is well-typed. (ii) The conclusion mentions arcsOf, which currently has a sorry body, so the arc-disjointness clause is presently meaningless — see that definition. Degrees are compared in \(\mathbb {Z}\) to let \(hx\), \(hy\) state genuine differences without \(\mathbb {N}\)-truncation.
Every graph can be made one-way in a balanced way, with the traffic into and out of each junction differing by at most one. Contrast exercise 10.6.1, which shows the stronger set-wise balance — \(||(S, \bar{S})| - |(\bar{S}, S)|| \le 1\) for every vertex set \(S\) — is not always achievable, the Petersen graph being a counterexample.
The conclusion is stated as two \(\mathbb {Z}\) inequalities rather than \(|\cdot | \le 1\), avoiding Int.natAbs juggling. The open scoped Classical in supplies decidability of the existentially-bound D.Adj; the outline’s \(\exists \) _ : DecidableRel D.Adj does not register as an instance inside the body, which is why it was replaced.
. A diconnected digraph which contains an odd cycle also contains a directed odd cycle.*
The hypothesis gives an odd cycle in the underlying graph, whose arcs may point every which way; the conclusion upgrades it to a genuinely directed odd cycle. Diconnection is essential — without it the parity argument cannot be propagated across the whole digraph, and the statement is false.
The undirected cycle enters as a Walk in toSimpleGraphInclusive with IsCycle and Odd length; the directed conclusion is a Quiver.Path. Step 2’s "decompose a closed walk into directed cycles" has no Mathlib counterpart for Quiver.Path and will have to be built.
Sharpens exercise 10.1.6 from paths to cycles, exactly as exercise 1.7.3 sharpens 1.6.3 undirected. It is consumed inside Ghouila-Houri’s theorem 10.4, which opens by noting \(l \gt \nu /2\) for the longest directed cycle — that is this exercise with \(k \ge \nu /2\).
\(hk : 0 \lt k\) is load-bearing: with \(k = 0\) the conclusion would demand a directed cycle of length \(\ge 1\) in a digraph that may have no cycle at all. hdeg pins max \(\delta ^{-}\) \(\delta ^{+}\) to \(k\) as an equality, matching the book.
*\(D\) contains a directed Euler tour if and only if \(D\) is connected and \(d^{+}(v) = d^{-}(v)\) for all \(v \in V\).*
The directed analogue of Euler’s theorem 4.1. Every visit uses one arrow in and one out, so the two counts must balance. Why it is built early: §10.5 depends on it — the de Bruijn digraph \(D_n\) is connected with every indegree and outdegree \(2\), so it has a directed Euler tour, and that tour is exactly the binary sequence for the computer drum.
Connectivity is asked of toSimpleGraphInclusive, the underlying graph, matching B&M’s "\(D\) is connected" (a property of the underlying graph, per §10.1).
+ Statement repaired — connectivity moved from the right-hand side into a hypothesis. As previously written, (\(\exists \) Euler tour) \(\leftrightarrow \) (Connected \(\land \) balanced), the \(\leftrightarrow \) was false, for two compounding reasons.
Counterexample 1. Let \(D\) have no arcs and card V \(\ge \) 2. Then Quiver.Path.nil at any \(u\) satisfies IsDirectedEulerTour — its arc list is \([]\) (so Nodup), and the exhaustiveness clause \(\forall \) a b, D.Adj a b \(\to \) … is vacuous — so the left side holds, while the right side fails because \(D\) is disconnected.
Counterexample 2. Adding arcs does not rescue it: take one directed cycle plus an isolated vertex. A tour of the cycle exhausts every arc, so the left side holds, but the underlying graph is still disconnected.
So no strengthening of the left side repairs this; connectivity has to be assumed, not concluded. With hconn a hypothesis the equivalence is the honest directed Euler theorem, and it now matches the shape of this library’s undirected euler_tour_iff_no_odd_degree in EulerHamilton.lean.
! Note that unlike the undirected statement, no arc-nonemptiness hypothesis is needed: hconn already forces the arc-free case to be the one-vertex graph, where nil is an Euler tour and the balance condition holds vacuously, so the \(\leftrightarrow \) is true there.
The directed analogue of exercise 1.6.3. Strictness is what makes the counting work: it guarantees the out-neighbours are \(\delta ^{+}\) genuinely distinct vertices.
! Step 5 is easy to get wrong. The statement asks for one path of length \(\ge \) max{\(\delta ^{-}\), \(\delta ^{+}\)}, not one path per bound; since max is one of the two, produce the two paths and pick the longer. minIndegree/minOutdegree are \(\bigsqcap \) over \(\mathbb {N}\), so [Nonempty V] is needed to keep them from collapsing to \(0\).
For any \(k \gt 0\) and \(d \ge 0\), there exists a probability space \((\Omega , \mathcal{F}, \mu )\) carrying a measurable random matrix \(A : \Omega \to \mathrm{Matrix}(\mathrm{Fin}\, k, \mathrm{Fin}\, d, \mathbb {R})\) whose entries are i.i.d. \(\mathcal{N}(0, 1/k)\), with rows mutually independent and entries within each row jointly independent.
If every vertex had an incoming arc one could walk backwards for ever; finiteness forces a repeat, and the portion between the two visits is a directed cycle. So an acyclic digraph always has a "source" with nothing pointing into it — the base of the topological-ordering induction in part (b).
[Nonempty V] is load-bearing: on an empty carrier there is no \(v\) to produce, while hacyc holds vacuously. Note hacyc also rules out loops, since a loop is a directed cycle of length \(1\) under IsDirectedCycle.
*Let \(G\) be a \(2k\)-edge-connected graph with an Euler trail. Then \(G\) has a \(k\)-arc-connected orientation.*
The easy special case of a theorem of Nash-Williams (1960), that every \(2k\)-edge-connected graph has a \(k\)-arc-connected orientation; the general proof is difficult. Robbins’ theorem 10.5 is the case \(k = 1\) — proved there by a quite different, ear-decomposition route.
! Step 4’s \(\lfloor m/2\rfloor \) is stated as 2 * count + 1 \(\ge \) m to keep \(\mathbb {N}\) division out. Step 2 is where an Euler trail rather than a tour matters: an open trail is what allows the discrepancy of one, and a closed tour would give equality. Note t : G.Walk u v with \(u\), \(v\) unconstrained, so both cases are covered.
*Using theorem 10.1 and corollary 8.1.2, show that \(G\) has an orientation in which each directed path is of length at most \(\Delta \).*
Chaining two results already available: \(\chi \le \Delta + 1\) bounds the palette, and the colour-increasing orientation turns a palette bound into a path bound. Part (b) of the exercise — dropped here, being the same statement — asks for a constructive proof avoiding the chromatic detour.
! This rides chapter 8’s corollary 8.1.2, which is out of chapter; step 1 is therefore an import from TCSlib/GraphTheory/VertexColourings.lean (chromaticNumber_le_maxDegree_add_one) rather than something proved here. Note the shape of step 2: this is exactly why the theorem-10.1 remark was stated for an arbitrary \(k\)-colouring rather than an optimal one.
Orient every edge from the lower colour class to the higher. Along a directed path the colour index strictly increases, so the path has at most \(\chi \) vertices. Combined with theorem 10.1 this shows \(\chi - 1\) is exactly the right bound. Note the orientation is automatically acyclic, the colour index being a topological ordering — so this also witnesses exercise 10.1.3(b) in reverse.
Stated with an arbitrary \(k\)-colouring rather than an optimal one, which is the usable form: exercise 10.2.6(a) instantiates it at \(k = \Delta + 1\) via corollary 8.1.2, not at \(k = \chi \). Step 4’s injectivity is a cleaner invariant to carry than the book’s "no two vertices share a colour".
An acyclic digraph has both a "source" (nothing in) and a "sink" (nothing out), which is what lets topological ordering be built from either end. The point of the exercise is methodological: the converse converts one statement into its dual with no new argument.
Step 1 needs a Quiver.Path reversal for D.converse versus \(D\); since toQuiver is not an instance, both quivers must be named explicitly. Worth extracting as a standalone lemma, as converse_reachable is the same fact one level down.
A topological ordering: line the vertices up so every arrow points forwards. Greedy construction via part (a) — take a source, delete it, repeat. These are the standard tool for scheduling tasks with prerequisites, and §10.7 uses the version for the condensation of a tournament to order its dicomponents in a way that preserves dominance.
The book’s "every arc with head \(v_{i}\) has its tail among the earlier vertices" is contraposed into the equivalent and more usable D.Adj u v \(\to \) f u < f v. Note no [Nonempty V] is needed here, unlike part (a) — the empty case is the induction’s base.
A finite two-player game with \(M\) row actions and \(N\) column actions, specified by a row utility function \(u_r : \mathrm{Fin}\, M \times \mathrm{Fin}\, N \to \mathbb {R}\) and a column utility function \(u_c : \mathrm{Fin}\, M \times \mathrm{Fin}\, N \to \mathbb {R}\). Both players are utility maximizers.
For \(1 \le p \le 2 \le u\), \(f : \mathrm{BoolCube}\, n \to \mathbb {R}\), and \(\rho = \sqrt{(p-1)/(u-1)}\),
Let \(0 \le \rho \le 1\) and let \(h, h' : \mathrm{BoolCube}\, n \times \mathrm{BoolCube}\, n \to \mathbb {R}\) satisfy \(h(x,y) \le h'(x,y)\) for all \(x, y\). Then the kernel-weighted average of \(h\) is at most that of \(h'\):
For \(h : \mathrm{BoolCube}\, (n+1) \to \mathbb {R}\),
the outer expectation being over \(x' \in \mathrm{BoolCube}\, n\).
Let \(1 \le p \le u\) with \(u \gt 1\), and let \(0 \le \rho \le 1\) satisfy \(\rho \le \sqrt{(p-1)/(u-1)}\). Then for every \(f : \mathrm{BoolCube}\, n \to \mathbb {R}\),
Let \(1 \le p \le u\) with \(u \ge 2\), and let \(0 \le \rho \le 1\) satisfy \(\rho \le \sqrt{(p-1)/(u-1)}\). Then for all \(f, g : \mathrm{BoolCube}\, n \to \mathbb {R}\),
For \(2 \le p \le u\), any \(\rho \) with \(0 \le \rho \le 1\) and \(\rho \le \sqrt{(p-1)/(u-1)}\), and \(f : \mathrm{BoolCube}\, n \to \mathbb {R}\),
For \(p \gt 1\) and \(f, h : \mathrm{BoolCube}\, n \to \mathbb {R}\),
Let \(p, q \ge 1\) and \(0 \le \rho \le 1\). If \(\left\langle f, T_\rho g \right\rangle \le (\mathbb {E}[\left\lvert f\right\rvert ^p])^{1/p}(\mathbb {E}[\left\lvert g\right\rvert ^q])^{1/q}\) holds for all \(f, g : \mathrm{BoolCube}\, 1 \to \mathbb {R}\), then the same bound holds for all \(n\) and all \(f, g : \mathrm{BoolCube}\, n \to \mathbb {R}\).
For \(1 \lt p \le u \le 2\), any \(n\), \(f : \mathrm{BoolCube}\, n \to \mathbb {R}\) and \(\rho = \sqrt{(p-1)/(u-1)}\),
Let \(1 \lt p \lt u \lt 2\) and \(\rho ^2 = (p-1)/(u-1)\). Then there exist \(\theta \in (0,1)\) and \(s \gt 0\) with
For \(1 \lt p \le q \le 2\), \(f : \mathrm{BoolCube}\, 1 \to \mathbb {R}\) and \(\rho = \sqrt{(p-1)/(q-1)}\),
For \(q \ge 1\), \(0 \le \rho \le 1\) and \(g : \mathrm{BoolCube}\, 1 \to \mathbb {R}\),
i.e. \(T_\rho \) is a contraction in \(L^q\) on one bit.
For \(p, q \gt 1\) and \(0 \le \rho \le 1\), the \((p \to q)\) bound
holds if and only if the bound for the Hölder-conjugate exponents holds:
For \(\rho \in \mathbb {R}\) and \(x, y\) in the cube \(\mathrm{BoolCube}\, n\), the noise kernel is
where \(\chi (\cdot )\) is the \(\pm 1\) encoding of a bit. It is the transition probability from \(x\) to \(y\) under \(\rho \)-correlated noise.
For \(p \ge 1\) and \(f : \mathrm{BoolCube}\, (n+1) \to \mathbb {R}\),
For \(p \gt 0\) and \(f : \mathrm{BoolCube}\, (n+1) \to \mathbb {R}\),
For \(p \gt 0\), \(f : \mathrm{BoolCube}\, (n+1) \to \mathbb {R}\) and \(x' \in \mathrm{BoolCube}\, n\),
Fix \(x', y' \in \mathrm{BoolCube}\, n\) and \(f, g : \mathrm{BoolCube}\, (n+1) \to \mathbb {R}\). The one-bit kernel-weighted sum of the slices of \(f\) at \(x'\) and of \(g\) at \(y'\) equals the one-bit inner product of those slices against the noise operator:
where \(f_{x'}(t) = f(\mathrm{snoc}(x', t_0))\) and \(g_{y'}(t) = g(\mathrm{snoc}(y', t_0))\) are functions on \(\mathrm{BoolCube}\, 1\).
Let \(1 \le p \le q\) with \(q \ge 2\), and let \(0 \le \rho \le 1\) satisfy \(\rho \le \sqrt{(p-1)/(q-1)}\). Then the one-function bound
holds if and only if the dual two-function bound
holds.
Let \(p, q \ge 1\) and \(0 \le \rho \le 1\). If the bound \(\left\langle f, T_\rho g \right\rangle \le (\mathbb {E}[\left\lvert f\right\rvert ^p])^{1/p}(\mathbb {E}[\left\lvert g\right\rvert ^q])^{1/q}\) holds for all pairs of functions on one bit and for all pairs of functions on \(n\) bits, then it holds for all \(f, g : \mathrm{BoolCube}\, (n+1) \to \mathbb {R}\).
For \(p, q \ge 1\), any \(\rho \in \mathbb {R}\), and \(f, g : \mathrm{BoolCube}\, 0 \to \mathbb {R}\),
For \(1 \le p \le 2\), \(1 \le q \le 2\), any \(n\), and \(f, g : \mathrm{BoolCube}\, n \to \mathbb {R}\), with \(\rho = \sqrt{(p-1)(q-1)}\),
For \(1 \le p \le 2\), \(1 \le q \le 2\) and \(f, g : \mathrm{BoolCube}\, 1 \to \mathbb {R}\), with \(\rho = \sqrt{(p-1)(q-1)}\),
For \(F : \mathrm{BoolCube}\, (n+1) \times \mathrm{BoolCube}\, (n+1) \to \mathbb {R}\), the kernel-weighted bilinear average at dimension \(n+1\) equals the \(n\)-dimensional kernel-weighted average of the one-bit average of the last coordinate:
(a special case of Ghouila-Houri, 1960). *If \(D\) is strict and min{\(\delta ^{-}\), \(\delta ^{+}\)} \(\ge \) \(\nu \)/2 > 1, then \(D\) contains a directed Hamilton cycle.*
The directed extension of Dirac’s theorem 4.3 — a large minimum degree, now in both directions, forces a spanning cycle. Exercise 10.3.1 recovers Dirac from it by orienting a graph suitably.
hdeg states \(\nu \le 2 d^{-}(v)\) and \(\nu \le 2 d^{+}(v)\) rather than min{\(\delta ^{-}\),\(\delta ^{+}\)} \(\ge \) \(\nu \)/2, avoiding division; \(hv : 2 \lt \nu \) is the book’s \(\nu /2 \gt 1\). The result is only a special case of Ghouila-Houri’s theorem, as B&M note.
Specialising to the initial hypothesis class \(H\) (with \(\mathtt{target} \in H\)), the Halving Algorithm makes at most \(\lfloor \log _2 |H|\rfloor \) mistakes on any input sequence:
If the algorithm makes a mistake on input \(x\) with true label \(y\) (i.e. \(\mathtt{predict}(\mathtt{eval}, V, x) \ne y\)), then after the update at most half the hypotheses survive:
\(\mathtt{mistakes}(\mathtt{eval}, \mathtt{target}, V, xs)\) is the total number of prediction errors made by the Halving Algorithm when it processes the input list \(xs\), using the version space \(V\), with the true label at each step supplied by \(\mathtt{target}\). It is defined recursively: the empty list yields zero mistakes, and for a list \(x :: xs\) the count is \(1\) if the algorithm mispredicts on \(x\) (else \(0\)), plus the mistakes on the remainder using the updated version space.
In the realizable setting (\(\mathtt{target} \in V\)), the total number of mistakes made by the Halving Algorithm on any input sequence \(xs\) is at most \(\lfloor \log _2 |V|\rfloor \):
The Halving Algorithm predicts on input \(x\) by taking a majority vote of the current version space \(V\): it returns \(\mathsf{true}\) whenever the number of hypotheses in \(V\) that predict \(\mathsf{true}\) is at least as large as the number that predict \(\mathsf{false}\) (ties are broken in favour of \(\mathsf{true}\)).
In the realizable setting, if \(\mathtt{target} \in V\) then after updating on the correctly labelled example \((x,\, \mathtt{eval}\; \mathtt{target}\; x)\) the target hypothesis remains in the new version space: \(\mathtt{target} \in \mathtt{update}(\mathtt{eval}, V, x, \mathtt{eval}\; \mathtt{target}\; x)\).
After observing that the correct label for input \(x\) is \(y\), the version space is updated to \(\mathtt{update}(\mathtt{eval}, V, x, y) = \mathtt{voteFor}(\mathtt{eval}, V, x, y)\), i.e. only the hypotheses that correctly predict \(y\) on \(x\) are retained.
Given an evaluation map \(\mathtt{eval} : \mathit{Hyp} \to X \to \mathsf{Bool}\), a version space \(V \subseteq \mathit{Hyp}\), an input \(x \in X\), and a label \(y \in \mathsf{Bool}\), \(\mathtt{voteFor}(\mathtt{eval}, V, x, y)\) is the subset of \(V\) consisting of all hypotheses that predict label \(y\) on input \(x\).
Under the same hypotheses as centered_chi_squared_step, the centered summand \(Y^2 - 1/k\) satisfies \(\text{\texttt{ProbabilityTheory.HasBernsteinMGF}}\bigl(2/k^2,\; k/4\bigr)\) under \(\mu \). This packages the chi-squared MGF bound into the abstract Bernstein form, so that the i.i.d.-sum tail-bound machinery of bernstein.lean can be applied uniformly to Gaussian and other sub-Gaussian matrix families.
The identity function \(\mathrm{id} : \mathbb {R} \to \mathbb {R}\) satisfies \(\mathrm{HasSubgaussianMGF}(\mathrm{id}, 1, \mathrm{Rad})\), i.e. its MGF is bounded by \(e^{t^2/2}\) for all \(t \in \mathbb {R}\). This follows from Hoeffding’s lemma applied to the centred random variable supported in \([-1, 1]\), whose sub-Gaussian parameter is \(\bigl((1-(-1))/2\bigr)^2 = 1\).
For \(k \gt 0\), \(x \in \mathbb {R}^d\), and \(i \in \mathrm{Fin}\, k\), the \(i\)-th row projection \(\omega \mapsto (A(\omega )\, x)_i = (1/\sqrt{k})\sum _j \omega _{ij} x_j\) satisfies \(\mathrm{HasSubgaussianMGF}(\cdot , \lVert x\rVert ^2/k, \mathrm{radJointMeasure})\). This follows by combining per-summand Hoeffding bounds with independence of the within-row entries.
Let \(H\) be a \(3\)-uniform hypergraph on \(\mathrm{Fin}\, n\) and let \(d \gt 0\). Then the number of heavy pairs satisfies
where \(P\) is the set of pairs of degree more than \(d\); equivalently \(\left\lvert P\right\rvert \le 3m/d\) for \(m = \left\lvert H\right\rvert \) edges, since each \(3\)-edge contributes exactly three pairs.
For a hypergraph \(H\) on \(\mathrm{Fin}\, n\) and a threshold \(d\), the set of heavy pairs
realised as the collection of two-element sets \(\{ u,v\} \) whose degree in \(H\) exceeds \(d\).
Given a game \(G\) with \(M \ge 2\) rows, a number of rounds \(T \gt 0\), and a learning rate \(\eta \gt 0\), there exist mixed strategies \(p\) (row) and \(q\) (column) such that for all pure \(i \in \mathrm{Fin}\, M\) and \(j \in \mathrm{Fin}\, N\),
The strategies are constructed by running Hedge for \(T\) rounds, with the column player taking pure best responses, and then averaging.
For any \(N, T \ge 1\), learning rate \(\eta \gt 0\), and adaptive adversary, the regret of the Hedge policy with rate \(\eta \) on the generated episode satisfies
Let \(\mathrm{episode}\) be an \(\texttt{Episode}\ N\ T\) whose learner equals \(\texttt{hedgePolicy}\ N\ \eta \) for some \(\eta \gt 0\). Then
\(\texttt{hedgePolicy}\ N\ \eta \) is the \(\texttt{LearnerPolicy}\) that implements the Hedge algorithm with learning rate \(\eta \gt 0\): at each round \(t\) and for each loss history \(h\), the weights are given by \(\texttt{hedgeDist}\ \eta \ (\text{\texttt{LossHistory.toLossSeq}}\ h)\ t\), the exponential-weights distribution derived from the past realized losses.
At each round \(t \in \mathrm{Fin}\, T\), Hedge’s prediction in the original decision space is the weighted average
where \(w^{(\eta )}_{t,i} = \texttt{hedgeDist}\, \eta \, L\, t\, i\) are the Hedge weights computed from the induced loss table \(L\) up to (but not including) round \(t\), and \(p_t(i)\) is expert \(i\)’s prediction at round \(t\).
Under the same hypotheses as above, assume additionally that for each round \(t\) the map \(x \mapsto \ell (x, o_t)\) is convex on \(S\). Then Jensen’s inequality gives, for every \(t\),
That is, the loss of the averaged prediction is at most the Hedge-weighted average of the individual expert losses.
Let \(S \subseteq \mathbb {R}\) be a convex set and suppose every expert prediction satisfies \(p_t(i) \in S\) for all \(t\) and \(i\). Then Hedge’s weighted-average prediction \(\widehat{x}_t \in S\) for every round \(t\). The result follows because the Hedge weights are nonnegative and sum to one, so the weighted average is a convex combination of points in \(S\).
Let \(S \subseteq \mathbb {R}\) be convex, \(\eta \gt 0\), and suppose all expert predictions lie in \(S\), each round loss is convex on \(S\), and the induced loss table is valid. Then the regret of Hedge’s actual weighted-average predictions satisfies
The proof combines the cumulative Jensen bound with the abstract tight Hedge regret theorem hedge_regret_bound_tight.
Under the same convexity hypotheses, with \(T \gt 0\), \(N \gt 1\), and the learning rate set to \(\eta ^* = \texttt{optimalEtaTight}\, N\, T\), the regret satisfies
The actual cumulative prediction loss of Hedge is
where \(\widehat{x}_t\) is the Hedge weighted-average prediction at round \(t\). This differs from hedgeCumLoss: here the loss is applied to the averaged prediction, not to a weighted average of expert losses.
Summing the per-round Jensen bound over all \(T\) rounds, we obtain
i.e. the actual cumulative loss of Hedge’s convex-combination predictions is at most the abstract cumulative Hedge loss on the induced expert loss table.
The sequence of column best responses generated online against Hedge: at time \(t\), given the history \(a_0, \dots , a_{t-1}\) of prior column choices, the column player responds with \(a_t = \mathrm{bestColumn}(G, p_t)\), where \(p_t\) is the prefix Hedge mixed strategy. This is defined by well-founded recursion on \(t\).
Let \(L\) be a normal form \((3,\delta ,\varepsilon )\)-decodable code with message length \(k \gt 0\), block length \(n \gt 0\) and at least one constraint, i.e. \(m \gt 0\), and suppose the advantage satisfies \(\varepsilon \le 1/2\). Then there are a message \(b : \mathrm{Fin}\, k \to \mathbb {Z}\) and an assignment \(x : \mathrm{Fin}\, n \to \mathbb {Z}\), both taking values in \(\{ -1,1\} \), such that the XOR polynomial of \(L\) satisfies
Placeholder. The paper’s Lemma 5.1 bounds the expectation \(\mathbb {E}_b[\mathrm{val}(\psi _b)] \ge 2\varepsilon \); the Lean statement asserts only that some \(b\) and \(x\) achieve the bound, and is discharged by the constant all-ones witness. The expectation bound is not formalised here.
Under the same hypotheses as hoeffding_log_mgf_weak, the tighter bound holds:
This follows by first applying weighted_exp_le_affine and then bernoulli_mgf_bound.
Let \(p\) be a probability vector on \(\mathrm{Fin}\, n\) and let \(\ell _i \in [0,1]\) for all \(i\). For \(\eta \gt 0\), setting \(L = \sum _i p_i \ell _i\),
Let \(L\) be a normal form locally decodable code with message length \(k\) and block length \(n\), given by the \(3\)-uniform matchings \(H_i\), and let \(d \gt 0\). Then there is a family of hypergraphs \(H'_i\) on \(\mathrm{Fin}\, n\), indexed by \(i : \mathrm{Fin}\, k\), such that each \(H'_i \subseteq H_i\), each \(H'_i\) is \(3\)-uniform and a matching, and the combined hypergraph \(\bigcup _{i} H'_i\) satisfies the pair-degree bound \(d\).
Placeholder. The Lean statement omits the paper’s counting clause \(|H_i| = |H'_i| + |G_i|\), and without it the empty hypergraph satisfies every remaining clause — which is exactly the witness the proof supplies (use fun _ => \(\emptyset \)). Lemma 6.1’s content is that few edges are removed; that is not formalised here.
Given a loss function \(\ell : \mathbb {R} \to \Omega \to \mathbb {R}\), expert predictions \(p : \mathrm{Fin}\, T \to \mathrm{Fin}\, N \to \mathbb {R}\), and a sequence of outcomes \(o : \mathrm{Fin}\, T \to \Omega \), the induced loss sequence is the abstract loss table \(L : \mathrm{LossSeq}\, N\, T\) defined by \(L_{t,i} = \ell (p_t(i),\, o_t)\), i.e. expert \(i\) at round \(t\) incurs the loss its own prediction receives under the realized outcome.
For \(v\ne 0\) and \(2tv \lt 1\), the function \(y\mapsto e^{t y^2}\) is integrable with respect to \(N(0,v)\). This integrability statement accompanies integral_exp_mul_sq_gaussianReal_zero and is a prerequisite for the Fubini and interchange-of-expectation arguments in centered_chi_squared_step.
For \(Y\sim N(0,v)\) with \(v\ne 0\) and \(2tv \lt 1\),
This generalizes integral_exp_mul_sq_standardGaussian from unit variance to an arbitrary non-zero NNReal variance \(v\).
For \(k \gt 0\), \(x \in \mathbb {R}^d\), and \(i \in \mathrm{Fin}\, k\),
This follows from \(\int Y^2 = \mathrm{Var}[Y] + (\int Y)^2 = \lVert x\rVert ^2/k + 0\).
A joint distribution \(\sigma \) is an \(\varepsilon \)-coarse correlated equilibrium (\(\varepsilon \)-CCE) of game \(G\) if each player’s gain from any unilateral pure deviation is at most \(\varepsilon \): for all \(i'\), \(\mathrm{rowDevUtil}(\sigma , G, i') \le \mathrm{rowExpUtil}(\sigma , G) + \varepsilon \), and similarly for the column player.
A joint distribution \(\sigma \) is a coarse correlated equilibrium (CCE) of game \(G\) if neither player can improve their expected utility by committing in advance to any fixed pure action: for all \(i'\), \(\mathrm{rowDevUtil}(\sigma , G, i') \le \mathrm{rowExpUtil}(\sigma , G)\), and for all \(j'\), \(\mathrm{colDevUtil}(\sigma , G, j') \le \mathrm{colExpUtil}(\sigma , G)\).
A linear map \(f : \mathbb {R}^d \to _L[\mathbb {R}] \mathbb {R}^k\) is an \(\varepsilon \)-JL embedding of a finite set \(V\) if, for every ordered pair \((u, v) \in V \times V\), the pair \((f(u), f(v))\) satisfies JLDistortion \(\varepsilon \; u\; v\).
. \(D\) is unilateral if and only if \(D\) has a spanning directed walk.*
Unilateral means any two vertices are comparable — you can get from one to the other, though perhaps only one way round. It sits strictly between "connected" and "diconnected".
! The book genuinely means walk, not path: revisiting vertices is essential, since a spanning directed path would be a Hamilton path and is a far stronger requirement. The Lean statement accordingly asks only for a Quiver.Path (= directed walk) whose vertices cover \(V\), with no Nodup condition — do not be tempted to add IsDirectedPath.
Let \(A\) be a random \(k \times d\) matrix whose entries are i.i.d. \(\mathcal{N}(0, 1/k)\) (rows mutually independent, entries independent within each row). For any fixed \(x \in \mathbb {R}^d\) and any \(0 \lt \varepsilon \lt 1\),
Let \(k, d \geq 1\) and let \(A\) be the Rademacher matrix \(\mathrm{radMatrix}(k,d)\) on the joint \(\pm 1\) sample space. For every nonzero \(x \in \mathbb {R}^d\) and every \(0 \lt \varepsilon \lt 1\),
This recovers Achlioptas’s \(\pm 1\)-entries variant of Johnson–Lindenstrauss with the Dasgupta–Gupta exponent.
Let \(A : \Omega \to \mathbb {R}^{k \times d}\) be a random matrix on a probability space, and let \(x \in \mathbb {R}^d\) be a nonzero vector. Suppose the \(k\) row projections \((Ax)_i\) are mutually independent, each integrable against \(e^{t(\cdot )}\) for every \(t \in \mathbb {R}\), each has sub-Gaussian MGF bounded by \(\exp \! \bigl((\lVert x\rVert ^2/k)\, t^2/2\bigr)\), and each satisfies \(\int (Ax)_i^2 \, d\mu = \lVert x\rVert ^2/k\). Then for every \(0 \lt \varepsilon \lt 1\),
Let \(A:\Omega \to \mathbb {R}^{k\times d}\) be a random matrix whose row projections \((A\, \omega ).\texttt{toEuclideanLin}\, x\, i\) are measurable, independent across \(i\), and such that each centered squared summand \(((A\, \omega ).\texttt{toEuclideanLin}\, x\, i)^2 - \| x\| ^2/k\) satisfies \(\text{\texttt{ProbabilityTheory.HasBernsteinMGF}}(c, t_{\max })\) for some \(c\gt 0\). For any \(s\ge 0\) with \(s\le 2k\, c\, t_{\max }\),
This theorem makes no assumption on the distribution of the matrix entries beyond the Bernstein MGF condition, giving a general tail bound for the squared-norm distortion.
Let \(A:\Omega \to \mathbb {R}^{k\times d}\) be a random matrix under a probability measure \(\mu \) whose entries \(A_{ij}\) are each \(N(0,1/k)\) and are jointly independent (row entries and row vectors alike). For any fixed \(x\in \mathbb {R}^d\) and \(0\lt \varepsilon \lt 1\),
The proof handles \(x=0\) via concentration_zero and the general case by showing each row projection \(\sum _j A_{ij}\, x_j\) is Gaussian with variance \(\| x\| ^2/k\), establishing independence of row projections via rows_indep, and then applying chi_squared_tail.
If \(f\) is an \(\varepsilon \)-JL embedding of \(V\) (in the squared-distance sense), then for all \(u, v \in V\),
obtained by taking square roots of the JLDistortion bounds.
Given \(0 \lt \varepsilon \), \(n \ge 2\), \(k \ge 32 \log n / \varepsilon ^2\), and \(|V| \le n\), this lemma derives (i) \(k \gt 0\) and (ii) \(|V|^2 \cdot 2\exp (-k\varepsilon ^2/8) \lt 1\), the numerical precondition consumed by both johnson_lindenstrauss_of_gaussian and johnson_lindenstrauss_of_subgaussian.
Suppose each per-pair bad event satisfies \(\Pr [\text{BadSingle}\; \varepsilon \; A\; \cdot ] \le 2\exp (-k\varepsilon ^2/8)\). Then the probability that some ordered pair in \(V \times V\) is distorted is at most
For \(\varepsilon \in \mathbb {R}\), vectors \(u, v \in \mathbb {R}^d\), and their images \(u', v' \in \mathbb {R}^k\), JLDistortion asserts the two-sided squared-distance inequality
If the matrix \(A\) does not trigger the bad-single event for the difference \(u - v\), then JLDistortion \(\varepsilon \; u\; v\; (A.toEuclideanLin\; u)\; (A.toEuclideanLin\; v)\) holds; that is, the squared-distance of the images is within a factor of \((1 \pm \varepsilon )\) of the squared-distance of the originals.
For any \(0 \lt \varepsilon \lt 1\), \(n \ge 2\), \(k \ge 32 \log n / \varepsilon ^2\), and any finite set \(V \subseteq \mathbb {R}^d\) of at most \(n\) points, there exists a linear map \(f : \mathbb {R}^d \to _L \mathbb {R}^k\) that is an \(\varepsilon \)-JL embedding of \(V\), i.e. it satisfies \((1 - \varepsilon )\| u-v\| ^2 \le \| f(u)-f(v)\| ^2 \le (1+\varepsilon )\| u-v\| ^2\) for all \(u, v \in V\).
For any \(0 \lt \varepsilon \lt 1\) and \(n \ge 2\), there exists a threshold \(k_0 \in \mathbb {N}\) such that for every \(k \ge k_0\), every ambient dimension \(d\), and every set \(V \subseteq \mathbb {R}^d\) of at most \(n\) points, an \(\varepsilon \)-JL embedding \(f : \mathbb {R}^d \to _L \mathbb {R}^k\) of \(V\) exists. In particular the target dimension is \(O(\log n / \varepsilon ^2)\).
Under the same hypotheses as johnson_lindenstrauss, there exists a linear map \(f : \mathbb {R}^d \to _L \mathbb {R}^k\) such that for all \(u, v \in V\),
Let \(A\) be a random Gaussian \(k \times d\) matrix as above. If the union-bound failure probability satisfies \(|V|^2 \cdot 2\exp (-k\varepsilon ^2/8) \lt 1\), then there exists a linear map \(f : \mathbb {R}^d \to _L \mathbb {R}^k\) that is an \(\varepsilon \)-JL embedding of \(V\), extracted from the positive-measure good event.
Sub-Gaussian analogue of johnson_lindenstrauss_of_gaussian: the Gaussian entry hypotheses are replaced by the assumptions that each row projection \((Ax)_i\) is sub-Gaussian with parameter \(\| x\| ^2/k\) and has variance exactly \(\| x\| ^2/k\). Under the same failure-probability bound \(|V|^2 \cdot 2\exp (-k\varepsilon ^2/8) \lt 1\), an \(\varepsilon \)-JL embedding of \(V\) is guaranteed to exist; this covers, for instance, Rademacher (\(\pm 1/\sqrt{k}\)) matrices.
Rademacher (\(\pm 1/\sqrt{k}\) entries) analogue of johnson_lindenstrauss: same hypotheses on \(\varepsilon \), \(n\), \(k\), and \(V\), same conclusion—an \(\varepsilon \)-JL embedding of \(V\) exists—but now realized by a Rademacher matrix. The proof uses the sub-Gaussian concentration bound jl_concentration_single_subgaussian (which inherits the Hanson-Wright axiom) and the identical union-bound argument.
Sub-Gaussian (Rademacher) analogue of johnson_lindenstrauss_dim_bound: same threshold \(k_0 = O(\log n / \varepsilon ^2)\), same universal conclusion for all \(k \ge k_0\), \(d\), and \(V\) of size at most \(n\), but inheriting the Hanson-Wright axiom from the sub-Gaussian concentration chain.
Under the same hypotheses as johnson_lindenstrauss_subgaussian, there exists a linear map \(f : \mathbb {R}^d \to _L \mathbb {R}^k\) satisfying the same two-sided distance-ratio bounds as johnson_lindenstrauss_dist, now realized by a Rademacher random matrix.
A joint distribution \(\sigma \) on \(\mathrm{Fin}\, M \times \mathrm{Fin}\, N\) is a nonnegative function \(\sigma _{ij} \ge 0\) satisfying \(\sum _{i,j} \sigma _{ij} = 1\). It represents a correlated distribution over pure action profiles of the two players.
Let \(C\) be a minimum cut of a multigraph \(G\) with \(n = \left\lvert V(G)\right\rvert \ge 4\). Then the telescoping product of per-step survival factors, which represents the probability that none of the \(n-2\) contractions picks a cut edge, is bounded below by
A run of the algorithm on \(G_0\) is indexed by a sequence of edge choices, one for each of the \(\left\lvert V(G_0)\right\rvert - 2\) contraction steps, and produces a multigraph. The current Lean definition is a placeholder that returns \(G_0\); the state-threading version is not yet formalized.
Given a multigraph \(G\) with at least one edge, a step of the algorithm is modelled as a function from an index \(i \in \mathrm{Fin}\, \left\lvert E(G)\right\rvert \) — thought of as a uniformly random edge choice — to the multigraph obtained by contracting the \(i\)-th edge of \(G\).
Let \(S\) be a finite set, \(p\) a decidable predicate, \(f : S \to \mathbb {R}\) and \(B \in \mathbb {R}\) with \(B \le f(x)\) for every \(x \in S\) satisfying \(p\). Then
where terms failing \(p\) contribute \(0\).
The finite set of pairs (edge, occurrence index) obtained from the edge multiset of \(s.G\); the second coordinate distinguishes parallel copies of the same edge, so that a uniform choice on this set is a uniform choice of an edge occurrence.
For a state \(s\) whose distinguished cut is a min-cut of positive size and whose graph has \(n = s.G.\mathrm{vertexCount} \ge 2\) vertices, both of the following hold: the recursive sampling model survives \(n-2\) contractions with probability at least \(2/(n(n-1))\), and every adaptive graph trace of \(n-2\) contractions starting from \(s.G\) ends with a Karger output.
An explicit indexed execution of the contraction loop: a family of graphs indexed by \(\mathbb {N}\), an edge occurrence of the graph at each index below \(\text{steps}\), and the requirement that the next graph is the contraction of the current one along that occurrence. The choice type depends on the current graph, matching the adaptive nature of the process.
The finite probability that the distinguished cut survives the next given number of random edge-occurrence choices, defined by recursion on the number of steps: zero steps have probability \(1\), and one further step averages over all edge occurrences, contributing \(0\) for occurrences that cross the cut and the recursive value at the contracted state otherwise.
For every \(n\) and every state \(s\) whose distinguished cut is a min-cut of positive size, if \(2 \le n\) and \(s.G\) has exactly \(n\) vertices, then the recursive sampling model survives \(n-2\) contractions with probability at least
If the occurrence sample space of \(s\) is nonempty and every surviving branch has recursive survival probability at least \(B\), then the averaged survival probability for one more step satisfies
The unfolding equation: the survival probability for \(\text{steps}+1\) contractions at \(s\) is the average over all edge occurrences of \(s\) of the survival probability for \(\text{steps}\) contractions at the contracted state, with crossing occurrences contributing \(0\).
If \(t\) is reachable from \(s\) by a surviving run and \(s.C\) is a min-cut, then the graph reached after the run still satisfies the handshaking lower bound
The same invariant, with the vertex count after \(n\) contractions written explicitly: for a surviving run of \(n\) steps from \(s\) to \(t\) with \(s.C\) a min-cut,
If \(t\) is reached from \(s\) by a surviving run of \(i\) steps, a further surviving step is possible from \(t\), \(s.C\) is a min-cut, and \(t.G\) has at least two vertices, then with \(n_t = t.G.\mathrm{vertexCount}\),
If a surviving step is possible from \(s\), the distinguished cut \(s.C\) is a min-cut, and \(s.G\) has at least two vertices, then writing \(n = s.G.\mathrm{vertexCount}\),
For an indexed surviving trace of \(n-2\) steps starting from an \(n\)-vertex graph with \(n \ge 2\), initial min-cut, and at least two vertices at every step, the product of the finite uniform edge-choice survival ratios is at least \(2/(n(n-1))\).
If the initial cut is a min-cut and every graph along the first \(\text{steps}\) indices has at least two vertices, then
where \(n_i\) is the vertex count at index \(i\).
For an indexed surviving trace of \(n-2\) steps starting from an \(n\)-vertex graph with \(n \ge 2\), initial min-cut, and at least two vertices at every step,
If the initial cut of an indexed surviving trace is a min-cut, \(i \lt \text{steps}\), and the graph at index \(i\) has at least two vertices, then with \(n_i\) its vertex count,
If \(s.G\) has at least one edge, the uniform survival probability of \(s\) equals \(\mathrm{survivalProb}(s.C.\mathrm{size},\, s.G.\mathrm{edgeCount}) = 1 - c/m\) with \(c = s.C.\mathrm{size}\) and \(m = s.G.\mathrm{edgeCount}\).
(Friedgut, 1998.) Let \(f : \{ 0,1\} ^n \to \{ -1,1\} \) and let \(\varepsilon \gt 0\). Then there are a coordinate set \(J\) and a function \(g\) such that \(\left\lvert J\right\rvert \le 4n\, I[f]/\varepsilon \), the function \(g\) is a \(J\)-junta, and \(\mathbb {E}\big[(f - g)^2\big] \le \varepsilon \).
For every \(f\), every level \(k\) and every \(\tau \gt 0\) there is a function \(g\) that is a junta on the \(\tau \)-influential coordinates \(J_\tau (f)\) and satisfies \(\mathbb {E}\big[(f_{\le k} - g)^2\big] \le n\tau \).
A subspace \(C \le \mathcal{H}_n\) satisfies the Knill–Laflamme condition for \(t\)-error correction if for all Pauli strings \(E,F\) with \(\mathrm{wt}(E),\mathrm{wt}(F) \le t\) there exists \(\lambda _{EF}\in \mathbb {C}\) such that \(P_C\, E^\dagger F\, P_C = \lambda _{EF}\, P_C\), where \(P_C\) is the orthogonal projection onto \(C\).
For naturals \(n\), \(j\), \(x\),
where the subtraction \(n-x\) is natural-number subtraction; the definition gives the intended values for \(x \le n\).
Let \(\mathit{base}, \mathit{rest}\) be edge lists on \(n\) vertices and let \(g, e\) be edges. Suppose that in \(\mathit{base} \mathbin {+\! \! +} \mathit{rest}\) the vertex \(e.u\) reaches \(g.u\) and \(g.v\) reaches \(e.v\). Then every pair \(a, b\) that is reachable in \(\mathit{base} \mathbin {+\! \! +} (g :: \mathit{rest})\) is also reachable in \(\mathit{base} \mathbin {+\! \! +} \mathit{rest} \mathbin {+\! \! +} [e]\); that is, \(g\) may be replaced by \(e\) without losing connectivity.
The same exchange statement with the endpoints of \(g\) taken in the opposite order: if in \(\mathit{base} \mathbin {+\! \! +} \mathit{rest}\) the vertex \(e.u\) reaches \(g.v\) and \(g.u\) reaches \(e.v\), then every pair reachable in \(\mathit{base} \mathbin {+\! \! +} (g :: \mathit{rest})\) is reachable in \(\mathit{base} \mathbin {+\! \! +} \mathit{rest} \mathbin {+\! \! +} [e]\).
Let \(\mathit{base}, S\) be edge lists and let \(e\) be an edge with \(e.u \neq e.v\) whose endpoints are connected in \(\mathit{base} \mathbin {+\! \! +} S\) but not in \(\mathit{base}\) alone. Then there exists an edge \(f \in S\) such that every pair \(a, b\) reachable in \(\mathit{base} \mathbin {+\! \! +} S\) remains reachable in \(\mathit{base} \mathbin {+\! \! +} (S \setminus \{ f\} ) \mathbin {+\! \! +} [e]\), where \(S \setminus \{ f\} \) denotes \(\mathtt{S.erase}\, f\).
For any state \(\mathit{uf}\) and edges \(a, b\), merging the endpoints of \(a\) and then those of \(b\) yields the same partition as merging them in the opposite order: \(\mathtt{SamePartition}\, ((\mathit{uf}.\mathtt{merge}\, a.u\, a.v).\mathtt{merge}\, b.u\, b.v)\, ((\mathit{uf}.\mathtt{merge}\, b.u\, b.v).\mathtt{merge}\, a.u\, a.v)\).
Merging along \(l \mathbin {+\! \! +} [e]\) equals first merging along \(l\) and then merging the endpoints of \(e\): \(\mathit{uf}.\mathtt{mergeAll}\, (l \mathbin {+\! \! +} [e]) = (\mathit{uf}.\mathtt{mergeAll}\, l).\mathtt{merge}\, e.u\, e.v\).
If \(\mathtt{SamePartition}\, \mathit{uf}_1\, \mathit{uf}_2\), then merging both states along the same edge list preserves this: \(\mathtt{SamePartition}\, (\mathit{uf}_1.\mathtt{mergeAll}\, \mathit{edges})\, (\mathit{uf}_2.\mathtt{mergeAll}\, \mathit{edges})\).
Merging along \(e :: S\) gives the same partition as first merging the endpoints of \(e\) and then merging along \(S\): \(\mathtt{SamePartition}\, (\mathit{uf}.\mathtt{mergeAll}\, (e :: S))\, ((\mathit{uf}.\mathtt{merge}\, e.u\, e.v).\mathtt{mergeAll}\, S)\).
Suppose the union–find state \(\mathit{uf}\) represents reachability in a base edge list, i.e. \(\mathit{uf}\, a = \mathit{uf}\, b \leftrightarrow \mathtt{Reach}\, \mathit{base}\, a\, b\) for all \(a, b\). Then after merging along \(\mathit{edges}\),
Starting from the initial union–find state \(\mathtt{UF.init}\, n\), in which every vertex is its own component, two vertices \(a, b\) end up with the same representative after merging along \(\mathit{edges}\) if and only if \(\mathtt{Reach}\, \mathit{edges}\, a\, b\).
If \(\mathit{uf}\, a = \mathit{uf}\, b\), then for any list of weighted edges \(\mathit{edges}\) we still have \((\mathit{uf}.\mathtt{mergeAll}\, \mathit{edges})\, a = (\mathit{uf}.\mathtt{mergeAll}\, \mathit{edges})\, b\); that is, merging never splits vertices that are already in the same component.
\(\mathtt{processEdges}\, \mathit{es}\, \mathit{uf}\, \mathit{acc}\) scans the edge list \(\mathit{es}\) left-to-right: an edge \(e\) is added to the accumulator and its endpoints are merged whenever \(\mathit{uf}.\mathtt{find}\, e.u \ne \mathit{uf}.\mathtt{find}\, e.v\); otherwise \(e\) is skipped. The reversed accumulator is returned when the list is exhausted.
Let \(\mathit{es}\) be a list of weighted edges, \(\mathit{uf}\) a union-find state, \(\mathit{acc}\) an accumulator list, and \(e\) an edge. If \(e \in \mathtt{processEdges}\, \mathit{es}\, \mathit{uf}\, \mathit{acc}\), then \(e \in \mathit{acc}\) or \(e \in \mathit{es}\).
Let \(uf\) be a union–find state whose classes are exactly the reachability classes of a base edge list, and let the input list \(edges\) be sorted by nondecreasing weight. Then for any competing sublist \(S \subseteq edges\) that induces the same partition as \(edges\) does over \(uf\), the greedy output satisfies
If the endpoints of \(e\) lie in different components of \(uf\), then the total weight of the greedy output on \(e :: rest\) equals \(e.\mathrm{weight}\) plus the total weight of the greedy output on \(rest\) started from the merged state \(uf.\mathrm{merge}\, e.u\, e.v\).
For a non-empty edge list \((g :: \mathit{rest})\), \(\mathtt{Reach}\, (g :: \mathit{rest})\, a\, b\) if and only if one of three cases holds: (1) \(\mathtt{Reach}\, \mathit{rest}\, a\, b\); (2) \(\mathtt{Reach}\, \mathit{rest}\, a\, g.u\) and \(\mathtt{Reach}\, \mathit{rest}\, g.v\, b\); or (3) \(\mathtt{Reach}\, \mathit{rest}\, a\, g.v\) and \(\mathtt{Reach}\, \mathit{rest}\, g.u\, b\).
Let \(\mathit{uf}\) be a union–find state, \(e\) an edge, and \(\mathit{rest}, S\) edge lists with every element of \(S\) lying in \(e :: \mathit{rest}\), such that \(\mathit{uf}.\mathtt{mergeAll}\, S\) and \(\mathit{uf}.\mathtt{mergeAll}\, \mathit{rest}\) induce the same partition. If \(e\) is redundant for \(\mathit{uf}\), i.e. \(\mathit{uf}\, e.u = \mathit{uf}\, e.v\), then there exists a list \(S'\) all of whose edges lie in \(\mathit{rest}\), such that \(\mathit{uf}.\mathtt{mergeAll}\, S'\) induces the same partition as \(\mathit{uf}.\mathtt{mergeAll}\, \mathit{rest}\) and \(\mathtt{totalWeight}\, S' \leq \mathtt{totalWeight}\, S\).
Given a list of weighted edges \(\mathit{edges}\) on \(n\) vertices, \(\mathtt{SymAdj}\, \mathit{edges}\, u\, v\) holds when there exists an edge \(e \in \mathit{edges}\) whose endpoints are \(\{ u, v\} \) (in either order), i.e. \((e.u = u \wedge e.v = v) \vee (e.u = v \wedge e.v = u)\).
\(\mathtt{SamePartition}\, \mathit{uf}_1\, \mathit{uf}_2\) holds when two union-find states induce the same equivalence relation on nodes: for all \(i, j : \mathrm{Fin}\, n\), \(\mathit{uf}_1(i) = \mathit{uf}_1(j)\) if and only if \(\mathit{uf}_2(i) = \mathit{uf}_2(j)\).
If \(\mathtt{SamePartition}\, \mathit{uf}_1\, \mathit{uf}_2\) and \(\mathtt{SamePartition}\, \mathit{uf}_2\, \mathit{uf}_3\), then \(\mathtt{SamePartition}\, \mathit{uf}_1\, \mathit{uf}_3\). Together with reflexivity and symmetry, \(\mathtt{SamePartition}\) is an equivalence relation on union–find states.
Let \(\mathit{uf}\) be a union–find state whose classes are exactly the reachability classes of an edge list \(\mathit{base}\), i.e. \(\mathit{uf}\, a = \mathit{uf}\, b\) iff \(a\) and \(b\) are reachable in \(\mathit{base}\). If merging all edges of \(S\) into \(\mathit{uf}\) identifies \(e.u\) and \(e.v\) while \(\mathit{uf}\) itself keeps them apart, then there is an edge \(f \in S\) such that \((\mathit{uf}.\mathtt{merge}\, e.u\, e.v).\mathtt{mergeAll}\, (S \setminus \{ f\} )\) induces the same partition as \(\mathit{uf}.\mathtt{mergeAll}\, S\).
The union–find structure obtained by running the greedy loop over a list of weighted edges: starting from a state \(uf\), each edge \(e\) is merged into the state when its endpoints \(e.u\) and \(e.v\) currently lie in different components, and is ignored otherwise. Unlike \(\texttt{Kruskal.processEdges}\) it returns only the final state, not the list of accepted edges.
For every edge list and every initial state \(uf\), the state \(\texttt{Kruskal.ufAfterProcessEdges}\) produces induces the same partition of the vertices as merging all the edges unconditionally, i.e. it has the same partition as \(uf.\mathrm{mergeAll}\) applied to the whole list.
A \(\texttt{LearnerPolicy}\ N\) is a deterministic online strategy for a learner interacting with \(N\) experts: it provides a weight function \(\mathrm{weights} : (t : \mathbb {N}) \to \texttt{LossHistory}\ N\ t \to \mathrm{Fin}\, N \to \mathbb {R}\) together with proofs that the weights are nonnegative and sum to one, so that the weight vector at each round forms a valid mixed strategy.
The combined absorption step: for \(c_{\mathrm{top}}\) of depth at least \(1\) (with \(0 \lt l\)) over \(\mathrm{Layer2Data}\) gates having width-\(l\) DNF and CNF representations, there are a new \(\mathrm{Layer2Data}'\) of width at most \(l\) and a circuit \(c_{\mathrm{top}}'\) of depth at most \(\mathrm{depth}\, c_{\mathrm{top}} - 1\) computing the same function. This dispatches to the depth-1 case (giving depth \(0\)) and the general case (giving depth at most \(1\)).
Let \(c_{\mathrm{top}}\) have depth exactly \(1\) over the gates of some \(\mathrm{Layer2Data}\), where (with \(0 \lt l\)) each gate has a width-\(l\) DNF and CNF representation. Then there is a new \(\mathrm{Layer2Data}'\) of width at most \(l\) and a circuit \(c_{\mathrm{top}}'\) of depth \(0\) over it computing the same function as \(c_{\mathrm{top}}\) over the original gates.
The \(\mathrm{Layer2Data}\) wrapper of the general depth reduction: for \(c_{\mathrm{top}}\) of depth at least \(2\) (with \(0 \lt l\)) over gates having width-\(l\) DNF and CNF representations, there are a new \(\mathrm{Layer2Data}'\) of width at most \(l\) and a circuit \(c_{\mathrm{top}}'\) of depth at most \(\mathrm{depth}\, c_{\mathrm{top}} - 1\) computing the same function.
For \(\sum _i \mathrm{layer\_ size}(i)\le s\) with \(0\lt s\) and \(0\lt \varepsilon \), if each per-stage bound satisfies \(\mathrm{per\_ stage\_ bound}(i)\le (\mathrm{layer\_ size}(i))\cdot (1/2)^{\log _2(2s/\varepsilon )}\), then \(\sum _i \mathrm{per\_ stage\_ bound}(i)\le \varepsilon /2\). This packages the union bound over all \(d-2\) iterations as a purely arithmetic consequence of the per-stage bounds.
Given a family of \(\mathrm{DNF}\) gates and a restriction \(\rho \) under which every gate satisfies \(\mathrm{dtDepth}(\mathrm{gates}_i|_\rho )\le l\), every gate can be replaced by a \(\mathrm{CNF}\) of width at most \(l\) computing \(\mathrm{gates}_i|_\rho \) on all inputs.
If every child \(c \in cs\) satisfies \(\mathrm{dtDepth}(\mathrm{restrictFn}\, c.\mathrm{eval}\, \rho ) \le l\), then there is a CNF \(\psi \) of width at most \(l\) that computes the restriction of the AND node: \(\mathrm{CNF.eval}\, \psi \, x = \mathrm{restrictFn}\, (\mathrm{eval}\, (\mathrm{node}\, \mathrm{true}\, cs))\, \rho \, x\) for all \(x\).
If each restricted gate \(\mathrm{restrictFn}\, (\mathrm{gates}\, i).\mathrm{eval}\, \rho _1\) has decision-tree depth \(\le l\), then there is a CNF \(\Psi \) of width \(\le l\), with nodup and variable-injective clauses, whose evaluation equals the AND over all gates of their restricted evaluations.
Consider an AND node \(\mathrm{Circuit.node}\, \mathrm{true}\, cs\) whose children are all literals, where each gate function has a width-\(l\) DNF and a width-\(l\) CNF representation. Then the function computed by the node has a width-\(l\) CNF \(\psi \) with \(\mathrm{CNF.eval}\, \psi \, x = (\mathrm{Circuit.node}\, \mathrm{true}\, cs).\mathrm{eval}\, (\lambda i,\ \mathrm{gates}\, i\, x)\) for all \(x\).
If \(f\) and \(g\) agree pointwise, then for any \(p\in \mathbb {R}\) and \(t\in \mathbb {N}\) the Bernoulli restriction probabilities of the events \(\{ \rho : \mathrm{dtDepth}(\mathrm{restrictFn}\, f\, \rho ) \gt t\} \) and \(\{ \rho : \mathrm{dtDepth}(\mathrm{restrictFn}\, g\, \rho ) \gt t\} \) are equal.
For every Boolean function \(f\), threshold \(t\), and parameters \(p_1, p_2 \in (0,1]\), the probability that the restricted depth exceeds \(t\) under the stronger Bernoulli restriction of parameter \(p_1 p_2\) is at most that under parameter \(p_1\):
For \(0\le p\le 1\), a list of circuits \(\mathit{cs}\), and a predicate \(\mathrm{bad}\) on circuits and restrictions, the probability that some circuit in \(\mathit{cs}\) is bad is bounded by the folded sum of the per-circuit probabilities \(\sum _{c\in \mathit{cs}}\Pr _{p}[\mathrm{bad}\, c]\).
For \(0\le p\le 1\) and finitely many events \(A_0,\dots ,A_{m-1}\) on restrictions, the Bernoulli\((p)\) probability that some \(A_i\) holds is at most the sum of the individual probabilities:
The Bernoulli restriction weight of \(\rho \) at parameter \(p\) equals the product over all coordinates \(i\) of the per-variable weights:
For any flag \(\mathit{isAnd}\), arity \(k\), and sign family \(\mathit{signs} : \mathrm{Fin}\, k \to \mathrm{Bool}\), there is a circuit \(c'\) of depth at most \(1\) that equals the node \(\mathrm{Circuit.node}\, \mathit{isAnd}\) over the literals \(\mathrm{Circuit.lit}\, \langle j, \mathit{signs}\, j\rangle \), evaluating identically on every input assignment \(g\).
A circuit \(c_j\) of depth at most \(1\) over gates that each have a width-\(l\) DNF and CNF representation admits a width-\(l\) DNF \(\varphi \) together with a sign bit such that, for all \(x\), the signed evaluation \(\big(\mathrm{if}\ \mathit{sign}\ \mathrm{then} \varphi .\mathrm{eval}\, x\ \mathrm{else}\ \neg \varphi .\mathrm{eval}\, x\big)\) equals \(c_j.\mathrm{eval}\, (\lambda i,\ \mathrm{gates}\, i\, x)\); moreover the terms of \(\varphi \) are duplicate-free with no repeated variable.
The Boolean function on \(\mathrm{Fin}\, n \to \mathrm{Bool}\) computed by a subcircuit \(c_{\mathrm{sub}}\) when each of its inputs \(i\) is replaced by the gate function \(\mathrm{gates}\, i\), namely \(x \mapsto c_{\mathrm{sub}}.\mathrm{eval}\, (\lambda i,\ \mathrm{gates}\, i\, x)\).
Replacing the coefficient \(s-1\) by \(s\) in the previous bound: under the same hypotheses and the parameter \(\mathrm{composedDelta}(w,l,d)\),
The user-facing form of the iterative reduction: for \(f\) computed by a circuit of depth at most \(d\ge 2\), size at most \(s\), and fan-in at most \(w\), under \(\mathrm{composedDelta}(w,l,d)\),
For a depth-3 circuit in normal form (AND of \(s_2\) width-\(w\) DNF gates, with \(w,l \gt 0\), \(n \gt 0\)), under the composed Bernoulli\((\mathrm{composedDelta}\, w\, l\, 3) = \mathrm{Bernoulli}(1/(40w) \cdot 1/(40l))\) restriction, writing \(p_1 = 1/(40w)\) and \(p_2 = 1/(40l)\),
For a depth-3 circuit in normal form, if \(l\) and \(t\) are chosen so that \(s_2 (1/2)^l \le \varepsilon /2\) and \((1/2)^t \le \varepsilon /2\), then under the composed Bernoulli\((\mathrm{composedDelta}\, w\, l\, 3)\) restriction (with \(p_1 = 1/(40w)\), \(p_2 = 1/(40l)\)),
The exponential tails vanish as \(n \to \infty \), so the bound is \(\le \varepsilon \) asymptotically.
By strong induction on the depth \(d\ge 2\): if \(f\) is computed by a circuit of depth at most \(d\), size at most \(s\), and fan-in at most \(w\) (with \(s,w,l,n\gt 0\)), then under \(\mathrm{composedDelta}(w,l,d)\),
The base case (\(d=2\)) of the inductive bound: if \(f\) is computed by a depth-\(2\) circuit of size at most \(s\) and fan-in at most \(w\) (with \(s,w,l\gt 0\) and \(n\gt 0\)), then under the composed restriction parameter \(\mathrm{composedDelta}(w,l,2)\),
The inductive step: for depth \(d\ge 3\), assuming the bound holds for depth \(d-1\) (the hypothesis \(\mathit{ih}\) applied to each child of the root), a circuit of depth at most \(d\), size at most \(s\), and fan-in at most \(w\) satisfies, under \(\mathrm{composedDelta}(w,l,d)\),
Summing the product \(\mathrm{bernoulliRestrWeight}\, p\, \rho _1 \cdot \mathrm{bernoulliRestrWeight}\, q\, \rho _2\) over all pairs \((\rho _1, \rho _2)\) that compose to \(\sigma \) equals the Bernoulli weight of \(\sigma \) at parameter \(pq\):
Given two restrictions \(\rho _1, \rho _2\) on \(n\) variables, their composition is the restriction that on each coordinate \(i\) uses the value fixed by \(\rho _1\) if there is one, and otherwise the value given by \(\rho _2\). This models applying \(\rho _1\) first and then \(\rho _2\) on the variables left free by \(\rho _1\).
Suppose \(0 \lt l\), \(0 \lt n\), and every child \(c \in cs\) satisfies \(\mathrm{dtDepth}(\mathrm{restrictFn}\, c.\mathrm{eval}\, \rho _1) \le l\). Then under a further Bernoulli random restriction \(\rho _2\) with parameter \(1/(40 l)\), the probability that the restricted node \(\mathrm{restrictFn}\, (\mathrm{eval}\, (\mathrm{node}\, \mathit{isAnd}\, cs))\, (\mathrm{composeRestr}\, \rho _1\, \rho _2)\) has decision-tree depth greater than \(t\) is at most
Let an AND gate have a list of children, each of which computes a function expressible by a CNF of width at most \(\ell \). Then the AND of all children is itself computed by a single CNF of width at most \(\ell \), namely the concatenation of the children’s clause lists. This collapses the AND layer and the CNF layer into one.
Dual to the AND case: if an OR gate has children each expressible by a DNF of width at most \(\ell \), then the OR of all children is computed by a single DNF of width at most \(\ell \), obtained by concatenating the children’s term lists.
For a non-contradictory term \(t\) (i.e. \(\mathrm{termHasContradiction}\, t = \texttt{false}\)), de-duplication does not change the conjunction value: \(\mathrm{Term.eval}\, (\mathrm{dedupTermVar}\, t)\, x = \mathrm{Term.eval}\, t\, x\) for all \(x\).
If \(f\) is computed by a circuit of depth at most \(2\), size at most \(s\), and fan-in at most \(w\), then for a Bernoulli parameter \(p\) with \(0\lt p\le 1/(40w)\) and \(p\le 1\),
Converts a list of children \(cs\) of a top AND gate (of depth \(\le 2\)) into a CNF: each literal child becomes a singleton clause, each OR child becomes the clause of its literals, and each AND child contributes the singleton clauses of its literals.
If the top AND node \(\mathrm{node}\, \texttt{true}\, cs\) has depth at most \(2\), then the CNF \(\mathrm{depth2AndToCNF}\, cs\) computes the same Boolean function as the circuit: \(\mathrm{CNF.eval}\, (\mathrm{depth2AndToCNF}\, cs)\, x = (\mathrm{node}\, \texttt{true}\, cs).\mathrm{eval}\, x\) for all \(x\).
If the top AND node \(\mathrm{node}\, \texttt{true}\, cs\) has depth at most \(2\), the resulting CNF has width at most the maximum fan-in of the circuit: \(\mathrm{CNF.width}\, (\mathrm{depth2AndToCNF}\, cs) \le (\mathrm{node}\, \texttt{true}\, cs).\mathrm{maxFanin}\).
Converts a list of children \(cs\) of a top OR gate (of depth \(\le 2\)) into a DNF: each literal child becomes a singleton term, each AND child becomes the term of its literals, and each OR child contributes the singleton terms of its literals.
If the top OR node \(\mathrm{node}\, \texttt{false}\, cs\) has depth at most \(2\), then the DNF \(\mathrm{depth2OrToDNF}\, cs\) computes the same Boolean function as the circuit: \((\mathrm{depth2OrToDNF}\, cs).\mathrm{eval}\, x = (\mathrm{node}\, \texttt{false}\, cs).\mathrm{eval}\, x\) for all \(x\).
If the top OR node \(\mathrm{node}\, \texttt{false}\, cs\) has depth at most \(2\), the resulting DNF has width at most the maximum fan-in of the circuit: \((\mathrm{depth2OrToDNF}\, cs).\mathrm{width} \le (\mathrm{node}\, \texttt{false}\, cs).\mathrm{maxFanin}\).
Given \(s_2\) DNF gates each of width \(\le w\) (with \(w \gt 0\), non-degenerate and duplicate-free terms) and \(n \gt 0\), for any \(0 \lt p \le 1/(40w)\) the Bernoulli\((p)\) random restriction satisfies, with probability at least \(1 - s_2\bigl((1/2)^l + \exp (-np/3)\bigr)\), that there exists a CNF \(\Psi \) of width \(\le l\) whose evaluation equals the AND of the restricted gates. This is the depth-3 to depth-2 compression step.
Suppose \(f\) is the AND of the gates (\(f(x) = \mathrm{true}\) iff every gate is true at \(x\)) and each restricted gate has decision-tree depth \(\le l\). Then there is a CNF \(\Psi \) of width \(\le l\), with nodup and variable-injective clauses, whose evaluation equals \(\mathrm{restrictFn}\, f\, \rho _1\).
Suppose \(f\) is the AND of the gates and, under the first-stage restriction \(\rho _1\), each restricted gate has decision-tree depth \(\le l\) (with \(l \gt 0\), \(n \gt 0\)). Then for any \(0 \lt p_2 \le 1/(40l)\) the second-stage Bernoulli\((p_2)\) restriction satisfies \(\Pr _{\rho _2}[\mathrm{dtDepth}(\mathrm{restrictFn}\, f\, (\mathrm{composeRestr}\, \rho _1\, \rho _2)) \gt t] \le (1/2)^t + \exp (-np_2/3)\).
Let \(f\) be the AND of \(s_2\) DNF gates each of width \(\le w\) (with \(w,l \gt 0\), non-degenerate and duplicate-free terms, \(n \gt 0\)). For \(0 \lt p_1 \le 1/(40w)\) and \(0 \lt p_2 \le 1/(40l)\), the composed Bernoulli\((p_1 p_2)\) restriction satisfies
For every Boolean function \(f\) and restrictions \(\rho _1, \rho _2\), restricting by the composed restriction can only decrease decision-tree depth: \(\mathrm{dtDepth}(f|_{\rho _1 \circ \rho _2}) \le \mathrm{dtDepth}(f|_{\rho _1})\).
Given a decision tree \(T\) and a partial assignment \(\rho \), the restricted tree \(\mathrm{dtRestrict}\, T\, \rho \) is obtained by collapsing every branch whose query variable is fixed by \(\rho \) into the corresponding subtree, and keeping unrestricted branches intact.
For every decision tree \(T\), restriction \(\rho \), and input \(x\), the restricted tree evaluates as \((\mathrm{dtRestrict}\, T\, \rho ).\mathrm{eval}(x) = T.\mathrm{eval}(\mathrm{extend}\, \rho \, x)\), where \(\mathrm{extend}\, \rho \, x\) fills in the unset coordinates of \(\rho \) using \(x\).
For a circuit \(c\) of depth at least \(1\) (with \(0 \lt l\)) over gates that each have a width-\(l\) DNF representation with duplicate-free, non-repeating-variable terms and a width-\(l\) CNF representation, there exist a fresh gate family \(\mathrm{gates}'\) of such width-\(l\) DNFs and a circuit \(c'\) of depth at most \(\mathrm{depth}\, c - 1\) computing the same function as \(c\).
A circuit \(c\) of depth exactly \(1\) over gates with width-\(l\) DNF and CNF representations collapses to a single signed gate: there exist a width-\(l\) DNF \(\varphi \) (with duplicate-free, non-repeating-variable terms) and a sign bit whose signed evaluation equals \(c.\mathrm{eval}\, (\lambda i,\ \mathrm{gates}\, i\, x)\) for all \(x\).
A circuit \(c\) of depth exactly \(2\) over gates with width-\(l\) DNF and CNF representations reduces to a circuit \(c'\) of depth at most \(1\) over a fresh gate family \(\mathrm{gates}'\) of width-\(l\) DNFs (with duplicate-free, non-repeating-variable terms), so that \(c\) and \(c'\) compute the same function on every \(x\).
For any CNF \(\psi \) there exists a CNF \(\psi '\) of width \(\le \) that of \(\psi \), evaluating identically to \(\psi \) on every input, with no duplicate literals in any clause and with each clause variable-injective. Hence every CNF can be cleaned to satisfy the switching lemma hypotheses.
Given layer sizes summing to at most \(s\), if each per-layer quantity is bounded by \(\mathrm{layerSize}(i)\cdot \alpha \) (with \(\alpha \ge 0\)) and a final term is bounded by \(\beta \), then the total \(\sum _i \mathrm{per\_ layer}(i) + \mathrm{final}\) is at most \(s\cdot \alpha +\beta \).
Let \(c\) be a circuit on \(n\) variables with \(n \gt 0\), depth at most \(d\), size at most \(s\), and fan-in at most \(w\), where \(d \ge 2\) and \(s, w, l \gt 0\). Under a Bernoulli(\(\delta \)) random restriction \(\rho \) with \(\delta = \mathrm{composedDelta}\, w\, l\, d\), the probability that the restricted function has decision-tree depth exceeding \(t\) is bounded by
The exponential Chernoff tails vanish as \(n \to \infty \).
Under the same hypotheses as the previous theorem, fix \(\varepsilon \gt 0\) and \(s_2\gt 0\), and suppose \(n\) is large enough that \(\exp \! \bigl(-\tfrac {np}{3}\bigr)\le \tfrac {\varepsilon }{s_2}\). Then the probability under a Bernoulli\((p)\) restriction \(\rho \) that some layer-2 gate fails to admit a width-\(l\) \(\mathrm{CNF}\) representation of \(\mathrm{gates}_i|_\rho \) is at most
Let \(\mathrm{gates}_0,\dots ,\mathrm{gates}_{s_2-1}\) be the layer-2 \(\mathrm{DNF}\) gates, each of width at most \(w\gt 0\) (with distinct variables per term and no duplicate literals), let \(n\gt 0\), and let \(0\lt p\le \tfrac {1}{40w}\) with \(p\le 1\). Then the probability under a Bernoulli\((p)\) restriction \(\rho \) that some gate fails to admit a width-\(l\) \(\mathrm{CNF}\) representation of \(\mathrm{gates}_i|_\rho \) is at most
Base case (\(d_{\mathrm{inner}} = 2\)) of the composed layer-2 bound. Here the top circuit \(c_{\mathrm{top}}\) has depth \(0\), hence is a single literal, so the composed function is one DNF gate or its negation. Under a Bernoulli random restriction with parameter \(\mathrm{composedDelta}\, l\, l\, 2\), the probability that the restricted function has decision-tree depth exceeding \(t\) is at most
under the hypotheses \(0 \lt l\), \(0 \lt n\), \(c_{\mathrm{top}}.\mathrm{depth}+2\le 2\), \(c_{\mathrm{top}}.\mathrm{size}\le s_{\mathrm{rem}}\), \(\mathrm{data.width}\le l\), and \(0 \lt s_{\mathrm{rem}}\).
A bundle describing the second layer of a circuit over \(n\) variables: a number of gates, a family of DNF formulas indexed by the gates, a common width bound \(\mathrm{width}\gt 0\) such that every gate’s width is at most \(\mathrm{width}\), together with the hypothesis that within each term of each gate distinct literals have distinct variables.
Given a list \(cs\) of circuits each of depth at most \(1\), over gates with width-\(l\) DNF and CNF representations, there are families \(\varphi _s\) of width-\(l\) DNFs (with duplicate-free, non-repeating-variable terms) and signs indexed by \(\mathrm{Fin}\, cs.\mathrm{length}\) such that, for each index \(j\), the signed evaluation of \(\varphi _s\, j\) matches \((cs.\mathrm{get}\, j).\mathrm{eval}\, (\lambda i,\ \mathrm{gates}\, i\, x)\) on every \(x\).
Flattens a list of lists \([\, \ell _1, \ell _2, \dots \, ]\) into the single list \(\ell _1 \mathbin {+\! \! +} \ell _2 \mathbin {+\! \! +} \cdots \), defined by recursion on the outer list. Used to merge the clause (or term) lists of several CNFs (or DNFs).
Given gate arrays \(g_1 : \mathrm{Fin}\, m_1 \to \alpha \) and \(g_2 : \mathrm{Fin}\, m_2 \to \alpha \), the merged array \(\mathrm{mergeGates}\, g_1\, g_2 : \mathrm{Fin}\, (m_1+m_2) \to \alpha \) takes its values from \(g_1\) on indices \(0,\dots ,m_1-1\) and from \(g_2\) on indices \(m_1,\dots ,m_1+m_2-1\).
If over \(m\) stages each failure bound satisfies \(\mathrm{failure\_ bound}(i)\le (\mathrm{layer\_ size}(i))\cdot \alpha \) with \(\alpha \ge 0\), and \(\sum _i \mathrm{layer\_ size}(i)\le s\), then \(\sum _i \mathrm{failure\_ bound}(i)\le s\cdot \alpha \).
If each re-indexed child \(\mathrm{new\_ cs}\, j\) evaluated at \(g'\) agrees with the original child \(cs.\mathrm{get}\, j\) evaluated at \(g\), then the node over \(cs\) at \(g\) equals the node over \((\mathrm{List.finRange}\, cs.\mathrm{length}).\mathrm{map}\, \mathrm{new\_ cs}\) at \(g'\), for the same flag \(\mathit{isAnd}\).
For layer-2 data and a Bernoulli parameter \(p\) with \(0\lt p\le 1/(40\cdot \mathrm{width})\) and \(p\le 1\), the probability that it fails that every gate’s restricted function is computed by some width-\(l\) CNF is at most
For layer-2 data and a Bernoulli parameter \(p\) with \(0\lt p\le 1/(40\cdot \mathrm{width})\) and \(p\le 1\), the probability that some gate’s restricted function has decision-tree depth greater than \(l\) is at most
Let \(c\) be a circuit on \(n\) variables with \(n \gt 0\), depth at most \(d\), size at most \(s\), and fan-in at most \(w\), where \(d \ge 2\) and \(s, w, l \gt 0\). Fix \(\varepsilon \gt 0\) and naturals \(l, t\) with \(s \cdot \left(\tfrac {1}{2}\right)^l \le \varepsilon /2\) and \(\left(\tfrac {1}{2}\right)^t \le \varepsilon /2\). Then under a Bernoulli(\(\mathrm{composedDelta}\, w\, l\, d\)) restriction \(\rho \),
The exponential tails vanish as \(n \to \infty \), giving \(\Pr \le \varepsilon \) asymptotically.
Under a Bernoulli restriction with \(p \le 1/(40w)\) on \(s_2\) width-\(w\) DNF gates, the probability that every restricted gate has decision-tree depth at most \(\ell \) is at least \(1 - s_2 \cdot \left( (1/2)^{\ell } + \exp (-np/3) \right)\).
For \(s_2\) layer-2 DNF gates of width at most \(w\) (with the usual no-duplicate-variable and nodup hypotheses on terms) and a Bernoulli restriction with parameter \(p \le 1/(40w)\), the probability that some gate fails to admit a width-\(\ell \) CNF representation of its restriction is at most \(s_2 \cdot \left( (1/2)^{\ell } + \exp (-np/3) \right)\).
Combining Steps 6 and 7: after a Bernoulli restriction with \(p \le 1/(40w)\) on \(s_2\) width-\(w\) DNF gates, the probability that every restricted gate admits a width-\(\ell \) CNF representation is at least \(1 - s_2 \cdot \left( (1/2)^{\ell } + \exp (-np/3) \right)\), so that the compression of Step 6 applies and the circuit reduces to depth \((d-1)\) with width at most \(\ell \).
If every child \(c \in cs\) satisfies \(\mathrm{dtDepth}(\mathrm{restrictFn}\, c.\mathrm{eval}\, \rho ) \le l\), then there is a DNF \(\varphi \) of width at most \(l\) that computes the restriction of the OR node: \(\mathrm{DNF.eval}\, \varphi \, x = \mathrm{restrictFn}\, (\mathrm{eval}\, (\mathrm{node}\, \mathrm{false}\, cs))\, \rho \, x\) for all \(x\).
Consider an OR node \(\mathrm{Circuit.node}\, \mathrm{false}\, cs\) whose children are all literals, where each gate function has a width-\(l\) DNF and a width-\(l\) CNF representation. Then the function computed by the node also has a width-\(l\) DNF \(\varphi \) with \(\varphi .\mathrm{eval}\, x = (\mathrm{Circuit.node}\, \mathrm{false}\, cs).\mathrm{eval}\, (\lambda i,\ \mathrm{gates}\, i\, x)\) for all \(x\).
Given a list \(cs\) of circuits where each child \(cs.\mathrm{get}\, j\) has been reduced to a circuit \(c_j\) of depth at most \(\mathrm{bound}\, j\) over its own width-\(l\) DNF gate family, this combines all the per-child gate families into a single merged family \(\mathrm{merged}\) indexed by \(\mathrm{Fin}\, M\), with re-indexed circuits \(\mathrm{new\_ cs}\, j\) of depth at most \(\mathrm{bound}\, j\) that reproduce each child’s function.
For a circuit \(c\) on \(m_1\) gates and Boolean gate values \(g_1, g_2\), reindexing \(c\) along the left embedding \(\mathrm{castAdd}\, m_2\) and evaluating against the merged array yields the original evaluation: \((\mathrm{reidx}\, c\, (\mathrm{castAdd}\, m_2)).\mathrm{eval}\, (\mathrm{mergeGates}\, g_1\, g_2) = c.\mathrm{eval}\, g_1\).
For a circuit \(c\) on \(m_2\) gates and Boolean gate values \(g_1, g_2\), reindexing \(c\) along the right embedding \(\mathrm{natAdd}\, m_1\) and evaluating against the merged array yields the original evaluation: \((\mathrm{reidx}\, c\, (\mathrm{natAdd}\, m_1)).\mathrm{eval}\, (\mathrm{mergeGates}\, g_1\, g_2) = c.\mathrm{eval}\, g_2\).
For a Boolean function \(f\) and restrictions \(\rho _1,\rho _2\), restricting \(f\) by the composition \(\rho _1 \circ \rho _2\) equals first restricting by \(\rho _1\) and then by \(\rho _2\): \(\mathrm{restrictFn}\, f\, (\mathrm{composeRestr}\, \rho _1\, \rho _2) = \mathrm{restrictFn}\, (\mathrm{restrictFn}\, f\, \rho _1)\, \rho _2\).
For a Boolean function \(f\) and restrictions \(\rho _1,\rho _2\), restricting by the composed restriction equals restricting by \(\rho _1\) and then by \(\rho _2\):
If \(f,g:(\mathrm{Fin}\, n\to \{ 0,1\} )\to \{ 0,1\} \) agree pointwise, i.e. \(f(x)=g(x)\) for all \(x\), then for every restriction \(\rho \) the restricted functions coincide: \(\mathrm{restrictFn}\, f\, \rho = \mathrm{restrictFn}\, g\, \rho \).
Restricting the pointwise AND of a list of functions equals the pointwise AND of the restricted functions: for all \(x\), \(\mathrm{restrictFn}\, (\mathrm{listAnd}\, fs)\, \rho \, x = \mathrm{listAnd}(fs.\mathrm{map}\, (\lambda f.\ \mathrm{restrictFn}\, f\, \rho ))\, x\).
The restriction of the evaluation of a node circuit equals the conjunction or disjunction, according to \(\mathit{isAnd}\), of the restricted evaluations of its children. That is, \(\mathrm{restrictFn}\, (\mathrm{eval}\, (\mathrm{node}\, \mathit{isAnd}\, cs))\, \rho \) sends \(x\) to the fold-\(\mathrm{and}\) over \(cs\) of \(\mathrm{restrictFn}\, c.\mathrm{eval}\, \rho \, x\) when \(\mathit{isAnd}\) is true, and to the corresponding fold-\(\mathrm{or}\) otherwise.
For \(0 \lt p \le 1\), \(0 \lt q \le 1\) and any event on restrictions, the Bernoulli(\(pq\)) probability of the event equals the weighted average, over Bernoulli(\(p\)) restrictions \(\rho _1\), of the Bernoulli(\(q\)) probability that the event holds after composing with \(\rho _1\):
This says a Bernoulli(\(p\)) restriction followed by a Bernoulli(\(q\)) restriction on the remaining free variables has the same distribution as a single Bernoulli(\(pq\)) restriction.
For \(0 \lt p \le 1\) and \(0 \lt q \le 1\), the Bernoulli(\(pq\)) probability of an event is at most the Bernoulli(\(p\)) probability that some \(\rho _2\) makes the event hold after composition:
For \(s \in \mathbb {N}\) with \(0 \lt s\) and \(\varepsilon \in \mathbb {R}\) with \(0 \lt \varepsilon \), taking \(l = \log _2(2s/\varepsilon )\) gives
since \(2^{-l} = \varepsilon /(2s)\).
Under the same hypotheses, a Bernoulli\((p)\) restriction \(\rho \) leaves every one of the \(s_i\) width-\(\le l\) gates with restricted function of decision-tree depth at most \(l\), with probability at least \(1-s_i\cdot \bigl((1/2)^l+\exp (-np/3)\bigr)\). This is the decision-tree-depth form of the one-step bound applied with width \(l\).
Let \(g_1,\dots ,g_{s_i}\) be width-\(\le l\) DNFs on \(n\) variables (with \(0\lt l\), \(0\lt n\)), and let \(0\lt p\le 1/(40l)\) with \(p\le 1\). Under a Bernoulli\((p)\) random restriction \(\rho \), the probability that some restricted gate fails to be representable by a width-\(\le l\) CNF agreeing with it pointwise is at most \(s_i\cdot \bigl((1/2)^l+\exp (-np/3)\bigr)\). This is the one-step reduction bound applied with width parameter \(l\).
Suppose for each gate \(i\) the restricted function \(\mathrm{restrictFn}\, (\mathrm{gates}\, i).\mathrm{eval}\, \rho _1\) has decision-tree depth at most \(l\). Then there exist DNFs \(\mathrm{gates}'\) such that each \((\mathrm{gates}'\, i)\) has width at most \(l\), evaluates to the corresponding restricted gate function on every input, and is clean: within each term every literal is determined by its variable (injectivity on variables) and each term has no duplicate literals.
If, after applying a restriction \(\rho \), every gate function \(\mathrm{restrictFn}\, (\mathrm{gates}\, i).\mathrm{eval}\, \rho \) has decision-tree depth at most \(l\), then each gate admits both a width-\(l\) DNF representation (whose terms are duplicate-free and contain no two literals on the same variable) and a width-\(l\) CNF representation, each computing the same function.
Let \(f\) be a CNF of width at most \(w\) with \(0\lt w\) and \(0\lt n\), and let \(p\in \mathbb {R}\) satisfy \(0\lt p\), \(p\le \tfrac {1}{40w}\) and \(p\le 1\). Then for every \(t\in \mathbb {N}\),
again without any non-duplication hypothesis on \(f\).
Let \(f\) be a DNF of width at most \(w\) with \(0\lt w\) and \(0\lt n\), and let \(p\in \mathbb {R}\) satisfy \(0\lt p\), \(p\le \tfrac {1}{40w}\) and \(p\le 1\). Then for every \(t\in \mathbb {N}\),
Unlike the base version, no syntactic non-duplication hypothesis is required, since the formula is first cleaned.
For any function \(f\) with decision-tree depth \(\le w\) (with \(w \gt 0\), \(n \gt 0\)) and any \(0 \lt p \le 1/(40w)\), the Bernoulli\((p)\) restriction satisfies \(\Pr _\rho [\mathrm{dtDepth}(\mathrm{restrictFn}\, f\, \rho ) \gt t] \le (1/2)^t + \exp (-np/3)\). This is the switching lemma stated at the level of functions rather than formulas.
Let \(g\) be a \(\mathrm{DNF}\) of width at most \(w\gt 0\) (with distinct variables per term and no duplicate literals), let \(n\gt 0\), and let \(0\lt p\le \tfrac {1}{40w}\) with \(p\le 1\). Then the probability under a Bernoulli\((p)\) restriction \(\rho \) that \(g|_\rho \) cannot be expressed as a \(\mathrm{CNF}\) of width at most \(l\) is at most
The dual statement. Let \(g\) be a \(\mathrm{CNF}\) of width at most \(w\gt 0\) (with distinct variables per clause and no duplicate literals), let \(n\gt 0\), and let \(0\lt p\le \tfrac {1}{40w}\) with \(p\le 1\). Then the probability under a Bernoulli\((p)\) restriction \(\rho \) that \(g|_\rho \) cannot be expressed as a \(\mathrm{DNF}\) of width at most \(l\) is at most
Let \(\mathrm{gates}_0,\dots ,\mathrm{gates}_{s-1}\) be \(s\) many \(\mathrm{DNF}\)s, each of width at most \(w\gt 0\) (with distinct variables per term and no duplicate literals), let \(n\gt 0\), and let \(0\lt p\le \tfrac {1}{40w}\) with \(p\le 1\). Then the probability under a Bernoulli\((p)\) restriction \(\rho \) that some gate \(\mathrm{gates}_i\) has \(\mathrm{dtDepth}(\mathrm{gates}_i|_\rho ) \gt l\) is at most
Let \(0 \lt p_1,p_2 \le 1\), let \(E\) be an event on restrictions and \(A\) a “failure” event, and let \(\beta \ge 0\). If for every \(\rho _1\) with \(\lnot A(\rho _1)\) the conditional probability \(\Pr _{p_2}[E(\mathrm{composeRestr}\, \rho _1\, \rho _2)] \le \beta \), then \(\Pr _{p_1 p_2}[E] \le \Pr _{p_1}[A] + \beta \).
Let \(p_1,p_2\in (0,1]\), let \(E\) and \(A\) be predicates on restrictions, and let \(\beta \ge 0\). If for every \(\rho _1\) with \(\neg A(\rho _1)\) the conditional probability \(\Pr _{p_2}[E(\mathrm{composeRestr}\, \rho _1\, \rho _2)]\le \beta \), then
For \(0\le p\le 1\) and \(0\le q\le 1\), and decidable events \(A,B\) on restrictions,
where the inner event combines \(A\) on the first-stage restriction with \(B\) on the second-stage restriction. This bounds the failure of a composed two-stage Bernoulli restriction by the sum of the two individual stage probabilities.
For parameters \(p, q \in \mathbb {R}\) and any outcome \(c\), summing the products \(\mathrm{varWeight}\, p\, a \cdot \mathrm{varWeight}\, q\, b\) over all pairs \((a,b)\) whose composition equals \(c\) gives \(\mathrm{varWeight}\, (pq)\, c\):
\(\texttt{LossHistory}\ N\ t\) is the type of length-\(t\) histories of loss vectors for \(N\) experts: it is the function type \(\mathrm{Fin}\, t \to \mathrm{Fin}\, N \to \mathbb {R}\), recording all loss vectors that have been revealed in the past \(t\) rounds.
Given a history \(h : \texttt{LossHistory}\ N\ t\), \(\text{\texttt{LossHistory.toLossSeq}}\ h\) coerces it to a \(\texttt{LossSeq}\ N\ t\), enabling the reuse of definitions and theorems from the pathwise Hedge formalization that are stated over finite loss sequences.
A loss sequence \(\ell \) for \(N\) experts over \(T\) rounds is a function \(\ell : \mathrm{Fin}\, T \to \mathrm{Fin}\, N \to \mathbb {R}\), i.e., at each round \(t \lt T\) the adversary reveals a loss vector \(\ell _t : \mathrm{Fin}\, N \to \mathbb {R}\) whose values are intended to lie in \([0,1]\).
The probability that the \((d{+}1)\)-fold derivative test accepts \(f\):
If \(d \ge 2\) and \(f : \{ 0,1\} ^n \to \{ 0,1\} \) is \(\varepsilon \)-far from degree \(\le d\), then there exists \(\delta \ge \varepsilon \) such that for every \(h \in \{ 0,1\} ^n\) there exists a Boolean function \(g\) of degree \(\le d{-}1\) with \(\operatorname{dist}(\Delta _h f, g) \ge \delta \). Intuitively, the multiplicative derivative \(\Delta _h f(x) = f(x) \oplus f(x \oplus h)\) is on average far from degree \(\le d{-}1\).
If \(d \ge 1\) and \(f\) is \(\varepsilon \)-far from degree \(\le d\), then there exists a constant \(c \gt 0\) such that \(\| (-1)^f\| _{U^{d+1}}^{2^{d+1}} \le 1 - c\varepsilon \). For \(d = 1\) one may take \(c = 2\); the case \(d \ge 2\) follows by induction using the derivative distance lemma (BKSSZ 2010).
For \(f : \{ 0,1\} ^n \to \mathbb {R}\), base point \(x \in \{ 0,1\} ^n\), and direction vectors \(h_1, \ldots , h_k \in \{ 0,1\} ^n\), the order-\(k\) Gowers product is defined recursively:
It averages \(f\) over the \(2^k\) vertices of the combinatorial cube \(x + \mathrm{span}\{ h_1,\ldots ,h_k\} \).
If \(g\) has degree \(\le d\), then for any \(f\), \(\mathrm{GP}(f \cdot g, d{+}1, x, h_1,\ldots ,h_{d+1}) = \mathrm{GP}(f, d{+}1, x, h_1,\ldots ,h_{d+1})\): multiplying by a low-degree function does not change the \((d{+}1)\)-fold Gowers product.
For any \(f\), \(k \ge 0\), \(x\), and direction vectors \(h_1,\ldots ,h_{k+1}\), the Gowers product unfolds as
A function \(f : \{ 0,1\} ^n \to \mathbb {R}\) has degree \(\le d\) if all its \((d{+}1)\)-fold multiplicative derivatives vanish: for every \(x\) and every \(h_1,\ldots ,h_{d+1}\), \(\mathrm{GP}(f, d{+}1, x, h_1,\ldots ,h_{d+1}) = 1\).
Let \(k \gt 0\), \(n \ge 2\), and let \(\delta , \varepsilon \in (0,1]\). Let \(L\) be a normal form \((3,\delta ,\varepsilon )\)-decodable code with message length \(k\) and block length \(n\), whose parameters are \(\delta \) and \(\varepsilon \). Then there is a constant \(C \gt 0\) with
Placeholder — the statement carries no lower-bound content. The constant \(C\) is quantified after \(k\), \(n\), \(\delta \), \(\varepsilon \) and the code \(L\), so it may depend on all of them; the Lean proof takes \(C = (k^3\varepsilon ^{16}\delta ^{16} + 1)/(n\log ^6 n)\), which satisfies the displayed inequality for every choice of parameters. The intended Theorem 9.1 of Alrabiah–Guruswami–Kothari–Manohar requires an absolute \(C\), quantified before the instance, and would yield \(n = \Omega (k^3/\log ^6 k)\); that theorem is not formalised here, and this entry must not be cited as a formalisation of it.
Let \(X : \Omega \to \mathbb {R}\) be measurable with \(X_*\mu = N(0,\sigma _0)\). Then for any constant \(c\in \mathbb {R}\),
This is an auxiliary restatement of gaussianReal_map_const_mul phrased for easy application in the inductive step of sum_scaled_iid_gaussian_map.
For the adjacency matrix this says: however you pick a starting and finishing vertex, there is a directed walk of some common length \(k\) between them. Corollary 10.7 characterises when a tournament’s matrix is primitive — exactly when the tournament is diconnected with \(\nu \ge 4\). Primitivity is what licenses Perron–Frobenius, which gives the convergence of the iterated score vectors \(s_{i} = A^{i}J\) used to rank the players.
! Missing from Mathlib (0 hits). Stated for Matrix n n \(\mathbb {N}\) rather than the book’s real matrices, since the only instance needed is the adjacency matrix; \(0 \lt (R ^k) i j\) is then the entrywise positivity \(R^{k} \gt 0\). Note Mathlib’s Matrix order is not entrywise by default, which is why the positivity is spelled pointwise.
"Full" means as large as the matrix allows — for a \((\nu -1) \times \varepsilon \) basis matrix of the bond space, the square submatrices of order \(\nu - 1\). Theorem 12.3 says such a basis matrix is unimodular, and that is exactly what makes theorem 12.4’s determinant count the spanning trees: each nonsingular full submatrix contributes \((\pm 1)^{2} = 1\).
! Not Matrix.IsTotallyUnimodular, which quantifies over all square submatrices — that is B&M’s strictly stronger totally unimodular of exercise 12.2.3, stated separately below. "Full square submatrix" is rendered as M.submatrix id g for an injective \(g : n \to m\): all rows, and card n columns chosen injectively. Placed in the Matrix namespace so it reads B.IsUnimodular.
Fact 4.1 (Tropp 2015, Theorem 4.1.1), stated abstractly through the bounding quantity it produces: for \(k \gt 0\), a variance proxy \(\sigma ^2 \gt 0\) and dimensions \(d_1, d_2 \gt 0\) there is a constant \(C_{\mathrm{MK}} \gt 0\) with
This is the bound the Khintchine inequality supplies for \(\mathbb {E}\bigl[\lVert \sum _i b_i X_i\rVert _2\bigr]\) when the \(b_i\) are i.i.d. uniform signs and \(\sigma ^2 = \max \bigl(\lVert \sum _i X_i X_i^{\mathsf T}\rVert _2, \lVert \sum _i X_i^{\mathsf T} X_i\rVert _2\bigr)\).
Placeholder. No matrices, random signs, or spectral norms appear in the Lean statement: it asserts only that some positive real lies below the stated square root, and is discharged by taking that square root itself. It records the shape of the Khintchine bound for downstream use and does not formalise Tropp’s inequality. It must not be cited as a formalisation of that inequality.
For any measurable map \(A : \Omega \to \mathrm{Matrix}(\mathrm{Fin}\, k, \mathrm{Fin}\, d,\mathbb {R})\), fixed \(x \in \mathbb {R}^d\), and \(\varepsilon \in \mathbb {R}\), the set \(\{ \omega \mid \text{BadSingle}\; \varepsilon \; (A\, \omega )\; x\} \) is measurable. The key step is that each coordinate map \(\omega \mapsto (A\, \omega \cdot \text{toEuclideanLin}\; x)_i\) is measurable, hence so is the squared norm.
For any finite zero-sum game \(G\) with at least \(2\) row actions and any \(\varepsilon \gt 0\), there exist mixed strategies \(p, q\) such that for all pure \(i, j\),
This is the same guarantee as approx_minimax, stated in the \(\forall \varepsilon \gt 0, \exists p, q\) form.
A mixed strategy over \(n\) actions is a record consisting of a weight function \(w : \mathrm{Fin}\, n \to \mathbb {R}\) together with proofs that every weight is non-negative and that the weights sum to \(1\), i.e. \(w\) is a probability distribution over \(\mathrm{Fin}\, n\).
(Moon, 1966). *Each vertex of a diconnected tournament \(D\) with \(\nu \ge 3\) is contained in a directed \(k\)-cycle, \(3 \le k \le \nu \).*
A digraph with this property is vertex-pancyclic: every vertex lies on cycles of every possible length. Taking \(k = \nu \), every diconnected tournament has a directed Hamilton cycle — first proved by Camion (1959). Theorem 10.7 consumes the full strength, needing cycles of several specific lengths through a given vertex.
The cycle is based at \(u\) (p : Path u u), which is how "\(u\) is contained in" is expressed. ! The book’s final splice \((v_{0}, v, w, v_{2}, \dots , v_n)\) silently assumes \(v\) follows \(v_{0}\) and \(w\) precedes \(v_{2}\); check the index bookkeeping against \(n \ge 3\) before trusting it.
If \(e \in E(G)\) does not cross the cut \(C\), then \(C\) induces a cut of the contracted multigraph \(G/e\): the vertex side is the image of \(S\) after merging the endpoints of \(e\), and both nonemptiness conditions continue to hold because \(e\) has both endpoints on the same side.
The multiset of edges of \(G\) that cross the cut \(C\), i.e. those edges having exactly one endpoint in \(S\), counted with multiplicity. It is obtained by filtering the edge multiset by the condition that exactly one of the two representative endpoints lies in \(S\).
A multigraph on a vertex type \(\alpha \) consists of a finite vertex set together with a multiset of unordered pairs (elements of \(\mathrm{Sym}_2\, \alpha \)) as edges, subject to two conditions: every endpoint of every edge is a live vertex, and no edge is a self-loop (edges are loopless, since loops are deleted after each contraction).
Given an edge \(e \in E(G)\) with endpoints \(u\) and \(v\), the contracted multigraph \(G/e\) is obtained by replacing every occurrence of \(v\) by \(u\) in all edges, deleting the resulting self-loops (in particular all parallel copies of \(e\)), and removing \(v\) from the vertex set. Parallel edges between the merged vertex and the rest of the graph are retained with multiplicity.
Given three Boolean values \(a, b, c\) (the truth values of a clause’s three literals) and an index \(k \in \mathrm{Fin}\, 3\), returns the color in \(\mathrm{Fin}\, 3\) assigned to the \(k\)-th internal clause-gadget node. The coloring is chosen so that all three gadget nodes receive distinct colors whenever \((a, b, c)\) is a NAE-satisfying assignment; if the assignment is not NAE-satisfying, all gadget nodes are colored \(0\).
Given a NAE-SAT instance \(\mathit{clauses}\), the directed edge relation on \(\texttt{NAEtoColor.OutputVertex}\; V\) is defined by: (1) \(\mathtt{groundNode}\) is adjacent to every \(\mathtt{varNode}\); (2) \(\mathtt{varNode}\; v\) is adjacent to \(\mathtt{clauseNode}\; c\; i\) when \(v\) is the \(i\)-th variable of clause \(c\); (3) two clause-gadget nodes \(\mathtt{clauseNode}\; c\; i\) and \(\mathtt{clauseNode}\; c\; j\) are adjacent when \(c \in \mathit{clauses}\) and \(i \neq j\) (forming a triangle within each clause gadget). All other pairs are non-adjacent.
Given a Boolean assignment \(\mathit{assign} : V \to \mathtt{Bool}\), defines a coloring of all vertices of the reduction graph by: \(\mathtt{groundNode} \mapsto 0\); \(\mathtt{varNode}\; v \mapsto 1\) if \(\mathit{assign}(v) = \mathtt{true}\), else \(2\); \(\mathtt{clauseNode}\; c\; k \mapsto \texttt{NAEtoColor.clauseNodeColor}\; (\mathit{assign}(c.v_0))\; (\mathit{assign}(c.v_1))\; (\mathit{assign}(c.v_2))\; k\).
If a NAE-SAT instance \(f\) over variable type \(V\) is satisfiable, then the reduction graph \(\texttt{NAEtoColor.ReductionGraph}\; f\) is 3-colorable. Concretely, any satisfying assignment yields the proper coloring \(\texttt{NAEtoColor.naeColoring}\).
For any NAE-SAT instance \(f\) over variable type \(V\),
This is the main reduction theorem, combining completeness and soundness.
If the reduction graph \(\texttt{NAEtoColor.ReductionGraph}\; f\) is 3-colorable, then the NAE-SAT instance \(f\) is satisfiable. The assignment is recovered by comparing each variable-node color to the “true” color (ground color \(+1 \pmod{3}\)); the triangle gadgets within each clause force the three variable colors to be not all equal, yielding a NAE-satisfying assignment.
The vertex set of the reduction graph is an inductive type with three constructors:
\(\mathtt{groundNode}\) — a single ground vertex (colored “neutral”);
\(\mathtt{varNode}\; v\) — one vertex per variable \(v \in V\);
\(\mathtt{clauseNode}\; c\; k\) — three internal gadget vertices (\(k \in \mathrm{Fin}\, 3\)) for each clause \(c\).
Given a NAE-SAT instance \(f\), \(\texttt{NAEtoColor.ReductionGraph}\; f\) is the simple graph on \(\texttt{NAEtoColor.OutputVertex}\; V\) whose adjacency is the symmetrization of \(\texttt{NAEtoColor.EdgeRelation}\; f\) restricted to distinct pairs (no self-loops).
Given a Boolean assignment \(\mathit{assign} : V \to \mathtt{Bool}\) and a Not-All-Equal clause \(c\) with three variables \(c.v_0, c.v_1, c.v_2\), \(\texttt{NAEtoColor.SatisfiesClause}\) returns \(\mathtt{true}\) if and only if the three assigned values are not all equal, i.e. at least two of \(\mathit{assign}(c.v_0)\), \(\mathit{assign}(c.v_1)\), \(\mathit{assign}(c.v_2)\) differ.
Given an assignment \(\mathit{assign} : V \to \mathtt{Bool}\) and a NAE-SAT instance \(f\), \(\texttt{NAEtoColor.SatisfiesNAE3}\) returns \(\mathtt{true}\) if and only if every clause in \(f\) is satisfied by \(\mathit{assign}\) (i.e. \(\texttt{NAEtoColor.SatisfiesClause}\) holds for each clause).
For every \(s\in \mathbb {R}\) with \(|s|\le 1/4\),
This inequality is the Taylor-based analytic core of the centered chi-squared MGF bound; it is proved by showing that the auxiliary function \(h(u)=u^2+u+\log (1-u)\) satisfies \(h(0)=0\) and has non-negative derivative on \([0,1/2]\) and non-positive derivative on \([-1/2,0]\).
Make every street two-way. B&M call it a simple trick: it is how theorems 11.5 and 11.7 are deduced from their directed counterparts 11.4 and 11.6, since paths in \(G\) correspond exactly to directed paths in \(D(G)\).
One line — G.Adj is already symmetric, so it is the arc relation. A local copy of chapter 10’s SimpleGraph.associatedDigraph; the path correspondence that makes the trick work is that file’s associatedDigraph_pathEquiv, which is itself sorry-bodied there.
High connectivity forces any prescribed set of \(k\) vertices onto a single cycle. For \(k = 2\) this is corollary 3.2.1 — in a 2-connected graph any two vertices lie on a common cycle. One of the classic applications of Menger’s theorem, illustrating B&M’s remark that *many results on graphs turn out to be easy consequences* of max-flow min-cut.
Depends on exercise 11.4.3, hence on two sorry-bodied definitions; but note the statement here mentions none of them — it is about Walk/IsCycle only, so it is well-formed and would be meaningful once its dependency is repaired. Among the §11.4 items, this is the one whose statement is already honest.
The size of the undirected edge cut at \(S\) — how many edges would have to be severed to separate \(S\) from the rest. In exercise 11.5.5(a) it is the capacity available to carry the imbalance the prescribed indegrees force across \(S\)’s boundary.
A double sum of indicators rather than a Finset.card, matching the shape of fOut/capOf so the three compare directly. Since G.Adj is symmetric and the sum runs over \(S \times S^{c}\), each crossing edge is counted once.
Corollary 11.5 relates it to edge-disjoint paths: \(G\) is \(k\)-edge-connected exactly when any two distinct vertices are joined by \(k\) edge-disjoint paths — the global connectivity number turned into a local path count.
A minimal local copy; the real one lives in TCSlib.GraphTheory.Connectivity, deliberately not imported so this file stands alone. ! sInf \(\emptyset \) = 0, so a graph with no edge cut (a one-vertex graph) gets \(\kappa ' = 0\) — a boundary case that will bite corollary 11.5 exactly as it bit chapter 10’s associatedDigraph_isKArcConnected_iff.
*If \(N\) contains no \(f\)-incrementing path, then there is a cut \(K\) with val f = cap K.*
The constructive core of theorem 11.2’s converse: the cut built from the \(f\)-unsaturated reachability set has capacity exactly val f.
* This has to be extracted separately because theorem 11.2’s statement asserts only maximality and discards the cut, while theorem 11.3 needs the cut itself. Fill this one first and derive theorem 11.2’s converse from it, rather than the other way round — otherwise the reachability construction has to be written twice.
(assumed silently by the book).
Nothing deep: finitely many flows, so a best one. Worth stating separately because corollary 11.1 and theorem 11.3 both open by invoking it, and because the zero flow is the only reason the set is nonempty.
Step 1 is where the \(\mathbb {N}\)-valued \(f\) and finite \(V\) pay off; note theorem 11.1’s bound is not needed — finiteness alone suffices, which is simpler than the book’s implicit reasoning and avoids the \(X\)/\(x\) defect.
(assumed silently by the book).
Finitely many subsets, at least one of them a cut, so a cheapest one.
! Step 1 needs N.x \(\ne \) N.y, which the Network structure does not provide — hdisj separates \(X\) from \(Y\) but says nothing about \(x\) and \(y\). This is a smaller instance of the structural gap recorded in the Network docstring, and the same repair (\(hx\), \(hy\) tying \(x\), \(y\) to \(X\), \(Y\)) supplies it, since hdisj then forces \(x \ne y\). Without it the statement is false for a network with \(x = y\), where no cut exists.
Whatever leaves the producers must arrive at the consumers. This is what makes val f well defined — the two natural ways to measure throughput agree, and the book defines val f as the first only after asserting they coincide.
Step 4’s \(f^{+}(S) = f^{-}(S^{c})\) is worth an explicit simp lemma; it recurs throughout the chapter. Step 3 is where N.hdisj is spent.
A feasible flow exists exactly when, for every way of splitting the vertices, the capacity available for shipping into \(\bar{S}\) covers the net demand there — the demand of the sinks in \(\bar{S}\) less whatever supply already sits inside \(\bar{S}\). Necessity is obvious (that much material must cross the boundary); the content is sufficiency.
! Steps 3–4 use corollary 11.1 and theorem 11.3, both currently false for want of the N.X = {N.x} link — though note \(N'\) is built with a genuine single source and sink, so the repair is satisfied there; the defect bites only if one tries to apply those results to \(N\) itself. Step 1’s construction is the largest single piece of work in §11.5.
Equal sums (11.16) are necessary — both count the edges — but not sufficient, as \(p = q = (5,4,4,2,1)\) shows. Condition (11.18) adds that the \(k\) largest demands can actually be met: each \(x_{i}\) can supply at most min{p\(_{i}\), k} of them, having only \(p_{i}\) edges and only \(k\) targets.
Matrix form. Let \(B*\) have its first \(p_{i}\) entries of row \(i\) equal to \(1\), and let \(p*\) be its column sums — the conjugate of \(p\) (that of \((5,4,4,2,1)\) is \((5,4,3,3,1)\)). Row \(i\) contributes min{p\(_{i}\), k} to \(\sum _{j\le k} p*_{j}\), so (11.18) says exactly \(\sum _{j\le k} p*_{j} \ge \sum _{j\le k} q_{j}\) — the conjugate of \(p\) dominates \(q\). Due to Ryser (1957).
The chapter’s hardest item. \(k\) is a Fin n and the book’s \(1 \le k \le n\) becomes k.val + 1 in the min, so check the off-by-one against the book when filling. The \((0,1)\)-matrix carrier is used rather than a bipartite-graph predicate; see RealisableBipartite.
The paths share only their endpoints. This is the notion in which Menger’s vertex theorem 11.7 and corollary 11.7 are phrased, and — via the vertex splitting of theorem 11.6 — it is what arc-disjointness in the split digraph corresponds to.
A minimal local copy (the repo’s is TwoConnected.lean:58), stated for a pair of walks. ! Menger’s theorem needs internal disjointness of a whole family; extending this pairwise predicate to families is part of what maxInternallyDisjointPaths must do, and is one reason that count was stubbed.
The standard "weak duality certifies optimality" argument, the exact analogue of lemma 5.3 for matchings and coverings. It is what makes the labelling method self-verifying: when the algorithm stops it produces a matching flow and cut, and their equality proves both optimal.
The minimum cuts form a lattice. A consequence is that there is a unique smallest minimum cut and a unique largest one, which is useful algorithmically.
Unaffected by the \(X\)/\(x\) defect — the argument is entirely about capOf and IsCut, never about val. Step 2 is a good candidate to prove first and independently.
Make every edge one-way so each vertex ends up receiving exactly \(m\) arrows, or exactly \(n\). Since \(G\) is \((m+n)\)-regular, indegree \(m\) forces outdegree \(n\) and conversely, so an orientation splits the vertices into two classes. Exercise 11.5.5(a) characterises orientability by a cut condition, and (b) shows the classes can always be rebalanced one step towards each other.
! Missing from Mathlib (0 hits for "orientable"). The orientation is spelled out inline as a Digraph D with three clauses — \(D \subseteq G\), \(D\) never two-way, \(D\) covers every edge — rather than reusing chapter 10’s IsOrientationOf, which this file does not import. The fourth clause is the indegree condition. Note the \((m+n)\)-regularity is not part of this definition; it appears as a hypothesis on the theorems that use it.
An \((m+n)\)-regular graph is to be oriented so every indegree is \(m\) or \(n\). The partition names in advance which vertices get which, and the inequality is a feasibility condition in Gale’s sense.
! Step 2 needs an eulerian orientation, which comes from chapters 4 and 10 (every graph with all degrees even has an Euler tour; orient along it) — a genuine import, absent from this file. Note \((m+n)\)-regular forces every degree even only when \(m + n\) is even, so the eulerian step may itself need the odd-degree patch of chapter 10’s exercise 10.1.10. The absolute value is written as a two-sided bound to avoid abs and keep the arithmetic in \(\mathbb {Z}\).
The two permitted indegrees can always be moved one step closer together. Iterating, an \((m,n)\)-orientable graph is \((m',n')\)-orientable for every admissible pair with \(m' + n' = m + n\) and \(|m' - n'| \le |m - n|\) — in particular the most balanced orientation is always available.
A short deduction given part (a), which is the starred and substantial half. Step 2’s "scales down" should be checked at the sign: the bound is two-sided, so both directions shrink only because \(|m - n - 2| \le |m - n|\) when \(m - n \ge 1\).
\(k\)-connectivity says no \(k - 1\) vertices disconnect the graph; theorem 11.7 converts the local separation number for a nonadjacent pair into a path count, and minimising over pairs converts global into local.
! B&M call this immediate; it is not — step 2 is genuine work, and the \(k = 2\) case alone is a full proof in the repo (TwoConnected.lean:537). Uses the local vertexConnectivity, whose \(\nu - 1\) fallback for complete graphs interacts with step 2 (a complete graph has only adjacent pairs), so check that boundary. h : k + 1 \(\le \) card V is the book’s \(\nu \ge k + 1\).
\(k\)-edge-connectedness says no \(k - 1\) edges disconnect the graph; by theorem 11.5 the minimum number of edges separating a specific pair equals the maximum number of edge-disjoint paths between them. Minimising over pairs converts the global statement into the local one. This is the edge form of Menger’s theorem quoted without proof in §3.2, generalising exercise 3.2.1 (\(k = 2\)) to all \(k\).
Uses the local edgeConnectivity copy. ! Watch the sInf \(\emptyset \) = 0 boundary flagged there: on a one-vertex graph no edge cut exists, so edgeConnectivity = 0, while the right-hand side is vacuously true for every \(k\) (there is no pair \(u \ne v\)). So the \(\leftrightarrow \) fails at \(k \ge 1\), card V \(\le \) 1 — a [Nontrivial V] hypothesis is the fix, exactly as in chapter 10’s associatedDigraph_isKArcConnected_iff.
The left-hand side of Menger’s arc theorem 11.4: how many routes from \(x\) to \(y\) can run simultaneously without any two sharing an arc.
! sorry body. Repair: sSup over \(k\) admitting \(k\) pairwise arc-disjoint directed \((x,y)\)-paths. Needs a directed-path notion (Digraph.IsDirectedPath in the ch-10 file) and an arc-list, which is arcsOf there — itself sorry-bodied. Of the twelve, this is the one with the deepest dependency.
The left-hand side of Menger’s edge theorem 11.5, the undirected counterpart of theorem 11.4.
! sorry body — definable today. Repair: sSup {k | \(\exists \) ps : Fin k \(\to \) G.Walk x y, (\(\forall \) i, (ps i).IsPath) \(\land \) \(\forall \) i j, i \(\ne \) j \(\to \) List.Disjoint (ps i).edges (ps j).edges}. Every ingredient (Walk, IsPath, Walk.edges, List.Disjoint) is already imported.
If the sink cannot be reached at all, nothing can be shipped and nothing needs to be cut.
! Step 4 uses theorem 11.1, so it inherits the \(X\)/\(x\) defect recorded in the Network docstring; with the repair N.X = {N.x} it goes through. The hypothesis is phrased with ReflTransGen over positive-capacity arcs rather than as "no directed \((x,y)\)-path", which is the same thing and needs no path API.
B&M stress the analogy: *the rôle played by incrementing paths in flow theory is analogous to that of augmenting paths in matching theory* — compare Berge’s theorem 5.1.
Note steps 2–4 are exactly where IncPath being a walk rather than a path is convenient: \(S\) is a reachability closure, and closure under fwd and back is immediate for walks. ! Step 5 uses theorem 11.1 and corollary 11.1, so it inherits the \(X\)/\(x\) defect.
Theorem 11.1 gave the easy half — val f \(\le \) cap K for every flow and cut; this says the bound is always achieved, so the bottleneck is not merely an upper limit but the exact answer. B&M call it *of central importance in graph theory: many results on graphs turn out to be easy consequences of this theorem as applied to suitably chosen networks*, as §§11.4 and 11.5 demonstrate with Menger’s theorems and the Gale–Ryser criterion.
The labelling method (Ford and Fulkerson, 1957), which the constructive proof yields: start from the zero flow and repeatedly grow an \(f\)-unsaturated tree from \(x\), until either it reaches \(y\) (breakthrough, giving an incrementing path to revise along) or it stops growing (certifying maximality by theorem 11.2). B&M note it is not a good algorithm — figure 11.9 gives a network needing \(2m + 1\) iterations for arbitrary \(m\) — but Edmonds and Karp (1970) showed that scanning "first-labelled first-scanned", i.e. always taking a shortest incrementing path, makes it good.
Steps 1–4 are all already-stated results, so this theorem is five lines once its inputs are filled — but it sits at the top of the dependency chain and inherits every defect below it, including the sorry-bodied \(\iota \) and revisedFlow via step 2.
The right-hand side of Menger’s arc theorem 11.4: how few arcs must be cut to sever \(x\) from \(y\) entirely.
! sorry body. Repair: sInf {k | \(\exists \) Z : Finset (V \(\times \) V), Z.card = k \(\land \) \(\lnot \) Relation.ReflTransGen (fun u v => D.Adj u v \(\land \) (u,v) \(\notin \) Z) x y}.
— reachability suffices.
The right-hand side of Menger’s edge theorem 11.5.
! sorry body — definable today. Repair: sInf {k | \(\exists \) F : Finset (Sym2 V), F.card = k \(\land \) \(\lnot \) (G.deleteEdges ↑F).Reachable x y}. deleteEdges and Reachable are already imported.
The "fan" or set-to-set form of Menger’s theorem, where the endpoints are not fixed but merely constrained to lie in prescribed sets. This is the form exercise 11.4.4 (Dirac) actually consumes.
! sorry body — definable today. Repair: sSup over \(k\) admitting \(k\) paths, each with one end in \(S\) and one in \(T\), pairwise vertex-disjoint (not merely internally disjoint — the endpoints must differ too, which is why this is not a special case of maxInternallyDisjointPaths). A \(\Sigma \)-typed family Fin k \(\to \) \(\Sigma \) u \(\in \) S, \(\Sigma \) v \(\in \) T, G.Walk u v handles the varying endpoints.
The number of independent routes you can run equals the number of links an adversary must cut to stop you. This is the first of the four Menger theorems the chapter derives — arc/edge and vertex versions, for digraphs and graphs — two of which were quoted without proof back in §3.2.
! Steps 2 and 3 are not free: the network-level counts (Network.maxArcDisjointPaths) and the digraph-level ones (maxArcDisjointDirectedPaths) are separate stubbed definitions, so once both are repaired a lemma identifying them across the construction of step 1 will be needed. Defining the network-level pair in terms of the digraph-level pair applied to the underlying digraph would make steps 2–3 definitional and is the better design.
! The hypothesis \(\lnot \) D.Adj x y is load-bearing: an arc \((x, y)\) cannot be destroyed by deleting intermediate vertices, so without it the right-hand side would be unattainable while the left is at least \(1\).
! Step 1 must contend with splitDigraph splitting \(x\) and \(y\) as well, contrary to the book — see that definition’s docstring. Concretely, a \(D'\)-path from inr x to inl y never traverses \(x\)’s or \(y\)’s corridor, so the correspondence is unharmed; but that fact needs stating rather than assuming.
The most quoted form of Menger’s theorem, and the one §3.2 announced without proof. The number of independent routes between two stations equals the number of intermediate stations an adversary must destroy to sever them — the vertex analogue of max-flow min-cut duality, specialising at \(k = 2\) to Whitney’s theorem 3.2.
Note step 2 is genuinely easier than the corresponding step of theorem 11.5, so this is the better of the two undirected Menger theorems to attempt first.
The left-hand side of Menger’s arc theorem 11.4: how many routes from \(x\) to \(y\) can run simultaneously without any two sharing an arc.
! sorry body. Repair: sSup over \(k\) admitting \(k\) pairwise arc-disjoint directed \((x,y)\)-paths. Needs a directed-path notion (Digraph.IsDirectedPath in the ch-10 file) and an arc-list, which is arcsOf there — itself sorry-bodied. Of the twelve, this is the one with the deepest dependency.
The left-hand side of Menger’s edge theorem 11.5, the undirected counterpart of theorem 11.4.
! sorry body — definable today. Repair: sSup {k | \(\exists \) ps : Fin k \(\to \) G.Walk x y, (\(\forall \) i, (ps i).IsPath) \(\land \) \(\forall \) i j, i \(\ne \) j \(\to \) List.Disjoint (ps i).edges (ps j).edges}. Every ingredient (Walk, IsPath, Walk.edges, List.Disjoint) is already imported.
The "fan" or set-to-set form of Menger’s theorem, where the endpoints are not fixed but merely constrained to lie in prescribed sets. This is the form exercise 11.4.4 (Dirac) actually consumes.
! sorry body — definable today. Repair: sSup over \(k\) admitting \(k\) paths, each with one end in \(S\) and one in \(T\), pairwise vertex-disjoint (not merely internally disjoint — the endpoints must differ too, which is why this is not a special case of maxInternallyDisjointPaths). A \(\Sigma \)-typed family Fin k \(\to \) \(\Sigma \) u \(\in \) S, \(\Sigma \) v \(\in \) T, G.Walk u v handles the varying endpoints.
The left-hand side of Menger’s vertex theorem 11.6 — routes sharing no intermediate vertex, so destroying any one interior station leaves the others intact.
! sorry body. Repair: as for the arc version but with internal-vertex disjointness, which needs only the paths’ vertex lists (Quiver.Path.vertices), not arcsOf — so it is easier than maxArcDisjointDirectedPaths.
The left-hand side of Menger’s vertex theorem 11.7 — the form quoted back in §3.2, where it generalises Whitney’s theorem 3.2 from \(k = 2\) to all \(k\).
! sorry body — definable today. Repair: as maxEdgeDisjointPaths but with \(\forall \) i j, i \(\ne \) j \(\to \) InternallyDisjoint (ps i) (ps j), using the local pairwise InternallyDisjoint above.
A transportation network: goods are produced at the sources, consumed at the sinks, and shipped along the arcs, each with a maximum throughput.
! Missing from Mathlib (0 hits for flow/network/capacity). Capacity is carried as a function cap : V \(\to \) V \(\to \) \(\mathbb {N}\), with cap u v = 0 encoding "no arc \(u \to v\)"; this makes \(f^{+}\)/\(f^{-}\) plain Finset.sums. ! It cannot represent parallel arcs, which is a real restriction — lemma 11.4 is about a network in which every arc has unit capacity, and B&M’s digraphs may have several arcs between the same pair.
The structure carries both \(X\), \(Y\) (the source/sink sets of §11.1) and the distinguished \(x\), \(y\) used from §11.2 onward. That is because the book reduces the first to the second: *adjoin two new vertices \(x\) and \(y\); join \(x\) to each vertex in \(X\) by an arc of capacity \(\infty \); join each vertex in \(Y\) to \(y\) by an arc of capacity \(\infty \); designate \(x\) as the source and \(y\) as the sink of \(N'\)* — after which *throughout the next three sections, we shall confine our attention to networks that have a single source \(x\) and a single sink \(y\)*. That reduction is exercise 11.1.4, which is deferred here (it needs an \(\mathbb {N}\infty \)-capacity parallel carrier), so the two are simply both recorded in the structure.
! Structural defect: \(x\), \(y\) are unrelated to \(X\), \(Y\). Nothing in the structure requires N.x \(\in \) N.X, let alone N.X = {N.x}. But val is defined over the set \(X\) while every §11.2–§11.3 result is about cuts separating the single \(x\) from the single \(y\). The two therefore measure different things, and lemma 11.1, theorem 11.1 in both forms, corollary 11.1 and theorem 11.3 are all false as stated.
Counterexample (one network refutes all of them). \(V = {x_{1}, x_{2}, y_{1}}\), \(X = {x_{1}, x_{2}}\), \(Y = {y_{1}}\), N.x = x\(_{1}\), N.y = y\(_{1}\); capacities \(c(x_{1},y_{1}) = c(x_{2},y_{1}) = 1\) and \(0\) elsewhere. Then \(I = \emptyset \), so any \(f\) within capacity is a flow; take \(f(x_{1},y_{1}) = f(x_{2},y_{1}) = 1\). val f = f\(^{+}\)(X) - f\(^{-}\)(X) = 2. \(S = {x_{1}}\) is a cut (\(x_{1} \in S\), \(y_{1} \notin S\)), with \(f^{+}(S) - f^{-}(S) = 1\) and cap S = 1. So lemma 11.1 asserts \(2 = 1\); theorem 11.1 asserts \(2 \le 1\). Max flow value is \(2\), minimum cut capacity is \(1\), so theorem 11.3 asserts \(2 = 1\). Corollary 11.1 fails too: \(f'(x_{1},y_{1}) = 1\), \(f'(x_{2},y_{1}) = 0\) has val f’ = 1 = cap{x\(_{1}\)}, yet \(f'\) is not a maximum flow.
The repair is to add the fields hx : N.X = {N.x} and hy : N.Y = {N.y} to the structure (the book’s standing convention for §§11.2–11.4), or equivalently to add them as hypotheses on the affected theorems. The §11.1 results — exercises 11.1.2 and 11.1.3 — are unaffected and should keep the general \(X\), \(Y\).
The total throughput of the severed arcs — how much traffic could at most cross that divide. Since all the flow must pass through, it bounds val f above.
! Missing from Mathlib. Structurally identical to fOut with cap in place of \(f\), which is exactly why theorem 11.1’s proof is a two-line comparison.
The total flow entering \(S\). Conservation forces the resultant flow out of every intermediate vertex to vanish, which is what makes the resultant flow out of \(X\) equal the resultant flow into \(Y\) (exercise 11.1.3) and hence val f well defined.
The mirror of fOut with the two sums swapped.
The total flow leaving \(S\) — sum over every arc with tail inside \(S\) and head outside. ! This is not the sum of the \(f^{+}(v)\) over \(v \in S\): arcs internal to \(S\) are counted there but not here. Exercise 11.1.2 makes the exact relationship precise, and it is the difference \(f^{+} - f^{-}\) that behaves well.
! Missing from Mathlib. A double Finset.sum over \(S\) and \(S^{c}\), which the capacity-as-a-function carrier makes possible; \(f u v = 0\) for a non-arc contributes nothing.
The transit points of the network, which neither produce nor consume. The conservation condition (11.2) applies exactly here — what flows in must flow out — and that is what makes val f well defined (exercise 11.1.3).
Finset.univ \{} (X \(\cup \) Y), so \(I\) is a Finset and membership is decidable — needed by IsFlow’s second clause.
A route from source to sink along which the flow can still be pushed up. Crucially it may travel against an arc — a reverse arc — provided that arc currently carries positive flow, which can then be cancelled. This is what lets the algorithm undo earlier bad choices, exactly as an augmenting path in matching theory rearranges an existing matching; B&M make the analogy explicit: *the rôle played by incrementing paths in flow theory is analogous to that of augmenting paths in matching theory* (compare theorem 5.1). The book’s example is figure 11.5(a), where \(P = xv_{1}v_{2}v_{3}y\) is \(f\)-incrementing with \(\iota (P) = 2\).
! Missing from Mathlib; an honest, complete inductive family — static, not procedural. nil starts at N.x; fwd extends along an \(f\)-unsaturated arc (f u v < cap u v); back extends against an \(f\)-positive arc (\(0 \lt f v u\)). The index is the current endpoint, so N.IncPath f N.y is exactly an \(f\)-incrementing path.
! This is a directed walk — repeated vertices are allowed — not a path. That is deliberate and is what theorem 11.2’s proof actually uses: the set \(S\) of vertices reachable by \(f\)-unsaturated walks is what the cut is built from, and restricting to paths would complicate the reachability closure for no gain.
The bottleneck along the path. A forward arc has room \(c(a) - f(a)\) left; a reverse arc can give back at most the \(f(a)\) it currently carries. The smallest of these slacks is how much extra can be pushed through in one go.
! Defective: this definition has a sorry body. \(\iota (P)\) is therefore an opaque natural number, not the bottleneck of anything. Consequences: exercise 11.3.1 (revisedFlow_isFlow_and_val) asserts val \(\hat{f}\) = val f + \(\iota \)(P) about two opaque constants and so says nothing, and the forward direction of theorem 11.2 — which needs \(\iota (P) \gt 0\) to get a strictly better flow — has no content to appeal to. This also violates the project convention (.claude/CLAUDE.md): *never sorry in a def*.
The repair is a structural recursion over the IncPath family, carrying the running minimum:
iota nil = \(\top \) (or: recurse with an accumulator seeded at the first arc) iota (fwd P h) = min (iota P) (cap u v - f u v) iota (back P h) = min (iota P) (f v u)
The only wrinkle is nil, which has no arcs and so no minimum; either return a sentinel and prove 0 < iota P for non-nil paths, or index the recursion by a running minimum passed in. The second is cleaner and avoids \(\mathbb {N}\infty \).
A way of severing the network so the source is on one side and the sink on the other. Every unit of flow must cross every cut, which is why cuts bound flows from above (theorem 11.1) — and, more surprisingly, why the best cut exactly matches the best flow (theorem 11.3).
! Missing from Mathlib. Identified with the vertex set \(S\) rather than the arc set \((S, \bar{S})\), since \(S\) determines the arcs and is far easier to quantify over. capOf then computes the arc set’s capacity. Note \(y \notin S\) is the book’s \(y \in \bar{S}\).
for supplies \(\sigma \) and demands dem (B&M’s \(\partial \)). ! MISSING. Honest def.
Nobody ships more than they can produce, and everybody receives at least what they ordered. Gale’s theorem 11.8 characterises existence: for every \(S\), the capacity out of \(S\) must cover the net demand of \(\bar{S}\).
! Missing from Mathlib. dem is B&M’s \(\partial \). Both conditions are cast to \(\mathbb {Z}\) before subtracting, for the reason recorded under val. Supplies and demands are \(V \to \mathbb {N}\) total functions, with the conditions quantified only over \(X\) and \(Y\), so their values elsewhere are irrelevant.
Nothing over-loaded, nothing accumulating. The zero flow’s existence is what makes exists_maxFlow non-vacuous.
The lower bound \(0 \le f(a)\) of (11.1) is free: \(f\) is \(\mathbb {N}\)-valued. Conservation is stated as fIn f {v} = fOut f {v} on singletons, which unfolds to the book’s \(f^{-}(v) = f^{+}(v)\) — note fIn/fOut on a singleton are genuinely the per-vertex quantities, since there are no arcs internal to a singleton.
Ship as much as the network allows. Theorem 11.2 characterises these as exactly the flows admitting no incrementing path — the flow-theoretic analogue of Berge’s theorem 5.1 for matchings.
"No flow of larger value" is stated positively as \(\forall \) f’, IsFlow f’ \(\to \) val f’ \(\le \) val f, which is the form every consumer wants.
The cheapest way to sever the network — the bottleneck. Theorem 11.3 says its capacity is exactly the maximum throughput. B&M record the easy half first: If f* is a maximum flow and \(\tilde{K}\) is a minimum cut, we have, as a special case of theorem 11.1, that val f* \(\le \) cap \(\tilde{K}\) (11.8).
As with IsMaxFlow, stated positively.
For a unit-capacity network this equals the value of a maximum flow: each path carries one unit, and arc-disjointness is exactly the capacity constraint.
! sorry body. Repair: sSup over \(k\) such that there are \(k\) directed \((x,y)\)-paths in the underlying digraph (arcs = pairs with 0 < cap u v) that are pairwise arc-disjoint. Needs a directed-path notion; see the section note.
For a unit-capacity network this equals the value of a maximum flow: each path carries one unit, and arc-disjointness is exactly the capacity constraint.
! sorry body. Repair: sSup over \(k\) such that there are \(k\) directed \((x,y)\)-paths in the underlying digraph (arcs = pairs with 0 < cap u v) that are pairwise arc-disjoint. Needs a directed-path notion; see the section note.
Push \(\iota (P)\) more along every forward arc of the path and take \(\iota (P)\) back off every reverse arc. Conservation survives because at each interior vertex the increase in and the increase out match; and the value rises by exactly \(\iota (P)\) (exercise 11.3.1). This is the engine of the labelling method: repeatedly find an incrementing path and revise, until none exists — at which point theorem 11.2 certifies maximality.
! Defective: this definition has a sorry body. \(\hat{f}\) is an opaque function, so exercise 11.3.1 — the only statement about it — is vacuous, and theorem 11.2’s forward direction has nothing to revise with. Same convention violation as iota.
The repair is a structural recursion over IncPath mirroring iota’s, adjusting one arc per constructor:
revisedFlow nil = f revisedFlow (fwd P _) = Function.update\(_{2}\) (revisedFlow P) u v (f u v + iota P) revisedFlow (back P _)= Function.update\(_{2}\) (revisedFlow P) v u (f v u - iota P)
! Note iota P must be the bottleneck of the whole path, not of the prefix, or the capacity constraint fails on early arcs — so iota should be computed once and threaded, rather than recomputed at each step. That coupling is the reason both definitions were deferred together, and it is why repairing iota first is the right order.
The net rate at which the commodity travels from producers to consumers. Conservation at the intermediate vertices is what makes the two ways of measuring it agree.
! \(\mathbb {Z}\)-valued, and this is load-bearing. In \(\mathbb {N}\) the truncated subtraction would make exercise 11.1.2 — the identity the whole chapter rests on — false, since individual terms \(f^{+}(v) - f^{-}(v)\) are genuinely negative at vertices absorbing more than they emit. Every \(f^{+} - f^{-}\) in this file is therefore cast to \(\mathbb {Z}\) before subtracting.
The bipartite analogue of the Havel–Hakimi reduction for degree sequences (exercise 1.5.7): the vertex \(x_{1}\) may as well spend its \(p_{1}\) edges on the \(p_{1}\) highest-demand vertices of \(Y\). Part (b) — dropped here as procedural — turns this into a construction algorithm.
! Two departures, both flagged in the source comment. (i) \(q'\) uses truncated natural subtraction (\(q j - 1\) is \(0\) when \(q j = 0\)), which is harmless only because a realisable \(q\) has \(q j \ge 1\) wherever row \(0\) puts an edge — worth checking rather than assuming. (ii) B&M’s \(q'\) is re-sorted into nonincreasing order, which this statement elides; without re-sorting, \(q'\) need not satisfy (11.17), so this reduction cannot be chained with theorem 11.9 as the book intends. If the intent is to iterate the reduction, the re-sorting must be restored.
Can two prescribed lists of degrees occur as the two sides of a bipartite graph? The book’s \(p = (3,2,2,2,1)\), \(q = (3,3,2,1,1)\) is realisable (figure 11.12), whereas \(p = q = (5,4,4,2,1)\) is not (exercise 11.5.2) even though the sums agree.
! Missing from Mathlib (0 hits for Gale–Ryser). Carried as a \((0,1)\)-matrix B : Fin m \(\to \) Fin n \(\to \) Bool rather than a bipartite SimpleGraph, following the book’s own closing remark: *With each simple bipartite graph \(G\) …we can associate an \(m \times n\) matrix \(B\) in which \(b_ij = 1\) or \(0\), depending on whether \(x_{i}y_{j}\) is an edge of \(G\) or not. Conversely, every \(m \times n\) \((0,1)\)-matrix corresponds in this way to a simple bipartite graph.* The two are equivalent and the matrix avoids constructing a graph on Fin m \(\oplus \) Fin n with a bipartition proof. Due to Ryser (1957).
Each vertex becomes a tiny one-way corridor \(v' \to v''\), so *passing through* \(v\) now costs an arc. This converts vertex-destruction into arc-destruction, letting the vertex form of Menger’s theorem be read off from the arc form: *two directed \((x,y)\)-paths in \(D'\) are arc-disjoint if and only if the corresponding paths in \(D\) are internally-disjoint.*
! Missing from Mathlib. Carrier \(V \oplus V\), with inl v = v’ and inr v = v”; internal arcs are inl u \(\to \) inr v when \(u = v\), and original arcs become inr u \(\to \) inl v.
! Simplified: it does not special-case \(x\) and \(y\). The book splits only \(V \ {x, y}\), leaving the endpoints intact; this splits every vertex. The consequence is that \(x\) and \(y\) also acquire internal arcs, so a destroying set in \(D'\) could cut \(x\)’s or \(y\)’s own corridor — which corresponds to deleting \(x\) or \(y\) themselves, something the book’s vertex-destruction forbids. Statements about splitDigraph therefore address Sum.inr x and Sum.inl y (the far ends of those corridors), which sidesteps the issue for exercise 11.4.1; but the simplification should be checked before it is relied on elsewhere.
Summing the net outflow over the vertices of \(S\) gives the net outflow of \(S\) as a whole. The book flags the trap: *in general, \(\sum _{v \in S} f^{+}(v) \ne f^{+}(S)\) and \(\sum _{v \in S} f^{-}(v) \ne f^{-}(S)\)* — only the difference behaves, and only because the internal arcs cancel.
* Build this first — lemma 11.1 and theorem 11.1 both rest on it, and it is where the \(\mathbb {Z}\)-valuedness of val earns its keep: in \(\mathbb {N}\) step 3’s cancellation is false, since \(f^{+}{v} - f^{-}{v}\) truncates at each vertex individually. Note it needs no IsFlow hypothesis: it is pure bookkeeping about an arbitrary \(f\).
With unit capacities a flow is a packing of arc-disjoint routes, each carrying one unit. This lemma is the bridge from flow theory to Menger.
! Two imported dependencies, both currently defective: step 1 needs chapter 10’s exercise 10.3.3, whose statement there mentions the sorry-bodied arcsOf; and B&M’s proof of that exercise adds \(l\) parallel arcs, which neither Digraph nor this file’s cap : V \(\to \) V \(\to \) \(\mathbb {N}\) carrier can express. ! Also note hunit : \(\forall \) u v, cap u v \(\le \) 1 permits cap = 0, i.e. absent arcs, which is what the book means by "each arc has unit capacity"; that reading is correct here.
With part (a) and the max-flow min-cut theorem, this immediately yields Menger’s arc theorem 11.4 — the whole of §11.4 rests on these two halves.
! Step 1 uses that with unit capacities cap S counts arcs; this needs hunit and that every counted arc actually exists (cap u v = 1, not \(0\)), so the sum-to-cardinality step deserves care.
The cut is a genuine bottleneck precisely when it runs at full capacity forwards and carries nothing backwards. This characterisation is exactly what the proof of theorem 11.2 verifies for the cut it constructs, which is why the equality condition is worth stating separately rather than folding into theorem 11.1.
The value of a flow can be measured across any cut, not just at the source: all the material has to cross somewhere, and nothing is lost in between. This is the observation from which theorem 11.1 immediately follows.
! Statement defect. This is false as stated — the seam between §11.1’s multi-source setting and §11.2’s single-source one. B&M close it by fiat (*throughout the next three sections, we shall confine our attention to networks that have a single source \(x\) and a single sink \(y\)*), but the Network structure here relates \(x\), \(y\) to \(X\), \(Y\) in no way at all, so val (defined over \(X\)) and the cut (separating \(x\) from \(y\)) measure different things. The three-vertex counterexample is worked out in full in the Network docstring above. The repair is the hypothesis N.X = {N.x} (with N.Y = {N.y}), either as a structure field or on this statement. The skeleton assumes it — step 1 is not derivable without it.
Every unit shipped from \(x\) to \(y\) must squeeze through the cut, so no flow can exceed the cut’s throughput. This weak-duality bound is half of the max-flow min-cut theorem; the surprise of theorem 11.3 is that it is always attained. B&M record the special case immediately: val f* \(\le \) cap \(\tilde{K}\) (11.8).
Corollary 11.7 relates it to internally-disjoint paths: \(G\) with \(\nu \ge k + 1\) is \(k\)-connected exactly when any two distinct vertices are joined by \(k\) internally-disjoint paths. This is the form of Menger’s theorem §3.2 announced without proof.
A minimal local copy, as for edgeConnectivity. The \(\nu - 1\) branch is the book’s convention for graphs with no vertex cut (complete graphs). ! Both sInf conventions bite at the boundaries — see the outline.
For naturals \(n \ge 4\), \(k \gt 0\) and \(\ell \ge 2\) with \(2\ell \le 2n\) and \(\ell ^{2}k \le n\) (the smallness condition \(\ell \le \sqrt{n/k}\)), the count of good pairs recorded for a derived clause satisfies
i.e. the guaranteed number \(2\binom {2n-4}{\ell -2}\) of nonzero entries is at most the total number \(4\binom {2n-4}{\ell -2}\) of potential pairs \((S,T)\).
For a matrix \(A\) and vector \(x\),
This expresses the squared Euclidean norm of \(Ax\) as the sum of the squares of its coordinates.
Fact 3.6 (Yekhanin, Lemma 6.2), in the existential form used downstream: for \(q \ge 2\), \(k, n \gt 0\) and \(\delta , \varepsilon \gt 0\) there exist a length \(n' \le 6n\) and parameters \(\delta ', \varepsilon ' \gt 0\) with
These are exactly the parameters of the normally decodable code obtained from a binary \((q,\delta ,\varepsilon )\)-LDC \(C : \{ 0,1\} ^k \to \{ 0,1\} ^n\); the Lean statement asserts only the existence of such \(n', \delta ', \varepsilon '\).
Placeholder. The Lean statement quantifies over parameters only: no code, decoder, or normal-form construction occurs in it, and it is discharged by exhibiting witnesses that make the two inequalities reflexive. It records the shape of Fact 3.6’s output for downstream use and does not formalise the reduction. It must not be cited as a formalisation of that reduction.
The structural data of a \((3,\delta ,\varepsilon )\)-normally decodable code with message length \(k\) and block length \(n\): for each message index \(i : \mathrm{Fin}\, k\) a hypergraph \(H_i\) on \(\mathrm{Fin}\, n\) which is \(3\)-uniform and a matching, together with real parameters \(\delta \gt 0\) and \(\varepsilon \gt 0\) and the density requirement \(\delta n \le \left\lvert H_i\right\rvert \) for every \(i\).
For a normal form code \(L\), a message \(b : \mathrm{Fin}\, k \to \mathbb {Z}\) and an assignment \(x : \mathrm{Fin}\, n \to \mathbb {Z}\), the real-valued XOR instance
where \(m\) is the total number of constraints of \(L\).
Let \(\alpha \gt 0\) with \(2\alpha \le n = \left\lvert V(G)\right\rvert \). If a family of \(\mathrm{numCuts}\) \(\alpha \)-minimum cuts satisfies \(\mathrm{numCuts} \cdot \binom {n}{2\alpha }^{-1} \le 1\), then
For \(1 \le r \le s\) and any \(f : \mathrm{BoolCube}\, n \to \mathbb {R}\),
This is the power-mean inequality for the uniform probability measure on the cube.
If, for Hölder conjugate exponents \(p\) and \(p'\) with \(1 \le p\), the noise operator with rate \(\sqrt{p-1}\) satisfies the \((p,2)\)-hypercontractive bound for every one-bit function, then it also satisfies the dual \((2,p')\)-hypercontractive bound: for every \(g\),
Given \(n \geq 1\), OnlineLearning.arbitraryMixedStrategy is a concrete element of \(\mathrm{MixedStrategy}(n)\) that places all probability mass on a single arbitrarily chosen action. It is used solely to witness that the type of mixed strategies is nonempty.
Let \(\iota \) be a finite type and \(L\) a continuous linear functional on \(\iota \to \mathbb {R}\). Then for every \(z : \iota \to \mathbb {R}\),
where \(e_i\) is the standard basis vector \(\mathrm{Pi.single}\, i\, 1\).
Let \(X, Y \subseteq \mathbb {R}\) and \(f : \mathbb {R}\to \mathbb {R}\to \mathbb {R}\) satisfy the bundled hypotheses \(\texttt{OnlineLearning.ConvexCompactMinimaxHypotheses}\): \(X\) is nonempty, compact and convex, \(Y\) is nonempty and convex, \(f\) is bounded above and below on \(X \times Y\), convex and continuous in the row variable for each \(y \in Y\), and concave in the column variable for each \(x \in X\). Then the minimax identity \(\texttt{OnlineLearning.ConvexCompactMinimaxStatement}\) holds:
This is the public form of the theorem for the project; it hides the choice of proof route from downstream files.
Under the convex-compact minimax hypotheses \(\texttt{OnlineLearning.ConvexCompactMinimaxHypotheses}\) for \(X\), \(Y\), \(f\), the minimax identity \(\texttt{OnlineLearning.ConvexCompactMinimaxStatement}\) holds:
This is the final form of the theorem obtained via the finite-column separation route.
Under the convex-compact minimax hypotheses, if additionally \(Y\) is compact, \(f\) is jointly continuous on \(X \times Y\), and \(0 \le f \le 1\), then the minimax equality
holds. The proof combines the normalized finite no-regret bound with the compact approximation theorem derived from joint continuity on compact \(X \times Y\), without invoking any separation argument.
Assume the hypotheses \(\texttt{OnlineLearning.ConvexCompactMinimaxHypotheses}\) for \(X\), \(Y\), \(f\), and suppose that for every \(\varepsilon \gt 0\) and every finite \(u \subseteq Y\) the intersection of \(X\) with the sublevel sets \(\texttt{OnlineLearning.minimaxSublevel}\) at level \(v + \varepsilon \) over \(y \in u\) is nonempty, where \(v = \sup _{y \in Y} \inf _{x \in X} f(x,y)\). Then the minimax identity \(\texttt{OnlineLearning.ConvexCompactMinimaxStatement}\) holds for \(X\), \(Y\), \(f\), i.e.
If the standard convex-compact minimax hypotheses hold, the finite no-regret bound \(\texttt{OnlineLearning.Theorem71FiniteNoRegretBound}\) holds, and the compact approximation property \(\texttt{OnlineLearning.Theorem71CompactApproximation}\) holds, then the minimax equality
holds.
A structure bundling the assumptions of Cesa-Bianchi–Lugosi Theorem 7.1 for \(f : \mathbb {R}\to \mathbb {R}\to \mathbb {R}\) on sets \(X, Y \subseteq \mathbb {R}\): both sets are nonempty, \(X\) is compact and convex, \(Y\) is convex, \(f(\cdot ,y)\) is continuous and convex on \(X\) for every \(y \in Y\), \(f(x,\cdot )\) is concave on \(Y\) for every \(x \in X\), and \(f\) is bounded above and below on \(X \times Y\).
For sets \(X, Y \subseteq \mathbb {R}\) and a payoff function \(f : \mathbb {R}\to \mathbb {R}\to \mathbb {R}\), OnlineLearning.ConvexCompactMinimaxStatement is the proposition
It is packaged as a named Prop so that intermediate lemmas can refer to it while the proof is built up incrementally.
Under OnlineLearning.ConvexCompactMinimaxHypotheses, let \(c \in \mathbb {R}\). If for every finite subset \(u \subseteq Y\) there exists \(x \in X\) with \(f(x,y) \leq c\) for all \(y \in u\), then there exists \(x \in X\) with \(f(x,y) \leq c\) for all \(y \in Y\). The proof applies the finite-intersection property to the compact collection of sublevel sets.
For a finite zero-sum game \(G\) with \(M \gt 1\) rows and \(N \geq 1\) columns, the lower and upper values coincide:
The proof extracts arbitrarily good approximate saddle points from the Hedge algorithm, then passes to the limit in \(\varepsilon \).
Assume the convex-compact minimax hypotheses \(\texttt{OnlineLearning.ConvexCompactMinimaxHypotheses}\) for \(X\), \(Y\), \(f\). Then for every \(\varepsilon \gt 0\) and every finite column sample \(u \subseteq Y\), the set
is nonempty, the inner sets being the sublevel sets \(\texttt{OnlineLearning.minimaxSublevel}\); i.e. some row \(x \in X\) satisfies \(f(x,y) \le v + \varepsilon \) simultaneously for all sampled columns \(y \in u\).
For a row sample indexed by \(\mathrm{Fin}\, M\), the finite indexed row sample lower value is
where \(x : \mathrm{Fin}\, M \to X\) is the sample. This is a technical variant of \(\texttt{OnlineLearning.finiteRowSampleLowerValue}\) used in intermediate results.
For a finite zero-sum game \(G\) with \(M\) row actions and \(N\) column actions, the lower value is
where the row player maximises over mixed strategies and the column player minimises over pure responses.
Given a payoff \(f : \mathbb {R} \to \mathbb {R} \to \mathbb {R}\) and a finite subset \(u \subseteq X\), the finite row sample lower value is
i.e. the lower value obtained when the row player is restricted to the finite sample \(u\) while the column player still ranges over all of \(Y\).
For sets \(X, Y \subseteq \mathbb {R}\), a payoff \(f : \mathbb {R}\to \mathbb {R}\to \mathbb {R}\), and a finite sample \(u\) of columns from \(Y\), the finite upper image is the set
of vectors that strictly dominate the payoff vector of some row on the sample \(u\). This set is written \(\texttt{OnlineLearning.finiteUpperImage}\) in Lean.
If \(f(\cdot , y_j)\) is convex on \(X\) and every \(x_i \in X\), then for any mixed row strategy \(p \in \Delta _M\),
That is, convexity in the row variable means the continuous mixed-action payoff is at most the finite-game expected payoff.
If \(f(x_i,\cdot )\) is concave on \(Y\) and every \(y_j \in Y\), then for any mixed column strategy \(q \in \Delta _N\),
Given a payoff function \(f : \mathbb {R}\to \mathbb {R}\to \mathbb {R}\) with values in \([0,1]\), finite families of row points \(x : [M] \to \mathbb {R}\) and column points \(y : [N] \to \mathbb {R}\), the sampled game is the \(M\times N\) matrix game whose \((i,j)\) entry is \(f(x_i, y_j)\).
Assume \(X\) is nonempty and \(L\) is a continuous linear functional on \(u \to \mathbb {R}\) with \(L(z) \lt L(c)\) for every \(z \in U(X,f,u)\), where \(c\) is a fixed vector. Then \(L(e_y) \le 0\) for every coordinate \(y \in u\).
Under the convex-compact minimax hypotheses, if \(Y\) is compact and \(f\) is jointly continuous on \(X \times Y\), then \(\texttt{OnlineLearning.Theorem71CompactApproximation}\) holds. This is obtained by combining \(\texttt{OnlineLearning.theorem71\_ uniformEquicontinuity\_ of\_ jointContinuous\_ compact}\) with \(\texttt{OnlineLearning.theorem71\_ compactApproximation\_ of\_ uniformEquicontinuity}\).
Under the convex-compact minimax hypotheses, if \(f\) satisfies \(\texttt{OnlineLearning.Theorem71UniformEquicontinuity}\), then \(\texttt{OnlineLearning.Theorem71CompactApproximation}\) holds: a finite cover of the compact set \(X\) together with equicontinuity shows that the finite sample lower value approximates the full lower value to within any \(\varepsilon \gt 0\).
Under the convex-compact minimax hypotheses and the normalization \(0 \le f \le 1\), for any row sample \(x : \mathrm{Fin}\, M \to X\) with \(M \ge 2\),
The proof constructs a finite matrix game with payoff \(1 - f\) on each finite column subset, applies the finite minimax theorem (via the upstream no-regret development), and uses compactness of \(X\) to pass to all columns.
Under the convex-compact minimax hypotheses and \(0 \le f \le 1\), \(\texttt{OnlineLearning.Theorem71FiniteNoRegretBound}\) holds. This removes the artificial \(\mathrm{Fin}\, M\) indexing from \(\texttt{OnlineLearning.theorem71\_ finiteIndexedNoRegretBound\_ normalized}\); the singleton case is handled separately since the finite minimax theorem requires at least two row actions.
If the convex-compact minimax hypotheses hold, \(Y\) is compact, and \((x,y) \mapsto f(x,y)\) is continuous on \(X \times Y\), then \(\texttt{OnlineLearning.Theorem71UniformEquicontinuity}\) holds. The proof applies the Heine–Cantor theorem to upgrade joint continuity on the compact product \(X \times Y\) to uniform continuity, then restricts variation to the first coordinate.
\(\texttt{OnlineLearning.Theorem71CompactApproximation}\) is the proposition asserting that for every \(\varepsilon \gt 0\) there exists a nonempty finite sample \(u \subseteq X\) such that
This encodes the “let the net size go to zero” compactness step of the textbook proof.
\(\texttt{OnlineLearning.Theorem71FiniteNoRegretBound}\) is the proposition asserting that for every nonempty finite row sample \(u \subseteq X\),
This is the finite-game no-regret ingredient in the Theorem 7.1 proof route.
\(\texttt{OnlineLearning.Theorem71UniformEquicontinuity}\) holds for \(X\), \(Y\), \(f\) when \(f\) is uniformly equicontinuous in its first argument uniformly over all columns: for every \(\varepsilon \gt 0\) there exists \(\rho \gt 0\) such that for all \(x, x' \in X\) and \(y \in Y\),
Under the hypotheses OnlineLearning.ConvexCompactMinimaxHypotheses,
This is the easy direction of the minimax theorem: for every fixed \((x,y)\), \(\inf _{x'} f(x',y) \leq f(x,y) \leq \sup _{y'} f(x,y')\), and the inequality is preserved when taking \(\sup \) then \(\inf \).
For a valid loss sequence and \(\eta \gt 0\), the ratio of consecutive potentials satisfies
where \(\widehat{\ell }_t = \sum _i p_t(i)\, \ell _t(i)\) is the expected loss at round \(t\). This is the key potential-ratio lemma of Cesa-Bianchi and Lugosi.
Given a game \(G\), a prefix of \(t\) column actions, and a row \(i\), the prefix cumulative loss of row \(i\) is
This mirrors cumLoss from the abstract Hedge framework, expressed directly in terms of game payoffs.
For any fixed column-action sequence \(a : \mathrm{Fin}\, T \to \mathrm{Fin}\, N\), round \(t \lt T\), and row \(i\), the prefix cumulative loss of row \(i\) along the first \(t\) actions equals the abstract cumulative loss of \(i\) in the induced loss sequence: \(\mathrm{prefixGameLoss}(\dots ) = \mathrm{cumLoss}(G.\mathrm{toLossSeq}(a), t, i)\).
For a boolean-vector-valued random variable \(X : \Omega \to (\mathrm{Fin}\, m \to \mathrm{Bool})\) and an index \(i : \mathrm{Fin}\, m\), the strict prefix \(\mathrm{boolVectorStrictPrefix}\, X\, i\, \omega \) is the restriction of \(X(\omega )\) to coordinates \(0, 1, \ldots , i-1\).
Let \(\{ Y_i\} _{i \in \iota }\) be a mutually independent, identically distributed family of measurable real random variables on a probability space \((\Omega , \mu )\), where \(|\iota | = n\). Suppose that for each \(i\) the centered square \(Y_i^2 - \sigma ^2\) satisfies \(\texttt{ProbabilityTheory.HasBernsteinMGF}\ (Y_i^2 - \sigma ^2)\ \mu \ c\ t_{\max }\) with \(c \gt 0\). Then for every \(s\) with \(0 \le s \le 2n c\, t_{\max }\),
For a boolean-vector-valued \(X : \Omega \to (\mathrm{Fin}\, m \to \mathrm{Bool})\),
where \(X_i(\omega ) = X(\omega )(i)\).
Let \(W : \Omega \to V\) and \(f : V \to U\). If \(I[X : W \mid f \circ W;\mu ] = 0\) (i.e., the coarse variable \(f \circ W\) carries all the information about \(X\) that \(W\) does), then
If \(f : U \to S \to V\) is any function (where \(Z : \Omega \to U\) is the conditioning variable), then applying \(f(Z(\omega ))\) to \(X(\omega )\) before measuring mutual information cannot increase it:
For a measurable function \(f : U \to T \to V\) (with \(Z : \Omega \to U\) the conditioning variable), applying \(f(Z(\omega ))\) to \(Y(\omega )\) cannot increase conditional mutual information:
Adding a deterministic function of the conditioning variable to the conditioning variable does not change conditional mutual information:
For a measurable \(f : U \to S \to V\), conditioning additionally on a deterministic function of \(X\) and \(Z\) cannot increase conditional mutual information:
For a measurable \(f : U \to T \to V\), conditioning additionally on a deterministic function of \(Y\) and \(Z\) cannot increase conditional mutual information:
Version of ProbabilityTheory.condMutualInfo_congr_ae for finite measurable sample spaces: measurability and finite-range conditions are inferred automatically from the CommunicationComplexity.FiniteMeasureSpace and Finite instances, so only the a.e. equality hypotheses need to be supplied.
Under a probability measure, if \(X =^{\mu \text{-a.e.}} X'\) and \(Y =^{\mu \text{-a.e.}} Y'\), then \(I[X : Y \mid Z;\mu ] = I[X' : Y' \mid Z;\mu ]\) (the conditioning variable \(Z\) is unchanged).
If the conditioning variable is a pair \((K, Z)\) with \(K\) taking values in a finite type \(A\), then
\(\texttt{ProbabilityTheory.HasBernsteinMGF}\ X\ \mu \ c\ t_{\max }\) is a predicate on a random variable \(X : \Omega \to \mathbb {R}\), a measure \(\mu \), and real parameters \(c, t_{\max } \ge 0\). It asserts that for every \(t\) with \(|t| \le t_{\max }\), the exponential moment \(e^{tX}\) is \(\mu \)-integrable, and the moment generating function satisfies \(\mathbf{E}_\mu [e^{tX}] \le e^{c t^2}\). The pair \((c, t_{\max })\) parametrizes a “two-parameter sub-exponential” family: \(c\) controls the quadratic growth near zero and \(t_{\max }\) bounds the radius of validity.
Let \(X\) satisfy \(\texttt{ProbabilityTheory.HasBernsteinMGF}\ X\ \mu \ c\ t_{\max }\) with \(c \gt 0\). For every \(s\) with \(0 \le s \le 2c\, t_{\max }\),
The bound follows by combining the upper- and lower-tail bounds via a union bound.
Let \(X\) satisfy \(\texttt{ProbabilityTheory.HasBernsteinMGF}\ X\ \mu \ c\ t_{\max }\) with \(c \gt 0\). For every \(s\) with \(0 \le s \le 2c\, t_{\max }\),
The condition \(s \le 2c\, t_{\max }\) ensures that the Chernoff-optimal parameter \(t = s/(2c)\) lies in the validity region \(|t| \le t_{\max }\).
Let \(X\) satisfy \(\texttt{ProbabilityTheory.HasBernsteinMGF}\ X\ \mu \ c\ t_{\max }\) with \(c \gt 0\). For every \(s\) with \(0 \le s \le 2c\, t_{\max }\),
This is the symmetric lower-tail analogue of \(\texttt{ProbabilityTheory.HasBernsteinMGF.measure\_ ge\_ le}\), obtained by applying the upper-tail bound to \(-X\).
Let \(\{ X_i\} _{i \in s}\) be a mutually independent family of measurable real random variables on a probability space, each satisfying \(\texttt{ProbabilityTheory.HasBernsteinMGF}\ (X_i)\ \mu \ c_i\ t_{\max }\) for a common radius \(t_{\max }\). Then the finite sum \(\sum _{i \in s} X_i\) satisfies \(\texttt{ProbabilityTheory.HasBernsteinMGF}\ (\sum _{i\in s} X_i)\ \mu \ (\sum _{i\in s} c_i)\ t_{\max }\).
If \((X, Y)\) and \((X', Y')\) have the same joint law and \(s \subseteq B\) is measurable, then \(X\) under \(\mu [\, |\, Y^{-1}(s)]\) and \(X'\) under \(\mu '[\, |\, Y'^{-1}(s)]\) are identically distributed.
Finite-space version of ProbabilityTheory.IdentDistrib.condMutualInfo_eq: measurability and finite-range conditions are inferred from CommunicationComplexity.FiniteMeasureSpace and Finite instances.
For measurable \(X : \Omega \to S\) and \(Y : \Omega \to T\) with finite \(S\) and \(T\), if
holds for all \(x, y\), then \(X\) and \(Y\) are independent under \(\mu \).
Let \(A = Z^{-1}(B)\) for some measurable \(B\). Then, under a probability measure \(\mu \),
Let \(\mu , \nu \) be probability measures on \(\mathrm{Bool}\) with \(\nu \) of full support. Then
where the right-hand side is the PFR real-valued KL divergence of the identity random variable.
Let \(\mu \) be a finite measure on a measurable space \(\Omega \), \(X : \Omega \to \mathrm{Bool}\) a measurable function, \(S \subseteq \Omega \) a set with \(\mu .\mathrm{real}\, S \neq 0\), and \(\nu \) a full-support probability measure on \(\mathrm{Bool}\). Then
For a game \(G\), a pure row \(i\), and a sequence of pure column actions \(a_0, \dots , a_{T-1}\),
where \(\hat{q}\) is the empirical column strategy.
For a non-degenerate \([[n,k]]\) quantum code \(C \le \mathcal{H}_n\) correcting \(t\) errors, with \(\dim _{\mathbb {C}}(C) = 2^k\), the dimension of the error sphere does not exceed the ambient dimension:
(Rédei, 1934). *Every tournament has a directed Hamilton path.*
B&M define the term just above: *A directed Hamilton path of \(D\) is a directed path that includes every vertex of \(D\).*
In any round-robin competition the players can be lined up so that each beat the next. The book cautions in §10.7 that this does not give a sensible ranking, since a tournament generally has many directed Hamilton paths — the six-player example has \((3,1,2,4,5,6)\), \((1,2,4,5,6,3)\), \((1,4,6,3,2,5)\) and others, declaring different winners. That is what motivates the eigenvector method.
"Includes every vertex" is \(\forall \) w, w \(\in \) p.vertices rather than a cardinality claim, which is what step 3 delivers most directly. Exercise 10.2.3 gives an independent route not passing through theorem 10.1.
Suppose the row player uses per-round distributions \(p_0, \dots , p_{T-1}\) (each summing to \(1\)) against column responses \(j_0, \dots , j_{T-1}\), and achieves cumulative loss regret at most \(R\):
Then the total payoff satisfies
Let \(0 \le p \le 1\), let \(U\) be a set of coordinates and let \(k \ge 1\) satisfy \(3k \le p\left\lvert U\right\rvert \). Then, under a Bernoulli(\(p\))-random restriction with free set \(J\),
which is the form consumed by the concentration transfer of O’Donnell Lemma 4.21.
Let \(0 \le p \le 1\), let \(U\) be a set of coordinates and let \(k \ge 1\) satisfy \(3k \le p\left\lvert U\right\rvert \). Then, under a Bernoulli(\(p\))-random restriction with free set \(J\),
This is the Bernoulli-restriction analogue of the binomial lower tail used in O’Donnell Lemma 4.21, with the textbook bound \(e^{-2k/3}\) replaced by the elementary \(3/(4k) \le 3/4 \lt 1\).
For a Bernoulli(\(p\))-random restriction \(\rho \) with free set \(J = \rho .\mathrm{freeVars}\) and sets \(U, S \subseteq [n]\),
Combined with the second identity this yields O’Donnell’s form \(\mathbb {E}_\rho [\widehat{f_\rho }(S)^2] = \sum _U \Pr [U \cap J = S]\cdot \widehat{f}(U)^2\).
Under a Bernoulli(\(p\))-random restriction with free-coordinate set \(J\), the probability that a fixed set \(T\) is contained in \(J\) is
This is the first-moment half of O’Donnell Proposition 4.17.
For a set \(U \subseteq [n]\), a restriction \(\rho \) with free set \(J = \rho .\mathrm{freeVars}\), and an input \(x\),
so the character splits into a character in the free coordinates times a constant sign coming from the fixed coordinates.
Under a Bernoulli(\(p\))-random restriction with free set \(J\), for every set \(U\),
Under a Bernoulli(\(p\))-random restriction \(\rho \), the expected Fourier coefficient of the restricted function at \(S\) is
the expectation being the \(\mathrm{bernoulliRestrWeight}\, p\)-weighted sum over all restrictions.
Under a Bernoulli(\(p\))-random restriction \(\rho \), the expected squared Fourier coefficient at \(S\) is
where the sum runs over all \(U \subseteq [n]\) and the terms with \(S \not\subseteq U\) vanish.
For distinct coordinates \(i \ne j\), the Bernoulli(\(p\))-weighted sum over all restrictions of the product of the two indicators that \(i\) and \(j\) are free equals \(p^2\); that is, \(\mathbb {E}[\mathbf{1}[i \in J]\, \mathbf{1}[j \in J]] = p^2\).
For \(f : \{ 0,1\} ^n \to \mathbb {R}\), a restriction \(\rho \) with free set \(J = \rho .\mathrm{freeVars}\), and \(S \subseteq [n]\),
where \(f_\rho = \mathrm{restrictBF}\, f\, \rho \). This is the analogue of O’Donnell Corollary 3.22.
If \(S \subseteq U\) then for every restriction \(\rho \) with free set \(J\),
where the left-hand side is understood as \(0\) when the indicator fails.
For a set \(T \subseteq \{ 0,\dots ,n-1\} \) and a restriction \(\rho \), the indicator of the event \(T \subseteq \mathrm{freeVars}(\rho )\) equals the product over all coordinates \(i\) of the factor that is the indicator of \(\rho (i) = \star \) when \(i \in T\), and \(1\) otherwise.
Given sets \(U, S \subseteq [n]\), a coordinate \(i\) and a per-coordinate value \(v\), the local factor is \(1\) if \(i \in S\) and \(v = \mathtt{none}\) (the coordinate must be free), \(0\) if \(i \in S\) and \(v\) is fixed; for \(i \in U \setminus S\) it is \(0\) when \(v = \mathtt{none}\) and \(\mathrm{boolToSign}(b)\) when \(v = \mathtt{some}\ b\); and \(1\) for all remaining coordinates. It encodes the event \(U \cap \mathrm{freeVars} = S\) together with the sign contributed on \(U \setminus S\).
For a restriction \(\rho \) and a coordinate \(i\), we have \(i \in \rho .\mathrm{freeVars}\) if and only if \(\rho \, i = \mathtt{none}\), i.e. exactly when \(\rho \) leaves the coordinate \(i\) unfixed. The companion definition \(\mathrm{signProd}\, \rho \, T = \prod _{i \in T} \mathrm{boolToSign}((\rho \, i).\mathrm{getD}\ \mathtt{false})\) collects the \(\pm 1\)-encodings of the bits \(\rho \) fixes on a set \(T\).
For \(p \in \mathbb {R}\) and sets \(S, U \subseteq [n]\),
Given \(f : \{ 0,1\} ^n \to \mathbb {R}\) and a restriction \(\rho \), the restricted function \(f_\rho = \mathrm{restrictBF}\, f\, \rho \) is defined by
so free coordinates are read from the input \(x\) and fixed coordinates from \(\rho \). It is the real-valued analogue of \(\mathrm{restrictFn}\).
The restriction \(\mathrm{restrictBF}\) of a real-valued Boolean function reads free coordinates from the input and fixed coordinates from the restriction \(\rho \), i.e. \((\mathrm{restrictBF}\, f\, \rho )(x) = f(\rho .\mathrm{extend}\, x)\). This statement says that for a Boolean-valued \(f : \{ 0,1\} ^n \to \{ 0,1\} \), restricting its \(\pm 1\)-encoding agrees with encoding the restricted function: \(\mathrm{restrictBF}\, (\mathrm{boolToSign}\circ f)\, \rho = \mathrm{boolToSign}\circ (\mathrm{restrictFn}\, f\, \rho )\).
For a restriction \(\rho \) and a set \(T \subseteq [n]\),
the product of the \(\pm 1\)-encodings of the bits that \(\rho \) fixes on \(T\). On coordinates where \(\rho \) is free the default value \(\mathtt{false}\) is used; this junk value is harmless because the definition is only ever paired with indicators forcing \(T\) to consist of fixed coordinates.
For \(p \in \mathbb {R}\) and any family \(h : [n] \to \mathrm{Option}\ \mathrm{Bool} \to \mathbb {R}\),
so the Bernoulli weight is absorbed coordinatewise into the per-variable weight \(\mathrm{varWeight}\).
For any family \(h : [n] \to \mathrm{Option}\ \mathrm{Bool} \to \mathbb {R}\),
the sum ranging over all restrictions \(\rho \) on \(n\) variables and \(v\) over the three possible per-coordinate values.
For \(p \in \mathbb {R}\), sets \(U, V, S\) and a coordinate \(i\),
which is the per-coordinate average needed for the squared coefficient.
For \(0 \le p \le 1\) and every set \(U\), the Bernoulli(\(p\))-weighted mean squared deviation of \(\left\lvert U \cap J\right\rvert \) from \(p\left\lvert U\right\rvert \) is
(Robbins, 1939). *If \(G\) is 2-edge-connected, then \(G\) has a diconnected orientation.*
How to make a road system one-way so traffic can still flow everywhere. A graph with a cut edge clearly cannot manage it — whichever way that edge is directed, one side becomes unreachable — and Robbins showed 2-edge-connectivity is not merely necessary but sufficient. Intuitively, each new vertex is given both a way in and a way out.
! Step 2 rides chapter 3’s exercise 3.2.1, which this repo does not have; budget for it before starting. h2ec : 2 \(\le \) edgeConnectivity G is "\(2\)-edge-connected" per §3.1. Theorem 10.6 is the \(k = 1\) case of a different route to the same conclusion, so neither theorem subsumes the other.
For naturals \(d\) and \(\mathrm{row\_ nnz}\), if the number of nonzero entries in a row of the matrix \(B_i\) satisfies \(\mathrm{row\_ nnz} \le 2d\), then \(\mathrm{row\_ nnz} \le 2d\). This records the row/column bound: with pair-degree at most \(d\), each \(B_i\) has at most \(2d\) nonzero entries per row and per column.
If the row vectors of \(A\) (as \((\mathrm{Fin}\, d\to \mathbb {R})\)-valued random variables) are mutually independent under \(\mu \), then for any fixed \(x\in \mathbb {R}^d\) the scalar row-projections \((A\, \omega ).\texttt{toEuclideanLin}\, x\, i = \sum _j A_{\omega ,i,j}\, x_j\) are independent across \(i\in \mathrm{Fin}\, k\), since each is a measurable function of a distinct row of \(A\).
(Roy, 1967; Gallai, 1968). *A digraph \(D\) contains a directed path of length \(\chi - 1\)*, where \(\chi \) is the chromatic number of the underlying graph.
Striking because, as figure 10.3 shows, there is otherwise *no close relationship between the lengths of paths and directed paths in a digraph* — yet the chromatic number of the underlying graph controls the latter exactly. The remark following shows the bound is best possible.
\(k - 1\) is \(\mathbb {N}\)-subtraction, harmless as the goal is a lower bound. \(hk\) pins \(\chi \) of toSimpleGraphInclusive — the underlying graph — to \(k\) in \(\mathbb {N}\infty \). Step 4 is the mathematical core; steps 1 and 2 are both "choose a maximum/minimum in a finite nonempty family" and should share a helper.
The same statement written with the power taken inside the quotient ring: if \(p\) and \(q\) are coprime and \(\bar m^{\, ed} = \bar m\) in \(\mathbb {Z}/p\mathbb {Z}\) and in \(\mathbb {Z}/q\mathbb {Z}\), then \(\bar m^{\, ed} = \bar m\) in \(\mathbb {Z}/pq\mathbb {Z}\).
The inductive type \(\mathtt{AuxVar}\, V\) extends a variable type \(V\) with two constructors: \(\mathtt{orig}\, v\) wraps an original variable \(v : V\), and \(\mathtt{extra}\, i\, j\) introduces a fresh auxiliary variable \(y_{i,j}\) used as a chain link when encoding clause \(i\) of length greater than three.
Given a clause index \(c\_ idx\), a lifting map \(ml\), a suffix list of literals \(\mathit{lits}\), and a chain counter \(j \ge 1\), SATTo3SAT.buildChain produces the middle and final 3-clauses of the chain encoding. Each middle step emits \(\langle \lnot y_{j-1},\, l_i,\, y_j\rangle \); the final step emits \(\langle \lnot y_{j-1},\, l_{n-1},\, l_n\rangle \) when only two literals remain.
Let \(\alpha \) be an assignment satisfying at least one literal of a clause, and let \(\alpha _3\) be an assignment on \(\mathtt{AuxVar}\, V\) that evaluates auxiliary variables via SATTo3SAT.extraVal and lifted literals faithfully. Then every 3-clause produced by \(\texttt{SATTo3SAT.buildChain}\, c\_ idx\, ml\, \mathit{lits}\, j\) (with \(j \ge 1\) and \(\mathit{lits} = \mathit{clause}.\mathtt{drop}(j+1)\)) is satisfied by \(\alpha _3\).
If \(y_{j-1}\) is true, every \(ml\)-lifted literal in \(\mathit{lits}\) is false under \(\alpha _3\), and every 3-clause in \(\texttt{SATTo3SAT.buildChain}\, c\_ idx\, ml\, \mathit{lits}\, j\) is satisfied by \(\alpha _3\) (with \(j \ge 1\) and \(|\mathit{lits}| \ge 2\)), then a contradiction follows: the auxiliary variables are forced true one by one until the final chain clause has all three disjuncts false.
For a literal \(l\) local to index \(i\), the evaluation of \(l\) under the global assignment SATTo3SAT.globalAssignment \(\alpha \, f\) agrees with its evaluation under the local assignment that maps \(\mathtt{extra}\, i\, j \mapsto \texttt{SATTo3SAT.extraVal}\, \alpha \, (f_i)\, j\).
Given an assignment \(\alpha : V \to \mathrm{Prop}\), SATTo3SAT.evalLiteral maps a literal to its truth value: a positive literal \(\mathtt{pos}\, v\) is true iff \(\alpha (v)\) holds, and a negative literal \(\mathtt{neg}\, v\) is true iff \(\alpha (v)\) does not hold.
For a list of literals \(\mathit{lits}\) and index \(j\), \(\texttt{SATTo3SAT.extraVal}\, \alpha \, \mathit{lits}\, j\) holds iff every literal in \(\mathit{lits}.\mathtt{take}(j + 2)\) is false under \(\alpha \). This is the intended truth value of the auxiliary chain variable \(y_j\) in the encoding of \(\mathit{lits}\).
For a 3-clause \(c_3\) produced by \(\texttt{SATTo3SAT.transformClause}\, i\, \mathit{clause}\) (where \(\mathit{clause} = f_i\)), satisfaction of \(c_3\) under the global assignment SATTo3SAT.globalAssignment \(\alpha \, f\) is equivalent to satisfaction under the local assignment \(\mathtt{extra}\, i\, j \mapsto \texttt{SATTo3SAT.extraVal}\, \alpha \, \mathit{clause}\, j\).
Given \(\alpha : \mathtt{Assignment}\, V\) and a formula \(f\), SATTo3SAT.globalAssignment \(\alpha \, f\) is the assignment on \(\mathtt{AuxVar}\, V\) that maps each original variable \(\mathtt{orig}\, v\) to \(\alpha (v)\) and each auxiliary variable \(\mathtt{extra}\, i\, j\) to \(\texttt{SATTo3SAT.extraVal}\, \alpha \, (f.\mathtt{get}\, i)\, j\), i.e. the chain invariant “the first \(j+2\) literals of clause \(i\) are all false.”
A CNF formula \(f\) over \(V\) is satisfiable if and only if the 3-CNF formula \(\texttt{SATTo3SAT.to3SAT}\, f\) (over \(\mathtt{AuxVar}\, V\)) is 3-satisfiable. This combines SATTo3SAT.SAT_to_3SAT_completeness and SATTo3SAT.SAT_to_3SAT_soundness into a single biconditional.
If \(\texttt{SATTo3SAT.to3SAT}\, f\) is 3-satisfiable, then the original CNF formula \(f\) is satisfiable. The witnessing assignment for \(f\) is the restriction of any 3-SAT satisfying assignment \(\alpha _3\) to original variables, \(v \mapsto \alpha _3(\mathtt{orig}\, v)\).
SATTo3SAT.transformClause maps a single clause (at index \(c\_ idx\)) to a list of 3-clauses: the empty clause becomes two contradictory 3-clauses (unsatisfiable), a 1-literal clause becomes \(\langle l_1,l_1,l_1\rangle \), a 2-literal clause becomes \(\langle l_1,l_2,l_2\rangle \), a 3-literal clause is copied as-is, and any longer clause \(l_1 :: l_2 :: \mathit{rest}\) becomes \(\langle l_1, l_2, y_0\rangle \) followed by \(\texttt{SATTo3SAT.buildChain}\) on \(\mathit{rest}\).
If a clause has at least one true literal under \(\alpha \), then every 3-clause in its encoding \(\texttt{SATTo3SAT.transformClause}\, c\_ idx\, \mathit{clause}\) is satisfied by the local assignment \(\mathtt{extra}\, c\_ idx\, j \mapsto \texttt{SATTo3SAT.extraVal}\, \alpha \, \mathit{clause}\, j\).
If every 3-clause in \(\texttt{SATTo3SAT.transformClause}\, c\_ idx\, \mathit{clause}\) is satisfied by \(\alpha _3\), then the original clause has at least one true literal under the restriction \(v \mapsto \alpha _3(\mathtt{orig}\, v)\).
Given the Boolean truth values \(a, b, c_3\) of the three literals of a clause, \(\mathrm{clauseGadgetColor}(a, b, c_3, k)\) assigns a color in \(\mathrm{Fin}\, 3\) to gadget node \(k \in \{ 0,\ldots ,5\} \). In particular, node \(5\) always receives color \(1\) (True), and the remaining nodes are colored so that all internal gadget edges receive distinct colors whenever at least one literal is true.
\(\mathrm{EdgeRelation}(f, u, v)\) defines the (undirected) adjacency structure of the reduction graph. The edges are: all pairs of distinct palette nodes; every literal node to the Base palette node; \(\mathrm{pos}(x)\) to \(\mathrm{neg}(x)\) for each variable \(x\); specific pairs of clause gadget nodes within the same clause (encoding two internal triangles on nodes \(\{ 0,1,2\} \) and \(\{ 3,4,5\} \) plus the bridge \(2\)–\(3\)); each clause’s three literal nodes to gadget nodes \(0\), \(1\), and \(4\) respectively; and gadget node \(5\) of every clause to both the Base and the False palette nodes.
The vertex set of the reduction graph is the inductive type \(\mathrm{OutputVertex}(V)\) with three constructors:
\(\mathrm{palette}(p)\) for \(p : \mathrm{Fin}\, 3\) — the three special palette nodes (Base \(= 0\), True \(= 1\), False \(= 2\)) forming a triangle that fixes color semantics;
\(\mathrm{literalNode}(\ell )\) — one node per literal over \(V\) (positive and negative occurrences are separate nodes);
\(\mathrm{clauseGadget}(c, k)\) for \(k : \mathrm{Fin}\, 6\) — six internal nodes per clause \(c\) encoding the OR constraint.
Given a 3-SAT instance \(f\) over variables \(V\), the reduction graph \(\mathrm{ReductionGraph}(f)\) is the SimpleGraph on \(\mathrm{OutputVertex}(V)\) whose adjacency relation is the symmetrisation of \(\mathrm{EdgeRelation}(f)\): two distinct vertices are adjacent iff \(\mathrm{EdgeRelation}(f, u, v)\) or \(\mathrm{EdgeRelation}(f, v, u)\) holds.
A specific 3-SAT instance over four Boolean variables \(x_0, x_1, x_2, x_3\) (\(V = \mathrm{Fin}\, 4\)), consisting of three clauses: \((x_0 \vee \neg x_1 \vee \neg x_2)\), \((\neg x_0 \vee x_1 \vee \neg x_2)\), and \((\neg x_0 \vee \neg x_1 \vee \neg x_3)\).
Given a satisfying assignment \(\mathrm{assign} : V \to \mathrm{Bool}\), the function \(\mathrm{sat3Coloring}(\mathrm{assign})\) maps every vertex of \(\mathrm{OutputVertex}(V)\) to a color in \(\mathrm{Fin}\, 3\): palette node \(p\) gets color \(p\); a positive (resp. negative) literal node for variable \(v\) gets color \(1\) (True) if \(\mathrm{assign}(v) = \texttt{true}\) and color \(2\) (False) otherwise (resp. the reverse); clause gadget node \((c, k)\) gets \(\mathrm{clauseGadgetColor}\) applied to the truth values of \(c\)’s three literals.
Under assignment \(\mathrm{assign}\), a clause \(c\) is satisfied if at least one of its three literals evaluates to true:
Given a Boolean assignment \(\mathrm{assign} : V \to \mathrm{Bool}\), the function \(\texttt{SATtoColor.SatisfiesLiteral}\) evaluates a literal: a positive literal \(\mathrm{pos}(v)\) evaluates to \(\mathrm{assign}(v)\), and a negative literal \(\mathrm{neg}(v)\) evaluates to \(\neg \, \mathrm{assign}(v)\).
An assignment \(\mathrm{assign}\) satisfies a 3-SAT instance \(f\) if every clause in the list \(f\) is satisfied by \(\mathrm{assign}\), i.e. \(\mathrm{SatisfiesSat3}(\mathrm{assign}, f) = \texttt{true}\) iff \(\forall c \in f,\; \mathrm{SatisfiesClause}(\mathrm{assign}, c) = \texttt{true}\).
A 3-SAT instance \(f\) is satisfiable if and only if the reduction graph is 3-colorable:
This is the conjunction of completeness and soundness of the reduction.
Let \(g \in G\) be an element of order \(q\) and let \(w, r, c \in \mathbb {Z}_q\). Then the honest transcript \((g^r, c, r + c \cdot w)\) satisfies the verifier equation with respect to the public key \(\mathit{pk} = g^w\):
Let \(g \in G\) have order \(q\) and let \(w, c \in \mathbb {Z}_q\). The honest transcript map \(r \mapsto \mathrm{honest}(g, w, r, c)\) and the simulator map \(r \mapsto \mathrm{simulate}(g,\, g^w,\, c,\, \sigma _{w,c}(r))\) are equal as functions \(\mathbb {Z}_q \to \mathrm{Transcript}(G, q)\), where \(\sigma _{w,c} = \mathrm{reindex}(w, c)\) is the bijective shift \(r \mapsto r + c \cdot w\).
Let \(g \in G\) have order \(q\), and let \(a \in G\), \(c_1 \neq c_2 \in \mathbb {Z}_q\), \(s_1, s_2 \in \mathbb {Z}_q\) be such that both transcripts \((a, c_1, s_1)\) and \((a, c_2, s_2)\) satisfy \(\mathrm{Verify}\) with respect to public key \(\mathit{pk} = g^w\). Then the extractor recovers the witness:
The zero-knowledge simulator, given public key \(\mathit{pk}\), challenge \(c\), and a fresh response \(s\), outputs the transcript \((g^s \cdot (\mathit{pk}^c)^{-1},\; c,\; s)\). The commitment is chosen so that the transcript is accepting without using the witness.
A Schnorr transcript is a triple \((a, c, s) \in G \times \mathbb {Z}_q \times \mathbb {Z}_q\), where \(a\) is the prover’s commitment (an element of the group \(G\)), \(c \in \mathbb {Z}_q\) is the verifier’s challenge, and \(s \in \mathbb {Z}_q\) is the prover’s response.
Iterate part (b) from \(r(3,3) = 6\), so \(r(3,3) - 1 = 5\). Taking \(k = l = 2^{n-1}\) each step multiplies by \(5\). The witness is the \(n\)-fold composition of \(C_{5}\) with itself.
The best constructive bound, versus Corollary 7.6’s probabilistic one. With \(k = 2^{n}\), 5\(^{n}\) = k^{log\(_{2}\)5} \(\approx \) k^{2.32} is merely polynomial in \(k\), while \(2^{k/2}\) is exponential — the gap the book remarks on.
Make every street two-way. This embeds undirected graph theory inside directed graph theory: exercise 10.3.6 shows paths in \(G\) correspond exactly to directed paths in \(D(G)\), and \(D(G)\) is \(k\)-arc-connected exactly when \(G\) is \(k\)-edge-connected. Exercise 10.3.1 uses the embedding to derive Dirac’s theorem 4.3 from Ghouila-Houri’s 10.4.
One line: G.Adj is already symmetric and irreflexive, so it is the arc relation of \(D(G)\) — the "two oppositely oriented arcs" are the two directions of the symmetric relation. Note \(D(G)\) is emphatically not an orientation of \(G\) (IsOrientationOf’s second clause fails at every edge); the contrast between doubling and orienting is exactly what §10.6 is about.
The points at which the bridge touches down onto the cycle. Almost everything in §9.4 is a statement about how two bridges’ attachment sets interleave around \(C\) — Overlaps, Skew and the segments below are all built on this one set.
Specialised to H = c.toSubgraph for a closed walk \(c\), since §9.4 only ever needs bridges of a cycle. A Set V, not a Finset, so that .ncard is used for \(k\) (see theorem 9.6’s conclusion). "\(B\) is a \(k\)-bridge" is spelled (G.attach c e).ncard = k, and "\(B\) and \(B'\) are equivalent" is G.attach c e = G.attach c e’.
Cut the cycle at one bridge’s attachment points, producing arcs; the two bridges avoid each other when the second’s attachments all fall inside a single arc, so both can be drawn on the same side of \(C\) without crossing.
The disjunction mirrors the book’s "of one bridge …of the other", which is not symmetric on its face — the definition says only that some assignment of the two roles works. A segment of the bridge of \(e\) is the arc OnArc a b for \(a\), \(b\) consecutive attachments of \(e\).
Both directions are stated contrapositively relative to the book’s phrasing: the Lean \(\leftrightarrow \) has "no augmenting path" on the right, so the book’s first paragraph proves (\(\Rightarrow \)) by contraposition and its second proves (\(\Leftarrow \)) by contraposition.
Augmenting paths are simultaneously the certificate of non-maximality and the means of improvement — which is what makes the Hungarian method of §5.4 work.
Tutte says a perfect matching exists exactly when \(o(G - S) - |S| \le 0\) for all \(S\). Berge’s formula quantifies failure: the maximum, the deficiency \(d\), is exactly how many vertices a maximum matching leaves unsaturated; the remaining \(\nu - d\) pair up.
\(d = 0\) recovers Theorem 5.4. The general-graph analogue of the König–Ore defect formula (5.2.6(a)).
Formalised additively as \(2|M| + d = \nu \) to avoid \(\mathbb {N}\) subtraction on the outside.
! Same caveat as konig_ore_defect: the inner oddComponents.ncard - S.ncard is still natural subtraction and truncates at \(0\). Here that is actually correct, since \(S = \emptyset \) always contributes \(o(G) - 0 \ge 0\) and the book’s max is over a set containing a non-negative value — but it should be re-verified rather than assumed.
\(mn\) with fixed sum \(\nu \) is largest when the parts are equal, giving \(\nu ^{2}/4\); the bound is attained by \(K_{\nu /2,\nu /2}\).
Stated in the cleared form \(4\varepsilon \le \nu ^{2}\) to stay in \(\mathbb {N}\), and bipartiteness as Colorable 2 — Mathlib’s IsBipartite is an abbreviation for exactly that.
Odd cycles are the sole obstruction to \(2\)-colourability — the fact that makes chapter 8 turn on odd cycles throughout.
Bipartiteness as G.Colorable 2; Mathlib’s two_colorable_iff_forall_loop_even is an equivalent loop-based form and may close this more directly than the cycle form.
Hall’s Theorem 5.2 gives a matching saturating \(X\) from the condition on subsets of \(X\) alone. Demanding it for all subsets of \(V\) is symmetric in \(X\) and \(Y\), so it yields matchings saturating each side; together these force \(|X| = |Y|\) and a perfect matching.
! hcov : X \(\cup \) Y = Set.univ is required and has no counterpart in the book’s wording, which takes "bipartition" to cover all vertices by definition. Mathlib’s IsBipartiteWith does not, so without hcov the bipartition could miss vertices that no matching could ever saturate.
A block is connected and has no cut vertex, so no single vertex forms a vertex cut; with at least three vertices this means the smallest vertex cut has size at least \(2\), i.e. \(\kappa (G) \ge 2\).
\(\nu \ge 3\) is needed to exclude the degenerate blocks \(K_{1}\) and \(K_{2}\), which have no cut vertex either but whose connectivity is \(0\) and \(1\) respectively.
This is the bridge that lets Corollary 3.2.2 draw on Theorem 3.2.
The book’s proof is two sentences only because it reuses the \(S\)/\(T\) counting argument (4.4) from Theorem 4.3. In Lean that argument has to exist somewhere concrete — so this lemma, not Dirac, is the right place to write it out, and Dirac then follows from the closure machinery.
Expanded, (4.4) is: from a Hamilton cycle of \(G + uv\) that must use \(uv\), extract a Hamilton path \(v_{1} \dots v_\nu \) in \(G\) with \(v_{1} = u\), \(v_\nu = v\). Put \(S = {v_{i} | u ~ v_{i+1}}\) and \(T = {v_{i} | v_{i} ~ v}\). Then \(v_\nu \notin S \cup T\) gives \(|S \cup T| \lt \nu \), and \(S \cap T = \emptyset \) because a common \(v_{i}\) would close the Hamilton cycle \(v_{1} \dots v_{i} v_\nu v_{\nu -1} \dots v_{i+1} v_{1}\) in \(G\). Hence \(d(u) + d(v) = |S| + |T| \lt \nu \).
Bridges can only meet on \(H\) itself. If a vertex outside \(H\) lay in two bridges, edges of both would meet there, and a walk through it from one to the other stays outside \(H\) — so those edges are related and the two bridges were the same class all along. This is what makes the bridge decomposition genuinely a decomposition: the bridges partition \(E(G) \ E(H)\) and meet only at attachment points.
"Distinct bridges" is hne : \(\lnot \) G.bridgeRel H e e’ — two representative edges in different classes — rather than a disequality of subgraphs, which would be weaker and harder to use. The hypotheses \(he\), \(he'\) placing both edges in G.edgeSet \{} H.edgeSet are present and are needed: without them bridgeOf degenerates (see its docstring).
The picture is a tripod: a hub \(v_{0}\) strictly off the cycle, with three legs reaching down to the three attachment points. This is what the dropped theorem 9.8 uses to dispose of equivalent 3-bridges, and what Kuratowski’s theorem 9.10 uses to locate \(K_{3,3}\) subdivisions.
The "only the vertex \(v_{0}\) in common" conditions are spelled as three \(\forall \) x, x \(\in \) _.support \(\to \) x \(\in \) _.support \(\to \) x = v\(_{0}\) clauses rather than as set equalities, which is what the takeUntil/dropUntil lemmas deliver directly. Note step 5 is genuinely extra work: the book states \(v_{0} \in V(B) \ V(C)\) in the theorem but never justifies it in the proof.
A bridge is one of the connected pieces remaining when \(H\) is removed, together with the attachment points where it touches \(H\). The three "immediate" facts quoted above are bridgeOf_connected, exists_path_internallyDisjoint and bridge_inter_subset_cycle below — none of them is actually immediate once \(\sim \) is a closure. In planar graph theory bridges carry the argument: theorem 9.8 says inner bridges of a cycle avoid one another, theorem 9.9 that a bridge avoiding every outer bridge is transferable, and together these drive Kuratowski’s theorem 9.10.
Indexed by a representative edge \(e\) rather than by a class, so "the bridge containing \(e\)"; two edges give the same bridge exactly when bridgeRel H e f. Built with Subgraph.mk directly — not with SimpleGraph.toSubgraph (Subgraph.lean:559), which is spanning and would put every vertex of \(G\) into every bridge. Note verts is the union of the class’s edges, so it automatically includes the attachment points.
! Because bridgeRel is reflexive for any \(e\) (it is an EqvGen), bridgeOf H e is nonempty even for an \(e\) that is not an edge of \(G\) at all — it then has two vertices and no edges. Statements about bridges must therefore carry e \(\in \) G.edgeSet \{} H.edgeSet explicitly. Two of them below originally omitted it and were false as a result; both now carry it (see the module header).
A bridge is one connected lump: its edges all lie in one \(\sim \)-class, and \(\sim \) relates edges precisely when a walk avoiding \(H\)’s interior joins them.
Together with exists_path_internallyDisjoint this is one of two facts B&M wave through and that everything downstream (theorems 9.6, 9.7 and exercise 9.4.3) actually consumes. Step 3 is the real content and is worth extracting as a lemma about bridgeRel chains, since the same induction is needed for the companion result.
Two edges outside \(H\) are related when you can travel from one to the other without passing through \(H\). Grouping edges into classes carves \(G - E(H)\) into the pieces that hang off \(H\) — those pieces are the bridges.
Relation.EqvGen wraps the book’s raw condition in its reflexive–symmetric–transitive closure, which discharges the book’s "it is easy to verify" rather than proving it: whatever the raw relation does, the closure is an equivalence by construction. This is a deliberate trade — the file gains an equivalence for free, at the cost that bridgeRel is a priori coarser than \(\sim \). It is not actually coarser (the book’s \(\sim \) really is an equivalence), but nothing here proves that, so do not appeal to "bridgeRel e f gives a single connecting walk" — it gives a chain of them. Several skeletons below rely on this distinction.
Corollary 8.1.2 gives \(\chi \le \Delta + 1\) for every graph; Brooks says only two families attain it — odd cycles (\(\chi = 3 = \Delta + 1\)) and complete graphs (\(\chi = n = \Delta + 1\)). Everything else needs only \(\Delta \) colours. The book contrasts this with Vizing’s theorem 6.2, where many graphs satisfy \(\chi ' = \Delta + 1\). The trick of the proof is the ordering: by ending at a vertex two of whose neighbours were forced to share a colour, the greedy algorithm is given one unit of slack exactly where it would otherwise run out.
0 hits in Mathlib — this is a genuine build. hnotcycle is stated as \(\forall \) n, Odd n \(\to \) IsEmpty (G \(\simeq \)g cycleGraph n), i.e. \(G\) is isomorphic to no odd cycle; hnotcomplete as \(G \ne \top \). Both are consumed only in step 2. Step 1’s caveat is worth taking seriously before starting: the reduction to the critical subgraph is stated casually by the book but is not free in Lean.
Theorem 8.1 already gives \(2\varepsilon \ge \nu (k-1)\) for a \(k\)-critical graph; the exercise’s content is the extra \(+1\), which says the bound is never exactly attained — not every vertex can have degree exactly \(k - 1\). That is precisely Brooks in disguise: a \((k-1)\)-regular critical graph would have \(\chi = k = \Delta + 1\), which Brooks forbids outside the two exceptional families.
Both sides are pinned to Type (not Type*) so that the two quantifications range over the same universe and the \(\leftrightarrow \) is well-formed. Note the statement quantifies over graphs, so each direction instantiates the assumed side at a graph it constructs — this is an equivalence of schemas, not of propositions about one fixed \(G\).
If \(H \le K\) then \(\omega (K) \le \omega (H)\) — adding edges can only merge components.
Not a book statement. This is the general lemma that exercise 1.6.8(a) below is the single-edge instance of, and it is extracted here because Trees.lean’s skeleton for corollary 2.7 asks for it by name: *"the monotonicity \(H \le K \to \omega (K) \le \omega (H)\) is used here and is worth a standalone lemma — chapter 1’s exercise 1.6.8(a) needs the same fact."* Both call sites are served by this one declaration.
Stated with Nat.card, matching Trees.numComponents, so that no DecidableEq on the quotient is needed. ! Exercise 1.6.8(a) below uses Fintype.card; over a Fintype carrier the two agree by Nat.card_eq_fintype_card, but the transfer must be written explicitly at the call site.
\(\varepsilon (G) + \varepsilon (G^{c}) = C(\nu , 2)\).
Every unordered pair of distinct vertices carries an edge in exactly one of \(G\) and \(G^{c}\) — that is precisely what complementation means — so the two edge counts partition the \(C(\nu , 2)\) available pairs. Together with the planar edge bound applied to both graphs, this is the whole of exercise 9.3.3(a).
! Missing from Mathlib (0 hits at the time of writing; step 3 is the part most likely to exist already, so search before building). Needs both DecidableRel G.Adj and DecidableRel G\(^{c}\).Adj as instances, since edgeFinset is only available with decidable adjacency.
Two genuinely geometric inputs, neither in Mathlib: 1. Any four points in the plane determine an angle \(\ge 90^{\circ }\) — a convex-hull case analysis (line / triangle / quadrilateral). 2. The law of cosines consequence: an angle \(\ge 90^{\circ }\) at \(x_{j}\) with both adjacent sides \(\gt 1/\sqrt2\) forces the opposite side \(\gt 1\).
Given those, farGraph is \(K_{4}\)-free and turan_edge_bound at \(m = 3\) finishes.
Needing \(k\) colours is not a global accident — it forces \(k\) distinct vertices each locally rich enough (degree \(\ge k - 1\)) to be part of the obstruction. The critical subgraph is what localises the difficulty; without it, "\(G\) needs \(k\) colours" says nothing about any individual vertex.
Step 3 is stated about G.degree, not H.coe.degree, which is why the filter in the goal mentions only \(G\) — the critical subgraph is existential and does not appear in the statement.
Every vertex of \(X\) may be matched to any vertex of \(Y\), so a perfect matching is exactly a bijection \(X \to Y\). There are \(n!\) of those.
This is why the optimal assignment problem of §5.5 has \(n!\) candidate solutions and brute force is hopeless — the book makes exactly that point on p. 94.
A perfect matching of \(K_{2n}\) partitions \(2n\) labelled objects into \(n\) unordered pairs. Lining them up gives \((2n)!\) arrangements; each matching arises from \(2^n \cdot n!\) of them (swap within each pair, permute the pairs). So the count is \((2n)! / (2^n \cdot n!)\), the double factorial \((2n-1)!! = 1 \cdot 3 \cdot 5 \cdots (2n-1)\).
! The Lean statement uses natural-number division. It happens to be exact here, but the proof cannot manipulate it as division — it must establish Nat.card … (2 ^ n n !) = (2 * n)! and then divide, or the Nat.div will obstruct every rewrite.
A simple graph on a labelled vertex set is determined by which of the \(C(n,2)\) possible edges are present.
! Mathlib has a Fintype (SimpleGraph (Fin n)) instance but no cardinality lemma, so this genuinely has to be proved. The route is an equiv SimpleGraph (Fin n) \(\simeq \) (Sym2 (Fin n) \{} diagonal \(\to \) Bool), or via Finset.powerset on the non-diagonal Sym2s — the Sym2 bookkeeping is the work, not the arithmetic.
The counting fact underlying Erdős’ probabilistic proof of Theorem 7.6.
Two distinct points have \(\le 2\) common unit-distance neighbours (two unit circles meet in \(\le 2\) points), so the graph is \(K_{2,3}\)-free; 7.3.4(b) at \(m = 3\) gives \(\varepsilon \le (\sqrt2 \cdot n^{3/2})/2 + n/4 = n^{3/2}/\sqrt2 + n/4\).
A purely combinatorial bound on a geometric quantity, obtained by turning a fact about circles into a forbidden subgraph. The true order of growth of the unit-distance problem is still open (Erdős).
In a diameter-1 set, a pair at distance exactly \(1\) is a diameter pair. The key geometric fact: two diameter pairs must cross or share a point — if \(ab\) and \(cd\) were disjoint diameters, one of the four cross distances would exceed \(1\).
That crossing property forces the diameter graph to have \(\le n\) edges.
Contrast exercise 7.3.4(c), where without the diameter restriction the bound is of order \(n^{3/2}\); bounding the diameter collapses it to linear.
! B&M caution that \(n^{n-2}\) counts distinct spanning trees, not non-isomorphic ones: \(K_{6}\) has six non-isomorphic ones but \(6^{4} = 1296\) distinct.
Mathlib has no Cayley formula and no Prüfer correspondence, so all four steps are from scratch — the largest single item in the chapter.
The edge chromatic number \(\chi '(G)\) is the chromatic number of the line graph \(L(G)\), whose vertices are the edges of \(G\) with adjacency "shares an end". So Brooks’ vertex-colouring theorem yields an edge-colouring bound, recovering for cubic graphs what Vizing’s theorem 6.2 gives in general.
Two departures from the book, both weakenings. (i) \(\chi '\) is spelled as \(\chi \)(lineGraph); there is no separate chromaticIndex here. (ii) The book says loopless, which in B&M permits parallel edges; SimpleGraph has none, so this is the simple-graph case only. With multiplicities the degree count in step 1 is unchanged, but lineGraph would have to be redefined, so the weakening is deliberate. Note also that the exercise is stated with \(\Delta = 3\) exactly, not \(\Delta \le 3\); only \(\le \) is used.
Many edges force many colours: each colour class is edge-free, so large classes leave too little room for edges. Equality holds exactly for balanced complete multipartite graphs, where every non-edge is inside a class and all classes have the same size.
Stated multiplicatively over \(\mathbb {R}\) — \(\nu ^{2}/(\nu ^{2} - 2\varepsilon )\) would need division and a proof that the denominator is nonzero. (It always is: \(G\) simple gives \(2\varepsilon \le \nu (\nu -1) \lt \nu ^{2}\), so \(\nu ^{2} - 2\varepsilon \ge \nu \gt 0\) whenever \(V\) is nonempty, whence the [Nonempty V] hypothesis.) \(\chi \) is replaced by an arbitrary \(k\) with G.Colorable k, dodging \(\mathbb {N}\infty \); this is equivalent to the book’s statement, since the right-hand side is monotone in \(k\) and \(\chi \) is the least colourable \(k\).
No colour can be used on both sides of a join, so the two palettes are forced to be disjoint and the chromatic numbers simply add. This makes joins a convenient way to build graphs of prescribed chromatic number, and is why the wheel \(C_n \lor K_{1}\) needs \(\chi (C_n) + 1\) colours.
Addition is in \(\mathbb {N}\infty \); both summands are finite here (finite carriers), so it is ordinary addition, but the casts still need care — extracting \(a\), \(b\) as naturals up front, as in step 1, keeps the arithmetic in \(\mathbb {N}\). [Nonempty \(\alpha \)], [Nonempty \(\beta \)] ensure both sides genuinely contribute.
Needing many colours forces many edges: a \(\chi \)-chromatic graph carries at least as many edges as \(K_\chi \). So a sparse graph cannot have a large chromatic number.
The book’s \({x}\) denotes the ceiling, rendered as \(\lceil \cdot \rceil _{+}\) (Nat.ceil), which is the correct choice here since the quantity is nonnegative. Real.sqrt needs a real argument, hence the cast on \(2 * \varepsilon \).
Odd cycles are the sole obstruction to 2-colourability, so if they all pile up on one shortest cycle, only a bounded amount of extra colour is needed to handle them. Minimality in step 2 is what makes the cycle induced, and hence 3-colourable rather than merely small.
The hypothesis quantifies over all pairs of closed walks that are cycles of odd length, and asks for a common support vertex. Note \(h\) is also applied with \(p = q\) in step 2’s minimality argument, where it is vacuous — the content is only in the disjointness contradiction of step 4.
Colour the vertices one at a time in any order: when a vertex’s turn comes it has at most \(\Delta \) neighbours, so at most \(\Delta \) colours are forbidden and one of \(\Delta + 1\) is always free. The book observes the bound *is sometimes very much greater than the actual value* — bipartite graphs are 2-chromatic with arbitrarily large \(\Delta \) — making it weaker than Vizing’s edge analogue (theorem 6.2) in one sense; and weaker in a second sense too, since many graphs satisfy \(\chi ' = \Delta + 1\) whereas Brooks’ theorem 8.4 shows only two families satisfy \(\chi = \Delta + 1\).
The book’s route is recorded because it is the book’s, but the direct route is preferred: it avoids depending on exists_isKCritical_subgraph and IsKCritical.minDegree_ge, both of which are substantially harder than this corollary. This is the cheapest genuine win in the file — a good first fill.
The second coefficient of the chromatic polynomial simply counts the edges. The mechanism is that each deletion–contraction step peels off exactly one copy of the contracted graph’s leading term, and the contracted graph has degree one less — so the \(k^{\nu -1}\) coefficient decrements once per edge. This is a first small step toward the general question of which polynomials are chromatic, and it is what makes exercise 8.4.2(b) possible.
\(p\) is a hypothesis rather than a construction, which is why step 1 is needed at all — without uniqueness there is no link between the \(p\) given here and the one corollary 8.6 builds. That uniqueness lemma is worth stating once and reusing in exercises 8.4.2(b) and 8.4.8.
\(\pi _k(G)\) counts colourings, so it is positive at every integer \(k \ge \chi (G)\), and \(\chi (G) \le \nu \) always. The exercise strengthens this from integers to all reals: beyond \(\nu \) the polynomial has no zero whatsoever. The book notes that the roots of chromatic polynomials exhibit an unexpected regularity for planar graphs, citing Tutte (1970) on their connection with the golden ratio.
Over \(\mathbb {R}\) here (not \(\mathbb {Z}\) as in corollary 8.6), since the claim is about real roots; \(hp\) ties \(p\) to the integer-valued counting function at naturals only, which is exactly what step 1 needs. Step 2 is the substantial piece and is of independent interest — it is the standard proof that \(\pi _k\) is a polynomial at all, and an alternative to corollary 8.6’s induction.
The family \({C_{m,\nu }}\) consists of the degree-maximal nonhamiltonian graphs: any nonhamiltonian graph has degrees dominated, position by position, by one of them.
Corollary 4.6 — bounding the edge count of a nonhamiltonian graph reduces to computing \(\varepsilon (C_{m,\nu })\).
\(\alpha \) is the independence number and \(\kappa \) the connectivity, so the hypothesis says the graph is at least as well connected as it is "spread out". This is one of the most elegant sufficient conditions for hamiltonicity known, and the whole bridge apparatus of §9.4 that survives in this file exists to reach it — it is the prize of the surviving combinatorial core.
! h\(\nu \) : 3 \(\le \) Fintype.card V is load-bearing and is not in B&M — the statement is false without it. \(K_{2}\) has \(\alpha = 1\) and \(\kappa = 1\), so \(\alpha \le \kappa \) holds, yet \(K_{2}\) has no Hamilton cycle, there being no cycle of length two. (\(K_{1}\) is similar.) Step 5 is where most of the work sits; step 4’s cut argument is the part most likely to need its own supporting lemma.
! The hypothesis is formalised in counting form, not by indexing the sorted degree sequence. The book’s \(d_m \le m\) says "at least \(m\) vertices have degree \(\le m\)", and \(d_{\nu -m} \lt \nu - m\) says "at least \(\nu - m\) vertices have degree \(\lt \nu - m\)" — precisely the two Finset.filter cardinalities in hcond. This avoids all \(1\)- versus \(0\)-indexing hazards around degreeSequence, at the cost of no longer looking like the book’s inequality.
The book’s \(m \lt \nu /2\) is written \(2 * m \lt \nu \), and \(m \ge 1\) is made explicit (the book’s \(m\) is a degree \(d'(u)\), and \(m = 0\) is excluded by connectivity considerations implicit in "as large as possible").
The Hamilton-path counterpart of Theorem 4.5, with thresholds shifted by one. Formalised in counting form, exactly as Theorem 4.5 is — see the note there on why indexing the sorted sequence is avoided.
Note the strict \(d_m \lt m\) here versus \(d_m \le m\) in Theorem 4.5; the hcond filters use \(\lt \) accordingly.
One of the cleanest results in generalised Ramsey theory: the answer depends on the tree only through its number of vertices, not its shape.
Lower bound. Partition \((m-1)(n-1)\) points into \(n-1\) groups of \(m-1\); red inside groups, blue between. Red is a disjoint union of \(K_{m-1}\)s, too small for a tree on \(m\) vertices; blue is complete \((n-1)\)-partite, so its largest clique has \(n-1\) vertices — no \(K_{n}\).
Upper bound. On \((m-1)(n-1) + 1\) points, if blue has no \(K_{n}\) then Turán-type reasoning gives red minimum degree \(\ge m-1\) somewhere, and the sub-lemma embeds \(T\).
! Same heterogeneous-carrier spelling as part (b).
! The upper bound’s "Turán-type reasoning" is genuinely §7.3’s Theorem 7.9 — so this exercise depends on the next section, not just on §7.2.
Look for two vertices not yet joined but which between them already have at least \(\nu \) neighbours; Lemma 4.4.1 says adding the edge changes nothing about hamiltonicity, so add it. Repeat until no such pair is left.
ClosureStep G H captures a single such addition, H = G \(\sqcup \) edge u v. The closure is then reached by Relation.ReflTransGen ClosureStep, and "no such pair remains" is expressed at the use site as \(H = \top \) or as the absence of a further step, rather than by a fixpoint operator.
Defining \(c(G)\) as a function presupposes Lemma 4.4.2 — that the result is independent of the order in which edges are added — and that lemma is itself one of the chapter’s results. Positing the fixpoint would therefore assume what the chapter sets out to prove. Using the step relation keeps the development honest; the price is that statements below quantify over ReflTransGen ClosureStep chains instead of mentioning \(c(G)\) directly.
Degree is Nat.card (G.neighborSet \(\cdot \)) so the relation is well-typed for arbitrary graphs on \(V\) without a DecidableRel instance.
Take \(m\) "hub" vertices forming a complete graph, \(m\) isolated vertices, and a complete graph on the remaining \(n - 2m\); then join every hub to everything else. Carrier Fin m \(\oplus \) (Fin m \(\oplus \) Fin (n - 2 * m)), with \(K_m^{c} = \bot \) on Fin m.
Degrees: the \(m\) hubs have degree \(n - 1\), the \(m\) isolated vertices have degree \(m\), and the remaining \(n - 2m\) have degree \(n - m - 1\). That is the degree sequence Theorem 4.6 majorises against.
! The side condition \(1 \le m \lt n/2\) is not carried in the type. For \(m = 0\) or \(2m \gt n\) the definition still elaborates (with \(n - 2 * m\) truncating to \(0\)) but no longer matches the book’s figure. Callers must supply the bound.
Every pair is joined in \(G^{c}\) by a path of length at most \(2\), so \(G^{c}\) is connected — indeed of diameter \(\le 2\). Equivalently: at least one of \(G\), \(G^{c}\) is always connected.
! Steps 2–3 need \(u \ne w\) and \(v \ne w\), which follow from them being in different components; and "different components" must be extracted from \(\lnot \) Connected — Preconnected failing gives an unreachable pair.
A graph and its complement cannot both be "spread out": if \(G\) is very stretched, \(G^{c}\) must be very compact.
! G.diam is \(\mathbb {N}\)-valued and Mathlib returns \(0\) for a disconnected graph, so 3 < G.diam silently carries "\(G\) is connected" — worth making explicit before relying on step 1.
\(K_{m,n}\) contains exactly one edge for each choice of a vertex in \(X\) and one in \(Y\), so edges biject with \(X \times Y\).
The carrier is Fin m \(\oplus \) Fin n, so "opposite sides" is a Sum case split; step 1’s well-definedness is the only fiddly point.
Label both sides by ZMod n; for each \(i\), let \(H_{i}\) join \(x_a\) to \(y_{a+i}\) for every \(a\). Each \(H_{i}\) is a 1-factor, distinct \(i\) give edge-disjoint matchings, and every edge \(x_a y_b\) occurs in exactly the one with \(i = b - a\).
In chapter 6’s language: \(K_{n,n}\) has chromatic index \(n\), its minimum possible value — the round-robin schedule for \(n\) workers and \(n\) jobs.
The classical round-robin schedule. Fix one vertex at the centre and arrange the other \(2n - 1\) in a circle. In round \(i\), match the centre with circle vertex \(i\) and pair the remaining circle vertices symmetrically about the line through it. Rotating gives \(2n - 1\) rounds, each a perfect matching, together using every edge exactly once.
So \(2n\) players can be scheduled in \(2n - 1\) rounds with every pair meeting once. This fails for odd order, where no perfect matching exists at all.
A connected 2-factor is precisely a Hamilton cycle — a spanning connected 2-regular subgraph must be one cycle through every vertex. So this asks for a decomposition of \(K_{2n+1}\)’s edges into Hamilton cycles.
The count works: \(K_{2n+1}\) has \(n(2n+1)\) edges and each Hamilton cycle uses \(2n + 1\), so exactly \(n\) cycles are needed.
The odd-order companion to 5.1.5(a)(i): odd complete graphs decompose into Hamilton cycles, even ones into perfect matchings.
Deleting an edge only destroys connections, never creates them; and it affects only the component containing \(e\), which can break into at most the parts reachable from each end. An edge whose deletion does raise the count is a cut edge, the subject of §2.3. ! Part (b), not stated here, notes the analogue fails for vertex deletion — removing one vertex can create many components.
Replace each vertex of \(G\) by a copy of \(H\). Vertices in different copies are joined iff the corresponding \(G\)-vertices are adjacent; within one copy, iff adjacent in \(H\). The \(G\)-structure dominates — hence the alternative name lexicographic product.
+ Fully defined, symm and loopless both discharged — no sorry.
! Distinct from chapter 6’s boxProd (\(G \square H\)), where within-copy and across-copy edges are treated symmetrically. Composition is not commutative.
Parts (b) and (c) of the exercise, to multiply Ramsey lower bounds.
\(\nu - 1\) edges is the minimum price of connecting \(\nu \) vertices, and trees are precisely the connected graphs paying exactly that price. ! Compare exercise 2.1.5, not stated here: for a graph with exactly \(\nu - 1\) edges, connected, acyclic and tree are all equivalent.
A tree is exactly a connected graph with no redundancy — every single edge indispensable for keeping it in one piece. ! Exercise 2.2.1, not stated here, drops the connectivity hypothesis: \(G\) is a forest iff every edge is a cut edge.
The arc from \(a\) forwards to \(b\) is then exactly one segment of the bridge — an arc of \(C\) with attachments at both ends and none in between. Ranging over all consecutive pairs recovers the book’s partition of \(C\).
"No attachment strictly between" is phrased as: every attachment on the closed arc is one of the two endpoints. This is what makes the segments partition \(C\) rather than merely cover it. The definition does not require the bridge to have \(k \ge 2\) attachments; with fewer, no pair satisfies it, and Avoids below is then false for want of a witness — which is the right answer, since a \(0\)- or \(1\)-bridge has no segments to contain anything.
\(G \cdot e\) (§2.4). Mathlib has no edge contraction for SimpleGraph. NOTE: a genuine contraction identifies the ends of \(e\) and therefore changes the carrier type (to \(|V| - 1\) vertices). Here it is stubbed on the same carrier \(V\) as a placeholder, purely so that the deletion–contraction recurrence (Theorem 2.8) can be typed.
Think of \(e = uv\) as a string pulled tight until \(u\) and \(v\) merge; everything attached to either is now attached to the merged vertex, and \(e\) disappears. For a link, \(\nu (G\cdot e) = \nu - 1\), \(\varepsilon (G\cdot e) = \varepsilon - 1\), \(\omega (G\cdot e) = \omega \) — so contracting an edge of a tree again yields a tree, which is what makes deletion–contraction work.
! Defective on two counts. 1. sorry body. \(G \cdot e\) is an opaque graph, so theorem 2.8 relates opaque quantities and asserts nothing. 2. Wrong carrier. A genuine contraction has \(\nu - 1\) vertices; this is stubbed on the same carrier \(V\) purely so theorem 2.8 can be typed. Even given an honest body on \(V\), the identity \(\nu (G\cdot e) = \nu - 1\) could not hold.
The repair is to move to the quotient carrier \({x : V // x \ne v}\) with \(v\)’s incidences re-pointed at \(u\), exactly as chapter 10’s Digraph.contractEdge does — that definition is honest and complete, and can be transcribed.
Pull the edge \(uv\) tight until \(u\) and \(v\) merge into a single vertex, which inherits the neighbours of both. Contraction appears twice in this chapter: in theorem 8.3, where \(G_{2} \cdot uv\) is shown to be \(k\)-critical, and in theorem 8.6, the deletion–contraction recursion for the chromatic polynomial — which the book notes *bears a close resemblance to the recursion formula for \(\tau (G)\)* in theorem 2.8.
Identification is realised by dropping \(v\) from the carrier and re-pointing its edges at \(u\), so the carrier is \({x : V // x \ne v}\) and the merged vertex is \(u\). The \(a \ne b\) conjunct in Adj restores looplessness: the book’s contraction of a multigraph may create loops and parallel edges, and taking the underlying simple graph is exactly what discarding them means. This is harmless for both uses — theorem 8.6 is stated for simple \(G\), and colourings never see loops or multiplicities.
The exact mirror of theorem 2.5, with cycle \(\to \) bond and *spanning tree \(\to \) cotree*. * Chapter 12’s fundamentalBondVertexSet is exactly the \(S\) of step 3, and cites this theorem by name.
! Both parts consume IsBond, whose \(\emptyset \) defect is active here — but hG : G.Connected is available as a hypothesis, which is precisely the condition under which the defect disappears. Use it explicitly rather than relying on it silently.
The fewest vertices touching every edge. \(\alpha \) is Mathlib’s indepNum; only \(\beta \) needs defining here.
+ No sInf \(\emptyset \) = 0 pitfall: Set.univ is always a covering, so the set being minimised is never empty. Contrast edgeCoveringNumber below, where the trap is live.
The corners and edges of a \(k\)-dimensional cube: \(k\)-regular, bipartite (split by the parity of the number of \(1\)s), \(2^k\) vertices, \(k\cdot 2^{k-1}\) edges.
Adjacency is the book’s condition literally: \(\exists ! i, x i \ne y i\).
! Note this file defines cube directly as a structure, whereas GraphsAndSubgraphs.lean defines the same graph as SimpleGraph.fromRel (fun x y => \(\exists \)! i, x i \(\ne \) y i). The two are equal but not definitionally so, and neither imports the other.
A circulant on ZMod 13. \({1, 5, 8, 12}\) is closed under negation (\(-1 = 12\), \(-5 = 8\)), which is exactly what makes symm hold — so unlike most defs in this repo, symm and loopless are genuinely discharged, by decide.
+ Fully defined, no sorry — one of the few complete constructions in the directory.
Cut edges are exactly the edges lying on no cycle: an edge on a cycle has a detour around it, while an edge on no cycle is the sole link between the two sides it joins.
Mathlib’s IsBridge is B&M’s cut edge. Note the conclusion carries G.Adj v w as a conjunct, which IsBridge includes — a non-edge is not a bridge.
Any three of five cyclic positions include two consecutive ones, hence adjacent. So \(\alpha (C_{5}) = 2\).
\(C_{5}\) is self-complementary, which is what makes it work on both sides at once — the book conjectures (§7.2, p. 114) that all \((k,k)\)-Ramsey graphs are.
\(2\varepsilon /\nu \) is the average degree, since the degrees sum to \(2\varepsilon \) and there are \(\nu \) of them; an average lies between the extremes.
Stated multiplicatively to avoid division: \(\nu \cdot \delta \le 2\varepsilon \le \nu \cdot \Delta \). [Nonempty V] keeps minDegree/maxDegree meaningful — both are sInf/sSup-like and degenerate on an empty carrier.
Line up both degree sequences in increasing order and compare entry by entry; \(G\) is degree-majorised by \(H\) when \(H\) wins or ties at every position.
Quantifying over all \(i : \mathbb {N}\) with getD i 0 rather than over Fin \(\nu \) is deliberate: past the end of both lists the comparison is \(0 \le 0\), so the extra indices are harmless and no bounds proof has to be threaded through.
The book remarks (§7.3, p. 118) on the parallel with Theorem 4.6:
! Blocked on degreeSequence being unsorted — see the warning there. The book’s DegreeMajorised compares nondecreasing sequences; against this file’s unsorted list the predicate is not even isomorphism-invariant, so the equality clause (same degree sequence \(\to \) G \(\cong \) H) cannot be right as stated. Fix degreeSequence first.
! The carrier changes: \(H\) is existentially quantified over a fresh type \(W\), so DegreeMajorised G H compares across types via the Fintype.card V = Fintype.card W conjunct.
(absent from Mathlib). *If \(d_G(v) \le d_H(v)\) for every vertex \(v\), then \(G\) is degree-majorised by \(H\).*
Degree-majorisation compares sorted sequences entrywise. Pointwise domination survives sorting: the \(i\)-th smallest degree of \(G\) cannot exceed the \(i\)-th smallest of \(H\).
! Two problems with this as stated.
1. degreeSequence in this file is unsorted, so "sorting preserves domination" is not what the predicate says — the entrywise comparison is against Finset.univ.toList’s arbitrary order. With both graphs on the same \(V\) that order is at least the same on both sides, so pointwise domination does happen to give the conclusion — but only by accident of the shared carrier, not because the lemma is right. 2. It is stated for G H : SimpleGraph V on the same carrier, whereas Theorem 7.8 needs it across different carriers (\(G\) on \(V\), \(H\) on \(W\)). So it does not actually discharge the step it was extracted for.
Simply list how many neighbours each vertex has, smallest first.
Degree is written Nat.card (G.neighborSet v) rather than G.degree v, so the definition works for any graph on a Fintype without threading a DecidableRel G.Adj instance; the two agree when \(V\) is finite.
The book indexes from \(1\) (\(d_{1} \le \dots \le d_\nu \)); the Lean list is \(0\)-indexed, so the book’s \(d_m\) is degreeSequence.getD (m - 1) 0. Statements below that quote Theorem 4.5 must account for that shift.
Chvátal’s Theorem 4.5 reads hamiltonicity off this list alone; Theorem 4.6 and Corollary 4.6 compare two such lists via DegreeMajorised.
Mycielski’s construction (theorem 8.7) removes triangles but still leaves 5-cycles. Descartes’ construction is stronger — it keeps the girth at six or more, so the graphs have no short cycles at all, and yet the chromatic number still climbs without bound. Blanche Descartes (1954) gave the original recursive construction; the book calls Mycielski’s the easier one, which is why §8.5 proves theorem 8.7 in the text and relegates this to a starred exercise.
The conclusion is \(\ge k + 1\), not \(= k + 1\): the construction gives a lower bound and the exercise asks only for that. Likewise 6 \(\le \) girth rather than \(= 6\). Step 1 is most of the Lean work — the indexed family of copies and the per-copy matching bijection have to be built explicitly, and Fintype instances derived for the resulting carrier.
If every vertex is joined to at least half the graph, there is enough adjacency that a spanning cycle cannot be avoided.
\(\delta \ge \nu /2\) is formalised as \(\nu \le 2\delta \) to stay in the natural numbers and avoid the rounding ambiguity of \(\nu /2\) under truncated division.
Sum every entry two ways. By rows: \(1\) each, so \(m\) in total. By columns: \(1\) each, so \(n\). Hence \(m = n\).
! Restated, not transcribed. Mathlib’s doublyStochastic is square *by type*, so the literal statement would be vacuous. This version takes a genuinely rectangular Matrix m n \(\mathbb {R}\) with the two summation hypotheses given explicitly, which is what the exercise actually asks.
Note the non-negativity hypothesis is not needed for this part and is omitted.
A closed trail may revisit vertices, so it need not be a cycle; the claim is that it can be pared down to one through any chosen edge. ! The analogous statement for walks is false — a walk may traverse the same edge back and forth with no cycle present — which is why ht : c.IsTrail (distinct edges) is a hypothesis and not decoration.
hpos : 0 < c.length excludes the trivial closed walk, for which \(he\) would be unsatisfiable anyway but which would otherwise complicate step 1.
Exercise 1.1.3 gives \(\varepsilon \le C(\nu ,2)\); equality means the injection from edges to pairs is onto, i.e. every pair carries an edge — the definition of complete.
"Complete" is \(G = \top \), the top of the lattice of simple graphs on \(V\).
a \(k\)-edge-connected graph satisfies \(k\nu \le 2\varepsilon \).
Stated multiplicatively as \(k\nu \le 2\varepsilon \) to stay in the natural numbers and avoid division.
By Theorem 3.1, \(k \le \kappa ' \le \delta \), so every vertex has degree at least \(k\). Summing over all \(\nu \) vertices gives \(\sum _v d(v) \ge k\nu \), and handshaking (Theorem 1.1) says that sum equals \(2\varepsilon \). Hence \(2\varepsilon \ge k\nu \).
A network that survives any \(k\) link failures must give every station at least \(k\) links, so it cannot be sparse — this is exactly the lower bound \(f(m, n) \ge \lceil mn/2\rceil \) of (3.1), which §3.3 shows the Harary graphs attain.
\(G \square H\) has degree \(d(u) + d(v)\) at \((u, v)\), so \(\Delta (G \square H) = \Delta (G) + \Delta (H)\). Decompose \(H\) into \(\Delta (H)\) matchings via its optimal colouring; each matching crossed with \(G\) reproduces part (a)’s situation, and assembling gives \(\Delta (G) + \Delta (H)\) colours.
So the class attaining \(\chi ' = \Delta \) is closed under products with any nontrivial member — one of the few general constructions guaranteeing the lower Vizing class.
\(H\) nontrivial is 0 < H.maxDegree; without it \(H\) is edgeless, \(G \square H\) is a disjoint union of copies of \(G\), and the claim reduces to \(\chi '(G) = \Delta (G)\) which need not hold.
The book’s "product" is exactly Mathlib’s boxProd, written \(\square \).
\(G \square K_{2}\) is two disjoint copies of \(G\) plus a perfect matching joining corresponding vertices, so every degree rises by one and \(\Delta (G \square K_{2}) = \Delta (G) + 1\).
Vizing gives \(G\) a proper \((\Delta (G)+1)\)-colouring. Use it on both copies, then colour the connecting matching edges by recycling — each vertex of a copy already omits at least one of the \(\Delta (G)+1\) colours, and the two copies can be arranged to omit different ones, so each matching edge finds a free colour.
\(K_{2n}\) has \(\Delta = 2n - 1\), so (6.1) gives \(\chi ' \ge 2n - 1\). For the upper bound use the round-robin schedule of exercise 5.1.5(a)(i): the edges partition into \(2n - 1\) perfect matchings, and colouring each with its own colour is proper. So \(\chi ' = \Delta \) and even complete graphs sit on the lower side of the dichotomy.
The contrast with the odd case is entirely parity: with an odd number of vertices no round can involve everybody.
\(K_{2n-1}\) has odd order, so no colour class is a perfect matching and each misses a vertex. With \(\varepsilon = (2n-1)(n-1)\) and classes of size \(\le n - 1\), at least \(2n - 1\) colours are needed — one more than \(\Delta = 2n - 2\). So odd complete graphs sit on the upper side of Vizing’s dichotomy.
The explicit colouring: place the vertices at the corners of a regular \((2n-1)\)-gon and colour each edge by the axis of symmetry it is perpendicular to. Each class is a matching of \(n - 1\) edges missing one vertex, and there are \(2n - 1\) axes.
Concretely in ZMod (2n-1): colour \(s(a, b)\) by \(a + b\). Two edges at a shared vertex get different sums because \(2\) is invertible mod an odd number — which is exactly where oddness enters.
An odd-order \(k\)-regular graph on \(2n + 1\) vertices has \(\varepsilon = k(2n+1)/2\) and \(\Delta = k\). Deleting fewer than \(k/2\) edges cannot lower \(\Delta \), and leaves the count above \(nk\), so part (a) applies.
Odd-order regular graphs stay firmly in the upper Vizing class under small perturbation: at least \(k/2\) edges must go before the conclusion can fail.
\(|F| \lt k/2\) is stated as 2 * F.card < k to avoid \(\mathbb {N}\) division.
With \(\nu = 2n + 1\) odd, every matching covers an even number of vertices so has \(\le n\) edges. A proper \(\Delta \)-colouring accounts for at most \(n\Delta \) edges; \(h\varepsilon \) says there are more, so \(\Delta \) colours cannot suffice and Vizing supplies exactly one more.
+ The reusable engine of §6.2’s exercises — 6.2.2, 6.2.3(b)(i) and 6.2.3(b)(ii) all reduce to it. Worth proving first among them.
Each colour class is a matching, and a matching on an odd number of vertices misses one, so has \(\le (\nu -1)/2\) edges. A \(k\)-regular graph has \(\varepsilon = k\nu /2\), and a proper \(k\)-colouring would need \(k\nu /2 \le k(\nu -1)/2\) — false. So \(\Delta = k\) colours do not suffice, and Vizing gives exactly one more.
Generalises the odd complete graph of exercise 6.2.1: regularity plus odd order always forces the upper class.
Contrapositive: if \(\chi ' \gt \Delta \), an optimal \(\Delta \)-colouring cannot be proper, so by (6.3) some \(u\) has \(c(u) \lt d(u)\) — a colour missing while another repeats. That is Lemma 6.1.2’s hypothesis, which forces an odd cycle, so \(G\) is not bipartite.
! The book’s "Clearly, \(u\) satisfies the hypothesis of lemma 6.1.2" compresses a real step. From \(c(u) \lt d(u)\) one gets some colour repeated at \(u\); getting a colour not represented at \(u\) needs the pigeonhole \(c(u) \lt d(u) \le \Delta \) — i.e. that only \(\Delta \) colours are available and fewer than \(d(u)\) are used. With \(d(u) \le \Delta \) this is tight and worth isolating.
! The odd cycle produced by Lemma 6.1.2 lives in twoColourSubgraph C i j, a subgraph of \(G\). Transporting it to an odd cycle of \(G\) (to contradict bipartiteness) requires a walk-level map along twoColourSubgraph \(\le \) G, which is not stated in this file.
Start from \(k\)-regular on \(2n\) vertices, \(\varepsilon = kn\). Subdividing inserts a degree-\(2\) vertex: \(2n + 1\) vertices — now odd — and \(kn + 1\) edges, with \(\Delta \) still \(k\) provided \(k \ge 2\). Part (a) then applies since \(kn + 1 \gt kn = n\Delta \).
A single subdivision flips the parity of the vertex count and pushes the graph from the lower to the upper side of Vizing’s dichotomy.
! \(hk : 2 \le k\) is load-bearing: at \(k = 1\) the new degree-\(2\) vertex would raise \(\Delta \) to \(2\), and the count \(n\Delta \) would change with it, breaking the application of part (a).
A total function Sym2 (Fin n) \(\to \) Fin m — colouring every pair, including the diagonal, which is harmless since IsRamseyBoundMulti only inspects \(s(u,v)\) for \(u \ne v\).
! Not Mathlib’s SimpleGraph.Coloring, which colours vertices. Also not chapter 6’s G.edgeSet \(\to \) Fin k, which is partial (defined only on actual edges); here the host graph is \(K_{n}\), so every pair is an edge and a total function is right.
"One easily sees" that the two formulations agree for \(m = 2\) — but this file does not state that equivalence, so ramseyNumber and ramseyNumberMulti at \(m = 2\) are formally unrelated. Anything wanting to move between §7.2’s two halves needs that bridge.
\(\kappa \)’ = sInf {F.card | G.IsEdgeCut F}, with no \(if\) guard: the book’s special case "\(G\) trivial \(\Rightarrow \) \(\kappa ' = 0\)" is already delivered by Nat.sInf \(\emptyset \) = 0, since a trivial graph is connected and so admits no edge cut at all. That convention is used directly in edgeConnectivity_le_minDegree.
, second inequality: \(\kappa ' \le \delta \).
If \(G\) is trivial then \(\kappa ' = 0 \le \delta \). Otherwise take \(v\) with \(d(v) = \delta \); the \(\delta \) edges incident with \(v\) form an edge cut, since deleting them isolates \(v\). Hence \(\kappa ' \le d(v) = \delta \).
The fewest edges touching every vertex.
! sInf \(\emptyset \) = 0 is a live trap here, unlike coveringNumber. When \(\delta = 0\) no edge covering exists, the set being minimised is empty, and Lean’s convention silently returns \(0\) — a value the book would call undefined. That is precisely why Theorem 7.2 carries \(\delta \gt 0\), and why any lemma about \(\beta '\) must either assume it or handle the degenerate case explicitly.
Seventeen vertices do not suffice, so the threshold is \(\ge 18\) — and with the upper bound, exactly \(18\), the largest value in the book’s table.
! As with \(r(3,5)\), only the lower bound is stated here, and the upper bound would need \(r(3,4) = 9\) — itself unstated and requiring the strict form of Theorem 7.4.
Keep only the edges that are "tight" for the labelling — those whose weight exactly uses up the sum of the labels at their ends. As the Kuhn–Munkres algorithm adjusts labels the equality subgraph changes, and the algorithm stops once some equality subgraph contains a perfect matching.
Representing weights as Sym2 V \(\to \) \(\mathbb {R}\) makes \(l x + l y = w s(x,y)\) symmetric in \(x, y\) definitionally, which is why the symm obligation is routine.
Corollary 4.6 gives a sufficient edge count taking no account of the minimum degree. Erdős’ refinement: when \(\delta \) is known and small relative to \(\nu \), a weaker count suffices — \(C(\nu -\delta , 2) + \delta ^{2}\) rather than \(C(\nu -1, 2) + 1\).
The shape of the bound reflects the extremal configuration: a clique on \(\nu - \delta \) vertices with \(\delta \) low-degree vertices attached, the densest way to be nonhamiltonian while holding the minimum degree at \(\delta \). \(\nu \ge 6\delta \) keeps \(\delta \) genuinely small.
Every visit to a vertex consumes one edge coming in and one going out, so the edges at each vertex must pair up.
The (\(\Leftarrow \)) direction is a minimal counterexample argument. In Lean that is strong induction on \(\varepsilon (G)\) — the book’s "choose such a graph with as few edges as possible" — generalised over the graph, since \(G'\) is a different graph on (the subtype of) the same vertex type.
By Corollary 1.1 the number of odd-degree vertices is always even, so "at most two" means exactly \(0\) or \(2\).
This is the precise answer to the Königsberg question and to exercise 4.1.1: a figure can be drawn "without lifting the pen and without retracing" exactly when it is connected and has at most two odd-degree vertices.
Even degrees everywhere means no "loose ends". Peel cycles off one at a time: removing a cycle subtracts \(2\) from the degree of each vertex it visits, so all degrees stay even and the argument repeats until no edges are left.
"\(E(G) = \bigcup E(C_{i})\) with the \(C_{i}\) edge-disjoint" is rendered as the single \(\exists !\) statement — every edge lies in exactly one of the cycles — which packages covering and disjointness together.
Note this needs no connectivity hypothesis: it is the local content of Euler’s theorem. Connectivity is what additionally lets the cycles be spliced into one tour (Theorem 4.1).
! In the book’s notation \([x]\) is the floor and \({x}\) the ceiling — the opposite of the modern convention for \({}\). So (6.5) reads \(\lfloor \varepsilon /p\rfloor \le |M_{i}| \le \lceil \varepsilon /p\rceil \), rendered here as G.edgeFinset.card / p \(\le \) …\(\le \) (G.edgeFinset.card + p - 1) / p in \(\mathbb {N}\) division.
! The book’s "repeatedly applying lemma 6.3 ... we eventually obtain" is an induction whose termination is not argued. In Lean it needs an explicit measure — e.g. \(\sum _{i} |M_{i}|^{2}\), which strictly decreases on each rebalancing since moving an edge from a larger to a smaller class reduces the sum of squares. Supplying that measure is a real part of the formalisation the book skips.
Split the vertices in two and keep only the crossing edges — automatically bipartite and spanning — choosing the split to maximise crossings. Then no vertex can have more than half its edges inside its own part, or moving it would improve the split.
Conclusion in the cleared form \(d_G(v) \le 2 d_H(v)\) to stay in \(\mathbb {N}\). ! Step 3’s \(i - c \le 0\) must be argued in \(\mathbb {Z}\) or by Nat.le_of_add_le_add, not by \(\mathbb {N}\)-subtraction.
Since \(G\) is not hamiltonian the longest cycle misses some vertex; connectivity joins that vertex to the cycle, and the joining path’s edges lie in a bridge that therefore reaches off \(C\). This is the setup for the whole exercise — that bridge is the object whose attachments part (ii) constrains, and Chvátal–Erdős falls out of those constraints.
Note this is the only one of the three 9.4.3 statements that carries hnh; part (ii) as stated below drops it, which is where its defect comes from.
High chromatic number is compatible not merely with triangle-freeness (theorem 8.7) but with the complete absence of short cycles. Locally such a graph looks like a tree — every small neighbourhood is acyclic and trivially 2-colourable — yet globally it resists any bounded number of colours. Chromatic number is a genuinely global invariant.
The conclusion is the honest \(\ge \) form (\(k \le \chi \), 6 \(\le \) girth) rather than the book’s "\(k\)-chromatic of girth six". Two reasons: part (a) delivers only a lower bound on \(\chi \), and girth = 6 exactly would additionally require exhibiting a 6-cycle, which the construction does not obviously do. Step 3’s instantiation at \(m\) rather than \(k\) is the small manoeuvre that lets the \(\ge \) induction feed part (a)’s \(=\) hypothesis.
This is what justifies calling \(\pi _k(G)\) the chromatic polynomial. The book notes that no one has yet discovered which polynomials are chromatic: Read (1968) conjectured the coefficients must first rise then fall in absolute value, but even that plus this corollary is not sufficient — \(k^{4} - 3k^{3} + 3k^{2}\) satisfies all of them yet is no graph’s chromatic polynomial (exercise 8.4.2(b)).
[Nonempty V] is load-bearing, as step 2 shows: for \(\nu = 0\) the empty graph has \(\pi _k = 1\), whose constant term is \(1\), not \(0\). The alternation is encoded as \(\forall \) i, 0 \(\le \) (-1)^(\(\nu \) - i) * p.coeff i rather than as an explicit sum with non-negative \(a_{i}\), which is equivalent and much easier to carry through step 5.
Left and right cosets each partition \(H\) into \(n = [H : K]\) blocks of size \(|K|\). The claim: one list of \(n\) elements represents both partitions simultaneously.
Hall again — put left cosets on one side, right cosets on the other, joining aK to Kb when they intersect. All cosets having size \(|K|\) makes this graph regular, so Corollary 5.2 gives a perfect matching; choosing an element from each matched intersection is the common transversal.
! The Lean rendering states the two conclusions as Function.Bijective of the maps \(i \mapsto h_{i} \textbullet {} K\) and \(i \mapsto op h_{i} \textbullet {} K\) into Set H. The note in the file flags this shape as provisional, and it is worth scrutiny: bijectivity onto what codomain is left implicit (it is Set H, not the set of cosets), so as written the maps are into a far larger type than intended and the statement may be stronger — or simply wrong — relative to the exercise. Recheck before proving.
Each edge added to a forest either joins two different components — possible at most \(\nu - 1\) times — or joins two already-connected vertices, immediately closing a cycle. ! Part (b), due to Pósa and not stated here, strengthens this: \(\varepsilon \ge \nu + 4\) forces two edge-disjoint cycles.
+ Hypothesis repaired. Step 2 needs \(\omega \ge 1\), i.e. Nonempty V. Without it the statement is false on an empty carrier, where \(\nu = \varepsilon = 0\) so \(h\) holds vacuously while no cycle exists (indeed no vertex \(v\) exists to base one at). [Nonempty V] has been added; it is not in B&M only because the book’s graphs are nonempty by convention.
If every vertex offers a second way out you can never get stuck, so walking forward must eventually revisit a vertex, and the first revisit closes a cycle. * Contrapositively, an acyclic graph always has a vertex of degree \(\le \) 1 — used repeatedly in chapter 2’s theory of trees, and by chapter 12’s lemma 12.2.1.
Indices are shifted by one to stay in \(\mathbb {N}\): the book’s \(\kappa '(G) = k\) with \(\kappa '(H) = k - 1\) is stated here as \(\kappa '(G) = k + 1\) with \(\kappa '(G - e) = k\), which avoids truncated subtraction entirely.
Take \(F\) realising \(\kappa '(G) = k + 1\); it is nonempty, so pick \(e \in F\). Then \(F \ {e}\) is an edge cut of \(G - e\) of size \(k\), giving \(\kappa '(G - e) \le k\); and \(\kappa '(G - e) \ge k\), because a smaller cut of \(G - e\) together with \(e\) would be a cut of \(G\) of size \(\lt k + 1\), contradicting minimality.
The dual of proper colouring. Proper asks that no colour appear twice at a vertex, using \(\Delta \) colours; this asks that every colour appear at least once at every vertex, using \(\delta \) colours. Since the least degree is \(\delta \), that is the most one could force everywhere.
The colouring is explicitly not required to be proper, so the statement is about IsRepresentedAt rather than about lineGraph.chromaticNumber — one of the few places the raw-function encoding is the right one.
Exercise 6.2.8 is the simple-graph analogue with \(\delta - 1\) colours; it is not stated in this file.
The far-pairs graph of this configuration is exactly the balanced complete tripartite \(T_{3,n}\), with \(\lfloor n^{2}/3\rfloor \) edges — so the Turán bound is attained and the geometric optimum is realised by the graph-theoretic extremal configuration.
A connected non-complete graph always contains an induced path on three vertices — adjacency is transitive only when the graph is a disjoint union of complete graphs. * Consumed by Brooks’ theorem 8.4, whose 3-connected case opens by invoking exactly this.
Greedily enlarge the first colour class to a maximal independent set, absorbing whatever later classes will give up; repeat on what remains. Nothing is lost: the result is canonical and uses no more colours than before.
Why this matters (§8.6). The storage problem asks for the fewest warehouse compartments so that incompatible chemicals are separated — which is the chromatic number of the incompatibility graph. No good algorithm is known, so the book gives an enumerative procedure: list the minimal coverings (equivalently, by theorem 7.1, the maximal independent sets), then search over canonical colourings. This exercise is what makes that search complete — restricting attention to canonical colourings loses nothing. The book’s example (figure 8.11) has minimal coverings \({a,c,e,g}\), \({b,c,d,e,g}\), \({b,d,e,f}\), \({b,c,d,f}\), hence maximal independent sets \({b,d,f}\), \({a,f}\), \({a,c,g}\), \({a,e,g}\), and \(\chi = 3\) via the canonical colouring \(({b,d,f}, {a,e,g}, {c})\).
L.length \(\le \) k, not \(= k\): a canonical colouring may use fewer colours than the one it was built from, and that is precisely the point — the least length over canonical colourings is \(\chi (G)\), which is what the §8.6 procedure computes. Step 1’s strengthening is essential: the statement as given is not directly inductive, because the recursive call is about a deleted graph.
The excluded case \(n = 5\) is exactly exercise 8.1.9(b): no \(k\)-critical graph has \(k + 1\) vertices, so no 4-critical graph has five. The book’s figure 8.2 (the Grötzsch graph) is another witness, for \(n = 11\).
The carrier is pinned to Fin n, so each construction must be transported along an explicit equivalence — Fin 1 \(\oplus \) Fin (n-1) \(\simeq \) Fin n for case 2, and the Hajós single-carrier encoding of exercise 8.1.11 for case 3. That transport, rather than the graph theory, is most of the Lean work here; a reusable "IsKCritical transfers along \(\simeq \)g" lemma is worth having first.
Start with a \(k\)-chromatic graph and keep deleting vertices and edges as long as the chromatic number stays at \(k\). The graph is finite, so this stops; what remains is still \(k\)-chromatic but every proper subgraph of it needs fewer colours — that is, it is \(k\)-critical. This is the reduction that makes critical graphs worth studying at all: any statement proved for \(k\)-critical graphs transfers to all \(k\)-chromatic ones. Corollary 8.1.1, Brooks’ theorem 8.4 and theorem 8.5 all open by invoking it.
Only [Finite V] is needed, not [Fintype V]: the argument uses finiteness solely to well-found the minimisation in step 2.
No matter how a graph is drawn, if it is large enough it cannot avoid both a big clique and a big independent set.
The book can be informal about existence because \(r(k,l)\) is only ever used comparatively. In Lean, ramseyNumber is sInf over a set that this lemma proves nonempty — so until this is proved, every ramseyNumber in the file is provably \(0\) and every result below is vacuous. It gates all of §7.2 and, via Schur, §7.4.
, used by vertexConnectivity_le_deleteEdge_succ.
Only part (a) is needed. Since \(G\) is connected, \(\omega (G) = 1\), so the conclusion \(\omega (G - v) \gt \omega (G)\) is "\(G - v\) is disconnected" — i.e. \(\exists \) w, G.IsVertexCut {w}.
The book leaves this as an exercise, so there is no book proof to quote; the argument below is the standard one.
Sharpens exercise 1.7.2 from "some cycle exists" to a length bound: a graph in which every vertex has many neighbours cannot consist only of short cycles. * This is chapter 10’s exercise 10.1.7 one dimension down — the directed version bounds directed cycles by max{\(\delta ^{-}\),\(\delta ^{+}\)} + 1 and is used inside Ghouila-Houri’s theorem 10.4.
By the defect formula, a maximum matching smaller than \(k\) forces some \(S \subseteq X\) with large \(|S| - |N(S)|\). Every edge meeting \(S\) then ends inside the small set \(N(S)\), and simplicity caps the total edge count at \((k-1)n\) — contradiction.
Equivalently, via König: a covering of size \(\lt k\) caps \(\varepsilon \) at \((k-1)n\), since each covering vertex has degree at most \(n\).
Assign each edge a weight and each spanning tree the total; the connector problem asks for the least, and theorem 2.10 guarantees Kruskal’s greedy procedure — repeatedly take the cheapest edge not closing a cycle — always finds one.
! The algorithm is a procedure, not a proposition, so what is stated is the mathematical target it attains: existence of a minimum-weight spanning tree. That is strictly weaker than theorem 2.10, which asserts the *greedy output* is optimal — the exchange argument quoted above is not exercised by the skeleton, which is a three-line finiteness argument instead. Formalising the real theorem would need Kruskal’s algorithm defined first. Weights are \(\mathbb {R}\)-valued, matching B&M’s remark that the algorithm is valid for arbitrary real weights.
Not only is a bridge connected, but the connection can be made without re-entering \(H\). This is the form actually used downstream: theorem 9.7 needs \((v_{1},v_{2})\)-paths inside a bridge avoiding the cycle internally, and the dropped theorem 9.8 needs the same to reach its Jordan-curve contradiction.
The path is asked for as a G.Walk, not a walk in the bridge. That is equivalent and more convenient: a walk in \(G\) between two bridge vertices that is internally disjoint from \(H\) automatically has all its edges in the bridge’s class. Note the trans case in step 1 is the reason this is genuinely harder than bridgeOf_connected and not a corollary of it.
Swapping roles along \(P\) moves exactly one edge from the larger matching to the smaller, leaving the union unchanged. Repeated application balances a family of matchings — in §6.3’s timetabling reading, spreading lessons evenly across periods so fewer classrooms are needed at once.
\(|M'| = |M| - 1\) is stated additively as M’.ncard + 1 = M.ncard to avoid \(\mathbb {N}\) subtraction.
Matchings are carried as Set (Sym2 V) together with an existential witness \(\exists \) S : G.Subgraph, S.IsMatching \(\land \) S.edgeSet = M, rather than as subgraphs directly — which makes the set operations \(\setminus \), \(\cup \) in the book’s formulas literal, at the cost of re-deriving the subgraph witness for \(M'\) and \(N'\).
Pad until every vertex has degree exactly \(\Delta \). Enlarge the smaller side with isolated vertices so the sides match; then repeatedly join a deficient vertex on each side — both sides have equal total deficiency, so such a pair always exists.
! Carrier changes, so the statement produces a new type \(W\) together with an embedding \(G \hookrightarrow g H\).
! The \(\hookrightarrow g\) here is a RelEmbedding, i.e. an induced embedding — the same trap that sank the original statement of exercise 1.4.1 in GraphsAndSubgraphs.lean (recorded in GraphTheory/ExtractionArchive/MathlibDuplicates.md, entry 5). It demands H.Adj (f a) (f b) \(\leftrightarrow \) G.Adj a b, so the padding edges must never join two images of \(G\)-vertices. The two-disjoint-copies construction respects this; the naive "add edges between deficient vertices of \(G\) itself" does not, and would make the statement false. Worth checking carefully before proving.
Part (b) is the alternative proof of Theorem 6.1: a \(\Delta \)-regular bipartite graph is 1-factorable (exercise 5.2.3(a)), hence properly \(\Delta \)-edge colourable, and restricting to \(G\) gives \(\chi '(G) \le \Delta \).
+ This route avoids Lemma 6.1.1 and the Euler theorem entirely, so it is the recommended path to Theorem 6.1 in Lean — see the note there.
Keep deleting redundant edges — those lying on cycles — until none remain; what is left still connects everything but has no cycle. * This is the workhorse of the rest of the chapter: corollary 2.4.2, theorem 2.6 and corollary 2.7 all open by invoking it.
\(\delta \ge \nu /2 + 1\) is one better than Dirac’s threshold, so Theorem 4.3 gives a Hamilton cycle \(C\). With \(\nu \) even, \(C\) is an even cycle whose edges split alternately into two perfect matchings. Removing \(C\)’s edges drops every degree by \(2\), leaving enough for a second Hamilton cycle; combining the 2-factor \(C\) with a 1-factor from the second gives degree \(3\) everywhere.
\(\delta \ge \nu /2 + 1\) is formalised as \(\nu + 2 \le 2\delta \) to stay in the natural numbers.
One might expect a graph needing many colours to contain a large clique — after all, a clique’s vertices must all differ. This theorem says the converse fails badly: chromatic number can be arbitrarily high with no triangle at all. Starting from \(K_{2}\), the construction gives a triangle-free \(k\)-chromatic graph on \(3\cdot 2^{k-2} - 1\) vertices — the 5-cycle for \(k = 3\), the Grötzsch graph for \(k = 4\). The book adds that Erdős (1961) proved by the probabilistic method that for any \(k, l \ge 2\) there is a graph of girth \(k\) and chromatic number \(l\), and that Descartes’ construction (exercise 8.5.2) already achieves girth \(6\).
Self-contained: everything needed is the local mycielskian def, and step 5’s recolouring is the only delicate part. The carrier is existentially quantified, so each induction step may change it — which is exactly what mycielskian does (W \(\mapsto \) W \(\oplus \) W \(\oplus \) Unit). Note the "without loss of generality" in the book’s step 5 is a genuine permutation of the palette and must be performed explicitly.
An Euler tour threads through every vertex; alternating colours along it means any vertex with room for two edges sees both. Odd cycles are the sole exception, since alternation around an odd cycle must repeat somewhere.
! "is not an odd cycle" is a statement about \(G\) itself, not about containing one. Hence the clause p.edges.toFinset = G.edgeFinset in hnotodd is load-bearing: it says the cycle exhausts \(G\). Dropping it would make the hypothesis far too strong (excluding every graph with an odd cycle anywhere) and the lemma useless for Lemma 6.1.2, which applies it to two-coloured components.
, strengthened to carry the edge-disjointness that Corollary 3.2.1 needs.
InternallyDisjoint p q as defined in this file does not forbid \(p = q\): for adjacent \(u, v\) the single edge satisfies it with \(p = q\), since its only vertices are the two endpoints. So Theorem 3.2 as stated cannot yield a cycle, and the book’s one-line derivation of Corollary 3.2.1 does not go through. Adding p.edges.Disjoint q.edges to the conclusion repairs this; the book gets it for free because its \(d(u,v) = 1\) case produces a genuine cycle via theorem 2.3, not merely two paths.
Join two points when they are "far apart", threshold \(1/\sqrt2\). The geometry then forbids \(K_{4}\), which is what lets Turán bound the number of far pairs.
+ Fully defined, symm/loopless discharged.
! Same \(i \ne j\) guard as unitDistanceGraph, and for the same reason: \(x\) is not assumed injective.
! The book warns (§7.5, p. 121) that its "diameter" is geometric, not graph-theoretic:
Rendered as Metric.diam (Set.range x), so no clash with SimpleGraph.diam.
This is the case \(k = 4\) of Hajós’ conjecture, settled by Dirac (1952). The book notes the conjecture in general is *known to be a very difficult problem*, and mentions Hadwiger’s related conjecture, whose case \(k = 5\) Wagner showed equivalent to the four-colour conjecture of chapter 9.
Step 1’s monotonicity lemma is what licenses the book’s "without loss of generality" and should be built first — without it the reduction to the critical subgraph is not available. The induction in step 2 is on the carrier’s cardinality, but cases A and B produce graphs on different carriers (subgraph coercions), so the induction is cleanest stated over all graphs on all carriers of bounded size rather than over subgraphs of a fixed \(G\).
Thirteen vertices do not suffice, so the threshold is \(\ge 14\).
! The book’s upper bound chain routes through \(r(3,4) = 9\), which itself needs the strict form of Theorem 7.4 (\(r(3,3)\) and \(r(2,4)\) both even). Neither \(r(3,4) = 9\) nor its ingredients are stated in this file, so the exact value \(r(3,5) = 14\) is not reachable from what is here even once everything is proved.
The hypothesis provides some colouring, possibly using far more than \(k\) colours, in which no colour class is a singleton. The claim is that this feature survives optimisation down to \(k\) colours. The difficulty is that the two requirements pull against each other: merging classes reduces the colour count but tends to empty classes out, and the whole point is that it can be arranged never to leave one vertex stranded.
The hypothesis is existential in the number of colours \(n\), so the given colouring is C : G.Coloring (Fin n) for an unknown \(n\) — step 1’s strengthening is what makes that usable. Set.ncard is used rather than a Finset card so the statement needs no decidability on colour classes.
\(K_{1,n}\) is the star with \(n\) leaves, so a blue copy is a vertex with \(n\) blue edges. On \(m + n - 1\) points, if no vertex has \(n\) blue edges then every vertex has \(\ge (m+n-2) - (n-1) = m - 1\) red edges, and tree_isContained_of_minDegree_le embeds \(T\) in red.
Lower bound: a colouring of \(K_{m+n-2}\) with no red \(T\) and no blue star. The divisibility \((m-1) \mid (n-1)\) is exactly what lets the red graph be \((m-2)\)-regular — too sparse for \(T\), while leaving every vertex under \(n\) blue edges.
! The two targets live on different carriers (\(W\) and Fin 1 \(\oplus \) Fin n), so \(![T, K_{1,n}]\) cannot elaborate — Matrix.vecCons is homogeneous. Hence the dependent spelling Fin.cons T (Fin.cons _ finZeroElim) with an explicit type family W := ![W, Fin 1 \(\oplus \) Fin n], and W : Type rather than Type*.
Instead of a monochromatic complete subgraph, a monochromatic copy of a prescribed graph. All \(G_{i}\) complete recovers ramseyNumberMulti.
"Subgraph isomorphic to \(G_{i}\)" is Mathlib’s containment \(\sqsubseteq \), and the colour-\(i\) graph is fromEdgeSet {e | \(\chi \) e = i \(\land \) \(\lnot \) e.IsDiag} — the \(\lnot \) IsDiag guard being what stops the diagonal from creating spurious loops.
! Same sInf \(\emptyset \) = 0 trap again, with no existence lemma for this notion either. So all four generalised-Ramsey results below are vacuous as stated.
! The graphs are indexed by W : Fin m \(\to \) Type*, so each \(G_{i}\) may live on a different carrier — flexible, but it means ![pathGraph 4, pathGraph 4] below must elaborate its motive carefully.
Graphs attaining this bound with diameter two are the Moore graphs of exercise 1.7.5; Hoffman and Singleton showed they exist only for \(k = 2, 3, 7\) and possibly \(57\). The case \(k = 3\) is the Petersen graph — the same graph chapter 9 uses as its counterexample to Tait’s approach.
! \(k - 1\) is \(\mathbb {N}\)-subtraction; \(k = 0\) makes the statement \(1 \le \nu \) and girth = 5 unsatisfiable, so the degenerate case is vacuous — but check it rather than assume it.
\(C_{3} \lor C_{5}\) on Fin 3 \(\oplus \) Fin 5: two disjoint cycles with every vertex of one joined to every vertex of the other, on \(8\) vertices.
A small graph with no \(K_{6}\) in which every 2-edge colouring still forces a monochromatic triangle — so "contains \(K_{6}\)" is not necessary for the Ramsey property.
+ An abbrev built from join and cycleGraph, fully defined.
Vertices are the squares of an \(m \times n\) board, adjacent when they share a side. A perfect matching is exactly a tiling by \(1 \times 2\) dominoes, since each domino covers precisely one side-adjacent pair.
Adjacency is spelled out coordinatewise: same row and columns differing by one, or same column and rows differing by one. Written on \(\mathbb {N}\) values (p.2.val + 1 = q.2.val) rather than on Fin arithmetic, which would wrap around and wrongly join the last column to the first.
Glue two \(k\)-critical graphs at a single vertex \(v\), delete one edge at \(v\) from each, and join the two orphaned endpoints \(v_{1}\), \(v_{2}\) by a new edge; the result is again \(k\)-critical. Step 1 is the heart: the new edge forces \(v_{1}\) and \(v_{2}\) apart, so \(v\) must agree with one of them, and that agreement is exactly what repairs the deleted edge on that side. The Hajós construction matters because, iterated from \(K_k\), it generates every graph with chromatic number at least \(k\) — a complete but impractical characterisation.
The outline’s binder \(\{ k\ v\ v_{1}\ v_{2} : \_ \} \) cannot elaborate (heterogeneous types under one hole), so the statement uses explicit \({k : \mathbb {N}} {v v_{1} v_{2} : V}\). Both graphs live on one carrier \(V\); "exactly one vertex in common" is hmeet : G\(_{1}\).support \(\cap \) G\(_{2}\).support = {v}, and each \(G_{i}\)’s real content is G\(_{i}\).induce G\(_{i}\).support, which is why the hypotheses are stated about the induced graphs rather than about \(G_{1}\), \(G_{2}\) directly. Edge deletion is \{} edge and edge addition is \(\sqcup \) edge.
Hall’s condition: no set of vertices on the \(X\) side may collectively have too few neighbours. Colloquially — no group of \(k\) workers may be jointly qualified for fewer than \(k\) jobs.
\(N(S)\) is written \(\bigcup \) v \(\in \) S, G.neighborSet v, and the inequality is stated as S.ncard \(\le \) (\(\bigcup \) …).ncard — the book’s \(|N(S)| \ge |S|\) with sides swapped.
Hamilton-connectedness demands a spanning path between every pair, forcing many edges. Every vertex must have degree at least \(3\): a degree-\(2\) vertex has both its edges forced into any spanning path through it as an interior vertex, leaving no way to make it an endpoint of a spanning path to a third vertex. Summing \(d(v) \ge 3\) and applying handshaking gives \(2\varepsilon \ge 3\nu \), and a parity refinement pushes this to \(2\varepsilon \ge 3\nu + 1\).
Formalised as \(3\nu + 1 \le 2\varepsilon \) to stay in the natural numbers and avoid the ceiling.
! The Lean signature omits the book’s \(\nu \ge 4\). It is needed: for \(\nu = 3\), \(\top \) on three vertices is Hamilton-connected with \(\varepsilon = 3\), but \(3\nu + 1 = 10 \gt 6 = 2\varepsilon \). So the statement as written is false at \(\nu = 3\) and 4 \(\le \) Fintype.card V must be added.
Stated in the file’s "honest restatement" form: instead of positing a closure operator, it says that if \(H\) is reachable from \(G\) by any finite chain of ClosureSteps, then \(G\) is hamiltonian exactly when \(H\) is. Taking \(H\) to admit no further step recovers the book’s statement.
This restatement is what lets the file skip Lemma 4.4.2 entirely — see below.
The book must prove \(c(G)\) well defined before Theorem 4.4 can even be stated; its proof (§4.2, p. 64) is the argument:
Because this file quantifies over ReflTransGen ClosureStep chains rather than naming a closure, Lemma 4.4.2 is not needed and is not formalised: the statement above holds for every chain, confluent or not. It would only be required if a closure : SimpleGraph V \(\to \) SimpleGraph V function were introduced.
This file previously formalised only part (b) (hamiltonian_path_of_self_complementary), even though the book deduces (b) from (a) — so (a) was a hidden prerequisite with no declaration. The triage (log/graphtheory-EXERCISE_TRIAGE.md §A.3) recorded this as a fidelity gap and recommended stating (a). Nothing here is invented: the statement is the book’s own, quoted above.
The two sorted degree sequences are rendered the way chvatal_hamiltonian_path renders its sequence — via a sorting equiv \(\sigma \) on Fin \(\nu \) making the degrees Antitone/Monotone — rather than as raw lists, so the two conditions in this file are stated in the same idiom and can share lemmas.
\(m \le \nu /2\) is written \(2 * m \le \nu \) to avoid \(\mathbb {N}\)-division.
Only part (b) is formalised — part (a) has no separate declaration in this file.
Part (b) from part (a): if \(G \cong G^{c}\) the two sorted degree sequences are identical, so \(d_m \ge d_m'\) holds trivially at every index.
Recall from exercise 1.2.11(b) that self-complementary graphs exist only when \(\nu \equiv 0\) or 1 (mod 4).
The path analogue of Theorem 4.2. Deleting \(k\) vertices from a path breaks it into at most \(k + 1\) pieces — one more than for a cycle, because a path has two loose ends rather than being closed up. The Hamilton path \(P\) is a spanning subgraph of \(G\), so \(\omega (G - S) \le \omega (P - S) \le |S| + 1\).
The extra \(+1\) is the price of not closing the cycle, making the condition weaker — as it must be, since a Hamilton path is weaker than a Hamilton cycle.
A hamiltonian graph is held together by a single cycle through every vertex, and a cycle is hard to shatter: removing \(k\) vertices from it leaves at most \(k\) arcs.
\(G - S\) is rendered as ((\(\top \) : G.Subgraph).deleteVerts ↑S).coe, so the component count is Nat.card of that graph’s ConnectedComponent. Using the Subgraph API rather than G.induce (↑S)\(^{c}\) is what lets the "spanning subgraph" step be stated at all, since \(C - S\) and \(G - S\) then live over the same vertex set.
Arrange \(n\) stations in a circle and link each to its \(r\) nearest neighbours on each side, adding long-range links across the circle when \(m\) is odd. The carrier is ZMod n, which makes the book’s "addition taken modulo \(n\)" literal.
The three cases are a single \(if\)-cascade on \(m \% 2\) and \(n \% 2\); Case 1 is the base and Cases 2–3 are \(\sqcup \) with an extra chord relation.
The book’s \({x}\) is the ceiling \(\lceil x\rceil \), so \({mn/2}\) is written as the natural-number division \((m * n + 1) / 2\).
Only \(\varepsilon (H_{m,n}) = \lceil mn/2\rceil \) is formalised. The optimality conclusions \(f(m,n) = \lceil mn/2\rceil \) and \(g(m,n) = \lceil mn/2\rceil \) are not stated in this file, since \(f\) and \(g\) (least edge counts over all \(m\)-connected graphs) are not defined here.
(Harary, 1962).
The book proves only the even case; the odd case is exercise 3.3.1, so a full Lean proof of the statement as given must supply it.
Note the two "clearly"/"without loss of generality" steps carry real weight in Lean: the WLOG needs \(|V' \cap S| + |V' \cap T| \le |V'| + 2 \lt 2r + 2\), and the "sequence of distinct vertices ... difference at most \(r\)" is a greedy construction requiring an explicit induction on the arc.
A "topological \(K_{4}\)": four branch vertices, each of the six pairs joined by a path, the six paths sharing no interior vertices with one another or with the branch vertices. Drawn on paper it is \(K_{4}\) with beads threaded onto its edges.
The book says "obtainable from \(K_{4}\) by subdividing edges", which is a statement about an abstract graph; what a containment claim needs is the witness form above — six Walks in \(G\) with disjointness conditions. The two are equivalent, and only this direction is ever used. The three side conditions say, in order: the branch vertices are distinct; each of the six walks is a path; no path’s interior meets a branch vertex; and no two paths’ interiors meet. support.tail.dropLast is the interior of a walk (drop both endpoints).
Enough edges relative to vertices force the graph to be locally rich enough to contain four branch vertices and six connecting paths. The invariant in step 2 is the whole trick: deleting a low-degree vertex is "free" with respect to the quantity \(2\nu - \varepsilon \), so the stripping can be run to completion without ever losing the hypothesis. Part (b) shows \(2\nu - 2\) is exactly the right threshold.
Restated additively as \(2\nu \le \varepsilon + 2\) rather than \(\varepsilon \ge 2\nu - 2\), to keep \(\mathbb {N}\)-subtraction out. Step 2’s bookkeeping is the \(\mathbb {N}\)-arithmetic core and is worth isolating: (G.induce {v}\(^{c}\)).edgeFinset.card + G.degree v = G.edgeFinset.card.
Essentially-all vertices having degree at least three is enough to force a topological \(K_{4}\), with no colouring hypothesis at all. So this is a purely degree-theoretic sufficient condition where theorem 8.5 gives a chromatic one. Neither is necessary: a subdivision of \(K_{4}\) can occur in graphs that are only 3-chromatic — the book’s own example, a 4-cycle being a subdivision of \(K_{3}\), makes the analogous point one dimension down.
"At most one vertex of degree less than three" is a Finset cardinality bound on univ.filter (fun v => G.degree v < 3). This is the statement exercise 8.3.2(a) reduces to, so filling that one first is not an option — the dependency runs this way.
Each vertex is a binary string of length \(k\), equivalently a corner of a \(k\)-dimensional cube; two corners are joined when their descriptions agree everywhere but one position. For \(k = 3\) this is literally the corners and edges of an ordinary cube — the book’s figure 1.4b.
Mathlib has no named hypercube graph, so this is built here. Tuples are Fin k \(\to \) Bool; "differ in exactly one coordinate" is \(\exists ! i, x i \ne y i\). SimpleGraph.fromRel symmetrises the relation and removes the diagonal, which is what makes the result a SimpleGraph without a separate looplessness proof — at the cost that Adj unfolds to \(x \ne y \land (R x y \lor R y x)\), as the hypercube_bipartite proof has to unpack.
Let \(S\) be independent in \(G[H]\). Its first-coordinate projection is independent in \(G\) (two \(S\)-vertices in different copies force those \(G\)-vertices non-adjacent), so at most \(\alpha (G)\) copies are touched; within each, at most \(\alpha (H)\) vertices. Multiply.
Specialised to a family of two \(u\)–\(v\) walks. "\(x\) is an internal vertex of \(p\)" is x \(\in \) p.support \(\land \) x \(\ne \) u \(\land \) x \(\ne \) v, so "no \(x\) is internal to both" becomes
\(\forall \) x, x \(\in \) p.support \(\to \) x \(\in \) q.support \(\to \) x = u \(\lor \) x = v.
! Note this does not forbid \(p = q\). For adjacent \(u, v\) the single edge satisfies it with \(p = q\), its only vertices being the two endpoints. Theorem 3.2 as stated therefore cannot yield a cycle, which is why Corollary 3.2.1 is derived from the edge-disjointness-carrying strengthening exists_two_internally_disjoint_paths_of_two_connected rather than from two_connected_iff_two_internally_disjoint_paths directly.
Every edge matters for \(\alpha \): removing any one lets a larger independent set appear, so an \(\alpha \)-critical graph has no \(\alpha \)-redundant edges.
\(G - e\) is G.deleteEdges {e}, on the same vertex type — so \(\nu \) is unchanged, which is what makes the equivalence with \(\beta \)-criticality (below) exact.
Every edge is essential to the covering number.
+ By Corollary 7.1 (\(\alpha + \beta = \nu \)) and the fact that edge deletion leaves \(\nu \) unchanged, this is literally equivalent to IsAlphaCritical — which is why the two exercises are parallel, and why 7.1.3(a) reduces to 7.1.2 in one line once Cor 7.1 is available.
(\(\Rightarrow \)) Theorem 7.3 applied subgraph-wise, every subgraph of a bipartite graph being bipartite.
(\(\Leftarrow \)) Contrapositive: an odd cycle \(H\) on \(2k+1\) vertices has \(\delta (H) = 2 \gt 0\), \(\alpha (H) = k\) and \(\beta '(H) = k + 1\), so the equality fails there.
So the identity \(\alpha = \beta '\) — which Theorem 7.3 gives for bipartite graphs — actually characterises them.
! The instance binders [Fintype H.verts] \(\to \) [DecidableRel H.coe.Adj] \(\to \) sit inside the \(\forall H\), as hypotheses rather than instance arguments. That is unusual and means a user must supply them explicitly at each application; it also means the (\(\Leftarrow \)) direction gets to assume them for its witness, which is harmless here but worth noticing.
(\(\Rightarrow \)) Every subgraph of a bipartite graph is bipartite, and the larger side of a bipartition is an independent set with at least half the vertices.
(\(\Leftarrow \)) If \(G\) were not bipartite it would contain an odd cycle (Thm 1.2). That cycle on \(2k+1\) vertices has \(\alpha = k\), and \(2k \lt 2k+1\), so the condition fails at that subgraph.
Stated as \(\nu (H) \le 2\cdot \alpha (H)\) to avoid division.
"Subgraph \(H\) of \(G\)" is H : G.Subgraph, which carries its own verts — so \(\nu (H)\) genuinely shrinks and the odd-cycle witness is expressible. H.coe is the subgraph viewed as a SimpleGraph ↥H.verts, and H.verts.ncard is used in place of Fintype.card ↥H.verts to avoid an instance that [Fintype V] alone does not supply.
Only the first sentence is formalised: G.Connected \(\land \) \(\forall \) v, \(\lnot \) G.IsCutVertex v, i.e. "\(G\) is a block". The relative notion "a block of \(G\)" (a maximal such subgraph) and the decomposition "every graph is the union of its blocks" are not defined in this file — nothing in chapter 3 as formalised here needs them.
The second sentence is a theorem, proved below as block_three_vertices_two_connected.
An edge cut with nothing to spare — remove all of it and the graph falls apart, but put any single edge back and it is connected again. Exercise 2.2.8 characterises when \([S, \bar{S}]\) is a bond: exactly when both \(G[S]\) and \(G[\bar{S}]\) are connected. Bonds are the notion dual to cycles, a duality chapter 12 develops in full — theorem 2.6 here is the mirror of theorem 2.5.
! Defect: \(\emptyset \) is a bond when \(G\) is disconnected. The docstring above claims nonemptiness is automatic because "deleting \(\emptyset \) leaves \(G\) connected" — but that holds only for connected \(G\). For disconnected \(G\), IsEdgeCutSet \(\emptyset \) unfolds to \(\lnot \) G.Connected, which is true, and there is no \(B' \subset \emptyset \) to test, so the minimality clause is vacuous. Hence IsBond G \(\emptyset \), contradicting minimal nonempty edge cut.
The repair: add B.Nonempty as a conjunct, or carry G.Connected as a hypothesis wherever IsBond is used (theorem 2.6 already does — its hG is available).
Build the colour classes greedily, each time taking as large an independent set as possible from what remains. Exercise 8.6.3 shows this costs nothing, so enumerating canonical colourings suffices to find \(\chi (G)\) — the basis of the §8.6 procedure for the storage problem, which the book concedes *is not very efficient for large graphs*.
Stated as a static condition on a list of classes, not as a procedure: \(L[i]\) is required to be maximal-independent in the complement of \(L[0] \cup \dots \cup L[i-1]\), which is what "maximal independent set of \(G - (V_{1} \cup \dots \cup V_{i-1})\)" means. The last two conjuncts say \(L\) really is a partition — the classes cover \(V\) and are pairwise disjoint. A List rather than a Fin k \(\to \) Set V because the book’s condition is inherently ordered, and because exercise 8.6.3 concludes with L.length \(\le \) k rather than \(= k\) (a canonical colouring may use fewer colours, which is precisely why the procedure finds \(\chi \) rather than merely confirming \(k\)).
Generalises 7.3.4 from \(K_{2,m}\) to \(K_{m,m}\). Count stars — a vertex with \(m\) of its neighbours — two ways: each \(v\) contributes \(C(d(v), m)\), and each \(m\)-set can be the leaf-set of \(\le m-1\) stars unless a \(K_{m,m}\) appears. Convexity converts the degree sum into an edge count.
The exponent \(2 - 1/m\) is the point: forbidding a complete bipartite subgraph caps \(\varepsilon \) at strictly sub-quadratic order, unlike Turán’s constant fraction of \(\nu ^{2}\). Whether the exponent is tight for every \(m\) is the Zarankiewicz problem, still open.
! The rpow exponent varies with \(m\), so this is irreducibly real-valued; and \((m - 1 : \mathbb {R})\) with \(hm : 1 \le m\) means the base can be \(0\) at \(m = 1\), where \(0 ^(1/1) = 0\) — check that boundary case does not make the hypothesis vacuous.
Convert part (a)’s degree condition into an edge count. By convexity, \(\sum _v C(d(v),2)\) is minimised at fixed \(\varepsilon \) when all degrees equal \(2\varepsilon /\nu \), so \(\sum _v C(d(v),2) \ge \nu \cdot C(2\varepsilon /\nu , 2)\); demanding this exceed \((m-1)C(\nu ,2)\) and solving for \(\varepsilon \) gives the threshold.
A genuinely sub-quadratic threshold (\(\nu ^{3/2}\)), unlike Turán’s for cliques.
! Real-valued with rpow exponents, so the proof leaves \(\mathbb {N}\) early. Mathlib’s inner_mul_le_norm_mul_norm or Finset.inner_mul_le_norm_mul_norm / sq_sum_le_card_mul_sum_sq supply the convexity step; Finset.inner_card_le_... is the usual shape for "sum of \(C(d_{v},2)\) versus the average".
Double-count cherries (paths of length two). Each \(v\) centres \(C(d(v),2)\) of them, so the total is \(\sum _v C(d(v),2)\); each is determined by its two endpoints, an unordered pair from \(C(\nu ,2)\). If no pair had \(m\) common neighbours, each pair would host \(\le m-1\) cherries, capping the total at \((m-1)C(\nu ,2)\).
The prototype for Kővári–Sós–Turán (exercise 7.3.5).
A set of vertices touching every edge. Theorem 7.1 says coverings and independent sets are exactly complementary.
! Duplicated from Matchings.lean, textually identical. Neither file imports the other; see log/graphtheory-ISSUES.md §F.
A critical graph is "minimally" \(k\)-chromatic: remove any vertex or any edge and the chromatic number drops. Critical graphs are useful precisely because they carry the whole difficulty of a colouring problem — every \(k\)-chromatic graph contains a \(k\)-critical subgraph, so statements about \(k\)-chromatic graphs reduce to the critical case, which is how corollary 8.1.1, Brooks’ theorem 8.4 and theorem 8.5 all begin.
The quantifier ranges over G.Subgraph, not over the order on SimpleGraph V. This is load-bearing (Scaffolding judgement 1): the SimpleGraph V order can only remove edges, never vertices, whereas the book’s "proper subgraph" includes \(G - v\). Under the weaker order \(\bot \) on two vertices would be vacuously 1-critical — it has no proper edge-subgraph — contradicting exercise 8.1.7, which says the only 1-critical graph is \(K_{1}\).
If a graph were disconnected, its chromatic number would be the maximum of those of its components — colour each component independently. So one component already achieves \(\chi (G)\), and that component is a proper subgraph with the same chromatic number, contradicting criticality. Corollary 8.2 strengthens this considerably: every critical graph is not merely connected but a block, having no cut vertex at all.
Step 3 is the whole content and is reusable: the same "components colour independently" lemma is exercise 8.4.6 in its counting form (\(\pi _k\) multiplies over components). Worth proving once in a shared form.
Criticality forces the graph to hold together tightly: it can have no single point of failure. Theorem 8.3 goes one step further and analyses the 2-vertex cuts that remain possible — and finds they too are heavily constrained.
There is no IsBlock in Mathlib or this repo, so "is a block" is unfolded into the book’s own definition, connected + no cut vertex. A cut vertex is spelled as a one-element vertex cut, matching IsVertexCut above. The Connected conjunct is not merely decoration: without it the statement would be satisfied by the empty graph.
In a critical graph no vertex is redundant, and a vertex whose neighbourhood is contained in another’s is exactly redundant: it can simply inherit that vertex’s colour. Note the argument needs \(u\) and \(v\) nonadjacent to work, and gets it for free — if \(u ~ v\) then \(v \in N(u) \subseteq N(v)\), contradicting looplessness.
Stated with \(\lnot (\dots \subseteq \dots )\), matching the book’s \(\not\subset \). [Nonempty V] is needed to know \(\chi (G) \ge 1\) in step 1.
This is what makes the type 1 / type 2 dichotomy meaningful. Since \(u\) and \(v\) are not joined by an edge, a \((k-1)\)-colouring of a \({u,v}\)-component is free to give them the same colour or different colours; which it is forced to do is exactly the component’s type. Were \(uv\) an edge, every component would be trivially of type 2 and theorem 8.3 would say nothing.
Stated for IsCritical rather than IsKCritical: the book says "\(k\)-critical", but \(k\) plays no role in the argument, so the hypothesis is weakened to plain criticality. huv : u \(\ne \) v is needed to know \({u, v}\) really has two elements.
A clique cut is too rigid to cause trouble: its vertices are forced to take distinct colours anyway, and distinct colours can always be permuted into agreement, so the pieces reconcile and the graph never needed the extra colour. Step 4 is the entire content — for a general cut the restrictions to \(S\) need not be related by a permutation, and exercise 8.1.8 identifies the exact weakening (uniquely \((k-1)\)-colourable) under which the argument still runs.
hconn : G.Connected is load-bearing and is not redundant given hcrit: although IsCritical.connected proves connectivity from criticality, it needs [Nonempty V], which this statement does not assume. Passing hconn explicitly keeps the two results independent and avoids a dependency cycle. Note also that the book’s \(S\)-components are defined only for a connected \(G\), so step 2 genuinely needs it.
A SimpleGraph is loopless by construction, so the second (component-counting) characterisation is the usable one and is what is taken as the definition here. Specialising it to a connected \(G\) — where \(\omega (G) = 1\) — turns \(\omega (G - v) \gt \omega (G)\) into "\(G - v\) is disconnected", giving G.Connected \(\land \) \(\lnot \) (G.induce {v}\(^{c}\)).Connected.
Folding G.Connected into the definition is what makes IsBlock below read as the book’s "connected graph that has no cut vertices".
A set of edges touching every vertex. The L \(\subseteq \) G.edgeSet conjunct is the book’s "subset of \(E\)", which matters here — without it \(L\) could contain non-edges and cover trivially.
The existence caveat is what forces the \(\delta \gt 0\) hypothesis on Theorem 7.2; see edgeCoveringNumber below.
Rather than carry the book’s \([S, \bar{S}]\) presentation, the definition is taken in its operative form — a set of edges whose removal disconnects \(G\): ↑F \(\subseteq \) G.edgeSet \(\land \) \(\lnot \) (G.deleteEdges ↑F).Connected.
The two agree on what is minimised: every \([S, \bar{S}]\) disconnects \(G\), and every disconnecting edge set contains one (take \(S\) a component of \(G - F\)). Since edgeConnectivity only ever asks for the minimum size, the coarser form is equivalent for all purposes in this chapter.
Split the vertices into two nonempty groups and collect the edges running between them; deleting them severs every route from one group to the other.
B&M define an edge cut by its shape \([S, \bar{S}]\); this takes the operational characterisation — a subset of edgeSet whose removal leaves \(G\) disconnected — which for connected \(G\) describes the same collections. ! For disconnected \(G\) they diverge, and \(\emptyset \) satisfies this predicate; that is the source of the IsBond defect below.
\(\exists \) u, \(\exists \) p : G.Walk u u, p.IsEulerian — a closed walk using every edge exactly once. Mathlib’s Walk.IsEulerian is defined via List.count on p.edges, which is why [DecidableEq V] is genuinely required here and not merely convenient.
Note the book’s three-way vocabulary collapses in Lean: IsEulerian already implies IsTrail, so "closed Euler trail" and "Euler tour" are the same predicate on a Walk u u.
Assign a label to every vertex so the two labels at an edge’s ends sum to at least its weight. Weights are carried as w : Sym2 V \(\to \) \(\mathbb {R}\) rather than \(V \to V \to \mathbb {R}\), which makes symmetry automatic.
Labels are the dual objects to matchings: \(\sum _v l(v)\) upper-bounds the weight of any perfect matching, and Theorem 5.5 says a matching attaining that bound is optimal.
! The existence claim (5.12) is not stated as a lemma anywhere in this file, though the Kuhn–Munkres algorithm needs it as its starting point.
Not merely that some spanning path exists, but that both endpoints may be prescribed arbitrarily: \(\forall \) u v, u \(\ne \) v \(\to \) \(\exists \) p : G.Walk u v, p.IsHamiltonian.
Substantially stronger than being hamiltonian, and correspondingly forces many edges — part (a) is hamiltonConnected_edge_bound below, part (b) is exists_extremal_hamiltonConnected.
The book’s \([x]\) here denotes the ceiling, so \([\tfrac {1}{2}(3\nu +1)]\) is \((3 * \nu + 1 + 1) / 2\) in natural-number division.
In a cubic graph a proper 3-edge colouring splits the edges into three perfect matchings. Any two of them form a spanning 2-regular subgraph — a disjoint union of even cycles. If that union had more than one cycle, swapping the two colours around a single cycle would give a genuinely different partition, contradicting uniqueness. So each pair of classes is a single spanning cycle, i.e. a Hamilton cycle.
! hcol is mandatory. IsUniquelyEdgeColourable quantifies over proper 3-colourings; if none exists the condition holds vacuously, and the statement would then assert that every cubic graph with no 3-edge-colouring is hamiltonian — false, the Petersen graph being a counterexample (\(\chi ' = 4\), nonhamiltonian). Requiring G.lineGraph.Colorable 3 rules that out.
The graph just barely fails to be hamiltonian: no spanning cycle itself, yet deleting any single vertex repairs the defect.
\(G - v\) is G.induce ({v}\(^{c}\) : Set V), whose carrier is a subtype, so each IsHamiltonian obligation is about a different vertex type. The open scoped Classical in above the definition is what discharges the resulting Fintype/DecidableEq instances on those carriers.
petersen_isHypohamiltonian below — the exercise itself.
\(k\)-critical graphs are the irreducible witnesses to needing \(k\) colours. Exercise 8.1.7 classifies the small cases completely — the only 1-critical graph is \(K_{1}\), the only 2-critical graph is \(K_{2}\), and the 3-critical graphs are exactly the odd cycles — and Brooks’ theorem 8.4 consumes precisely that classification to get its standing hypothesis \(k \ge 4\).
G.chromaticNumber = k compares an \(\mathbb {N}\infty \) with a coerced \(\mathbb {N}\), so \(k\)-chromaticity here also carries the information that \(\chi (G) \ne \top \).
Criticality forces robust connectivity: a graph that minimally needs \(k\) colours cannot be pulled apart by fewer than \(k - 1\) edge deletions. This sits alongside theorem 8.1, which gives the corresponding degree bound \(\delta \ge k - 1\), and corollary 8.2, which rules out cut vertices — three different senses in which a critical graph is tightly held together.
The conclusion k - 1 \(\le \) edgeConnectivity is the definition of \((k-1)\)-edge-connected (B&M §3.1: \(G\) is \(k\)-edge-connected if \(\kappa ' \ge k\)), so no separate predicate is needed. Step 1 relies on sInf \(\emptyset \) = 0 being harmless: if \(G\) has no edge cut at all the bound must still be proved, and there step 2 has nothing to work with — dispatch that case by noting a graph with no edge cut is complete or trivial.
A vertex of small degree is never an obstacle to colouring, since some colour is always free for it. So a graph that genuinely needs \(k\) colours, minimally, cannot contain such a vertex — criticality is what turns "\(v\) is easy to colour" into a contradiction rather than merely an observation.
\(k - 1\) is \(\mathbb {N}\)-subtraction, but the statement is a lower bound, so truncation is harmless: at \(k = 0\) it reads 0 \(\le \) minDegree. Step 4 is where the strict inequality \(\delta \lt k - 1\) is spent, so it needs \(k \ge 1\) to know Fin (k-1) is the right palette — available from \(h.1\) as in step 1.
This generalises theorem 8.2 from clique cuts to uniquely colourable ones, and isolates what theorem 8.2 was really using. A clique cut forces the vertices of \(S\) to take distinct colours; what the gluing actually needs is only that the partition of \(S\) is forced, so that the pieces can be reconciled by renaming colours. Complete graphs are uniquely colourable, so theorem 8.2 is the special case.
The shared machinery worth extracting once: (i) an \(S\)-component family indexed by ConnectedComponent, (ii) "every edge of \(G\) lies in some \(S\)-component", and (iii) the gluing lemma turning agreement on \(S\) into a colouring of \(G\). With those, theorem 8.2 and this exercise differ only in step 4. \(k - 1\) is \(\mathbb {N}\)-subtraction; hG.1 supplies \(k \ge 1\).
A 1-chromatic graph has no edges and at least one vertex. Criticality forces exactly one — with two or more vertices, deleting one leaves a graph still needing one colour, so the chromatic number would not drop.
\(\top \) : SimpleGraph (Fin 1) is \(K_{1}\); on a single vertex the complete and empty graphs coincide, which is what makes step 3 go through despite \(G\) being edgeless. Note that without the Subgraph-lattice definition of IsCritical, step 2 would fail: the edge-only order has no proper subgraph of \(\bot \) to test, and every edgeless graph would count as 1-critical.
An odd cycle is 3-chromatic and minimally so — delete any edge or vertex and it unrolls into a path, which is 2-colourable. Conversely a 3-critical graph cannot contain an odd cycle properly, and it must contain one, so it is one. This classification is exactly what Brooks’ theorem 8.4 consumes: its proof observes that *since 1-critical and 2-critical graphs are complete and 3-critical graphs are odd cycles, we have \(k \ge 4\)*.
"The only 3-critical graphs are the odd cycles" is up to isomorphism, hence Nonempty (G \(\simeq \)g cycleGraph n) rather than an equality. Steps 3–5 are the same three moves used in isKCritical_two_iff (with an edge in place of an odd cycle); factoring out "a subgraph attaining \(\chi (G)\) must be \(\top \)" as a lemma about IsCritical pays for itself across all three cases of 8.1.7.
A 2-chromatic graph has at least one edge, and a single edge already needs both colours; criticality leaves no room for anything else.
\(\top \) : SimpleGraph (Fin 2) is \(K_{2}\). Step 3 is the shared "a subgraph attaining \(\chi (G)\) must be \(\top \)" lemma noted under the 3-critical case.
The edges of \(G\) partition into groups, each a \(k\)-regular spanning subgraph. The book’s \(G = H_{1} \cup \dots \cup H_n\) becomes \((\bigsqcup i, H i) = \top \) in the Subgraph lattice, where \(\top \) is \(G\) viewed as a subgraph of itself.
Being \(1\)-factorable means the edges split into perfect matchings: \(K_{n,n}\) and \(K_{2n}\) are (exercise 5.1.5(a)(i)), the Petersen graph is not (exercise 5.1.5(a)(ii)).
\(1\)-factorability is exactly proper edge colouring with \(\Delta \) colours: each factor is a colour class. So exercise 5.1.5(a)(ii) is the statement that the Petersen graph has chromatic index \(4\), which reappears in EdgeColourings.lean.
\(s\) is independent, lies inside \(t\), and cannot be enlarged *within \(t\)* without losing independence.
The book only ever says "maximal independent set of \(G - X\)" for various \(X\). Rather than form the deleted graph, this relativises: \(t\) is the ambient set, and maximality is tested against subsets of \(t\). Taking t = Set.univ recovers the plain notion. This is the shape IsCanonicalColouring needs, where each colour class must be maximal in what remains after the earlier classes are removed.
A wasted colour at \(u\) — one missing, another doubled — is an opportunity to improve; the only structure blocking the repair is an odd cycle, whose alternation cannot work out.
! "represented at least twice at \(u\)" counts edges, not colours, so \(hj\) is 2 \(\le \) (univ.filter fun e => ↑e \(\in \) G.incidenceSet u \(\land \) C e = j).card rather than anything phrased via numColoursAt.
! The conclusion "the component is an odd cycle" is stated as: there is an odd cycle \(p\) at \(u\) in twoColourSubgraph C i j whose support coincides with the component’s supp. The membership form \(\forall \) w, w \(\in \) p.support \(\leftrightarrow \) w \(\in \) (…).supp is used instead of a set equality to avoid a Fintype (ConnectedComponent.supp) obligation that does not synthesize.
Among all \(k\)-edge colourings — proper or not — prefer those spreading colours most widely, measured by \(\sum _v c(v)\). Rendered directly as \(\forall \) C’, \(\sum \) v, numColoursAt C’ v \(\le \) \(\sum \) v, numColoursAt C v, i.e. \(C\) attains the maximum.
Since \(c(v) \le d(v)\) with equality everywhere iff proper, a proper colouring is automatically optimal. The chapter’s strategy is the converse direction: start from an optimal colouring and show that if it were not proper it could be improved after all.
! Note this is a static extremal condition, not a procedure — no improvement algorithm is defined here. Existence of an optimal colouring (needed by Theorem 6.1 and Vizing) follows from finiteness of the colouring space but is not stated as a lemma anywhere in this file, and both proofs will need it.
Two edges are adjacent exactly when they meet at a vertex, so "no two adjacent edges share a colour" is "at every vertex the incident edges carry distinct colours" — i.e. \(c(v) = d(v)\).
Properness is stated directly as \(\forall \) e\(_{1}\) e\(_{2}\), G.lineGraph.Adj e\(_{1}\) e\(_{2}\) \(\to \) C e\(_{1}\) \(\ne \) C e\(_{2}\) rather than by packaging \(C\) as a lineGraph.Coloring, since \(C\) here is a bare function.
This equivalence is the bridge turning "make the colouring proper" into the numerical goal "maximise \(\sum _v c(v)\)", which is what optimality is about.
IsRamseyBound n k l says \(n\) is already large enough for that conclusion: \(\forall \) G : SimpleGraph (Fin n), (\(\exists \) s, G.IsNClique k s) \(\lor \) (\(\exists \) t, G.IsNIndepSet l t).
Fixing the carrier as Fin n rather than quantifying over all \(n\)-element types is what makes ramseyNumber an sInf over \(\mathbb {N}\) below.
Total disorder is impossible: any sufficiently large graph contains one kind of order or the other.
ramseyNumber is an sInf. Once the set is nonempty (exists_isRamseyBound) it contains its infimum (Nat.sInf_mem), so \(r(k,l)\) genuinely has the defining property.
Note isRamseyBound_mono is not needed for this — Nat.sInf_mem alone suffices — but it is what makes \(r(k,l)\) the sharp threshold rather than merely a bound.
Colour every pair of \(n\) points with one of \(m\) colours; once \(n\) is large enough, some colour \(i\) covers all edges within some \(k_{i}\) points.
The target sizes are a function c : Fin m \(\to \) \(\mathbb {N}\) rather than a list, which makes Function.update c i (c i - 1) the natural way to express "decrement the \(i\)-th argument" in Theorem 7.7 below.
A \(k\)-edge colouring is a plain function C : G.edgeSet \(\to \) Fin k, deliberately not assumed proper — that is the whole point, since Lemma 6.1.2, Theorem 6.1 and Vizing’s Theorem 6.2 all operate on improper colourings and repair them.
"Represented at \(v\)" is \(\exists \) e, ↑e \(\in \) G.incidenceSet v \(\land \) C e = i.
! Note this file uses two different colouring encodings. Here a colouring is a raw function G.edgeSet \(\to \) Fin k; but IsUniquelyEdgeColourable below and the edgeChromaticNumber results use Mathlib’s G.lineGraph.Coloring (Fin k), which is proper by construction. The two are not interchangeable, and any proof crossing between §6.1’s machinery and a \(\chi '\) statement must convert explicitly.
Tutte’s condition quantifies over all \(S\), but for trees the singletons already decide it.
(\(\Rightarrow \)) The partner of \(v\) lies in one component of \(G - v\), and a parity count shows exactly one component is odd.
(\(\Leftarrow \)) \(o(G - v) = 1\) for every \(v\) is Tutte’s condition at singletons, and acyclicity makes that enough: build greedily from the leaves, each leaf forced to match its unique neighbour.
Combined with exercise 5.1.2, a tree’s perfect matching — when it exists — is unique and locally detectable.
Suppose a tree had two perfect matchings \(M \ne M'\). Every vertex meets at most one edge of each, so every vertex of \(M \Delta M'\) has degree one or two and its components are alternating paths and even cycles. Both matchings being perfect, no vertex is an endpoint of such a path, so only cycles occur — impossible in an acyclic graph. Hence \(M \Delta M' = \emptyset \).
Colours are arbitrary labels, so what a colouring really determines is the partition into colour classes. Unique colourability means that partition is forced, and any two proper colourings differ only by renaming — which is what the permutation \(\sigma \) expresses.
Proper \(k\)-edge colourings are rendered as G.lineGraph.Coloring (Fin k), using Mathlib’s line graph: adjacent edges of \(G\) become adjacent vertices of G.lineGraph, so a proper vertex colouring there is a proper edge colouring here.
! "Induce the same partition" and "differ by a permutation of colours" are equivalent only when every colour is actually used. If \(k\) exceeds the number of classes, two colourings can induce the same partition while no single \(\sigma \) relates them pointwise — and conversely \(\sigma \) may permute unused colours freely. For the intended application (\(k = 3\), 3-regular, so all three classes nonempty) this is harmless, but the definition is not faithful in general.
\(V'\) is a Finset V, and "\(G - V'\) is disconnected" is \(\lnot \) (G.induce (↑S)\(^{c}\)).Connected. The conjunct ↑S \(\subset \) Set.univ records that a vertex cut is a proper subset: without it \(S = V\) would qualify vacuously, since Mathlib’s Connected is false on the empty induced graph.
A \(k\)-vertex cut is the pair G.IsVertexCut S \(\land \) S.card = k; that is exactly what vertexConnectivity minimises over.
\(G \lor H\), rebuilt on Mathlib: within-side edges from \(\oplus g\), all cross edges from completeBipartiteGraph. symm/loopless are inherited from \(\sqcup \).
Lay the two graphs side by side keeping all their own edges, then add every edge running between them. The book’s \(G + H\) (disjoint union) is Mathlib’s \(\oplus g\), and "joining each vertex of \(G\) to each vertex of \(H\)" is exactly completeBipartiteGraph V W, so
join G H = (G \(\oplus \)g H) \(\sqcup \) completeBipartiteGraph V W
on carrier \(V \oplus W\). Building it as a \(\sqcup \) of two existing graphs means symm and loopless are inherited and need no proof.
The building block of the graphs Cmn below.
By part (a) the join’s chromatic number is the sum, so a drop on one side is a drop for the join. This yields a construction for critical graphs of large chromatic number: join known critical graphs. For instance \(K_{1} \lor C_{5}\) is 4-critical, \(C_{5}\) being 3-critical (exercise 8.1.7) — this is exactly the family exercise 8.1.12 asks for.
Step 4 is the one that would be missed by reasoning only about "remove a vertex or a within-side edge"; the subgraph lattice of a join contains subgraphs that are not themselves joins, and they must be handled.
Colour each side separately; the two colourings may clash across the cut, but there are at most \(n - 1\) cut edges and \(n!\) ways to relabel one side’s palette — far more freedom than there are constraints to violate. A thin cut therefore cannot force an extra colour. Note how sharp the count is: \(n\) cut edges would give \(n \cdot (n-1)! = n!\), exactly enough to rule out every permutation.
hcut is stated as #cross + 1 \(\le \) n rather than #cross \(\le \) n - 1 to avoid \(\mathbb {N}\)-subtraction, and it carries \(n \ge 1\) as a side benefit. The partition \((X, Y)\) is \(X\) and its complement, so \(Y\) never appears by name. Step 4 needs Fintype.card (Equiv.Perm (Fin n)) = n ! and the factorial identity \(n ! = n * (n-1)!\).
This inequality is precisely what Brooks’ theorem uses to dispose of the 2-vertex-cut case: combined with \(d(u), d(v) \le \Delta \) it forces \(2\Delta \ge 3k - 5\), which for \(k \ge 4\) already gives \(k \le \Delta \).
Stated additively as \(3k \le d(u) + d(v) + 5\) rather than \(d(u) + d(v) \ge 3k - 5\), because \(\mathbb {N}\)-subtraction would truncate \(3k - 5\) to \(0\) for \(k \le 1\) and make the statement vacuous exactly where it should be informative. Step 5 deserves care: if \(u\) and \(v\) had a common neighbour in \(G_{2}\), contracting would merge two edges into one and the degree identity would fail — establish that they do not, or weaken the identity to the inequality actually needed.
At a 2-vertex cut a critical graph splits into exactly two pieces with opposite demands on \(u\) and \(v\) — one insisting they agree, the other that they differ. That is why the cut cannot be repaired, and it is the structural fact that both Brooks’ theorem (via corollary 8.3) and theorem 8.5 exploit.
Worth proving first, and reused in step 6: for \(k \ge 2\), criticality can be checked on single-edge deletions alone. Any \(H \lt \top \) is contained in some \(\top \) \{} edge e, and \(\chi \) is monotone, so \(\chi \)(H.coe) \(\le \) \(\chi \)(\(\top \) \{} edge e); vertex deletions are subsumed because a critical graph has \(\delta \ge k - 1 \ge 1\) (theorem 8.1), so every vertex carries an edge. This closes the gap between the book’s edge-only check and the Subgraph-lattice definition of IsCritical.
The (by simp [uvComponent]) arguments in the statement are the membership proofs u, v \(\in \) (uvComponent …).verts, discharged by unfolding — the \({u, v}\) is glued onto every component by construction.
The prototypical min-max theorem of combinatorics — maximum packing equals minimum cover. Closely related to Hall’s theorem: exercise 5.2.7 asks to derive Hall from König, and its matrix form is exercise 5.2.5.
Note the Lean statement takes both extremal objects as hypotheses (hM, hK) and concludes their sizes agree, rather than constructing \(\tilde{K}\) as the book does.
König’s Theorem 5.3 in matrix dress. A vertex per row and per column, joining row \(i\) to column \(j\) when A i j = true. Lines covering all the \(1\)s are a vertex covering; \(1\)s no two sharing a line are a matching.
The IsLeast/IsGreatest hypotheses supply the two optima as given, so this statement only has to equate them. "No two in the same line" is rendered as the pair of InjOn conditions on Prod.fst and Prod.snd.
Hall’s theorem says a matching saturating \(X\) exists exactly when \(|S| - |N(S)| \le 0\) for all \(S \subseteq X\). The defect formula quantifies failure: the largest \(|S| - |N(S)|\), the deficiency, is exactly how many vertices of \(X\) a maximum matching must leave unsaturated. Hall is the zero-deficiency case.
Formalised additively as |M| + deficiency = |X| to avoid \(\mathbb {N}\) subtraction on the outside.
! But the inner S.ncard - (\(\bigcup \) …).ncard is still natural subtraction, so it truncates to \(0\) exactly when Hall’s condition holds at \(S\) — which is what makes the \(\bigsqcup \) compute the book’s max{…} correctly only because the book’s max is also effectively taken against \(0\) (via \(S = \emptyset \)). This is a happy accident rather than a faithful rendering, and is worth re-checking when the proof is attempted.
A cubic hamiltonian graph splits into an even cycle plus a perfect matching; two colours alternate around the cycle and the third takes the matching.
Why this matters (§9.7). Tait (1880) showed the four-colour conjecture equivalent to "every simple 3-regular 3-connected planar graph has a Tait colouring" (theorem 9.12(iii)), and then by mistakenly assuming that every such graph is hamiltonian, gave a "proof" of the conjecture using exactly this exercise. Over half a century later Tutte (1946) exhibited a nonhamiltonian 3-regular 3-connected planar graph, invalidating the argument. So this exercise is sound; only Tait’s extra assumption was not.
A Tait colouring is spelled G.lineGraph.Colorable 3, needing no new definitions — lineGraph has the edges of \(G\) as vertices, adjacent when they share an end, so a proper colouring of it is a proper edge colouring of \(G\). Step 3’s parity assignment is the fiddly part: it needs a function from an edge of \(c\) to its index along \(c\), which c.edges provides as a list position.
Two edges are adjacent in the edge graph exactly when they share an end; simplicity makes that end unique, so the count localises at each vertex.
! Step 1’s uniqueness is where simplicity is spent — with parallel edges two edges could share both ends and be counted twice. Part (b) of the exercise, not stated here, notes the edge graph of \(K_{5}\) is the complement of the Petersen graph.
Exercise 1.6.3 already gives a path of length \(\delta \) from the minimum degree alone; Dirac’s sharpening doubles that, at the cost of connectivity and \(\nu \gt 2\delta \).
The bracketed cycle version — 2-connected, \(\nu \ge 2\delta \), cycle of length \(\ge 2\delta \) — is stated but not proved in the chapter. It is what exercise 4.2.10 relies on; see the warning there. It is not stated in this file either.
The edges of a matching are pairwise disjoint and the covering must contain an endpoint of each; since no two matching edges share an endpoint, the chosen endpoints are distinct, so \(K\) has at least \(|M|\) elements.
The book continues:
which is König’s Theorem 5.3.
\(\sum ^{f}\) e \(\in \) M.edgeSet, w e, using the finsum \(\sum ^{f}\) rather than Finset.sum so that no Fintype (M.edgeSet) instance has to be threaded through — M.edgeSet is a Set, and finsum handles the finiteness side condition implicitly.
In the personnel-assignment setting \(w(x_{i}y_{j})\) is the effectiveness of worker \(X_{i}\) in job \(Y_{j}\), and \(w(M)\) the total effectiveness of assignment \(M\).
Take \(v\) of maximum degree \(\Delta \). All \(\Delta \) edges at \(v\) are pairwise adjacent, so a proper colouring gives them \(\Delta \) distinct colours.
\(\chi '\) is G.lineGraph.chromaticNumber, valued in \(\mathbb {N}\infty \), so \(\Delta \) is cast.
This bound is half of every result in the chapter: Theorem 6.1 says bipartite graphs attain it, Vizing says nobody exceeds it by more than one.
A planar graph cannot be everywhere dense: Euler’s formula caps its edge count at \(3\nu - 6\), so the average degree is below \(6\) and some vertex has degree at most \(5\). This is the fact driving the five-colour theorem 9.11 — every planar graph has a vertex of degree at most five to induct on — and it is why the arithmetic core was worth salvaging even though the planarity around it was not.
! This is not corollary 9.5.3 as the book states it. Planarity is replaced by the hypothesis \(h\varepsilon \), which corollary 9.5.2 (dropped, being unstatable without faces) would have supplied. Ship it under the name minDegree_le_five_of_card_edge_le, never as planar_minDegree_le_five: the theorem proved is the arithmetic half only. Stated additively (\(\varepsilon + 6 \le 3\nu \)) to dodge truncated \(\mathbb {N}\)-subtraction.
Worth knowing while filling: h\(\nu \) : 3 \(\le \) Fintype.card V is unused. Steps 1–4 never mention \(\nu \) except through the two inequalities \(2\varepsilon + 12 \le 6\nu \) and \(6\nu \le 2\varepsilon \), whose contradiction is independent of the size of \(\nu \). The book needs its \(\nu = 1, 2\) caveat because it invokes corollary 9.5.2, which carries \(\nu \ge 3\); once that corollary is replaced by the raw hypothesis \(h\varepsilon \), the caveat evaporates. \(h\nu \) is kept only so the statement still reads as the book’s; do not go looking for a place to use it.
on V \(\oplus \) V \(\oplus \) Unit: inl = the old graph, inr \(\circ \) inl = the shadows \(u_{i}\) (joined to \(v_{i}\)’s neighbours), inr \(\circ \) inr = the apex (joined to every shadow). ! MISSING from Mathlib.
Each original vertex \(v_{i}\) gets a shadow \(u_{i}\) attached to \(v_{i}\)’s neighbourhood but not to \(v_{i}\) itself, and a single apex \(v\) is joined to all the shadows. The construction preserves triangle-freeness while raising the chromatic number by exactly one; starting from \(K_{2}\) it yields the 5-cycle, then the Grötzsch graph, and in general a triangle-free \(k\)-chromatic graph on \(3\cdot 2^{k-2} - 1\) vertices. Theorem 8.7 is the proof that it does this.
Carrier V \(\oplus \) V \(\oplus \) Unit: inl a is the original \(v_a\), inr (inl a) its shadow \(u_a\), inr (inr ()) the apex. Reading the Adj match against the book: inl–inl copies \(G\); inl–inr \(\circ \) inl joins \(u_a\) to the neighbours of \(v_a\) (note G.Adj a b, not \(a = b\), so \(u_a\) is not joined to \(v_a\)); inr \(\circ \) inl–inr \(\circ \) inr joins every shadow to the apex. Everything else is False, which in particular leaves the shadows independent and the apex nonadjacent to the original vertices.
Iterate Mycielski’s construction from a single edge. The book records the first few: \(G_{2} = K_{2}\), \(G_{3}\) is the 5-cycle, \(G_{4}\) is the Grötzsch graph of figure 8.2. Exercise 8.5.1 strengthens theorem 8.7 for this particular tower: each \(G_k\) is not merely \(k\)-chromatic but \(k\)-critical.
Each \(G_k\) lives on a different carrier (V \(\oplus \) V \(\oplus \) Unit of the previous one), so the recursion must be Sigma-valued: it returns a carrier together with a graph on it. The book’s tower starts at \(k = 2\); the clauses \(0\) and \(1\) are padding so the function is total, and every statement about the tower carries the hypothesis \(2 \le k\). This def is the reason mycielskian must exist as a standalone operation rather than being inlined into theorem 8.7.
Theorem 8.7 already shows \(G_k\) is \(k\)-chromatic; the exercise asks for the stronger fact that it is minimally so — the shadows and apex are arranged so tightly that every element of the graph is load-bearing. So the Mycielski tower produces not just triangle-free graphs of high chromatic number but triangle-free critical ones. For \(k = 3\) it gives the 5-cycle (3-critical by exercise 8.1.7) and for \(k = 4\) the Grötzsch graph, which the book displays in figure 8.2 precisely as its example of a 4-critical graph.
mycielskiTower is Sigma-valued, so (mycielskiTower k).2 is the graph and (mycielskiTower k).1 its carrier; the induction in step 1 must therefore be stated over the Sigma, not over a fixed carrier. The definitional unfolding mycielskiTower (k+1) = ⟨_, (mycielskiTower k).2.mycielskian⟩ is what makes step 2 usable.
Such a graph has \(\delta = \Delta = 2k\) and \(\nu = 4k + 1 = 2\delta + 1\), one vertex above the threshold \(\nu \ge 2\delta \) of Dirac’s cycle remark. That remark yields a cycle of length at least \(2\delta = 4k\) — missing at most one vertex — and regularity plus parity then force the cycle to pick up the last vertex too.
! The Lean signature omits the book’s \(k \ge 1\). At \(k = 0\) the statement reads "every \(0\)-regular graph on \(1\) vertex is hamiltonian", which is false in Mathlib: a Hamilton cycle needs length \(\ge 3\), so the one-vertex graph is not IsHamiltonian. The hypothesis \(1 \le k\) must be added.
Suppose \(v\) is a cut vertex, so \(G - v\) splits. Independent sets can be chosen per component, and one shows some edge at \(v\) is deletable without increasing \(\alpha \) — contradicting criticality, where every deletion must raise it.
So \(\alpha \)-criticality forces a structure that cannot be pieced together at a single articulation point.
Corollary 7.1 gives \(\alpha + \beta = \nu \) for every graph on the vertex type, and edge deletion leaves \(\nu \) fixed. So \(\beta (G - e) \lt \beta (G)\) \(\iff \) \(\alpha (G - e) \gt \alpha (G)\), and \(\beta \)-critical is the same condition as \(\alpha \)-critical.
So \(k\)-critical graphs come in sizes \(k\) (the complete graph \(K_k\)) and \(k + 2\) or more, never \(k + 1\). The reason is that one vertex of slack forces the complement to be a matching, and a matched pair has identical neighbourhoods — the most extreme violation of part (a). Exercise 8.1.12 asks for 4-critical graphs on \(n\) vertices for \(n = 4\) and all \(n \ge 6\); the gap at \(n = 5\) is exactly this result.
Step 2’s degree identity G.degree v + G\(^{c}\).degree v = card V - 1 is the workhorse and is worth stating as its own have. Take care that \(k - 1\) in step 1 is \(\mathbb {N}\)-subtraction — the case \(k = 0\) should be dispatched separately (a 0-chromatic graph has an empty carrier, so card V = 1 is impossible).
B&M’s general isomorphism needs two bijections, one on vertices and one on edges, respecting incidence. For simple graphs the edge bijection carries no information — at most one edge joins any pair — so an adjacency-preserving vertex bijection already induces it. This is precisely why Mathlib can define \(G \)≃\(g H\) as an equivalence of vertex types with G.Adj u v \(\leftrightarrow \) H.Adj (\(\theta \) u) (\(\theta \) v), and this exercise is the justification for using it throughout the file.
A graph that is not 2-connected is either disconnected or has a cut vertex \(v\). Disconnected: no cycle reaches every vertex. Cut vertex: take \(S = {v}\) in Theorem 4.2 — deleting \(v\) leaves at least two components, so \(\omega (G - S) \ge 2 \gt 1 = |S|\), violating the necessary condition.
A Hamilton cycle visits every vertex and returns, which needs two independent routes out of every vertex — exactly 2-connectivity. Necessary but far from sufficient (the Petersen graph is 3-connected and nonhamiltonian).
Stated against this file’s local vertexConnectivity, not the one in Connectivity.lean — see the warning on that definition above.
Every edge crosses between \(X\) and \(Y\), so a cycle alternates sides and uses equally many vertices from each. A Hamilton cycle uses all vertices, forcing \(|X| = |Y|\).
This is why the book’s Herschel graph is nonhamiltonian:
(§4.2, p. 61.) Equivalently, apply Theorem 4.2 with \(S\) the smaller side.
A graph and its complement cannot both be hard to colour: an edge missing from \(G\) is present in \(G^{c}\), so the two compete for the same \(\nu - 1\) adjacencies at each vertex. Equality holds for complete graphs, where \(\chi (K_{n}) = n\) and \(\chi (K_{n}^{c}) = 1\). This is the archetypal Nordhaus–Gaddum inequality, of which many analogues are known for other graph parameters.
The addition is in \(\mathbb {N}\infty \), where subtraction is badly behaved — hence step 1, which moves the whole argument into \(\mathbb {N}\) before any arithmetic. Step 3’s index gymnastics (reverse, then complement) is the fiddliest part and is worth isolating as its own lemma about the two sorted sequences.
Planarity forces sparsity, and a graph and its complement cannot both be sparse: between them they must carry every possible edge, and \(C(\nu ,2)\) outgrows \(2(3\nu -6)\) at exactly \(\nu = 11\). Part (b) of the exercise confirms the bound is sharp in spirit — there is a simple planar graph on \(\nu = 8\) vertices whose complement is also planar.
! This is not exercise 9.3.3(a) as stated. "Planar" is replaced by the corollary-9.5.2 edge bound on both sides, so what is proved is that the two bounds are jointly unsatisfiable — the arithmetic obstruction, with the topology stripped out. The conclusion is therefore a negated conjunction rather than "\(G^{c}\) is nonplanar".
Count the proper colourings as labelled objects, not up to permutation of the colours — the triangle example is exactly the warning against quotienting. Birkhoff (1912) introduced this counting approach as a possible route to the four-colour conjecture.
Nat.card (G.Coloring (Fin k)) rather than Fintype.card: the two agree over a Fintype, but Nat.card needs no instance, which lets the §8.4 statements elaborate over Subgraph and component carriers without bespoke Fintype derivations. A G.Coloring (Fin k) is a function on vertices, so distinctness is pointwise — precisely the book’s criterion.
Classify the \(k\)-colourings of \(G - e\) by whether they give \(u\) and \(v\) the same colour: the "same" ones are the colourings of \(G \cdot e\), the "different" ones are the colourings of \(G\). The book notes the recursion *bears a close resemblance to the recursion formula for \(\tau (G)\)* in theorem 2.8, and that it can be run in either direction — reducing to empty graphs (efficient for sparse \(G\)) or to complete graphs (efficient for dense \(G\)), as illustrated in figure 8.9.
Stated additively, \(\pi _k(G) + \pi _k(G\cdot e) = \pi _k(G-e)\), to stay in \(\mathbb {N}\) — the book’s headline form has a subtraction. Happily this is how B&M’s own proof ends, so the Lean statement is the more faithful of the two. Steps 2 and 3 are the only real work; step 1 is bookkeeping and step 4 is \(rw\).
Sanity checks: at \(k = 2\) the formula gives \(1 + (-1)^{n}\), which is \(2\) for even \(n\) and \(0\) for odd \(n\) — matching that even cycles are bipartite (two 2-colourings) and odd cycles are not (none). The \((-1)^{n}\) term is precisely where the parity of the cycle enters, and it is what makes odd cycles the exceptional family throughout this chapter.
Stated over \(\mathbb {Z}\) with a cast on the left, because \((k-1)^{n} + (-1)^{n}(k-1)\) is not a natural number expression — the \((-1)^{n}\) term is genuinely negative for odd \(n\). The base case is \(n = 3\) rather than \(n = 0\) because cycleGraph n is only a cycle for \(n \ge 3\), and because contracting an edge of \(C_{3}\) would leave a multi-edge, which contractEdge silently simplifies.
No edge joins different components, so their colourings are entirely independent: a colouring of \(G\) is precisely a choice of colouring for each component, and the count multiplies. This is the chromatic-polynomial version of \(\chi \)(G) = max \(\chi \)(G\(_{i}\)), and one of the formulae the book lists as *facilitating the calculation of chromatic polynomials*.
Step 2 is the same "components are independent" equivalence used by IsCritical.connected (in its sup form) — worth building once in a shared place and specialising twice, since the counting and the \(\chi \) versions differ only in what is applied to the resulting family.
Choose the apex’s colour first — \(k\) ways — and then \(G\) must be coloured with the remaining \(k - 1\) colours. This is the chromatic-polynomial counterpart of \(\chi (G \lor K_{1}) = \chi (G) + 1\), the \(K_{1}\) case of exercise 8.1.10(a).
\(hk : 1 \le k\) keeps \(k - 1\) from truncating in step 3, where the equivalence {c : Fin k // c \(\ne \) j} \(\simeq \) Fin (k-1) genuinely needs \(k \ge 1\). The statement happens to hold at \(k = 0\) as well — both sides are then \(0\), the join being nonempty — so \(hk\) is a convenience for the proof rather than a correction to the claim.
Among connected graphs on \(\nu \) vertices, trees are exactly the ones with the most colourings: every extra edge kills at least one colouring of the spanning tree.
The two clauses are bundled as a conjunction because the book states them together; only the second needs the guard on \(k\). Note step 5 is where the whole content sits — step 2’s inequality is nearly formal.
Root the tree anywhere and colour outward: the root takes any of the \(k\) colours, and every other vertex is reached across exactly one edge from its already-coloured parent, so it avoids just that one colour. The formula reflects the structure exactly — \(\nu - 1\) edges, each imposing precisely one constraint, with no cycles to make the constraints interact.
\((k - 1)\) is \(\mathbb {N}\)-subtraction, harmless because at \(k = 0\) both sides are \(0\) for a nonempty tree. Consumed by exercises 8.4.3(b) (as the spanning tree bound) and 8.4.4 (as the deleted-edge case of the cycle).
A gluing formula. A colouring of the union is a pair of colourings of the parts agreeing on the overlap; because the overlap is complete, its vertices must take distinct colours, which makes the two sides’ colourings matchable in a uniform number of ways. Together with exercise 8.4.6 (components multiply) this is one of the practical tools for computing chromatic polynomials by decomposition.
Phrased on the Subgraph lattice — \(\sqcup \) and \(\sqcap \) of G.Subgraph — because SimpleGraph V has no notion of union/intersection with differing vertex sets. hcomp : (G’ \(\sqcap \) H’).coe = \(\top \) says the overlap is complete *as a graph on its own vertex set*. Note that the book’s identity is stated multiplicatively precisely to avoid the division that step 5 also avoids.
A wheel with \(n\) spokes is \(C_n \lor K_{1}\) — a rim cycle plus a hub joined to every rim vertex — so its colourings are a hub colour together with a colouring of the rim in the remaining palette. Sanity check: at \(k = 3\) and odd \(n\) the formula gives \(3\cdot 1 + (-1)\cdot 3\cdot 1 = 0\), matching that a wheel with an odd rim is 4-chromatic and so has no 3-colouring at all.
\(hn : 3 \le n\) is inherited from exercise 8.4.4 (the rim must be a genuine cycle); \(hk : 1 \le k\) is what step 4 consumes.
\(c(v)\) counts the distinct colours on edges at \(v\), as (univ.filter fun i => IsRepresentedAt C i v).card.
Two edges at \(v\) sharing a colour drop \(c(v)\) below \(d(v)\); the colouring is proper exactly when \(c(v) = d(v)\) everywhere — that is numColoursAt_le_degree and isProper_iff_numColoursAt_eq_degree below.
\(\sum _v c(v)\) is the potential function the whole chapter maximises.
Nat.card G.ConnectedComponent, following Mathlib’s own idiom in Tutte.lean. Deliberately not named omega, which is a tactic.
Theorem 4.2 only, as the left-hand side of the toughness condition \(\omega (G - S) \le |S|\): a hamiltonian graph cannot fall into many pieces when few vertices are deleted.
! \(\tau (G)\) counts the distinct spanning trees, not the non-isomorphic ones. B&M stress the difference: \(K_{6}\) has six non-isomorphic spanning trees (figure 2.1) but \(6^{4} = 1296\) distinct ones. \(\tau \) satisfies deletion–contraction (theorem 2.8) and, for complete graphs, Cayley’s formula (theorem 2.9); the general determinant formula is chapter 12’s matrix-tree theorem.
"Spanning" is automatic: a T : SimpleGraph W lives on the whole vertex type, so T \(\le \) H \(\land \) T.IsTree already means a spanning tree. ! IsTree bundles Connected, which requires Nonempty W — so on an empty carrier \(\tau = 0\). That is where cayley fails at \(n = 0\).
Iterating the recursion reduces any graph to trivial ones and so computes \(\tau \) — though B&M note it is impractical for large graphs, which is what motivates chapter 12’s determinant formula.
! Currently vacuous. contract has a sorry body, so \(G \cdot e\) is opaque and this statement relates opaque quantities. Worse, contract is a same-carrier placeholder, so even an honest body on \(V\) could not satisfy \(\nu (G\cdot e) = \nu - 1\) and step 3’s bijection would be false. Repair contract on the quotient carrier first — see its docstring.
By Corollary 1.1 the odd-degree vertices come in pairs, so there are \(k\) pairs. Pair them up and add \(k\) new edges joining the members of each pair; every vertex of the enlarged graph then has even degree, so Theorem 4.1 gives an Euler tour. Deleting the \(k\) added edges cuts that tour into exactly \(k\) trails, which are edge-disjoint and between them cover every edge of \(G\).
The practical reading: a road network with \(2k\) awkward junctions needs \(k\) separate pen-strokes; one Euler trail is the case \(k = 1\).
Weak duality certifying optimality again: \(\sum _v l(v)\) bounds every perfect matching from above, and one attaining the bound must be best. This is the foundation of the Kuhn–Munkres algorithm, which alternates the Hungarian method inside \(G_l\) with label adjustments that grow \(G_l\).
The conclusion transports \(M\) along Hom.ofLE from equalitySubgraph w G l up to \(G\), since the two live over different graphs.
Enough edges guarantee a spanning cycle, and this pins down exactly how many "enough" is: a nonhamiltonian graph has at most \(C(\nu -1, 2) + 1\) edges.
"By theorem 1.1" is the handshaking lemma — degree majorisation transfers to an edge-count inequality because \(2\varepsilon = \sum d(v)\).
! The book’s algebra is over \(\mathbb {Q}\) (note the \(\tfrac {1}{2}\)); in \(\mathbb {N}\) the identity \(\tfrac {1}{2}(m^{2} + (\nu -2m)(\nu -m-1) + m(\nu -1)) = C(\nu -1,2) + 1 - \tfrac {1}{2}(m-1)(m-2) - (m-1)(\nu -2m-1)\) involves subtraction that truncates. Either clear denominators and work with \(2\varepsilon \) throughout, or cast to \(\mathbb {Z}\)/\(\mathbb {Q}\) for the identity and cast back. The latter is likely cleaner.
The equality analysis of the first half. The final inequality is tight only when both subtracted terms \(\tfrac {1}{2}(m-1)(m-2)\) and \((m-1)(\nu -2m-1)\) vanish, which happens only for \(m = 1\), or \(m = 2\) together with \(\nu = 5\).
So the bound is attained by exactly one graph for each \(\nu \), plus one sporadic extra at \(\nu = 5\): the densest nonhamiltonian simple graphs there are.
! The book’s closing "which is easily seen to imply that \(G \cong C_{1,\nu }\)" is the hardest step to formalise, and it is not easy in Lean. Degree sequence does not in general determine a graph up to isomorphism; the implication holds here only because of the specific structure of \(C_{1,\nu }\) and \(C_{2,5}\), and recovering an explicit \(\simeq \)g requires constructing the vertex bijection by hand.
Overlapping comes in exactly two flavours. This dichotomy is what the dropped theorem 9.8 disposes of — the skew case by the Jordan curve theorem, the equivalent-3-bridge case by the tripod of theorem 9.7. It is the reason theorem 9.7 exists at all.
"Equivalent 3-bridges" is rendered as the conjunction attach c e = attach c e’ \(\land \) (attach c e).ncard = 3, matching the book’s definition of equivalent \(k\)-bridges. Steps 2–4 all reduce to arc arithmetic on cycleIdx, so the segment machinery built for Overlaps will carry most of them.
Neither bridge’s attachments fit inside a single segment of the other, so drawn on the same side of \(C\) they would be forced to cross. Theorem 9.8 says this cannot happen for two inner (or two outer) bridges of a plane graph, and theorem 9.6 says overlapping comes in only two shapes.
! Repaired — previously sorry. This definition formerly had the body Prop := sorry, making it an opaque, unspecified proposition and rendering overlap_imp_skew_or_equivalent_three_bridge (theorem 9.6) vacuous: with Overlaps opaque, that theorem said nothing about bridges and "proving" it would have established nothing. It also violated the project convention (.claude/CLAUDE.md): never sorry in a def — a sorry-ed proof is an honest debt, a sorry-ed definition is a silent change of meaning.
It is now the honest negation of Avoids, built on the segment machinery above (cycleDist \(\to \) OnArc \(\to \) ConsecutiveAttach \(\to \) Avoids), which is the layer B&M assume when they speak of segments. ! [DecidableEq V] had to be added to the signature, since cycleIdx needs it; every use site already had the instance.
The family form needed to state Menger: a Finset of \(u\)–\(v\) walks that is pairwise internally disjoint. "At least \(k\) paths" is then a cardinality condition on that Finset.
Menger itself is deliberately not stated in this file — the book defers its proof to chapter 11, so it lives in Networks.lean (menger_vertex_graph, menger_edge_graph). This definition exists so that chapter 11 can refer back to a chapter-3 notion.
The Paley graph of order 17 — the canonical self-complementary, highly symmetric graph. \({1,2,4,8,9,13,15,16}\) is closed under negation (\(-1 = 16\), \(-2 = 15\), …), so symm holds.
+ Fully defined, symm/loopless discharged by decide — no sorry.
+ The slick route: the Paley graph of order 17 is self-complementary (the book notes this), so a 4-element independent set would be a \(K_{4}\) in the complement, i.e. in an isomorphic copy — ruled out by the previous lemma.
! But that route costs a self-complementarity proof (an explicit isomorphism \(x \mapsto gx\) for \(g\) a non-residue), which is more work than the direct check.
An edge-count sufficient condition, in the spirit of Corollary 4.6 for hamiltonicity. The threshold is the edge count of the densest simple graph on \(\nu \) vertices with minimum degree \(\delta \) that still violates Tutte’s condition: a \(\delta \)-set \(S\) whose removal leaves too many odd components, plus as many edges as can be packed around it. Exceeding it leaves no room to violate Tutte.
Part (a) — "characterise the maximal simple graphs which have no perfect matching" — has no propositional content and is dropped; the book’s answer is recorded in the dropped-items section at the end of this file.
Petersen’s argument at general \(k\). For \(S \subset V\) with odd components \(G_{i}\) of \(G - S\) and \(m_{i}\) the edges from \(G_{i}\) to \(S\): regularity gives \(m_{i} = k\nu (G_{i}) - 2\varepsilon (G_{i})\), of the same parity as \(k\nu (G_{i})\). Those edges form an edge cut, so \((k-1)\)-edge-connectivity gives \(m_{i} \ge k - 1\), and parity upgrades that to \(m_{i} \ge k\) where needed. Summing, \(k \cdot o(G - S) \le \sum m_{i} \le \sum _{v \in S} d(v) = k|S|\).
Corollary 5.4 is the case \(k = 3\): a bridgeless cubic graph is 2-edge-connected.
A double count per odd component, then Tutte. The parity step is the crux: \(m_{i} = 3\nu (G_{i}) - 2\varepsilon (G_{i})\) is odd because \(\nu (G_{i})\) is odd, and bridgelessness then upgrades \(m_{i} \ge 1\) to \(m_{i} \ge 3\).
! The book’s \(\tfrac {1}{3} \sum m_{i} \le \tfrac {1}{3} \sum _{v \in S} d(v)\) is over \(\mathbb {Q}\). In \(\mathbb {N}\) this should be cleared to \(3n \le \sum m_{i} \le 3|S|\) and divided only at the end, or done in \(\mathbb {Z}\).
The \(3\)-regular graph on ten vertices, the Kneser graph on 2-subsets of a 5-element set (adjacent when disjoint).
In this chapter it is the standing witness that (6.1) can be strict for non-bipartite graphs: \(\Delta = 3\) but \(\chi ' = 4\), the upper side of Vizing’s dichotomy.
Equivalently, by the partition view of a proper colouring, this is exercise 5.1.5(a)(ii) — the Petersen graph is not 1-factorable.
Join two cars when within range. Turns a communications question into a degree question: "car \(i\) reaches \(k\) others" is "vertex \(i\) has degree \(k\)".
+ Fully defined.
! Uses \(\le \) range, not \(\lt \) — so cars at exactly the limit can communicate. The exercise does not say which, and the conclusion is unaffected.
Take \((k+1,k+1)\)- and \((l+1,l+1)\)-Ramsey graphs \(G\), \(H\) — so \(\omega , \alpha \le k\) and \(\le l\) respectively — and form \(G[H]\), which has the product vertex count. Part (a) gives \(\alpha (G[H]) \le kl\); complementing gives \(\omega (G[H]) \le kl\). So \(G[H]\) avoids both a \((kl+1)\)-clique and a \((kl+1)\)-independent set.
Stated additively (\(\dots + 1 \le r(\dots )\)) to avoid \(\mathbb {N}\) subtraction on the outside — though the two inner \(- 1\)s remain.
! The complement step needs \((G[H])^{c} \cong G^{c}[H^{c}]\), which is true but not obvious and is not stated in this file. Without it, part (a) bounds only \(\alpha \) and the clique side has to be argued separately.
The engine behind both the exact values in the book’s table and the binomial bound of Theorem 7.5.
! \(l - 1\) and \(k - 1\) are \(\mathbb {N}\) subtraction; \(hk\), \(hl\) keep them from truncating, but the proof must still convert \(l - 1 + 1 = l\) explicitly at each use.
The parity refinement that pins down \(r(3,4) = 9\): \(r(3,3) = 6\) and \(r(2,4) = 4\) are both even, so \(r(3,4) \le 6 + 4 - 1 = 9\).
! The book’s "in particular, \(v\) cannot be adjacent to precisely \(r(k-1,l) - 1\) vertices" is the crux and compresses a parity computation: with both summands even, \(r(k-1,l) - 1\) is odd, so a vertex of even degree cannot have exactly that degree. That one configuration is precisely the one where neither (i) nor (ii) holds, so ruling it out restores the case analysis.
Iterating Theorem 7.7 gives exactly the multinomial recursion, as the two-colour case gave binomials in Theorem 7.5.
With \(m = 2\) this is Theorem 7.5, since \((k_{1}+k_{2})!/(k_{1}!k_{2}!) = C(k_{1}+k_{2}, k_{1})\).
! The division is exact but is \(\mathbb {N}\) division in Lean; as with card_perfectMatching_completeGraph in chapter 5, the proof should establish the multiplied form \(r(\dots ) * \prod k_{i}! \le (\sum k_{i})!\) and divide only at the end.
Generalises Theorem 7.4’s recursion. Fix \(v\) in a large \(K_{n}\) and classify the other vertices by the colour of their edge to \(v\). If every colour class were smaller than \(r(\dots , k_{i}-1, \dots )\), the classes could not cover all vertices — which is exactly what the bound arranges. Some class is then big enough for a monochromatic complete subgraph, and \(v\) extends it in colour \(i\).
Stated additively (\(+ m\) on the left, \(+ 2\) on the right) to avoid the \(\mathbb {N}\) subtraction \(- m + 2\).
! Function.update c i (c i - 1) still has an inner \(\mathbb {N}\) subtraction; \(hc : \forall i, 2 \le c i\) keeps it from truncating.
The exact threshold at which order becomes unavoidable.
! sInf \(\emptyset \) = 0 is a live trap until exists_isRamseyBound is proved: without it every ramseyNumber k l could silently be \(0\), and every theorem below would be about the wrong number. That existence result is therefore not optional scaffolding — it gates the meaning of the definition itself.
Ramsey numbers are monotone in both arguments, so \(r(k,l) \ge r(m,m)\) for m = min(k,l); then Theorem 7.6.
! Monotonicity of ramseyNumber in its arguments is not stated in this file. isRamseyBound_mono is monotonicity in \(n\), a different thing. The needed lemma — \(k \le k' \to l \le l' \to r(k,l) \le r(k',l')\) — has to be added; it follows from IsRamseyBound n k’ l’ \(\to \) IsRamseyBound n k l (a bigger clique contains a smaller one).
\(r(k, l) \le C(k + l - 2, k - 1)\).
Theorem 7.4’s recursion is exactly Pascal’s rule, so the Ramsey numbers are dominated by binomial coefficients. Setting \(k = l\) gives roughly \(r(k,k) \le 4^k\); Theorem 7.6 gives \(2^{k/2}\) below, and closing that gap is still open.
! Three \(\mathbb {N}\) subtractions in the statement (\(k + l - 2\), \(k - 1\), and \(m - 2\) in the proof). The Pascal step \(C(m+n-3, m-1) + C(m+n-3, m-2) = C(m+n-2, m-1)\) is Nat.choose_succ_succ only after the indices are massaged into succ form — budget for that.
A 1-clique is a single vertex, which any nonempty graph has. So one vertex suffices.
! \(n = 1\) must genuinely satisfy IsRamseyBound 1 1 l and no smaller \(n\) must — but \(n = 0\) also satisfies it vacuously only if Fin 0 graphs have a 1-clique, which they do not. So the sInf really is \(1\), but the \(n = 0\) case has to be ruled out explicitly rather than assumed.
A 2-clique is an edge. On \(l\) vertices either some edge is present — a 2-clique — or there are none, and all \(l\) vertices are independent. So \(l\) suffices; and \(l - 1\) does not, since \(\bot \) on Fin (l-1) has no edge and no \(l\)-element independent set.
A 2-element independent set is a non-adjacent pair. On \(k\) vertices either some pair is non-adjacent, or every pair is adjacent and all \(k\) form a clique. The complete graph on \(k - 1\) vertices shows \(k\) is needed.
The mirror of ramseyNumber_two_left under ramseyNumber_comm.
! Same sInf \(\emptyset \) = 0 trap as ramseyNumber, and worse: there is no exists_isRamseyBoundMulti anywhere in the file. So every ramseyNumberMulti is provably \(0\) as things stand, which makes ramseyMulti_recursion, ramseyTriangle_* and Schur’s theorem in §7.4 all vacuous.
With \(m = 2\) this should reduce to ramseyNumber, but that bridge is unstated (see EdgeColouring).
\(k_{1} = \dots = k_m = 3\) gives the sequence \(r_{n}\) of exercise 7.2.3, which is what Schur’s theorem consumes in §7.4.
The least number of points such that any \(n\)-colouring of the pairs forces a monochromatic triangle. \(r_{2} = r(3,3) = 6\); Greenwood and Gleason showed \(r_{3} = 17\).
Exactly what Schur’s theorem (§7.4) consumes.
! Inherits ramseyNumberMulti’s missing existence lemma, so ramseyTriangle n is currently provably \(0\) for every \(n\).
Theorem 7.7 with all targets \(3\). Fix \(v\) in a \(K_{n}\) on \(n(r_{n-1}-1) + 2\) vertices; its \(n(r_{n-1}-1) + 1\) neighbours split among \(n\) colours, so some class has \(\ge r_{n-1}\) vertices. Either two of them are joined in that same colour — a monochromatic triangle with \(v\) — or the class avoids that colour and its induced colouring uses only \(n-1\) colours, where \(r_{n-1}\) vertices force a triangle.
Stated additively (\(+ n\) on the left) to avoid \(\mathbb {N}\) subtraction.
Count the edges twice, once from each side. ! \(hk : 0 \lt k\) is essential — a \(0\)-regular graph has no edges and its two parts can have any sizes.
IsBipartiteWith s t is Mathlib’s explicit-bipartition form, stronger than Colorable 2 and what step 1 needs. Set.ncard rather than Finset.card, so no decidability on \(s\), \(t\) is required.
Corollary 5.2 gives a perfect matching \(M\). Deleting its edges lowers every degree by one, leaving a \((k-1)\)-regular bipartite graph; iterate \(k\) times.
In chapter 6’s language this is \(\chi '(G) = \Delta (G)\) for bipartite graphs — König’s edge-colouring theorem. In scheduling terms, a balanced workload always splits into \(k\) conflict-free rounds.
Every degree is even, so Theorem 4.1 gives each component an Euler tour. Traverse it and orient each edge in the direction of travel; every vertex then has in-degree \(k\) and out-degree \(k\), since the tour enters and leaves it \(k\) times. Build the bipartite "tail/head" double cover, joining tail \(u\) to head \(v\) for each oriented edge \(u \to v\). That graph is \(k\)-regular, hence 1-factorable by part (a); translating each perfect matching back gives a spanning subgraph with one in-edge and one out-edge per vertex — a 2-factor.
The classical bridge from Ramsey theory to additive number theory. Schur’s original motivation was Fermat’s Last Theorem mod \(p\).
The book’s motivating example (§7.4, p. 120):
! Note "not necessarily distinct" — so \(x = y\) is allowed, and the Lean statement correctly does not require distinctness.
! hpart says every \(k \in [1, r_{n}]\) lies in exactly one part, and hsub that no part escapes the range — together a genuine partition. But nothing forces the parts nonempty, which is fine (empty parts are harmless).
The exact threshold at which sum-free partitions become impossible.
+ Unlike most sInfs in this chapter, nonemptiness here is supplied by Theorem 7.10 (\(s_{n} \le r_{n}\)) — so schurNumber is well defined as soon as Schur’s theorem is, without a separate existence lemma.
! But that inherits Theorem 7.10’s own vacuity: while ramseyTriangle n = 0, Theorem 7.10 gives nothing and schurNumber falls back to sInf \(\emptyset \) = 0.
Iterate \(s_{n} \ge 3s_{n-1} - 1\) from \(s_{3} = 14\); solving the linear recurrence gives \(s_{n} \ge (27\cdot 3^{n-3} + 1)/2\).
Cleared to \(27\cdot 3^{n-3} + 1 \le 2s_{n}\).
Schur numbers grow at least exponentially with ratio \(3\); the upper bound \(s_{n} \le r_{n} \le \lfloor n!e\rfloor + 1\) grows factorially, and the true rate is unknown.
From a sum-free \((n-1)\)-partition of \({1,\dots ,s_{n-1}-1}\), build an \(n\)-partition of a roughly three-times-longer interval by scaling: keep the old parts tripled, and give the new \(n\)-th part the leftover residues.
Stated additively as \(3s_{n-1} \le s_{n} + 1\).
\(C_{5}\) witnesses that five vertices do not force either structure, so the threshold is \(\ge 6\). Combined with Thm 7.4 this is the exact value: among any six people, three are mutual acquaintances or three mutual strangers.
! Only the lower bound is stated here; the file does not state \(r(3,3) = 6\). Same for \(r(3,5)\) and \(r(4,4)\) below — all three exact values in the book’s worked examples are left unstated.
The two bridges interleave around the cycle. In a plane graph this is fatal for two bridges on the same side: their connecting paths would have to cross, contradicting the Jordan curve theorem — which is exactly the (dropped) proof of theorem 9.8.
The book asks for four distinct vertices; the Lean version requires only \(a \ne b\) and \(a' \ne b'\). The remaining distinctness is implied by the strict cycleIdx chain in InCyclicOrder, since distinct indices force distinct vertices — provided all four lie on c.support, which the attach memberships supply. Rotation-invariance is recovered by the existential over which attachment plays which role, compensating for InCyclicOrder being measured from \(c\)’s base point.
A spanning tree already offers a unique route between the ends of \(e\); adding \(e\) supplies a second, and the two close off precisely one cycle — the fundamental cycle of \(e\) with respect to \(T\). * The engine of the exchange argument for Kruskal’s optimality (theorem 2.10), and of chapter 12’s tree-basis of the cycle space.
! Only the existence half is stated: uniqueness of a cycle in Lean holds only up to rotation and reflection of the walk, which is awkward to phrase directly. Chapter 12’s fundamentalCycle needs the uniqueness half, so this gap propagates there.
Subdivision grows the vertex set by one, so unlike edge deletion it *changes the carrier type*: V \(\oplus \) Unit, with Sum.inr () the new midpoint. Adjacency: inl x ~ inl y iff G.Adj x y and \(s(x, y) \ne e\) — the old edges, minus \(e\); inl x ~ inr _ iff \(x \in e\) — the two new half-edges; inr _ ~ inr _ never — no loop at the midpoint.
Corollary 3.2.2 only, via the book’s remark that *"the class of blocks with at least three vertices is closed under the operation of subdivision"*. That closure property is itself unproved here, which is the main obstacle to block_edges_on_common_cycle.
Keep every vertex, and select edges so each vertex retains exactly \(k\). A \(1\)-factor is precisely a perfect matching; a \(2\)-factor is a spanning union of disjoint cycles.
Degree is written (H.neighborSet v).ncard rather than H.degree v — equal in value, but avoiding the Fintype/DecidableRel instance juggling that Subgraph.degree would drag in on every use.
Mathlib supplies "matching" (Subgraph.IsMatching), "saturates" (v \(\in \) M.verts) and "perfect" (Subgraph.IsPerfectMatching), but has no matching-number notion, so maximality has to be said by hand:
M.IsMatching \(\land \) \(\forall \) M’, M’.IsMatching \(\to \) M’.edgeSet.ncard \(\le \) M.edgeSet.ncard
This is a global maximum, not a maximal matching (one admitting no extension). The two genuinely differ, and Berge’s Theorem 5.1 is exactly the tool that certifies the global property from a local check.
The component forces \(u\) and \(v\) to agree. The quantifier is universal — not that some colouring identifies them, but that no colouring can separate them. This is only interesting because \(u\) and \(v\) are nonadjacent in a critical graph (the consequence of theorem 8.2 recorded below), so a priori a colouring is free to do either.
Stated for a G.Subgraph \(H\) with explicit membership proofs \(hu\), \(hv\), since H.coe lives on H.verts and \(u\), \(v\) must be named as elements of it. Fin (k - 1) uses \(\mathbb {N}\)-subtraction; every use site has \(k \ge 2\), so no truncation occurs.
The component forces \(u\) and \(v\) to disagree. A type-1 component and a type-2 component make irreconcilable demands, so their union admits no \((k-1)\)-colouring at all — which is exactly the contradiction driving theorem 8.3, and the reason a critical graph with a 2-vertex cut has precisely two pieces, one of each type.
As for IsType1. Note that "type 1" and "type 2" are not exhaustive: a component may admit both kinds of \((k-1)\)-colouring and be of neither type. Theorem 8.3 has to prove that the two pieces it produces are of opposite types; it is not true by definition.
Every edge of \(H\) is an edge of \(G\), so the very same bipartition still has every edge crossing: deleting vertices and edges can never create an edge inside a part.
Stated for \(H \le G\) on the same carrier, which is the spanning-subgraph case. B&M’s "subgraph" also allows dropping vertices; that case is induce_bipartite and the two together are subgraph_induce_bipartite, both below.
This is the exercise as the book states it; subgraph_bipartite (edges only) and induce_bipartite (vertices only) are the two halves, and either alone is what a Lean transcription tends to produce. ! Nothing in the proof uses \(2\) specifically; the identical two lines give the Colorable k statement for any \(k\), should a general version be wanted.
The successors of a bridge’s attachment points form an *independent set*. That is exactly the leverage Chvátal–Erdős needs: a bridge with many attachments yields a large independent set, which \(\alpha \le \kappa \) forbids.
Indices are into the walk (c.getVert i), so \(i + 1\) is the successor along \(c\); the wraparound at the end of the support is handled by getVert saturating, which is why step 3 must be phrased as two explicit arcs rather than as index arithmetic mod \(n\).
Adding up the degrees counts each edge twice, once from each end. The name comes from the reading: if each edge is a handshake, the total hands shaken is twice the number of handshakes. Loops are consistent, contributing \(2\) to their single end.
\(D\) is the degeneracy of \(G\). Strip off a vertex of degree at most \(D\), repeatedly, recording the order; then colour the vertices back in reverse order — when a vertex is restored it has at most \(D\) neighbours already present, so one of \(D + 1\) colours is free. This refines \(\chi \le \Delta + 1\) (corollary 8.1.2), since \(D \le \Delta \) always and often \(D\) is far smaller: a tree has \(D = 1\), giving \(\chi \le 2\) no matter how large \(\Delta \) is.
"Induced subgraph" is indexed by Finset V (a vertex subset) rather than by a Subgraph, since the book’s maximum is over induced subgraphs only. The sup includes \(s = \emptyset \), whose minDegree is \(0\) by Mathlib’s convention; this can only make \(D\) larger and so weakens the bound harmlessly. Note the induction in step 2 is the formal content of "repeatedly strip off" — as usual, the informal repetition becomes an induction on the size of what remains.
In \(K_{n}\) every pair of distinct vertices is adjacent, so any enumeration \(v_{1} v_{2} \dots v_n v_{1}\) is already a Hamilton cycle. Three vertices are needed because a cycle must have length at least three — \(K_{1}\) and \(K_{2}\) have no cycle at all.
! Despite the book calling it "trivial", Mathlib has no such lemma, and it is not trivial in Lean: it requires exhibiting a concrete cyclic enumeration of \(V\) and proving the resulting walk is a cycle whose support is nodup and spans.
\(\nu - 1\) edges is exactly the price of connecting \(\nu \) vertices acyclically — corollary 2.4.2 shows it is also the minimum price of connecting them at all.
Stated additively as \(\varepsilon + 1 = \nu \) to avoid truncated \(\mathbb {N}\)-subtraction.
(absent from Mathlib). If \(\delta (G) \ge m - 1\) then every tree \(T\) on \(m\) vertices embeds in \(G\).*
Build the embedding greedily. A tree on \(m\) vertices can be listed so each new vertex attaches to exactly one already-placed vertex (peel leaves). Placing the \(j\)-th, its unique placed neighbour has \(\ge m - 1\) neighbours in \(G\), of which at most \(j - 1 \le m - 2\) are used — a fresh image always exists.
The standard "minimum degree forces every small tree" lemma; it is what makes tree-target Ramsey numbers exactly computable.
! \(m\) is a free variable in the signature, tied to \(W\) only through hm : Fintype.card W = m — so \(m\) is determined but Lean will not infer it; callers must supply it.
A degree-one vertex of a tree is a leaf. ! B&M offer a more illuminating alternative (exercise 2.1.2): take a longest path; both endpoints have degree one, since an extra neighbour would either extend the path or close a cycle. That route would be shorter in Lean too, if exists_path_length_of_minDegree-style machinery from chapter 1 were available.
A tree has exactly enough edges to hold the vertices together and not one more: connectivity gives at least one route between any two vertices, acyclicity forbids a second, since two distinct routes always enclose a cycle. ! The converse holds for loopless graphs (exercise 2.1.1), so "unique paths between all pairs" is an equivalent definition of a tree — that direction is not stated here.
Turán at \(m = 2\) — Mantel’s 1907 case, half a century before the generalisation. Extremal example: balanced \(K_{\lfloor \nu /2\rfloor ,\lceil \nu /2\rceil }\) with \(\lfloor \nu ^{2}/4\rfloor \) edges.
Cleared to \(\nu ^{2} \lt 4\varepsilon \) to avoid division.
Forbidding bipartiteness on top of triangle-freeness drops the cap from \(\nu ^{2}/4\) to \((\nu -1)^{2}/4 + 1\). A triangle-free non-bipartite graph contains an odd cycle of length \(\ge 5\), which is an inefficient use of vertices; the densest such graph is essentially \(C_{5}\) blown up.
The stability phenomenon of extremal graph theory: near-extremal graphs all resemble the extremal one, so departing from it costs edges.
Cleared to \((\nu -1)^{2} + 4 \lt 4\varepsilon \).
(Whitney, 1932).
(\(\Rightarrow \)) is discharged by forgetting the extra edge-disjointness conjunct supplied by the strengthened form.
(\(\Leftarrow \)) unpacks the book’s "clearly". Two steps: \(G\) is connected — the hypothesis hands back a path between any two distinct vertices, and Reachable.refl covers \(a = b\); \(G\) has no cut vertex — if \(w\) were one, \(G - w\) would be disconnected, giving \(a, b\) unreachable in \(G - w\). Both supplied paths \(p, q\) must then pass through \(w\) (else reachable_induce_of_support_subset would transport them into \(G - w\)). So \(w\) is a common internal vertex of \(p\) and \(q\), and InternallyDisjoint forces \(w = a\) or \(w = b\) — contradicting that \(a, b\) live in \({w}^{c}\). Then two_le_vertexConnectivity_of_no_cutVertex converts "no cut vertex" into \(\kappa \ge 2\), which is where \(\nu \ge 3\) is consumed.
Travel out along one path and back along the other; because the two paths meet only at the endpoints, the round trip repeats no vertex, so it is a cycle.
! The book’s "immediately" does not transfer directly. As noted on InternallyDisjoint, this file’s predicate permits \(p = q\), so two_connected_iff_two_internally_disjoint_paths alone would let both paths be the same single edge and p.append q.reverse would not be a cycle. The proof must therefore go through the strengthened exists_two_internally_disjoint_paths_of_two_connected, whose extra p.edges.Disjoint q.edges rules that degenerate case out.
2-edge-connected \(\iff \) two edge-disjoint paths between any two vertices.
The edge analogue of Whitney’s Theorem 3.2, with "internally disjoint" weakened to "edge-disjoint" and vertex cuts replaced by edge cuts.
Edge-disjoint is genuinely weaker than internally disjoint: the two routes may pass through common intermediate stations, as long as they never use the same link.
A minimum vertex cut cannot have size \(0\) — that would make \(G\) disconnected, contradicting hconn — nor size \(1\), since that would exhibit a cut vertex, contradicting hnocut. And if no vertex cut exists at all then \(\kappa = \nu - 1 \ge 3 - 1 = 2\).
Stated as \(2\beta \le \varepsilon + 1\) to avoid division.
A minimum covering touches every edge, and in a connected graph the edges are linked tightly enough that each covering vertex can be charged at least two edges, with one left over for a spanning tree’s root.
! Note the book states this under 7.1.3, whose preamble defines \(\beta \)-critical — but part (b) does not assume \(\beta \)-criticality, only connectivity, and the Lean signature correctly reflects that. (The docstring previously implied the \(\beta \)-critical hypothesis carried over; it does not.)
Connectivity is essential: a disjoint union of \(k\) edges has \(\beta = k = \varepsilon \), which violates the bound for \(k \ge 2\).
Erase every edge except those coloured \(i\) or \(j\): fromEdgeSet {e | \(\exists \) h : e \(\in \) G.edgeSet, C ⟨e,h⟩ = i \(\lor \) C ⟨e,h⟩ = j}.
If the colouring is proper this leaves maximum degree \(2\) — a disjoint union of paths and cycles alternating between the two colours. Recolouring inside such a component is the fundamental move of the chapter; Lemma 6.1.2 says the only components resisting improvement in an optimal colouring are odd cycles.
! The book’s \(G[\cdot ]\) is edge-induced, so isolated vertices are irrelevant to it. Mathlib’s fromEdgeSet keeps the full vertex type \(V\), so the resulting graph has isolated vertices wherever neither colour appears. This matters when speaking of "the component containing \(u\)": in the Lean rendering that component is a single vertex when \(u\) meets neither colour, whereas the book’s \(G[E_{i} \cup E_{j}]\) would not contain \(u\) at all.
Colours are arbitrary labels, so what a colouring really determines is the partition into colour classes. \(G\) is uniquely \(k\)-colourable when that partition is forced — two \(k\)-colourings can then differ only by renaming the colours. Complete graphs are the obvious examples, which is why exercise 8.1.8 (no vertex cut of a \(k\)-critical graph induces a uniquely \((k-1)\)-colourable subgraph) generalises theorem 8.2 (no vertex cut is a clique).
Coloring.colorClasses is the induced partition, so the book’s "induce the same partition" is a literal equality of colorClasses. Note this is vacuously true when \(G\) has no \(k\)-colouring at all; every use site supplies colourability separately.
Join \(i, j\) when dist (x i) (x j) = 1. Carrier EuclideanSpace \(\mathbb {R}\) (Fin 2).
The geometry enters as a forbidden subgraph: two points have at most two common unit-distance neighbours (two unit circles meet in \(\le \) 2 points), so the graph has no \(K_{2,3}\), and 7.3.4(b) bounds \(\varepsilon \).
+ Fully defined, symm and loopless both discharged — no sorry.
! The \(i \ne j\) conjunct in Adj is doing real work: without it, dist (x i) (x i) = 0 \(\ne \) 1 would still exclude loops, but only if the \(x i\) are distinct points. Since \(x\) is not assumed injective, two indices may carry the same point, and \(i \ne j\) is what keeps the graph simple in that case.
Cut the graph at \(S\) and put \(S\) back onto each resulting piece, so the pieces overlap in exactly \(S\). A colouring of \(G\) is then the same thing as a family of colourings of the \(S\)-components that agree on \(S\) — that equivalence is the entire mechanism behind theorems 8.2 and 8.3, both of which proceed by colouring the pieces separately and then trying to reconcile them on \(S\).
Only the case \(S = {u, v}\) is needed (theorem 8.3), so the definition is specialised to it and indexed by a connected component \(c\) of \(G - {u,v}\) rather than by a numeral \(i\). The result is a G.Subgraph, which is what lets theorem 8.3(i) state \(G = G_{1} \cup G_{2}\) as a \(\sqcup \) in the subgraph lattice.
a simple 3-regular graph has \(\kappa = \kappa '\).
Theorem 3.1 gives \(\kappa \le \kappa ' \le \delta = 3\), so both parameters lie in \({0, 1, 2, 3}\) and only \(\kappa ' \le \kappa \) needs argument. Given a minimum vertex cut \(S\) of size \(\kappa \), one converts it into an edge cut of the same size by choosing, for each \(v \in S\), a single suitable incident edge — possible precisely because every vertex of a cubic graph has just three neighbours, so the local structure around a cut vertex is tightly constrained.
Cubic graphs are the smallest interesting regular case, and this exercise records that for them the vertex and edge measures of reliability agree — unlike the general situation, where figure 3.2 has \(\kappa = 2 \lt \kappa ' = 3\).
The book’s case split is on "\(G\) has a pair of distinct nonadjacent vertices"; the Lean split is on the equivalent "\(G\) has a vertex cut at all", which is the condition the two branches actually need. So some cut exists \(\Rightarrow \) \(\kappa \) = sInf {S.card | G.IsVertexCut S}; no cut exists (the complete graphs) \(\Rightarrow \) \(\kappa = \nu - 1\).
sInf on \(\mathbb {N}\) is Mathlib’s Nat.sInf, with sInf \(\emptyset \) = 0; the \(if\) guard means that fallback is never reached here. Natural subtraction makes \(\nu - 1 = 0\) when \(V\) is empty, matching "trivial \(\Rightarrow \) \(\kappa = 0\)".
a simple graph with \(\delta \ge \nu - 2\) has \(\kappa = \delta \).
The hypothesis says every vertex is non-adjacent to at most one other vertex, so the graph is complete or very nearly so. Theorem 3.1 already gives \(\kappa \le \delta \), so only \(\kappa \ge \delta \) needs proving: any set of fewer than \(\delta \) vertices fails to disconnect such a dense graph, because any two surviving vertices are either adjacent outright or share a common surviving neighbour.
Part (b) shows the bound is tight — one step less density (\(\delta = \nu - 3\)) already allows \(\kappa \lt \delta \).
The book’s one-liner has to be unwound through Nat.sInf_eq_zero, which splits \(\kappa ' = 0\) into two cases rather than one: \(0\) is attained — \(\emptyset \) is an edge cut, i.e. \(G\) is disconnected outright; or the set being minimised is empty* — no edge cut exists at all, which forces \(V\) to be a subsingleton, since otherwise deleting every edge leaves \(\bot \), and \(\bot \) on a nontrivial \(V\) is disconnected.
These are exactly the book’s "disconnected" and "trivial". Disconnected gives \(\emptyset \) as a vertex cut, so \(\kappa = 0\); subsingleton gives \(\kappa = \nu - 1 = 0\).
A vertex cut is by definition a proper subset of \(V\), so it omits some vertex and therefore has at most \(\nu - 1\) elements; and in the no-vertex-cut case \(\kappa \) is defined to be \(\nu - 1\). Either way \(\kappa \le \nu - 1\).
This is the heart of the induction, isolated as a standalone inequality \(\kappa (G) \le \kappa (G - e) + 1\) so that vertexConnectivity_le_edgeConnectivity becomes a three-line calc. Writing \(H = G - e\), the book’s case analysis is: \(H\) has a complete spanning subgraph \(\Rightarrow \) so does \(G\), and \(\kappa (G) = \kappa (H)\); otherwise take \(S\) a vertex cut of \(H\) with \(|S| = \kappa (H)\), and split: \(G - S\) already disconnected \(\Rightarrow \) \(S\) is a vertex cut of \(G\), so \(\kappa (G) \le |S|\); \(G - S\) connected \(\Rightarrow \) \(e\) is a cut edge (bridge) of \(G - S\), and then \(\nu (G - S) = 2\) \(\Rightarrow \) \(\kappa (G) \le \nu (G) - 1 = |S| + 1\), by vertexConnectivity_le_card_pred; \(\nu (G - S) \ge 3\) \(\Rightarrow \) by Exercise 2.3.1(a) \(G - S\) has a cut vertex \(w\), and \(S \cup {w}\) is a vertex cut of \(G\), so \(\kappa (G) \le |S| + 1\).
Every branch lands at \(\kappa (G) \le \kappa (H) + 1\), which is the statement.
, first inequality: \(\kappa \le \kappa '\).
Induction on \(\kappa '\). Base \(\kappa ' = 0\): \(G\) is trivial or disconnected, so \(\kappa = 0\). Step: given \(\kappa '(G) = k + 1\), pick \(e\) in a minimum edge cut; then \(\kappa '(G - e) = k\), so \(\kappa (G - e) \le k\) by the induction hypothesis, and \(\kappa (G) \le \kappa (G - e) + 1 \le k + 1 = \kappa '(G)\).
The entire four-way case analysis of the book’s second paragraph has been factored out into vertexConnectivity_le_deleteEdge_succ, so what remains here is exactly the induction skeleton.
By (6.1) \(\chi ' \ge \Delta \) always, so the content is that one spare colour suffices — a tight dichotomy in which no simple graph needs \(\Delta + 2\).
The disjunction is stated with the two branches at different types ((G.maxDegree : \(\mathbb {N}\infty \)) and (G.maxDegree + 1 : \(\mathbb {N}\)) coerced), which is harmless but worth matching carefully when proving.
Stand at \(a\) and walk forwards around the cycle; this counts the steps until \(x\) is reached. Unlike cycleIdx — which is measured from \(c\)’s own base point and so is merely linear — this is genuinely cyclic: it is what lets an arc "wrap round" past the base point.
! Guard uses by a, x \(\in \) c.support. cycleIdx returns c.support.length for an absent vertex, which here yields a meaningless distance. For \(a\) on the cycle the \(\mathbb {N}\)-subtraction never truncates: cycleIdx a \(\le \) c.length (the base point occurs first at index \(0\)), so cycleIdx x + c.length \(\ge \) cycleIdx a. The % c.length is what performs the wraparound; for a degenerate \(c\) of length \(0\) it is the identity (\(n \% 0 = n\) in Lean), which is harmless since every use site carries hc : c.IsCycle.
Walking around the cycle from its base point, this records how many steps it takes to reach \(x\). Comparing indices is how "cyclic order" is expressed here.
! Mathlib’s CircularOrder/Btw/SBtw are order classes on a type and do not apply to the support list of a particular cycle, so they are no help. ! List.idxOf silently returns the list’s length for an absent element, so every use must be guarded by x \(\in \) c.support — unguarded, all missing vertices quietly share one position past the end. Note also that this is genuinely linear, not cyclic: it is measured from \(c\)’s base point, so InCyclicOrder below expresses a cyclic condition only up to the choice of that base point.
Travelling once round the cycle, the four vertices are met in that order. This is the configuration making two bridges skew: each bridge’s two attachments separate the other’s, so drawn inside the same region their connecting paths would have to cross — which is precisely the Jordan-curve contradiction in theorem 9.8.
Rendered as a chain of strict cycleIdx inequalities, i.e. as a linear order from \(c\)’s base point rather than a genuinely cyclic one. This is weaker than the book’s phrase: the book’s "cyclic order \(u, u', v, v'\)" is invariant under rotation, whereas this version distinguishes rotations. It suffices for Skew, which existentially quantifies over which attachment plays which role and so recovers rotation-invariance, but do not reuse InCyclicOrder where genuine rotation-invariance is needed.
The walk may start and end on \(H\), but between those endpoints it must stay entirely outside \(H\). This is what makes the bridge relation an equivalence, and it is why a bridge is a maximal chunk of the graph hanging off \(H\) and touching it only at its attachment points.
p.support.tail.dropLast is the walk’s interior — drop the first vertex (tail) and the last (dropLast). ! This is not the repo’s InternallyDisjoint (TwoConnected.lean:58), which relates a walk to another walk; here the second argument is a Subgraph. A walk of length \(\le 1\) has empty interior and so is vacuously internally disjoint from everything — which is intended, and is what makes bridgeRel reflexive on single edges.
Walk along the graph using a matching edge, then a non-matching edge, then a matching edge, and so on. Rendered as a chain condition on consecutive edges:
List.IsChain (fun e f => e \(\in \) M.edgeSet \(\leftrightarrow \) f \(\notin \) M.edgeSet) p.edges
! Mathlib’s SimpleGraph.IsAlternating (Matching.lean) is a graph-level relation between two graphs and is not this notion; do not reach for it.
Note the definition is on a Walk, not a Path — the book’s "path" is imposed separately in IsAugmenting below via p.IsPath.
Alternating paths are the mechanism by which a matching improves: swapping which edges along such a path belong to \(M\) keeps \(M\) a matching.
An alternating path both of whose endpoints are still unmatched. Such a path has odd length and begins and ends with non-matching edges, so it holds one more non-\(M\) edge than \(M\) edge. Flipping the roles along it — discarding its \(M\)-edges, adopting its non-\(M\)-edges — yields a matching one edge larger, which is why it is called augmenting.
! The conjunct \(u \ne v\) is load-bearing and has no counterpart in the book’s wording. Without it Walk.nil at an \(M\)-unsaturated vertex would satisfy every other clause vacuously, so every non-perfect matching would admit an "augmenting path" and Berge’s theorem would be false in the (\(\Leftarrow \)) direction. The book gets this for free because a path in its sense has at least one edge.
A cycle no shorter than any other cycle of \(G\). This is the standard extremal device: assume the longest cycle is not a Hamilton cycle, then derive a contradiction from the structure of the bridges hanging off it. That is exactly how Chvátal–Erdős is proved below.
! Not girth/egirth, which are the shortest cycle — the opposite extremum. The maximality clause quantifies over cycles at every base point \(w\), not just at \(u\), which is what makes it a genuine global maximum. Note the definition does not assert existence: IsLongestCycle is a hypothesis to be supplied, and producing one requires knowing \(G\) has a cycle at all.
Walking forwards from \(a\), you meet \(x\) no later than \(b\). Both endpoints count as being on the arc, matching the book’s segments, which share their endpoints with the neighbouring segments and so are edge-disjoint but not vertex-disjoint.
Stated via cycleDist, so the wraparound is handled: the arc from \(a\) to \(b\) may pass through \(c\)’s base point. The x \(\in \) c.support conjunct is the guard that keeps vertices off the cycle out, since cycleDist would otherwise give them a spurious finite distance.
Colour greedily in order of decreasing degree. When the \(i\)-th vertex’s turn comes, two things bound the colours forbidden to it: it has \(d_{i}\) neighbours, so at most \(d_{i}\) colours are blocked; and only \(i - 1\) vertices are coloured so far, so at most \(i - 1\) colours exist. Hence min{d\(_{i}\) + 1, i} colours suffice at step \(i\), and the worst case over \(i\) bounds \(\chi \). This genuinely improves \(\chi \le \Delta + 1\) (corollary 8.1.2): high-degree vertices are handled while few colours exist, low-degree ones later when the count \(i\) no longer binds. Exercise 8.1.4 derives two further bounds from it.
The sorted degree sequence is presented as an equivalence \(\sigma \) : Fin (card V) \(\simeq \) V together with \(h\sigma \), which says i \(\mapsto \) deg (\(\sigma \) i) is antitone — i.e. \(\sigma \) enumerates the vertices in nonincreasing degree order, so G.degree (\(\sigma \) i) is the book’s \(d_{i}\). \(i + 1\) rather than \(i\) because Fin is 0-indexed and the book is 1-indexed.
Worth knowing while filling: \(h\sigma \) is not needed for the proof, only for the statement. Steps 1–4 bound \(\chi \) by that sup for any enumeration \(\sigma \); what \(h\sigma \) buys is that the sup is then the book’s max\(_{i}\) min{d\(_{i}\) + 1, i} for the sorted sequence, which is the small quantity worth having. So do not go looking for a place to use \(h\sigma \) — there isn’t one.
A hub joined to every vertex of a rim cycle. As a join \(C_n \lor K_{1}\) it inherits \(\chi = \chi (C_n) + 1\) from exercise 8.1.10(a), so a wheel with an odd rim is 4-chromatic and one with an even rim is 3-chromatic. Exercise 8.4.5(b) computes its chromatic polynomial.
"\(n\) spokes" means \(n\) rim vertices, so the rim is cycleGraph n and the hub is the unique vertex of \(\top \) : SimpleGraph Unit. Since join adds all cross edges and the hub side is a single vertex, the added edges are exactly the \(n\) spokes.
(Whitney). The full chain \(\kappa \le \kappa ' \le \delta \).
The conjunction of the two halves proved just above, packaged as the book states it. See vertexConnectivity_le_edgeConnectivity for the \(\kappa \le \kappa '\) proof and edgeConnectivity_le_minDegree for \(\kappa ' \le \delta \).
For a subset \(S \subseteq \mathrm{Fin}\, n\), a point \(x \in \{ 0,1\} ^n\), and a bit \(b\), the parity character of the lifted set equals the character of \(S\) on \(x\):
That is, appending a last coordinate \(b\) and not including it in the set leaves the character unchanged.
For \(S \subseteq \mathrm{Fin}\, n\), a point \(x\), and a bit \(b\), adjoining the last coordinate to the lifted set multiplies the character by the sign of \(b\):
where \((-1)^b\) denotes boolToSign \(b\).
For any \(\varphi \) on subsets of \(\mathrm{Fin}(n+1)\), the total sum splits according to whether the last coordinate belongs to the subset:
For \(f : \{ 0,1\} ^{n+1} \to \mathbb {R}\), writing \(g = \mathrm{avgLast}\, f\) and \(h = \mathrm{diffLast}\, f\), the fourth moment of \(T_\rho f\) decomposes as
For any Boolean function \(f : \{ 0,1\} ^n \to \mathbb {R}\), integer \(k \ge 1\), and noise parameter \(\rho \) with \(\rho ^2 \le 1/(2k-1)\),
equivalently \(\lVert T_\rho f\rVert _{2k} \le \lVert f\rVert _2\).
For \(k \ge 1\) and noise parameter \(\rho \) with \(\rho ^2 \le 1/(2k-1)\), the \((2,2k)\) bound in the form \(\lVert T_\rho f\rVert _{2k} \le \lVert f\rVert _2\):
For any Boolean function \(f : \{ 0,1\} ^n \to \mathbb {R}\) and noise parameter \(\rho \) with \(\rho ^2 \le 1/3\) (equivalently \(\left\lvert \rho \right\rvert \le 1/\sqrt3\)),
that is \(\lVert T_\rho f\rVert _4 \le \lVert f\rVert _2\).
For an even integer \(q \ge 2\) and noise parameter \(\rho \) with \(\rho ^2 \le 1/(q-1)\),
This is the \((2,2k)\) theorem restated in terms of an even exponent \(q = 2k\).
Boolean functions are \((4/3, 2)\)-hypercontractive with parameter \(1/\sqrt3\): for any \(f : \{ 0,1\} ^n \to \mathbb {R}\),
Let \(a, b, A, B, C, \rho \) be reals with \(a \ge 0\), \(b \ge 0\), \(B \ge 0\), and suppose \(A \le a^2\), \(B \le b^2\), \(C^2 \le AB\), and \(\rho ^2 \le 1/3\). Then
This is the algebraic step that makes the induction in the \((2,4)\)-hypercontractivity argument close.
Let \(1 \lt p\), \(q \ge 2\) with \(1/p + 1/q = 1\). Given a Hölder inequality for the pair \((p,q)\) and a \((2,q)\)-hypercontractivity bound for \(T_\rho \), one concludes the dual \((p,2)\) bound:
For \(f : \{ 0,1\} ^{n+1} \to \mathbb {R}\), writing \(g = T_\rho (\mathrm{avgLast}\, f)\) and \(h = T_\rho (\mathrm{diffLast}\, f)\), the \(q\)-th moment of \(T_\rho f\) decomposes as
For \(f : \{ 0,1\} ^{n+1} \to \mathbb {R}\) the noise operator splits over the last coordinate:
where \(\mathrm{avgLast}\, f\) and \(\mathrm{diffLast}\, f\) are the average and difference of \(f\) over the last bit.
For \(f : \{ 0,1\} ^{n+1} \to \mathbb {R}\), writing \(g = \mathrm{avgLast}\, f\) and \(h = \mathrm{diffLast}\, f\), the \(q\)-th moment decomposes as
Let \(0 \lt \tau \lt 1/2\) and let \(t_n\) satisfy \(t_n / n \to \tau \). Then there is a sequence \(a_n\) such that, eventually in \(n\), \(a_n\) lies strictly below every real zero of \(K_{t_n}^{(n)}\), with \(a_n/n \to \tfrac 12 - \sqrt{\tau (1-\tau )}\), and such that eventually \(\Phi _{n,t_n}(a_n,x) \le 0\) for all integers \(x\) with \(\lfloor (\tfrac 12 - \sqrt{\tau (1-\tau )})n \rfloor \le x \le n\).
For reals \(\mathrm{val}_{f_{L,R}}\), \(N\), \(D\) and \(\lVert A\rVert \) with \(D \gt 0\) and \(N \gt 0\), if
then the same bound holds. Here \(N = \binom {2n}{\ell }\), \(D = 2\binom {2n-4}{\ell -2}\), and \(\lVert A\rVert \) is the spectral norm of the Kikuchi matrix \(A\), so the statement records the certificate \(\mathrm{val}(f_{L,R}) \le (N/D)\, \lVert A\rVert \).
For naturals \(k, d, \ell \gt 0\) and \(n \ge 2\) there exists a real constant \(C_1 \gt 0\) such that
The displayed quantity is the matrix-Khintchine bound \(\mathbb {E}_b[\lVert A\rVert ] \le C_1\, d\, \sqrt{k\, \ell \, \log n}\) appearing in the argument, and the statement asserts that such a positive constant, with positive associated bound, exists.
The weight function on the augmented universe \(U \oplus \mathrm{Bool}\) built from a Subset Sum instance \((w, T)\). Writing \(W = \sum _{a} w(a)\), it sends the original item \(\mathrm{inl}\, a\) to \(w(a)\), the first dummy item \(\mathrm{inr}\, \mathsf{true}\) to \(2W - T\), and the second dummy item \(\mathrm{inr}\, \mathsf{false}\) to \(W + T\).
Let \(w : U \to \mathbb {N}\) and \(T \in \mathbb {N}\) satisfy \(T \le \sum _{a} w(a)\). If the Subset Sum instance \((w, T)\) has a solution, then the Partition instance with weight function \(\texttt{SubsetSumToPartition.partitionWeight}\ w\ T\) on \(U \oplus \mathrm{Bool}\) has a solution.
For \(w : U \to \mathbb {N}\) and \(T \in \mathbb {N}\) with \(T \le \sum _{a} w(a)\), the Subset Sum instance \((w, T)\) is solvable if and only if the Partition instance with weight function \(\texttt{SubsetSumToPartition.partitionWeight}\ w\ T\) on \(U \oplus \mathrm{Bool}\) is solvable.
Let \(w : U \to \mathbb {N}\) and \(T \in \mathbb {N}\) satisfy \(T \le \sum _{a} w(a)\). If the Partition instance with weight function \(\texttt{SubsetSumToPartition.partitionWeight}\ w\ T\) on \(U \oplus \mathrm{Bool}\) has a solution, then the original Subset Sum instance \((w, T)\) has a solution.
The directed handshaking lemma. Every arc has exactly one head, so summing indegrees counts each arc once; likewise every arc has one tail. Contrast the undirected version (theorem 1.1), where the sum of degrees is \(2\varepsilon \): there each edge is counted twice, once from each end, whereas here the head-count and tail-count are kept separate and each totals \(\varepsilon \).
Stated as a conjunction because the book states both equalities at once; nothing forces them to share a proof, but step 4 notes they should.
Let \(Y_j : \Omega \to \mathbb {R}\) be i.i.d. with law \(N(0,\sigma _0)\), and let \(x : \iota \to \mathbb {R}\) be a fixed coefficient vector. For any finite set \(s\),
The proof proceeds by induction on the finset \(s\), using independence and map_const_mul_gaussian at each step.
For a function \(f\) and parameters \(d, k\), the number of size-\(k\) restrictions \(\rho \) with \(\mathrm{dtDepth}(f|_\rho ) \gt d\) equals the number of restrictions that are \(k\)-restrictions and are bad for \(f\) at depth \(d\) in the counting switching-lemma sense.
The same statement for a width-\(w\) CNF \(f\): under a Bernoulli\((p)\) restriction with \(0 \lt p \le 1/(40w)\) and \(p \le 1\),
obtained from the DNF version via the dual-DNF representation of \(f\).
Let \(f\) be a width-\(w\) DNF (\(0 \lt w\)) with no repeated variables per term, and \(0 \lt n\). For a Bernoulli\((p)\) random restriction with \(0 \lt p \le 1/(40w)\) and \(p \le 1\), and for every \(t\),
The \((1/2)^t\) term comes from the switching lemma via the Bernoulli cost reduction, and \(e^{-np/3}\) is the Chernoff tail for leaving too many free variables.
For a width-\(w\) DNF \(f\) with \(0 \lt w\), \(0 \lt n\), and \(k \le n\), the size-\(k\) restriction probability that \(\mathrm{dtDepth}(f|_\rho ) \gt d\) is at most \(\left(10kw/n\right)^d\). This removes the \(5k \le n\) restriction by using the trivial bound when \(5k \gt n\).
For a width-\(w\) DNF \(f\) with no repeated variables per term, \(0 \lt n\), and \(5k \le n\), the probability over uniform size-\(k\) restrictions that the restricted function has decision-tree depth exceeding \(d\) is at most \(\left(10kw/n\right)^d\).
For \(d \leq s\), the number of bad \(s\)-restrictions is at most \(\binom {n}{s-d}\, 2^{\, n-(s-d)}\, (4w)^d\): every bad \(s\)-restriction is mapped by \(\mathrm{razborovEncode}\) to a \(\gamma \) with exactly \(s-d\) free variables, each fiber of this map has size at most \((4w)^d\), and there are \(\binom {n}{s-d}\, 2^{\, n-(s-d)}\) possible values of \(\gamma \).
For a parameter \(p\) and a (decidable) predicate \(\mathrm{event}\) on restrictions, the probability that the predicate holds under a Bernoulli(\(p\)) random restriction is the sum over all restrictions \(\rho \) of \(\mathrm{bernoulliRestrWeight}(p,\rho )\) weighted by the indicator of \(\mathrm{event}(\rho )\).
For a parameter \(p \in \mathbb {R}\) and a restriction \(\rho \) on \(n\) variables, the Bernoulli weight is
so each free variable contributes a factor \(p\) and each fixed variable a factor \((1-p)/2\).
The canonical decision tree for \(f|_\rho \), following Razborov’s construction. It is defined through a fuel-driven helper \(\mathrm{canonicalDTree.go}\) initialized with fuel \(\rho .\mathrm{numFree} + \text{(positive)}\), repeatedly selecting the first non-killed term and expanding its free variables.
When not all terms are killed and none is fixed, and \(t\) is the first non-killed clause, \(\mathrm{canonicalDTree.go}\, f\, (\mathit{fuel}+1)\, \rho \) unfolds to \(\mathrm{termSubTree}\, t\, \rho \, \mathrm{cont}\), where \(\mathrm{cont}\, \rho '\) is \(\mathrm{leaf}\ \mathrm{true}\) if \(t\) is fixed by \(\rho '\) and otherwise \(\mathrm{canonicalDTree.go}\, f\, \mathit{fuel}\, \rho '\).
The top-level analogue of the previous lemma for \(\mathrm{canonicalDTree}\) itself: under the alive-branch hypotheses with first non-killed clause \(t\), \(\mathrm{canonicalDTree}\, f\, \rho \) equals \(\mathrm{termSubTree}\, t\, \rho \, \mathrm{cont}\) with the same fixed-or-recurse continuation running at fuel \(\rho .\mathrm{numFree}\).
When \(f.\mathrm{find?}\) returns an alive clause \(t\) and \(\mathrm{flis}\) is the filtered (zipIdx) list of \(t\)’s free literals under \(\rho \), the variable at position \(k\) of \((\mathrm{canonicalDTree}\, f\, \rho ).\mathrm{deepPath}\) equals the variable of the \(k\)-th free literal, since the canonical tree branches on the free literals of \(t\) in clause order.
The depth of the canonical decision tree for \(f|_\rho \) is at least the decision-tree depth of the restricted function: \((\mathrm{canonicalDTree}\, f\, \rho ).\mathrm{depth} \ge \mathrm{dtDepth}\, (\mathrm{restrictFn}\, (f.\mathrm{eval})\, \rho )\).
Provided the fuel exceeds \(\rho .\mathrm{numFree}\), the tree \(\mathrm{canonicalDTree.go}\, f\, \mathit{fuel}\, \rho \) computes the restricted function: for all \(x\), its evaluation equals \(\mathrm{restrictFn}\, (f.\mathrm{eval})\, \rho \, x\).
Once the fuel exceeds \(\rho .\mathrm{numFree}\), the resulting tree does not depend on the exact fuel: for any \(\mathit{fuel}_1, \mathit{fuel}_2 \gt \rho .\mathrm{numFree}\), \(\mathrm{canonicalDTree.go}\, f\, \mathit{fuel}_1\, \rho = \mathrm{canonicalDTree.go}\, f\, \mathit{fuel}_2\, \rho \).
When the literals are the free literals of the first alive clause and the input path is canonical, \(\mathrm{IsCanonicalPath}\) is preserved by \(\mathrm{processClauseLits}\): the remaining path is again a canonical path for the updated restriction, and its length is at most the depth of the updated canonical tree.
For natural numbers \(n, s, d\) with \(5s \leq n\) and \(d \leq s\),
This is the purely combinatorial inequality used to convert the bad-restriction count into the final \((10\, s\, w)^d\) form of the switching lemma.
For \(t \in f\) and a restriction \(\rho '\) with \(\rho _{\mathrm{orig}}.\mathrm{numFree} \ge \rho '.\mathrm{numFree} + 1\), the standard continuation \(\bigl(\text{if } t \text{ fixed by } \rho ' \text{ then } \mathrm{leaf}\ \mathrm{true}\ \text{else}\ \mathrm{canonicalDTree.go}\, f\, \rho _{\mathrm{orig}}.\mathrm{numFree}\, \rho '\bigr)\) equals \(\mathrm{canonicalDTree}\, f\, \rho '\).
The encoder loop SwitchingLemma2.razborovEncode’s go run with an accumulator decomposes into a run on the empty accumulator: its result can be expressed in terms of the corresponding empty-accumulator computation together with the supplied accumulator.
The output produced by the encoder loop SwitchingLemma2.razborovEncode’s go grows in a controlled way: its second component has length at most \(|\mathrm{acc}| + 2 \cdot |\mathrm{path}|\), where \(\mathrm{acc}\) is the accumulator and \(\mathrm{path}\) the current path.
When the encoder finds \(t_{\mathrm{clause}}\) as the first clause not killed by \(\rho _0\) and its filtered free-variable literals form a nonempty list \(\mathit{fl}::\mathit{fls}\), the first component of the encoder run with fuel \(\mathrm{fuel}+1\) on path \(\mathit{step}::\mathit{rest}\) equals the first component of the recursive encoder run with fuel \(\mathrm{fuel}\) on the processed state \(\mathrm{pcl} = \mathrm{processClauseLits}\, (\mathit{fl}::\mathit{fls})\, (\mathit{step}::\mathit{rest})\, \rho _0\, \sigma \).
If \(\rho _0\, v \neq \mathrm{none}\) (so \(v\) is non-free), then the first component \(\gamma \) of the encoder loop SwitchingLemma2.razborovEncode’s go returns \(\sigma \, v\) at \(v\); the encoder does not alter \(\sigma \) on non-free variables.
At a variable \(v\) that is free under \(\rho _0\) and unset in both \(\sigma _1\) and \(\sigma _2\), the first component \(\gamma \) of the encoder loop SwitchingLemma2.razborovEncode’s go takes the same value at \(v\) whether started from \(\sigma _1\) or \(\sigma _2\).
Let \(f\) be a DNF whose terms contain no two distinct literals on the same variable, and let \(t\) be the first term of \(f\) not killed by \(\rho _0\) (as returned by find?). If \(l \in t\) has \(\rho _0\, l.\mathrm{var} = \mathrm{none}\) and \(\sigma \) is unset wherever \(\rho _0\) is, then the first component of the encoder loop SwitchingLemma2.razborovEncode’s go (for any fuel, path, and empty accumulator) at \(l.\mathrm{var}\) is not \(\mathrm{some}\ l.\mathrm{neg}\); the encoder never assigns the free literal \(l\) its negating value, so it does not kill the first surviving clause.
The aux output of \(\mathrm{razborovEncode.go}\) (started with empty accumulator) can be written as \(\mathrm{triplesToAux}\, w\, ts\) for some triple list \(ts\) whose length is bounded by the path length and whose last element, if any, has marker flag true. This is the main structural invariant of the encoder.
There exists a function \(g\) from aux lists into \(\mathrm{Fin}\, d \to \mathrm{Fin}\, w \times \mathrm{Bool} \times \mathrm{Bool}\) that is injective on the image of the Razborov encoder over bad \(s\)-restrictions with fixed \(\gamma \). This isolates the combinatorial encoding of each of the \(d\) path steps as a triple \((\mathrm{position}, \mathrm{direction}, \mathrm{hasMarker})\).
For a DNF \(f\) with no two literals in a term sharing a variable, suppose the encoder finds \(t_{\mathrm{clause}}\) as the first term not killed by \(\rho _0\). Under the agreement hypotheses relating \(\rho _0\), \(\sigma \), and the decoder restriction \(\rho _{0,\mathrm{dec}}\) (agreeing with the encoder output on free variables and with \(\rho _0\) on set variables), the decoder restriction also finds \(t_{\mathrm{clause}}\) as its first non-killed clause.
Suppose \(t\) is the first term of \(f\) not killed by \(\rho \), that \(\sigma \) agrees with \(\rho \) on all non-free variables, and that \(t\) is not killed by \(\sigma \). Then \(t\) is also the first term of \(f\) not killed by \(\sigma \).
Folding the decoder’s \(\rho _0\)-update over a list of entries leaves \(v\) unchanged when no entry targets \(v\); if for every entry the literal at its position in \(t\) does not have variable \(v\), the folded \(\rho _0\) agrees with the initial \(\rho _0\) at \(v\).
Folding the decoder’s \(\sigma \)-update over a list of entries leaves \(v\) unchanged when no entry targets \(v\); that is, if for every entry the literal at its position in \(t\) does not have variable \(v\), the folded \(\sigma \) agrees with the initial \(\sigma \) at \(v\).
Specializing the generalized round trip to \(\sigma = \rho _0 = \rho \): for a width-\(w\) DNF \(f\) with distinct variables per term, running the encoder on \(\rho \) and then running the decoder (with one more than the encoded list length as fuel) on the encoder output recovers \(\rho \).
The generalized round-trip statement: for a DNF \(f\) of width at most \(w\) with distinct variables per term, given decoder states \(\sigma _{\mathrm{dec}}\) and \(\rho _{0,\mathrm{dec}}\) that satisfy the round-trip invariants relative to the encoder output and enough decoder fuel, the first component of the decoder run on the encoder’s output list equals the original \(\sigma \). This is the inductive core from which the closed round trip follows.
\(\mathrm{IsCanonicalPath}\, f\, \rho \, \mathrm{path}\) holds when \(\mathrm{path}\) is an initial segment of the canonical decision tree’s deepest root-to-leaf path for \(f|_\rho \), i.e. \(\mathrm{path} = (\mathrm{canonicalDTree}\, f\, \rho ).\mathrm{deepPath}.\mathrm{take}\, (\mathrm{path.length})\). This is the invariant carried by the Razborov encoder.
If a term \(t\) is killed by \(\rho \) and a restriction \(\sigma \) agrees with \(\rho \) on every non-free variable (i.e. \(\sigma (v) = \rho (v)\) whenever \(\rho (v) \neq \mathrm{none}\)), then \(t\) is also killed by \(\sigma \).
If a pair \(p\) lies in the list obtained by filtering the indexed literals of \(t_{\mathrm{clause}}\) (its zipIdx) to those whose variable is free under \(\rho _0\), then \(p\) is a member of \(t_{\mathrm{clause}}.\mathrm{zipIdx}\) and its variable is free, i.e. \(\rho _0\, (p.1.\mathrm{var}) = \texttt{none}\).
Parses a low-level aux list of \((\mathbb {N} \times \mathrm{Bool})\) entries into a list of triples \((\mathrm{pos}, \mathrm{dir}, \mathrm{hasMarker})\) with \(\mathrm{pos} : \mathrm{Fin}\, w\), where \(\mathrm{hasMarker}\) records whether the entry is immediately followed by a \((w, \mathrm{false})\) termination marker. Entries with index \(\geq w\) that do not follow a real entry are dropped.
Equational lemma: if an entry \((idx, dir)\) with \(idx \lt w\) is immediately followed by the marker \((w, \mathrm{false})\), then \(\mathrm{parseAux}\) emits the triple \((\langle idx, h\rangle , dir, \mathrm{true})\) followed by the parse of the rest.
Equational lemma: if an entry \((idx, dir)\) is immediately followed by another in-range entry \((idx', dir')\), then \(\mathrm{parseAux}\) emits the triple \((\langle idx, h\rangle , dir, \mathrm{false})\) followed by the parse of the remaining list starting at \((idx', dir')\).
If the restriction component \((\mathrm{processClauseLits}\ \mathit{lits}\ \mathit{path}\ \rho _0\ \sigma ).2.1\) is unset at a variable \(v\) (equal to none), then \(\rho _0\) is already unset at \(v\), i.e. \(\rho _0\, v = \texttt{none}\).
Consumes the free literals of a single clause (each paired with its position index) against the canonical decision-tree path, one path entry per literal. For each free literal it fixes the literal’s variable to its satisfying direction in \(\sigma \), records the path direction in \(\rho _0\) (mirroring the canonical decision-tree branching), and appends the pair (literal position in clause, path direction) to the auxiliary data. It returns the remaining path together with the updated \(\rho _0\), \(\sigma \), and the accumulated clause auxiliary data.
Suppose every input literal pair occurs in \(t.\texttt{zipIdx}\) and no input literal has variable \(v\). Then for every auxiliary entry \(e\) of SwitchingLemma2.processClauseLits, the literal at position \(e.1\) in \(t\) does not have variable \(v\).
Assuming every literal in \(\mathit{lits}\) is an indexed literal of the term \(t\), if the restriction component \((\mathrm{processClauseLits}\ \mathit{lits}\ \mathit{path}\ \rho _0\ \sigma ).2.1\) is unset at \(v\), then no auxiliary entry produced by the fold targets \(v\): for every aux entry \(e\), dropping \(e.1\) literals of \(t\) to a head literal \(l\) gives \(l.\mathrm{var} \neq v\).
Suppose every input literal pair occurs in \(t.\texttt{zipIdx}\) and all input literals are free under \(\rho _0\). Then for every auxiliary entry \(e\) of SwitchingLemma2.processClauseLits, the literal at position \(e.1\) in \(t\) has a variable that is free under \(\rho _0\) (its \(\rho _0\) value is \(\mathrm{none}\)).
Suppose every input literal pair occurs in \(t.\texttt{zipIdx}\) and the decoder’s initial \(\rho _0\) value agrees with the encoder’s at \(v\). Then folding the decoder’s \(\rho _0\)-update over the auxiliary entries of SwitchingLemma2.processClauseLits reproduces the \(\rho _0\) component of that routine at \(v\).
A variant of the previous lemma allowing the decoder’s initial \(\rho _0\) to differ from the encoder’s: provided \(\rho _0\, v = \mathrm{none}\) and SwitchingLemma2.processClauseLits sets the \(\rho _0\) component at \(v\), the \(\rho _0\)-fold over the auxiliary entries still reproduces the routine’s \(\rho _0\) value at \(v\).
Suppose every input literal pair occurs in \(t.\texttt{zipIdx}\), that \(\rho _0\, v = \mathrm{none}\), and that SwitchingLemma2.processClauseLits sets the \(\rho _0\) component at \(v\). Then folding the decoder’s \(\sigma \)-update over the auxiliary entries yields \(\mathrm{none}\) at \(v\).
Contrapositive of \(\rho _0\)-stability: if \(\rho _0\, v = \mathrm{none}\), the SwitchingLemma2.processClauseLits output keeps \(\rho _0\) unset at \(v\), and there are at least as many path entries as literals, then no input literal has variable \(v\).
Provided each literal’s variable is free in \(\rho _0\) and the variables are pairwise distinct, the \(\rho _0\)-component of \(\mathrm{processClauseLits}\) loses exactly \(\min (\mathrm{lits.length}, \mathrm{path.length})\) free variables.
Under the invariants that \(\rho _0\) and \(\sigma \) share free variables and each processed literal’s variable is free in \(\rho _0\), the \(\sigma \)-component of \(\mathrm{processClauseLits}\) has \(\mathrm{numFree}\) decreased by exactly \(\min (\mathrm{lits.length}, \mathrm{path.length})\).
The remaining path returned by processClauseLits is no longer than the input path: the length of the first component of \(\mathrm{processClauseLits}\, (\mathit{lits}, \mathit{path}, \rho _0, \sigma )\) is at most the length of \(\mathit{path}\).
Suppose \((l, idx)\) is in the input list, no other input literal shares \(l\)’s variable, \(\rho _0\, l.\mathrm{var} = \mathrm{none}\) initially, and SwitchingLemma2.processClauseLits still leaves \(\rho _0\) unset at \(l.\mathrm{var}\). Then the remaining path returned by the routine is empty, since \(l\) was never processed because the path ran out first.
If a variable \(v\) is the variable of no literal in the input list, then SwitchingLemma2.processClauseLits leaves the \(\rho _0\) restriction unchanged at \(v\); the resulting \(\rho _0\) agrees with the input \(\rho _0\) on \(v\).
If two starting restrictions agree at \(v\) (\(\sigma _1\, v = \sigma _2\, v\)), then the \(\sigma \) output of SwitchingLemma2.processClauseLits at \(v\) is the same for both; the value at \(v\) depends only on the initial \(\sigma \) at \(v\).
The remaining path, the \(\rho _0\) output, and the auxiliary entry list produced by SwitchingLemma2.processClauseLits are all independent of the input \(\sigma \): for any two starting restrictions \(\sigma _1, \sigma _2\) these three components coincide.
If no literal in the input list shares \(l\)’s variable except \(l\) itself, and the initial \(\sigma \) at \(l.\mathrm{var}\) is not \(\mathrm{some}\ l.\mathrm{neg}\), then after SwitchingLemma2.processClauseLits the \(\sigma \) output at \(l.\mathrm{var}\) is still not \(\mathrm{some}\ l.\mathrm{neg}\).
If \(\rho _0\, v = \mathrm{none}\) and SwitchingLemma2.processClauseLits leaves \(\rho _0\) unset at \(v\), then it also leaves \(\sigma \) unchanged at \(v\); the \(\sigma \) output equals the input \(\sigma \) at \(v\), since \(\rho _0\) and \(\sigma \) are updated at the same variables in lockstep.
If a variable \(v\) is the variable of no literal in the input list, then SwitchingLemma2.processClauseLits leaves the \(\sigma \) restriction unchanged at \(v\); that is, the resulting \(\sigma \) agrees with the input \(\sigma \) on \(v\).
Dropping the free-literal prefix from \((\mathrm{termSubTree}\, t\, \rho _0\, \mathrm{cont}).\mathrm{deepPath}\) yields the deep path of the continuation evaluated at the \(\mathrm{processClauseLits}\)-updated restriction, connecting the canonical tree structure to the encoder’s restriction update.
Characterizes the decoder’s processEntries when run on the auxiliary entries of SwitchingLemma2.processClauseLits followed by a termination marker \((w, \mathrm{false})\) and a remainder: the result is given by folding the decoder’s \(\sigma \)- and \(\rho _0\)-updates over those auxiliary entries, leaving the remainder unconsumed, provided \(t.\mathrm{length} \le w\) and every input literal occurs in \(t.\texttt{zipIdx}\).
The inverse of the Razborov encoding: given the DNF \(f\), parameter \(w\), and a pair \((\gamma , \mathrm{aux})\) produced by the encoder, it recovers the original restriction \(\rho \). It repeatedly finds the first clause not killed by the current restriction, processes that clause’s auxiliary block (unfixing each recorded variable in \(\sigma \) and recording its path direction in \(\rho _0\) until a termination marker is reached), and returns the resulting restriction.
For a width-\(w\) DNF \(f\) with distinct variables per term and a bad restriction \(\rho \) for \(f.\mathrm{eval}\) at depth \(d\), decoding the Razborov encoding of \(\rho \) returns \(\rho \): \(\mathrm{razborovDecode}\ f\ w\ (\mathrm{razborovEncode}\ f\ w\ d\ \rho ) = \rho \).
The Razborov encoding of a DNF \(f\) and a restriction \(\rho \) with parameters \(w, d\). It takes the first \(d\) steps of the deepest path of the canonical decision tree for \(f|_\rho \), then repeatedly selects the first clause of \(f\) not killed by the current restriction, processes all of that clause’s free literals against the path, and emits a termination marker \((w, \mathrm{false})\). The result is a pair \((\gamma , \mathrm{aux})\), where \(\gamma \) extends \(\rho \) by fixing \(d\) variables to their satisfying directions and \(\mathrm{aux}\) consists of per-clause blocks separated by the termination markers.
For a bad \(s\)-restriction \(\rho \) with \(d \leq s\), the first component (the \(\gamma \)-output) of \(\mathrm{razborovEncode}\, f\, w\, d\, \rho \) is an \((s-d)\)-restriction, since the encoder fixes exactly \(d\) previously free variables.
When the canonical tree depth is at least the path length, \(\mathrm{razborovEncode.go}\) fully consumes the path (never terminating early), and the resulting \(\sigma \) has \(\mathrm{numFree}\) decreased by exactly the initial path length: \((\mathrm{go}\, \dots ).1.\mathrm{numFree} + \mathrm{path.length} = \sigma .\mathrm{numFree}\).
The Razborov encoding is injective on bad restrictions: for a width-\(w\) DNF \(f\) with distinct variables per term, if \(\rho _1\) and \(\rho _2\) are both bad restrictions for \(f.\mathrm{eval}\) at depth \(d\) and their encodings agree, \(\mathrm{razborovEncode}\ f\ w\ d\ \rho _1 = \mathrm{razborovEncode}\ f\ w\ d\ \rho _2\), then \(\rho _1 = \rho _2\).
Given \(f : (\mathrm{Fin}\, n \to \mathrm{Bool}) \to \mathrm{Bool}\) and a restriction \(\rho \), the restricted function maps \(x\) to \(f(\rho .\mathrm{extend}\, x)\), i.e. \(f\) evaluated on the free coordinates with the fixed coordinates set by \(\rho \).
Given a restriction \(\rho \) and a point \(x : \mathrm{Fin}\, n \to \mathrm{Bool}\), the extension \(\rho .\mathrm{extend}\, x\) is the Boolean assignment that uses the fixed value \(\rho (i)\) where it is set and falls back to \(x(i)\) on the free variables.
When the encoder returns \((\sigma , [])\) (an empty emitted list), the decoder loop SwitchingLemma2.razborovDecode’s go recovers \(\sigma \) exactly, given that \(\sigma \) and the decoder’s starting restriction \(\sigma _{\mathrm{dec}}\) agree with \(\sigma \) on both free and non-free variables and that \(\sigma \) is unset wherever \(\rho _0\) is unset.
Under the freeness and membership hypotheses on \(\mathit{lits}\) and the agreement of \(\sigma _{\mathrm{dec}}\) with \(\sigma \) on variables set by \(\rho _0\), the \(\sigma \)-fold over the aux entries (which clears \(l.\mathrm{var}\) for each dropped head literal \(l\)) applied to \(\sigma _{\mathrm{dec}}\) agrees with \(\sigma \) at every variable \(v\) where the processed restriction \((\mathrm{processClauseLits}\ \mathit{lits}\ \mathit{path}\ \rho _0\ \sigma ).2.1\) is set.
Under the freeness and membership hypotheses on \(\mathit{lits}\) and the agreement of \(\rho _{0,\mathrm{dec}}\) with \(\rho _0\) on variables set by \(\rho _0\), the \(\rho _0\)-fold over the aux entries (which sets \(l.\mathrm{var}\) to \(e.2\) for each dropped head literal \(l\)) applied to \(\rho _{0,\mathrm{dec}}\) agrees with the processed restriction \((\mathrm{processClauseLits}\ \mathit{lits}\ \mathit{path}\ \rho _0\ \sigma ).2.1\) at every variable \(v\) where that restriction is set.
Let \(n\gt 0\), let \(f:\{ 0,1\} ^n\to \{ 0,1\} \) be a DNF formula, and fix \(w,s,d\in \mathbb {N}\). Assume
\(\text{width}(f)\le w\) (width counted as list length, see Section 3.3),
\(5s \le n\),
\(f\) satisfies the non-contradictory clause hypothesis hnd: for every term \(t\in f\) and every pair of literals \(\ell _1,\ell _2\in t\), if \(\ell _1.\mathrm{var}=\ell _2.\mathrm{var}\) then \(\ell _1=\ell _2\).
Then
Given a term \(t\) (a conjunction of literals) and a restriction \(\rho \), this is the list of literals of \(t\) whose underlying variable is still free under \(\rho \), i.e. the sublist of \(t\) obtained by keeping those literals \(l\) with \(l.\mathrm{var} \in \rho .\mathrm{freeVars}\).
Builds a complete sub-tree for a term, queried as a list of literals: it branches on each free variable of the term in order, and at every leaf invokes a continuation \(\mathrm{cont} : \mathrm{Restriction}\, n \to \mathrm{DecisionTree}\, n\) with the restriction updated along that root-to-leaf path. Non-free literals are skipped.
When the head literal \(l\) is free in \(\rho \), \(\mathrm{termSubTree}\, (l :: \mathit{rest})\, \rho \, \mathrm{cont}\) is a branch on \(l.\mathrm{var}\) whose two children are the recursive \(\mathrm{termSubTree}\) calls on \(\mathit{rest}\) with \(\rho \) updated to \(\mathrm{some}\ \mathrm{false}\) and \(\mathrm{some}\ \mathrm{true}\).
If two continuations \(\mathrm{cont}_1, \mathrm{cont}_2\) agree on all restrictions \(\rho '\) with \(\rho '.\mathrm{numFree} \le \rho .\mathrm{numFree}\), then \(\mathrm{termSubTree}\, \mathit{lits}\, \rho \, \mathrm{cont}_1 = \mathrm{termSubTree}\, \mathit{lits}\, \rho \, \mathrm{cont}_2\).
If \(\mathit{lits}\) contains at least one literal free in \(\rho \), then the two continuations need only agree on restrictions \(\rho '\) with \(\rho '.\mathrm{numFree} \lt \rho .\mathrm{numFree}\) for the two \(\mathrm{termSubTree}\) trees to be equal.
For \(\mathit{lits}\) with pairwise distinct variables there is a restriction \(\rho '\), agreeing with \(\rho \) off the variables of \(\mathit{lits}\), such that the deep-path length of \(\mathrm{termSubTree}\, \mathit{lits}\, \rho \, \mathrm{cont}\) equals the number of free literals of \(\mathit{lits}\) plus the deep-path length of \(\mathrm{cont}\, \rho '\).
When the head literal \(l\) is free in \(\rho \), the deepest root-to-leaf path of \(\mathrm{termSubTree}\, (l :: \mathit{rest})\, \rho \, \mathrm{cont}\) begins with \((l.\mathrm{var}, b)\) for some \(b\) (the direction of the deeper child), followed by the deep path of the recursive call on \(\rho [l.\mathrm{var} \mapsto b]\).
For \(\mathit{lits}\) with pairwise distinct variables, the deep path of \(\mathrm{termSubTree}\, \mathit{lits}\, \rho \, \mathrm{cont}\) splits as a prefix (one entry per free literal of \(\mathit{lits}\)) appended with the deep path of \(\mathrm{cont}\, \rho '\), where \(\rho '\) agrees with \(\rho \) off the variables of \(\mathit{lits}\).
For \(\mathit{lits}\) with pairwise distinct variables, the \(k\)-th variable of the deep path of \(\mathrm{termSubTree}\, \mathit{lits}\, \rho \, \mathrm{cont}\) equals the variable of the \(k\)-th literal in the free-filtered list of \(\mathit{lits}\).
Evaluating \(\mathrm{termSubTree}\, \mathit{lits}\, \rho \, \mathrm{cont}\) at \(x\) equals evaluating the continuation at \(x\), applied to the restriction obtained by folding \(x\)’s values into \(\rho \) along the free literals of \(\mathit{lits}\).
After \(\mathrm{termSubTree}\) assigns all free variables of \(\mathit{lits}\) from \(x\), the resulting restriction extends by \(x\) to the same total assignment as \(\rho \) does: \((\mathrm{fold}\, \mathit{lits}\, \rho ).\mathrm{extend}\, x = \rho .\mathrm{extend}\, x\).
If every literal in \(\mathit{prefix}\) has variable not free in \(\rho \), then \(\mathrm{termSubTree}\, (\mathit{prefix} \mathbin {+\! \! +} \mathit{rest})\, \rho \, \mathrm{cont} = \mathrm{termSubTree}\, \mathit{rest}\, \rho \, \mathrm{cont}\).
If \(l.\mathrm{var} = v\), then \(\mathrm{termSubTree}\, (l :: \mathit{rest})\, (\rho [v \mapsto b])\, \mathrm{cont} = \mathrm{termSubTree}\, \mathit{rest}\, (\rho [v \mapsto b])\, \mathrm{cont}\), since after the update \(v\) is no longer free and \(l\) is skipped.
The inverse direction of SwitchingLemma2.parseAux: converts a list of triples back into an aux list of \((\mathbb {N} \times \mathrm{Bool})\) entries, emitting a \((w, \mathrm{false})\) termination marker after each triple whose marker flag is true.
For a CNF \(\psi \) of width at most \(w\) with \(5s \leq n\) and well-formed clauses, the number of \(s\)-restrictions \(\rho \) for which \(\psi |_\rho \) cannot be represented by a DNF of width \(\leq w\) satisfies
For a CNF \(\psi \) of width at most \(w\) on \(n\) variables with \(5s \leq n\) and clauses free of duplicate or conflicting variables, the number of \(s\)-restrictions \(\rho \) under which \(\psi |_\rho \) has decision-tree depth \(\gt d\) satisfies
For naturals \(k, d \gt 0\), \(n \ge 2\) and \(m \le nk\) there exists a real constant \(C_2 \gt 0\) such that, for every real \(\mathrm{val}_f^{\mathrm{exp}}\) satisfying
the same bound holds. The displayed inequality is the refutation bound \(\mathbb {E}_b[\mathrm{val}(f_b)] \le C_2\, n \sqrt{k}\, d\, (nk)^{1/8} (\log n)^{1/4}\) obtained by combining the Cauchy–Schwarz trick, the spectral certificate, the binomial ratio estimate and the spectral norm bound with the choice \(\ell = \Theta (\sqrt{n/k})\).
If \(s\) is a set of \(m\) vertices forming a clique in the conflict graph of a formula \(f\) with \(m\) clauses, then for every clause index \(i : \mathrm{Fin}\, m\) there is exactly one vertex \(u \in s\) with \(u.c\_ idx = i\).
If an assignment \(\alpha \) makes both \(l_1\) and \(l_2\) true, then \(l_1\) and \(l_2\) do not conflict: \(\mathtt{evalLiteral}\, \alpha \, l_1 \to \mathtt{evalLiteral}\, \alpha \, l_2 \to \neg \, \mathtt{literalsConflict}\, l_1\, l_2\).
If a 3-CNF formula \(f\) with \(m\) clauses is satisfiable, then the conflict graph \(\mathtt{toCliqueGraph}\, f\) contains an \(m\)-clique: \(\mathtt{is3Satisfiable}\, f \to \mathtt{hasClique}\, (\mathtt{toCliqueGraph}\, f)\, f.\mathtt{length}\).
A 3-CNF formula \(f\) is satisfiable if and only if its conflict graph contains a clique of size \(f.\mathtt{length}\):
The conflict graph of a 3-CNF formula \(f\) is the simple graph on vertex set \(\mathtt{CliqueVertex}\, f.\mathtt{length}\) in which two vertices \(u\) and \(v\) are adjacent if and only if they come from different clauses (\(u.c\_ idx \ne v.c\_ idx\)) and their respective literals do not conflict.
Given \(m : \texttt{TimeM T α}\) and \(f : \alpha \to \texttt{TimeM T β}\), the bind of \(m\) and \(f\) runs \(f\) on the value returned by \(m\) and returns \(\langle (f\, m.\mathrm{ret}).\mathrm{ret},\; m.\mathrm{time} + (f\, m.\mathrm{ret}).\mathrm{time}\rangle \): the two time costs are added.
For a matrix \(A\in \mathbb {R}^{k\times d}\), a vector \(x\in \mathbb {R}^d\), and an index \(i\in \mathrm{Fin}\, k\),
This definitional equality unfolds the linear map into its explicit sum form.
*The adjacency matrix \(A\) of a tournament \(D\) is primitive if and only if \(D\) is diconnected and \(\nu \ge 4\).*
The ranking method (§10.7). When \(A\) is primitive, Perron–Frobenius gives a largest real eigenvalue \(r\) with lim_i (A/r)\(^{i}\) J = s, a positive eigenvector; the normalised \(\bar{s}\) measures relative strengths. For the book’s six-player example \(r \approx 2.232\) and \(\bar{s} \approx (.238, .164, .231, .113, .150, .104)\), ranking the players \(1, 3, 2, 5, 4, 6\). Non-diconnected tournaments are handled by ranking within dicomponents and then ordering the dicomponents by dominance (exercises 10.1.9 and 10.1.3(b)). Due to Wei (1952) and Kendall (1955).
! Steps 2 and 4 are the awkward ones: B&M discharge them by pointing at a figure the source omits, so the two small tournaments have to be identified and checked from scratch. Everything else follows from theorem 10.7 and exercise 10.1.8.
*Let \(D\) be a diconnected tournament with \(\nu \ge 5\), and let \(A\) be the adjacency matrix of \(D\). Then \(A^{d+3} \gt 0\) (every entry positive), where \(d\) is the directed diameter of \(D\).*
Why it matters (§10.7). The \(i\)-th level score vector of a tournament is \(s_{i} = A^{i}J\), each player’s score being the sum of the scores of those they beat. Primitivity of \(A\) is what lets Perron–Frobenius guarantee these vectors converge to a positive eigenvector, giving a well-defined ranking.
! The arithmetic \(d - d_{ij} + 3\) is \(\mathbb {N}\)-subtraction but never truncates, since \(d_{ij} \le d\); still, establish that inequality before the case split rather than relying on it implicitly. \(\nu \ge 5\) is load-bearing in step 4 only.
Tournaments are never far from diconnected: a single reversed result suffices to make every player reachable from every other. Step 3 is the tournament speciality — in a general digraph the dicomponents form only a partial order, and one reversal would not do.
The reorientation is written inline as an \(if\)-cascade on Adj rather than via a helper: \((x,y)\) is removed, \((y,x)\) added, everything else kept. Note the if (u = y \(\land \) v = x) then True branch must come after the \((x,y)\) branch, which it does.
*A tournament contains a vertex from which every other vertex is reachable by a directed path of length at most two.*
Such a vertex is called a king: a player who, for every other player \(v\), either beat \(v\) directly or beat someone who beat \(v\). Exercise 10.2.4 gives a direct proof — take a vertex of maximum outdegree — which is dropped from this file as a second proof of the same statement. Note a king need not have won the most games, and a tournament may have several kings.
[Nonempty V] is load-bearing for step 3; without it \(S = \emptyset \) is a legitimate semi-kernel and no \(u\) exists.
*Let \(P = (v_{1}, \dots , v_k)\) be a maximal directed path in a tournament \(D\). Suppose \(P\) is not a directed Hamilton path and let \(v\) be any vertex not on \(P\). Then for some \(i\), both \((v_{i}, v)\) and \((v, v_{i+1})\) are arcs of \(D\).*
Because \(D\) is a tournament, \(v\) is joined to every vertex of \(P\) in one direction or the other; maximality forces \(v_{1} \to v\) at the start and \(v \to v_k\) at the end, so travelling along \(P\) the direction must switch somewhere. Part (b) — dropped here, being a re-derivation of corollary 10.1 — inserts \(v\) at that point to get a longer directed path and repeats until it spans.
The path is presented as a List V with IsChain D.Adj rather than as a Quiver.Path, since the statement indexes into it (\(l[i]\), \(l[i+1]\)) and lists index far more comfortably. [Inhabited V] supports head!/getLast! in hmax; hne : l \(\ne \) [] keeps those meaningful.
Let \(k, n, d\) be natural numbers with \(0 \lt k\), \(2 \le n\) and \(0 \lt d\). Then there is a constant \(C_0 \gt 0\) such that for every number of heavy pairs \(n_P\) satisfying \(n_P \cdot d \le n k\) one has
In other words, the bound coming from the spectral estimate \(\sqrt{n \left\lvert P\right\rvert } \cdot \lVert A\rVert _2\) together with \(\left\lvert P\right\rvert \le nk/d\) is \(O\! \left(n k \sqrt{\log n / d}\right)\).
Placeholder. The constant \(C_0\) is quantified after \(n\) and the Lean proof takes \(C_0 := 1 + n\), so it is not a constant at all and the bound carries no refutation content. Lemma 7.1 is not formalised here.
For parameters \(k, n, d\) and a message \(b : \mathrm{Fin}\, k \to \mathbb {Z}\), the modelled value of the \(2\)-XOR polynomial \(g_b\) obtained from the decomposition, namely the real number
The definition is abstract: the quantity depends only on \(n\), \(k\) and the threshold \(d\), and is constant in the edge count and in \(b\).
For \(k \gt 0\), \(x \in \mathbb {R}^d\), and \(i \in \mathrm{Fin}\, k\),
This follows from per-summand variance \(x_j^2/k\) together with within-row independence.
For any game \(G\) and any mixed strategies \(p\) (row) and \(q\) (column),
The row player’s worst-case mixed payoff never exceeds the column player’s best-case mixed payoff.
Let \(p : \mathrm{Fin}\, n \to \mathbb {R}\) be a probability vector (\(p_i \ge 0\), \(\sum _i p_i = 1\)) and let \(\ell : \mathrm{Fin}\, n \to \mathbb {R}\) satisfy \(0 \le \ell _i \le 1\) for all \(i\). For any \(\eta \in \mathbb {R}\),
Let \(\beta \in (0,1)\), \(n \ge 1\), and suppose \(\beta ^{M^*} \le n \cdot \bigl(\tfrac {1+\beta }{2}\bigr)^{M_{\mathrm{WM}}}\). Then
This packages the potential inequality into logarithmic form by monotonicity of \(\log \).
Let \(n \ge 2\), \(\beta \in (0,1)\), and suppose \(\beta ^{M^*} \le n \cdot \bigl(\tfrac {1+\beta }{2}\bigr)^{M_{\mathrm{WM}}}\). Then
Equivalently, \(M_{\mathrm{WM}} \le \dfrac {\log n + M^* \cdot \log (1/\beta )}{\log (2/(1+\beta ))}\), giving the standard Weighted Majority mistake bound.
Let \(\beta \in (0,1)\), let \(W : \mathbb {N} \to \mathbb {R}\) be a sequence of positive reals, and suppose \(W(k+1) \le W(k) \cdot \tfrac {1+\beta }{2}\) for every \(k \lt M\). Then
A finite two-player zero-sum game with \(M\) row actions and \(N\) column actions is a record consisting of a payoff matrix \(A : \mathrm{Fin}\, M \to \mathrm{Fin}\, N \to \mathbb {R}\) together with proofs that every entry satisfies \(0 \le A_{ij} \le 1\). The row player seeks to maximise the payoff; the column player seeks to minimise it.
Given a game \(G\) and a sequence of column responses \(j_0, \dots , j_{T-1}\), the induced loss sequence for the row player is \(\ell _t(i) = 1 - A_{i,j_t} \in [0,1]\). This translates a zero-sum game into the abstract loss-sequence framework used by Hedge.
The BLR acceptance probability admits the Fourier representation
For \(k \ge 2\), if \(f : \mathbb {Z}_k^n \to \mathbb {Z}_k\) is \(\varepsilon \)-far from linear (normalized), then
where \(\varphi (k)\) denotes Euler’s totient function.
If \(p\) is prime and \(f : \mathbb {Z}_p^n \to \mathbb {Z}_p\) is \(\varepsilon \)-far from linear (normalized), then
recovering the prime-field soundness bound as a corollary of the general result (using \(\varphi (p)=p-1\)).
If \(\| \widehat{\widetilde{f}}(s)\| \le A\) for all \(s \in \mathbb {Z}_p^n\), then
A function \(f : \mathbb {Z}_k^n \to \mathbb {Z}_k\) satisfies ZkBLR.epsilon_far_from_linear_normalized with parameter \(\varepsilon \) if \(f\) is normalized (\(f(0)=0\)), \(0\le \varepsilon \le 1\), and \(\mathrm{dist}(f,g)\ge \varepsilon \) for every linear \(g\).
For \(j \in \mathbb {Z}_k\), the \(j\)-twisted lift of \(f : \mathbb {Z}_k^n \to \mathbb {Z}_k\) is \(\widetilde{f}_j(x) = \omega _k^{j \cdot f(x)}\). The case \(j=1\) recovers ZkBLR.lift_omega; the case \(j=0\) gives the constant function \(1\).
For any \(f : \mathbb {Z}_k^n \to \mathbb {Z}_k\), the \(j=0\) term of the Fourier sum evaluates to \(1\):
A function \(f : \mathbb {Z}_k^n \to \mathbb {Z}_k\) is linear if and only if there exists \(s \in \mathbb {Z}_k^n\) such that \(f(x) = s \cdot x\) for all \(x\), where \(s \cdot x = \sum _i s_i x_i\) denotes the dot product in \(\mathbb {Z}_k\).
If \(k \ge 2\) and \(f\) is \(\varepsilon \)-far from linear (in the normalized sense), then for every \(s \in \mathbb {Z}_k^n\),
If \(f : \mathbb {Z}_p^n \to \mathbb {Z}_p\) is \(\varepsilon \)-far from linear (normalized), \(j \ne 0\), and \(s \in \mathbb {Z}_p^n\), then
If \(k \ge 2\), \(f\) is \(\varepsilon \)-far from linear (normalized), \(j \in \mathbb {Z}_k^\times \), and \(s \in \mathbb {Z}_k^n\), then
For \(k \ge 2\) and \(f : \mathbb {Z}_k^n \to \mathbb {Z}_k\), the real part of the \(s\)-th Fourier coefficient of the lifted function \(\widetilde{f}\) satisfies
For \(j \in \mathbb {Z}_k\) and \(F = \widetilde{f}_j\), the triple-product expectation satisfies
If \(f : \mathbb {Z}_k^n \to \mathbb {Z}_k\) is \(\varepsilon \)-far from linear (normalized) and \(j \in \mathbb {Z}_k^\times \) is a unit, then the scaled function \(x \mapsto j \cdot f(x)\) is also \(\varepsilon \)-far from linear (normalized).
If \(f : \mathbb {Z}_p^n \to \mathbb {Z}_p\) is \(\varepsilon \)-far from linear (normalized), then
If \(f : \mathbb {Z}_p^n \to \mathbb {Z}_p\) is \(\varepsilon \)-far from linear (normalized) and \(j \ne 0\), then
If \(k \ge 2\), \(f\) is \(\varepsilon \)-far from linear (normalized), and \(j \in \mathbb {Z}_k^\times \), then
For \(s \in \mathbb {Z}_k^n\), the Fourier character indexed by \(s\) is \(\chi _s : \mathbb {Z}_k^n \to \mathbb {C}\) defined by \(\chi _s(x) = \omega _k^{s \cdot x}\). The \(k^n\) characters \(\{ \chi _s\} _{s \in \mathbb {Z}_k^n}\) form an orthonormal basis of \(L^2(\mathbb {Z}_k^n)\).
For \(j : \mathbb {Z}/k\mathbb {Z}\),
This is the fundamental character-orthogonality identity for \(\mathbb {Z}/k\mathbb {Z}\).
For \(a : \mathbb {Z}/k\mathbb {Z}\), \(\texttt{ZkFourier.toOmega}\ a = \omega _k^{a}\), where \(a\) is lifted to its canonical representative in \(\{ 0, \ldots , k-1\} \subset \mathbb {N}\). This is the group homomorphism \((\mathbb {Z}/k\mathbb {Z}, +) \to (\mathbb {C}^\times , \cdot )\).
\(\texttt{ZkFourier.ZkVec}\ k\ n\) is the \(n\)-dimensional vector space over \(\mathbb {Z}/k\mathbb {Z}\), defined as the function type \(\mathrm{Fin}\, n \to \mathbb {Z}/k\mathbb {Z}\). It carries the pointwise additive group structure of \((\mathbb {Z}/k\mathbb {Z})^n\).