ProofAtlas

Resistance distance

The effective resistance distance on a hypergraph is the oldest and best-behaved of the four candidates: it has a closed-form spectral expression, satisfies the metric axioms unconditionally, and is monotone under hyperedge addition. It is the only metric currently sorry-free.

Definition

Pick a conductance schedule κ:E×V×VR0\kappa : E \times V \times V \to \mathbb{R}_{\ge 0} (see below). The associated weighted Laplacian is Lκ=DAL_\kappa = D - A where Au,v=eκ(e,u,v)A_{u,v} = \sum_e \kappa(e, u, v) is the total conductance between uu and vv and DD is its row-sum diagonal. Write Lκ+L_\kappa^+ for the Moore–Penrose pseudoinverse.

The resistance distance between u,vVu, v \in V is

dH(u,v)  =  (euev)Lκ+(euev)  =  Lκ+[u,u]+Lκ+[v,v]2Lκ+[u,v].d_H(u, v) \;=\; (e_u - e_v)^{\top} \, L_\kappa^{+} \, (e_u - e_v) \;=\; L_\kappa^{+}[u,u] + L_\kappa^{+}[v,v] - 2 L_\kappa^{+}[u,v].

Here euRVe_u \in \mathbb{R}^V is the standard basis vector at uu.

Why this is a distance

Three properties drop out of the spectral formula directly:

  • dH(u,u)=0d_H(u, u) = 0: the vector eueu=0e_u - e_u = 0 kills the quadratic form.
  • Symmetry: Lκ+L_\kappa^+ is symmetric (it's a pseudoinverse of a symmetric matrix).
  • Non-negativity: LκL_\kappa is positive semidefinite (it's a weighted Laplacian), and so is its pseudoinverse, so the quadratic form is 0\ge 0.

Triangle inequality is harder; the proof routes through the Klein–Randić formulation — see Metric/Resistance/Algebraic.lean.

Intuition: how hard is it to cut the connection?

Treat each hyperedge as a resistor network with conductance κ(e,u,v)\kappa(e, u, v) between every incident pair. Then dH(u,v)d_H(u, v) is literally the electrical resistance of the resulting circuit between terminals uu and vv.

That makes the inequality

dH(u,v)    (any unweighted path length between u and v)d_H(u, v) \;\le\; (\text{any unweighted path length between } u \text{ and } v)

obvious. It also explains why two vertices in a densely-connected hyperedge cluster are close (many parallel resistors) while two vertices joined by a long thin chain are far (resistors in series).

Conductance from hyperedges

The conductance comes from the harmonic schedule

κ(e,u,v)  =  α(c(e))(iu+1)out(e)\kappa(e, u, v) \;=\; \frac{\alpha(c(e))}{(i_u + 1) \cdot |\mathrm{out}(e)|}

when uu is the iui_u-th input of ee and vv is an output of ee; symmetrised by adding κ(e,v,u)\kappa(e, v, u). The α(c)\alpha(c) factor weights edges by colour, the 1/(i+1)1/(i+1) factor enforces input monotonicity (the first input carries more weight than the last), and dividing by out(e)|\mathrm{out}(e)| spreads the weight uniformly across outputs.

Rayleigh monotonicity

Adding a hyperedge can only decrease every pairwise distance:

HH    dH(u,v)dH(u,v)for all u,v.H' \supseteq H \implies d_{H'}(u, v) \le d_H(u, v) \quad \text{for all } u, v.

Operationally: adding an inference rule can only make two propositions closer together. This is the discrete analogue of the classical electrical fact that adding a resistor in parallel reduces total resistance.

The corollary that drives the headline pitch: hypergraph resistance distance is a non-increasing function of mathematical knowledge.

In the compute layer

Pipeline/Linalg.lean implements the resistance matrix end-to-end in Float:

def IncidenceData.resistanceMatrix (H : IncidenceData) : Array (Array Float)

The pseudoinverse is computed via Gauss–Jordan on Lκ+εIL_\kappa + \varepsilon I with ε=109\varepsilon = 10^{-9} — the regularisation cancels in the final L+[u,u]+L+[v,v]2L+[u,v]L^+[u,u] + L^+[v,v] - 2 L^+[u,v] difference up to floating-point noise. This is the formula evaluated when you run #atlas.resistance.

Try it

#atlas.resistance Nat.add_zero Nat.add_comm glues both proofs via const-sharing and reports dH(rootA,rootB)d_H(\text{root}_A, \text{root}_B).

References

[BDF26] §5.1 — resistance distance on hypergraphs.
[KR93] Klein, Randić, Resistance distance, J. Math. Chem. 12, 1993.