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
TankTechnology added a commit that referenced this pull request Aug 1, 2026
PR #113 (feat/johnson-algorithm-issue-104) was developed in parallel with
PR #115 (already on main) and shares 11 declarations with it, so it could
not be merged as-is.  This commit transplants its unique content:

- johnsonAllPairsDist_correct: CLRS Theorem 25.6, Johnson's algorithm
  computes all-pairs shortest distances via Dijkstra (main only had the
  Theorem 25.5 end-to-end statement)
- isShortestDist_edge_ineq: general triangle inequality for shortest-path
  distances (no sign assumptions)
- walk_johnsonAugmented_some_projection: augmented-graph walks project to
  original-graph walks with the same weight
- edge_target_some, johnsonPotential_finite, johnsonReweightedNonneg

The transplanted theorems compile against main's declarations (identical
signatures for johnsonPotential, johnsonPotential_triangle, etc.).
Proof-map and CSV updated (24/24); Progress.lean regenerated.

Co-Authored-By: Claude <noreply@anthropic.com>
TankTechnology added a commit that referenced this pull request Aug 1, 2026
Completes Section 25.3 with Bellman-Ford potential construction, triangle inequality, reweighted edge nonnegativity, and end-to-end Johnson correctness (CLRS Theorem 25.5).

- Add noNegCycle_johnsonAugmentedGraph lemma for augmented graph
- Construct johnsonPotential h(v) = δ(none, some v) via Bellman-Ford
- Prove triangle inequality h(v) ≤ h(u) + w(u,v) for every edge
- Prove reweightedGraph_nonneg (Dijkstra precondition)
- Prove end-to-end johnsonDist_isShortestDist (CLRS Theorem 25.5)
- Add generic walk-extension lemmas (append_step, walkWeight_append_step)
- Add walk-projection infrastructure for none-free walks
- Update chapter guide and progress CSV
- All 3 sections of Chapter 25 are now core-complete (0 sorry)

Closes #32, closes #104

🤖 Generated with [Claude Code](https://claude.com/claude-code)
TankTechnology added a commit that referenced this pull request Aug 1, 2026
PR #113 (feat/johnson-algorithm-issue-104) was developed in parallel with
PR #115 (already on main) and shares 11 declarations with it, so it could
not be merged as-is.  This commit transplants its unique content:

- johnsonAllPairsDist_correct: CLRS Theorem 25.6, Johnson's algorithm
  computes all-pairs shortest distances via Dijkstra (main only had the
  Theorem 25.5 end-to-end statement)
- isShortestDist_edge_ineq: general triangle inequality for shortest-path
  distances (no sign assumptions)
- walk_johnsonAugmented_some_projection: augmented-graph walks project to
  original-graph walks with the same weight
- edge_target_some, johnsonPotential_finite, johnsonReweightedNonneg

The transplanted theorems compile against main's declarations (identical
signatures for johnsonPotential, johnsonPotential_triangle, etc.).
Proof-map and CSV updated (24/24); Progress.lean regenerated.

Co-Authored-By: Claude <noreply@anthropic.com>
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