Skip to content

feat: verifiable whileM via ordered fixpoints for stronger specs#13689

Merged
sgraf812 merged 2 commits into
masterfrom
sg/whileM-partial-fixpoint
May 26, 2026
Merged

feat: verifiable whileM via ordered fixpoints for stronger specs#13689
sgraf812 merged 2 commits into
masterfrom
sg/whileM-partial-fixpoint

Conversation

@sgraf812
Copy link
Copy Markdown
Contributor

@sgraf812 sgraf812 commented May 8, 2026

This PR makes the unfolding lemma for whileM derivable from a Lean.Order.MonadTail instance. The public entry point is whileM_eq_of_monadTail in Init.Internal.Order.While; the underlying pinning predicate whileM.Pred and the conditional whileM_eq lemma in Init.While are kept module-internal.

The state-aware Spec.whileM and Spec.forIn_loop in Std.Do.Triple.SpecLemmas use the same WhileInvariant α β ps for expressing termination measures. WPAdequate and the supporting Ensures/MayReturn machinery move to Std.Do.WP.Adequate and Std.Do.Internal.Ensures.

@sgraf812 sgraf812 added the changelog-library Library label May 8, 2026
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label May 8, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

mathlib-lean-pr-testing Bot commented May 8, 2026

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 79659457fb0377da019c274eb58e5de2ff95d9d0 --onto 5d5642107d0433519265f155ddbfbfb98007a80b. You can force Mathlib CI using the force-mathlib-ci label. (2026-05-08 11:36:04)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 79659457fb0377da019c274eb58e5de2ff95d9d0 --onto 2cd98639c40d2d2a026dd599093b70f55f55ffaf. You can force Mathlib CI using the force-mathlib-ci label. (2026-05-25 14:54:20)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

leanprover-bot commented May 8, 2026

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 79659457fb0377da019c274eb58e5de2ff95d9d0 --onto 5d5642107d0433519265f155ddbfbfb98007a80b. You can force reference manual CI using the force-manual-ci label. (2026-05-08 11:36:06)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 79659457fb0377da019c274eb58e5de2ff95d9d0 --onto 803553a556fd82fa1060efb0c43eda542130cb16. You can force reference manual CI using the force-manual-ci label. (2026-05-25 14:54:21)

@sgraf812 sgraf812 force-pushed the sg/whileM-partial-fixpoint branch 2 times, most recently from eaf161e to f33b479 Compare May 25, 2026 20:52
@sgraf812 sgraf812 marked this pull request as ready for review May 25, 2026 20:53
@sgraf812 sgraf812 force-pushed the sg/whileM-partial-fixpoint branch from f33b479 to 1f9a595 Compare May 25, 2026 21:14
@sgraf812 sgraf812 requested a review from TwoFX as a code owner May 25, 2026 21:14
This PR makes the unfolding lemma for `whileM` derivable from a
`Lean.Order.MonadTail` instance instead of `MonadAttach`/`Acc`. The
public entry point is `whileM_eq_of_monadTail` in
`Init.Internal.Order.While`; the underlying pinning predicate
`whileM.Pred` and the conditional `whileM_eq` lemma in `Init.While` are
kept module-internal.

The state-aware `Spec.whileM` and `Spec.forIn_loop` in
`Std.Do.Triple.SpecLemmas` use the same `WhileInvariant α β ps` cursor
over `α ⊕ β`. `WPAdequate` and the supporting `Ensures`/`MayReturn`
machinery move to `Std.Do.WP.Adequate` and `Std.Do.Internal.Ensures`.
@sgraf812 sgraf812 enabled auto-merge May 25, 2026 21:16
# Conflicts:
#	src/Std/Do/Triple/SpecLemmas.lean
@sgraf812 sgraf812 force-pushed the sg/whileM-partial-fixpoint branch from 1f9a595 to bac7026 Compare May 26, 2026 07:30
@sgraf812 sgraf812 added this pull request to the merge queue May 26, 2026
Merged via the queue into master with commit f3e3c0c May 26, 2026
16 checks passed
@sgraf812 sgraf812 deleted the sg/whileM-partial-fixpoint branch May 26, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants