CommuteTime.lean

Lean 4 source, lean/DataMiningAsObservation/CommuteTime.lean at commit bccca4f. Appendix C, Machine-checked statements, says what each file proves. All Lean files.

/-
CommuteTime.lean. Chapter 0 section 0.10 and equation 0.20, the commute time.

The commute time between two nodes is the hitting time there plus the hitting time back,
so it is symmetric and zero from a node to itself. The resistance of equation 0.20 is the
commute time divided by the graph's volume. Chapter 3 section 3.3 reads the collapse of that
resistance on large neighbourhood graphs to one over each degree, and the file states the
consequence the chapter draws, that the collapsed value depends on two nodes only through
their degrees and is the same for every pair of a regular graph.
-/
import Mathlib

namespace DMO.CommuteTime

variable {V : Type*}

/-- The commute time from hitting times `H`. -/
def commute (H : V → V → ℝ) (i j : V) : ℝ := H i j + H j i

/-- **The commute time is symmetric.** -/
theorem commute_symm (H : V → V → ℝ) (i j : V) : commute H i j = commute H j i := by
  unfold commute
  ring

/-- **The commute time from a node to itself is zero.** -/
theorem commute_self (H : V → V → ℝ) (i : V) (h : H i i = 0) : commute H i i = 0 := by
  simp [commute, h]

/-- The resistance, the commute time over the volume, as in equation 0.20. -/
noncomputable def resistance (vol : ℝ) (H : V → V → ℝ) (i j : V) : ℝ := commute H i j / vol

/-- **The resistance is symmetric.** -/
theorem resistance_symm (vol : ℝ) (H : V → V → ℝ) (i j : V) :
    resistance vol H i j = resistance vol H j i := by
  unfold resistance
  rw [commute_symm]

/-- **The commute time is the resistance times the volume.** -/
theorem commute_eq_resistance_mul (vol : ℝ) (hv : vol ≠ 0) (H : V → V → ℝ) (i j : V) :
    commute H i j = resistance vol H i j * vol := by
  unfold resistance
  rw [div_mul_cancel₀ _ hv]

/-- The collapsed resistance of chapter 3, one over each degree. -/
noncomputable def collapsed (d : V → ℝ) (i j : V) : ℝ := 1 / d i + 1 / d j

/-- **The collapsed resistance depends on two nodes only through their degrees.** -/
theorem collapsed_congr (d : V → ℝ) (i j i' j' : V) (hi : d i = d i') (hj : d j = d j') :
    collapsed d i j = collapsed d i' j' := by
  simp [collapsed, hi, hj]

/-- **On a regular graph the collapsed resistance is the same for every pair.** -/
theorem collapsed_const (d : V → ℝ) (c : ℝ) (h : ∀ v, d v = c) (i j i' j' : V) :
    collapsed d i j = collapsed d i' j' :=
  collapsed_congr d i j i' j' (by rw [h, h]) (by rw [h, h])

end DMO.CommuteTime