Proof closures #1419
Replies: 4 comments 9 replies
-
|
This would be useful implementing a verified Rc with T as covariant instead of invariant. |
Beta Was this translation helpful? Give feedback.
-
|
I think I have some time to work on this now. Here's a sketch of a design and implementation. DesignMostly, the design borrows from what's already in place for spec mode:
and what's already in place for exec mode:
I propose the following user interface design for proof closures:
For example: I think types like ImplementationMostly, the implementation borrows from what's already implemented for spec mode and exec mode: In the implementation, there's currently a struct Currently, there are Fn, FnMut, and FnOnce impls for FnSpec. Likewise, there would be a Fn, FnMut, and FnOnce impls for FnProof, depending on the Usage argument. This would allow Rust to type-check and ownership-check the calls to the various proof functions. Currently, there is a Currently, there is a private vstd Currently, there is an AST expression ExprX::ExecClosure for VIR exec closures. I think this can be generalized for proof-mode closures as well. Again, modes.rs will need to be extended to check these. Extensions for marker traitsClosures may implement the following marker traits: Clone, Copy, Send, Sync. For normal Rust exec closures, functions can add these markers as bounds on function types, as in To support these marker traits for proof closures, I propose extending the In the underlying implementation, this can be encoded with more type arguments: |
Beta Was this translation helpful? Give feedback.
-
|
I think it would be helpful to be able to specify requires / ensures clauses for a |
Beta Was this translation helpful? Give feedback.
-
|
And there's one more design detail that I forgot: a proof function will have a lifetime. So the underlying Rust type will be something with an |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Verus already supports exec-mode closures (
Fn,FnMut,FnOnce) and spec-mode closures (spec_fn), so it makes sense to also support proof-mode closures. Since Verus treats proof-mode functions very similarly to exec-mode functions, I would expect that proof-mode closures would be very similar to exec-mode closures.As far as I know, this feature is currently missing simply because nobody has gotten around to implementing it yet. Currently, the workaround is to use a trait instead.
Beta Was this translation helpful? Give feedback.
All reactions