Skip to content

feat(ch25): complete Johnson's algorithm — end-to-end correctness (#104) - #113

Closed
TankTechnology wants to merge 2 commits into
mainfrom
feat/johnson-algorithm-issue-104
Closed

feat(ch25): complete Johnson's algorithm — end-to-end correctness (#104)#113
TankTechnology wants to merge 2 commits into
mainfrom
feat/johnson-algorithm-issue-104

Conversation

@TankTechnology

Copy link
Copy Markdown
Owner

Summary

Completes Johnson's algorithm for all-pairs shortest paths (Issue #104).

New definitions

  • johnsonAugmentedGraph: augmented graph with new source none and zero-weight edges to all vertices
  • reweightedWeight / reweightedGraph: reweighting with a potential function h
  • johnsonPotential: Bellman-Ford potential h(v) = δ(none, some v)
  • johnsonAllPairsDist: end-to-end Johnson distance function

New theorems

Theorem CLRS reference
isShortestDist_edge_ineq General triangle inequality
walk_johnsonAugmented_some_projection Walk projection from augmented graph
noNegCycle_johnsonAugmentedGraph Negative-cycle preservation
reweightedWalkWeight_eq Telescoping property (Equation 25.10)
reweightedWeight_nonneg Nonnegative reweighted weights
reweighted_isShortestDist Shortest-path preservation (shift formula)
johnsonPotential_finite Potential is always finite
johnsonPotential_isShortestDist Potential satisfies IsShortestDist
johnsonPotential_triangle Lemma 25.3: h(v) ≤ h(u) + w(u,v)
johnsonReweightedNonneg Reweighted graph is nonnegative
johnsonAllPairsDist_correct Theorem 25.6: End-to-end correctness

Proof structure

  1. Add none source with 0-weight edges → augmented graph
  2. Prove no negative cycles are introduced (projection lemma + case analysis)
  3. Run Bellman-Ford from none on augmented graph → potential h
  4. Prove h satisfies triangle inequality (Lemma 25.3) via isShortestDist_edge_ineq
  5. Reweight graph with h → nonnegative weights → Dijkstra applies
  6. Run Dijkstra from each vertex → recover true distances via shift formula (Theorem 25.6)

Bookkeeping

  • docs/proof-map.md: Section 25.3 status partialproved
  • docs/clrs-proof-progress.csv: Ch25 partialmain-proof-complete, missing groups 2 → 1
  • Module doc comment updated to list all theorems

Closes #104

🤖 Generated with Claude Code

TankTechnology and others added 2 commits July 22, 2026 21:04
…sue #104)

Add the full Johnson algorithm implementation for all-pairs shortest paths:

- isShortestDist_edge_ineq: general triangle inequality for shortest-path distances
- walk_johnsonAugmented_some_projection: project walks from augmented graph to original
- noNegCycle_johnsonAugmentedGraph: negative-cycle preservation in augmented graph
- johnsonPotential: Bellman-Ford potential h(v) = δ(none, some v)
- johnsonPotential_finite: the potential is always finite
- johnsonPotential_isShortestDist: potential satisfies IsShortestDist
- johnsonPotential_triangle: h(v) ≤ h(u) + w(u,v) for every edge (CLRS Lemma 25.3)
- johnsonReweightedNonneg: reweighted graph has nonnegative weights
- johnsonAllPairsDist: end-to-end Johnson distance function
- johnsonAllPairsDist_correct: correctness theorem (CLRS Theorem 25.6)

Update proof-map.md: Section 25.3 status partial → proved.
Update clrs-proof-progress.csv: Ch25 status partial → main-proof-complete,
missing core groups 2 → 1.

Co-Authored-By: Claude <noreply@anthropic.com>
Add doc comments for johnsonPotential, johnsonPotential_eq, and
johnsonPotential_isShortestDist.

Co-Authored-By: Claude <noreply@anthropic.com>
@TankTechnology

Copy link
Copy Markdown
Owner Author

Closed as duplicate development: the same Johnson end-to-end correctness work was merged via #115 on 2026-07-23 (johnsonDist_isShortestDist, Theorem 25.5). The unique content of this PR — johnsonAllPairsDist_correct (Theorem 25.6), isShortestDist_edge_ineq, walk_johnsonAugmented_some_projection, johnsonPotential_finite, johnsonReweightedNonneg — was transplanted to main in commit b4c697f and compiles against the existing declarations. Thank you for the work.

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
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

Development

Successfully merging this pull request may close these issues.

Ch25.3: Johnson end-to-end — |V|×Dijkstra wrapper and O(VE log V) correctness

1 participant