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

Add support for array literals #1198

Merged
merged 34 commits into from
Jul 16, 2024
Merged

Add support for array literals #1198

merged 34 commits into from
Jul 16, 2024

Conversation

parno
Copy link
Collaborator

@parno parno commented Jun 28, 2024

This introduces an AIR-level array literal, which we then connect all the way up to the rust_verify level. This includes updating the interpreter to handle the new array literals.

The AIR-level approach allows an efficient encoding to associate array indices to values. A future PR will take advantage of this new encoding to optimize sequence literals by changing how seq! behaves.

Commit 3779b06 is small, but it should be carefully reviewed, since it changes the mode checking for tuples, arrays, datatypes. The change is consistent with our formalization, but it's worth double checking. @Chris-Hawblitzel plans to add a few additional tests as a sanity check.

Chris-Hawblitzel and others added 30 commits June 9, 2024 14:41
with the design in our OOPSLA formalization.  This eliminates the error
that Verus previously produced when declaring a constant using
any of these types, e.g.,
```
const a: [usize; 2] = [0, 1];
```
where Verus concluded that the expression on the right-hand side
was spec, which made it invalid for use in the exec aspect of the
constant.
…iterals,"

Save the seq! for a separate PR

This reverts commit edb9c31.
@y1ca1
Copy link
Contributor

y1ca1 commented Jun 28, 2024

This is very cool! I played with it and it really enables a seamless experience of spec array and exec array interplays.

@@ -9,7 +9,9 @@ verus! {
impl<T, const N: usize> View for [T; N] {
type V = Seq<T>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we mark the view of arrays to be just [T; N] (like those primitive integer types)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My guess is that a sequence view will be more useful, since the spec writer can then make use of all the features in the sequence library.

@parno
Copy link
Collaborator Author

parno commented Jul 12, 2024

@Chris-Hawblitzel Thanks for adding the mode test. Did you get a chance to review the rest of the code? No hurry on my side; I'm just not sure if we're ready to merge.

@Chris-Hawblitzel
Copy link
Collaborator

Did you get a chance to review the rest of the code? No hurry on my side; I'm just not sure if we're ready to merge.

I think you can go ahead and squash and merge.

@parno parno merged commit 2ab19da into main Jul 16, 2024
10 checks passed
@parno parno deleted the air-array branch July 16, 2024 19:35
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.

None yet

4 participants