Repository navigation
feat: trait-level specs - #85
Draft
clementblaudeau wants to merge 17 commits into
Draft
clementblaudeau wants to merge 17 commits into
clementblaudeau wants to merge 17 commits into
Conversation
clementblaudeau
added this pull request to stack #78
October 14, 2026 14:49
clementblaudeau
force-pushed
the
add-trait-specs
branch
from
October 23, 2026 13:18
818b3fa to
5d600b8
Compare
- Mismatch with the number of generics cause the method to be dropped with a warning instead of an internal error. - Dropping warnings no longer escape under -warnings-as-errors (error, exit 1). - One failing spec or obligation no longer aborts the rest of the file. - Impl obligations of an untranslated trait are skipped with a warning. - Lawful field names are reserved before the trait generics. - Tests: the 5 synthesized.rs traits that now extract (contracts dropped), naming.rs lawful_field; the BUG block narrowed to AssocGen and SubBoth.
- Const-generic trait (two impls, [u32; N] blanket impl, generic caller), trait implemented from another module, impl Trait argument, where-clause impl, two impls of a generic trait, projection bound, inherent method of a generic impl, impl for a reference; with their proofs. - Regression test that -specs hax requires -core-models-lib; the error no longer prints the usage text, so its message is checked.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR extends the support for rust written specs (via
hax_libannotations) by adding trait-level specs. On the lean side, traits definitions (represented as structures) get a companion "lawful" structure that states the properties. Downstream, callers rely on Lawful as an assumption, and each impl proves its own Lawful theorem.Example
Trait contract (Specs.lean): the conditions become pre/post functions, and the Lawful structure says that every implementation satisfies them.
Review
The detailed documentation is in
documentation/hax-specs.md. A large chunk of the diff comes from test files and lean output. The changes to the ml engine are somewhat small and contained.