Degree.lean
Lean 4 source, lean/DataMiningAsObservation/Degree.lean at commit bccca4f. Appendix C, Machine-checked statements, says what each file proves. All Lean files.
/-
Degree.lean. Chapter 0 section 0.10, the degree of a node.
The degree of a node is the number of edges it has. Summed over the graph the degrees count
every edge twice, which is the handshake lemma, and no node has degree more than the number
of other nodes. The file takes both from Mathlib's simple graphs. Chapter 3 measures that
the radius of a spectral embedding tracks the degree, which stays a measurement.
-/
import Mathlib
namespace DMO.Degree
variable {V : Type*} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj]
/-- **The handshake lemma.** The degrees sum to twice the number of edges. -/
theorem sum_degrees : ∑ v, G.degree v = 2 * G.edgeFinset.card :=
SimpleGraph.sum_degrees_eq_twice_card_edges G
/-- **No node has degree more than the number of other nodes.** -/
theorem degree_lt_card [Nonempty V] (v : V) : G.degree v < Fintype.card V :=
SimpleGraph.degree_lt_card_verts v
/-- **The degree sum is even.** -/
theorem sum_degrees_even : Even (∑ v, G.degree v) := by
rw [sum_degrees]
exact even_two_mul _
/-- The average degree is twice the edge count over the node count. -/
theorem average_degree [Nonempty V] :
(∑ v, G.degree v : ℝ) / Fintype.card V = 2 * G.edgeFinset.card / Fintype.card V := by
have h := sum_degrees G
rw [← Nat.cast_sum, h]
push_cast
ring
end DMO.Degree