notation.v 5.21 KB
Newer Older
1
From iris.heap_lang Require Export derived.
2
Export heap_lang.
3

4
Arguments wp {_ _} _ _%E _.
5

6
Notation "'WP' e @ E {{ Φ } }" := (wp E e%E Φ)
7
  (at level 20, e, Φ at level 200,
8 9
   format "'WP'  e  @  E  {{  Φ  } }") : uPred_scope.
Notation "'WP' e {{ Φ } }" := (wp  e%E Φ)
10
  (at level 20, e, Φ at level 200,
11
   format "'WP'  e  {{  Φ  } }") : uPred_scope.
12

13 14 15 16 17 18 19
Notation "'WP' e @ E {{ v , Q } }" := (wp E e%E (λ v, Q))
  (at level 20, e, Q at level 200,
   format "'WP'  e  @  E  {{  v ,  Q  } }") : uPred_scope.
Notation "'WP' e {{ v , Q } }" := (wp  e%E (λ v, Q))
  (at level 20, e, Q at level 200,
   format "'WP'  e  {{  v ,  Q  } }") : uPred_scope.

20
Coercion LitInt : Z >-> base_lit.
21 22 23 24
Coercion LitBool : bool >-> base_lit.
Coercion App : expr >-> Funclass.
Coercion of_val : val >-> expr.

25
Coercion BNamed : string >-> binder.
26
Notation "<>" := BAnon : binder_scope.
27

28
(* No scope for the values, does not conflict and scope is often not inferred properly. *)
29
Notation "# l" := (LitV l%Z%V) (at level 8, format "# l").
Ralf Jung's avatar
Ralf Jung committed
30
Notation "% l" := (LocV l) (at level 8, format "% l").
31
Notation "# l" := (LitV l%Z%V) (at level 8, format "# l") : val_scope.
32
Notation "% l" := (LocV l) (at level 8, format "% l") : val_scope.
33
Notation "# l" := (Lit l%Z%V) (at level 8, format "# l") : expr_scope.
34 35 36 37
Notation "% l" := (Loc l) (at level 8, format "% l") : expr_scope.

