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