Chip-firing graphs #
A chip-firing graph (CFGraph) is a loopless undirected multigraph with bundled vertex type
G.V (assumed Fintype, DecidableEq, and Nonempty). Edges are stored as a multiset of pairs;
num_edges G v w counts total edge multiplicity between v and w, including both (v, w)
and (w, v) entries.
We define the degree (valence) of a vertex as the sum of edge multiplicities at that vertex,
and the genus (cyclomatic number) g = |E| - |G.V| + 1, which plays a central role in the
Riemann-Roch theorem for graphs ([Corry-Perkinson], Chapter 5).
Many main theorems in this library require connectivity; see graph_connected. In those cases, a
proof of connectivity must be provided as an additional argument.
A chip-firing graph is a loopless multigraph. It is not assumed connected by default, though many of our main theorems pertain to connected graphs.
- V : Type u
- instDecidableEq : DecidableEq self.V
Instances For
The number of edges between vertex v and vertex w. When working with chip-firing graphs in this repository, it is usually preferable to work with this function, rather than with the multiset of edges directly.
Equations
Instances For
A graph is connected if the vertices cannot be partitioned into two nonempty sets with no edges between them. This is equivalent to saying there is a path between any two vertices, but the first definition is more convenient to work with in this repository.
Equations
Instances For
Degree (valence) of a vertex as an integer (defined as the sum of incident edge multiplicities)
Equations
- vertex_degree G v = ∑ u : G.V, ↑(num_edges G v u)
Instances For
The divisor group #
A divisor (CFDiv G) is an integer-valued function on the vertices of a chip-firing graph,
representing a distribution of chips (possibly negative, i.e. debt) across vertices.
The divisor group Div(G) = CFDiv G is the abelian group G.V → ℤ under pointwise addition.
([Corry-Perkinson], Definition 1.3)
This section establishes basic operations on divisors: pointwise arithmetic lemmas, the
firing move at a single vertex (lending chips to all neighbors), the borrowing move
(the inverse operation), and the generalization to set firing ([Corry-Perkinson],
Definitions 1.5–1.6). The firing vector firing_vector G v is the principal divisor
produced by firing vertex v once.
The principal divisor associated to firing a single vertex
Equations
- firing_vector G v w = if w = v then -vertex_degree G v else ↑(num_edges G v w)
Instances For
Principal divisors and linear equivalence #
A firing script (firing_script G = G.V → ℤ) assigns an integer firing level to each vertex.
The associated principal divisor prin G σ records the net chip flow at each vertex when
script σ is applied: (prin G σ)(v) = Σ_u (σ(u) - σ(v)) · num_edges(v, u)
([Corry-Perkinson], Definition 2.3).
The subgroup of principal divisors principal_divisors G is generated by the firing vectors
firing_vector G v for all v. Two divisors D and D' are linearly equivalent
(linear_equiv G D D') if their difference is a principal divisor ([Corry-Perkinson],
Definition 1.8). This defines an equivalence relation on Div(G), and linearly equivalent
divisors have the same degree (see linear_equiv_preserves_deg).
The subgroup of principal divisors is generated by firing vectors at individual vertices.
Equations
Instances For
Two divisors are linearly equivalent if their difference is a principal divisor. [Corry-Perkinson], Definition 1.8
Equations
- linear_equiv G D D' = (D' - D ∈ principal_divisors G)
Instances For
Linear equivalence is an equivalence relation on Div(G).
A firing script is an integer-valued function on vertices, recording how many times each vertex is fired. Negative values represent borrowing. [Corry-Perkinson], Definition 2.2
Equations
- firing_script G = (G.V → ℤ)
Instances For
The group homomorphism sending a firing script σ to the principal divisor
(prin G σ)(v) = Σ_u (σ(u) - σ(v)) * num_edges G v u.
[Corry-Perkinson], Definition 2.3 (denoted div(σ) there)
Equations
Instances For
A divisor is principal if and only if it equals prin G σ for some firing script σ.
This gives a concrete characterization of the subgroup principal_divisors G.
Effective divisors and winnability #
A divisor is effective if it assigns a nonnegative number of chips to every vertex
([Corry-Perkinson], Definition 1.13). The divisor group carries a natural partial order
where D₁ ≤ D₂ iff D₁ v ≤ D₂ v for all v; effectivity is equivalent to D ≥ 0.
The submonoid of effective divisors is denoted Eff G.
A divisor D is winnable if it is linearly equivalent to some effective divisor
([Corry-Perkinson], Definition 1.14) — that is, the players can collectively win the
dollar game starting from position D.
The degree homomorphism and the Laplacian #
The degree of a divisor D is $\deg(D) = \sum_v D(v)$, the total number of chips
([Corry-Perkinson], Definition 1.4). It is a group homomorphism $\mathrm{Div}(G) \to \mathbb{Z}$.
Principal divisors have degree zero, so linearly equivalent divisors have equal degree
([Corry-Perkinson], Proposition 1.15).
The Laplacian matrix laplacian_matrix G is the matrix $L = \mathrm{Deg}(G) - A$, where
$\mathrm{Deg}(G)$ is the diagonal degree matrix and $A$ is the adjacency matrix
([Corry-Perkinson], Definition 2.6). Applying the Laplacian to a firing script produces
the corresponding principal divisor.
Linearly equivalent divisors have the same degree. [Corry-Perkinson], Proposition 1.15
Apply the Laplacian matrix to a firing script, and current divisor to get a new divisor.
Equations
- apply_laplacian G σ D v = D v - (laplacian_matrix G).mulVec σ v
Instances For
q-effective divisors #
Fix a vertex $q$. A divisor $D$ is $q$-effective if $D(v) \geq 0$ for all $v \neq q$;
it may have an arbitrary (possibly negative) value at $q$ itself. The structure q_eff_div
packages such a divisor with its proof of $q$-effectivity.
A key fact for connected graphs is that every divisor is linearly equivalent to a
$q$-effective divisor (q_effective_exists). The proof goes via the notion of a
benevolent set: a set $S$ is benevolent if any divisor can be made to have all its
debt concentrated on $S$ via firing moves.
A set of vertices is benevolent if it is possible to concentrate all debt on this set.
Equations
- benevolent G S = ∀ (D : CFDiv G), ∃ (E : CFDiv G), linear_equiv G D E ∧ ∀ (v : G.V), E v < 0 → v ∈ S
Instances For
Every divisor can have its debt concentrated on on vertex, as long as the graph is connected. That is, D is linearly equivalent to a q-effective divisor.
The q-reduction partial order #
A firing script $\sigma$ is a $q$-reducer if $\sigma(q) \leq \sigma(v)$ for all $v$,
meaning $q$ is fired the least (or not at all relative to the others). The relation
reduces_to G q D₁ D₂ holds when $D_2$ is obtained from $D_1$ by applying a $q$-reducer
script, i.e. $D_2 = D_1 + \mathrm{prin}(\sigma)$ for some $q$-reducer $\sigma$.
This relation is reflexive and transitive, and in connected graphs it is also antisymmetric
(reduces_to_antisymmetric), making it a partial order on $q$-effective divisors. The
antisymmetry relies on the fact that a firing script with trivial principal divisor must
be constant (constant_script_of_zero_prin).
reduces_to G q D₁ D₂ holds when D₂ is obtained from D₁ by applying a $q$-reducer
script: D₂ = D₁ + prin G σ for some σ with σ q ≤ σ v for all v.
Equations
- reduces_to G q D₁ D₂ = ∃ (σ : firing_script G), q_reducer G q σ ∧ D₂ = D₁ + (prin G) σ
Instances For
q-reduced divisors #
A $q$-effective divisor $D$ is $q$-reduced if, for every nonempty set $S \subseteq G.V \setminus \{q\}$, some vertex in $S$ would go into debt if $S$ were fired ([Corry-Perkinson], Definition 3.4). Equivalently, $D$ is the maximum element of its linear equivalence class in the $q$-reduction partial order.
The main results of this section are:
- Every divisor has a unique $q$-reduced representative (
exists_q_reduced_representative,q_reduced_unique), corresponding to [Corry-Perkinson], Theorem 3.6. - A divisor is winnable if and only if its $q$-reduced representative is effective
(
winnable_iff_q_reduced_effective), corresponding to [Corry-Perkinson], Corollary 3.7.
The existence proof proceeds by defining an active vertex (one that can still be fired
while maintaining $q$-effectivity) and showing that the reduction_excess — the total chips
at active vertices — strictly decreases at each reduction step.
A divisior is q-reduced if it is effective away from q, but firing any vertex set disjoint from q puts some vertex into debt. [Corry-Perkinson], Definition 3.4
Equations
Instances For
A vertex is called ``active'' if there exists a firing script that leaves the divisor effective away from q, does not fire q, and fires at least once at that vertex.
Equations
- active G q D v = ∃ (σ : firing_script G), q_reducer G q σ ∧ q_effective q (D + (prin G) σ) ∧ σ q < σ v
Instances For
The total chips held at active vertices of D. This quantity strictly decreases at each
step of the $q$-reduction algorithm, providing the termination measure for
q_effective_to_q_reduced.
Instances For
In a connected graph, every $q$-effective divisor is linearly equivalent to a $q$-reduced
divisor. The proof is by induction on reduction_excess.
Every divisor is linearly equivalent to some $q$-reduced divisor. [Corry-Perkinson], Theorem 3.6, part 1 (existence).
Every divisor is linearly equivalent to exactly one $q$-reduced divisor. [Corry-Perkinson], Theorem 3.6 (existence and uniqueness combined).
A divisor is winnable if and only if its q-reduced representative is effective. [Corry-Perkinson], Corollary 3.7, rephrased.