Skip to content

Commit

Permalink
bug-reports: strange failure invoking FStar GTot fn in Pulse
Browse files Browse the repository at this point in the history
  • Loading branch information
meganfrisella committed Jul 26, 2023
1 parent 6fecd23 commit 73a7c5c
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 3 deletions.
47 changes: 47 additions & 0 deletions share/steel/examples/pulse/bug-reports/FStarGhost.fst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module FStarGhost

open Pulse.Main
open Pulse.Steel.Wrapper
open Steel.ST.Util
module G = FStar.Ghost
module R = Steel.ST.Reference
module GR = Steel.ST.GhostReference

let fstar_gtot_incr (n:G.erased nat) : GTot nat
= n + 1

(* this checks *)
```pulse
ghost
fn invoke_fstar_gtot (r:GR.ref nat) (#n:G.erased nat)
requires GR.pts_to r full_perm n
ensures GR.pts_to r full_perm (n+1)
{
gwrite r (fstar_gtot_incr n)
}
```

(* invocation of GTot fcn: expected a total term, got a ghost term *)
[@@expect_failure]
```pulse
ghost
fn bind_fstar_gtot (r:GR.ref nat) (#n:G.erased nat)
requires GR.pts_to r full_perm n
ensures GR.pts_to r full_perm (n+1)
{
let nn = fstar_gtot_incr n;
gwrite r nn
}
```

(* same issue as above *)
[@@expect_failure]
```pulse
ghost
fn return_fstar_gtot (#n:G.erased nat)
requires emp
ensures emp
{
fstar_gtot_incr n
}
```
29 changes: 26 additions & 3 deletions share/steel/examples/pulse/by-example/PulseByExample.fst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ fn invoke (r:ref nat)




(*
to cover
- ref alloc/free
- local references
- earlier, explicitly introduce erased/exists/forall in spec
*)


```pulse
Expand Down Expand Up @@ -172,6 +177,24 @@ fn write_array (#t:Type0)
```

(*
- loop invariants
- magic wand!
- loop invariants (while), other control flow (if, match)
- then, a program that brings everything up to this point together
- maybe fibo with primitive types then introduce bounded integers
- arrays
- some more mature example (e.g. sorting alg)
- some simple record data structure along with a library of functions on this DS
(e.g. library of functions on 2D points)
- build up to explaining the pulse implementation of lpht? -- emphasis on connecting
pure implementation to imperative code
- pulse linked list? -- more traditional sep logic example
- concurrency, e.g. par incr of a ctr
*)

0 comments on commit 73a7c5c

Please sign in to comment.