\begin{syntax}
  module ::= "module" uident-nq label* mdecl* "end"
  \
  mdecl ::= decl                                ; theory declaration
    | "type" mtype-decl ("with" mtype-decl)*    ; mutable types
    | "type" lident-nq ("'" lident-nq)* invariant+    ; added invariant
    | "let" "ghost"? lident-nq label* pgm-defn     ;
    | "let" "rec" rec-defn                      ;
    | "val" "ghost"? lident-nq label* pgm-decl     ;
    | "exception" lident-nq label* type?           ;
    | "namespace" "import"? uident-nq mdecl* "end" ;
  \
  mtype-decl ::= lident-nq label* ("'" lident-nq label*)* ;
                              mtype-defn            ;
  \
  mtype-defn ::=                                    ; abstract type
    | "=" type                                      ; alias type
    | "=" "|"? type-case ("|" type-case)* invariant* ; algebraic type
    | "=" "{" mrecord-field (";" mrecord-field)* "}" ; record type
          invariant*
  \
  mrecord-field ::= "ghost"? "mutable"? lident-nq label* ":" type
  \
  pgm-defn ::= fun-body ;
    | "=" "fun" binder+ spec* "->" spec* expr ;
  \
  pgm-decl ::= ":" type                                  ; global variable
    | param (spec* param)+ ":" type spec*  ; abstract function%
\end{syntax}
