doc-src/Ref/theory-syntax.tex
author wenzelm
Mon, 15 Jan 1996 15:49:21 +0100
changeset 1440 de6f18da81bb
parent 1385 63c3d78df538
child 1488 b25a747876a4
permissions -rw-r--r--
added this stuff;

%% $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 | type ) );

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

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

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


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

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


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

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

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}