Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Re)introduce Invariant trait #3190

Merged
merged 14 commits into from
Jun 6, 2024

Conversation

adpaco-aws
Copy link
Contributor

@adpaco-aws adpaco-aws commented May 16, 2024

This PR reintroduces the Invariant trait as a mechanism for the specification of type safety invariants. The trait is defined in the Kani library where we also provide Invariant implementations for primitive types.

In contrast to the previous Invariant trait, this version doesn't require the Arbitrary bound (i.e., it has the same requirements as Arbitrary). This way, the user isn't required to provide an Arbitrary implementation in addition to the Invariant one.

Related #3095

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@adpaco-aws adpaco-aws requested a review from a team as a code owner May 16, 2024 21:16
@github-actions github-actions bot added the Z-BenchCI Tag a PR to run benchmark CI label May 16, 2024
@adpaco-aws adpaco-aws marked this pull request as draft May 16, 2024 21:17
@adpaco-aws adpaco-aws marked this pull request as ready for review May 17, 2024 18:33
@adpaco-aws
Copy link
Contributor Author

The PR is ready for review.

Question: Since we're considering checking automatically these invariants at some level in the future, would it make sense to warn Kani users in the release notes?

@adpaco-aws adpaco-aws changed the title [Draft] (Re)introduce Invariant trait (Re)introduce Invariant trait May 17, 2024
Copy link
Contributor

@celinval celinval left a comment

Choose a reason for hiding this comment

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

Btw, great documentation. Thanks

@adpaco-aws adpaco-aws enabled auto-merge (squash) June 6, 2024 18:16
Copy link
Contributor

@feliperodri feliperodri left a comment

Choose a reason for hiding this comment

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

This is such a great addition. In the future, we could have something like safe_any(), which would return non-deterministic values that automatically assume the safety invariants of a type.

library/kani/src/invariant.rs Outdated Show resolved Hide resolved
@adpaco-aws adpaco-aws removed their assignment Jun 6, 2024
@adpaco-aws adpaco-aws merged commit a6332fc into model-checking:main Jun 6, 2024
23 checks passed
celinval pushed a commit to celinval/kani-dev that referenced this pull request Jun 6, 2024
This PR reintroduces the `Invariant` trait as a mechanism for the
specification of type safety invariants. The trait is defined in the
Kani library where we also provide `Invariant` implementations for
primitive types.

In contrast to the previous `Invariant` trait, this version doesn't
require the `Arbitrary` bound (i.e., it has the same requirements as
`Arbitrary`). This way, the user isn't required to provide an
`Arbitrary` implementation in addition to the `Invariant` one.

Related model-checking#3095
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-BenchCI Tag a PR to run benchmark CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants