Skip to content

fix: report a missing spec for an un-steppable vcgen program head - #14688

Open
sgraf812 wants to merge 2 commits into
leanprover:masterfrom
sgraf812:sg/vcgen-liftm-loop-fix
Open

fix: report a missing spec for an un-steppable vcgen program head#14688
sgraf812 wants to merge 2 commits into
leanprover:masterfrom
sgraf812:sg/vcgen-liftm-loop-fix

Conversation

@sgraf812

@sgraf812 sgraf812 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This PR makes vcgen report No spec found for program … when the program head is one that no strategy steps and no spec keys on, such as the bare fun s => … left by unfolding a liftM of an anonymous state transformer. Previously this failed with Failed to decompose weakest precondition … This should not happen.

When `vcgen`'s program-shape phase reaches a `wp⟦e⟧` whose program `e` has a
head that no strategy steps and no spec keys on, report it as a missing spec,
the result `findSpec` already returns for a constant head with no registered
spec, rather than a hard "This should not happen" failure.

Unfolding `liftMach c = liftM (fun s => match c s.machine with …)` reaches this
case: the `monadLift` spec chain rewrites the lift down to the bare anonymous
state transformer `fun s => match c s.machine with …`, whose head is a lambda.

  abbrev Base := EStateM Unit Nat
  abbrev M := ReaderT Unit (StateT Unit (EStateM Unit Sys))
  def liftMach {α} (c : Base α) : M α :=
    liftM (m := EStateM Unit Sys) (fun s => match c s.machine with
      | .ok a m => .ok a { s with machine := m }
      | .error e m => .error e { s with machine := m })
  def prog : M Unit := do let v ← liftMach (get : Base Nat); liftMach (set v)
  theorem prog_spec : ⦃ fun r n s => Q () r n s ⦄ prog ⦃ Q; E ⦄ := by
    vcgen [prog, liftMach]   -- No spec found for program fun s => match …
@sgraf812
sgraf812 force-pushed the sg/vcgen-liftm-loop-fix branch from 7b1191c to 3b56da8 Compare August 7, 2026 18:08
@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 Aug 7, 2026
@mathlib-lean-pr-testing

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 87e7204456bfca901bdc724c996030e13c2f80c6 --onto bd97ed8e35639e17a11d1490cbc46d994e7b4513. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-07 18:35:40)

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 87e7204456bfca901bdc724c996030e13c2f80c6 --onto c4e6b62c3d955ef20da94310797072f7c4c5fa2b. You can force reference manual CI using the force-manual-ci label. (2026-08-07 18:35:41)

@sgraf812
sgraf812 marked this pull request as ready for review August 11, 2026 07:40
@sgraf812
sgraf812 enabled auto-merge August 11, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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