Skip to content

Commit 8af5236

Browse files
committed
Update Refinements Section
1 parent e99d9aa commit 8af5236

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

reference/refinements.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,19 @@ public class RefinementExamples {
3131
}
3232
```
3333

34+
## Predicate Syntax
35+
36+
The predicates allowed inside a refinement belong to quantifier-free linear integer arithmetic. In practice, this means you can write boolean expressions over integer values using comparisons, logical connectives, arithmetic operators, and conditional expressions. You can also call ghost variables and aliases from refinements, which we cover in later sections.
37+
38+
| Form | Syntax | Example |
39+
| --- | --- | --- |
40+
| Comparison | `==` `!=` `>` `>=` `<` `<=` | `@Refinement("x > 0") int x = 1;` |
41+
| Logical operators | `!` `&&` <code>&#124;&#124;</code> `-->` | `@Refinement("0 <= y && y <= 100") int y = 25;` |
42+
| Arithmetic | `+` `-` `*` `/` `%` | `@Refinement("v + 20 < 100") int v = 79;` |
43+
| Conditional | `cond ? e1 : e2` | `@Refinement("a > b ? _ == a : _ == b") int max(int a, int b)` |
44+
| Ghost and alias calls | `a(b)` `A(b)` | `@Refinement("Positive(_)") int c = 10;` |
45+
| Literals | `true` `false` `0` `1.5` | `@Refinement("_ == true") boolean ok = true;` |
46+
47+
LiquidJava currently only supports a small set of types in refinements:
48+
- Primitive types: `int`, `boolean`, `long`, `double`, `float`
49+
- Boxed types: `Boolean`, `Integer`, `Double`

0 commit comments

Comments
 (0)