doc-src/Ref/theory-syntax.tex
author clasohm
Fri, 01 Dec 1995 12:26:42 +0100
changeset 1379 8f693d2ffb59
parent 1375 d04af07266e8
child 1382 7e97232c1159
permissions -rw-r--r--
modified simpleType

%% $Id$

\appendix
\newlinechar=-1  %mathsing.sty sets \newlinechar=`\|, which would cause mayhem

\chapter{Syntax of Isabelle Theories}\label{app:TheorySyntax}
Chapter~\ref{sec:ref-defining-theories} explains the meanings of these
constructs.  The syntax obeys the following conventions:
\begin{itemize}
\item {\tt Typewriter font} denotes terminal symbols.
\item $id$, $tid$, $nat$, $string$ and $text$ are the lexical classes of
  identifiers, type identifiers, natural numbers, \ML\ strings (with their
  quotation marks, but without the need for \verb$\$ at the end of a line and
  the beginning of the next line) and arbitrary \ML\ text.  The first three
  are fully defined in \iflabelundefined{Defining-Logics}%
    {{\it The Isabelle Reference Manual}, chapter `Defining Logics'}%
    {Chap.\ts\ref{Defining-Logics}}.
\end{itemize}
Comments in theories take the form {\tt (*} {\it text\/} {\tt*)}, where
{\it text\/} should not contain the character sequence {\tt*)}.

\begin{rail}

theoryDef : id '=' (name + '+') ('+' extension | ());

name: id | string;

extension : (section +) 'end' ( () | ml );

section : classes
        | default
        | types
        | arities
        | consts
        | trans
        | defs
        | rules
        ;

classes : 'classes' ( ( id (  ()
                            | '<' (id + ',')
                           ) 
                       ) + )
        ;

default : 'default' sort 
        ;

sort :  id
     | '\{' (id * ',') '\}'
     ;

types : 'types' ( ( typeDecl ( () | '(' infix ')' ) ) + )
      ;

typeDecl : ( () | tid | '(' ( tid + ',' ) ')') name ( () | '='  string );

infix : ( 'infixr' | 'infixl' ) nat;


arities : 'arities' ((( name + ',' ) '::' arity ) + )
        ;

arity   : ( () 
          | '(' (sort + ',') ')' 
          ) id
        ;


consts : 'consts' ( ( constDecl ( () | ( '(' mixfix ')' ) ) ) + )
       ;

constDecl : ( name + ',') '::' (string | constType);

constType : simpleType | '(' constType ')' | '[' ( constType + "," ) ']'
            '=>' constType | constType '=>' constType;

simpleType: id | ( tid ( () | '::' id ) ) |
            '(' ( constType + "," ) ')' ( id + ',' ) | simpleType ( id + ',' );

mixfix :  string ( () | ( () | ('[' (nat + ',') ']')) nat )
       | infix
       | 'binder' string nat ;

trans : 'translations' ( pat ( '==' | '=>' | '<=' ) pat + )
      ;

pat : ( () | ( '(' id ')' ) ) string;

rules : 'rules' (( id string ) + )
      ;

defs : 'defs' (( id string ) + )
     ;

ml : 'ML' text
   ;

\end{rail}