The Königsberg bridges problem #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
We show that a graph that represents the islands and mainlands of Königsberg and seven bridges between them has no Eulerian trail.
- V1 : konigsberg.verts
- V2 : konigsberg.verts
- V3 : konigsberg.verts
- V4 : konigsberg.verts
- B1 : konigsberg.verts
- B2 : konigsberg.verts
- B3 : konigsberg.verts
- B4 : konigsberg.verts
- B5 : konigsberg.verts
- B6 : konigsberg.verts
- B7 : konigsberg.verts
The vertices for the Königsberg graph; four vertices for the bodies of land and seven vertices for the bridges.
Instances for konigsberg.verts
- konigsberg.verts.has_sizeof_inst
- konigsberg.verts.fintype
Each of the connections between the islands/mainlands and the bridges.
These are ordered pairs, but the data becomes symmetric in konigsberg.adj
.
Equations
- konigsberg.edges = [(konigsberg.verts.V1, konigsberg.verts.B1), (konigsberg.verts.V1, konigsberg.verts.B2), (konigsberg.verts.V1, konigsberg.verts.B3), (konigsberg.verts.V1, konigsberg.verts.B4), (konigsberg.verts.V1, konigsberg.verts.B5), (konigsberg.verts.B1, konigsberg.verts.V2), (konigsberg.verts.B2, konigsberg.verts.V2), (konigsberg.verts.B3, konigsberg.verts.V4), (konigsberg.verts.B4, konigsberg.verts.V3), (konigsberg.verts.B5, konigsberg.verts.V3), (konigsberg.verts.V2, konigsberg.verts.B6), (konigsberg.verts.B6, konigsberg.verts.V4), (konigsberg.verts.V3, konigsberg.verts.B7), (konigsberg.verts.B7, konigsberg.verts.V4)]
The adjacency relation for the Königsberg graph.
Equations
- konigsberg.adj v w = decidable.to_bool ((v, w) ∈ konigsberg.edges) || decidable.to_bool ((w, v) ∈ konigsberg.edges)
The Königsberg graph structure. While the Königsberg bridge problem is usually described using a multigraph, the we use a "mediant" construction to transform it into a simple graph -- every edge in the multigraph is subdivided into a path of two edges. This construction preserves whether a graph is Eulerian.
(TODO: once mathlib has multigraphs, either prove the mediant construction preserves the Eulerian property or switch this file to use multigraphs.
Equations
- konigsberg.graph = {adj := λ (v w : konigsberg.verts), ↥(konigsberg.adj v w), symm := konigsberg.graph._proof_1, loopless := konigsberg.graph._proof_2}
Equations
- konigsberg.adj.decidable_rel = λ (a b : konigsberg.verts), decidable_of_bool (konigsberg.adj a b) _
To speed up the proof, this is a cache of all the degrees of each vertex,
proved in konigsberg.degree_eq_degree
.
Equations
- konigsberg.degree konigsberg.verts.B7 = 2
- konigsberg.degree konigsberg.verts.B6 = 2
- konigsberg.degree konigsberg.verts.B5 = 2
- konigsberg.degree konigsberg.verts.B4 = 2
- konigsberg.degree konigsberg.verts.B3 = 2
- konigsberg.degree konigsberg.verts.B2 = 2
- konigsberg.degree konigsberg.verts.B1 = 2
- konigsberg.degree konigsberg.verts.V4 = 3
- konigsberg.degree konigsberg.verts.V3 = 3
- konigsberg.degree konigsberg.verts.V2 = 3
- konigsberg.degree konigsberg.verts.V1 = 5
The Königsberg graph is not Eulerian.