doc-src/IsarRef/generic.tex
author wenzelm
Wed, 01 Aug 2007 16:55:37 +0200
changeset 24110 4ab3084e311c
parent 24085 cbad32e7ab40
child 24429 76372c3847a2
permissions -rw-r--r--
tuned config options: eliminated separate attribute "option";
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13048
wenzelm
parents: 13042
diff changeset
     1
\chapter{Generic tools and packages}\label{ch:gen-tools}
7167
wenzelm
parents: 7141
diff changeset
     2
24085
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
     3
\section{Specification commands}
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
     4
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
     5
\subsection{Derived specifications}
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
     6
19666
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
     7
\indexisarcmd{axiomatization}
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
     8
\indexisarcmd{definition}\indexisaratt{defn}
21716
8fcacb0e3b15 added print_abbrevs;
wenzelm
parents: 21601
diff changeset
     9
\indexisarcmd{abbreviation}\indexisarcmd{print-abbrevs}
21209
dbb8decc36bc 'const_syntax' command: allow fixed variables, renamed to 'notation';
wenzelm
parents: 21076
diff changeset
    10
\indexisarcmd{notation}
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    11
\begin{matharray}{rcll}
19666
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    12
  \isarcmd{axiomatization} & : & \isarkeep{local{\dsh}theory} & (axiomatic!)\\
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    13
  \isarcmd{definition} & : & \isarkeep{local{\dsh}theory} \\
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    14
  defn & : & \isaratt \\
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    15
  \isarcmd{abbreviation} & : & \isarkeep{local{\dsh}theory} \\
21716
8fcacb0e3b15 added print_abbrevs;
wenzelm
parents: 21601
diff changeset
    16
  \isarcmd{print_abbrevs}^* & : & \isarkeep{theory~|~proof} \\
21209
dbb8decc36bc 'const_syntax' command: allow fixed variables, renamed to 'notation';
wenzelm
parents: 21076
diff changeset
    17
  \isarcmd{notation} & : & \isarkeep{local{\dsh}theory} \\
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    18
\end{matharray}
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    19
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    20
These specification mechanisms provide a slightly more abstract view
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    21
than the underlying primitives of $\CONSTS$, $\DEFS$ (see
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    22
\S\ref{sec:consts}), and $\isarkeyword{axioms}$ (see
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    23
\S\ref{sec:axms-thms}).  In particular, type-inference is commonly
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    24
available, and result names need not be given.
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    25
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    26
\begin{rail}
21601
6588b947d631 simplified syntax for 'definition', 'abbreviation';
wenzelm
parents: 21403
diff changeset
    27
  'axiomatization' target? fixes? ('where' specs)?
19666
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    28
  ;
21601
6588b947d631 simplified syntax for 'definition', 'abbreviation';
wenzelm
parents: 21403
diff changeset
    29
  'definition' target? (decl 'where')? thmdecl? prop
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    30
  ;
21601
6588b947d631 simplified syntax for 'definition', 'abbreviation';
wenzelm
parents: 21403
diff changeset
    31
  'abbreviation' target? mode? (decl 'where')? prop
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    32
  ;
21403
dd58f13a8eb4 'notation': more robust 'and' list;
wenzelm
parents: 21303
diff changeset
    33
  'notation' target? mode? (nameref mixfix + 'and')
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    34
  ;
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    35
21601
6588b947d631 simplified syntax for 'definition', 'abbreviation';
wenzelm
parents: 21403
diff changeset
    36
  fixes: ((name ('::' type)? mixfix? | vars) + 'and')
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    37
  ;
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    38
  specs: (thmdecl? props + 'and')
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    39
  ;
21601
6588b947d631 simplified syntax for 'definition', 'abbreviation';
wenzelm
parents: 21403
diff changeset
    40
  decl: name ('::' type)? mixfix?
6588b947d631 simplified syntax for 'definition', 'abbreviation';
wenzelm
parents: 21403
diff changeset
    41
  ;
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    42
\end{rail}
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    43
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    44
\begin{descr}
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    45
  
19666
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    46
\item $\isarkeyword{axiomatization} ~ c@1 \dots c@n ~
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    47
  \isarkeyword{where} ~ A@1 \dots A@m$ introduces several constants
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    48
  simultaneously and states axiomatic properties for these.  The
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    49
  constants are marked as being specified once and for all, which
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    50
  prevents additional specifications being issued later on.
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    51
  
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    52
  Note that axiomatic specifications are only appropriate when
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    53
  declaring a new logical system.  Normal applications should only use
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    54
  definitional mechanisms!
eee5e8dbda59 const_syntax;
wenzelm
parents: 19379
diff changeset
    55
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    56
\item $\isarkeyword{definition}~c~\isarkeyword{where}~eq$ produces an
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    57
  internal definition $c \equiv t$ according to the specification
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    58
  given as $eq$, which is then turned into a proven fact.  The given
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    59
  proposition may deviate from internal meta-level equality according
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    60
  to the rewrite rules declared as $defn$ by the object-logic.  This
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    61
  typically covers object-level equality $x = t$ and equivalence $A
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    62
  \leftrightarrow B$.  Users normally need not change the $defn$
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    63
  setup.
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    64
  
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    65
  Definitions may be presented with explicit arguments on the LHS, as
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    66
  well as additional conditions, e.g.\ $f\;x\;y = t$ instead of $f
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    67
  \equiv \lambda x\;y. t$ and $y \not= 0 \Imp g\;x\;y = u$ instead of
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    68
  an unguarded $g \equiv \lambda x\;y. u$.
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    69
  
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    70
\item $\isarkeyword{abbreviation}~c~\isarkeyword{where}~eq$ introduces
19363
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    71
  a syntactic constant which is associated with a certain term
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    72
  according to the meta-level equality $eq$.
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    73
  
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    74
  Abbreviations participate in the usual type-inference process, but
19363
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    75
  are expanded before the logic ever sees them.  Pretty printing of
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    76
  terms involves higher-order rewriting with rules stemming from
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    77
  reverted abbreviations.  This needs some care to avoid overlapping
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    78
  or looping syntactic replacements!
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    79
  
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    80
  The optional $mode$ specification restricts output to a particular
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    81
  print mode; using ``$input$'' here achieves the effect of one-way
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    82
  abbreviations.  The mode may also include an ``$output$'' qualifier
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    83
  that affects the concrete syntax declared for abbreviations, cf.\ 
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19145
diff changeset
    84
  $\isarkeyword{syntax}$ in \S\ref{sec:syn-trans}.
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    85
  
21716
8fcacb0e3b15 added print_abbrevs;
wenzelm
parents: 21601
diff changeset
    86
\item $\isarkeyword{print_abbrevs}$ prints all constant abbreviations
8fcacb0e3b15 added print_abbrevs;
wenzelm
parents: 21601
diff changeset
    87
  of the current context.
8fcacb0e3b15 added print_abbrevs;
wenzelm
parents: 21601
diff changeset
    88
  
21209
dbb8decc36bc 'const_syntax' command: allow fixed variables, renamed to 'notation';
wenzelm
parents: 21076
diff changeset
    89
\item $\isarkeyword{notation}~c~mx$ associates mixfix syntax with an
dbb8decc36bc 'const_syntax' command: allow fixed variables, renamed to 'notation';
wenzelm
parents: 21076
diff changeset
    90
  existing constant or fixed variable.  This is a robust interface to
dbb8decc36bc 'const_syntax' command: allow fixed variables, renamed to 'notation';
wenzelm
parents: 21076
diff changeset
    91
  the underlying $\isarkeyword{syntax}$ primitive
dbb8decc36bc 'const_syntax' command: allow fixed variables, renamed to 'notation';
wenzelm
parents: 21076
diff changeset
    92
  (\S\ref{sec:syn-trans}).  Type declaration and internal syntactic
dbb8decc36bc 'const_syntax' command: allow fixed variables, renamed to 'notation';
wenzelm
parents: 21076
diff changeset
    93
  representation of the given entity is retrieved from the context.
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    94
  
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    95
\end{descr}
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    96
21303
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
    97
All of these specifications support local theory targets (cf.\ 
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
    98
\S\ref{sec:target}).
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
    99
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
   100
24026
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   101
\subsection{Generic declarations}
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   102
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   103
Arbitrary operations on the background context may be wrapped-up as
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   104
generic declaration elements.  Since the underlying concept of local
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   105
theories may be subject to later re-interpretation, there is an
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   106
additional dependency on a morphism that tells the difference of the
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   107
original declaration context wrt.\ the application context encountered
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   108
later on.  A fact declaration is an important special case: it
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   109
consists of a theorem which is applied to the context by means of an
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   110
attribute.
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   111
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   112
\indexisarcmd{declaration}\indexisarcmd{declare}
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   113
\begin{matharray}{rcl}
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   114
  \isarcmd{declaration} & : & \isarkeep{local{\dsh}theory} \\
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   115
  \isarcmd{declare} & : & \isarkeep{local{\dsh}theory} \\
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   116
\end{matharray}
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   117
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   118
\begin{rail}
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   119
  'declaration' target? text
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   120
  ;
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   121
  'declare' target? (thmrefs + 'and')
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   122
  ;
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   123
\end{rail}
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   124
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   125
\begin{descr}
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   126
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   127
\item [$\isarkeyword{declaration}~d$] adds the declaration function
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   128
  $d$ of ML type \verb,declaration, to the current local theory under
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   129
  construction.  In later application contexts, the function is
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   130
  transformed according to the morphisms being involved in the
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   131
  interpretation hierarchy.
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   132
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   133
\item [$\isarkeyword{declare}~thms$] declares theorems to the current
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   134
  local theory context.  No theorem binding is involved here, unlike
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   135
  $\isarkeyword{theorems}$ or $\isarkeyword{lemmas}$ (cf.\
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   136
  \S\ref{sec:axms-thms}), so $\isarkeyword{declare}$ only has the
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   137
  effect of applying attributes as included in the theorem
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   138
  specification.
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   139
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   140
\end{descr}
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   141
8a4d5312d378 commands 'declare', 'declaration';
wenzelm
parents: 24015
diff changeset
   142
21303
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   143
\subsection{Local theory targets}\label{sec:target}
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   144
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   145
A local theory target is a context managed separately within the
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   146
enclosing theory.  Contexts may introduce parameters (fixed variables)
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   147
and assumptions (hypotheses).  Definitions and theorems depending on
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   148
the context may be added incrementally later on.  Named contexts refer
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   149
to locales (cf.\ \S\ref{sec:locale}) or type classes (cf.\ 
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   150
\S\ref{sec:class}); the name ``$-$'' signifies the global theory
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   151
context.
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   152
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   153
\indexisarcmd{context}\indexisarcmd{end}
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   154
\begin{matharray}{rcll}
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   155
  \isarcmd{context} & : & \isartrans{theory}{local{\dsh}theory} \\
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   156
  \isarcmd{end} & : & \isartrans{local{\dsh}theory}{theory} \\
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   157
\end{matharray}
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   158
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   159
\indexouternonterm{target}
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   160
\begin{rail}
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   161
  'context' name 'begin'
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   162
  ;
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   163
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   164
  target: '(' 'in' name ')'
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   165
  ;
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   166
\end{rail}
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   167
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   168
\begin{descr}
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   169
  
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   170
\item $\isarkeyword{context}~c~\isarkeyword{begin}$ recommences an
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   171
  existing locale or class context $c$.  Note that locale and class
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   172
  definitions allow to include the $\isarkeyword{begin}$ keyword as
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   173
  well, in order to continue the local theory immediately after the
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   174
  initial specification.
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   175
  
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   176
\item $\END$ concludes the current local theory and continues the
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   177
  enclosing global theory.  Note that a non-local $\END$ has a
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   178
  different meaning: it concludes the theory itself
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   179
  (\S\ref{sec:begin-thy}).
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   180
  
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   181
\item $(\IN~loc)$ given after any local theory command specifies an
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   182
  immediate target, e.g.\ 
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   183
  ``$\isarkeyword{definition}~(\IN~loc)~\dots$'' or
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   184
  ``$\THEOREMNAME~(\IN~loc)~\dots$''.  This works both in a local or
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   185
  global theory context; the current target context will be suspended
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   186
  for this command only.  Note that $(\IN~-)$ will always produce a
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   187
  global result independently of the current target context.
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   188
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   189
\end{descr}
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   190
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   191
The exact meaning of results produced within a local theory context
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   192
depends on the underlying target infrastructure (locale, type class
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   193
etc.).  The general idea is as follows, considering a context named
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   194
$c$ with parameter $x$ and assumption $A[x]$.
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   195
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   196
Definitions are exported by introducing a global version with
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   197
additional arguments; a syntactic abbreviation links the long form
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   198
with the abstract version of the target context.  For example, $a
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   199
\equiv t[x]$ becomes $c\dtt a \; ?x \equiv t[?x]$ at the theory level
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   200
(for arbitrary $?x$), together with a local abbreviation $c \equiv
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   201
c\dtt a\; x$ in the target context (for fixed $x$).
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   202
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   203
Theorems are exported by discharging the assumptions and generalizing
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   204
the parameters of the context.  For example, $a: B[x]$ becomes $c\dtt
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   205
a: A[?x] \Imp B[?x]$ (for arbitrary $?x$).
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   206
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   207
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   208
\subsection{Locales}\label{sec:locale}
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
   209
13040
wenzelm
parents: 13039
diff changeset
   210
Locales are named local contexts, consisting of a list of declaration elements
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   211
that are modeled after the Isar proof context commands (cf.\
13040
wenzelm
parents: 13039
diff changeset
   212
\S\ref{sec:proof-context}).
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   213
13048
wenzelm
parents: 13042
diff changeset
   214
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   215
\subsubsection{Locale specifications}
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   216
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   217
\indexisarcmd{locale}\indexisarcmd{print-locale}\indexisarcmd{print-locales}
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   218
\begin{matharray}{rcl}
19070
99001616e0e2 derived specifications: definition, abbreviation, axiomatization;
wenzelm
parents: 18903
diff changeset
   219
  \isarcmd{locale} & : & \isartrans{theory}{local{\dsh}theory} \\
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   220
  \isarcmd{print_locale}^* & : & \isarkeep{theory~|~proof} \\
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   221
  \isarcmd{print_locales}^* & : & \isarkeep{theory~|~proof} \\
20468
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   222
  intro_locales & : & \isarmeth \\
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   223
  unfold_locales & : & \isarmeth \\
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   224
\end{matharray}
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   225
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   226
\indexouternonterm{contextexpr}\indexouternonterm{contextelem}
18903
45c732782339 'obtain': optional case name;
wenzelm
parents: 18854
diff changeset
   227
\indexisarelem{fixes}\indexisarelem{constrains}\indexisarelem{assumes}
45c732782339 'obtain': optional case name;
wenzelm
parents: 18854
diff changeset
   228
