doc-src/TutorialI/basics.tex
changeset 16359 af7239e3054d
parent 16306 8117e2037d3b
child 16523 f8a734dc0fbc
equal deleted inserted replaced
16358:2e2a506553a3 16359:af7239e3054d
    85 \end{warn}
    85 \end{warn}
    86 HOL's theory collection is available online at
    86 HOL's theory collection is available online at
    87 \begin{center}\small
    87 \begin{center}\small
    88     \url{http://isabelle.in.tum.de/library/HOL/}
    88     \url{http://isabelle.in.tum.de/library/HOL/}
    89 \end{center}
    89 \end{center}
    90 and is recommended browsing.
    90 and is recommended browsing. In subdirectory \texttt{Library} you find
    91 There is also a growing Library~\cite{HOL-Library}\index{Library}
    91 a growing library of useful theories that are not part of \isa{Main}
    92 of useful theories that are not part of \isa{Main} but can be included
    92 but can be included among the parents of a theory and will then be
    93 among the parents of a theory and will then be loaded automatically.
    93 loaded automatically.
    94 
    94 
    95 For the more adventurous, there is the \emph{Archive of Formal Proofs},
    95 For the more adventurous, there is the \emph{Archive of Formal Proofs},
    96 a journal-like collection of more advanced Isabelle theories:
    96 a journal-like collection of more advanced Isabelle theories:
    97 \begin{center}\small
    97 \begin{center}\small
    98     \url{http://afp.sourceforge.net/}
    98     \url{http://afp.sourceforge.net/}
   132   to polymorphic types like \isa{'a \isasymFun~'a}, the type of the identity
   132   to polymorphic types like \isa{'a \isasymFun~'a}, the type of the identity
   133   function.
   133   function.
   134 \end{description}
   134 \end{description}
   135 \begin{warn}
   135 \begin{warn}
   136   Types are extremely important because they prevent us from writing
   136   Types are extremely important because they prevent us from writing
   137   nonsense.  Isabelle insists that all terms and formulae must be well-typed
   137   nonsense.  Isabelle insists that all terms and formulae must be
   138   and will print an error message if a type mismatch is encountered. To
   138   well-typed and will print an error message if a type mismatch is
   139   reduce the amount of explicit type information that needs to be provided by
   139   encountered. To reduce the amount of explicit type information that
   140   the user, Isabelle infers the type of all variables automatically (this is
   140   needs to be provided by the user, Isabelle infers the type of all
   141   called \bfindex{type inference}) and keeps quiet about it. Occasionally
   141   variables automatically (this is called \bfindex{type inference})
   142   this may lead to misunderstandings between you and the system. If anything
   142   and keeps quiet about it. Occasionally this may lead to
   143   strange happens, we recommend that you ask Isabelle to display all type
   143   misunderstandings between you and the system. If anything strange
   144   information. This is best done through the Proof General interface; see
   144   happens, we recommend that you ask Isabelle to display all type
   145   \S\ref{sec:interface} for details.
   145   information via the Proof General menu item \textsf{Isabelle} $>$
       
   146   \textsf{Settings} $>$ \textsf{Show Types} (see \S\ref{sec:interface}
       
   147   for details).
   146 \end{warn}%
   148 \end{warn}%
   147 \index{types|)}
   149 \index{types|)}
   148 
   150 
   149 
   151 
   150 \index{terms|(}
   152 \index{terms|(}
   255 For the sake of readability, we use the usual mathematical symbols throughout
   257 For the sake of readability, we use the usual mathematical symbols throughout
   256 the tutorial. Their \textsc{ascii}-equivalents are shown in table~\ref{tab:ascii} in
   258 the tutorial. Their \textsc{ascii}-equivalents are shown in table~\ref{tab:ascii} in
   257 the appendix.
   259 the appendix.
   258 
   260 
   259 \begin{warn}
   261 \begin{warn}
   260 A particular
   262 A particular problem for novices can be the priority of operators. If
   261 problem for novices can be the priority of operators. If you are unsure, use
   263 you are unsure, use additional parentheses. In those cases where
   262 additional parentheses. In those cases where Isabelle echoes your
   264 Isabelle echoes your input, you can see which parentheses are dropped
   263 input, you can see which parentheses are dropped --- they were superfluous. If
   265 --- they were superfluous. If you are unsure how to interpret
   264 you are unsure how to interpret Isabelle's output because you don't know
   266 Isabelle's output because you don't know where the (dropped)
   265 where the (dropped) parentheses go, set the flag\index{flags}
   267 parentheses go, set the Proof General flag \textsf{Isabelle} $>$
   266 \isa{show_brackets}\index{*show_brackets (flag)}:
   268 \textsf{Settings} $>$ \textsf{Show Brackets} (see \S\ref{sec:interface}).
   267 \begin{ttbox}
       
   268 ML "set show_brackets"; \(\dots\); ML "reset show_brackets";
       
   269 \end{ttbox}
       
   270 \end{warn}
   269 \end{warn}
   271 
   270 
   272 
   271 
   273 \section{Variables}
   272 \section{Variables}
   274 \label{sec:variables}
   273 \label{sec:variables}
   302 \index{variables|)}
   301 \index{variables|)}
   303 
   302 
   304 \section{Interaction and Interfaces}
   303 \section{Interaction and Interfaces}
   305 \label{sec:interface}
   304 \label{sec:interface}
   306 
   305 
   307 Interaction with Isabelle can either occur at the shell level or through more
   306 The recommended interface for Isabelle/Isar is the (X)Emacs-based
   308 advanced interfaces. To keep the tutorial independent of the interface, we
   307 \bfindex{Proof General}~\cite{proofgeneral,Aspinall:TACAS:2000}.
   309 have phrased the description of the interaction in a neutral language. For
   308 Interaction with Isabelle at the shell level, although possible,
   310 example, the phrase ``to abandon a proof'' means to type \isacommand{oops} at the
   309 should be avoided. Most of the tutorial is independent of the
   311 shell level, which is explained the first time the phrase is used. Other
   310 interface and is phrased in a neutral language. For example, the
   312 interfaces perform the same act by cursor movements and/or mouse clicks.
   311 phrase ``to abandon a proof'' corresponds to the obvious
   313 Although shell-based interaction is quite feasible for the kind of proof
   312 action of clicking on the \textsf{Undo} symbol in Proof General.
   314 scripts currently presented in this tutorial, the recommended interface for
   313 Proof General specific information is often displayed in paragraphs
   315 Isabelle/Isar is the Emacs-based \bfindex{Proof
   314 identified by a miniature Proof General icon. Here are two examples:
   316   General}~\cite{proofgeneral,Aspinall:TACAS:2000}.
       
   317 
       
   318 \begin{pgnote}
   315 \begin{pgnote}
   319 Proof General specific information is always displayed in paragraphs
   316 Proof General supports a special font with mathematical symbols known
   320 identified by this miniature Proof General icon.
   317 as ``x-symbols''. All symbols have \textsc{ascii}-equivalents: for
   321 
   318 example, you can enter either \verb!&!  or \verb!\<and>! to obtain
   322 On particularly nice feature of Proof General is its support for a special
   319 $\land$. For a list of the most frequent symbols see table~\ref{tab:ascii}
   323 fonts with mathematical symbols. Most symbols have
   320 in the appendix.
   324 \textsc{ascii}-equivalents: for example, you can enter either \verb!&!
   321 
   325 or \verb!\<and>! to obtain $\land$. For a list of the most frequent symbols
   322 Note that by default x-symbols are not enabled. You have to switch
   326 see table~\ref{tab:ascii} in the appendix.
   323 them on via the menu item \textsf{Proof-General} $>$ \textsf{Options} $>$
       
   324 \textsf{X-Symbols} (and save the option via the top-level
       
   325 \textsf{Options} menu).
   327 \end{pgnote}
   326 \end{pgnote}
   328 
   327 
   329 \begin{pgnote}
   328 \begin{pgnote}
   330 Proof General offers an \texttt{Isabelle} menu for displaying information
   329 Proof General offers the \textsf{Isabelle} menu for displaying
   331 and setting flags. A particularly useful flag is \texttt{Show Types}
   330 information and setting flags. A particularly useful flag is
   332 which causes Isabelle to output the type information that is usually
   331 \textsf{Isabelle} $>$ \textsf{Settings} $>$ \textsf{Show Types} which
       
   332 causes Isabelle to output the type information that is usually
   333 suppressed. This is indispensible in case of errors of all kinds
   333 suppressed. This is indispensible in case of errors of all kinds
   334 because often the types reveal the source of the problem. Once you have
   334 because often the types reveal the source of the problem. Once you
   335 diagnosed the problem you may no longer want to see the types because they
   335 have diagnosed the problem you may no longer want to see the types
   336 clutter all output. Simply reset the flag.
   336 because they clutter all output. Simply reset the flag.
   337 \end{pgnote}
   337 \end{pgnote}
   338 
   338 
   339 \section{Getting Started}
   339 \section{Getting Started}
   340 
   340 
   341 Assuming you have installed Isabelle, you start it by typing \texttt{isabelle
   341 Assuming you have installed Isabelle and Proof General, you start it by typing
   342   -I HOL} in a shell window.\footnote{Simply executing \texttt{isabelle -I}
   342 \texttt{Isabelle} in a shell window. This launches a Proof General window.
   343   starts the default logic, which usually is already \texttt{HOL}.  This is
   343 By default, you are in HOL\footnote{This is controlled by the
   344   controlled by the \texttt{ISABELLE_LOGIC} setting, see \emph{The Isabelle
   344 \texttt{ISABELLE_LOGIC} setting, see \emph{The Isabelle System Manual}
   345     System Manual} for more details.} This presents you with Isabelle's most
   345 for more details.}.
   346 basic \textsc{ascii} interface.  In addition you need to open an editor window to
   346 
   347 create theory files.  While you are developing a theory, we recommend that you
   347 \begin{pgnote}
   348 type each command into the file first and then enter it into Isabelle by
   348 You can choose a different logic via the \textsf{Isabelle} $>$
   349 copy-and-paste, thus ensuring that you have a complete record of your theory.
   349 \textsf{Logics} menu. For example, you may want to work in the real
   350 As mentioned above, Proof General offers a much superior interface.
   350 numbers, an extension of HOL (see \S\ref{sec:real}).
   351 If you have installed Proof General, you can start it by typing \texttt{Isabelle}.
   351 % This is just excess baggage:
       
   352 %(You have to restart Proof General if you only compile the new logic
       
   353 %after having launching Proof General already).
       
   354 \end{pgnote}