Skip to content

[WIP] feat: port SatisfiesM lemmas to mvcgen#1649

Closed
cmlsharp wants to merge 8 commits intoleanprover-community:mainfrom
cmlsharp:mvcgen
Closed

[WIP] feat: port SatisfiesM lemmas to mvcgen#1649
cmlsharp wants to merge 8 commits intoleanprover-community:mainfrom
cmlsharp:mvcgen

Conversation

@cmlsharp
Copy link
Copy Markdown
Contributor

@cmlsharp cmlsharp commented Feb 2, 2026

Per this Zulip thread there is interest in porting the existing SatisfiesM theorems to mvcgen. This PR begins this progress (still WIP). Thus far I have specs for List/Array mapM, anyM, and mapFinIdx as well as a few lemmas about them.

I'm still learning mvcgen myself, so it is highly likely even these proofs could be tightened up.

@cmlsharp
Copy link
Copy Markdown
Contributor Author

cmlsharp commented Feb 2, 2026

WIP

@cmlsharp cmlsharp marked this pull request as draft February 2, 2026 16:39
@github-actions github-actions bot added awaiting-review This PR is ready for review; the author thinks it is ready to be merged. WIP work in progress and removed awaiting-review This PR is ready for review; the author thinks it is ready to be merged. labels Feb 2, 2026
set_option mvcgen.warning false

@[spec]
theorem Spec.mapM_array {α β : Type w} [Monad m] [LawfulMonad m] [WPMonad m ps]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WPMonad extends LawfulMonad

Suggested change
theorem Spec.mapM_array {α β : Type w} [Monad m] [LawfulMonad m] [WPMonad m ps]
theorem Spec.mapM_array {α β : Type w} [Monad m] [WPMonad m ps]

Comment on lines +38 to +40
{tru : Assertion ps}
{fal : xs.toList.Cursor → Assertion ps}
{exc : ExceptConds ps}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you express this property in terms of {inv : Invariant xs.toList Bool ps}? The reason is that Invariant has special support in mvcgen so that it won't be accidentally instantiated when trying to discharge VCs by rfl.

⦃⌜True⌝⦄ f i xs[i] h ⦃(fun b => ⌜p i b h ∧ motive (i + 1)⌝, exc)⦄) :
⦃⌜True⌝⦄
xs.mapFinIdxM f
⦃(fun bs => ⌜motive xs.size ∧ ∃ eq : bs.size = xs.size, ∀ i h, p i bs[i] h⌝, exc)⦄ := by
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the spec and the attached @[spec] attribute suggest to me that it should allow a similarly general invariant as that for Spec.mapM

@cmlsharp cmlsharp closed this Feb 8, 2026
@github-actions github-actions bot removed the WIP work in progress label Feb 8, 2026
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.

2 participants