File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include "../include/PulseMacros.h"
2+
3+ REQUIRES (emp )
4+ ENSURES (emp )
5+ void test_empty (void )
6+ { return ; }
Original file line number Diff line number Diff line change 1+ #include "../include/PulseMacros.h"
2+ ERASED_ARG (#vr :erased _)
3+ REQUIRES (r |- > vr )
4+ REQUIRES (pure Pulse .Lib .C .Int32 .(fits (+ ) (as_int vr ) 1 ))
5+ ENSURES (exists * w . (r |- > w ) * * pure Pulse .Lib .C .Int32 .(as_int w == as_int vr + 1 ))
6+ int incr (int * r )
7+ {
8+ * r = * r + 1 ;
9+ }
10+
11+ REQUIRES (emp )
12+ RETURNS (i :Pulse .Lib .C .Int32 .int32 )
13+ ENSURES (pure Pulse .Lib .C .Int32 .(as_int i == 1 ))
14+ int one ()
15+ {
16+ int i = 0 ;
17+ incr (& i );
18+ return i ;
19+ }
Original file line number Diff line number Diff line change 1+ #include <stdint.h>
2+ #include <stdlib.h>
3+ #include "../include/PulseMacros.h"
4+
5+ REQUIRES (emp )
6+ RETURNS (i :int32 )
7+ ENSURES (emp )
8+ int test (void )
9+ {
10+ return 0 ;
11+ }
12+
13+ typedef struct _point {
14+ int px ;
15+ int py ;
16+ } point ;
17+
18+
19+ INCLUDE (
20+ let is_diag_point (p :ref point ) (v :int32 )
21+ : slprop
22+ = point_pred p {px = v ; py = v }
23+
24+ let is_point (p :ref point ) (xy : (int & int ))
25+ : slprop
26+ = exists * v . point_pred p v * * pure (as_int v .px == fst xy ) * * pure (as_int v .py == snd xy )
27+
28+ ghost
29+ fn fold_is_point (p :ref point ) (#s :point_spec )
30+ requires point_pred p s
31+ ensures exists * v . is_point p v * * pure (v == (as_int s .px , as_int s .py ))
32+ {
33+ fold (is_point p (as_int s .px , as_int s .py ));
34+ }
35+
36+ )
37+
38+ ERASED_ARG (#v :erased _)
39+ REQUIRES (is_point p v )
40+ REQUIRES (pure < | fits (+ ) (fst v ) (as_int dx ))
41+ REQUIRES (pure < | fits (+ ) (snd v ) (as_int dy ))
42+ ENSURES (is_point p (fst v + as_int dx , snd v + as_int dy ))
43+ void move (point * p , int dx , int dy )
44+ {
45+ LEMMA (unfold (is_point ); point_explode p );
46+ p - > px = p -> px + dx ;
47+ p -> py = p -> py + dy ;
48+ LEMMA (point_recover p ; fold_is_point p );
49+ }
Original file line number Diff line number Diff line change 1+ // RUN: %c2pulse %s
2+ // RUN: cat %p/Issue1_test.fst
3+ // RUN: diff %p/Issue1_test.fst %p/snapshots/Issue1_test.fst
4+ // RUN: %run_fstar.sh %p/Issue1_test.fst 2>&1 | %{FILECHECK} %s --check-prefix=PULSE
5+
6+ #include <stdint.h>
7+ #include <stdlib.h>
8+ #include "../include/PulseMacros.h"
9+
10+ REQUIRES ("x |-> 'i" )
11+ REQUIRES ("pure FStar.Int32.(fits (v 'i + 1))" )
12+ ENSURES ("exists* j. (x |-> j) ** pure FStar.Int32.((v j <: int) == v 'i + 1)" )
13+ void incr (int * x )
14+ {
15+ * x = * x + 1 ;
16+ }
17+
18+ ERASED_ARG (#i :_ )
19+ ERASED_ARG (#j :_ )
20+ REQUIRES (x |- > i )
21+ REQUIRES (y |- > j )
22+ REQUIRES (pure FStar .Int32 .(fits (v i + 1 )))
23+ ENSURES (exists * k . (x |-> k ) * * pure FStar .Int32 .(v i + 1 == v k ))
24+ ENSURES (y |- > j )
25+ void incr_frame (int * x , int * y )
26+ {
27+ incr (x );
28+ }
29+
30+ // PULSE: All verification conditions discharged successfully
Original file line number Diff line number Diff line change 1+ #include "../include/PulseMacros.h"
2+
3+ ERASED_ARG (#w :_)
4+ REQUIRES (r |- > w )
5+ RETURNS (v :Int32 .t )
6+ ENSURES (r |- > w )
7+ ENSURES (pure (v == w ))
8+ int value_of_explicit (int * r )
9+ {
10+ return * r ;
11+ }
Original file line number Diff line number Diff line change 1+ // EXPECT_FAILURE(19)
2+ #include "../include/PulseMacros.h"
3+ RETURNS (s :_ )
4+ ENSURES (s |-> 0 )
5+ int * refs_are_scoped ()
6+ {
7+ int s = 0 ;
8+ return & s ;
9+ }
You can’t perform that action at this time.
0 commit comments