Repository navigation
feat: trait-level specs - #85
Draft
clementblaudeau wants to merge 18 commits into
Draft
clementblaudeau wants to merge 18 commits into
clementblaudeau wants to merge 18 commits into
Conversation
clementblaudeau
force-pushed
the
add-trait-specs
branch
from
October 23, 2026 13:18
818b3fa to
5d600b8
Compare
clementblaudeau
force-pushed
the
add-trait-specs
branch
from
October 27, 2026 16:15
4aefccc to
a8051ac
Compare
clementblaudeau
force-pushed
the
add-trait-specs
branch
from
October 27, 2026 16:30
a8051ac to
ac6cfa8
Compare
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
- 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. Fork-Patch: hax-trait-specs
- 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. Fork-Patch: hax-trait-specs
Fork-Patch: hax-trait-specs
A unit argument of a trait method was bound in its `Lawful` field as a variable named `_`, printed `«_»`: it is now passed as `()` and bound as `_`, as in the specs of functions. An argument without a name (`_: u32`, or a pattern) is named after its type, as in function bodies, instead of `«_»`. Tests: `UnitArg` and `UnnamedArg` in `arguments.rs`. Fork-Patch: hax-trait-specs
clementblaudeau
force-pushed
the
add-trait-specs
branch
from
October 29, 2026 10:37
ac6cfa8 to
7247330
Compare
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.