\begin{syntax}
  expr ::= ...                ; see Fig.~\ref{fig:bnf:expr1}
    | expr spec+                            ; added specification
    | "if" expr "then" expr ("else" expr)?  ; conditional
    | "match" expr "with" ("|" pattern "->" expr)+ "end"  ; pattern matching
    | qualifier? "begin" spec+ expr "end"   ; abstract block
    | expr ";" expr                         ; sequence
    | "let" pattern "=" expr "in" expr      ; let-binding
    | "let" fun-defn "in" expr              ; local function
    | "let" "rec" fun-defn ("with" fun-defn)* "in" expr   ; recursive function
    | "fun" param+ spec* "->" spec* expr    ; unnamed function
    | "any" result spec*                    ; arbitrary value
  \
  fun-defn ::= fun-head spec* "=" spec* expr ; function definition
  \
  fun-head ::= "ghost"? kind? symbol param+ (":" result)? ; function header
  \
  kind ::= "function" | "predicate" | "lemma" ; function kind
  \
  result ::= ret-type                       ;
    | "(" ret-type ("," ret-type)* ")"      ;
    | "(" ret-name ("," ret-name)* ")"      ;
  \
  ret-type ::= "ghost"? type                ; unnamed result
  \
  ret-name ::= "ghost"? binder ":" type     ; named result
  \
  spec ::=
      "requires"  "{" term "}"                      ; pre-condition
    | "ensures"   "{" term "}"                      ; post-condition
    | "returns"   "{" ("|" pattern "->" term)+  "}" ; post-condition
    | "raises"    "{" ("|" pattern "->" term)+  "}" ; exceptional post-c.
    | "raises"    "{" uqualid ("," uqualid)*    "}" ; raised exceptions
    | "reads"     "{" lqualid ("," lqualid)*    "}" ; external reads
    | "writes"    "{" path ("," path)*          "}" ; memory writes
    | "alias"     "{" alias ("," alias)*        "}" ; memory aliases
    | "variant"   "{" variant ("," variant)*    "}" ; termination variant
    | "diverges"                                    ; may not terminate
    | ("reads" | "writes" | "alias") "{" "}"        ; empty effect
  \
  path ::= lqualid ("." lqualid)*           ; \texttt{v.field1.field2}
  \
  alias ::= path "with" path                ; \texttt{arg1 with result}
  \
  variant ::= term ("with" lqualid)?        ; variant + WF-order %
\end{syntax}
