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

Verus snapshot update #77

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/verus-snapshot/source/vstd/source/vstd/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,24 @@ macro_rules! atomic_types {
pub open spec fn points_to(&self, v: $value_ty) -> bool {
self.view().value == v
}

#[verifier::inline]
pub open spec fn value(&self) -> $value_ty {
self.view().value
}

#[verifier::inline]
pub open spec fn id(&self) -> AtomicCellId {
self.view().patomic
}
}

}
};
}

pub type AtomicCellId = int;

macro_rules! atomic_common_methods {
($at_ident:ident, $p_ident:ident, $p_data_ident:ident, $rust_ty: ty, $value_ty: ty) => {
verus!{
Expand Down
17 changes: 15 additions & 2 deletions examples/verus-snapshot/source/vstd/source/vstd/pcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,20 @@ impl<P: PCM> Resource<P> {

// Operations with shared references
#[verifier::external_body]
pub proof fn join_shared<'a>(
pub proof fn join_shared<'a>(tracked &'a self, tracked other: &'a Self) -> (tracked out:
&'a Self)
requires
self.loc() == other.loc(),
ensures
out.loc() == self.loc(),
incl(self.value(), out.value()),
incl(other.value(), out.value()),
{
unimplemented!();
}

#[verifier::external_body]
pub proof fn join_shared_to_target<'a>(
tracked &'a self,
tracked other: &'a Self,
target: P,
Expand All @@ -169,7 +182,7 @@ impl<P: PCM> Resource<P> {
out.loc() == self.loc(),
out.value() == target,
{
unimplemented!();
self.join_shared(other).weaken(target)
}

#[verifier::external_body]
Expand Down
22 changes: 16 additions & 6 deletions examples/verus-snapshot/source/vstd/source/vstd/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ impl<A> Seq<A> {

/// Appends the value `a` to the end of the sequence.
/// This always increases the length of the sequence by 1.
/// This often requires annotating the type of the element literal in the sequence,
/// e.g., `10int`.
///
/// ## Example
///
/// ```rust
/// proof fn push_test() {
/// assert(seq![10, 11, 12].push(13) =~= seq![10, 11, 12, 13]);
/// assert(seq![10int, 11, 12].push(13) =~= seq![10, 11, 12, 13]);
/// }
/// ```
#[rustc_diagnostic_item = "verus::vstd::seq::Seq::push"]
Expand Down Expand Up @@ -117,9 +119,9 @@ impl<A> Seq<A> {
///
/// ```rust
/// proof fn subrange_test() {
/// let s = seq![10, 11, 12, 13, 14];
/// // ^-------^
/// // 0 1 2 3 4 5
/// let s = seq![10int, 11, 12, 13, 14];
/// // ^-------^
/// // 0 1 2 3 4 5
/// let sub = s.subrange(2, 4);
/// assert(sub =~= seq![12, 13]);
/// }
Expand Down Expand Up @@ -359,15 +361,23 @@ macro_rules! seq_internal {
[$($elem:expr),* $(,)?] => {
$crate::vstd::seq::Seq::empty()
$(.push($elem))*
}
};
[$elem:expr; $n:expr] => {
$crate::vstd::seq::Seq::new(
$n,
$crate::vstd::prelude::closure_to_fn_spec(
|_x: _| $elem
),
)
};
}

/// Creates a [`Seq`] containing the given elements.
///
/// ## Example
///
/// ```rust
/// let s = seq![11, 12, 13];
/// let s = seq![11int, 12, 13];
///
/// assert(s.len() == 3);
/// assert(s[0] == 11);
Expand Down
15 changes: 0 additions & 15 deletions examples/verus-snapshot/source/vstd/source/vstd/std_specs/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ pub struct ExVec<T, A: Allocator>(Vec<T, A>);
#[verifier::external_body]
pub struct ExGlobal(alloc::alloc::Global);

impl<T, A: Allocator> View for Vec<T, A> {
type V = Seq<T>;

spec fn view(&self) -> Seq<T>;
}

impl<T: DeepView, A: Allocator> DeepView for Vec<T, A> {
type V = Seq<T::V>;

open spec fn deep_view(&self) -> Seq<T::V> {
let v = self.view();
Seq::new(v.len(), |i: int| v[i].deep_view())
}
}

pub trait VecAdditionalSpecFns<T>: View<V = Seq<T>> {
spec fn spec_index(&self, i: int) -> T
recommends
Expand Down
Loading