Skip to content

Commit 1735146

Browse files
committed
Corrections
1 parent 1efe64d commit 1735146

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

pages/annotations/refinement-predicates.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ The `@Ghost` and `@StateSet` annotations are sugar for the `@RefinementPredicate
1818
| `@Ghost("boolean open")` | `@RefinementPredicate("boolean open(InputStreamReader)")` |
1919
| `@StateSet({"open", "closed"})` | `@RefinementPredicate("int state1(File)")`<br>`state1(this) == 0 <=> open(this)`<br>`state1(this) == 1 <=> closed(this)` |
2020

21-
In the current implementation, `@RefinementPredicate` is only supported on methods and constructors, but it is not currently scoped to the annotated method or constructor. Instead, is a global declaration that is available for the whole verification.
22-
23-
## What's a Ghost Function?
21+
## Ghost Functions
2422

2523
A ghost function is an uninterpreted function used only during verification. In practice, that means:
2624

@@ -51,7 +49,7 @@ The meaning comes from those constraints, not from a body.
5149

5250
## Example
5351

54-
You can model any typestate protocol without using the `@StateSet` annotation, by declaring a ghost function that represents the state and then using aliases to give names to the different states, which is kind of like how `@StateSet` works. Under the hood, states are just ghost functions that return an integer representing current the state. For example:
52+
You can model any typestate protocol without using the `@StateSet` annotation, by declaring a ghost function that represents the state and then using aliases to give names to the different states, which is kind of like how `@StateSet` works. Under the hood, states are just ghost functions that return an integer representing the current state. For example:
5553

5654
```java
5755
import liquidjava.specification.*;

pages/examples/downloader.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This example models a simple downloader object that tracks the progress of a dow
1313
```java
1414
import liquidjava.specification.*;
1515

16+
@RefinementAlias("Percentage(int p) { 0 <= p && p <= 100 }")
1617
@Ghost("int progress")
1718
@StateSet({"created", "downloading", "completed"})
1819
public class Downloader {
@@ -22,8 +23,8 @@ public class Downloader {
2223
@StateRefinement(from="created() && progress() == 0", to="downloading() && progress() == 0")
2324
public void start() {}
2425

25-
@StateRefinement(from="downloading()", to="downloading() && progress() == percentage")
26-
public void update(@Refinement("percentage > progress()") int percentage) {}
26+
@StateRefinement(from="downloading() && percentage > progress()", to="downloading() && progress() == percentage")
27+
public void update(@Refinement("Percentage(_)") int percentage) {}
2728

2829
@StateRefinement(from="downloading() && progress() == 100", to="completed()")
2930
public void finish() {}

pages/examples/email.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class Email {
2727
@StateRefinement(from="senderSet() || receiverSet()", to="receiverSet()")
2828
public Email to(String s) {}
2929

30-
@StateRefinement(from="receiverSet()", to="receiverSet()")
30+
@StateRefinement(from="receiverSet()")
3131
public Email subject(String s) {}
3232

3333
@StateRefinement(from="receiverSet()", to="bodySet()")
@@ -59,5 +59,5 @@ LiquidJava enforces the intended protocol:
5959

6060
- The `from` must be set first
6161
- The `to` must be set at least once before setting the `body`
62-
- The `subject` is optional
62+
- The `subject` is optional, but if used it must be set before the `body`
6363
- The `build` method can only be called after the body is set

0 commit comments

Comments
 (0)