Skip to content

Commit

Permalink
one more proof and some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
elaustell committed Jul 24, 2023
1 parent 7665102 commit 7053d4c
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 285 deletions.
1 change: 0 additions & 1 deletion source/pervasive/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,4 @@ pub exec fn u64_to_le_bytes(x: u64) -> (s: Vec<u8>)
x.to_le_bytes().to_vec()
}


} // verus!
14 changes: 9 additions & 5 deletions source/pervasive/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ impl<A> Seq<A> {
#[rustc_diagnostic_item = "verus::pervasive::seq::Seq::new"]
pub spec fn new(len: nat, f: impl Fn(int) -> A) -> Seq<A>;

/// Constructs a sequence of length 1 containing only the given element.

#[verifier(inline)]
pub open spec fn singleton(elt: A) -> Seq<A> {
Self::empty().push(elt)
}

/// Returns a constant sequence of a given length
/// Constructs a sequence of length `length` where every element in the sequence
/// is equivalent to `val`.

spec fn fill(val: A, length: nat) -> Seq<A>
{
if length <= 0 {Self::empty()}
Expand Down Expand Up @@ -153,27 +157,27 @@ impl<A> Seq<A> {
recommends 0 <= start_inclusive <= end_exclusive <= self.len();

/// Returns a sequence containing only the first n elements of the original sequence

#[verifier(inline)]
pub open spec fn take(self, n: int) -> Seq<A>{
self.subrange(0,n)
}

/// Returns a sequence that drops the first n elements of the original sequence
/// Returns a sequence without the first n elements of the original sequence

#[verifier(inline)]
pub open spec fn drop(self, n: int) -> Seq<A>{
self.subrange(n,self.len() as int)
}

pub open spec fn rank(self) -> int;

/// Concatenates the sequences.
///
/// ## Example
///
/// ```rust
/// proof fn add_test() {
/// assert_seqs_equal!(
/// seq![10, 11].push(seq![12, 13, 14]),
/// seq![10int, 11].add(seq![12, 13, 14]),
/// seq![10, 11, 12, 13, 14],
/// );
/// }
Expand Down
Loading

0 comments on commit 7053d4c

Please sign in to comment.