doc-src/TutorialI/basics.tex
changeset 8771 026f37a86ea7
parent 8743 3253c6046d57
child 9541 d17c0b34d5c8
equal deleted inserted replaced
8770:bfab4d4b7516 8771:026f37a86ea7
    46 end
    46 end
    47 \end{ttbox}
    47 \end{ttbox}
    48 where \texttt{B}$@1$, \dots, \texttt{B}$@n$ are the names of existing
    48 where \texttt{B}$@1$, \dots, \texttt{B}$@n$ are the names of existing
    49 theories that \texttt{T} is based on and \texttt{\textit{declarations,
    49 theories that \texttt{T} is based on and \texttt{\textit{declarations,
    50     definitions, and proofs}} represents the newly introduced concepts
    50     definitions, and proofs}} represents the newly introduced concepts
    51 (types, functions etc) and proofs about them. The \texttt{B}$@i$ are the
    51 (types, functions etc.) and proofs about them. The \texttt{B}$@i$ are the
    52 direct \textbf{parent theories}\indexbold{parent theory} of \texttt{T}.
    52 direct \textbf{parent theories}\indexbold{parent theory} of \texttt{T}.
    53 Everything defined in the parent theories (and their parents \dots) is
    53 Everything defined in the parent theories (and their parents \dots) is
    54 automatically visible. To avoid name clashes, identifiers can be
    54 automatically visible. To avoid name clashes, identifiers can be
    55 \textbf{qualified} by theory names as in \texttt{T.f} and
    55 \textbf{qualified} by theory names as in \texttt{T.f} and
    56 \texttt{B.f}.\indexbold{identifier!qualified} Each theory \texttt{T} must
    56 \texttt{B.f}.\indexbold{identifier!qualified} Each theory \texttt{T} must
    57 reside in a \indexbold{theory file} named \texttt{T.thy}.
    57 reside in a \bfindex{theory file} named \texttt{T.thy}.
    58 
    58 
    59 This tutorial is concerned with introducing you to the different linguistic
    59 This tutorial is concerned with introducing you to the different linguistic
    60 constructs that can fill \textit{\texttt{declarations, definitions, and
    60 constructs that can fill \textit{\texttt{declarations, definitions, and
    61     proofs}} in the above theory template.  A complete grammar of the basic
    61     proofs}} in the above theory template.  A complete grammar of the basic
    62 constructs is found in the Isabelle/Isar Reference Manual.
    62 constructs is found in the Isabelle/Isar Reference Manual.
    72   library).  Unless you know what you are doing, always include \texttt{Main}
    72   library).  Unless you know what you are doing, always include \texttt{Main}
    73   as a direct or indirect parent theory of all your theories.
    73   as a direct or indirect parent theory of all your theories.
    74 \end{warn}
    74 \end{warn}
    75 
    75 
    76 
    76 
    77 \section{Interaction and interfaces}
       
    78 
       
    79 Interaction with Isabelle can either occur at the shell level or through more
       
    80 advanced interfaces. To keep the tutorial independent of the interface we
       
    81 have phrased the description of the intraction in a neutral language. For
       
    82 example, the phrase ``to cancel a proof'' means to type \texttt{oops} at the
       
    83 shell level, which is explained the first time the phrase is used. Other
       
    84 interfaces perform the same act by cursor movements and/or mouse clicks.
       
    85 Although shell-based interaction is quite feasible for the kind of proof
       
    86 scripts currently presented in this tutorial, the recommended interface for
       
    87 Isabelle/Isar is the Emacs-based \bfindex{Proof
       
    88   General}~\cite{Aspinall:TACAS:2000,proofgeneral}.
       
    89 
       
    90 To improve readability some of the interfaces (including the shell level)
       
    91 offer special fonts with mathematical symbols. Therefore the usual
       
    92 mathematical symbols are used throughout the tutorial. Their
       
    93 ASCII-equivalents are shown in figure~\ref{fig:ascii} in the appendix.
       
    94 
       
    95 Finally, a word about semicolons.\indexbold{$Isar@\texttt{;}} Some interfaces,
       
    96 for example Proof General, require each command to be terminated by a
       
    97 semicolon, whereas others, for example the shell level, do not. But even at
       
    98 the shell level it is advisable to use semicolons to enforce that a command
       
    99 is executed immediately; otherwise Isabelle may wait for the next keyword
       
   100 before it knows that the command is complete. Note that for readibility
       
   101 reasons we often drop the final semicolon in the text.
       
   102 
       
   103 
       
   104 \section{Types, terms and formulae}
    77 \section{Types, terms and formulae}
   105 \label{sec:TypesTermsForms}
    78 \label{sec:TypesTermsForms}
   106 \indexbold{type}
    79 \indexbold{type}
   107 
    80 
   108 Embedded in the declarations of a theory are the types, terms and formulae of
    81 Embedded in a theory are the types, terms and formulae of HOL. HOL is a typed
   109 HOL. HOL is a typed logic whose type system resembles that of functional
    82 logic whose type system resembles that of functional programming languages
   110 programming languages like ML or Haskell. Thus there are
    83 like ML or Haskell. Thus there are
   111 \begin{description}
    84 \begin{description}
   112 \item[base types,] in particular \ttindex{bool}, the type of truth values,
    85 \item[base types,] in particular \isaindex{bool}, the type of truth values,
   113 and \ttindex{nat}, the type of natural numbers.
    86 and \isaindex{nat}, the type of natural numbers.
   114 \item[type constructors,] in particular \texttt{list}, the type of
    87 \item[type constructors,] in particular \isaindex{list}, the type of
   115 lists, and \texttt{set}, the type of sets. Type constructors are written
    88 lists, and \isaindex{set}, the type of sets. Type constructors are written
   116 postfix, e.g.\ \texttt{(nat)list} is the type of lists whose elements are
    89 postfix, e.g.\ \isa{(nat)list} is the type of lists whose elements are
   117 natural numbers. Parentheses around single arguments can be dropped (as in
    90 natural numbers. Parentheses around single arguments can be dropped (as in
   118 \texttt{nat list}), multiple arguments are separated by commas (as in
    91 \isa{nat list}), multiple arguments are separated by commas (as in
   119 \texttt{(bool,nat)foo}).
    92 \isa{(bool,nat)ty}).
   120 \item[function types,] denoted by \isasymFun\indexbold{$IsaFun@\isasymFun}.
    93 \item[function types,] denoted by \isasymFun\indexbold{$IsaFun@\isasymFun}.
   121   In HOL \isasymFun\ represents {\em total} functions only. As is customary,
    94   In HOL \isasymFun\ represents \emph{total} functions only. As is customary,
   122   \texttt{$\tau@1$ \isasymFun~$\tau@2$ \isasymFun~$\tau@3$} means
    95   \isa{$\tau@1$ \isasymFun~$\tau@2$ \isasymFun~$\tau@3$} means
   123   \texttt{$\tau@1$ \isasymFun~($\tau@2$ \isasymFun~$\tau@3$)}. Isabelle also
    96   \isa{$\tau@1$ \isasymFun~($\tau@2$ \isasymFun~$\tau@3$)}. Isabelle also
   124   supports the notation \texttt{[$\tau@1,\dots,\tau@n$] \isasymFun~$\tau$}
    97   supports the notation \isa{[$\tau@1,\dots,\tau@n$] \isasymFun~$\tau$}
   125   which abbreviates \texttt{$\tau@1$ \isasymFun~$\cdots$ \isasymFun~$\tau@n$
    98   which abbreviates \isa{$\tau@1$ \isasymFun~$\cdots$ \isasymFun~$\tau@n$
   126     \isasymFun~$\tau$}.
    99     \isasymFun~$\tau$}.
   127 \item[type variables,] denoted by \texttt{'a}, \texttt{'b} etc, just like in
   100 \item[type variables,]\indexbold{type variable}\indexbold{variable!type}
   128 ML. They give rise to polymorphic types like \texttt{'a \isasymFun~'a}, the
   101   denoted by \isaindexbold{'a}, \isa{'b} etc., just like in ML. They give rise
   129 type of the identity function.
   102   to polymorphic types like \isa{'a \isasymFun~'a}, the type of the identity
       
   103   function.
   130 \end{description}
   104 \end{description}
   131 \begin{warn}
   105 \begin{warn}
   132   Types are extremely important because they prevent us from writing
   106   Types are extremely important because they prevent us from writing
   133   nonsense.  Isabelle insists that all terms and formulae must be well-typed
   107   nonsense.  Isabelle insists that all terms and formulae must be well-typed
   134   and will print an error message if a type mismatch is encountered. To
   108   and will print an error message if a type mismatch is encountered. To
   143 ML "set show_types"
   117 ML "set show_types"
   144 \end{ttbox}
   118 \end{ttbox}
   145 
   119 
   146 \noindent
   120 \noindent
   147 This can be reversed by \texttt{ML "reset show_types"}. Various other flags
   121 This can be reversed by \texttt{ML "reset show_types"}. Various other flags
   148 can be set and reset in the same manner.\bfindex{flag!(re)setting}
   122 can be set and reset in the same manner.\indexbold{flag!(re)setting}
   149 \end{warn}
   123 \end{warn}
   150 
   124 
   151 
   125 
   152 \textbf{Terms}\indexbold{term} are formed as in functional programming by
   126 \textbf{Terms}\indexbold{term} are formed as in functional programming by
   153 applying functions to arguments. If \texttt{f} is a function of type
   127 applying functions to arguments. If \isa{f} is a function of type
   154 \texttt{$\tau@1$ \isasymFun~$\tau@2$} and \texttt{t} is a term of type
   128 \isa{$\tau@1$ \isasymFun~$\tau@2$} and \isa{t} is a term of type
   155 $\tau@1$ then \texttt{f~t} is a term of type $\tau@2$. HOL also supports
   129 $\tau@1$ then \isa{f~t} is a term of type $\tau@2$. HOL also supports
   156 infix functions like \texttt{+} and some basic constructs from functional
   130 infix functions like \isa{+} and some basic constructs from functional
   157 programming:
   131 programming:
   158 \begin{description}
   132 \begin{description}
   159 \item[\texttt{if $b$ then $t@1$ else $t@2$}]\indexbold{*if}
   133 \item[\isa{if $b$ then $t@1$ else $t@2$}]\indexbold{*if}
   160 means what you think it means and requires that
   134 means what you think it means and requires that
   161 $b$ is of type \texttt{bool} and $t@1$ and $t@2$ are of the same type.
   135 $b$ is of type \isa{bool} and $t@1$ and $t@2$ are of the same type.
   162 \item[\texttt{let $x$ = $t$ in $u$}]\indexbold{*let}
   136 \item[\isa{let $x$ = $t$ in $u$}]\indexbold{*let}
   163 is equivalent to $u$ where all occurrences of $x$ have been replaced by
   137 is equivalent to $u$ where all occurrences of $x$ have been replaced by
   164 $t$. For example,
   138 $t$. For example,
   165 \texttt{let x = 0 in x+x} means \texttt{0+0}. Multiple bindings are separated
   139 \isa{let x = 0 in x+x} is equivalent to \isa{0+0}. Multiple bindings are separated
   166 by semicolons: \texttt{let $x@1$ = $t@1$; \dots; $x@n$ = $t@n$ in $u$}.
   140 by semicolons: \isa{let $x@1$ = $t@1$; \dots; $x@n$ = $t@n$ in $u$}.
   167 \item[\texttt{case $e$ of $c@1$ \isasymFun~$e@1$ |~\dots~| $c@n$ \isasymFun~$e@n$}]
   141 \item[\isa{case $e$ of $c@1$ \isasymFun~$e@1$ |~\dots~| $c@n$ \isasymFun~$e@n$}]
   168 \indexbold{*case}
   142 \indexbold{*case}
   169 evaluates to $e@i$ if $e$ is of the form
   143 evaluates to $e@i$ if $e$ is of the form $c@i$.
   170 $c@i$. See~\S\ref{sec:case-expressions} for details.
       
   171 \end{description}
   144 \end{description}
   172 
   145 
   173 Terms may also contain
   146 Terms may also contain
   174 \isasymlambda-abstractions\indexbold{$Isalam@\isasymlambda}. For example,
   147 \isasymlambda-abstractions\indexbold{$Isalam@\isasymlambda}. For example,
   175 \texttt{\isasymlambda{}x.~x+1} is the function that takes an argument
   148 \isa{\isasymlambda{}x.~x+1} is the function that takes an argument \isa{x} and
   176 \texttt{x} and returns \texttt{x+1}. Instead of
   149 returns \isa{x+1}. Instead of
   177 \texttt{\isasymlambda{}x.\isasymlambda{}y.\isasymlambda{}z.}~$t$ we can write
   150 \isa{\isasymlambda{}x.\isasymlambda{}y.\isasymlambda{}z.~$t$} we can write
   178 \texttt{\isasymlambda{}x~y~z.}~$t$.
   151 \isa{\isasymlambda{}x~y~z.~$t$}.
   179 
   152 
   180 \textbf{Formulae}\indexbold{formula}
   153 \textbf{Formulae}\indexbold{formula} are terms of type \isaindexbold{bool}.
   181 are terms of type \texttt{bool}. There are the basic
   154 There are the basic constants \isaindexbold{True} and \isaindexbold{False} and
   182 constants \ttindexbold{True} and \ttindexbold{False} and the usual logical
   155 the usual logical connectives (in decreasing order of priority):
   183 connectives (in decreasing order of priority):
   156 \indexboldpos{\isasymnot}{$HOL0not}, \indexboldpos{\isasymand}{$HOL0and},
   184 \indexboldpos{\isasymnot}{$HOL0not},
   157 \indexboldpos{\isasymor}{$HOL0or}, and \indexboldpos{\isasymimp}{$HOL0imp},
   185 \indexboldpos{\isasymand}{$HOL0and},
       
   186 \indexboldpos{\isasymor}{$HOL0or}, and
       
   187 \indexboldpos{\isasymimp}{$HOL0imp},
       
   188 all of which (except the unary \isasymnot) associate to the right. In
   158 all of which (except the unary \isasymnot) associate to the right. In
   189 particular \texttt{A \isasymimp~B \isasymimp~C} means
   159 particular \isa{A \isasymimp~B \isasymimp~C} means \isa{A \isasymimp~(B
   190 \texttt{A \isasymimp~(B \isasymimp~C)} and is thus
   160   \isasymimp~C)} and is thus logically equivalent to \isa{A \isasymand~B
   191 logically equivalent with \texttt{A \isasymand~B \isasymimp~C}
   161   \isasymimp~C} (which is \isa{(A \isasymand~B) \isasymimp~C}).
   192 (which is \texttt{(A \isasymand~B) \isasymimp~C}).
       
   193 
   162 
   194 Equality is available in the form of the infix function
   163 Equality is available in the form of the infix function
   195 \texttt{=}\indexbold{$HOL0eq@\texttt{=}} of type \texttt{'a \isasymFun~'a
   164 \isa{=}\indexbold{$HOL0eq@\texttt{=}} of type \isa{'a \isasymFun~'a
   196   \isasymFun~bool}. Thus \texttt{$t@1$ = $t@2$} is a formula provided $t@1$
   165   \isasymFun~bool}. Thus \isa{$t@1$ = $t@2$} is a formula provided $t@1$
   197 and $t@2$ are terms of the same type. In case $t@1$ and $t@2$ are of type
   166 and $t@2$ are terms of the same type. In case $t@1$ and $t@2$ are of type
   198 \texttt{bool}, \texttt{=} acts as if-and-only-if. The formula
   167 \isa{bool}, \isa{=} acts as if-and-only-if. The formula
   199 $t@1$~\isasymnoteq~$t@2$ is merely an abbreviation for
   168 \isa{$t@1$~\isasymnoteq~$t@2$} is merely an abbreviation for
   200 \texttt{\isasymnot($t@1$ = $t@2$)}.
   169 \isa{\isasymnot($t@1$ = $t@2$)}.
   201 
   170 
   202 The syntax for quantifiers is
   171 The syntax for quantifiers is
   203 \texttt{\isasymforall{}x.}~$P$\indexbold{$HOL0All@\isasymforall} and
   172 \isa{\isasymforall{}x.~$P$}\indexbold{$HOL0All@\isasymforall} and
   204 \texttt{\isasymexists{}x.}~$P$\indexbold{$HOL0Ex@\isasymexists}.  There is
   173 \isa{\isasymexists{}x.~$P$}\indexbold{$HOL0Ex@\isasymexists}.  There is
   205 even \texttt{\isasymuniqex{}x.}~$P$\index{$HOL0ExU@\isasymuniqex|bold}, which
   174 even \isa{\isasymuniqex{}x.~$P$}\index{$HOL0ExU@\isasymuniqex|bold}, which
   206 means that there exists exactly one \texttt{x} that satisfies $P$.
   175 means that there exists exactly one \isa{x} that satisfies \isa{$P$}.  Nested
   207 Nested quantifications can be abbreviated:
   176 quantifications can be abbreviated: \isa{\isasymforall{}x~y~z.~$P$} means
   208 \texttt{\isasymforall{}x~y~z.}~$P$ means
   177 \isa{\isasymforall{}x.\isasymforall{}y.\isasymforall{}z.~$P$}.
   209 \texttt{\isasymforall{}x.\isasymforall{}y.\isasymforall{}z.}~$P$.
       
   210 
   178 
   211 Despite type inference, it is sometimes necessary to attach explicit
   179 Despite type inference, it is sometimes necessary to attach explicit
   212 \bfindex{type constraints} to a term.  The syntax is \texttt{$t$::$\tau$} as
   180 \textbf{type constraints}\indexbold{type constraint} to a term.  The syntax is
   213 in \texttt{x < (y::nat)}. Note that \ttindexboldpos{::}{$Isalamtc} binds weakly
   181 \isa{$t$::$\tau$} as in \isa{x < (y::nat)}. Note that
   214 and should therefore be enclosed in parentheses: \texttt{x < y::nat} is
   182 \ttindexboldpos{::}{$Isalamtc} binds weakly and should therefore be enclosed
   215 ill-typed because it is interpreted as \texttt{(x < y)::nat}. The main reason
   183 in parentheses: \isa{x < y::nat} is ill-typed because it is interpreted as
   216 for type constraints are overloaded functions like \texttt{+}, \texttt{*} and
   184 \isa{(x < y)::nat}. The main reason for type constraints are overloaded
   217 \texttt{<}. (See \S\ref{sec:TypeClasses} for a full discussion of
   185 functions like \isa{+}, \isa{*} and \isa{<}. (See \S\ref{sec:TypeClasses} for
   218 overloading.)
   186 a full discussion of overloading.)
   219 
   187 
   220 \begin{warn}
   188 \begin{warn}
   221 In general, HOL's concrete syntax tries to follow the conventions of
   189 In general, HOL's concrete syntax tries to follow the conventions of
   222 functional programming and mathematics. Below we list the main rules that you
   190 functional programming and mathematics. Below we list the main rules that you
   223 should be familiar with to avoid certain syntactic traps. A particular
   191 should be familiar with to avoid certain syntactic traps. A particular
   232 \end{ttbox}
   200 \end{ttbox}
   233 \end{warn}
   201 \end{warn}
   234 
   202 
   235 \begin{itemize}
   203 \begin{itemize}
   236 \item
   204 \item
   237 Remember that \texttt{f t u} means \texttt{(f t) u} and not \texttt{f(t u)}!
   205 Remember that \isa{f t u} means \isa{(f t) u} and not \isa{f(t u)}!
   238 \item
   206 \item
   239 Isabelle allows infix functions like \texttt{+}. The prefix form of function
   207 Isabelle allows infix functions like \isa{+}. The prefix form of function
   240 application binds more strongly than anything else and hence \texttt{f~x + y}
   208 application binds more strongly than anything else and hence \isa{f~x + y}
   241 means \texttt{(f~x)~+~y} and not \texttt{f(x+y)}.
   209 means \isa{(f~x)~+~y} and not \isa{f(x+y)}.
   242 \item Remember that in HOL if-and-only-if is expressed using equality.  But
   210 \item Remember that in HOL if-and-only-if is expressed using equality.  But
   243   equality has a high priority, as befitting a relation, while if-and-only-if
   211   equality has a high priority, as befitting a relation, while if-and-only-if
   244   typically has the lowest priority.  Thus, \texttt{\isasymnot~\isasymnot~P =
   212   typically has the lowest priority.  Thus, \isa{\isasymnot~\isasymnot~P =
   245     P} means \texttt{\isasymnot\isasymnot(P = P)} and not
   213     P} means \isa{\isasymnot\isasymnot(P = P)} and not
   246   \texttt{(\isasymnot\isasymnot P) = P}. When using \texttt{=} to mean
   214   \isa{(\isasymnot\isasymnot P) = P}. When using \isa{=} to mean
   247   logical equivalence, enclose both operands in parentheses, as in \texttt{(A
   215   logical equivalence, enclose both operands in parentheses, as in \isa{(A
   248     \isasymand~B) = (B \isasymand~A)}.
   216     \isasymand~B) = (B \isasymand~A)}.
   249 \item
   217 \item
   250 Constructs with an opening but without a closing delimiter bind very weakly
   218 Constructs with an opening but without a closing delimiter bind very weakly
   251 and should therefore be enclosed in parentheses if they appear in subterms, as
   219 and should therefore be enclosed in parentheses if they appear in subterms, as
   252 in \texttt{f = (\isasymlambda{}x.~x)}. This includes \ttindex{if},
   220 in \isa{f = (\isasymlambda{}x.~x)}. This includes \isaindex{if},
   253 \ttindex{let}, \ttindex{case}, \isasymlambda, and quantifiers.
   221 \isaindex{let}, \isaindex{case}, \isa{\isasymlambda}, and quantifiers.
   254 \item
   222 \item
   255 Never write \texttt{\isasymlambda{}x.x} or \texttt{\isasymforall{}x.x=x}
   223 Never write \isa{\isasymlambda{}x.x} or \isa{\isasymforall{}x.x=x}
   256 because \texttt{x.x} is always read as a single qualified identifier that
   224 because \isa{x.x} is always read as a single qualified identifier that
   257 refers to an item \texttt{x} in theory \texttt{x}. Write
   225 refers to an item \isa{x} in theory \isa{x}. Write
   258 \texttt{\isasymlambda{}x.~x} and \texttt{\isasymforall{}x.~x=x} instead.
   226 \isa{\isasymlambda{}x.~x} and \isa{\isasymforall{}x.~x=x} instead.
   259 \item Identifiers\indexbold{identifier} may contain \texttt{_} and \texttt{'}.
   227 \item Identifiers\indexbold{identifier} may contain \isa{_} and \isa{'}.
   260 \end{itemize}
   228 \end{itemize}
   261 
   229 
   262 Remember that ASCII-equivalents of all mathematical symbols are
   230 For the sake of readability the usual mathematical symbols are used throughout
   263 given in figure~\ref{fig:ascii} in the appendix.
   231 the tutorial. Their ASCII-equivalents are shown in figure~\ref{fig:ascii} in
       
   232 the appendix.
       
   233 
   264 
   234 
   265 \section{Variables}
   235 \section{Variables}
   266 \label{sec:variables}
   236 \label{sec:variables}
   267 \indexbold{variable}
   237 \indexbold{variable}
   268 
   238 
   269 Isabelle distinguishes free and bound variables just as is customary. Bound
   239 Isabelle distinguishes free and bound variables just as is customary. Bound
   270 variables are automatically renamed to avoid clashes with free variables. In
   240 variables are automatically renamed to avoid clashes with free variables. In
   271 addition, Isabelle has a third kind of variable, called a \bfindex{schematic
   241 addition, Isabelle has a third kind of variable, called a \bfindex{schematic
   272   variable}\indexbold{variable!schematic} or \bfindex{unknown}, which starts
   242   variable}\indexbold{variable!schematic} or \bfindex{unknown}, which starts
   273 with a \texttt{?}.  Logically, an unknown is a free variable. But it may be
   243 with a \isa{?}.  Logically, an unknown is a free variable. But it may be
   274 instantiated by another term during the proof process. For example, the
   244 instantiated by another term during the proof process. For example, the
   275 mathematical theorem $x = x$ is represented in Isabelle as \texttt{?x = ?x},
   245 mathematical theorem $x = x$ is represented in Isabelle as \isa{?x = ?x},
   276 which means that Isabelle can instantiate it arbitrarily. This is in contrast
   246 which means that Isabelle can instantiate it arbitrarily. This is in contrast
   277 to ordinary variables, which remain fixed. The programming language Prolog
   247 to ordinary variables, which remain fixed. The programming language Prolog
   278 calls unknowns {\em logical\/} variables.
   248 calls unknowns {\em logical\/} variables.
   279 
   249 
   280 Most of the time you can and should ignore unknowns and work with ordinary
   250 Most of the time you can and should ignore unknowns and work with ordinary
   281 variables. Just don't be surprised that after you have finished the proof of
   251 variables. Just don't be surprised that after you have finished the proof of
   282 a theorem, Isabelle will turn your free variables into unknowns: it merely
   252 a theorem, Isabelle will turn your free variables into unknowns: it merely
   283 indicates that Isabelle will automatically instantiate those unknowns
   253 indicates that Isabelle will automatically instantiate those unknowns
   284 suitably when the theorem is used in some other proof.
   254 suitably when the theorem is used in some other proof.
   285 \begin{warn}
   255 \begin{warn}
   286   If you use \texttt{?}\index{$HOL0Ex@\texttt{?}} as an existential
   256   If you use \isa{?}\index{$HOL0Ex@\texttt{?}} as an existential
   287   quantifier, it needs to be followed by a space. Otherwise \texttt{?x} is
   257   quantifier, it needs to be followed by a space. Otherwise \isa{?x} is
   288   interpreted as a schematic variable.
   258   interpreted as a schematic variable.
   289 \end{warn}
   259 \end{warn}
       
   260 
       
   261 \section{Interaction and interfaces}
       
   262 
       
   263 Interaction with Isabelle can either occur at the shell level or through more
       
   264 advanced interfaces. To keep the tutorial independent of the interface we
       
   265 have phrased the description of the intraction in a neutral language. For
       
   266 example, the phrase ``to abandon a proof'' means to type \isacommand{oops} at the
       
   267 shell level, which is explained the first time the phrase is used. Other
       
   268 interfaces perform the same act by cursor movements and/or mouse clicks.
       
   269 Although shell-based interaction is quite feasible for the kind of proof
       
   270 scripts currently presented in this tutorial, the recommended interface for
       
   271 Isabelle/Isar is the Emacs-based \bfindex{Proof
       
   272   General}~\cite{Aspinall:TACAS:2000,proofgeneral}.
       
   273 
       
   274 Some interfaces (including the shell level) offer special fonts with
       
   275 mathematical symbols. For those that do not, remember that ASCII-equivalents
       
   276 are shown in figure~\ref{fig:ascii} in the appendix.
       
   277 
       
   278 Finally, a word about semicolons.\indexbold{$Isar@\texttt{;}} Some interfaces,
       
   279 for example Proof General, require each command to be terminated by a
       
   280 semicolon, whereas others, for example the shell level, do not. But even at
       
   281 the shell level it is advisable to use semicolons to enforce that a command
       
   282 is executed immediately; otherwise Isabelle may wait for the next keyword
       
   283 before it knows that the command is complete. Note that for readibility
       
   284 reasons we often drop the final semicolon in the text.
       
   285 
   290 
   286 
   291 \section{Getting started}
   287 \section{Getting started}
   292 
   288 
   293 Assuming you have installed Isabelle, you start it by typing \texttt{isabelle
   289 Assuming you have installed Isabelle, you start it by typing \texttt{isabelle
   294   -I HOL} in a shell window.\footnote{Simply executing \texttt{isabelle -I}
   290   -I HOL} in a shell window.\footnote{Simply executing \texttt{isabelle -I}
   297     System Manual} for more details.} This presents you with Isabelle's most
   293     System Manual} for more details.} This presents you with Isabelle's most
   298 basic ASCII interface.  In addition you need to open an editor window to
   294 basic ASCII interface.  In addition you need to open an editor window to
   299 create theory files.  While you are developing a theory, we recommend to
   295 create theory files.  While you are developing a theory, we recommend to
   300 type each command into the file first and then enter it into Isabelle by
   296 type each command into the file first and then enter it into Isabelle by
   301 copy-and-paste, thus ensuring that you have a complete record of your theory.
   297 copy-and-paste, thus ensuring that you have a complete record of your theory.
   302 As mentioned earlier, Proof General offers a much superior interface.
   298 As mentioned above, Proof General offers a much superior interface.