\indexisarelem{defines}\indexisarelem{notes}\indexisarelem{includes}
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   229
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   230
\begin{rail}
21303
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   231
  'locale' ('(open)')? name ('=' localeexpr)? 'begin'?
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   232
  ;
18903
45c732782339 'obtain': optional case name;
wenzelm
parents: 18854
diff changeset
   233
  'print\_locale' '!'? localeexpr
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   234
  ;
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   235
  localeexpr: ((contextexpr '+' (contextelem+)) | contextexpr | (contextelem+))
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   236
  ;
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   237
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   238
  contextexpr: nameref | '(' contextexpr ')' |
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 16010
diff changeset
   239
  (contextexpr (name mixfix? +)) | (contextexpr + '+')
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   240
  ;
16168
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
   241
  contextelem: fixes | constrains | assumes | defines | notes | includes
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   242
  ;
18854
99124f3beccf 'fixes': support plain vars;
wenzelm
parents: 18530
diff changeset
   243
  fixes: 'fixes' ((name ('::' type)? structmixfix? | vars) + 'and')
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   244
  ;
16168
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
   245
  constrains: 'constrains' (name '::' type + 'and')
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
   246
  ;
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   247
  assumes: 'assumes' (thmdecl? props + 'and')
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   248
  ;
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   249
  defines: 'defines' (thmdecl? prop proppat? + 'and')
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   250
  ;
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   251
  notes: 'notes' (thmdef? thmrefs + 'and')
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   252
  ;
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   253
  includes: 'includes' contextexpr
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   254
  ;
12967
wenzelm
parents: 12879
diff changeset
   255
\end{rail}
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
   256
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   257
\begin{descr}
13411
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   258
  
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   259
\item [$\LOCALE~loc~=~import~+~body$] defines a new locale $loc$ as a context
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   260
  consisting of a certain view of existing locales ($import$) plus some
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   261
  additional elements ($body$).  Both $import$ and $body$ are optional; the
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   262
  degenerate form $\LOCALE~loc$ defines an empty locale, which may still be
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   263
  useful to collect declarations of facts later on.  Type-inference on locale
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   264
  expressions automatically takes care of the most general typing that the
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   265
  combined context elements may acquire.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   266
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   267
  The $import$ consists of a structured context expression, consisting of
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   268
  references to existing locales, renamed contexts, or merged contexts.
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 16010
diff changeset
   269
  Renaming uses positional notation: $c~\vec x$ means that (a prefix of) the
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   270
  fixed parameters of context $c$ are named according to $\vec x$; a
16102
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 16010
diff changeset
   271
  ``\texttt{_}'' (underscore) \indexisarthm{_@\texttt{_}} means to skip that
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 16010
diff changeset
   272
  position.  Renaming by default deletes existing syntax.  Optionally,
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 16010
diff changeset
   273
  new syntax may by specified with a mixfix annotation.  Note that the
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 16010
diff changeset
   274
  special syntax declared with ``$(structure)$'' (see below) is
c5f6726d9bb1 Locale expressions: rename with optional mixfix syntax.
ballarin
parents: 16010
diff changeset
   275
  neither deleted nor can it be changed.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   276
  Merging proceeds from left-to-right, suppressing any duplicates stemming
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   277
  from different paths through the import hierarchy.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   278
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   279
  The $body$ consists of basic context elements, further context expressions
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   280
  may be included as well.
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   281
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   282
  \begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   283
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   284
  \item [$\FIXES{~x::\tau~(mx)}$] declares a local parameter of type $\tau$
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   285
    and mixfix annotation $mx$ (both are optional).  The special syntax
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   286
    declaration ``$(structure)$'' means that $x$ may be referenced
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   287
    implicitly in this context.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   288
16168
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
   289
  \item [$\CONSTRAINS{~x::\tau}$] introduces a type constraint $\tau$
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
   290
    on the local parameter $x$.
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
   291
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   292
  \item [$\ASSUMES{a}{\vec\phi}$] introduces local premises, similar to
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   293
    $\ASSUMENAME$ within a proof (cf.\ \S\ref{sec:proof-context}).
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   294
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   295
  \item [$\DEFINES{a}{x \equiv t}$] defines a previously declared parameter.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   296
    This is close to $\DEFNAME$ within a proof (cf.\
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   297
    \S\ref{sec:proof-context}), but $\DEFINESNAME$ takes an equational
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   298
    proposition instead of variable-term pair.  The left-hand side of the
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   299
    equation may have additional arguments, e.g.\ ``$\DEFINES{}{f~\vec x
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   300
      \equiv t}$''.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   301
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   302
  \item [$\NOTES{a}{\vec b}$] reconsiders facts within a local context.  Most
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   303
    notably, this may include arbitrary declarations in any attribute
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   304
    specifications included here, e.g.\ a local $simp$ rule.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   305
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   306
  \item [$\INCLUDES{c}$] copies the specified context in a statically scoped
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   307
    manner.  Only available in the long goal format of \S\ref{sec:goals}.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   308
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   309
    In contrast, the initial $import$ specification of a locale expression
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   310
    maintains a dynamic relation to the locales being referenced (benefiting
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   311
    from any later fact declarations in the obvious manner).
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   312
  \end{descr}
13411
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   313
  
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   314
  Note that ``$\IS{p}$'' patterns given in the syntax of $\ASSUMESNAME$ and
13411
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   315
  $\DEFINESNAME$ above are illegal in locale definitions.  In the long goal
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   316
  format of \S\ref{sec:goals}, term bindings may be included as expected,
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   317
  though.
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   318
  
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   319
  \medskip By default, locale specifications are ``closed up'' by turning the
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   320
  given text into a predicate definition $loc_axioms$ and deriving the
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   321
  original assumptions as local lemmas (modulo local definitions).  The
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   322
  predicate statement covers only the newly specified assumptions, omitting
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   323
  the content of included locale expressions.  The full cumulative view is
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   324
  only provided on export, involving another predicate $loc$ that refers to
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   325
  the complete specification text.
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   326
  
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   327
  In any case, the predicate arguments are those locale parameters that
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   328
  actually occur in the respective piece of text.  Also note that these
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   329
  predicates operate at the meta-level in theory, but the locale packages
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   330
  attempts to internalize statements according to the object-logic setup
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   331
  (e.g.\ replacing $\Forall$ by $\forall$, and $\Imp$ by $\imp$ in HOL; see
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   332
  also \S\ref{sec:object-logic}).  Separate introduction rules
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   333
  $loc_axioms.intro$ and $loc.intro$ are declared as well.
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   334
  
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   335
  The $(open)$ option of a locale specification prevents both the current
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   336
  $loc_axioms$ and cumulative $loc$ predicate constructions.  Predicates are
181a293aa37a locales: predicate defs;
wenzelm
parents: 13048
diff changeset
   337
  also omitted for empty specification texts.
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   338
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   339
\item [$\isarkeyword{print_locale}~import~+~body$] prints the specified locale
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   340
  expression in a flattened form.  The notable special case
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   341
  $\isarkeyword{print_locale}~loc$ just prints the contents of the named
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   342
  locale, but keep in mind that type-inference will normalize type variables
17228
19b460b39dad print_locale omits facts by default
ballarin
parents: 17139
diff changeset
   343
  according to the usual alphabetical order.  The command omits
19b460b39dad print_locale omits facts by default
ballarin
parents: 17139
diff changeset
   344
  $\isarkeyword{notes}$ elements by default.  Use
19b460b39dad print_locale omits facts by default
ballarin
parents: 17139
diff changeset
   345
  $\isarkeyword{print_locale}!$ to get them included.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   346
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   347
\item [$\isarkeyword{print_locales}$] prints the names of all locales of the
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   348
  current theory.
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   349
20468
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   350
\item [$intro_locales$ and $unfold_locales$] repeatedly expand
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   351
  all introduction rules of locale predicates of the theory.  While
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   352
  $intro_locales$ only applies the $loc.intro$ introduction rules and
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   353
  therefore does not decend to assumptions, $unfold_locales$ is more
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   354
  aggressive and applies $loc_axioms.intro$ as well.  Both methods are
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   355
  aware of locale specifications entailed by the context, both from
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   356
  target and $\isarkeyword{includes}$ statements, and from
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   357
  interpretations (see below).  New goals that are entailed by the
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   358
  current context are discharged automatically.
0bda06d731ee Documented methods intro_locales and unfold_locales.
ballarin
parents: 20467
diff changeset
   359
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   360
\end{descr}
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   361
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   362
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   363
\subsubsection{Interpretation of locales}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   364
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   365
Locale expressions (more precisely, \emph{context expressions}) may be
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   366
instantiated, and the instantiated facts added to the current context.
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   367
This requires a proof of the instantiated specification and is called
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   368
\emph{locale interpretation}.  Interpretation is possible in theories
21303
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   369
and locales (command $\isarcmd{interpretation}$) and also in proof
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   370
contexts ($\isarcmd{interpret}$).
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   371
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   372
\indexisarcmd{interpretation}\indexisarcmd{interpret}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   373
\indexisarcmd{print-interps}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   374
\begin{matharray}{rcl}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   375
  \isarcmd{interpretation} & : & \isartrans{theory}{proof(prove)} \\
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   376
  \isarcmd{interpret} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   377
  \isarcmd{print_interps}^* & : &  \isarkeep{theory~|~proof} \\
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   378
\end{matharray}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   379
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   380
\indexouternonterm{interp}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   381
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   382
\railalias{printinterps}{print\_interps}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   383
\railterm{printinterps}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   384
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   385
\begin{rail}
23920
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   386
  'interpretation' (interp | name ('<' | subseteq) contextexpr)
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   387
  ;
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   388
  'interpret' interp
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   389
  ;
17139
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   390
  printinterps '!'? name
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   391
  ;
23920
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   392
  interp: thmdecl? \\ (contextexpr ('[' (inst+) ']')? |
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   393
    name ('[' (inst+) ']')? 'where' (prop + 'and'))
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   394
  ;
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   395
\end{rail}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   396
17043
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   397
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   398
\begin{descr}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   399
23920
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   400
\item [$\isarcmd{interpretation}~expr~insts~\isarkeyword{where}~eqns$]
17043
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   401
23920
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   402
  The first form of $\isarcmd{interpretation}$ interprets $expr$ in
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   403
  the theory.  The instantiation is given as a list of terms $insts$
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   404
  and is positional.  All parameters must receive an instantiation
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   405
  term --- with the exception of defined parameters.  These are, if
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   406
  omitted, derived from the defining equation and other
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   407
  instantiations.  Use ``\_'' to omit an instantiation term.  Free
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   408
  variables are automatically generalized.
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   409
17043
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   410
  The command generates proof obligations for the instantiated
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   411
  specifications (assumes and defines elements).  Once these are
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   412
  discharged by the user, instantiated facts are added to the theory in
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   413
  a post-processing phase.
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   414
23920
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   415
  Additional equations, which are unfolded in facts during
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   416
  post-processing, may be given after the keyword
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   417
  $\isarkeyword{where}$.  This is useful for interpreting concepts
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   418
  introduced through definition specification elements.  The equations
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   419
  must be proved.  Note that if equations are present, the context
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   420
  expression is restricted to a locale name.
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   421
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   422
  The command is aware of interpretations already active in the
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   423
  theory.  No proof obligations are generated for those, neither is
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   424
  post-processing applied to their facts.  This avoids duplication of
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   425
  interpreted facts, in particular.  Note that, in the case of a
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   426
  locale with import, parts of the interpretation may already be
23920
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   427
  active.  The command will only generate proof obligations and process
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   428
  facts for new parts.
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   429
17043
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   430
  The context expression may be preceded by a name and/or attributes.
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   431
  These take effect in the post-processing of facts.  The name is used
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   432
  to prefix fact names, for example to avoid accidental hiding of
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   433
  other facts.  Attributes are applied after attributes of the
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   434
  interpreted facts.
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   435
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   436
  Adding facts to locales has the
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   437
  effect of adding interpreted facts to the theory for all active
17043
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   438
  interpretations also.  That is, interpretations dynamically
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   439
  participate in any facts added to locales.
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   440
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   441
\item [$\isarcmd{interpretation}~name~\subseteq~expr$]
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   442
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   443
  This form of the command interprets $expr$ in the locale $name$.  It
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   444
  requires a proof that the specification of $name$ implies the
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   445
  specification of $expr$.  As in the localized version of the theorem
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   446
  command, the proof is in the context of $name$.  After the proof
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   447
  obligation has been dischared, the facts of $expr$
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   448
  become part of locale $name$ as \emph{derived} context elements and
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   449
  are available when the context $name$ is subsequently entered.
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   450
  Note that, like import, this is dynamic: facts added to a locale
17139
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   451
  part of $expr$ after interpretation become also available in
