Documentation

ChipFiringWithLean.Orientation

Orientations of chip-firing graphs #

This file defines orientations of chip-firing graphs and establishes their relationship to divisors, configurations, and the Riemann-Roch theorem.

An orientation (CFOrientation G) assigns a direction to each edge of G. The key objects are:

The main results are:

structure CFOrientation (G : CFGraph) :
Type u_1

An orientation of G assigns a direction to each edge: directed_edges is a multiset of directed pairs summing to G.edges (with each undirected edge directed exactly one way). The count_preserving field ensures total flow on each edge equals its multiplicity, and no_bidirectional ensures no edge is directed both ways.

Instances For
    @[reducible, inline]
    abbrev flow {G : CFGraph} (O : CFOrientation G) (u v : G.V) :

    The flow from u to v under orientation O: the multiplicity of the directed edge (u,v).

    Equations
    Instances For
      theorem opp_flow {G : CFGraph} (O : CFOrientation G) (u v : G.V) :
      flow O u v + flow O v u = num_edges G u v

      The total flow on an undirected edge equals its multiplicity: flow O u v + flow O v u = num_edges G u v.

      theorem eq_orient {G : CFGraph} (O1 O2 : CFOrientation G) :
      O1 = O2 ∀ (u v : G.V), flow O1 u v = flow O2 u v

      Two orientations are equal iff they assign the same flow to every directed pair.

      theorem double_sum {T : Type u_1} [DecidableEq T] [Fintype T] (f : T × T) :
      u : T, v : T, f (u, v) = e : T × T, f e

      Helper lema for the count below.

      Helper lemma for later calculations. Puzzlingly intricate for such a simple statement! Perhaps it can be simplified.

      def indeg (G : CFGraph) (O : CFOrientation G) (v : G.V) :

      Number of edges directed into a vertex under an orientation

      Equations
      Instances For
        theorem indeg_eq_sum_flow {G : CFGraph} (O : CFOrientation G) (v : G.V) :
        indeg G O v = w : G.V, flow O w v

        The in-degree of v equals the sum of flows into v from all vertices.

        def outdeg (G : CFGraph) (O : CFOrientation G) (v : G.V) :

        Number of edges directed out of a vertex under an orientation

        Equations
        Instances For
          def is_source (G : CFGraph) (O : CFOrientation G) (v : G.V) :

          A vertex is a source if it has no incoming edges (indegree = 0)

          Equations
          Instances For
            def is_sink (G : CFGraph) (O : CFOrientation G) (v : G.V) :

            A vertex is a sink if it has no outgoing edges (outdegree = 0)

            Equations
            Instances For
              def directed_edge (G : CFGraph) (O : CFOrientation G) (u v : G.V) :

              directed_edge G O u v holds when there is a directed edge from u to v in orientation O.

              Equations
              Instances For
                def list_get_safe {α : Type} (l : List α) (i : ) :

                Helper function for safe list access

                Equations
                Instances For
                  structure DirectedPath {G : CFGraph} (O : CFOrientation G) :
                  Type u_1

                  A directed path in a graph under an orientation

                  Instances For

                    A directed path is non-repeating if its vertex list has no duplicates.

                    Equations
                    Instances For

                      A non-repeating directed path has length at most |G.V|.

                      An orientation is acyclic if it has no directed cycles and maintains consistent edge directions between vertices

                      Equations
                      Instances For
                        noncomputable def ancestors (G : CFGraph) (O : CFOrientation G) (v : G.V) :

                        The set of ancestors of a vertex v (nodes x such that there is a path x -> ... -> v)

                        Equations
                        Instances For
                          noncomputable def vertexLevelMeasure (G : CFGraph) (O : CFOrientation G) (v : G.V) :

                          Measure for vertex_level termination: number of ancestors.

                          Equations
                          Instances For
                            theorem indeg_ge_one_of_not_source (G : CFGraph) (O : CFOrientation G) (v : G.V) :
                            ¬is_source G O vindeg G O v 1

                            Vertices that are not sources must have at least one incoming edge.

                            theorem indeg_minus_one_nonneg_of_not_source (G : CFGraph) (O : CFOrientation G) (v : G.V) :
                            ¬is_source G O v0 (indeg G O v) - 1

                            For vertices that are not sources, indegree - 1 is non-negative.

                            theorem subset_source (G : CFGraph) (O : CFOrientation G) (S : Finset G.V) :
                            S.Nonemptyis_acyclic G OvS, wS, flow O w v = 0

                            In an acyclic orientation, every nonempty subset of vertices contains a vertex with no incoming flow from within the subset (a relative source).

                            theorem acyclic_has_source (G : CFGraph) (O : CFOrientation G) :
                            is_acyclic G O∃ (v : G.V), is_source G O v

                            Lemma: A non-empty graph with an acyclic orientation must have at least one source.

                            theorem is_source_of_unique_source {G : CFGraph} (O : CFOrientation G) {q : G.V} (h_acyclic : is_acyclic G O) (h_unique_source : ∀ (w : G.V), is_source G O ww = q) :
                            is_source G O q

                            If every source of an acyclic orientation must equal q, then q is indeed a source.

                            acyclic_with_unique_source G O q means that O is acyclic and every source of O is equal to q.

                            Equations
                            Instances For

                              In an acyclic orientation with unique source q, the vertex q is a source.

                              def config_of_source {G : CFGraph} {O : CFOrientation G} {q : G.V} (hO : acyclic_with_unique_source G O q) :
                              Config G q

                              The configuration associated to an acyclic orientation with unique source q: assigns $\mathrm{indeg}(v) - 1$ chips to each vertex $v \neq q$, and $0$ at $q$.

                              Equations
                              Instances For

                                Orientation divisors and configurations #

                                For an orientation $\mathcal{O}$ of $G$, the orientation divisor ordiv G O is $D(\mathcal{O})(v) = \mathrm{indeg}_{\mathcal{O}}(v) - 1$ ([Corry-Perkinson], Definition 4.7).

                                For an acyclic orientation $\mathcal{O}$ with unique source $q$, the associated configuration orientation_to_config G O q assigns $\mathrm{indeg}(v) - 1$ chips to each non-$q$ vertex. An acyclic orientation is uniquely determined by its in-degree sequence (orientation_determined_by_indegrees), and the divisor of an acyclic orientation is always $q$-reduced and unwinnable.

                                def ordiv (G : CFGraph) (O : CFOrientation G) :

                                The divisor associated with an orientation assigns indegree - 1 to each vertex [Corry-Perkinson], Definition 4.7, part 1; written D(O) there.

                                Equations
                                Instances For
                                  def orqed {G : CFGraph} (O : CFOrientation G) {q : G.V} (hO : acyclic_with_unique_source G O q) :

                                  The orientation divisor ordiv G O bundled as a q_eff_div, using acyclicity to prove $q$-effectivity.

                                  Equations
                                  Instances For

                                    The configuration c(O) associated to an acyclic orientation O. [Corry-Perkinson], Definition 4.7 (part 2)

                                    Equations
                                    Instances For
                                      theorem orientation_to_config_indeg (G : CFGraph) (O : CFOrientation G) (q : G.V) (hO : acyclic_with_unique_source G O q) (v : G.V) :
                                      (orientation_to_config G O q hO).vertex_degree v = if v = q then 0 else (indeg G O v) - 1

                                      Lemma: CFOrientation to config preserves indegrees

                                      Compatibility between configurations and divisors from an orientation

                                      theorem sum_filter_eq_map (G : CFGraph) (M : Multiset (G.V × G.V)) (crit : G.VG.V × G.VProp) [(v : G.V) → (e : G.V × G.V) → Decidable (crit v e)] :
                                      v : G.V, (Multiset.filter (crit v) M).card = (Multiset.map (fun (e : G.V × G.V) => {v : G.V | crit v e}.card) M).sum

                                      Helper lemma to simplify handshking argument. Is something like this already in Mathlib somewhere?

                                      theorem orientation_determined_by_indegrees {G : CFGraph} (O O' : CFOrientation G) :
                                      is_acyclic G Ois_acyclic G O'(∀ (v : G.V), indeg G O v = indeg G O' v)O = O'

                                      An acyclic orientation is uniquely determined by its indegree sequence. See [Corry-Perkinson], Lemma 4.3.

                                      theorem helper_config_to_orientation_unique (G : CFGraph) (q : G.V) (c : Config G q) (O₁ O₂ : CFOrientation G) (hO₁ : acyclic_with_unique_source G O₁ q) (hO₂ : acyclic_with_unique_source G O₂ q) (h_eq₁ : orientation_to_config G O₁ q hO₁ = c) (h_eq₂ : orientation_to_config G O₂ q hO₂ = c) :
                                      O₁ = O₂

                                      Lemma proving uniqueness of orientations giving same config

                                      theorem degree_ordiv {G : CFGraph} (O : CFOrientation G) :
                                      deg (ordiv G O) = genus G - 1

                                      The degree of an orientation divisor equals $g - 1$, where $g$ is the genus of $G$.

                                      The configuration degree of an acyclic orientation with unique source equals the genus.

                                      theorem ordiv_unwinnable (G : CFGraph) (O : CFOrientation G) :
                                      is_acyclic G O¬winnable G (ordiv G O)

                                      The orientation divisor $D(\mathcal{O})$ of an acyclic orientation $\mathcal{O}$ is not winnable. This is part of [Corry-Perkinson], Proposition 4.11.

                                      theorem ordiv_q_reduced {G : CFGraph} (O : CFOrientation G) {q : G.V} (hO : acyclic_with_unique_source G O q) :
                                      q_reduced G q (ordiv G O)

                                      The orientation divisor $D(\mathcal{O})$ of an acyclic orientation with unique source $q$ is $q$-reduced. Together with ordiv_unwinnable, this proves [Corry-Perkinson], Proposition 4.11.

                                      The configuration associated to an acyclic orientation with unique source $q$ is superstable.

                                      The canonical divisor and reverse orientations #

                                      The canonical divisor of $G$ is $K_G(v) = \deg(v) - 2$ for each vertex $v$ ([Corry-Perkinson], Definition 4.7). The reverse orientation $\overline{\mathcal{O}}$ of an orientation $\mathcal{O}$ is obtained by reversing all edge directions. The key identity is $D(\mathcal{O}) + D(\overline{\mathcal{O}}) = K_G$ (divisor_reverse_orientation).

                                      This section also contains the handshaking theorem (helper_sum_vertex_degrees): $\sum_{v \in G.V} \deg(v) = 2|E|$, and its corollary that $\deg(K_G) = 2g - 2$ (degree_of_canonical_divisor).

                                      The canonical divisor assigns degree - 2 to each vertex. This is independent of orientation and equals D(O) + D(reverse(O))

                                      Equations
                                      Instances For

                                        The reverse orientation $\overline{\mathcal{O}}$ obtained by reversing all edge directions. See [Corry-Perkinson], Definition 5.7.

                                        Equations
                                        Instances For
                                          theorem flow_reverse {G : CFGraph} (O : CFOrientation G) (v w : G.V) :

                                          The flow of the reverse orientation $\overline{\mathcal{O}}$ from $v$ to $w$ equals the flow of $\mathcal{O}$ from $w$ to $v$.

                                          theorem indeg_reverse_eq_outdeg (G : CFGraph) (O : CFOrientation G) (v : G.V) :

                                          The indegree of $v$ in the reverse orientation $\overline{\mathcal{O}}$ equals the outdegree of $v$ in $\mathcal{O}$.

                                          The reverse of an acyclic orientation is also acyclic.

                                          The orientation divisors of $\mathcal{O}$ and its reverse sum to the canonical divisor: $D(\mathcal{O}) + D(\overline{\mathcal{O}}) = K_G$.

                                          theorem edge_endpoints_distinct (G : CFGraph) (e : G.V × G.V) (he : e G.edges) :
                                          e.1 e.2

                                          Helper lemma: In a loopless graph, each edge has distinct endpoints

                                          theorem edge_incident_vertices_count (G : CFGraph) (e : G.V × G.V) (he : e G.edges) :
                                          {v : G.V | e.1 = v e.2 = v}.card = 2

                                          Helper lemma: Each edge is incident to exactly two vertices

                                          theorem map_inc_eq_map_two_nat (G : CFGraph) :
                                          (Multiset.map (fun (e : G.V × G.V) => {v : G.V | e.1 = v e.2 = v}.card) G.edges).sum = 2 * G.edges.card

                                          Helper lemma: Summing mapped incidence counts equals summing constant 2 (Nat version).

                                          theorem degree_eq_total_flow {T : Type u_1} [DecidableEq T] [Fintype T] (S : Multiset (T × T)) (v : T) :
                                          (∀ eS, e.1 e.2)u : T, (Multiset.filter (fun (e : T × T) => e = (v, u) e = (u, v)) S).card = (Multiset.filter (fun (e : T × T) => e.1 = v e.2 = v) S).card

                                          Helper lemma to rewrite (in-)degree in terms of edge counts from each direction. This proof is quite clunky, and I suspect it can be simplified.

                                          theorem sum_num_edges_eq_filter_count (G : CFGraph) (v : G.V) :
                                          u : G.V, num_edges G v u = (Multiset.filter (fun (e : G.V × G.V) => e.1 = v e.2 = v) G.edges).card
                                          theorem helper_sum_vertex_degrees (G : CFGraph) :
                                          v : G.V, vertex_degree G v = 2 * G.edges.card

                                          Handshaking Theorem: In a loopless multigraph (G), the sum of the degrees of all vertices is twice the number of edges:

                                          [ \sum_{v \in G.V} \deg(v) = 2 \cdot #(\text{edges of }G). ]

                                          The degree of the canonical divisor is $2g - 2$, where $g$ is the genus of $G$. This is [Corry-Perkinson], Exercise 5.8.

                                          Orientations from burn lists #

                                          Given a complete burn list L for a superstable configuration c, the function burn_orientation L h_full constructs an acyclic orientation of G with unique source q (burn_acyclic, burn_unique_source). Acyclicity is proved by showing that position in the burn list gives a strictly decreasing labeling along any directed path (dp_dec).

                                          The key lemma dp_dec formalizes this as a strict chain of natural numbers, and orientation_from_flow constructs a CFOrientation from an explicit flow function.

                                          def multiset_of_count {T : Type u_1} [DecidableEq T] [Fintype T] (f : T) :

                                          Create a multiset with a given count function. This is a thin wrapper around DFinsupp.toMultiset specialized to a finite type.

                                          Equations
                                          Instances For
                                            @[simp]
                                            theorem count_of_multiset_of_count {T : Type u_1} [DecidableEq T] [Fintype T] (f : T) (e : T) :
                                            def orientation_from_flow {G : CFGraph} (f : G.V × G.V) (h_count_preserving : ∀ (v w : G.V), f (v, w) + f (w, v) = num_edges G v w) (h_no_bidirectional : ∀ (v w : G.V), f (v, w) = 0 f (w, v) = 0) :

                                            Construct a CFOrientation from an explicit flow function, given proofs that it respects edge multiplicities and has no bidirectional edges.

                                            Equations
                                            Instances For
                                              def burn_orientation {G : CFGraph} {q : G.V} {c : Config G q} (L : burn_list G c) (h_full : ∀ (v : G.V), v L.list) :

                                              The orientation constructed from a complete burn list L for a superstable configuration, via burn_flow. This is shown to be acyclic with unique source $q$ by burn_acyclic and burn_unique_source.

                                              Equations
                                              Instances For
                                                theorem dp_dec {G : CFGraph} {q : G.V} {c : Config G q} (L : burn_list G c) (h_full : ∀ (v : G.V), v L.list) (p : DirectedPath (burn_orientation L h_full)) :
                                                List.IsChain (fun (x1 x2 : ) => x1 > x2) (List.map (fun (v : G.V) => List.idxOf v L.list) p.vertices)

                                                Along any directed path in burn_orientation L, the positions of vertices in the burn list are strictly decreasing. This is the key lemma for proving acyclicity.

                                                theorem burn_nodup {G : CFGraph} {q : G.V} {c : Config G q} (L : burn_list G c) (h_full : ∀ (v : G.V), v L.list) (p : DirectedPath (burn_orientation L h_full)) :

                                                Every directed path in burn_orientation L has no repeated vertices.

                                                theorem burn_acyclic {G : CFGraph} {q : G.V} {c : Config G q} (L : burn_list G c) (h_full : ∀ (v : G.V), v L.list) :

                                                The orientation constructed from a complete burn list is acyclic.

                                                theorem burn_unique_source {G : CFGraph} {q : G.V} {c : Config G q} (L : burn_list G c) (h_full : ∀ (v : G.V), v L.list) (w : G.V) :
                                                is_source G (burn_orientation L h_full) ww = q

                                                The orientation constructed from a complete burn list has $q$ as its unique source.

                                                theorem burn_acyclic_with_unique_source {G : CFGraph} {q : G.V} {c : Config G q} (L : burn_list G c) (h_full : ∀ (v : G.V), v L.list) :

                                                The orientation constructed from a complete burn list is acyclic with unique source q.

                                                The bijection between orientations and maximal superstable configurations #

                                                This section establishes [Corry-Perkinson], Theorem 4.8: there is a bijection between acyclic orientations with unique source $q$ and maximal superstable configurations.

                                                theorem superstable_dhar {G : CFGraph} {q : G.V} {c : Config G q} (h_ss : superstable G q c) :

                                                Theorem: Dhar's burning algorithm produces, from a superstable configuration, an orientation giving a maximal superstable above it.

                                                The configuration asssociated to an acyclic orientation with unique source is maximal superstable. [Corry-Perkinson], Theorem 4.8, part 1 (c(O) is maximal superstable)

                                                theorem maximal_superstable_exists (G : CFGraph) (q : G.V) (c : Config G q) (h_super : superstable G q c) :
                                                ∃ (c' : Config G q), maximal_superstable G c' c c'

                                                Every superstable configuration extends to a maximal superstable configuration

                                                theorem maximal_superstable_orientation (G : CFGraph) (q : G.V) (c : Config G q) (h_max : maximal_superstable G c) :

                                                Every maximal superstable configuration comes from an acyclic orientation [Corry-Perkinson], Theorem 4.8, part 2 (surjectivity)

                                                theorem orientation_superstable_bijection (G : CFGraph) (q : G.V) :
                                                let α := { O : CFOrientation G // acyclic_with_unique_source G O q }; let β := { c : Config G q // maximal_superstable G c }; let f_raw := fun (O_sub : α) => orientation_to_config G (↑O_sub) q ; have f := fun (O_sub : α) => f_raw O_sub, ; Function.Bijective f

                                                Proposition 4.1.11: Bijection between acyclic orientations with source q and maximal superstable configurations Corry-Perkinson], Theorem 4.8, part 3 (bijection)