Skip to content

feat(ch25): complete Johnson's algorithm — potential, triangle inequality, end-to-end correctness - #115

Merged
TankTechnology merged 1 commit into
mainfrom
feat/ch25-johnson-completion
Jul 22, 2026
Merged

feat(ch25): complete Johnson's algorithm — potential, triangle inequality, end-to-end correctness#115
TankTechnology merged 1 commit into
mainfrom
feat/ch25-johnson-completion

Conversation

@TankTechnology

Copy link
Copy Markdown
Owner

Summary

Completes Section 25.3 (Johnson's Algorithm), filling the last remaining gaps in Chapter 25.

What's new

12 new definitions/theorems (~350 lines of Lean):

Negative-cycle equivalence for the augmented graph

  • adj_target_ne_none — no edge in the augmented graph targets none
  • chain_no_none — chains not starting at none never contain none
  • walk_from_none_to_none_singleton — the only none→none walk is [none]
  • noNegCycle_johnsonAugmentedGraph — G has no negative cycles iff G' has none

Walk projection (G' → G)

  • chain_none_free_map — lift a none-free chain from G' to G
  • walkWeight_none_free_eq — corresponding walk weights agree
  • exists_walk_in_G_of_none_free_walk — project walks back to G

Walk extension utilities (reusable beyond Ch25)

  • IsWalkFrom.append_step — extend a walk by a single edge at the end
  • walkWeight_append_step — weight formula for extended walks

Johnson potential

  • isWalkFrom_none_some — direct edge none → some v
  • relaxDist_none_some_ne_top — distance finiteness
  • johnsonPotentialh(v) = δ(none, some v) via Bellman-Ford
  • johnsonPotential_triangleh(v) ≤ h(u) + w(u,v) for every edge

End-to-end correctness

  • reweightedGraph_nonneg / reweightedGraph_noNegCycle
  • johnsonDist — Johnson's all-pairs shortest-path distance
  • johnsonDist_isShortestDist — CLRS Theorem 25.5

Chapter 25 status

Section Status
25.1 All-Pairs Model ✅ Complete
25.2 Floyd-Warshall ✅ Complete (incl. path-reconstruction weight equality, #114)
25.3 Johnson's Algorithm ✅ Complete (this PR)

0 sorry, full lake build and check_repository.py pass.

Closes #32, closes #104

🤖 Generated with Claude Code

…lity, end-to-end correctness

- Add Bellman-Ford potential construction h(v) = δ(none, some v)
  via augmented graph with noNegCycle_johnsonAugmentedGraph lemma
- Prove triangle inequality h(v) ≤ h(u) + w(u, v) for every edge
- Prove reweighted graph edge nonnegativity (Dijkstra precondition)
- Prove end-to-end Johnson correctness theorem johnsonDist_isShortestDist
  (CLRS Theorem 25.5)
- Add generic walk-extension lemmas (append_step, walkWeight_append_step)
- Add walk-projection infrastructure (chain_none_free_map,
  walkWeight_none_free_eq, exists_walk_in_G_of_none_free_walk)
- Update chapter guide to reflect completion of Sections 25.2 and 25.3
- Update progress CSV to track completed theorems

Closes #32, closes #104

Co-Authored-By: Claude <noreply@anthropic.com>
@TankTechnology
TankTechnology merged commit 2080869 into main Jul 22, 2026
0 of 2 checks passed
@TankTechnology
TankTechnology deleted the feat/ch25-johnson-completion branch July 22, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant