moonbit-proof

Writes and debugs proof-carrying MoonBit code with Why3-backed contracts, invariants, and proof assertions.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill moonbit-proof
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moonbit-proof
Source: https://github.com/golemcloud/golem/tree/main/.agents/skills/moonbit-proof
Command: npx skills add https://github.com/golemcloud/golem --skill moonbit-proof

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing formally verified MoonBit code requires coordinating abstract models, representation invariants, contracts, loop invariants, and solver guidance, and ad-hoc attempts often produce unprovable verification conditions or bloated trusted code. This Skill provides a disciplined workflow for structuring proof-carrying MoonBit packages so proofs actually go through.

Core Features & Use Cases

  • Structured proof design: Separates proof-side logic (models, invariants, lemmas) into .mbtp files from executable .mbt code with named *_pre / *_post contract predicates.
  • Solver guidance patterns: Provides concrete techniques for proof_assert placement, loop proof_invariant and proof_yield annotations, extensional equality lemmas for sets/maps, and staged concrete-update predicates for packed representations.
  • Proof debugging workflow: Classifies failures from moon prove output and _build/verif/<pkg>/<pkg>.proof.json into missing facts, bad quantifier instantiation, solver perturbation, or frontend lowering limits, with matching fixes.
  • Use Case: When implementing a verified sparse array or AVL tree in MoonBit, use this Skill to define the abstract model(...), keep the invariant small, write loop invariants early, and shrink trusted proof_axiomatized bridges step by step.

Quick Start

Use the moonbit-proof skill to add verified contracts and invariants to my MoonBit hash set implementation and get moon prove passing.

Frequently Asked Questions about moonbit-proof

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write verified MoonBit code with proof contracts?

Define an abstract model function and a small representation invariant in a .mbtp file, then attach named *_pre and *_post predicates to executable functions in .mbt. Add proof_assert steps after construction and branching, and give every proof-relevant loop explicit proof_invariant annotations.

How to debug moon prove failures and timeouts?

Run moon prove <pkg> and inspect _build/verif/<pkg>/<pkg>.proof.json to classify the failure. Missing index facts need local proof_assert steps, missing model bridges need helper lemmas, solver perturbation may require moving lemmas out of shared shims, and lowering limits need a smaller reproducer.

What is the difference between .mbt and .mbtp files in MoonBit proofs?

The .mbtp file holds proof-side material such as model functions, predicates, and lemmas, while the .mbt file holds executable runtime code with contracts and local proof_assert steps. Keeping this split prevents proof logic from polluting runtime code.

When should I use proof_axiomatized trusted functions in MoonBit?

Use proof_axiomatized only as a narrow temporary bridge with concrete preconditions targeting one named predicate, keeping the mathematical statement in .mbtp. Remove trusted bridges in order: constructors first, then observers, update functions, and primitive machine-word bridges.

How do I prove loops correct in MoonBit verification?

Annotate proof-relevant loops with proof_invariant clauses covering index bounds, the relation between the accumulator and the abstract model, and prefix or suffix copy facts. Add proof_yield when the proof needs a fact about the value produced by the whole loop expression.