doc-src/IsarRef/Thy/pure.thy
author wenzelm
Fri, 09 May 2008 23:20:17 +0200
changeset 26866 3cff7b336c75
parent 26852 a31203f58b20
child 26870 94bedbb34b92
permissions -rw-r--r--
proper antiquotations for commands;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     1
(* $Id$ *)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     2
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     3
theory pure
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     4
imports CPure
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     5
begin
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     6
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     7
chapter {* Basic language elements \label{ch:pure-syntax} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     8
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     9
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    10
  Subsequently, we introduce the main part of Pure theory and proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    11
  commands, together with fundamental proof methods and attributes.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    12
  \Chref{ch:gen-tools} describes further Isar elements provided by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    13
  generic tools and packages (such as the Simplifier) that are either
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    14
  part of Pure Isabelle or pre-installed in most object logics.
26852
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
    15
  Specific language elements introduced by the major object-logics are
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
    16
  described in \chref{ch:hol} (Isabelle/HOL), \chref{ch:holcf}
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
    17
  (Isabelle/HOLCF), and \chref{ch:zf} (Isabelle/ZF).  Nevertheless,
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
    18
  examples given in the generic parts will usually refer to
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
    19
  Isabelle/HOL as well.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    20
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    21
  \medskip Isar commands may be either \emph{proper} document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    22
  constructors, or \emph{improper commands}.  Some proof methods and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    23
  attributes introduced later are classified as improper as well.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    24
  Improper Isar language elements, which are subsequently marked by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    25
  ``@{text "\<^sup>*"}'', are often helpful when developing proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    26
  documents, while their use is discouraged for the final
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    27
  human-readable outcome.  Typical examples are diagnostic commands
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    28
  that print terms or theorems according to the current context; other
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    29
  commands emulate old-style tactical theorem proving.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    30
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    31
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    32
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    33
section {* Theory commands *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    34
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    35
subsection {* Defining theories \label{sec:begin-thy} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    36
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    37
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    38
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    39
    @{command_def "header"} & : & \isarkeep{toplevel} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    40
    @{command_def "theory"} & : & \isartrans{toplevel}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    41
    @{command_def "end"} & : & \isartrans{theory}{toplevel} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    42
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    43
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    44
  Isabelle/Isar theories are defined via theory, which contain both
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    45
  specifications and proofs; occasionally definitional mechanisms also
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    46
  require some explicit proof.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    47
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    48
  The first ``real'' command of any theory has to be @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    49
  "theory"}, which starts a new theory based on the merge of existing
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    50
  ones.  Just preceding the @{command "theory"} keyword, there may be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    51
  an optional @{command "header"} declaration, which is relevant to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    52
  document preparation only; it acts very much like a special
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    53
  pre-theory markup command (cf.\ \secref{sec:markup-thy} and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    54
  \secref{sec:markup-thy}).  The @{command "end"} command concludes a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    55
  theory development; it has to be the very last command of any theory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    56
  file loaded in batch-mode.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    57
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    58
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    59
    'header' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    60
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    61
    'theory' name 'imports' (name +) uses? 'begin'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    62
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    63
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    64
    uses: 'uses' ((name | parname) +);
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    65
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    66
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    67
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    68
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    69
  \item [@{command "header"}~@{text "text"}] provides plain text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    70
  markup just preceding the formal beginning of a theory.  In actual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    71
  document preparation the corresponding {\LaTeX} macro @{verbatim
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    72
  "\\isamarkupheader"} may be redefined to produce chapter or section
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    73
  headings.  See also \secref{sec:markup-thy} and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    74
  \secref{sec:markup-prf} for further markup commands.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    75
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    76
  \item [@{command "theory"}~@{text "A \<IMPORTS> B\<^sub>1 \<dots>
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    77
  B\<^sub>n \<BEGIN>"}] starts a new theory @{text A} based on the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    78
  merge of existing theories @{text "B\<^sub>1 \<dots> B\<^sub>n"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    79
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    80
  Due to inclusion of several ancestors, the overall theory structure
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    81
  emerging in an Isabelle session forms a directed acyclic graph
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    82
  (DAG).  Isabelle's theory loader ensures that the sources
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    83
  contributing to the development graph are always up-to-date.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    84
  Changed files are automatically reloaded when processing theory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    85
  headers.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    86
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    87
  The optional @{keyword_def "uses"} specification declares additional
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    88
  dependencies on extra files (usually ML sources).  Files will be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    89
  loaded immediately (as ML), unless the name is put in parentheses,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    90
  which merely documents the dependency to be resolved later in the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    91
  text (typically via explicit @{command_ref "use"} in the body text,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    92
  see \secref{sec:ML}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    93
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    94
  \item [@{command "end"}] concludes the current theory definition or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    95
  context switch.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    96
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    97
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    98
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    99
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   100
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   101
subsection {* Markup commands \label{sec:markup-thy} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   102
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   103
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   104
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   105
    @{command_def "chapter"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   106
    @{command_def "section"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   107
    @{command_def "subsection"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   108
    @{command_def "subsubsection"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   109
    @{command_def "text"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   110
    @{command_def "text_raw"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   111
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   112
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   113
  Apart from formal comments (see \secref{sec:comments}), markup
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   114
  commands provide a structured way to insert text into the document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   115
  generated from a theory (see \cite{isabelle-sys} for more
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   116
  information on Isabelle's document preparation tools).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   117
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   118
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   119
    ('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text') target? text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   120
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   121
    'text\_raw' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   122
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   123
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   124
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   125
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   126
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   127
  \item [@{command "chapter"}, @{command "section"}, @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   128
  "subsection"}, and @{command "subsubsection"}] mark chapter and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   129
  section headings.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   130
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   131
  \item [@{command "text"}] specifies paragraphs of plain text.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   132
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   133
  \item [@{command "text_raw"}] inserts {\LaTeX} source into the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   134
  output, without additional markup.  Thus the full range of document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   135
  manipulations becomes available.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   136
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   137
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   138
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   139
  The @{text "text"} argument of these markup commands (except for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   140
  @{command "text_raw"}) may contain references to formal entities
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   141
  (``antiquotations'', see also \secref{sec:antiq}).  These are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   142
  interpreted in the present theory context, or the named @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   143
  "target"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   144
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   145
  Any of these markup elements corresponds to a {\LaTeX} command with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   146
  the name prefixed by @{verbatim "\\isamarkup"}.  For the sectioning
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   147
  commands this is a plain macro with a single argument, e.g.\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   148
  @{verbatim "\\isamarkupchapter{"}@{text "\<dots>"}@{verbatim "}"} for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   149
  @{command "chapter"}.  The @{command "text"} markup results in a
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   150
  {\LaTeX} environment @{verbatim "\\begin{isamarkuptext}"} @{text
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   151
  "\<dots>"} @{verbatim "\\end{isamarkuptext}"}, while @{command "text_raw"}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   152
  causes the text to be inserted directly into the {\LaTeX} source.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   153
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   154
  \medskip Additional markup commands are available for proofs (see
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   155
  \secref{sec:markup-prf}).  Also note that the @{command_ref
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   156
  "header"} declaration (see \secref{sec:begin-thy}) admits to insert
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   157
  section markup just preceding the actual theory definition.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   158
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   159
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   160
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   161
subsection {* Type classes and sorts \label{sec:classes} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   162
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   163
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   164
  \begin{matharray}{rcll}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   165
    @{command_def "classes"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   166
    @{command_def "classrel"} & : & \isartrans{theory}{theory} & (axiomatic!) \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   167
    @{command_def "defaultsort"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   168
    @{command_def "class_deps"} & : & \isarkeep{theory~|~proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   169
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   170
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   171
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   172
    'classes' (classdecl +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   173
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   174
    'classrel' (nameref ('<' | subseteq) nameref + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   175
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   176
    'defaultsort' sort
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   177
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   178
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   179
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   180
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   181
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   182
  \item [@{command "classes"}~@{text "c \<subseteq> c\<^sub>1, \<dots>, c\<^sub>n"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   183
  declares class @{text c} to be a subclass of existing classes @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   184
  "c\<^sub>1, \<dots>, c\<^sub>n"}.  Cyclic class structures are not permitted.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   185
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   186
  \item [@{command "classrel"}~@{text "c\<^sub>1 \<subseteq> c\<^sub>2"}] states
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   187
  subclass relations between existing classes @{text "c\<^sub>1"} and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   188
  @{text "c\<^sub>2"}.  This is done axiomatically!  The @{command_ref
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   189
  "instance"} command (see \secref{sec:axclass}) provides a way to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   190
  introduce proven class relations.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   191
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   192
  \item [@{command "defaultsort"}~@{text s}] makes sort @{text s} the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   193
  new default sort for any type variables given without sort
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   194
  constraints.  Usually, the default sort would be only changed when
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   195
  defining a new object-logic.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   196
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   197
  \item [@{command "class_deps"}] visualizes the subclass relation,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   198
  using Isabelle's graph browser tool (see also \cite{isabelle-sys}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   199
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   200
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   201
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   202
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   203
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   204
subsection {* Primitive types and type abbreviations \label{sec:types-pure} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   205
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   206
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   207
  \begin{matharray}{rcll}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   208
    @{command_def "types"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   209
    @{command_def "typedecl"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   210
    @{command_def "nonterminals"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   211
    @{command_def "arities"} & : & \isartrans{theory}{theory} & (axiomatic!) \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   212
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   213
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   214
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   215
    'types' (typespec '=' type infix? +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   216
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   217
    'typedecl' typespec infix?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   218
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   219
    'nonterminals' (name +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   220
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   221
    'arities' (nameref '::' arity +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   222
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   223
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   224
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   225
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   226
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   227
  \item [@{command "types"}~@{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t = \<tau>"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   228
  introduces \emph{type synonym} @{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   229
  for existing type @{text "\<tau>"}.  Unlike actual type definitions, as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   230
  are available in Isabelle/HOL for example, type synonyms are just
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   231
  purely syntactic abbreviations without any logical significance.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   232
  Internally, type synonyms are fully expanded.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   233
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   234
  \item [@{command "typedecl"}~@{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   235
  declares a new type constructor @{text t}, intended as an actual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   236
  logical type (of the object-logic, if available).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   237
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   238
  \item [@{command "nonterminals"}~@{text c}] declares type
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   239
  constructors @{text c} (without arguments) to act as purely
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   240
  syntactic types, i.e.\ nonterminal symbols of Isabelle's inner
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   241
  syntax of terms or types.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   242
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   243
  \item [@{command "arities"}~@{text "t :: (s\<^sub>1, \<dots>, s\<^sub>n)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   244
  s"}] augments Isabelle's order-sorted signature of types by new type
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   245
  constructor arities.  This is done axiomatically!  The @{command_ref
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   246
  "instance"} command (see \S\ref{sec:axclass}) provides a way to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   247
  introduce proven type arities.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   248
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   249
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   250
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   251
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   252
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   253
subsection {* Primitive constants and definitions \label{sec:consts} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   254
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   255
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   256
  Definitions essentially express abbreviations within the logic.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   257
  simplest form of a definition is @{text "c :: \<sigma> \<equiv> t"}, where @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   258
  c} is a newly declared constant.  Isabelle also allows derived forms
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   259
  where the arguments of @{text c} appear on the left, abbreviating a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   260
  prefix of @{text \<lambda>}-abstractions, e.g.\ @{text "c \<equiv> \<lambda>x y. t"} may be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   261
  written more conveniently as @{text "c x y \<equiv> t"}.  Moreover,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   262
  definitions may be weakened by adding arbitrary pre-conditions:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   263
  @{text "A \<Longrightarrow> c x y \<equiv> t"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   264
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   265
  \medskip The built-in well-formedness conditions for definitional
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   266
  specifications are:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   267
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   268
  \begin{itemize}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   269
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   270
  \item Arguments (on the left-hand side) must be distinct variables.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   271
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   272
  \item All variables on the right-hand side must also appear on the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   273
  left-hand side.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   274
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   275
  \item All type variables on the right-hand side must also appear on
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   276
  the left-hand side; this prohibits @{text "0 :: nat \<equiv> length ([] ::
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   277
  \<alpha> list)"} for example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   278
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   279
  \item The definition must not be recursive.  Most object-logics
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   280
  provide definitional principles that can be used to express
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   281
  recursion safely.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   282
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   283
  \end{itemize}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   284
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   285
  Overloading means that a constant being declared as @{text "c :: \<alpha>
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   286
  decl"} may be defined separately on type instances @{text "c ::
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   287
  (\<beta>\<^sub>1, \<dots>, \<beta>\<^sub>n) t decl"} for each type constructor @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   288
  t}.  The right-hand side may mention overloaded constants
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   289
  recursively at type instances corresponding to the immediate
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   290
  argument types @{text "\<beta>\<^sub>1, \<dots>, \<beta>\<^sub>n"}.  Incomplete
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   291
  specification patterns impose global constraints on all occurrences,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   292
  e.g.\ @{text "d :: \<alpha> \<times> \<alpha>"} on the left-hand side means that all
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   293
  corresponding occurrences on some right-hand side need to be an
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   294
  instance of this, general @{text "d :: \<alpha> \<times> \<beta>"} will be disallowed.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   295
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   296
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   297
    @{command_def "consts"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   298
    @{command_def "defs"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   299
    @{command_def "constdefs"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   300
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   301
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   302
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   303
    'consts' ((name '::' type mixfix?) +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   304
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   305
    'defs' ('(' 'unchecked'? 'overloaded'? ')')? \\ (axmdecl prop +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   306
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   307
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   308
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   309
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   310
    'constdefs' structs? (constdecl? constdef +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   311
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   312
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   313
    structs: '(' 'structure' (vars + 'and') ')'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   314
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   315
    constdecl:  ((name '::' type mixfix | name '::' type | name mixfix) 'where'?) | name 'where'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   316
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   317
    constdef: thmdecl? prop
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   318
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   319
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   320
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   321
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   322
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   323
  \item [@{command "consts"}~@{text "c :: \<sigma>"}] declares constant
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   324
  @{text c} to have any instance of type scheme @{text \<sigma>}.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   325
  optional mixfix annotations may attach concrete syntax to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   326
  constants declared.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   327
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   328
  \item [@{command "defs"}~@{text "name: eqn"}] introduces @{text eqn}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   329
  as a definitional axiom for some existing constant.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   330
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   331
  The @{text "(unchecked)"} option disables global dependency checks
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   332
  for this definition, which is occasionally useful for exotic
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   333
  overloading.  It is at the discretion of the user to avoid malformed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   334
  theory specifications!
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   335
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   336
  The @{text "(overloaded)"} option declares definitions to be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   337
  potentially overloaded.  Unless this option is given, a warning
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   338
  message would be issued for any definitional equation with a more
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   339
  special type than that of the corresponding constant declaration.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   340
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   341
  \item [@{command "constdefs"}] provides a streamlined combination of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   342
  constants declarations and definitions: type-inference takes care of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   343
  the most general typing of the given specification (the optional
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   344
  type constraint may refer to type-inference dummies ``@{text
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   345
  _}'' as usual).  The resulting type declaration needs to agree with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   346
  that of the specification; overloading is \emph{not} supported here!
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   347
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   348
  The constant name may be omitted altogether, if neither type nor
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   349
  syntax declarations are given.  The canonical name of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   350
  definitional axiom for constant @{text c} will be @{text c_def},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   351
  unless specified otherwise.  Also note that the given list of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   352
  specifications is processed in a strictly sequential manner, with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   353
  type-checking being performed independently.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   354
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   355
  An optional initial context of @{text "(structure)"} declarations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   356
  admits use of indexed syntax, using the special symbol @{verbatim
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   357
  "\<index>"} (printed as ``@{text "\<index>"}'').  The latter concept is
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   358
  particularly useful with locales (see also \S\ref{sec:locale}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   359
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   360
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   361
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   362
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   363
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   364
subsection {* Syntax and translations \label{sec:syn-trans} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   365
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   366
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   367
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   368
    @{command_def "syntax"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   369
    @{command_def "no_syntax"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   370
    @{command_def "translations"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   371
    @{command_def "no_translations"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   372
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   373
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   374
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   375
    ('syntax' | 'no\_syntax') mode? (constdecl +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   376
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   377
    ('translations' | 'no\_translations') (transpat ('==' | '=>' | '<=' | rightleftharpoons | rightharpoonup | leftharpoondown) transpat +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   378
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   379
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   380
    mode: ('(' ( name | 'output' | name 'output' ) ')')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   381
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   382
    transpat: ('(' nameref ')')? string
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   383
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   384
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   385
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   386
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   387
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   388
  \item [@{command "syntax"}~@{text "(mode) decls"}] is similar to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   389
  @{command "consts"}~@{text decls}, except that the actual logical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   390
  signature extension is omitted.  Thus the context free grammar of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   391
  Isabelle's inner syntax may be augmented in arbitrary ways,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   392
  independently of the logic.  The @{text mode} argument refers to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   393
  print mode that the grammar rules belong; unless the @{keyword_ref
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   394
  "output"} indicator is given, all productions are added both to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   395
  input and output grammar.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   396
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   397
  \item [@{command "no_syntax"}~@{text "(mode) decls"}] removes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   398
  grammar declarations (and translations) resulting from @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   399
  decls}, which are interpreted in the same manner as for @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   400
  "syntax"} above.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   401
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   402
  \item [@{command "translations"}~@{text rules}] specifies syntactic
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   403
  translation rules (i.e.\ macros): parse~/ print rules (@{text "\<rightleftharpoons>"}),
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   404
  parse rules (@{text "\<rightharpoonup>"}), or print rules (@{text "\<leftharpoondown>"}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   405
  Translation patterns may be prefixed by the syntactic category to be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   406
  used for parsing; the default is @{text logic}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   407
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   408
  \item [@{command "no_translations"}~@{text rules}] removes syntactic
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   409
  translation rules, which are interpreted in the same manner as for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   410
  @{command "translations"} above.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   411
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   412
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   413
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   414
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   415
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   416
subsection {* Axioms and theorems \label{sec:axms-thms} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   417
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   418
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   419
  \begin{matharray}{rcll}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   420
    @{command_def "axioms"} & : & \isartrans{theory}{theory} & (axiomatic!) \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   421
    @{command_def "lemmas"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   422
    @{command_def "theorems"} & : & isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   423
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   424
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   425
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   426
    'axioms' (axmdecl prop +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   427
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   428
    ('lemmas' | 'theorems') target? (thmdef? thmrefs + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   429
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   430
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   431
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   432
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   433
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   434
  \item [@{command "axioms"}~@{text "a: \<phi>"}] introduces arbitrary
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   435
  statements as axioms of the meta-logic.  In fact, axioms are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   436
  ``axiomatic theorems'', and may be referred later just as any other
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   437
  theorem.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   438
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   439
  Axioms are usually only introduced when declaring new logical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   440
  systems.  Everyday work is typically done the hard way, with proper
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   441
  definitions and proven theorems.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   442
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   443
  \item [@{command "lemmas"}~@{text "a = b\<^sub>1 \<dots> b\<^sub>n"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   444
  retrieves and stores existing facts in the theory context, or the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   445
  specified target context (see also \secref{sec:target}).  Typical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   446
  applications would also involve attributes, to declare Simplifier
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   447
  rules, for example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   448
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   449
  \item [@{command "theorems"}] is essentially the same as @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   450
  "lemmas"}, but marks the result as a different kind of facts.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   451
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   452
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   453
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   454
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   455
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   456
subsection {* Name spaces *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   457
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   458
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   459
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   460
    @{command_def "global"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   461
    @{command_def "local"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   462
    @{command_def "hide"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   463
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   464
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   465
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   466
    'hide' ('(open)')? name (nameref + )
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   467
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   468
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   469
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   470
  Isabelle organizes any kind of name declarations (of types,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   471
  constants, theorems etc.) by separate hierarchically structured name
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   472
  spaces.  Normally the user does not have to control the behavior of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   473
  name spaces by hand, yet the following commands provide some way to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   474
  do so.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   475
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   476
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   477
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   478
  \item [@{command "global"} and @{command "local"}] change the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   479
  current name declaration mode.  Initially, theories start in
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   480
  @{command "local"} mode, causing all names to be automatically
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   481
  qualified by the theory name.  Changing this to @{command "global"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   482
  causes all names to be declared without the theory prefix, until
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   483
  @{command "local"} is declared again.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   484
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   485
  Note that global names are prone to get hidden accidently later,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   486
  when qualified names of the same base name are introduced.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   487
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   488
  \item [@{command "hide"}~@{text "space names"}] fully removes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   489
  declarations from a given name space (which may be @{text "class"},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   490
  @{text "type"}, @{text "const"}, or @{text "fact"}); with the @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   491
  "(open)"} option, only the base name is hidden.  Global
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   492
  (unqualified) names may never be hidden.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   493
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   494
  Note that hiding name space accesses has no impact on logical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   495
  declarations -- they remain valid internally.  Entities that are no
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   496
  longer accessible to the user are printed with the special qualifier
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   497
  ``@{text "??"}'' prefixed to the full internal name.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   498
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   499
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   500
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   501
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   502
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   503
subsection {* Incorporating ML code \label{sec:ML} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   504
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   505
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   506
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   507
    @{command_def "use"} & : & \isarkeep{theory~|~local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   508
    @{command_def "ML"} & : & \isarkeep{theory~|~local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   509
    @{command_def "ML_val"} & : & \isartrans{\cdot}{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   510
    @{command_def "ML_command"} & : & \isartrans{\cdot}{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   511
    @{command_def "setup"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   512
    @{command_def "method_setup"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   513
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   514
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   515
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   516
    'use' name
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   517
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   518
    ('ML' | 'ML\_val' | 'ML\_command' | 'setup') text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   519
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   520
    'method\_setup' name '=' text text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   521
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   522
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   523
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   524
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   525
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   526
  \item [@{command "use"}~@{text "file"}] reads and executes ML
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   527
  commands from @{text "file"}.  The current theory context is passed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   528
  down to the ML toplevel and may be modified, using @{ML
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   529
  "Context.>>"} or derived ML commands.  The file name is checked with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   530
  the @{keyword_ref "uses"} dependency declaration given in the theory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   531
  header (see also \secref{sec:begin-thy}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   532
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   533
  \item [@{command "ML"}~@{text "text"}] is similar to @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   534
  "use"}, but executes ML commands directly from the given @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   535
  "text"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   536
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   537
  \item [@{command "ML_val"} and @{command "ML_command"}] are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   538
  diagnostic versions of @{command "ML"}, which means that the context
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   539
  may not be updated.  @{command "ML_val"} echos the bindings produced
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   540
  at the ML toplevel, but @{command "ML_command"} is silent.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   541
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   542
  \item [@{command "setup"}~@{text "text"}] changes the current theory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   543
  context by applying @{text "text"}, which refers to an ML expression
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   544
  of type @{ML_type "theory -> theory"}.  This enables to initialize
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   545
  any object-logic specific tools and packages written in ML, for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   546
  example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   547
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   548
  \item [@{command "method_setup"}~@{text "name = text description"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   549
  defines a proof method in the current theory.  The given @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   550
  "text"} has to be an ML expression of type @{ML_type "Args.src ->
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   551
  Proof.context -> Proof.method"}.  Parsing concrete method syntax
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   552
  from @{ML_type Args.src} input can be quite tedious in general.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   553
  following simple examples are for methods without any explicit
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   554
  arguments, or a list of theorems, respectively.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   555
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   556
%FIXME proper antiquotations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   557
{\footnotesize
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   558
\begin{verbatim}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   559
 Method.no_args (Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   560
 Method.thms_args (fn thms => Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   561
 Method.ctxt_args (fn ctxt => Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   562
 Method.thms_ctxt_args (fn thms => fn ctxt =>
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   563
    Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   564
\end{verbatim}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   565
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   566
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   567
  Note that mere tactic emulations may ignore the @{text facts}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   568
  parameter above.  Proper proof methods would do something
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   569
  appropriate with the list of current facts, though.  Single-rule
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   570
  methods usually do strict forward-chaining (e.g.\ by using @{ML
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   571
  Drule.multi_resolves}), while automatic ones just insert the facts
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   572
  using @{ML Method.insert_tac} before applying the main tactic.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   573
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   574
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   575
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   576
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   577
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   578
subsection {* Syntax translation functions *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   579
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   580
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   581
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   582
    @{command_def "parse_ast_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   583
    @{command_def "parse_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   584
    @{command_def "print_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   585
    @{command_def "typed_print_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   586
    @{command_def "print_ast_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   587
    @{command_def "token_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   588
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   589
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   590
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   591
  ( 'parse\_ast\_translation' | 'parse\_translation' | 'print\_translation' |
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   592
    'typed\_print\_translation' | 'print\_ast\_translation' ) ('(advanced)')? text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   593
  ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   594
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   595
  'token\_translation' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   596
  ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   597
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   598
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   599
  Syntax translation functions written in ML admit almost arbitrary
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   600
  manipulations of Isabelle's inner syntax.  Any of the above commands
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   601
  have a single \railqtok{text} argument that refers to an ML
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   602
  expression of appropriate type, which are as follows by default:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   603
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   604
%FIXME proper antiquotations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   605
\begin{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   606
val parse_ast_translation   : (string * (ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   607
val parse_translation       : (string * (term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   608
val print_translation       : (string * (term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   609
val typed_print_translation :
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   610
  (string * (bool -> typ -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   611
val print_ast_translation   : (string * (ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   612
val token_translation       :
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   613
  (string * string * (string -> string * real)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   614
\end{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   615
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   616
  If the @{text "(advanced)"} option is given, the corresponding
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   617
  translation functions may depend on the current theory or proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   618
  context.  This allows to implement advanced syntax mechanisms, as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   619
  translations functions may refer to specific theory declarations or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   620
  auxiliary proof data.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   621
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   622
  See also \cite[\S8]{isabelle-ref} for more information on the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   623
  general concept of syntax transformations in Isabelle.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   624
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   625
%FIXME proper antiquotations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   626
\begin{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   627
val parse_ast_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   628
  (string * (Context.generic -> ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   629
val parse_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   630
  (string * (Context.generic -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   631
val print_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   632
  (string * (Context.generic -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   633
val typed_print_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   634
  (string * (Context.generic -> bool -> typ -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   635
val print_ast_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   636
  (string * (Context.generic -> ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   637
\end{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   638
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   639
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   640
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   641
subsection {* Oracles *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   642
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   643
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   644
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   645
    @{command_def "oracle"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   646
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   647
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   648
  The oracle interface promotes a given ML function @{ML_text
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   649
  "theory -> T -> term"} to @{ML_text "theory -> T -> thm"}, for some
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   650
  type @{ML_text T} given by the user.  This acts like an infinitary
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   651
  specification of axioms -- there is no internal check of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   652
  correctness of the results!  The inference kernel records oracle
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   653
  invocations within the internal derivation object of theorems, and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   654
  the pretty printer attaches ``@{text "[!]"}'' to indicate results
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   655
  that are not fully checked by Isabelle inferences.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   656
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   657
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   658
    'oracle' name '(' type ')' '=' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   659
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   660
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   661
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   662
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   663
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   664
  \item [@{command "oracle"}~@{text "name (type) = text"}] turns the
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   665
  given ML expression @{text "text"} of type
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   666
  @{ML_text "theory ->"}~@{text "type"}~@{ML_text "-> term"} into an
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   667
  ML function of type
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   668
  @{ML_text "theory ->"}~@{text "type"}~@{ML_text "-> thm"}, which is
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   669
  bound to the global identifier @{ML_text name}.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   670
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   671
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   672
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   673
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   674
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   675
section {* Proof commands *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   676
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   677
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   678
  Proof commands perform transitions of Isar/VM machine
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   679
  configurations, which are block-structured, consisting of a stack of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   680
  nodes with three main components: logical proof context, current
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   681
  facts, and open goals.  Isar/VM transitions are \emph{typed}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   682
  according to the following three different modes of operation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   683
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   684
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   685
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   686
  \item [@{text "proof(prove)"}] means that a new goal has just been
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   687
  stated that is now to be \emph{proven}; the next command may refine
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   688
  it by some proof method, and enter a sub-proof to establish the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   689
  actual result.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   690
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   691
  \item [@{text "proof(state)"}] is like a nested theory mode: the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   692
  context may be augmented by \emph{stating} additional assumptions,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   693
  intermediate results etc.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   694
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   695
  \item [@{text "proof(chain)"}] is intermediate between @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   696
  "proof(state)"} and @{text "proof(prove)"}: existing facts (i.e.\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   697
  the contents of the special ``@{fact_ref this}'' register) have been
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   698
  just picked up in order to be used when refining the goal claimed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   699
  next.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   700
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   701
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   702
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   703
  The proof mode indicator may be read as a verb telling the writer
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   704
  what kind of operation may be performed next.  The corresponding
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   705
  typings of proof commands restricts the shape of well-formed proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   706
  texts to particular command sequences.  So dynamic arrangements of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   707
  commands eventually turn out as static texts of a certain structure.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   708
  \Appref{ap:refcard} gives a simplified grammar of the overall
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   709
  (extensible) language emerging that way.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   710
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   711
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   712
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   713
subsection {* Markup commands \label{sec:markup-prf} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   714
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   715
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   716
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   717
    @{command_def "sect"} & : & \isartrans{proof}{proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   718
    @{command_def "subsect"} & : & \isartrans{proof}{proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   719
    @{command_def "subsubsect"} & : & \isartrans{proof}{proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   720
    @{command_def "txt"} & : & \isartrans{proof}{proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   721
    @{command_def "txt_raw"} & : & \isartrans{proof}{proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   722
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   723
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   724
  These markup commands for proof mode closely correspond to the ones
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   725
  of theory mode (see \S\ref{sec:markup-thy}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   726
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   727
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   728
    ('sect' | 'subsect' | 'subsubsect' | 'txt' | 'txt\_raw') text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   729
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   730
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   731
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   732
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   733
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   734
subsection {* Context elements \label{sec:proof-context} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   735
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   736
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   737
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   738
    @{command_def "fix"} & : & \isartrans{proof(state)}{proof(state)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   739
    @{command_def "assume"} & : & \isartrans{proof(state)}{proof(state)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   740
    @{command_def "presume"} & : & \isartrans{proof(state)}{proof(state)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   741
    @{command_def "def"} & : & \isartrans{proof(state)}{proof(state)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   742
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   743
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   744
  The logical proof context consists of fixed variables and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   745
  assumptions.  The former closely correspond to Skolem constants, or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   746
  meta-level universal quantification as provided by the Isabelle/Pure
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   747
  logical framework.  Introducing some \emph{arbitrary, but fixed}
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   748
  variable via ``@{command "fix"}~@{text x}'' results in a local value
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   749
  that may be used in the subsequent proof as any other variable or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   750
  constant.  Furthermore, any result @{text "\<turnstile> \<phi>[x]"} exported from
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   751
  the context will be universally closed wrt.\ @{text x} at the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   752
  outermost level: @{text "\<turnstile> \<And>x. \<phi>[x]"} (this is expressed in normal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   753
  form using Isabelle's meta-variables).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   754
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   755
  Similarly, introducing some assumption @{text \<chi>} has two effects.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   756
  On the one hand, a local theorem is created that may be used as a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   757
  fact in subsequent proof steps.  On the other hand, any result
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   758
  @{text "\<chi> \<turnstile> \<phi>"} exported from the context becomes conditional wrt.\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   759
  the assumption: @{text "\<turnstile> \<chi> \<Longrightarrow> \<phi>"}.  Thus, solving an enclosing goal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   760
  using such a result would basically introduce a new subgoal stemming
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   761
  from the assumption.  How this situation is handled depends on the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   762
  version of assumption command used: while @{command "assume"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   763
  insists on solving the subgoal by unification with some premise of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   764
  the goal, @{command "presume"} leaves the subgoal unchanged in order
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   765
  to be proved later by the user.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   766
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   767
  Local definitions, introduced by ``@{command "def"}~@{text "x \<equiv>
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   768
  t"}'', are achieved by combining ``@{command "fix"}~@{text x}'' with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   769
  another version of assumption that causes any hypothetical equation
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   770
  @{text "x \<equiv> t"} to be eliminated by the reflexivity rule.  Thus,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   771
  exporting some result @{text "x \<equiv> t \<turnstile> \<phi>[x]"} yields @{text "\<turnstile>
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   772
  \<phi>[t]"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   773
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   774
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   775
    'fix' (vars + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   776
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   777
    ('assume' | 'presume') (props + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   778
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   779
    'def' (def + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   780
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   781
    def: thmdecl? \\ name ('==' | equiv) term termpat?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   782
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   783
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   784
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   785
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   786
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   787
  \item [@{command "fix"}~@{text x}] introduces a local variable
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   788
  @{text x} that is \emph{arbitrary, but fixed.}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   789
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   790
  \item [@{command "assume"}~@{text "a: \<phi>"} and @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   791
  "presume"}~@{text "a: \<phi>"}] introduce a local fact @{text "\<phi> \<turnstile> \<phi>"} by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   792
  assumption.  Subsequent results applied to an enclosing goal (e.g.\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   793
  by @{command_ref "show"}) are handled as follows: @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   794
  "assume"} expects to be able to unify with existing premises in the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   795
  goal, while @{command "presume"} leaves @{text \<phi>} as new subgoals.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   796
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   797
  Several lists of assumptions may be given (separated by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   798
  @{keyword_ref "and"}; the resulting list of current facts consists
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   799
  of all of these concatenated.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   800
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   801
  \item [@{command "def"}~@{text "x \<equiv> t"}] introduces a local
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   802
  (non-polymorphic) definition.  In results exported from the context,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   803
  @{text x} is replaced by @{text t}.  Basically, ``@{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   804
  "def"}~@{text "x \<equiv> t"}'' abbreviates ``@{command "fix"}~@{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   805
  x}~@{command "assume"}~@{text "x \<equiv> t"}'', with the resulting
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   806
  hypothetical equation solved by reflexivity.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   807
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   808
  The default name for the definitional equation is @{text x_def}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   809
  Several simultaneous definitions may be given at the same time.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   810
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   811
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   812
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   813
  The special name @{fact_ref prems} refers to all assumptions of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   814
  current context as a list of theorems.  This feature should be used
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   815
  with great care!  It is better avoided in final proof texts.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   816
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   817
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   818
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   819
subsection {* Facts and forward chaining *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   820
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   821
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   822
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   823
    @{command_def "note"} & : & \isartrans{proof(state)}{proof(state)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   824
    @{command_def "then"} & : & \isartrans{proof(state)}{proof(chain)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   825
    @{command_def "from"} & : & \isartrans{proof(state)}{proof(chain)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   826
    @{command_def "with"} & : & \isartrans{proof(state)}{proof(chain)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   827
    @{command_def "using"} & : & \isartrans{proof(prove)}{proof(prove)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   828
    @{command_def "unfolding"} & : & \isartrans{proof(prove)}{proof(prove)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   829
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   830
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   831
  New facts are established either by assumption or proof of local
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   832
  statements.  Any fact will usually be involved in further proofs,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   833
  either as explicit arguments of proof methods, or when forward
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   834
  chaining towards the next goal via @{command "then"} (and variants);
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   835
  @{command "from"} and @{command "with"} are composite forms
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   836
  involving @{command "note"}.  The @{command "using"} elements
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   837
  augments the collection of used facts \emph{after} a goal has been
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   838
  stated.  Note that the special theorem name @{fact_ref this} refers
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   839
  to the most recently established facts, but only \emph{before}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   840
  issuing a follow-up claim.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   841
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   842
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   843
    'note' (thmdef? thmrefs + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   844
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   845
    ('from' | 'with' | 'using' | 'unfolding') (thmrefs + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   846
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   847
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   848
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   849
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   850
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   851
  \item [@{command "note"}~@{text "a = b\<^sub>1 \<dots> b\<^sub>n"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   852
  recalls existing facts @{text "b\<^sub>1, \<dots>, b\<^sub>n"}, binding
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   853
  the result as @{text a}.  Note that attributes may be involved as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   854
  well, both on the left and right hand sides.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   855
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   856
  \item [@{command "then"}] indicates forward chaining by the current
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   857
  facts in order to establish the goal to be claimed next.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   858
  initial proof method invoked to refine that will be offered the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   859
  facts to do ``anything appropriate'' (see also
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   860
  \secref{sec:proof-steps}).  For example, method @{method_ref rule}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   861
  (see \secref{sec:pure-meth-att}) would typically do an elimination
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   862
  rather than an introduction.  Automatic methods usually insert the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   863
  facts into the goal state before operation.  This provides a simple
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   864
  scheme to control relevance of facts in automated proof search.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   865
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   866
  \item [@{command "from"}~@{text b}] abbreviates ``@{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   867
  "note"}~@{text b}~@{command "then"}''; thus @{command "then"} is
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   868
  equivalent to ``@{command "from"}~@{text this}''.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   869
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   870
  \item [@{command "with"}~@{text "b\<^sub>1 \<dots> b\<^sub>n"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   871
  abbreviates ``@{command "from"}~@{text "b\<^sub>1 \<dots> b\<^sub>n \<AND>
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   872
  this"}''; thus the forward chaining is from earlier facts together
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   873
  with the current ones.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   874
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   875
  \item [@{command "using"}~@{text "b\<^sub>1 \<dots> b\<^sub>n"}] augments
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   876
  the facts being currently indicated for use by a subsequent
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   877
  refinement step (such as @{command_ref "apply"} or @{command_ref
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   878
  "proof"}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   879
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   880
  \item [@{command "unfolding"}~@{text "b\<^sub>1 \<dots> b\<^sub>n"}] is
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   881
  structurally similar to @{command "using"}, but unfolds definitional
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   882
  equations @{text "b\<^sub>1, \<dots> b\<^sub>n"} throughout the goal state
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   883
  and facts.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   884
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   885
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   886
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   887
  Forward chaining with an empty list of theorems is the same as not
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   888
  chaining at all.  Thus ``@{command "from"}~@{text nothing}'' has no
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   889
  effect apart from entering @{text "prove(chain)"} mode, since
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   890
  @{fact_ref nothing} is bound to the empty list of theorems.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   891
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   892
  Basic proof methods (such as @{method_ref rule}) expect multiple
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   893
  facts to be given in their proper order, corresponding to a prefix
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   894
  of the premises of the rule involved.  Note that positions may be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   895
  easily skipped using something like @{command "from"}~@{text "_
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   896
  \<AND> a \<AND> b"}, for example.  This involves the trivial rule
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   897
  @{text "PROP \<psi> \<Longrightarrow> PROP \<psi>"}, which is bound in Isabelle/Pure as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   898
  ``@{fact_ref "_"}'' (underscore).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   899
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   900
  Automated methods (such as @{method simp} or @{method auto}) just
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   901
  insert any given facts before their usual operation.  Depending on
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   902
  the kind of procedure involved, the order of facts is less
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   903
  significant here.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   904
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   905
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   906
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   907
subsection {* Goal statements \label{sec:goals} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   908
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   909
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   910
  \begin{matharray}{rcl}
26866
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   911
    @{command_def "lemma"} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   912
    @{command_def "theorem"} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   913
    @{command_def "corollary"} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   914
    @{command_def "have"} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   915
    @{command_def "show"} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   916
    @{command_def "hence"} & : & \isartrans{proof(state)}{proof(prove)} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   917
    @{command_def "thus"} & : & \isartrans{proof(state)}{proof(prove)} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   918
    @{command_def "print_statement"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   919
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   920
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   921
  From a theory context, proof mode is entered by an initial goal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   922
  command such as @{command "lemma"}, @{command "theorem"}, or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   923
  @{command "corollary"}.  Within a proof, new claims may be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   924
  introduced locally as well; four variants are available here to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   925
  indicate whether forward chaining of facts should be performed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   926
  initially (via @{command_ref "then"}), and whether the final result
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   927
  is meant to solve some pending goal.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   928
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   929
  Goals may consist of multiple statements, resulting in a list of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   930
  facts eventually.  A pending multi-goal is internally represented as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   931
  a meta-level conjunction (printed as @{text "&&"}), which is usually
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   932
  split into the corresponding number of sub-goals prior to an initial
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   933
  method application, via @{command_ref "proof"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   934
  (\secref{sec:proof-steps}) or @{command_ref "apply"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   935
  (\secref{sec:tactic-commands}).  The @{method_ref induct} method
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   936
  covered in \secref{sec:cases-induct} acts on multiple claims
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   937
  simultaneously.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   938
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   939
  Claims at the theory level may be either in short or long form.  A
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   940
  short goal merely consists of several simultaneous propositions
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   941
  (often just one).  A long goal includes an explicit context
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   942
  specification for the subsequent conclusion, involving local
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   943
  parameters and assumptions.  Here the role of each part of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   944
  statement is explicitly marked by separate keywords (see also
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   945
  \secref{sec:locale}); the local assumptions being introduced here
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   946
  are available as @{fact_ref assms} in the proof.  Moreover, there
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   947
  are two kinds of conclusions: @{element_def "shows"} states several
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   948
  simultaneous propositions (essentially a big conjunction), while
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   949
  @{element_def "obtains"} claims several simultaneous simultaneous
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   950
  contexts of (essentially a big disjunction of eliminated parameters
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   951
  and assumptions, cf.\ \secref{sec:obtain}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   952
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   953
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   954
    ('lemma' | 'theorem' | 'corollary') target? (goal | longgoal)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   955
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   956
    ('have' | 'show' | 'hence' | 'thus') goal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   957
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   958
    'print\_statement' modes? thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   959
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   960
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   961
    goal: (props + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   962
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   963
    longgoal: thmdecl? (contextelem *) conclusion
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   964
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   965
    conclusion: 'shows' goal | 'obtains' (parname? case + '|')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   966
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   967
    case: (vars + 'and') 'where' (props + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   968
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   969
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   970
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   971
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   972
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   973
  \item [@{command "lemma"}~@{text "a: \<phi>"}] enters proof mode with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   974
  @{text \<phi>} as main goal, eventually resulting in some fact @{text "\<turnstile>
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   975
  \<phi>"} to be put back into the target context.  An additional
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   976
  \railnonterm{context} specification may build up an initial proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   977
  context for the subsequent claim; this includes local definitions
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   978
  and syntax as well, see the definition of @{syntax contextelem} in
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   979
  \secref{sec:locale}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   980
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   981
  \item [@{command "theorem"}~@{text "a: \<phi>"} and @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   982
  "corollary"}~@{text "a: \<phi>"}] are essentially the same as @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   983
  "lemma"}~@{text "a: \<phi>"}, but the facts are internally marked as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   984
  being of a different kind.  This discrimination acts like a formal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   985
  comment.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   986
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   987
  \item [@{command "have"}~@{text "a: \<phi>"}] claims a local goal,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   988
  eventually resulting in a fact within the current logical context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   989
  This operation is completely independent of any pending sub-goals of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   990
  an enclosing goal statements, so @{command "have"} may be freely
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   991
  used for experimental exploration of potential results within a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   992
  proof body.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   993
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   994
  \item [@{command "show"}~@{text "a: \<phi>"}] is like @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   995
  "have"}~@{text "a: \<phi>"} plus a second stage to refine some pending
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   996
  sub-goal for each one of the finished result, after having been
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   997
  exported into the corresponding context (at the head of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   998
  sub-proof of this @{command "show"} command).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   999
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1000
  To accommodate interactive debugging, resulting rules are printed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1001
  before being applied internally.  Even more, interactive execution
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1002
  of @{command "show"} predicts potential failure and displays the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1003
  resulting error as a warning beforehand.  Watch out for the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1004
  following message:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1005
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1006
  %FIXME proper antiquitation
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1007
  \begin{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1008
  Problem! Local statement will fail to solve any pending goal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1009
  \end{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1010
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1011
  \item [@{command "hence"}] abbreviates ``@{command "then"}~@{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1012
  "have"}'', i.e.\ claims a local goal to be proven by forward
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1013
  chaining the current facts.  Note that @{command "hence"} is also
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1014
  equivalent to ``@{command "from"}~@{text this}~@{command "have"}''.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1015
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1016
  \item [@{command "thus"}] abbreviates ``@{command "then"}~@{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1017
  "show"}''.  Note that @{command "thus"} is also equivalent to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1018
  ``@{command "from"}~@{text this}~@{command "show"}''.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1019
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1020
  \item [@{command "print_statement"}~@{text a}] prints facts from the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1021
  current theory or proof context in long statement form, according to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1022
  the syntax for @{command "lemma"} given above.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1023
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1024
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1025
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1026
  Any goal statement causes some term abbreviations (such as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1027
  @{variable_ref "?thesis"}) to be bound automatically, see also
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1028
  \secref{sec:term-abbrev}.  Furthermore, the local context of a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1029
  (non-atomic) goal is provided via the @{case_ref rule_context} case.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1030
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1031
  The optional case names of @{element_ref "obtains"} have a twofold
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1032
  meaning: (1) during the of this claim they refer to the the local
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1033
  context introductions, (2) the resulting rule is annotated
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1034
  accordingly to support symbolic case splits when used with the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1035
  @{method_ref cases} method (cf.  \secref{sec:cases-induct}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1036
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1037
  \medskip
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1038
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1039
  \begin{warn}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1040
    Isabelle/Isar suffers theory-level goal statements to contain
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1041
    \emph{unbound schematic variables}, although this does not conform
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1042
    to the aim of human-readable proof documents!  The main problem
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1043
    with schematic goals is that the actual outcome is usually hard to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1044
    predict, depending on the behavior of the proof methods applied
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1045
    during the course of reasoning.  Note that most semi-automated
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1046
    methods heavily depend on several kinds of implicit rule
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1047
    declarations within the current theory context.  As this would
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1048
    also result in non-compositional checking of sub-proofs,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1049
    \emph{local goals} are not allowed to be schematic at all.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1050
    Nevertheless, schematic goals do have their use in Prolog-style
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1051
    interactive synthesis of proven results, usually by stepwise
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1052
    refinement via emulation of traditional Isabelle tactic scripts
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1053
    (see also \secref{sec:tactic-commands}).  In any case, users
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1054
    should know what they are doing.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1055
  \end{warn}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1056
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1057
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1058
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1059
subsection {* Initial and terminal proof steps \label{sec:proof-steps} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1060
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1061
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1062
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1063
    @{command_def "proof"} & : & \isartrans{proof(prove)}{proof(state)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1064
    @{command_def "qed"} & : & \isartrans{proof(state)}{proof(state) ~|~ theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1065
    @{command_def "by"} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1066
    @{command_def ".."} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1067
    @{command_def "."} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1068
    @{command_def "sorry"} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1069
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1070
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1071
  Arbitrary goal refinement via tactics is considered harmful.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1072
  Structured proof composition in Isar admits proof methods to be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1073
  invoked in two places only.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1074
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1075
  \begin{enumerate}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1076
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1077
  \item An \emph{initial} refinement step @{command_ref
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1078
  "proof"}~@{text "m\<^sub>1"} reduces a newly stated goal to a number
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1079
  of sub-goals that are to be solved later.  Facts are passed to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1080
  @{text "m\<^sub>1"} for forward chaining, if so indicated by @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1081
  "proof(chain)"} mode.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1082
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1083
  \item A \emph{terminal} conclusion step @{command_ref "qed"}~@{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1084
  "m\<^sub>2"} is intended to solve remaining goals.  No facts are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1085
  passed to @{text "m\<^sub>2"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1086
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1087
  \end{enumerate}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1088
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1089
  The only other (proper) way to affect pending goals in a proof body
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1090
  is by @{command_ref "show"}, which involves an explicit statement of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1091
  what is to be solved eventually.  Thus we avoid the fundamental
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1092
  problem of unstructured tactic scripts that consist of numerous
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1093
  consecutive goal transformations, with invisible effects.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1094
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1095
  \medskip As a general rule of thumb for good proof style, initial
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1096
  proof methods should either solve the goal completely, or constitute
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1097
  some well-understood reduction to new sub-goals.  Arbitrary
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1098
  automatic proof tools that are prone leave a large number of badly
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1099
  structured sub-goals are no help in continuing the proof document in
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1100
  an intelligible manner.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1101
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1102
  Unless given explicitly by the user, the default initial method is
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1103
  ``@{method_ref rule}'', which applies a single standard elimination
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1104
  or introduction rule according to the topmost symbol involved.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1105
  There is no separate default terminal method.  Any remaining goals
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1106
  are always solved by assumption in the very last step.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1107
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1108
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1109
    'proof' method?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1110
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1111
    'qed' method?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1112
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1113
    'by' method method?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1114
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1115
    ('.' | '..' | 'sorry')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1116
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1117
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1118
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1119
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1120
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1121
  \item [@{command "proof"}~@{text "m\<^sub>1"}] refines the goal by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1122
  proof method @{text "m\<^sub>1"}; facts for forward chaining are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1123
  passed if so indicated by @{text "proof(chain)"} mode.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1124
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1125
  \item [@{command "qed"}~@{text "m\<^sub>2"}] refines any remaining
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1126
  goals by proof method @{text "m\<^sub>2"} and concludes the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1127
  sub-proof by assumption.  If the goal had been @{text "show"} (or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1128
  @{text "thus"}), some pending sub-goal is solved as well by the rule
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1129
  resulting from the result \emph{exported} into the enclosing goal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1130
  context.  Thus @{text "qed"} may fail for two reasons: either @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1131
  "m\<^sub>2"} fails, or the resulting rule does not fit to any
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1132
  pending goal\footnote{This includes any additional ``strong''
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1133
  assumptions as introduced by @{command "assume"}.} of the enclosing
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1134
  context.  Debugging such a situation might involve temporarily
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1135
  changing @{command "show"} into @{command "have"}, or weakening the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1136
  local context by replacing occurrences of @{command "assume"} by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1137
  @{command "presume"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1138
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1139
  \item [@{command "by"}~@{text "m\<^sub>1 m\<^sub>2"}] is a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1140
  \emph{terminal proof}\index{proof!terminal}; it abbreviates
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1141
  @{command "proof"}~@{text "m\<^sub>1"}~@{text "qed"}~@{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1142
  "m\<^sub>2"}, but with backtracking across both methods.  Debugging
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1143
  an unsuccessful @{command "by"}~@{text "m\<^sub>1 m\<^sub>2"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1144
  command can be done by expanding its definition; in many cases
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1145
  @{command "proof"}~@{text "m\<^sub>1"} (or even @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1146
  "apply"}~@{text "m\<^sub>1"}) is already sufficient to see the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1147
  problem.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1148
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1149
  \item [``@{command ".."}''] is a \emph{default
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1150
  proof}\index{proof!default}; it abbreviates @{command "by"}~@{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1151
  "rule"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1152
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1153
  \item [``@{command "."}''] is a \emph{trivial
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1154
  proof}\index{proof!trivial}; it abbreviates @{command "by"}~@{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1155
  "this"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1156
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1157
  \item [@{command "sorry"}] is a \emph{fake proof}\index{proof!fake}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1158
  pretending to solve the pending claim without further ado.  This
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1159
  only works in interactive development, or if the @{ML
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1160
  quick_and_dirty} flag is enabled (in ML).  Facts emerging from fake
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1161
  proofs are not the real thing.  Internally, each theorem container
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1162
  is tainted by an oracle invocation, which is indicated as ``@{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1163
  "[!]"}'' in the printed result.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1164
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1165
  The most important application of @{command "sorry"} is to support
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1166
  experimentation and top-down proof development.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1167
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1168
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1169
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1170
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1171
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1172
subsection {* Fundamental methods and attributes \label{sec:pure-meth-att} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1173
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1174
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1175
  The following proof methods and attributes refer to basic logical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1176
  operations of Isar.  Further methods and attributes are provided by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1177
  several generic and object-logic specific tools and packages (see
26852
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
  1178
  \chref{ch:gen-tools} and \chref{ch:hol}).
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1179
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1180
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1181
    @{method_def "-"} & : & \isarmeth \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1182
    @{method_def "fact"} & : & \isarmeth \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1183
    @{method_def "assumption"} & : & \isarmeth \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1184
    @{method_def "this"} & : & \isarmeth \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1185
    @{method_def "rule"} & : & \isarmeth \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1186
    @{method_def "iprover"} & : & \isarmeth \\[0.5ex]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1187
    @{attribute_def "intro"} & : & \isaratt \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1188
    @{attribute_def "elim"} & : & \isaratt \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1189
    @{attribute_def "dest"} & : & \isaratt \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1190
    @{attribute_def "rule"} & : & \isaratt \\[0.5ex]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1191
    @{attribute_def "OF"} & : & \isaratt \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1192
    @{attribute_def "of"} & : & \isaratt \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1193
    @{attribute_def "where"} & : & \isaratt \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1194
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1195
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1196
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1197
    'fact' thmrefs?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1198
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1199
    'rule' thmrefs?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1200
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1201
    'iprover' ('!' ?) (rulemod *)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1202
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1203
    rulemod: ('intro' | 'elim' | 'dest') ((('!' | () | '?') nat?) | 'del') ':' thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1204
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1205
    ('intro' | 'elim' | 'dest') ('!' | () | '?') nat?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1206
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1207
    'rule' 'del'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1208
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1209
    'OF' thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1210
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1211
    'of' insts ('concl' ':' insts)?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1212
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1213
    'where' ((name | var | typefree | typevar) '=' (type | term) * 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1214
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1215
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1216
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1217
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1218
  
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1219
  \item [``@{method "-"}'' (minus)] does nothing but insert the
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1220
  forward chaining facts as premises into the goal.  Note that command
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1221
  @{command_ref "proof"} without any method actually performs a single
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1222
  reduction step using the @{method_ref rule} method; thus a plain
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1223
  \emph{do-nothing} proof step would be ``@{command "proof"}~@{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1224
  "-"}'' rather than @{command "proof"} alone.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1225
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1226
  \item [@{method "fact"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}] composes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1227
  some fact from @{text "a\<^sub>1, \<dots>, a\<^sub>n"} (or implicitly from
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1228
  the current proof context) modulo unification of schematic type and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1229
  term variables.  The rule structure is not taken into account, i.e.\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1230
  meta-level implication is considered atomic.  This is the same
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1231
  principle underlying literal facts (cf.\ \secref{sec:syn-att}):
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1232
  ``@{command "have"}~@{text "\<phi>"}~@{command "by"}~@{text fact}'' is
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1233
  equivalent to ``@{command "note"}~@{verbatim "`"}@{text \<phi>}@{verbatim
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1234
  "`"}'' provided that @{text "\<turnstile> \<phi>"} is an instance of some known
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1235
  @{text "\<turnstile> \<phi>"} in the proof context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1236
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1237
  \item [@{method assumption}] solves some goal by a single assumption
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1238
  step.  All given facts are guaranteed to participate in the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1239
  refinement; this means there may be only 0 or 1 in the first place.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1240
  Recall that @{command "qed"} (\secref{sec:proof-steps}) already
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1241
  concludes any remaining sub-goals by assumption, so structured
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1242
  proofs usually need not quote the @{method assumption} method at
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1243
  all.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1244
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1245
  \item [@{method this}] applies all of the current facts directly as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1246
  rules.  Recall that ``@{command "."}'' (dot) abbreviates ``@{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1247
  "by"}~@{text this}''.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1248
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1249
  \item [@{method rule}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}] applies some
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1250
  rule given as argument in backward manner; facts are used to reduce
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1251
  the rule before applying it to the goal.  Thus @{method rule}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1252
  without facts is plain introduction, while with facts it becomes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1253
  elimination.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1254
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1255
  When no arguments are given, the @{method rule} method tries to pick
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1256
  appropriate rules automatically, as declared in the current context
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1257
  using the @{attribute intro}, @{attribute elim}, @{attribute dest}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1258
  attributes (see below).  This is the default behavior of @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1259
  "proof"} and ``@{command ".."}'' (double-dot) steps (see
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1260
  \secref{sec:proof-steps}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1261
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1262
  \item [@{method iprover}] performs intuitionistic proof search,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1263
  depending on specifically declared rules from the context, or given
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1264
  as explicit arguments.  Chained facts are inserted into the goal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1265
  before commencing proof search; ``@{method iprover}@{text "!"}'' 
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1266
  means to include the current @{fact prems} as well.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1267
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1268
  Rules need to be classified as @{attribute intro}, @{attribute
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1269
  elim}, or @{attribute dest}; here the ``@{text "!"}'' indicator
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1270
  refers to ``safe'' rules, which may be applied aggressively (without
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1271
  considering back-tracking later).  Rules declared with ``@{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1272
  "?"}'' are ignored in proof search (the single-step @{method rule}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1273
  method still observes these).  An explicit weight annotation may be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1274
  given as well; otherwise the number of rule premises will be taken
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1275
  into account here.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1276
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1277
  \item [@{attribute intro}, @{attribute elim}, and @{attribute dest}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1278
  declare introduction, elimination, and destruct rules, to be used
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1279
  with the @{method rule} and @{method iprover} methods.  Note that
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1280
  the latter will ignore rules declared with ``@{text "?"}'', while
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1281
  ``@{text "!"}''  are used most aggressively.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1282
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1283
  The classical reasoner (see \secref{sec:classical}) introduces its
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1284
  own variants of these attributes; use qualified names to access the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1285
  present versions of Isabelle/Pure, i.e.\ @{attribute "Pure.intro"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1286
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1287
  \item [@{attribute rule}~@{text del}] undeclares introduction,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1288
  elimination, or destruct rules.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1289
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1290
  \item [@{attribute OF}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}] applies some
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1291
  theorem to all of the given rules @{text "a\<^sub>1, \<dots>, a\<^sub>n"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1292
  (in parallel).  This corresponds to the @{ML "op MRS"} operation in
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1293
  ML, but note the reversed order.  Positions may be effectively
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1294
  skipped by including ``@{text _}'' (underscore) as argument.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1295
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1296
  \item [@{attribute of}~@{text "t\<^sub>1 \<dots> t\<^sub>n"}] performs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1297
  positional instantiation of term variables.  The terms @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1298
  "t\<^sub>1, \<dots>, t\<^sub>n"} are substituted for any schematic
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1299
  variables occurring in a theorem from left to right; ``@{text
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1300
  _}'' (underscore) indicates to skip a position.  Arguments following
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1301
  a ``@{keyword "concl"}@{text ":"}'' specification refer to positions
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1302
  of the conclusion of a rule.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1303
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1304
  \item [@{attribute "where"}~@{text "x\<^sub>1 = t\<^sub>1 \<AND> \<dots>
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1305
  x\<^sub>n = t\<^sub>n"}] performs named instantiation of schematic
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1306
  type and term variables occurring in a theorem.  Schematic variables
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1307
  have to be specified on the left-hand side (e.g.\ @{text "?x1.3"}).
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1308
  The question mark may be omitted if the variable name is a plain
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1309
  identifier without index.  As type instantiations are inferred from
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1310
  term instantiations, explicit type instantiations are seldom
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1311
  necessary.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1312
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1313
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1314
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1315
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1316
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1317
subsection {* Term abbreviations \label{sec:term-abbrev} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1318
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1319
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1320
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1321
    @{command_def "let"} & : & \isartrans{proof(state)}{proof(state)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1322
    @{keyword_def "is"} & : & syntax \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1323
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1324
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1325
  Abbreviations may be either bound by explicit @{command
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1326
  "let"}~@{text "p \<equiv> t"} statements, or by annotating assumptions or
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1327
  goal statements with a list of patterns ``@{text "(\<IS> p\<^sub>1 \<dots>
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1328
  p\<^sub>n)"}''.  In both cases, higher-order matching is invoked to
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1329
  bind extra-logical term variables, which may be either named
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1330
  schematic variables of the form @{text ?x}, or nameless dummies
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1331
  ``@{variable _}'' (underscore). Note that in the @{command "let"}
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1332
  form the patterns occur on the left-hand side, while the @{keyword
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1333
  "is"} patterns are in postfix position.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1334
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1335
  Polymorphism of term bindings is handled in Hindley-Milner style,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1336
  similar to ML.  Type variables referring to local assumptions or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1337
  open goal statements are \emph{fixed}, while those of finished
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1338
  results or bound by @{command "let"} may occur in \emph{arbitrary}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1339
  instances later.  Even though actual polymorphism should be rarely
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1340
  used in practice, this mechanism is essential to achieve proper
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1341
  incremental type-inference, as the user proceeds to build up the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1342
  Isar proof text from left to right.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1343
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1344
  \medskip Term abbreviations are quite different from local
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1345
  definitions as introduced via @{command "def"} (see
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1346
  \secref{sec:proof-context}).  The latter are visible within the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1347
  logic as actual equations, while abbreviations disappear during the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1348
  input process just after type checking.  Also note that @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1349
  "def"} does not support polymorphism.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1350
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1351
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1352
    'let' ((term + 'and') '=' term + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1353
    ;  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1354
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1355
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1356
  The syntax of @{keyword "is"} patterns follows \railnonterm{termpat}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1357
  or \railnonterm{proppat} (see \secref{sec:term-decls}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1358
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1359
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1360
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1361
  \item [@{command "let"}~@{text "p\<^sub>1 = t\<^sub>1 \<AND> \<dots>
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1362
  p\<^sub>n = t\<^sub>n"}] binds any text variables in patterns @{text
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1363
  "p\<^sub>1, \<dots>, p\<^sub>n"} by simultaneous higher-order matching
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1364
  against terms @{text "t\<^sub>1, \<dots>, t\<^sub>n"}.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1365
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1366
  \item [@{text "(\<IS> p\<^sub>1 \<dots> p\<^sub>n)"}] resembles @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1367
  "let"}, but matches @{text "p\<^sub>1, \<dots>, p\<^sub>n"} against the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1368
  preceding statement.  Also note that @{keyword "is"} is not a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1369
  separate command, but part of others (such as @{command "assume"},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1370
  @{command "have"} etc.).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1371
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1372
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1373
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1374
  Some \emph{implicit} term abbreviations\index{term abbreviations}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1375
  for goals and facts are available as well.  For any open goal,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1376
  @{variable_ref thesis} refers to its object-level statement,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1377
  abstracted over any meta-level parameters (if present).  Likewise,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1378
  @{variable_ref this} is bound for fact statements resulting from
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1379
  assumptions or finished goals.  In case @{variable this} refers to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1380
  an object-logic statement that is an application @{text "f t"}, then
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1381
  @{text t} is bound to the special text variable ``@{variable "\<dots>"}''
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1382
  (three dots).  The canonical application of this convenience are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1383
  calculational proofs (see \secref{sec:calculation}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1384
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1385
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1386
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1387
subsection {* Block structure *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1388
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1389
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1390
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1391
    @{command_def "next"} & : & \isartrans{proof(state)}{proof(state)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1392
    @{command_def "{"} & : & \isartrans{proof(state)}{proof(state)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1393
    @{command_def "}"} & : & \isartrans{proof(state)}{proof(state)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1394
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1395
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1396
  While Isar is inherently block-structured, opening and closing
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1397
  blocks is mostly handled rather casually, with little explicit
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1398
  user-intervention.  Any local goal statement automatically opens
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1399
  \emph{two} internal blocks, which are closed again when concluding
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1400
  the sub-proof (by @{command "qed"} etc.).  Sections of different
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1401
  context within a sub-proof may be switched via @{command "next"},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1402
  which is just a single block-close followed by block-open again.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1403
  The effect of @{command "next"} is to reset the local proof context;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1404
  there is no goal focus involved here!
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1405
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1406
  For slightly more advanced applications, there are explicit block
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1407
  parentheses as well.  These typically achieve a stronger forward
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1408
  style of reasoning.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1409
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1410
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1411
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1412
  \item [@{command "next"}] switches to a fresh block within a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1413
  sub-proof, resetting the local context to the initial one.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1414
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1415
  \item [@{command "{"} and @{command "}"}] explicitly open and close
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1416
  blocks.  Any current facts pass through ``@{command "{"}''
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1417
  unchanged, while ``@{command "}"}'' causes any result to be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1418
  \emph{exported} into the enclosing context.  Thus fixed variables
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1419
  are generalized, assumptions discharged, and local definitions
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1420
  unfolded (cf.\ \secref{sec:proof-context}).  There is no difference
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1421
  of @{command "assume"} and @{command "presume"} in this mode of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1422
  forward reasoning --- in contrast to plain backward reasoning with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1423
  the result exported at @{command "show"} time.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1424
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1425
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1426
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1427
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1428
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1429
subsection {* Emulating tactic scripts \label{sec:tactic-commands} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1430
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1431
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1432
  The Isar provides separate commands to accommodate tactic-style
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1433
  proof scripts within the same system.  While being outside the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1434
  orthodox Isar proof language, these might come in handy for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1435
  interactive exploration and debugging, or even actual tactical proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1436
  within new-style theories (to benefit from document preparation, for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1437
  example).  See also \secref{sec:tactics} for actual tactics, that
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1438
  have been encapsulated as proof methods.  Proper proof methods may
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1439
  be used in scripts, too.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1440
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1441
  \begin{matharray}{rcl}
26866
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1442
    @{command_def "apply"}@{text "\<^sup>*"} & : & \isartrans{proof(prove)}{proof(prove)} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1443
    @{command_def "apply_end"}@{text "\<^sup>*"} & : & \isartrans{proof(state)}{proof(state)} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1444
    @{command_def "done"}@{text "\<^sup>*"} & : & \isartrans{proof(prove)}{proof(state)} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1445
    @{command_def "defer"}@{text "\<^sup>*"} & : & \isartrans{proof}{proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1446
    @{command_def "prefer"}@{text "\<^sup>*"} & : & \isartrans{proof}{proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1447
    @{command_def "back"}@{text "\<^sup>*"} & : & \isartrans{proof}{proof} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1448
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1449
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1450
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1451
    ( 'apply' | 'apply\_end' ) method
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1452
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1453
    'defer' nat?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1454
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1455
    'prefer' nat
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1456
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1457
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1458
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1459
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1460
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1461
  \item [@{command "apply"}~@{text m}] applies proof method @{text m}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1462
  in initial position, but unlike @{command "proof"} it retains
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1463
  ``@{text "proof(prove)"}'' mode.  Thus consecutive method
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1464
  applications may be given just as in tactic scripts.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1465
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1466
  Facts are passed to @{text m} as indicated by the goal's
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1467
  forward-chain mode, and are \emph{consumed} afterwards.  Thus any
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1468
  further @{command "apply"} command would always work in a purely
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1469
  backward manner.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1470
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1471
  \item [@{command "apply_end"}~@{text "m"}] applies proof method
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1472
  @{text m} as if in terminal position.  Basically, this simulates a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1473
  multi-step tactic script for @{command "qed"}, but may be given
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1474
  anywhere within the proof body.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1475
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1476
  No facts are passed to @{method m} here.  Furthermore, the static
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1477
  context is that of the enclosing goal (as for actual @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1478
  "qed"}).  Thus the proof method may not refer to any assumptions
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1479
  introduced in the current body, for example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1480
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1481
  \item [@{command "done"}] completes a proof script, provided that
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1482
  the current goal state is solved completely.  Note that actual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1483
  structured proof commands (e.g.\ ``@{command "."}'' or @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1484
  "sorry"}) may be used to conclude proof scripts as well.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1485
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1486
  \item [@{command "defer"}~@{text n} and @{command "prefer"}~@{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1487
  n}] shuffle the list of pending goals: @{command "defer"} puts off
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1488
  sub-goal @{text n} to the end of the list (@{text "n = 1"} by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1489
  default), while @{command "prefer"} brings sub-goal @{text n} to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1490
  front.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1491
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1492
  \item [@{command "back"}] does back-tracking over the result
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1493
  sequence of the latest proof command.  Basically, any proof command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1494
  may return multiple results.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1495
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1496
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1497
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1498
  Any proper Isar proof method may be used with tactic script commands
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1499
  such as @{command "apply"}.  A few additional emulations of actual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1500
  tactics are provided as well; these would be never used in actual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1501
  structured proofs, of course.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1502
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1503
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1504
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1505
subsection {* Meta-linguistic features *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1506
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1507
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1508
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1509
    @{command_def "oops"} & : & \isartrans{proof}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1510
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1511
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1512
  The @{command "oops"} command discontinues the current proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1513
  attempt, while considering the partial proof text as properly
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1514
  processed.  This is conceptually quite different from ``faking''
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1515
  actual proofs via @{command_ref "sorry"} (see
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1516
  \secref{sec:proof-steps}): @{command "oops"} does not observe the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1517
  proof structure at all, but goes back right to the theory level.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1518
  Furthermore, @{command "oops"} does not produce any result theorem
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1519
  --- there is no intended claim to be able to complete the proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1520
  anyhow.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1521
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1522
  A typical application of @{command "oops"} is to explain Isar proofs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1523
  \emph{within} the system itself, in conjunction with the document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1524
  preparation tools of Isabelle described in \cite{isabelle-sys}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1525
  Thus partial or even wrong proof attempts can be discussed in a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1526
  logically sound manner.  Note that the Isabelle {\LaTeX} macros can
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1527
  be easily adapted to print something like ``@{text "\<dots>"}'' instead of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1528
  the keyword ``@{command "oops"}''.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1529
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1530
  \medskip The @{command "oops"} command is undo-able, unlike
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1531
  @{command_ref "kill"} (see \secref{sec:history}).  The effect is to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1532
  get back to the theory just before the opening of the proof.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1533
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1534
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1535
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1536
section {* Other commands *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1537
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1538
subsection {* Diagnostics *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1539
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1540
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1541
  \begin{matharray}{rcl}
26866
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1542
    @{command_def "pr"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1543
    @{command_def "thm"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1544
    @{command_def "term"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1545
    @{command_def "prop"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1546
    @{command_def "typ"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1547
    @{command_def "prf"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1548
    @{command_def "full_prf"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1549
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1550
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1551
  These diagnostic commands assist interactive development.  Note that
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1552
  @{command undo} does not apply here, the theory or proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1553
  configuration is not changed.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1554
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1555
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1556
    'pr' modes? nat? (',' nat)?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1557
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1558
    'thm' modes? thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1559
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1560
    'term' modes? term
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1561
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1562
    'prop' modes? prop
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1563
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1564
    'typ' modes? type
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1565
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1566
    'prf' modes? thmrefs?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1567
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1568
    'full\_prf' modes? thmrefs?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1569
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1570
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1571
    modes: '(' (name + ) ')'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1572
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1573
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1574
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1575
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1576
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1577
  \item [@{command "pr"}~@{text "goals, prems"}] prints the current
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1578
  proof state (if present), including the proof context, current facts
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1579
  and goals.  The optional limit arguments affect the number of goals
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1580
  and premises to be displayed, which is initially 10 for both.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1581
  Omitting limit values leaves the current setting unchanged.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1582
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1583
  \item [@{command "thm"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}] retrieves
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1584
  theorems from the current theory or proof context.  Note that any
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1585
  attributes included in the theorem specifications are applied to a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1586
  temporary context derived from the current theory or proof; the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1587
  result is discarded, i.e.\ attributes involved in @{text "a\<^sub>1,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1588
  \<dots>, a\<^sub>n"} do not have any permanent effect.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1589
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1590
  \item [@{command "term"}~@{text t} and @{command "prop"}~@{text \<phi>}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1591
  read, type-check and print terms or propositions according to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1592
  current theory or proof context; the inferred type of @{text t} is
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1593
  output as well.  Note that these commands are also useful in
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1594
  inspecting the current environment of term abbreviations.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1595
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1596
  \item [@{command "typ"}~@{text \<tau>}] reads and prints types of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1597
  meta-logic according to the current theory or proof context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1598
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1599
  \item [@{command "prf"}] displays the (compact) proof term of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1600
  current proof state (if present), or of the given theorems. Note
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1601
  that this requires proof terms to be switched on for the current
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1602
  object logic (see the ``Proof terms'' section of the Isabelle
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1603
  reference manual for information on how to do this).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1604
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1605
  \item [@{command "full_prf"}] is like @{command "prf"}, but displays
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1606
  the full proof term, i.e.\ also displays information omitted in the
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1607
  compact proof term, which is denoted by ``@{text _}'' placeholders
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1608
  there.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1609
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1610
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1611
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1612
  All of the diagnostic commands above admit a list of @{text modes}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1613
  to be specified, which is appended to the current print mode (see
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1614
  also \cite{isabelle-ref}).  Thus the output behavior may be modified
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1615
  according particular print mode features.  For example, @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1616
  "pr"}~@{text "(latex xsymbols symbols)"} would print the current
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1617
  proof state with mathematical symbols and special characters
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1618
  represented in {\LaTeX} source, according to the Isabelle style
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1619
  \cite{isabelle-sys}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1620
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1621
  Note that antiquotations (cf.\ \secref{sec:antiq}) provide a more
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1622
  systematic way to include formal items into the printed text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1623
  document.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1624
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1625
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1626
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1627
subsection {* Inspecting the context *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1628
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1629
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1630
  \begin{matharray}{rcl}
26866
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1631
    @{command_def "print_commands"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1632
    @{command_def "print_theory"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1633
    @{command_def "print_syntax"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1634
    @{command_def "print_methods"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1635
    @{command_def "print_attributes"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1636
    @{command_def "print_theorems"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1637
    @{command_def "find_theorems"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1638
    @{command_def "thms_deps"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1639
    @{command_def "print_facts"}@{text "\<^sup>*"} & : & \isarkeep{proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1640
    @{command_def "print_binds"}@{text "\<^sup>*"} & : & \isarkeep{proof} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1641
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1642
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1643
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1644
    'print\_theory' ( '!'?)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1645
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1646
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1647
    'find\_theorems' (('(' (nat)? ('with\_dups')? ')')?) (criterion *)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1648
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1649
    criterion: ('-'?) ('name' ':' nameref | 'intro' | 'elim' | 'dest' |
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1650
      'simp' ':' term | term)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1651
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1652
    'thm\_deps' thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1653
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1654
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1655
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1656
  These commands print certain parts of the theory and proof context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1657
  Note that there are some further ones available, such as for the set
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1658
  of rules declared for simplifications.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1659
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1660
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1661
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1662
  \item [@{command "print_commands"}] prints Isabelle's outer theory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1663
  syntax, including keywords and command.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1664
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1665
  \item [@{command "print_theory"}] prints the main logical content of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1666
  the theory context; the ``@{text "!"}'' option indicates extra
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1667
  verbosity.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1668
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1669
  \item [@{command "print_syntax"}] prints the inner syntax of types
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1670
  and terms, depending on the current context.  The output can be very
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1671
  verbose, including grammar tables and syntax translation rules.  See
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1672
  \cite[\S7, \S8]{isabelle-ref} for further information on Isabelle's
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1673
  inner syntax.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1674
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1675
  \item [@{command "print_methods"}] prints all proof methods
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1676
  available in the current theory context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1677
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1678
  \item [@{command "print_attributes"}] prints all attributes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1679
  available in the current theory context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1680
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1681
  \item [@{command "print_theorems"}] prints theorems resulting from
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1682
  the last command.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1683
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1684
  \item [@{command "find_theorems"}~@{text criteria}] retrieves facts
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1685
  from the theory or proof context matching all of given search
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1686
  criteria.  The criterion @{text "name: p"} selects all theorems
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1687
  whose fully qualified name matches pattern @{text p}, which may
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1688
  contain ``@{text "*"}'' wildcards.  The criteria @{text intro},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1689
  @{text elim}, and @{text dest} select theorems that match the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1690
  current goal as introduction, elimination or destruction rules,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1691
  respectively.  The criterion @{text "simp: t"} selects all rewrite
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1692
  rules whose left-hand side matches the given term.  The criterion
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1693
  term @{text t} selects all theorems that contain the pattern @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1694
  t} -- as usual, patterns may contain occurrences of the dummy
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
  1695
  ``@{text _}'', schematic variables, and type constraints.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1696
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1697
  Criteria can be preceded by ``@{text "-"}'' to select theorems that
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1698
  do \emph{not} match. Note that giving the empty list of criteria
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1699
  yields \emph{all} currently known facts.  An optional limit for the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1700
  number of printed facts may be given; the default is 40.  By
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1701
  default, duplicates are removed from the search result. Use
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1702
  @{keyword "with_dups"} to display duplicates.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1703
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1704
  \item [@{command "thm_deps"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1705
  visualizes dependencies of facts, using Isabelle's graph browser
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1706
  tool (see also \cite{isabelle-sys}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1707
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1708
  \item [@{command "print_facts"}] prints all local facts of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1709
  current context, both named and unnamed ones.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1710
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1711
  \item [@{command "print_binds"}] prints all term abbreviations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1712
  present in the context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1713
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1714
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1715
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1716
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1717
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1718
subsection {* History commands \label{sec:history} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1719
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1720
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1721
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1722
    @{command_def "undo"}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1723
    @{command_def "redo"}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1724
    @{command_def "kill"}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1725
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1726
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1727
  The Isabelle/Isar top-level maintains a two-stage history, for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1728
  theory and proof state transformation.  Basically, any command can
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1729
  be undone using @{command "undo"}, excluding mere diagnostic
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1730
  elements.  Its effect may be revoked via @{command "redo"}, unless
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1731
  the corresponding @{command "undo"} step has crossed the beginning
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1732
  of a proof or theory.  The @{command "kill"} command aborts the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1733
  current history node altogether, discontinuing a proof or even the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1734
  whole theory.  This operation is \emph{not} undo-able.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1735
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1736
  \begin{warn}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1737
    History commands should never be used with user interfaces such as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1738
    Proof~General \cite{proofgeneral,Aspinall:TACAS:2000}, which takes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1739
    care of stepping forth and back itself.  Interfering by manual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1740
    @{command "undo"}, @{command "redo"}, or even @{command "kill"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1741
    commands would quickly result in utter confusion.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1742
  \end{warn}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1743
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1744
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1745
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1746
subsection {* System operations *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1747
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1748
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1749
  \begin{matharray}{rcl}
26866
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1750
    @{command_def "cd"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1751
    @{command_def "pwd"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1752
    @{command_def "use_thy"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1753
    @{command_def "display_drafts"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
  1754
    @{command_def "print_drafts"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1755
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1756
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1757
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1758
    ('cd' | 'use\_thy' | 'update\_thy') name
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1759
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1760
    ('display\_drafts' | 'print\_drafts') (name +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1761
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1762
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1763
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1764
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1765
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1766
  \item [@{command "cd"}~@{text path}] changes the current directory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1767
  of the Isabelle process.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1768
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1769
  \item [@{command "pwd"}] prints the current working directory.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1770
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1771
  \item [@{command "use_thy"}~@{text A}] preload theory @{text A}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1772
  These system commands are scarcely used when working interactively,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1773
  since loading of theories is done automatically as required.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1774
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1775
  \item [@{command "display_drafts"}~@{text paths} and @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1776
  "print_drafts"}~@{text paths}] perform simple output of a given list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1777
  of raw source files.  Only those symbols that do not require
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1778
  additional {\LaTeX} packages are displayed properly, everything else
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1779
  is left verbatim.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1780
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1781
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1782
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1783
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1784
end