Skip to content

Conversation

@mtzguido
Copy link
Member

@mtzguido mtzguido commented Dec 7, 2025

Using FStarLang/FStar#4068, add a resugaring pass to detect pulse computation types and print them in a nicer way. Example:

fn test (x : ref int)
  requires x |-> 'v
  returns  old : int
  ensures  x |-> ('v + 1) ** pure (old == old)
{
  let old = !x;
  x := !x + 1;
  old
}

Now outputs:

* Info at Print.fst(15,0-15,11):
  - Term
    Print.test
    has type
    x: Pulse.Lib.Reference.ref Prims.int
      -> fn
           requires x |-> 'v
           returns x : Prims.int
           ensures x |-> ('v + 1) ** Pulse.Lib.Core.pure (x == x)

Note that there is a bad shadowing of x in the postcondition. This seems difficult to fix (x is ppname_default).

@mtzguido
Copy link
Member Author

mtzguido commented Dec 7, 2025

cc @amosr-msft, you may find this useful to resugar Co3.

@amosr-msft
Copy link

that's fantastic, thanks @mtzguido!

Using FStarLang/FStar#4068, add a resugaring pass to detect pulse
computation types and print them in a nicer way. Example:
```fstar
fn test (x : ref int)
  requires x |-> 'v
  returns  old : int
  ensures  x |-> ('v + 1) ** pure (old == old)
{
  let old = !x;
  x := !x + 1;
  old
}

```
Now outputs:
```
* Info at Print.fst(15,0-15,11):
  - Term
    Print.test
    has type
    x: Pulse.Lib.Reference.ref Prims.int
      -> fn
           requires x |-> 'v
           returns x : Prims.int
           ensures x |-> ('v + 1) ** Pulse.Lib.Core.pure (x == x)
```
Note that there is a bad shadowing of x in the postcondition. This seems
difficult to fix (`x` is ppname_default).
@mtzguido mtzguido enabled auto-merge December 7, 2025 23:03
@mtzguido mtzguido merged commit eb676d5 into FStarLang:main Dec 7, 2025
2 checks passed
@mtzguido mtzguido deleted the resugar_ext branch December 7, 2025 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants