Verified dynamic programming with Σ-types in Lean