feat(ch25): complete Floyd-Warshall path-reconstruction weight equality - #114
Merged
Conversation
Prove that the path reconstructed from the final predecessor matrix floydWarshallPi has weight exactly floydWarshall i j. New lemmas: - D_diag_eq_zero: diagonal of D is zero under NoNegCycle - Pi_D_ge: optimal-substructure lower bound D(i,k)+w(k,j) ≤ D(i,j) - floydWarshallPi_D_eq: equality floydWarshall i j = floydWarshall i k + w(k,j) - reconstructPathFuel_isWalkFrom: reconstructed path is a valid walk - reconstructPathFuel_weight_eq: reconstructed path weight equals floydWarshall The key insight is Pi_D_ge — it proves only the lower-bound direction by induction on ks, using min_le_left/min_le_right from the D recurrence and entirely avoiding the difficult D-edge inequality. The upper bound comes from the existing isShortestDist_edge_ineq. Together they give equality for the final matrices. Resolves the path-reconstruction gap in issue #95. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prove that the path reconstructed from the final Floyd-Warshall predecessor matrix
floydWarshallPihas weight exactlyfloydWarshall i j. This resolves the path-reconstruction weight-equality gap tracked in issue #95.New lemmas
D_diag_eq_zero— UnderNoNegCycle,D ks i i = 0for any intermediate setks.Pi_D_ge— Optimal-substructure lower bound: ifPi ks i j = some kwithi ≠ j, thenD ks i k + w(k,j) ≤ D ks i j. Proved by induction onksusing onlymin_le_left/min_le_rightfrom the D recurrence — avoids the difficult D-edge inequality entirely.isShortestDist_edge_ineq— Edge inequality for shortest-path distances:δ(v) ≤ δ(u) + w(u,v).floydWarshallPi_D_eq— Equality for the final matrices:floydWarshall i j = floydWarshall i k + w(k,j). CombinesPi_D_ge(lower bound) withisShortestDist_edge_ineq(upper bound).reconstructPathFuel_isWalkFrom— The reconstructed path is a valid walk.reconstructPathFuel_weight_eq— Main result: the reconstructed path has weightfloydWarshall i j.Key insight
The equality is proved by separating the optimal-substructure argument into two independent bounds:
Pi_D_ge): uses only the algebraicminstructure of the DP recurrenceisShortestDist_edge_ineq): uses the existingIsShortestDistproperty of the final Floyd-Warshall matricesNo D-edge inequality or semantic walk-through-
kslemma is required.Verification
Closes #95.
🤖 Generated with Claude Code