notation.v 4.4 KB
Newer Older
1
From heap_lang Require Export derived.
2

3 4
Arguments wp {_ _} _ _%E _.
Notation "|| e @ E {{ Φ } }" := (wp E e%E Φ)
5 6
  (at level 20, e, Φ at level 200,
   format "||  e  @  E  {{  Φ  } }") : uPred_scope.
7
Notation "|| e {{ Φ } }" := (wp  e%E Φ)
8 9
  (at level 20, e, Φ at level 200,
   format "||  e   {{  Φ  } }") : uPred_scope.
10

11
Coercion LitInt : Z >-> base_lit.
12 13 14 15 16 17 18
Coercion LitBool : bool >-> base_lit.
(** No coercion from base_lit to expr. This makes is slightly easier to tell
   apart language and Coq expressions. *)
Coercion Var : string >-> expr.
Coercion App : expr >-> Funclass.
Coercion of_val : val >-> expr.

19
Coercion BNamed : string >-> binder.
20
Notation "<>" := BAnon : binder_scope.
21

Ralf Jung's avatar
Ralf Jung committed
22 23 24 25
(* No scope, does not conflict and scope is often not inferred properly. *)
Notation "# l" := (LitV l%Z%V) (at level 8, format "# l").
Notation "% l" := (LocV l) (at level 8, format "% l").

26 27 28
(** Syntax inspired by Coq/Ocaml. Constructions with higher precedence come
    first. *)
Notation "( e1 , e2 , .. , en )" := (Pair .. (Pair e1 e2) .. en) : expr_scope.
29
Notation "'match:' e0 'with' 'InjL' x1 => e1 | 'InjR' x2 => e2 'end'" :=
30
  (Match e0 x1 e1 x2 e2)
31
  (e0, x1, e1, x2, e2 at level 200) : expr_scope.
32
Notation "()" := LitUnit : val_scope.
33 34 35 36 37 38 39 40 41 42 43 44 45
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.
46
(* The unicode ← is already part of the notation "_ ← _; _" for bind. *)
47 48 49 50
Notation "e1 <- e2" := (Store e1%E e2%E) (at level 80) : expr_scope.
Notation "'rec:' f x := e" := (Rec f x e%E)
  (at level 102, f at level 1, x at level 1, e at level 200) : expr_scope.
Notation "'rec:' f x := e" := (RecV f x e%E)
51
  (at level 102, f at level 1, x at level 1, e at level 200) : val_scope.
52 53
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.
54 55 56 57 58

(** 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. *)
59 60 61
Notation "λ: x , e" := (Lam x e%E)
  (at level 102, x at level 1, e at level 200) : expr_scope.
Notation "λ: x , e" := (LamV x e%E)
62 63
  (at level 102, x at level 1, e at level 200) : val_scope.

64 65 66 67
Notation "'let:' x := e1 'in' e2" := (Lam x e2%E e1%E)
  (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.
68
(* These are not actually values, but we want them to be pretty-printed. *)
69
Notation "'let:' x := e1 'in' e2" := (LamV x e2%E e1%E)
70
  (at level 102, x at level 1, e1, e2 at level 200) : val_scope.
71
Notation "e1 ;; e2" := (LamV BAnon e2%E e1%E)
72
  (at level 100, e2 at level 200, format "e1  ;;  e2") : val_scope.
Robbert Krebbers's avatar
Robbert Krebbers committed
73

74 75 76
Notation "'rec:' f x y := e" := (Rec f x (Lam y e%E))
  (at level 102, f, x, y at level 1, e at level 200) : expr_scope.
Notation "'rec:' f x y := e" := (RecV f x (Lam y e%E))
77
  (at level 102, f, x, y at level 1, e at level 200) : val_scope.
78 79 80
Notation "'rec:' f x y z := e" := (Rec f x (Lam y (Lam z e%E)))
  (at level 102, f, x, y, z at level 1, e at level 200) : expr_scope.
Notation "'rec:' f x y z := e" := (RecV f x (Lam y (Lam z e%E)))
81
  (at level 102, f, x, y, z at level 1, e at level 200) : val_scope.
82 83 84
Notation "λ: x y , e" := (Lam x (Lam y e%E))
  (at level 102, x, y at level 1, e at level 200) : expr_scope.
Notation "λ: x y , e" := (LamV x (Lam y e%E))
85
  (at level 102, x, y at level 1, e at level 200) : val_scope.
86 87 88
Notation "λ: x y z , e" := (Lam x (Lam y (Lam z e%E)))
  (at level 102, x, y, z at level 1, e at level 200) : expr_scope.
Notation "λ: x y z , e" := (LamV x (Lam y (Lam z e%E)))
89
  (at level 102, x, y, z at level 1, e at level 200) : val_scope.