Notation "' x" := (Var x) (at level 8, format "' x") : expr_scope.
Notation "^ v" := (of_val' v%V) (at level 8, format "^ v") : expr_scope.
Ralf Jung's avatar
Ralf Jung committed
38

39 40 41
(** Syntax inspired by Coq/Ocaml. Constructions with higher precedence come
    first. *)
Notation "( e1 , e2 , .. , en )" := (Pair .. (Pair e1 e2) .. en) : expr_scope.
Robbert Krebbers's avatar
Robbert Krebbers committed
42
Notation "( e1 , e2 , .. , en )" := (PairV .. (PairV e1 e2) .. en) : val_scope.
43
Notation "'match:' e0 'with' 'InjL' x1 => e1 | 'InjR' x2 => e2 'end'" :=
Ralf Jung's avatar
Ralf Jung committed
44
  (Match e0 x1%bind e1 x2%bind e2)
45
  (e0, x1, e1, x2, e2 at level 200) : expr_scope.
46
Notation "'match:' e0 'with' 'InjR' x1 => e1 | 'InjL' x2 => e2 'end'" :=
Ralf Jung's avatar
Ralf Jung committed
47
  (Match e0 x2%bind e2 x1%bind e1)
Ralf Jung's avatar
Ralf Jung committed
48
  (e0, x1, e1, x2, e2 at level 200, only parsing) : expr_scope.
49
Notation "()" := LitUnit : val_scope.
50 51 52 53 54 55 56 57 58 59 60 61 62
Notation "! e" := (Load e%E) (at level 9, right associativity) : expr_scope.
Notation "'ref' e" := (Alloc e%E)
  (at level 30, right associativity) : expr_scope.
Notation "- e" := (UnOp MinusUnOp e%E)
  (at level 35, right associativity) : expr_scope.
Notation "e1 + e2" := (BinOp PlusOp e1%E e2%E)
  (at level 50, left associativity) : expr_scope.
Notation "e1 - e2" := (BinOp MinusOp e1%E e2%E)
  (at level 50, left associativity) : expr_scope.
Notation "e1 ≤ e2" := (BinOp LeOp e1%E e2%E) (at level 70) : expr_scope.
Notation "e1 < e2" := (BinOp LtOp e1%E e2%E) (at level 70) : expr_scope.
Notation "e1 = e2" := (BinOp EqOp e1%E e2%E) (at level 70) : expr_scope.
Notation "~ e" := (UnOp NegOp e%E) (at level 75, right associativity) : expr_scope.
63
(* The unicode ← is already part of the notation "_ ← _; _" for bind. *)
64
Notation "e1 <- e2" := (Store e1%E e2%E) (at level 80) : expr_scope.
Ralf Jung's avatar
Ralf Jung committed
65
Notation "'rec:' f x := e" := (Rec f%bind x%bind e%E)
66
  (at level 102, f at level 1, x at level 1, e at level 200) : expr_scope.
Ralf Jung's avatar
Ralf Jung committed
67
Notation "'rec:' f x := e" := (RecV f%bind x%bind e%E)
68
  (at level 102, f at level 1, x at level 1, e at level 200) : val_scope.
69 70
Notation "'if:' e1 'then' e2 'else' e3" := (If e1%E e2%E e3%E)
  (at level 200, e1, e2, e3 at level 200) : expr_scope.
71 72 73 74 75

(** Derived notions, in order of declaration. The notations for let and seq
are stated explicitly instead of relying on the Notations Let and Seq as
defined above. This is needed because App is now a coercion, and these
notations are otherwise not pretty printed back accordingly. *)
Ralf Jung's avatar
Ralf Jung committed
76
Notation "'rec:' f x y := e" := (Rec f%bind x%bind (Lam y%bind e%E))
77
  (at level 102, f, x, y at level 1, e at level 200) : expr_scope.
Ralf Jung's avatar
Ralf Jung committed
78
Notation "'rec:' f x y := e" := (RecV f%bind x%bind (Lam y%bind e%E))
79
  (at level 102, f, x, y at level 1, e at level 200) : val_scope.
Ralf Jung's avatar
Ralf Jung committed
80
Notation "'rec:' f x y .. z := e" := (Rec f%bind x%bind (Lam y%bind .. (Lam z%bind e%E) ..))
81
  (at level 102, f, x, y, z at level 1, e at level 200) : expr_scope.
Ralf Jung's avatar
Ralf Jung committed
82
Notation "'rec:' f x y .. z := e" := (RecV f%bind x%bind (Lam y%bind .. (Lam z%bind e%E) ..))
83 84
  (at level 102, f, x, y, z at level 1, e at level 200) : val_scope.

Ralf Jung's avatar
Ralf Jung committed
85
Notation "λ: x , e" := (Lam x%bind e%E)
86
  (at level 102, x at level 1, e at level 200) : expr_scope.
Ralf Jung's avatar
Ralf Jung committed
87
Notation "λ: x y .. z , e" := (Lam x%bind (Lam y%bind .. (Lam z%bind e%E) ..))
88
  (at level 102, x, y, z at level 1, e at level 200) : expr_scope.
Ralf Jung's avatar
Ralf Jung committed
89
Notation "λ: x , e" := (LamV x%bind e%E)
90
  (at level 102, x at level 1, e at level 200) : val_scope.
Ralf Jung's avatar
Ralf Jung committed
91
Notation "λ: x y .. z , e" := (LamV x%bind (Lam y%bind .. (Lam z%bind e%E) .. ))
92
  (at level 102, x, y, z at level 1, e at level 200) : val_scope.
93

Ralf Jung's avatar
Ralf Jung committed
94
Notation "'let:' x := e1 'in' e2" := (Lam x%bind e2%E e1%E)
95 96 97
  (at level 102, x at level 1, e1, e2 at level 200) : expr_scope.
Notation "e1 ;; e2" := (Lam BAnon e2%E e1%E)
  (at level 100, e2 at level 200, format "e1  ;;  e2") : expr_scope.
98
(* These are not actually values, but we want them to be pretty-printed. *)
Ralf Jung's avatar
Ralf Jung committed
99
Notation "'let:' x := e1 'in' e2" := (LamV x%bind e2%E e1%E)
100
  (at level 102, x at level 1, e1, e2 at level 200) : val_scope.
101
Notation "e1 ;; e2" := (LamV BAnon e2%E e1%E)
102
  (at level 100, e2 at level 200, format "e1  ;;  e2") : val_scope.