automation_structures/connectives/
cursor.rs1use vstd::prelude::*;
7
8verus! {
9
10pub open spec fn cursor_admitted(position: nat, head: nat) -> bool {
12 position <= head
13}
14
15pub proof fn regression_rejected(position: nat, head: nat)
17 requires position > head,
18 ensures !cursor_admitted(position, head),
19{
20}
21
22pub struct Cursor {
24 pub position: usize,
26}
27
28impl Cursor {
29 pub fn new(position: usize) -> (cursor: Self)
31 ensures cursor.position == position,
32 {
33 Self { position }
34 }
35
36 pub fn advance_to(&mut self, position: usize)
38 requires old(self).position <= position,
39 ensures final(self).position == position,
40 {
41 self.position = position;
42 }
43}
44
45}