17043
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   452
  $name$.  Like facts
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   453
  of renamed context elements, facts obtained by interpretation may be
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   454
  accessed by prefixing with the parameter renaming (where the parameters
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   455
  are separated by `\_').
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   456
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   457
  Unlike interpretation in theories, instantiation is confined to the
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   458
  renaming of parameters, which may be specified as part of the context
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   459
  expression $expr$.  Using defined parameters in $name$ one may
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   460
  achieve an effect similar to instantiation, though.
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   461
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   462
  Only specification fragments of $expr$ that are not already part of
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   463
  $name$ (be it imported, derived or a derived fragment of the import)
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   464
  are considered by interpretation.  This enables circular
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   465
  interpretations.
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   466
17139
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   467
  If interpretations of $name$ exist in the current theory, the
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   468
  command adds interpretations for $expr$ as well, with the same
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   469
  prefix and attributes, although only for fragments of $expr$ that
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   470
  are not interpreted in the theory already.
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   471
23920
4288dc7dc248 interpretation: unfolding of equations;
ballarin
parents: 23654
diff changeset
   472
\item [$\isarcmd{interpret}~expr~insts~\isarkeyword{where}~eqns$]
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   473
  interprets $expr$ in the proof context and is otherwise similar to
17043
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   474
  interpretation in theories.  Free variables in instantiations are not
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   475
  generalized, however.
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   476
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   477
\item [$\isarcmd{print_interps}~loc$]
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   478
  prints the interpretations of a particular locale $loc$ that are
17139
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   479
  active in the current context, either theory or proof context.  The
19145
ballarin
parents: 19070
diff changeset
   480
  exclamation point argument triggers printing of
17139
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   481
  \emph{witness} theorems justifying interpretations.  These are
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   482
  normally omitted from the output.
165c97f9bb63 Printing of interpretations: option to show witness theorems;
ballarin
parents: 17043
diff changeset
   483
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   484
  
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   485
\end{descr}
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   486
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   487
\begin{warn}
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   488
  Since attributes are applied to interpreted theorems, interpretation
21303
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   489
  may modify the context of common proof tools, e.g.\ the Simplifier
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   490
  or Classical Reasoner.  Since the behavior of such automated
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   491
  reasoning tools is \emph{not} stable under interpretation morphisms,
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   492
  manual declarations might have to be issued.
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   493
\end{warn}
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15763
diff changeset
   494
16168
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
   495
\begin{warn}
17043
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   496
  An interpretation in a theory may subsume previous interpretations.
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   497
  This happens if the same specification fragment is interpreted twice
d3e52c3bfb07 New command: interpretation in locales.
ballarin
parents: 16168
diff changeset
   498
  and the instantiation of the second interpretation is more general
21303
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   499
  than the interpretation of the first.  A warning is issued, since it
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   500
  is likely that these could have been generalized in the first place.
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   501
  The locale package does not attempt to remove subsumed
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   502
  interpretations.
16168
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
   503
\end{warn}
adb83939177f Locales: new element constrains, parameter renaming with syntax,
ballarin
parents: 16102
diff changeset
   504
15763
b901a127ac73 Interpretation supports statically scoped attributes; documentation.
ballarin
parents: 14605
diff changeset
   505
21303
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   506
\subsection{Type classes}\label{sec:class}
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   507
21303
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   508
A type class is a special case of a locale, with some additional
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   509
infrastructure (notably a link to type-inference).  Type classes
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   510
consist of a locale with \emph{exactly one} type variable and an
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   511
corresponding axclass.  \cite{isabelle-classes} gives a substantial
21076
22ae82f77c5e small refinements
haftmann
parents: 20503
diff changeset
   512
introduction on type classes.
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   513
20467
210b326a03c9 some corrections in class section
haftmann
parents: 20379
diff changeset
   514
\indexisarcmd{instance}\indexisarcmd{class}\indexisarcmd{print-classes}
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   515
\begin{matharray}{rcl}
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   516
  \isarcmd{class} & : & \isartrans{theory}{local{\dsh}theory} \\
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   517
  \isarcmd{instance} & : & \isartrans{theory}{proof(prove)} \\
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   518
  \isarcmd{print_classes}^* & : & \isarkeep{theory~|~proof} \\
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   519
\end{matharray}
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   520
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   521
\begin{rail}
21303
fa16e4bf8717 updated local theory targets;
wenzelm
parents: 21209
diff changeset
   522
  'class' name '=' classexpr 'begin'?
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   523
  ;
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   524
  'instance' (instarity | instsubsort)
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   525
  ;
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   526
  'print\_classes'
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   527
  ;
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   528
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   529
  classexpr: ((superclassexpr '+' (contextelem+)) | superclassexpr | (contextelem+))
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   530
  ;
22294
4d342f77fd74 adjusted to changes in class package
haftmann
parents: 21716
diff changeset
   531
  instarity: (nameref '::' arity + 'and') (axmdecl prop +)?
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   532
  ;
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   533
  instsubsort: nameref ('<' | subseteq) sort
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   534
  ;
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   535
  superclassexpr: nameref | (nameref '+' superclassexpr)
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   536
  ;
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   537
\end{rail}
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   538
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   539
\begin{descr}
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   540
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   541
\item [$\CLASS~c = superclasses~+~body$] defines a new class $c$,
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   542
  inheriting from $superclasses$. Simultaneously, a locale
20467
210b326a03c9 some corrections in class section
haftmann
parents: 20379
diff changeset
   543
  named $c$ is introduced, inheriting from the locales
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   544
  corresponding to $superclasses$; also, an axclass
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   545
  named $c$, inheriting from the axclasses corresponding to
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   546
  $superclasses$. $\FIXESNAME$ in $body$ are lifted
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   547
  to the theory toplevel, constraining
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   548
  the free type variable to sort $c$ and stripping local syntax.
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   549
  $\ASSUMESNAME$ in $body$ are also lifted, 
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   550
  constraining
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   551
  the free type variable to sort $c$.
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   552
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   553
\item [$\INSTANCE~a: \vec{arity}~\vec{defs}$]
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   554
  sets up a goal stating type arities.  The proof would usually
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   555
  proceed by $intro_classes$, and then establish the characteristic theorems
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   556
  of the type classes involved.
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   557
  The $defs$, if given, must correspond to the class parameters
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   558
  involved in the $arities$ and are introduces in the theory
22294
4d342f77fd74 adjusted to changes in class package
haftmann
parents: 21716
diff changeset
   559
  before proof.
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   560
  After finishing the proof, the theory will be
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   561
  augmented by a type signature declaration corresponding to the
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   562
  resulting theorems.
22294
4d342f77fd74 adjusted to changes in class package
haftmann
parents: 21716
diff changeset
   563
  This $\isarcmd{instance}$ command is actually an extension
4d342f77fd74 adjusted to changes in class package
haftmann
parents: 21716
diff changeset
   564
  of primitive axclass $\isarcmd{instance}$ (see \ref{sec:axclass}).
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   565
  
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   566
\item [$\INSTANCE~c \subseteq \vec{c}$] sets up a
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   567
  goal stating 
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   568
  the interpretation of the locale corresponding to $c$
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   569
  in the merge of all locales corresponding to $\vec{c}$.
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   570
  After finishing the proof, it is automatically lifted to
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   571
  prove the additional class relation $c \subseteq \vec{c}$.
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   572
22294
4d342f77fd74 adjusted to changes in class package
haftmann
parents: 21716
diff changeset
   573
\item [$\isarkeyword{print_classes}$] prints all classes
20467
210b326a03c9 some corrections in class section
haftmann
parents: 20379
diff changeset
   574
  in the current theory.
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   575
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   576
\end{descr}
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   577
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
   578
20492
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   579
\subsection{Axiomatic type classes}\label{sec:axclass}
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   580
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   581
\indexisarcmd{axclass}\indexisarmeth{intro-classes}
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   582
\begin{matharray}{rcl}
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   583
  \isarcmd{axclass} & : & \isartrans{theory}{theory} \\
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   584
  \isarcmd{instance} & : & \isartrans{theory}{proof(prove)} \\
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   585
  intro_classes & : & \isarmeth \\
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   586
\end{matharray}
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   587
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   588
Axiomatic type classes are provided by Isabelle/Pure as a \emph{definitional}
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   589
interface to type classes (cf.~\S\ref{sec:classes}).  Thus any object logic
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   590
may make use of this light-weight mechanism of abstract theories
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   591
\cite{Wenzel:1997:TPHOL}.  There is also a tutorial on using axiomatic type
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   592
classes in Isabelle \cite{isabelle-axclass} that is part of the standard
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   593
Isabelle documentation.
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   594
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   595
\begin{rail}
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   596
  'axclass' classdecl (axmdecl prop +)
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   597
  ;
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   598
  'instance' (nameref ('<' | subseteq) nameref | nameref '::' arity)
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   599
  ;
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   600
\end{rail}
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   601
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   602
\begin{descr}
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   603
  
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   604
\item [$\AXCLASS~c \subseteq \vec c~~axms$] defines an axiomatic type class as
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   605
  the intersection of existing classes, with additional axioms holding.  Class
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   606
  axioms may not contain more than one type variable.  The class axioms (with
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   607
  implicit sort constraints added) are bound to the given names.  Furthermore
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   608
  a class introduction rule is generated (being bound as
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   609
  $c_class{\dtt}intro$); this rule is employed by method $intro_classes$ to
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   610
  support instantiation proofs of this class.
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   611
  
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   612
  The ``axioms'' are stored as theorems according to the given name
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   613
  specifications, adding the class name $c$ as name space prefix; the same
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   614
  facts are also stored collectively as $c_class{\dtt}axioms$.
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   615
  
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   616
\item [$\INSTANCE~c@1 \subseteq c@2$ and $\INSTANCE~t :: (\vec s)s$] setup a
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   617
  goal stating a class relation or type arity.  The proof would usually
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   618
  proceed by $intro_classes$, and then establish the characteristic theorems
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   619
  of the type classes involved.  After finishing the proof, the theory will be
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   620
  augmented by a type signature declaration corresponding to the resulting
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   621
  theorem.
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   622
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   623
\item [$intro_classes$] repeatedly expands all class introduction rules of
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   624
  this theory.  Note that this method usually needs not be named explicitly,
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   625
  as it is already included in the default proof step (of $\PROOFNAME$ etc.).
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   626
  In particular, instantiation of trivial (syntactic) classes may be performed
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   627
  by a single ``$\DDOT$'' proof step.
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   628
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   629
\end{descr}
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   630
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   631
24085
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   632
\subsection{Configuration options}
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   633
24110
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   634
Isabelle/Pure maintains a record of named configuration options within the
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   635
theory or proof context, with values of type $bool$, $int$, or $string$.
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   636
Tools may declare options in ML, and then refer to these values (relative to
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   637
the context).  Thus global reference variables are easily avoided.  The user
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   638
may change the value of a configuration option by means of an associated
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   639
attribute of the same name.  This form of context declaration works
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   640
particularly well with commands such as $\isarkeyword{declare}$ or
24085
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   641
$\isarkeyword{using}$.
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   642
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   643
For historical reasons, some tools cannot take the full proof context
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   644
into account and merely refer to the background theory.  This is
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   645
accommodated by configuration options being declared as ``global'',
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   646
which may not be changed within a local context.
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   647
24110
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   648
\indexisarcmd{print-configs}
24085
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   649
\begin{matharray}{rcll}
24110
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   650
  \isarcmd{print_configs} & : & \isarkeep{theory~|~proof} \\
24085
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   651
\end{matharray}
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   652
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   653
\begin{rail}
24110
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   654
  name ('=' ('true' | 'false' | int | name))?
24085
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   655
\end{rail}
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   656
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   657
\begin{descr}
24110
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   658
  
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   659
\item [$\isarkeyword{print_configs}$] prints the available configuration
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   660
  options, with names, types, and current values.
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   661
  
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   662
\item [$name = value$] as an attribute expression modifies the named option,
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   663
  with the syntax of the value depending on the option's type.  For $bool$ the
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   664
  default value is $true$.  Any attempt to change a global option in a local
4ab3084e311c tuned config options: eliminated separate attribute "option";
wenzelm
parents: 24085
diff changeset
   665
  context is ignored.
24085
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   666
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   667
\end{descr}
cbad32e7ab40 added configuration options;
wenzelm
parents: 24026
diff changeset
   668
20492
c9bfc874488c changed order of type classes and axclasses
haftmann
parents: 20468
diff changeset
   669
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   670
\section{Derived proof schemes}
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   671
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   672
\subsection{Generalized elimination}\label{sec:obtain}
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   673
17864
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   674
\indexisarcmd{obtain}\indexisarcmd{guess}
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   675
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   676
  \isarcmd{obtain} & : & \isartrans{proof(state)}{proof(prove)} \\
17864
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   677
  \isarcmd{guess}^* & : & \isartrans{proof(state)}{proof(prove)} \\
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   678
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   679
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   680
Generalized elimination means that additional elements with certain properties
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   681
may be introduced in the current context, by virtue of a locally proven
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   682
``soundness statement''.  Technically speaking, the $\OBTAINNAME$ language
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   683
element is like a declaration of $\FIXNAME$ and $\ASSUMENAME$ (see also see
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   684
\S\ref{sec:proof-context}), together with a soundness proof of its additional
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   685
claim.  According to the nature of existential reasoning, assumptions get
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   686
eliminated from any result exported from the context later, provided that the
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   687
corresponding parameters do \emph{not} occur in the conclusion.
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   688
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   689
\begin{rail}
18903
45c732782339 'obtain': optional case name;
wenzelm
parents: 18854
diff changeset
   690
  'obtain' parname? (vars + 'and') 'where' (props + 'and')
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   691
  ;
17864
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   692
  'guess' (vars + 'and')
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   693
  ;
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   694
\end{rail}
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
   695
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   696
$\OBTAINNAME$ is defined as a derived Isar command as follows, where $\vec b$
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   697
shall refer to (optional) facts indicated for forward chaining.
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   698
\begin{matharray}{l}
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   699
  \langle facts~\vec b\rangle \\
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   700
  \OBTAIN{\vec x}{a}{\vec \phi}~~\langle proof\rangle \equiv {} \\[1ex]
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   701
  \quad \HAVE{}{\All{thesis} (\All{\vec x} \vec\phi \Imp thesis) \Imp thesis} \\
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   702
  \quad \PROOF{succeed} \\
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   703
  \qquad \FIX{thesis} \\
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   704
  \qquad \ASSUME{that~[intro?]}{\All{\vec x} \vec\phi \Imp thesis} \\
13042
wenzelm
parents: 13041
diff changeset
   705
  \qquad \THUS{}{thesis} \\
wenzelm
parents: 13041
diff changeset
   706
  \quad\qquad \APPLY{-} \\
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   707
  \quad\qquad \USING{\vec b}~~\langle proof\rangle \\
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   708
  \quad \QED{} \\
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   709
  \quad \FIX{\vec x}~\ASSUMENAME^\ast~a\colon~\vec\phi \\
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   710
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   711
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   712
Typically, the soundness proof is relatively straight-forward, often just by
13048
wenzelm
parents: 13042
diff changeset
   713
canonical automated tools such as ``$\BY{simp}$'' or ``$\BY{blast}$''.
wenzelm
parents: 13042
diff changeset
   714
Accordingly, the ``$that$'' reduction above is declared as simplification and
wenzelm
parents: 13042
diff changeset
   715
introduction rule.
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   716
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   717
In a sense, $\OBTAINNAME$ represents at the level of Isar proofs what would be
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   718
meta-logical existential quantifiers and conjunctions.  This concept has a
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   719
broad range of useful applications, ranging from plain elimination (or
17864
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   720
introduction) of object-level existential and conjunctions, to elimination
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   721
over results of symbolic evaluation of recursive definitions, for example.
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   722
Also note that $\OBTAINNAME$ without parameters acts much like $\HAVENAME$,
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   723
where the result is treated as a genuine assumption.
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   724
18903
45c732782339 'obtain': optional case name;
wenzelm
parents: 18854
diff changeset
   725
An alternative name to be used instead of ``$that$'' above may be
45c732782339 'obtain': optional case name;
wenzelm
parents: 18854
diff changeset
   726
given in parentheses.
45c732782339 'obtain': optional case name;
wenzelm
parents: 18854
diff changeset
   727
17864
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   728
\medskip
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   729
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   730
The improper variant $\isarkeyword{guess}$ is similar to $\OBTAINNAME$, but
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   731
derives the obtained statement from the course of reasoning!  The proof starts
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   732
with a fixed goal $thesis$.  The subsequent proof may refine this to anything
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   733
of the form like $\All{\vec x} \vec\phi \Imp thesis$, but must not introduce
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   734
new subgoals.  The final goal state is then used as reduction rule for the
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   735
obtain scheme described above.  Obtained parameters $\vec x$ are marked as
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   736
internal by default, which prevents the proof context from being polluted by
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   737
ad-hoc variables.  The variable names and type constraints given as arguments
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   738
for $\isarkeyword{guess}$ specify a prefix of obtained parameters explicitly
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   739
in the text.
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   740
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   741
It is important to note that the facts introduced by $\OBTAINNAME$ and
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   742
$\isarkeyword{guess}$ may not be polymorphic: any type-variables occurring
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   743
here are fixed in the present context!
b039ea8bb965 added guess;
wenzelm
parents: 17274
diff changeset
   744
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   745
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   746
\subsection{Calculational reasoning}\label{sec:calculation}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   747
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   748
\indexisarcmd{also}\indexisarcmd{finally}
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   749
\indexisarcmd{moreover}\indexisarcmd{ultimately}
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   750
\indexisarcmd{print-trans-rules}
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   751
\indexisaratt{trans}\indexisaratt{sym}\indexisaratt{symmetric}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   752
\begin{matharray}{rcl}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   753
  \isarcmd{also} & : & \isartrans{proof(state)}{proof(state)} \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   754
  \isarcmd{finally} & : & \isartrans{proof(state)}{proof(chain)} \\
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   755
  \isarcmd{moreover} & : & \isartrans{proof(state)}{proof(state)} \\
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   756
  \isarcmd{ultimately} & : & \isartrans{proof(state)}{proof(chain)} \\
10154
wenzelm
parents: 10031
diff changeset
   757
  \isarcmd{print_trans_rules}^* & : & \isarkeep{theory~|~proof} \\
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   758
  trans & : & \isaratt \\
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   759
  sym & : & \isaratt \\
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   760
  symmetric & : & \isaratt \\
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   761
\end{matharray}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   762
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   763
Calculational proof is forward reasoning with implicit application of
11332
11ab8c8ce694 extended doc for iff attribute
oheimb
parents: 11128
diff changeset
   764
transitivity rules (such those of $=$, $\leq$, $<$).  Isabelle/Isar maintains
7391
b7ca64c8fa64 'iff' attribute;
wenzelm
parents: 7356
diff changeset
   765
an auxiliary register $calculation$\indexisarthm{calculation} for accumulating
7897
7f18f5ffbb92 *** empty log message ***
wenzelm
parents: 7526
diff changeset
   766
results obtained by transitivity composed with the current result.  Command
7f18f5ffbb92 *** empty log message ***
wenzelm
parents: 7526
diff changeset
   767
$\ALSO$ updates $calculation$ involving $this$, while $\FINALLY$ exhibits the
7f18f5ffbb92 *** empty log message ***
wenzelm
parents: 7526
diff changeset
   768
final $calculation$ by forward chaining towards the next goal statement.  Both
7f18f5ffbb92 *** empty log message ***
wenzelm
parents: 7526
diff changeset
   769
commands require valid current facts, i.e.\ may occur only after commands that
7f18f5ffbb92 *** empty log message ***
wenzelm
parents: 7526
diff changeset
   770
produce theorems such as $\ASSUMENAME$, $\NOTENAME$, or some finished proof of
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   771
$\HAVENAME$, $\SHOWNAME$ etc.  The $\MOREOVER$ and $\ULTIMATELY$ commands are
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   772
similar to $\ALSO$ and $\FINALLY$, but only collect further results in
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   773
$calculation$ without applying any rules yet.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   774
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   775
Also note that the implicit term abbreviation ``$\dots$'' has its canonical
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   776
application with calculational proofs.  It refers to the argument of the
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   777
preceding statement. (The argument of a curried infix expression happens to be
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   778
its right-hand side.)
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   779
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   780
Isabelle/Isar calculations are implicitly subject to block structure in the
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   781
sense that new threads of calculational reasoning are commenced for any new
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   782
block (as opened by a local goal, for example).  This means that, apart from
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   783
being able to nest calculations, there is no separate \emph{begin-calculation}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   784
command required.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   785
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   786
\medskip
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   787
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   788
The Isar calculation proof commands may be defined as follows:\footnote{We
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   789
  suppress internal bookkeeping such as proper handling of block-structure.}
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   790
\begin{matharray}{rcl}
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   791
  \ALSO@0 & \equiv & \NOTE{calculation}{this} \\
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   792
  \ALSO@{n+1} & \equiv & \NOTE{calculation}{trans~[OF~calculation~this]} \\[0.5ex]
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   793
  \FINALLY & \equiv & \ALSO~\FROM{calculation} \\
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   794
  \MOREOVER & \equiv & \NOTE{calculation}{calculation~this} \\
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   795
  \ULTIMATELY & \equiv & \MOREOVER~\FROM{calculation} \\
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   796
\end{matharray}
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   797
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   798
\begin{rail}
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   799
  ('also' | 'finally') ('(' thmrefs ')')?
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   800
  ;
8507
d22fcea34cb7 untag: only name arg;
wenzelm
parents: 8483
diff changeset
   801
  'trans' (() | 'add' | 'del')
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   802
  ;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   803
\end{rail}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   804
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   805
\begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   806
8547
wenzelm
parents: 8517
diff changeset
   807
\item [$\ALSO~(\vec a)$] maintains the auxiliary $calculation$ register as
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   808
  follows.  The first occurrence of $\ALSO$ in some calculational thread
7905
wenzelm
parents: 7897
diff changeset
   809
  initializes $calculation$ by $this$. Any subsequent $\ALSO$ on the same
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   810
  level of block-structure updates $calculation$ by some transitivity rule
7458
bb282845ca77 updated;
wenzelm
parents: 7396
diff changeset
   811
  applied to $calculation$ and $this$ (in that order).  Transitivity rules are
11095
2ffaf1e1e101 updated;
wenzelm
parents: 10858
diff changeset
   812
  picked from the current context, unless alternative rules are given as
2ffaf1e1e101 updated;
wenzelm
parents: 10858
diff changeset
   813
  explicit arguments.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   814
8547
wenzelm
parents: 8517
diff changeset
   815
\item [$\FINALLY~(\vec a)$] maintaining $calculation$ in the same way as
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   816
  $\ALSO$, and concludes the current calculational thread.  The final result
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   817
  is exhibited as fact for forward chaining towards the next goal. Basically,
7987
wenzelm
parents: 7981
diff changeset
   818
  $\FINALLY$ just abbreviates $\ALSO~\FROM{calculation}$.  Note that
wenzelm
parents: 7981
diff changeset
   819
  ``$\FINALLY~\SHOW{}{\Var{thesis}}~\DOT$'' and
wenzelm
parents: 7981
diff changeset
   820
  ``$\FINALLY~\HAVE{}{\phi}~\DOT$'' are typical idioms for concluding
wenzelm
parents: 7981
diff changeset
   821
  calculational proofs.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   822
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   823
\item [$\MOREOVER$ and $\ULTIMATELY$] are analogous to $\ALSO$ and $\FINALLY$,
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   824
  but collect results only, without applying rules.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   825
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   826
\item [$\isarkeyword{print_trans_rules}$] prints the list of transitivity
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   827
  rules (for calculational commands $\ALSO$ and $\FINALLY$) and symmetry rules
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   828
  (for the $symmetric$ operation and single step elimination patters) of the
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   829
  current context.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   830
8547
wenzelm
parents: 8517
diff changeset
   831
\item [$trans$] declares theorems as transitivity rules.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   832
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   833
\item [$sym$] declares symmetry rules.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   834
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   835
\item [$symmetric$] resolves a theorem with some rule declared as $sym$ in the
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   836
  current context.  For example, ``$\ASSUME{[symmetric]}{x = y}$'' produces a
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
   837
  swapped fact derived from that assumption.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   838
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   839
  In structured proof texts it is often more appropriate to use an explicit
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   840
  single-step elimination proof, such as ``$\ASSUME{}{x = y}~\HENCE{}{y =
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   841
    x}~\DDOT$''.  The very same rules known to $symmetric$ are declared as
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   842
  $elim?$ as well.
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   843
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   844
\end{descr}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   845
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   846
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   847
\section{Proof tools}
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   848
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
   849
\subsection{Miscellaneous methods and attributes}\label{sec:misc-meth-att}
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   850
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   851
\indexisarmeth{unfold}\indexisarmeth{fold}\indexisarmeth{insert}
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   852
\indexisarmeth{erule}\indexisarmeth{drule}\indexisarmeth{frule}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   853
\indexisarmeth{fail}\indexisarmeth{succeed}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   854
\begin{matharray}{rcl}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   855
  unfold & : & \isarmeth \\
10741
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   856
  fold & : & \isarmeth \\
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   857
  insert & : & \isarmeth \\[0.5ex]
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   858
  erule^* & : & \isarmeth \\
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   859
  drule^* & : & \isarmeth \\
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   860
  frule^* & : & \isarmeth \\
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   861
  succeed & : & \isarmeth \\
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   862
  fail & : & \isarmeth \\
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   863
\end{matharray}
7135
wenzelm
parents:
diff changeset
   864
wenzelm
parents:
diff changeset
   865
\begin{rail}
10741
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   866
  ('fold' | 'unfold' | 'insert') thmrefs
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   867
  ;
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   868
  ('erule' | 'drule' | 'frule') ('('nat')')? thmrefs
7135
wenzelm
parents:
diff changeset
   869
  ;
wenzelm
parents:
diff changeset
   870
\end{rail}
wenzelm
parents:
diff changeset
   871
7167
wenzelm
parents: 7141
diff changeset
   872
\begin{descr}
19379
c8cf1544b5a7 unfold(ed): not necessrily meta equations;
wenzelm
parents: 19363
diff changeset
   873
  
c8cf1544b5a7 unfold(ed): not necessrily meta equations;
wenzelm
parents: 19363
diff changeset
   874
\item [$unfold~\vec a$ and $fold~\vec a$] expand (or fold back again)
c8cf1544b5a7 unfold(ed): not necessrily meta equations;
wenzelm
parents: 19363
diff changeset
   875
  the given definitions throughout all goals; any chained facts
c8cf1544b5a7 unfold(ed): not necessrily meta equations;
wenzelm
parents: 19363
diff changeset
   876
  provided are inserted into the goal and subject to rewriting as
c8cf1544b5a7 unfold(ed): not necessrily meta equations;
wenzelm
parents: 19363
diff changeset
   877
  well.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   878
10741
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   879
\item [$insert~\vec a$] inserts theorems as facts into all goals of the proof
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   880
  state.  Note that current facts indicated for forward chaining are ignored.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   881
8547
wenzelm
parents: 8517
diff changeset
   882
\item [$erule~\vec a$, $drule~\vec a$, and $frule~\vec a$] are similar to the
wenzelm
parents: 8517
diff changeset
   883
  basic $rule$ method (see \S\ref{sec:pure-meth-att}), but apply rules by
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   884
  elim-resolution, destruct-resolution, and forward-resolution, respectively
10741
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   885
  \cite{isabelle-ref}.  The optional natural number argument (default $0$)
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   886
  specifies additional assumption steps to be performed here.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   887
10741
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   888
  Note that these methods are improper ones, mainly serving for
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   889
  experimentation and tactic script emulation.  Different modes of basic rule
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   890
  application are usually expressed in Isar at the proof language level,
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   891
  rather than via implicit proof state manipulations.  For example, a proper
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   892
  single-step elimination would be done using the plain $rule$ method, with
10741
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   893
  forward chaining of current facts.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   894
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   895
\item [$succeed$] yields a single (unchanged) result; it is the identity of
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   896
  the ``\texttt{,}'' method combinator (cf.\ \S\ref{sec:syn-meth}).
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   897
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   898
\item [$fail$] yields an empty result sequence; it is the identity of the
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   899
  ``\texttt{|}'' method combinator (cf.\ \S\ref{sec:syn-meth}).
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   900
7167
wenzelm
parents: 7141
diff changeset
   901
\end{descr}
7135
wenzelm
parents:
diff changeset
   902
10318
wenzelm
parents: 10223
diff changeset
   903
\indexisaratt{tagged}\indexisaratt{untagged}
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   904
\indexisaratt{THEN}\indexisaratt{COMP}
14175
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   905
\indexisaratt{unfolded}\indexisaratt{folded}
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   906
\indexisaratt{standard}\indexisarattof{Pure}{elim-format}
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
   907
\indexisaratt{no-vars}
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   908
\begin{matharray}{rcl}
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   909
  tagged & : & \isaratt \\
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   910
  untagged & : & \isaratt \\[0.5ex]
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   911
  THEN & : & \isaratt \\
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   912
  COMP & : & \isaratt \\[0.5ex]
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   913
  unfolded & : & \isaratt \\
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   914
  folded & : & \isaratt \\[0.5ex]
9941
fe05af7ec816 renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents: 9936
diff changeset
   915
  elim_format & : & \isaratt \\
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   916
  standard^* & : & \isaratt \\
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
   917
  no_vars^* & : & \isaratt \\
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   918
\end{matharray}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   919
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   920
\begin{rail}
23654
a2ad1c166ac8 attribute tagged: single argument;
wenzelm
parents: 22294
diff changeset
   921
  'tagged' nameref
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   922
  ;
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   923
  'untagged' name
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   924
  ;
10154
wenzelm
parents: 10031
diff changeset
   925
  ('THEN' | 'COMP') ('[' nat ']')? thmref
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   926
  ;
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   927
  ('unfolded' | 'folded') thmrefs
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   928
  ;
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   929
\end{rail}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   930
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   931
\begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   932
23654
a2ad1c166ac8 attribute tagged: single argument;
wenzelm
parents: 22294
diff changeset
   933
\item [$tagged~name~arg$ and $untagged~name$] add and remove $tags$ of some
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   934
  theorem.  Tags may be any list of strings that serve as comment for some
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   935
  tools (e.g.\ $\LEMMANAME$ causes the tag ``$lemma$'' to be added to the
23654
a2ad1c166ac8 attribute tagged: single argument;
wenzelm
parents: 22294
diff changeset
   936
  result).  The first string is considered the tag name, the second its
a2ad1c166ac8 attribute tagged: single argument;
wenzelm
parents: 22294
diff changeset
   937
  argument.  Note that $untagged$ removes any tags of the same name.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   938
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   939
\item [$THEN~a$ and $COMP~a$] compose rules by resolution.  $THEN$ resolves
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   940
  with the first premise of $a$ (an alternative position may be also
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   941
  specified); the $COMP$ version skips the automatic lifting process that is
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   942
  normally intended (cf.\ \texttt{RS} and \texttt{COMP} in
8547
wenzelm
parents: 8517
diff changeset
   943
  \cite[\S5]{isabelle-ref}).
19379
c8cf1544b5a7 unfold(ed): not necessrily meta equations;
wenzelm
parents: 19363
diff changeset
   944
  
c8cf1544b5a7 unfold(ed): not necessrily meta equations;
wenzelm
parents: 19363
diff changeset
   945
\item [$unfolded~\vec a$ and $folded~\vec a$] expand and fold back
c8cf1544b5a7 unfold(ed): not necessrily meta equations;
wenzelm
parents: 19363
diff changeset
   946
  again the given definitions throughout a rule.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   947
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   948
\item [$elim_format$] turns a destruction rule into elimination rule format,
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   949
  by resolving with the rule $\PROP A \Imp (\PROP A \Imp \PROP B) \Imp \PROP
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   950
  B$.
13048
wenzelm
parents: 13042
diff changeset
   951
  
wenzelm
parents: 13042
diff changeset
   952
  Note that the Classical Reasoner (\S\ref{sec:classical}) provides its own
wenzelm
parents: 13042
diff changeset
   953
  version of this operation.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   954
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   955
\item [$standard$] puts a theorem into the standard form of object-rules at
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   956
  the outermost theory level.  Note that this operation violates the local
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   957
  proof context (including active locales).
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
   958
9232
96722b04f2ae added no_vars att;
wenzelm
parents: 9005
diff changeset
   959
\item [$no_vars$] replaces schematic variables by free ones; this is mainly
96722b04f2ae added no_vars att;
wenzelm
parents: 9005
diff changeset
   960
  for tuning output of pretty printed theorems.
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   961
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   962
\end{descr}
7135
wenzelm
parents:
diff changeset
   963
wenzelm
parents:
diff changeset
   964
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
   965
\subsection{Further tactic emulations}\label{sec:tactics}
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   966
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   967
The following improper proof methods emulate traditional tactics.  These admit
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   968
direct access to the goal state, which is normally considered harmful!  In
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   969
particular, this may involve both numbered goal addressing (default 1), and
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   970
dynamic instantiation within the scope of some subgoal.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   971
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   972
\begin{warn}
14175
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   973
  Dynamic instantiations refer to universally quantified parameters of
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   974
  a subgoal (the dynamic context) rather than fixed variables and term
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   975
  abbreviations of a (static) Isar context.
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   976
\end{warn}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   977
14175
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   978
Tactic emulation methods, unlike their ML counterparts, admit
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   979
simultaneous instantiation from both dynamic and static contexts.  If
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   980
names occur in both contexts goal parameters hide locally fixed
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   981
variables.  Likewise, schematic variables refer to term abbreviations,
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   982
if present in the static context.  Otherwise the schematic variable is
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   983
interpreted as a schematic variable and left to be solved by unification
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   984
with certain parts of the subgoal.
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   985
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   986
Note that the tactic emulation proof methods in Isabelle/Isar are consistently
14175
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   987
named $foo_tac$.  Note also that variable names occurring on left hand sides
14212
cd05b503ca2d Improvements wrt rule_tac.
ballarin
parents: 14175
diff changeset
   988
of instantiations must be preceded by a question mark if they coincide with
cd05b503ca2d Improvements wrt rule_tac.
ballarin
parents: 14175
diff changeset
   989
a keyword or contain dots.
14175
dbd16ebaf907 Method rule_tac understands Isar contexts: documentation.
ballarin
parents: 13622
diff changeset
   990
This is consistent with the attribute $where$ (see \S\ref{sec:pure-meth-att}).
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   991
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   992
\indexisarmeth{rule-tac}\indexisarmeth{erule-tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   993
\indexisarmeth{drule-tac}\indexisarmeth{frule-tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   994
\indexisarmeth{cut-tac}\indexisarmeth{thin-tac}
9642
d8d1f70024bd fixed indexing;
wenzelm
parents: 9614
diff changeset
   995
\indexisarmeth{subgoal-tac}\indexisarmeth{rename-tac}
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   996
\indexisarmeth{rotate-tac}\indexisarmeth{tactic}
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   997
\begin{matharray}{rcl}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   998
  rule_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   999
  erule_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1000
  drule_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1001
  frule_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1002
  cut_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1003
  thin_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1004
  subgoal_tac^* & : & \isarmeth \\
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1005
  rename_tac^* & : & \isarmeth \\
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1006
  rotate_tac^* & : & \isarmeth \\
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1007
  tactic^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1008
\end{matharray}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1009
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1010
\railalias{ruletac}{rule\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1011
\railterm{ruletac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1012
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1013
\railalias{eruletac}{erule\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1014
\railterm{eruletac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1015
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1016
\railalias{druletac}{drule\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1017
\railterm{druletac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1018
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1019
\railalias{fruletac}{frule\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1020
\railterm{fruletac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1021
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1022
\railalias{cuttac}{cut\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1023
\railterm{cuttac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1024
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1025
\railalias{thintac}{thin\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1026
\railterm{thintac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1027
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1028
\railalias{subgoaltac}{subgoal\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1029
\railterm{subgoaltac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1030
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1031
\railalias{renametac}{rename\_tac}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1032
\railterm{renametac}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1033
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1034
\railalias{rotatetac}{rotate\_tac}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1035
\railterm{rotatetac}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1036
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1037
\begin{rail}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1038
  ( ruletac | eruletac | druletac | fruletac | cuttac | thintac ) goalspec?
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1039
  ( insts thmref | thmrefs )
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1040
  ;
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1041
  subgoaltac goalspec? (prop +)
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1042
  ;
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1043
  renametac goalspec? (name +)
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1044
  ;
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1045
  rotatetac goalspec? int?
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1046
  ;
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1047
  'tactic' text
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1048
  ;
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1049
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1050
  insts: ((name '=' term) + 'and') 'in'
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1051
  ;
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1052
\end{rail}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1053
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1054
\begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1055
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1056
\item [$rule_tac$ etc.] do resolution of rules with explicit instantiation.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1057
  This works the same way as the ML tactics \texttt{res_inst_tac} etc. (see
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1058
  \cite[\S3]{isabelle-ref}).
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1059
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1060
  Multiple rules may be only given if there is no instantiation; then
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1061
  $rule_tac$ is the same as \texttt{resolve_tac} in ML (see
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1062
  \cite[\S3]{isabelle-ref}).
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1063
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1064
\item [$cut_tac$] inserts facts into the proof state as assumption of a
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1065
  subgoal, see also \texttt{cut_facts_tac} in \cite[\S3]{isabelle-ref}.  Note
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1066
  that the scope of schematic variables is spread over the main goal
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1067
  statement.  Instantiations may be given as well, see also ML tactic
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1068
  \texttt{cut_inst_tac} in \cite[\S3]{isabelle-ref}.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1069
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1070
\item [$thin_tac~\phi$] deletes the specified assumption from a subgoal; note
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1071
  that $\phi$ may contain schematic variables.  See also \texttt{thin_tac} in
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1072
  \cite[\S3]{isabelle-ref}.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1073
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1074
\item [$subgoal_tac~\phi$] adds $\phi$ as an assumption to a subgoal.  See
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1075
  also \texttt{subgoal_tac} and \texttt{subgoals_tac} in
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1076
  \cite[\S3]{isabelle-ref}.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1077
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1078
\item [$rename_tac~\vec x$] renames parameters of a goal according to the list
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1079
  $\vec x$, which refers to the \emph{suffix} of variables.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1080
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1081
\item [$rotate_tac~n$] rotates the assumptions of a goal by $n$ positions:
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1082
  from right to left if $n$ is positive, and from left to right if $n$ is
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1083
  negative; the default value is $1$.  See also \texttt{rotate_tac} in
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1084
  \cite[\S3]{isabelle-ref}.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1085
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1086
\item [$tactic~text$] produces a proof method from any ML text of type
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1087
  \texttt{tactic}.  Apart from the usual ML environment and the current
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1088
  implicit theory context, the ML code may refer to the following locally
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1089
  bound values:
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1090
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1091
{\footnotesize\begin{verbatim}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1092
val ctxt  : Proof.context
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1093
val facts : thm list
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1094
val thm   : string -> thm
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1095
val thms  : string -> thm list
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1096
\end{verbatim}}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1097
  Here \texttt{ctxt} refers to the current proof context, \texttt{facts}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1098
  indicates any current facts for forward-chaining, and
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1099
  \texttt{thm}~/~\texttt{thms} retrieve named facts (including global
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1100
  theorems) from the context.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1101
\end{descr}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1102
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1103
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
  1104
\subsection{The Simplifier}\label{sec:simplifier}
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
  1105
13048
wenzelm
parents: 13042
diff changeset
  1106
\subsubsection{Simplification methods}
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1107
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
  1108
\indexisarmeth{simp}\indexisarmeth{simp-all}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1109
\begin{matharray}{rcl}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1110
  simp & : & \isarmeth \\
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
  1111
  simp_all & : & \isarmeth \\
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1112
\end{matharray}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1113
11128
48c63b87566e index mod syntax;
wenzelm
parents: 11100
diff changeset
  1114
\indexouternonterm{simpmod}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1115
\begin{rail}
20126
282165caaeaf simp method: depth_limit;
wenzelm
parents: 19786
diff changeset
  1116
  ('simp' | 'simp\_all') ('!' ?) opt? (simpmod *)
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1117
  ;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1118
20126
282165caaeaf simp method: depth_limit;
wenzelm
parents: 19786
diff changeset
  1119
  opt: '(' ('no\_asm' | 'no\_asm\_simp' | 'no\_asm\_use' | 'asm\_lr' | 'depth\_limit' ':' nat) ')'
8704
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
  1120
  ;
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1121
  simpmod: ('add' | 'del' | 'only' | 'cong' (() | 'add' | 'del') |
9847
32ce11c3f6b1 added 'iff' modifier;
wenzelm
parents: 9799
diff changeset
  1122
    'split' (() | 'add' | 'del')) ':' thmrefs
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1123
  ;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1124
\end{rail}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1125
7321
wenzelm
parents: 7319
diff changeset
  1126
\begin{descr}
13015
wenzelm
parents: 12976
diff changeset
  1127
8547
wenzelm
parents: 8517
diff changeset
  1128
\item [$simp$] invokes Isabelle's simplifier, after declaring additional rules
8594
d2e2a3df6871 rail token vs. terminal;
wenzelm
parents: 8547
diff changeset
  1129
  according to the arguments given.  Note that the \railtterm{only} modifier
8547
wenzelm
parents: 8517
diff changeset
  1130
  first removes all other rewrite rules, congruences, and looper tactics
8594
d2e2a3df6871 rail token vs. terminal;
wenzelm
parents: 8547
diff changeset
  1131
  (including splits), and then behaves like \railtterm{add}.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1132
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1133
  \medskip The \railtterm{cong} modifiers add or delete Simplifier congruence
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1134
  rules (see also \cite{isabelle-ref}), the default is to add.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1135
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1136
  \medskip The \railtterm{split} modifiers add or delete rules for the
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1137
  Splitter (see also \cite{isabelle-ref}), the default is to add.  This works
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1138
  only if the Simplifier method has been properly setup to include the
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1139
  Splitter (all major object logics such HOL, HOLCF, FOL, ZF do this already).
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1140
13015
wenzelm
parents: 12976
diff changeset
  1141
\item [$simp_all$] is similar to $simp$, but acts on all goals (backwards from
wenzelm
parents: 12976
diff changeset
  1142
  the last to the first one).
wenzelm
parents: 12976
diff changeset
  1143
7321
wenzelm
parents: 7319
diff changeset
  1144
\end{descr}
wenzelm
parents: 7319
diff changeset
  1145
13015
wenzelm
parents: 12976
diff changeset
  1146
By default the Simplifier methods take local assumptions fully into account,
wenzelm
parents: 12976
diff changeset
  1147
using equational assumptions in the subsequent normalization process, or
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1148
simplifying assumptions themselves (cf.\ \texttt{asm_full_simp_tac} in
13015
wenzelm
parents: 12976
diff changeset
  1149
\cite[\S10]{isabelle-ref}).  In structured proofs this is usually quite well
wenzelm
parents: 12976
diff changeset
  1150
behaved in practice: just the local premises of the actual goal are involved,
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1151
additional facts may be inserted via explicit forward-chaining (using $\THEN$,
13015
wenzelm
parents: 12976
diff changeset
  1152
$\FROMNAME$ etc.).  The full context of assumptions is only included if the
wenzelm
parents: 12976
diff changeset
  1153
``$!$'' (bang) argument is given, which should be used with some care, though.
7321
wenzelm
parents: 7319
diff changeset
  1154
13015
wenzelm
parents: 12976
diff changeset
  1155
Additional Simplifier options may be specified to tune the behavior further
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1156
(mostly for unstructured scripts with many accidental local facts):
20126
282165caaeaf simp method: depth_limit;
wenzelm
parents: 19786
diff changeset
  1157
``$(no_asm)$'' means assumptions are ignored completely (cf.\ 
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1158
\texttt{simp_tac}), ``$(no_asm_simp)$'' means assumptions are used in the
20126
282165caaeaf simp method: depth_limit;
wenzelm
parents: 19786
diff changeset
  1159
simplification of the conclusion but are not themselves simplified (cf.\ 
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1160
\texttt{asm_simp_tac}), and ``$(no_asm_use)$'' means assumptions are
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1161
simplified but are not used in the simplification of each other or the
20126
282165caaeaf simp method: depth_limit;
wenzelm
parents: 19786
diff changeset
  1162
conclusion (cf.\ \texttt{full_simp_tac}).  For compatibility reasons, there is
282165caaeaf simp method: depth_limit;
wenzelm
parents: 19786
diff changeset
  1163
also an option ``$(asm_lr)$'', which means that an assumption is only used for
282165caaeaf simp method: depth_limit;
wenzelm
parents: 19786
diff changeset
  1164
simplifying assumptions which are to the right of it (cf.\ 
282165caaeaf simp method: depth_limit;
wenzelm
parents: 19786
diff changeset
  1165
\texttt{asm_lr_simp_tac}).  Giving an option ``$(depth_limit: n)$'' limits the
282165caaeaf simp method: depth_limit;
wenzelm
parents: 19786
diff changeset
  1166
number of recursive invocations of the simplifier during conditional
282165caaeaf simp method: depth_limit;
wenzelm
parents: 19786
diff changeset
  1167
rewriting.
8704
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
  1168
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
  1169
\medskip
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
  1170
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
  1171
The Splitter package is usually configured to work as part of the Simplifier.
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1172
The effect of repeatedly applying \texttt{split_tac} can be simulated by
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1173
``$(simp~only\colon~split\colon~\vec a)$''.  There is also a separate $split$
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1174
method available for single-step case splitting.
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
  1175
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
  1176
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
  1177
\subsubsection{Declaring rules}
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
  1178
8667
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
  1179
\indexisarcmd{print-simpset}
8638
21cb46716f32 added 'cong' att;
wenzelm
parents: 8619
diff changeset
  1180
\indexisaratt{simp}\indexisaratt{split}\indexisaratt{cong}
7321
wenzelm
parents: 7319
diff changeset
  1181
\begin{matharray}{rcl}
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1182
  \isarcmd{print_simpset}^* & : & \isarkeep{theory~|~proof} \\
7321
wenzelm
parents: 7319
diff changeset
  1183
  simp & : & \isaratt \\
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1184
  cong & : & \isaratt \\
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
  1185
  split & : & \isaratt \\
7321
wenzelm
parents: 7319
diff changeset
  1186
\end{matharray}
wenzelm
parents: 7319
diff changeset
  1187
wenzelm
parents: 7319
diff changeset
  1188
\begin{rail}
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1189
  ('simp' | 'cong' | 'split') (() | 'add' | 'del')
7321
wenzelm
parents: 7319
diff changeset
  1190
  ;
wenzelm
parents: 7319
diff changeset
  1191
\end{rail}
wenzelm
parents: 7319
diff changeset
  1192
wenzelm
parents: 7319
diff changeset
  1193
\begin{descr}
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1194
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1195
\item [$\isarcmd{print_simpset}$] prints the collection of rules declared to
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1196
  the Simplifier, which is also known as ``simpset'' internally
8667
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
  1197
  \cite{isabelle-ref}.  This is a diagnostic command; $undo$ does not apply.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1198
8547
wenzelm
parents: 8517
diff changeset
  1199
\item [$simp$] declares simplification rules.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1200
8638
21cb46716f32 added 'cong' att;
wenzelm
parents: 8619
diff changeset
  1201
\item [$cong$] declares congruence rules.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1202
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1203
\item [$split$] declares case split rules.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1204
7321
wenzelm
parents: 7319
diff changeset
  1205
\end{descr}
7319
wenzelm
parents: 7315
diff changeset
  1206
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1207
24015
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1208
\subsubsection{Simplification procedures}
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1209
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1210
\indexisarcmd{simproc-setup}
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1211
\indexisaratt{simproc}
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1212
\begin{matharray}{rcl}
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1213
  \isarcmd{simproc_setup} & : & \isarkeep{local{\dsh}theory} \\
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1214
  simproc & : & \isaratt \\
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1215
\end{matharray}
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1216
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1217
\begin{rail}
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1218
  'simproc\_setup' name '(' (term + '|') ')' '=' text \\ ('identifier' (nameref+))?
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1219
  ;
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1220
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1221
  'simproc' (('add' ':')? | 'del' ':') (name+)
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1222
  ;
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1223
\end{rail}
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1224
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1225
\begin{descr}
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1226
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1227
\item [$\isarcmd{simproc_setup}$] defines a named simplification
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1228
  procedure that is invoked by the Simplifier whenever any of the
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1229
  given term patterns match the current redex.  The implementation,
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1230
  which is provided as ML source text, needs to be of type
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1231
  \verb,morphism -> simpset -> cterm -> thm option,, where the
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1232
  \verb,cterm, represents the current redex $r$ and the result is
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1233
  supposed to be some proven rewrite rule $r \equiv r'$ (or a
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1234
  generalized version), or \verb,NONE, to indicate failure.  The
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1235
  \verb,simpset, argument holds the full context of the current
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1236
  Simplifier invocation, including the actual Isar proof context.  The
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1237
  \verb,morphism, informs about the difference of the original
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1238
  compilation context wrt.\ the one of the actual application later
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1239
  on.  The optional $\isarkeyword{identifier}$ specifies theorems that
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1240
  represent the logical content of the abstract theory of this
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1241
  simproc.
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1242
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1243
  Morphisms and identifiers are only relevant for simprocs that are
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1244
  defined within a local target context, e.g.\ in a locale.
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1245
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1246
\item [$simproc\;add\colon\;name$ and $simproc\;del\colon\;name$] add
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1247
  or delete named simprocs to the current Simplifier context.  The
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1248
  default is to add a simproc.  Note that $\isarcmd{simproc_setup}$
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1249
  already adds the new simproc to the subsequent context.
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1250
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1251
\end{descr}
253720dddcde added command 'simproc_setup', attribute "simproc";
wenzelm
parents: 23920
diff changeset
  1252
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
  1253
\subsubsection{Forward simplification}
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
  1254
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
  1255
\indexisaratt{simplified}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1256
\begin{matharray}{rcl}
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
  1257
  simplified & : & \isaratt \\
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1258
\end{matharray}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1259
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
  1260
\begin{rail}
13015
wenzelm
parents: 12976
diff changeset
  1261
  'simplified' opt? thmrefs?
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
  1262
  ;
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
  1263
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
  1264
  opt: '(' (noasm | noasmsimp | noasmuse) ')'
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
  1265
  ;
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
  1266
\end{rail}
7905
wenzelm
parents: 7897
diff changeset
  1267
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
  1268
\begin{descr}
13048
wenzelm
parents: 13042
diff changeset
  1269
  
13015
wenzelm
parents: 12976
diff changeset
  1270
\item [$simplified~\vec a$] causes a theorem to be simplified, either by
wenzelm
parents: 12976
diff changeset
  1271
  exactly the specified rules $\vec a$, or the implicit Simplifier context if
wenzelm
parents: 12976
diff changeset
  1272
  no arguments are given.  The result is fully simplified by default,
wenzelm
parents: 12976
diff changeset
  1273
  including assumptions and conclusion; the options $no_asm$ etc.\ tune the
13048
wenzelm
parents: 13042
diff changeset
  1274
  Simplifier in the same way as the for the $simp$ method.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1275
13015
wenzelm
parents: 12976
diff changeset
  1276
  Note that forward simplification restricts the simplifier to its most basic
wenzelm
parents: 12976
diff changeset
  1277
  operation of term rewriting; solver and looper tactics \cite{isabelle-ref}
wenzelm
parents: 12976
diff changeset
  1278
  are \emph{not} involved here.  The $simplified$ attribute should be only
wenzelm
parents: 12976
diff changeset
  1279
  rarely required under normal circumstances.
wenzelm
parents: 12976
diff changeset
  1280
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
  1281
\end{descr}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1282
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1283
13048
wenzelm
parents: 13042
diff changeset
  1284
\subsubsection{Low-level equational reasoning}
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1285
12976
5cfe2941a5db contexts, locales, sym(metric);
wenzelm
parents: 12967
diff changeset
  1286
\indexisarmeth{subst}\indexisarmeth{hypsubst}\indexisarmeth{split}
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1287
\begin{matharray}{rcl}
13015
wenzelm
parents: 12976
diff changeset
  1288
  subst^* & : & \isarmeth \\
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1289
  hypsubst^* & : & \isarmeth \\
13015
wenzelm
parents: 12976
diff changeset
  1290
  split^* & : & \isarmeth \\
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1291
\end{matharray}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1292
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1293
\begin{rail}
15995
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1294
  'subst' ('(' 'asm' ')')? ('(' (nat+) ')')? thmref
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1295
  ;
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1296
  'split' ('(' 'asm' ')')? thmrefs
9703
bf65780eed02 added 'split' method;
wenzelm
parents: 9642
diff changeset
  1297
  ;
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1298
\end{rail}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1299
13015
wenzelm
parents: 12976
diff changeset
  1300
These methods provide low-level facilities for equational reasoning that are
wenzelm
parents: 12976
diff changeset
  1301
intended for specialized applications only.  Normally, single step
wenzelm
parents: 12976
diff changeset
  1302
calculations would be performed in a structured text (see also
wenzelm
parents: 12976
diff changeset
  1303
\S\ref{sec:calculation}), while the Simplifier methods provide the canonical
wenzelm
parents: 12976
diff changeset
  1304
way for automated normalization (see \S\ref{sec:simplifier}).
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1305
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1306
\begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1307
15995
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1308
\item [$subst~eq$] performs a single substitution step using rule $eq$, which
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1309
  may be either a meta or object equality.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1310
15995
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1311
\item [$subst~(asm)~eq$] substitutes in an assumption.
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1312
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1313
\item [$subst~(i \dots j)~eq$] performs several substitutions in the
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1314
conclusion. The numbers $i$ to $j$ indicate the positions to substitute at.
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1315
Positions are ordered from the top of the term tree moving down from left to
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1316
right. For example, in $(a+b)+(c+d)$ there are three positions where
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1317
commutativity of $+$ is applicable: 1 refers to the whole term, 2 to $a+b$
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1318
and 3 to $c+d$. If the positions in the list $(i \dots j)$ are
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1319
non-overlapping (e.g. $(2~3)$ in $(a+b)+(c+d)$) you may assume all
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1320
substitutions are performed simultaneously. Otherwise the behaviour of
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1321
$subst$ is not specified.
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1322
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1323
\item [$subst~(asm)~(i \dots j)~eq$] performs the substitutions in the
16010
0705c8d1f107 subst again
nipkow
parents: 15995
diff changeset
  1324
assumptions. Positions $1 \dots i@1$ refer
0705c8d1f107 subst again
nipkow
parents: 15995
diff changeset
  1325
to assumption 1, positions $i@1+1 \dots i@2$ to assumption 2, and so on.
15995
251069032c03 documented new subst
nipkow
parents: 15837
diff changeset
  1326
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1327
\item [$hypsubst$] performs substitution using some assumption; this only
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1328
  works for equations of the form $x = t$ where $x$ is a free or bound
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1329
  variable.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1330
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1331
\item [$split~\vec a$] performs single-step case splitting using rules $thms$.
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1332
  By default, splitting is performed in the conclusion of a goal; the $asm$
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1333
  option indicates to operate on assumptions instead.
13048
wenzelm
parents: 13042
diff changeset
  1334
  
9703
bf65780eed02 added 'split' method;
wenzelm
parents: 9642
diff changeset
  1335
  Note that the $simp$ method already involves repeated application of split
13048
wenzelm
parents: 13042
diff changeset
  1336
  rules as declared in the current context.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1337
\end{descr}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1338
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1339
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
  1340
\subsection{The Classical Reasoner}\label{sec:classical}
7135
wenzelm
parents:
diff changeset
  1341
13048
wenzelm
parents: 13042
diff changeset
  1342
\subsubsection{Basic methods}
7321
wenzelm
parents: 7319
diff changeset
  1343
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1344
\indexisarmeth{rule}\indexisarmeth{default}\indexisarmeth{contradiction}
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1345
\indexisarmeth{intro}\indexisarmeth{elim}
7321
wenzelm
parents: 7319
diff changeset
  1346
\begin{matharray}{rcl}
wenzelm
parents: 7319
diff changeset
  1347
  rule & : & \isarmeth \\
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1348
  contradiction & : & \isarmeth \\
7321
wenzelm
parents: 7319
diff changeset
  1349
  intro & : & \isarmeth \\
wenzelm
parents: 7319
diff changeset
  1350
  elim & : & \isarmeth \\
wenzelm
parents: 7319
diff changeset
  1351
\end{matharray}
wenzelm
parents: 7319
diff changeset
  1352
wenzelm
parents: 7319
diff changeset
  1353
\begin{rail}
8547
wenzelm
parents: 8517
diff changeset
  1354
  ('rule' | 'intro' | 'elim') thmrefs?
7321
wenzelm
parents: 7319
diff changeset
  1355
  ;
wenzelm
parents: 7319
diff changeset
  1356
\end{rail}
wenzelm
parents: 7319
diff changeset
  1357
wenzelm
parents: 7319
diff changeset
  1358
\begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1359
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
  1360
\item [$rule$] as offered by the classical reasoner is a refinement over the
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1361
  primitive one (see \S\ref{sec:pure-meth-att}).  Both versions essentially
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1362
  work the same, but the classical version observes the classical rule context
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1363
  in addition to that of Isabelle/Pure.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1364
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1365
  Common object logics (HOL, ZF, etc.) declare a rich collection of classical
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1366
  rules (even if these would qualify as intuitionistic ones), but only few
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1367
  declarations to the rule context of Isabelle/Pure
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1368
  (\S\ref{sec:pure-meth-att}).
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1369
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1370
\item [$contradiction$] solves some goal by contradiction, deriving any result
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
  1371
  from both $\lnot A$ and $A$.  Chained facts, which are guaranteed to
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1372
  participate, may appear in either order.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1373
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
  1374
\item [$intro$ and $elim$] repeatedly refine some goal by intro- or
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1375
  elim-resolution, after having inserted any chained facts.  Exactly the rules
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1376
  given as arguments are taken into account; this allows fine-tuned
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1377
  decomposition of a proof problem, in contrast to common automated tools.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1378
7321
wenzelm
parents: 7319
diff changeset
  1379
\end{descr}
wenzelm
parents: 7319
diff changeset
  1380
wenzelm
parents: 7319
diff changeset
  1381
13048
wenzelm
parents: 13042
diff changeset
  1382
\subsubsection{Automated methods}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1383
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1384
\indexisarmeth{blast}\indexisarmeth{fast}\indexisarmeth{slow}
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1385
\indexisarmeth{best}\indexisarmeth{safe}\indexisarmeth{clarify}
7321
wenzelm
parents: 7319
diff changeset
  1386
\begin{matharray}{rcl}
9780
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
  1387
  blast & : & \isarmeth \\
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
  1388
  fast & : & \isarmeth \\
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1389
  slow & : & \isarmeth \\
9780
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
  1390
  best & : & \isarmeth \\
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
  1391
  safe & : & \isarmeth \\
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
  1392
  clarify & : & \isarmeth \\
7321
wenzelm
parents: 7319
diff changeset
  1393
\end{matharray}
wenzelm
parents: 7319
diff changeset
  1394
11128
48c63b87566e index mod syntax;
wenzelm
parents: 11100
diff changeset
  1395
\indexouternonterm{clamod}
7321
wenzelm
parents: 7319
diff changeset
  1396
\begin{rail}
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1397
  'blast' ('!' ?) nat? (clamod *)
7321
wenzelm
parents: 7319
diff changeset
  1398
  ;
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1399
  ('fast' | 'slow' | 'best' | 'safe' | 'clarify') ('!' ?) (clamod *)
7321
wenzelm
parents: 7319
diff changeset
  1400
  ;
wenzelm
parents: 7319
diff changeset
  1401
9408
d3d56e1d2ec1 classical atts now intro! / intro / intro?;
wenzelm
parents: 9232
diff changeset
  1402
  clamod: (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del') ':' thmrefs
7321
wenzelm
parents: 7319
diff changeset
  1403
  ;
wenzelm
parents: 7319
diff changeset
  1404
\end{rail}
wenzelm
parents: 7319
diff changeset
  1405
wenzelm
parents: 7319
diff changeset
  1406
\begin{descr}
wenzelm
parents: 7319
diff changeset
  1407
\item [$blast$] refers to the classical tableau prover (see \texttt{blast_tac}
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
  1408
  in \cite[\S11]{isabelle-ref}).  The optional argument specifies a
10858
wenzelm
parents: 10741
diff changeset
  1409
  user-supplied search bound (default 20).
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1410
\item [$fast$, $slow$, $best$, $safe$, and $clarify$] refer to the generic
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1411
  classical reasoner.  See \texttt{fast_tac}, \texttt{slow_tac},
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1412
  \texttt{best_tac}, \texttt{safe_tac}, and \texttt{clarify_tac} in
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1413
  \cite[\S11]{isabelle-ref} for more information.
7321
wenzelm
parents: 7319
diff changeset
  1414
\end{descr}
wenzelm
parents: 7319
diff changeset
  1415
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1416
Any of the above methods support additional modifiers of the context of
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1417
classical rules.  Their semantics is analogous to the attributes given before.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1418
Facts provided by forward chaining are inserted into the goal before
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1419
commencing proof search.  The ``!''~argument causes the full context of
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1420
assumptions to be included as well.
7321
wenzelm
parents: 7319
diff changeset
  1421
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1422
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
  1423
\subsubsection{Combined automated methods}\label{sec:clasimp}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1424
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1425
\indexisarmeth{auto}\indexisarmeth{force}\indexisarmeth{clarsimp}
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1426
\indexisarmeth{fastsimp}\indexisarmeth{slowsimp}\indexisarmeth{bestsimp}
7321
wenzelm
parents: 7319
diff changeset
  1427
\begin{matharray}{rcl}
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1428
  auto & : & \isarmeth \\
7321
wenzelm
parents: 7319
diff changeset
  1429
  force & : & \isarmeth \\
9438
6131037f8a11 removed slow, slow_best methods;
wenzelm
parents: 9408
diff changeset
  1430
  clarsimp & : & \isarmeth \\
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
  1431
  fastsimp & : & \isarmeth \\
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1432
  slowsimp & : & \isarmeth \\
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1433
  bestsimp & : & \isarmeth \\
7321
wenzelm
parents: 7319
diff changeset
  1434
\end{matharray}
wenzelm
parents: 7319
diff changeset
  1435
11128
48c63b87566e index mod syntax;
wenzelm
parents: 11100
diff changeset
  1436
\indexouternonterm{clasimpmod}
7321
wenzelm
parents: 7319
diff changeset
  1437
\begin{rail}
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1438
  'auto' '!'? (nat nat)? (clasimpmod *)
9780
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
  1439
  ;
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1440
  ('force' | 'clarsimp' | 'fastsimp' | 'slowsimp' | 'bestsimp') '!'? (clasimpmod *)
7321
wenzelm
parents: 7319
diff changeset
  1441
  ;
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1442
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
  1443
  clasimpmod: ('simp' (() | 'add' | 'del' | 'only') |
10031
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
  1444
    ('cong' | 'split') (() | 'add' | 'del') |
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
  1445
    'iff' (((() | 'add') '?'?) | 'del') |
9408
d3d56e1d2ec1 classical atts now intro! / intro / intro?;
wenzelm
parents: 9232
diff changeset
  1446
    (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del')) ':' thmrefs
7321
wenzelm
parents: 7319
diff changeset
  1447
\end{rail}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
  1448
7321
wenzelm
parents: 7319
diff changeset
  1449
\begin{descr}
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1450
\item [$auto$, $force$, $clarsimp$, $fastsimp$, $slowsimp$, and $bestsimp$]
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1451
  provide access to Isabelle's combined simplification and classical reasoning
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1452
  tactics.  These correspond to \texttt{auto_tac}, \texttt{force_tac},
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1453
  \texttt{clarsimp_tac}, and Classical Reasoner tactics with the Simplifier
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
  1454
  added as wrapper, see \cite[\S11]{isabelle-ref} for more information.  The
13048
wenzelm
parents: 13042
diff changeset
  1455
  modifier arguments correspond to those given in \S\ref{sec:simplifier} and
wenzelm
parents: 13042
diff changeset
  1456
  \S\ref{sec:classical}.  Just note that the ones related to the Simplifier
wenzelm
parents: 13042
diff changeset
  1457
  are prefixed by \railtterm{simp} here.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1458
7987
wenzelm
parents: 7981
diff changeset
  1459
  Facts provided by forward chaining are inserted into the goal before doing
wenzelm
parents: 7981
diff changeset
  1460
  the search.  The ``!''~argument causes the full context of assumptions to be
wenzelm
parents: 7981
diff changeset
  1461
  included as well.
7321
wenzelm
parents: 7319
diff changeset
  1462
\end{descr}
wenzelm
parents: 7319
diff changeset
  1463
7987
wenzelm
parents: 7981
diff changeset
  1464
13048
wenzelm
parents: 13042
diff changeset
  1465
\subsubsection{Declaring rules}
7135
wenzelm
parents:
diff changeset
  1466
8667
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
  1467
\indexisarcmd{print-claset}
7391
b7ca64c8fa64 'iff' attribute;
wenzelm
parents: 7356
diff changeset
  1468
\indexisaratt{intro}\indexisaratt{elim}\indexisaratt{dest}
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
  1469
\indexisaratt{iff}\indexisaratt{rule}
7321
wenzelm
parents: 7319
diff changeset
  1470
\begin{matharray}{rcl}
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1471
  \isarcmd{print_claset}^* & : & \isarkeep{theory~|~proof} \\
7321
wenzelm
parents: 7319
diff changeset
  1472
  intro & : & \isaratt \\
wenzelm
parents: 7319
diff changeset
  1473
  elim & : & \isaratt \\
wenzelm
parents: 7319
diff changeset
  1474
  dest & : & \isaratt \\
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
  1475
  rule & : & \isaratt \\
7391
b7ca64c8fa64 'iff' attribute;
wenzelm
parents: 7356
diff changeset
  1476
  iff & : & \isaratt \\
7321
wenzelm
parents: 7319
diff changeset
  1477
\end{matharray}
7135
wenzelm
parents:
diff changeset
  1478
7321
wenzelm
parents: 7319
diff changeset
  1479
\begin{rail}
18854
99124f3beccf 'fixes': support plain vars;
wenzelm
parents: 18530
diff changeset
  1480
  ('intro' | 'elim' | 'dest') ('!' | () | '?') nat?
7321
wenzelm
parents: 7319
diff changeset
  1481
  ;
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
  1482
  'rule' 'del'
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
  1483
  ;
10031
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
  1484
  'iff' (((() | 'add') '?'?) | 'del')
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
  1485
  ;
7321
wenzelm
parents: 7319
diff changeset
  1486
\end{rail}
7135
wenzelm
parents:
diff changeset
  1487
7321
wenzelm
parents: 7319
diff changeset
  1488
\begin{descr}
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1489
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1490
\item [$\isarcmd{print_claset}$] prints the collection of rules declared to
21076
22ae82f77c5e small refinements
haftmann
parents: 20503
diff changeset
  1491
  the Classical Reasoner, which is also known as ``claset'' internally
8667
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
  1492
  \cite{isabelle-ref}.  This is a diagnostic command; $undo$ does not apply.
18854
99124f3beccf 'fixes': support plain vars;
wenzelm
parents: 18530
diff changeset
  1493
  
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
  1494
\item [$intro$, $elim$, and $dest$] declare introduction, elimination, and
11332
11ab8c8ce694 extended doc for iff attribute
oheimb
parents: 11128
diff changeset
  1495
  destruction rules, respectively.  By default, rules are considered as
9408
d3d56e1d2ec1 classical atts now intro! / intro / intro?;
wenzelm
parents: 9232
diff changeset
  1496
  \emph{unsafe} (i.e.\ not applied blindly without backtracking), while a
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1497
  single ``!'' classifies as \emph{safe}.  Rule declarations marked by ``?''
18854
99124f3beccf 'fixes': support plain vars;
wenzelm
parents: 18530
diff changeset
  1498
  coincide with those of Isabelle/Pure, cf.\ \S\ref{sec:pure-meth-att} (i.e.\ 
99124f3beccf 'fixes': support plain vars;
wenzelm
parents: 18530
diff changeset
  1499
  are only applied in single steps of the $rule$ method).  The optional
99124f3beccf 'fixes': support plain vars;
wenzelm
parents: 18530
diff changeset
  1500
  natural number specifies an explicit weight argument, which is ignored by
99124f3beccf 'fixes': support plain vars;
wenzelm
parents: 18530
diff changeset
  1501
  automated tools, but determines the search order of single rule steps.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1502
11332
11ab8c8ce694 extended doc for iff attribute
oheimb
parents: 11128
diff changeset
  1503
\item [$rule~del$] deletes introduction, elimination, or destruction rules from
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
  1504
  the context.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1505
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1506
\item [$iff$] declares logical equivalences to the Simplifier and the
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1507
  Classical reasoner at the same time.  Non-conditional rules result in a
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1508
  ``safe'' introduction and elimination pair; conditional ones are considered
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1509
  ``unsafe''.  Rules with negative conclusion are automatically inverted
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
  1510
  (using $\lnot$ elimination internally).
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1511
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1512
  The ``?'' version of $iff$ declares rules to the Isabelle/Pure context only,
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1513
  and omits the Simplifier declaration.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1514
7321
wenzelm
parents: 7319
diff changeset
  1515
\end{descr}
7135
wenzelm
parents:
diff changeset
  1516
8203
2fcc6017cb72 intro/elim/dest attributes: changed ! / !! flags to ? / ??;
wenzelm
parents: 8195
diff changeset
  1517
13048
wenzelm
parents: 13042
diff changeset
  1518
\subsubsection{Classical operations}
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1519
18530
d995aecddc15 removed classical elim_format;
wenzelm
parents: 18505
diff changeset
  1520
\indexisaratt{swapped}
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1521
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1522
\begin{matharray}{rcl}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1523
  swapped & : & \isaratt \\
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1524
\end{matharray}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1525
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1526
\begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1527
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1528
\item [$swapped$] turns an introduction rule into an elimination, by resolving
20379
154d8c155a65 added passage on class package
haftmann
parents: 20126
diff changeset
  1529
  with the classical swap principle $(\lnot B \Imp A) \Imp (\lnot A \Imp B)$.
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1530
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1531
\end{descr}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1532
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1533
12621
48cafea0684b next round of updates;
wenzelm
parents: 12618
diff changeset
  1534
\subsection{Proof by cases and induction}\label{sec:cases-induct}
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1535
13048
wenzelm
parents: 13042
diff changeset
  1536
\subsubsection{Rule contexts}
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1537
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1538
\indexisarcmd{case}\indexisarcmd{print-cases}
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1539
\indexisaratt{case-names}\indexisaratt{case-conclusion}
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1540
\indexisaratt{params}\indexisaratt{consumes}
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1541
\begin{matharray}{rcl}
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1542
  \isarcmd{case} & : & \isartrans{proof(state)}{proof(state)} \\
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1543
  \isarcmd{print_cases}^* & : & \isarkeep{proof} \\
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1544
  case_names & : & \isaratt \\
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1545
  case_conclusion & : & \isaratt \\
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1546
  params & : & \isaratt \\
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1547
  consumes & : & \isaratt \\
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1548
\end{matharray}
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1549
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1550
The puristic way to build up Isar proof contexts is by explicit language
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1551
elements like $\FIXNAME$, $\ASSUMENAME$, $\LET$ (see
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1552
\S\ref{sec:proof-context}).  This is adequate for plain natural deduction, but
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1553
easily becomes unwieldy in concrete verification tasks, which typically
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1554
involve big induction rules with several cases.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1555
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1556
The $\CASENAME$ command provides a shorthand to refer to a local context
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1557
symbolically: certain proof methods provide an environment of named ``cases''
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1558
of the form $c\colon \vec x, \vec \phi$; the effect of ``$\CASE{c}$'' is then
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1559
equivalent to ``$\FIX{\vec x}~\ASSUME{c}{\vec\phi}$''.  Term bindings may be
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1560
covered as well, notably $\Var{case}$ for the main conclusion.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1561
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1562
By default, the ``terminology'' $\vec x$ of a case value is marked as hidden,
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1563
i.e.\ there is no way to refer to such parameters in the subsequent proof
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1564
text.  After all, original rule parameters stem from somewhere outside of the
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1565
current proof text.  By using the explicit form ``$\CASE{(c~\vec y)}$''
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1566
instead, the proof author is able to chose local names that fit nicely into
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1567
the current context.
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1568
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1569
\medskip
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1570
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1571
It is important to note that proper use of $\CASENAME$ does not provide means
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1572
to peek at the current goal state, which is not directly observable in Isar!
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1573
Nonetheless, goal refinement commands do provide named cases $goal@i$ for each
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1574
subgoal $i = 1, \dots, n$ of the resulting goal state.  Using this feature
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1575
requires great care, because some bits of the internal tactical machinery
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1576
intrude the proof text.  In particular, parameter names stemming from the
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1577
left-over of automated reasoning tools are usually quite unpredictable.
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1578
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1579
Under normal circumstances, the text of cases emerge from standard elimination
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1580
or induction rules, which in turn are derived from previous theory
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1581
specifications in a canonical way (say from $\isarkeyword{inductive}$
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1582
definitions).
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1583
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1584
\medskip Proper cases are only available if both the proof method and the
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1585
rules involved support this.  By using appropriate attributes, case names,
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1586
conclusions, and parameters may be also declared by hand.  Thus variant
19786
eeefc22d08d8 fixed typo
haftmann
parents: 19666
diff changeset
  1587
versions of rules that have been derived manually become ready to use in
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1588
advanced case analysis later.
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1589
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1590
\begin{rail}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1591
  'case' (caseref | '(' caseref ((name | underscore) +) ')')
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1592
  ;
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1593
  caseref: nameref attributes?
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1594
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1595
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1596
  'case\_names' (name +)
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1597
  ;
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1598
  'case\_conclusion' name (name *)
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1599
  ;
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1600
  'params' ((name *) + 'and')
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1601
  ;
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1602
  'consumes' nat?
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1603
  ;
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1604
\end{rail}
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1605
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1606
\begin{descr}
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1607
  
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1608
\item [$\CASE{(c~\vec x)}$] invokes a named local context $c\colon \vec x,
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1609
  \vec \phi$, as provided by an appropriate proof method (such as $cases$ and
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1610
  $induct$).  The command ``$\CASE{(c~\vec x)}$'' abbreviates ``$\FIX{\vec
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1611
    x}~\ASSUME{c}{\vec\phi}$''.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1612
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1613
\item [$\isarkeyword{print_cases}$] prints all local contexts of the current
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1614
  state, using Isar proof language notation.  This is a diagnostic command;
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1615
  $undo$ does not apply.
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1616
  
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1617
\item [$case_names~\vec c$] declares names for the local contexts of premises
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1618
  of a theorem; $\vec c$ refers to the \emph{suffix} of the list of premises.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1619
  
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1620
\item [$case_conclusion~c~\vec d$] declares names for the conclusions of a
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1621
  named premise $c$; here $\vec d$ refers to the prefix of arguments of a
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1622
  logical formula built by nesting a binary connective (e.g.\ $\lor$).
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1623
  
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1624
  Note that proof methods such as $induct$ and $coinduct$ already provide a
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1625
  default name for the conclusion as a whole.  The need to name subformulas
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1626
  only arises with cases that split into several sub-cases, as in common
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1627
  co-induction rules.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1628
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1629
\item [$params~\vec p@1 \dots \vec p@n$] renames the innermost parameters of
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1630
  premises $1, \dots, n$ of some theorem.  An empty list of names may be given
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1631
  to skip positions, leaving the present parameters unchanged.
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1632
  
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1633
  Note that the default usage of case rules does \emph{not} directly expose
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1634
  parameters to the proof context.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1635
  
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1636
\item [$consumes~n$] declares the number of ``major premises'' of a rule,
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1637
  i.e.\ the number of facts to be consumed when it is applied by an
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1638
  appropriate proof method.  The default value of $consumes$ is $n = 1$, which
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1639
  is appropriate for the usual kind of cases and induction rules for inductive
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1640
  sets (cf.\ \S\ref{sec:hol-inductive}).  Rules without any $consumes$
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1641
  declaration given are treated as if $consumes~0$ had been specified.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1642
  
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1643
  Note that explicit $consumes$ declarations are only rarely needed; this is
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1644
  already taken care of automatically by the higher-level $cases$, $induct$,
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1645
  and $coinduct$ declarations.
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1646
12618
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1647
\end{descr}
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1648
43a97a2155d0 first stage of major update;
wenzelm
parents: 11691
diff changeset
  1649
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1650
\subsubsection{Proof methods}
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1651
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1652
\indexisarmeth{cases}\indexisarmeth{induct}\indexisarmeth{coinduct}
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1653
\begin{matharray}{rcl}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1654
  cases & : & \isarmeth \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1655
  induct & : & \isarmeth \\
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1656
  coinduct & : & \isarmeth \\
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1657
\end{matharray}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1658
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1659
The $cases$, $induct$, and $coinduct$ methods provide a uniform interface to
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1660
common proof techniques over datatypes, inductive sets, recursive functions
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1661
etc.  The corresponding rules may be specified and instantiated in a casual
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1662
manner.  Furthermore, these methods provide named local contexts that may be
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1663
invoked via the $\CASENAME$ proof command within the subsequent proof text.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1664
This accommodates compact proof texts even when reasoning about large
13048
wenzelm
parents: 13042
diff changeset
  1665
specifications.
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1666
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1667
The $induct$ method also provides some additional infrastructure in order to
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1668
be applicable to structure statements (either using explicit meta-level
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1669
connectives, or including facts and parameters separately).  This avoids
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1670
cumbersome encoding of ``strengthened'' inductive statements within the
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1671
object-logic.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1672
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1673
\begin{rail}
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1674
  'cases' open? (insts * 'and') rule?
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1675
  ;
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20492
diff changeset
  1676
  'induct' open? (definsts * 'and') \\ arbitrary? taking? rule?
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1677
  ;
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1678
  'coinduct' open? insts taking rule?
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1679
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1680
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1681
  open: '(' 'open' ')'
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1682
  ;
18505
95e6c9ef7488 induct etc.: admit multiple rules;
wenzelm
parents: 18232
diff changeset
  1683
  rule: ('type' | 'set') ':' (nameref +) | 'rule' ':' (thmref +)
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1684
  ;
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1685
  definst: name ('==' | equiv) term | inst
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1686
  ;
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1687
  definsts: ( definst *)
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1688
  ;
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20492
diff changeset
  1689
  arbitrary: 'arbitrary' ':' ((term *) 'and' +)
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1690
  ;
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1691
  taking: 'taking' ':' insts
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1692
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1693
\end{rail}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1694
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1695
\begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1696
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1697
\item [$cases~insts~R$] applies method $rule$ with an appropriate case
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1698
  distinction theorem, instantiated to the subjects $insts$.  Symbolic case
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1699
  names are bound according to the rule's local contexts.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1700
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1701
  The rule is determined as follows, according to the facts and arguments
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1702
  passed to the $cases$ method:
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1703
  \begin{matharray}{llll}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1704
    \Text{facts}    &       & \Text{arguments} & \Text{rule} \\\hline
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1705
                    & cases &           & \Text{classical case split} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1706
                    & cases & t         & \Text{datatype exhaustion (type of $t$)} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1707
    \edrv a \in A   & cases & \dots     & \Text{inductive set elimination (of $A$)} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1708
    \dots           & cases & \dots ~ R & \Text{explicit rule $R$} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1709
  \end{matharray}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1710
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1711
  Several instantiations may be given, referring to the \emph{suffix} of
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1712
  premises of the case rule; within each premise, the \emph{prefix} of
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1713
  variables is instantiated.  In most situations, only a single term needs to
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1714
  be specified; this refers to the first variable of the last premise (it is
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1715
  usually the same for all cases).
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1716
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1717
  The ``$(open)$'' option causes the parameters of the new local contexts to
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1718
  be exposed to the current proof context.  Thus local variables stemming from
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1719
  distant parts of the theory development may be introduced in an implicit
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1720
  manner, which can be quite confusing to the reader.  Furthermore, this
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1721
  option may cause unwanted hiding of existing local variables, resulting in
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1722
  less robust proof texts.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1723
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1724
\item [$induct~insts~R$] is analogous to the $cases$ method, but refers to
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1725
  induction rules, which are determined as follows:
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1726
  \begin{matharray}{llll}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1727
    \Text{facts}    &        & \Text{arguments} & \Text{rule} \\\hline
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1728
                    & induct & P ~ x ~ \dots & \Text{datatype induction (type of $x$)} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1729
    \edrv x \in A   & induct & \dots         & \Text{set induction (of $A$)} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1730
    \dots           & induct & \dots ~ R     & \Text{explicit rule $R$} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1731
  \end{matharray}
18505
95e6c9ef7488 induct etc.: admit multiple rules;
wenzelm
parents: 18232
diff changeset
  1732
  
95e6c9ef7488 induct etc.: admit multiple rules;
wenzelm
parents: 18232
diff changeset
  1733
  Several instantiations may be given, each referring to some part of
95e6c9ef7488 induct etc.: admit multiple rules;
wenzelm
parents: 18232
diff changeset
  1734
  a mutual inductive definition or datatype --- only related partial
95e6c9ef7488 induct etc.: admit multiple rules;
wenzelm
parents: 18232
diff changeset
  1735
  induction rules may be used together, though.  Any of the lists of
95e6c9ef7488 induct etc.: admit multiple rules;
wenzelm
parents: 18232
diff changeset
  1736
  terms $P, x, \dots$ refers to the \emph{suffix} of variables present
95e6c9ef7488 induct etc.: admit multiple rules;
wenzelm
parents: 18232
diff changeset
  1737
  in the induction rule.  This enables the writer to specify only
95e6c9ef7488 induct etc.: admit multiple rules;
wenzelm
parents: 18232
diff changeset
  1738
  induction variables, or both predicates and variables, for example.
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1739
  
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1740
  Instantiations may be definitional: equations $x \equiv t$ introduce local
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1741
  definitions, which are inserted into the claim and discharged after applying
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1742
  the induction rule.  Equalities reappear in the inductive cases, but have
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1743
  been transformed according to the induction principle being involved here.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1744
  In order to achieve practically useful induction hypotheses, some variables
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1745
  occurring in $t$ need to be fixed (see below).
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1746
  
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20492
diff changeset
  1747
  The optional ``$arbitrary\colon \vec x$'' specification generalizes
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20492
diff changeset
  1748
  variables $\vec x$ of the original goal before applying induction.  Thus
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20492
diff changeset
  1749
  induction hypotheses may become sufficiently general to get the proof
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20492
diff changeset
  1750
  through.  Together with definitional instantiations, one may effectively
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20492
diff changeset
  1751
  perform induction over expressions of a certain structure.
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1752
  
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1753
  The optional ``$taking\colon \vec t$'' specification provides additional
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1754
  instantiations of a prefix of pending variables in the rule.  Such schematic
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1755
  induction rules rarely occur in practice, though.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1756
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1757
  The ``$(open)$'' option works the same way as for $cases$.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1758
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1759
\item [$coinduct~inst~R$] is analogous to the $induct$ method, but refers to
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1760
  coinduction rules, which are determined as follows:
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1761
  \begin{matharray}{llll}
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1762
    \Text{goal}     &          & \Text{arguments} & \Text{rule} \\\hline
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1763
                    & coinduct & x ~ \dots        & \Text{type coinduction (type of $x$)} \\
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1764
    x \in A         & coinduct & \dots            & \Text{set coinduction (of $A$)} \\
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1765
    \dots           & coinduct & \dots ~ R        & \Text{explicit rule $R$} \\
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1766
  \end{matharray}
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1767
  
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1768
  Coinduction is the dual of induction.  Induction essentially eliminates $x
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1769
  \in A$ towards a generic result $P ~ x$, while coinduction introduces $x \in
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1770
  A$ starting with $x \in B$, for a suitable ``bisimulation'' $B$.  The cases
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1771
  of a coinduct rule are typically named after the sets being covered, while
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1772
  the conclusions consist of several alternatives being named after the
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1773
  individual destructor patterns.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1774
  
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1775
  The given instantiation refers to the \emph{prefix} of variables occurring
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1776
  in the rule's conclusion.  An additional ``$taking: \vec t$'' specification
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1777
  may be required in order to specify the bisimulation to be used in the
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1778
  coinduction step.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1779
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1780
  The ``$(open)$'' option works the same way as for $cases$.
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
  1781
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1782
\end{descr}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1783
13048
wenzelm
parents: 13042
diff changeset
  1784
Above methods produce named local contexts, as determined by the instantiated
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1785
rule as given in the text.  Beyond that, the $induct$ and $coinduct$ methods
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1786
guess further instantiations from the goal specification itself.  Any
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1787
persisting unresolved schematic variables of the resulting rule will render
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1788
the the corresponding case invalid.  The term binding
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1789
$\Var{case}$\indexisarvar{case} for the conclusion will be provided with each
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1790
case, provided that term is fully specified.
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1791
13048
wenzelm
parents: 13042
diff changeset
  1792
The $\isarkeyword{print_cases}$ command prints all named cases present in the
wenzelm
parents: 13042
diff changeset
  1793
current proof state.
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1794
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1795
\medskip
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1796
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1797
Despite the additional infrastructure, both $cases$ and $coinduct$ merely
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1798
apply a certain rule, after instantiation, while conforming due to the usual
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1799
way of monotonic natural deduction: the context of a structured statement
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1800
$\All{\vec x} \vec\phi \Imp \dots$ reappears unchanged after the case split.
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1801
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1802
The $induct$ method is significantly different in this respect: the meta-level
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1803
structure is passed through the ``recursive'' course involved in the
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1804
induction.  Thus the original statement is basically replaced by separate
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1805
copies, corresponding to the induction hypotheses and conclusion; the original
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1806
goal context is no longer available.  Thus local assumptions, fixed parameters
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1807
and definitions effectively participate in the inductive rephrasing of the
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1808
original statement.
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1809
13425
119ae829ad9b support for split assumptions in cases (hyps vs. prems);
wenzelm
parents: 13411
diff changeset
  1810
In induction proofs, local assumptions introduced by cases are split into two
119ae829ad9b support for split assumptions in cases (hyps vs. prems);
wenzelm
parents: 13411
diff changeset
  1811
different kinds: $hyps$ stemming from the rule and $prems$ from the goal
119ae829ad9b support for split assumptions in cases (hyps vs. prems);
wenzelm
parents: 13411
diff changeset
  1812
statement.  This is reflected in the extracted cases accordingly, so invoking
119ae829ad9b support for split assumptions in cases (hyps vs. prems);
wenzelm
parents: 13411
diff changeset
  1813
``$\isarcmd{case}~c$'' will provide separate facts $c\mathord.hyps$ and
119ae829ad9b support for split assumptions in cases (hyps vs. prems);
wenzelm
parents: 13411
diff changeset
  1814
$c\mathord.prems$, as well as fact $c$ to hold the all-inclusive list.
119ae829ad9b support for split assumptions in cases (hyps vs. prems);
wenzelm
parents: 13411
diff changeset
  1815
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1816
\medskip
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1817
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1818
Facts presented to either method are consumed according to the number of
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1819
``major premises'' of the rule involved, which is usually $0$ for plain cases
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1820
and induction rules of datatypes etc.\ and $1$ for rules of inductive sets and
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1821
the like.  The remaining facts are inserted into the goal verbatim before the
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1822
actual $cases$, $induct$, or $coinduct$ rule is applied.
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1823
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1824
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1825
\subsubsection{Declaring rules}
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1826
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1827
\indexisarcmd{print-induct-rules}\indexisaratt{cases}\indexisaratt{induct}\indexisaratt{coinduct}
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1828
\begin{matharray}{rcl}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1829
  \isarcmd{print_induct_rules}^* & : & \isarkeep{theory~|~proof} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1830
  cases & : & \isaratt \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1831
  induct & : & \isaratt \\
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1832
  coinduct & : & \isaratt \\
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1833
\end{matharray}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1834
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1835
\begin{rail}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1836
  'cases' spec
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1837
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1838
  'induct' spec
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1839
  ;
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1840
  'coinduct' spec
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1841
  ;
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1842
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1843
  spec: ('type' | 'set') ':' nameref
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1844
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1845
\end{rail}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1846
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1847
\begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1848
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1849
\item [$\isarkeyword{print_induct_rules}$] prints cases and induct rules for
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1850
  sets and types of the current context.
13048
wenzelm
parents: 13042
diff changeset
  1851
  
18232
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1852
\item [$cases$, $induct$, and $coinduct$] (as attributes) augment the
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1853
  corresponding context of rules for reasoning about (co)inductive sets and
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1854
  types, using the corresponding methods of the same name.  Certain
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1855
  definitional packages of object-logics usually declare emerging cases and
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1856
  induction rules as expected, so users rarely need to intervene.
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1857
  
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1858
  Manual rule declarations usually refer to the $case_names$ and $params$
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1859
  attributes to adjust names of cases and parameters of a rule; the $consumes$
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1860
  declaration is taken care of automatically: $consumes~0$ is specified for
bc367912603f added case_conclusion attribute;
wenzelm
parents: 17864
diff changeset
  1861
  ``type'' rules and $consumes~1$ for ``set'' rules.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13040
diff changeset
  1862
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13015
diff changeset
  1863
\end{descr}
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1864
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1865
%%% Local Variables:
7135
wenzelm
parents:
diff changeset
  1866
%%% mode: latex
wenzelm
parents:
diff changeset
  1867
%%% TeX-master: "isar-ref"
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1868
%%% End: