/-- Prove that detailed balance implies stationarity.
Hints: `funext j`, unfold `vecMul` and `dotProduct`, rewrite each term with `hdb _ j`, then pull
`π j` out of the sum (`← mul_sum`) and use the row sum of row `j`. -/
theorem detailed_balance_stationary {P : Matrix S S ℝ} (hrow : ∀ i, ∑ j, P i j = 1)
{π : S → ℝ} (hdb : ∀ i j, π i * P i j = π j * P j i) : π ᵥ* P = π := by
sorryShow the compiled solution
/-- **Detailed balance implies stationarity.** If `πᵢ Pᵢⱼ = πⱼ Pⱼᵢ` for all states (the flow
of probability from `i` to `j` equals the flow back), and the rows of `P` sum to `1`, then
`π P = π`. Proof: `(πP)ⱼ = ∑ᵢ πᵢ Pᵢⱼ = ∑ᵢ πⱼ Pⱼᵢ = πⱼ ∑ᵢ Pⱼᵢ = πⱼ`. -/
theorem detailed_balance_stationary {P : Matrix S S ℝ} (hrow : ∀ i, ∑ j, P i j = 1)
{π : S → ℝ} (hdb : ∀ i j, π i * P i j = π j * P j i) : π ᵥ* P = π := by
funext j
simp only [vecMul, dotProduct]
simp_rw [hdb _ j]
rw [← mul_sum, hrow j, mul_one]Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/MarkovChains.leanTry it in the Lean web editor