doc-src/IsarRef/generic.tex
author wenzelm
Thu, 04 Oct 2001 16:09:12 +0200
changeset 11691 fc9bd420162c
parent 11469 57b072f00626
child 12618 43a97a2155d0
permissions -rw-r--r--
induct/cases made generic, removed simplified/stripped options;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7135
wenzelm
parents:
diff changeset
     1
7167
wenzelm
parents: 7141
diff changeset
     2
\chapter{Generic Tools and Packages}\label{ch:gen-tools}
wenzelm
parents: 7141
diff changeset
     3
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
     4
\section{Axiomatic Type Classes}\label{sec:axclass}
7167
wenzelm
parents: 7141
diff changeset
     5
8904
0bb77c5b86cc added notes;
wenzelm
parents: 8901
diff changeset
     6
%FIXME
0bb77c5b86cc added notes;
wenzelm
parents: 8901
diff changeset
     7
% - qualified names
0bb77c5b86cc added notes;
wenzelm
parents: 8901
diff changeset
     8
% - class intro rules;
0bb77c5b86cc added notes;
wenzelm
parents: 8901
diff changeset
     9
% - class axioms;
0bb77c5b86cc added notes;
wenzelm
parents: 8901
diff changeset
    10
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
    11
\indexisarcmd{axclass}\indexisarcmd{instance}\indexisarmeth{intro-classes}
7167
wenzelm
parents: 7141
diff changeset
    12
\begin{matharray}{rcl}
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
    13
  \isarcmd{axclass} & : & \isartrans{theory}{theory} \\
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
    14
  \isarcmd{instance} & : & \isartrans{theory}{proof(prove)} \\
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
    15
  intro_classes & : & \isarmeth \\
7167
wenzelm
parents: 7141
diff changeset
    16
\end{matharray}
wenzelm
parents: 7141
diff changeset
    17
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
    18
Axiomatic type classes are provided by Isabelle/Pure as a \emph{definitional}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
    19
interface to type classes (cf.~\S\ref{sec:classes}).  Thus any object logic
8547
wenzelm
parents: 8517
diff changeset
    20
may make use of this light-weight mechanism of abstract theories
8901
e591fc327675 cite isabelle-axclass;
wenzelm
parents: 8811
diff changeset
    21
\cite{Wenzel:1997:TPHOL}.  There is also a tutorial on using axiomatic type
e591fc327675 cite isabelle-axclass;
wenzelm
parents: 8811
diff changeset
    22
classes in isabelle \cite{isabelle-axclass} that is part of the standard
e591fc327675 cite isabelle-axclass;
wenzelm
parents: 8811
diff changeset
    23
Isabelle documentation.
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
    24
7167
wenzelm
parents: 7141
diff changeset
    25
\begin{rail}
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
    26
  'axclass' classdecl (axmdecl prop comment? +)
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
    27
  ;
11100
34d58b1818f4 \<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents: 11095
diff changeset
    28
  'instance' (nameref ('<' | subseteq) nameref | nameref '::' simplearity) comment?
7167
wenzelm
parents: 7141
diff changeset
    29
  ;
wenzelm
parents: 7141
diff changeset
    30
\end{rail}
wenzelm
parents: 7141
diff changeset
    31
wenzelm
parents: 7141
diff changeset
    32
\begin{descr}
11100
34d58b1818f4 \<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents: 11095
diff changeset
    33
\item [$\AXCLASS~c \subseteq \vec c~axms$] defines an axiomatic type class as
34d58b1818f4 \<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents: 11095
diff changeset
    34
  the intersection of existing classes, with additional axioms holding.  Class
10223
wenzelm
parents: 10160
diff changeset
    35
  axioms may not contain more than one type variable.  The class axioms (with
wenzelm
parents: 10160
diff changeset
    36
  implicit sort constraints added) are bound to the given names.  Furthermore
wenzelm
parents: 10160
diff changeset
    37
  a class introduction rule is generated, which is employed by method
wenzelm
parents: 10160
diff changeset
    38
  $intro_classes$ to support instantiation proofs of this class.
wenzelm
parents: 10160
diff changeset
    39
  
11100
34d58b1818f4 \<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents: 11095
diff changeset
    40
\item [$\INSTANCE~c@1 \subseteq c@2$ and $\INSTANCE~t :: (\vec s)c$] setup a
34d58b1818f4 \<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents: 11095
diff changeset
    41
  goal stating a class relation or type arity.  The proof would usually
34d58b1818f4 \<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents: 11095
diff changeset
    42
  proceed by $intro_classes$, and then establish the characteristic theorems
34d58b1818f4 \<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents: 11095
diff changeset
    43
  of the type classes involved.  After finishing the proof, the theory will be
34d58b1818f4 \<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents: 11095
diff changeset
    44
  augmented by a type signature declaration corresponding to the resulting
34d58b1818f4 \<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents: 11095
diff changeset
    45
  theorem.
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
    46
\item [$intro_classes$] repeatedly expands all class introduction rules of
10858
wenzelm
parents: 10741
diff changeset
    47
  this theory.  Note that this method usually needs not be named explicitly,
wenzelm
parents: 10741
diff changeset
    48
  as it is already included in the default proof step (of $\PROOFNAME$,
wenzelm
parents: 10741
diff changeset
    49
  $\BYNAME$, etc.).  In particular, instantiation of trivial (syntactic)
wenzelm
parents: 10741
diff changeset
    50
  classes may be performed by a single ``$\DDOT$'' proof step.
7167
wenzelm
parents: 7141
diff changeset
    51
\end{descr}
wenzelm
parents: 7141
diff changeset
    52
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    53
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    54
\section{Calculational proof}\label{sec:calculation}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    55
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    56
\indexisarcmd{also}\indexisarcmd{finally}
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    57
\indexisarcmd{moreover}\indexisarcmd{ultimately}
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
    58
\indexisarcmd{print-trans-rules}\indexisaratt{trans}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    59
\begin{matharray}{rcl}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    60
  \isarcmd{also} & : & \isartrans{proof(state)}{proof(state)} \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    61
  \isarcmd{finally} & : & \isartrans{proof(state)}{proof(chain)} \\
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    62
  \isarcmd{moreover} & : & \isartrans{proof(state)}{proof(state)} \\
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    63
  \isarcmd{ultimately} & : & \isartrans{proof(state)}{proof(chain)} \\
10154
wenzelm
parents: 10031
diff changeset
    64
  \isarcmd{print_trans_rules}^* & : & \isarkeep{theory~|~proof} \\
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    65
  trans & : & \isaratt \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    66
\end{matharray}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    67
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    68
Calculational proof is forward reasoning with implicit application of
11332
11ab8c8ce694 extended doc for iff attribute
oheimb
parents: 11128
diff changeset
    69
transitivity rules (such those of $=$, $\leq$, $<$).  Isabelle/Isar maintains
7391
b7ca64c8fa64 'iff' attribute;
wenzelm
parents: 7356
diff changeset
    70
an auxiliary register $calculation$\indexisarthm{calculation} for accumulating
7897
7f18f5ffbb92 *** empty log message ***
wenzelm
parents: 7526
diff changeset
    71
results obtained by transitivity composed with the current result.  Command
7f18f5ffbb92 *** empty log message ***
wenzelm
parents: 7526
diff changeset
    72
$\ALSO$ updates $calculation$ involving $this$, while $\FINALLY$ exhibits the
7f18f5ffbb92 *** empty log message ***
wenzelm
parents: 7526
diff changeset
    73
final $calculation$ by forward chaining towards the next goal statement.  Both
7f18f5ffbb92 *** empty log message ***
wenzelm
parents: 7526
diff changeset
    74
commands require valid current facts, i.e.\ may occur only after commands that
7f18f5ffbb92 *** empty log message ***
wenzelm
parents: 7526
diff changeset
    75
produce theorems such as $\ASSUMENAME$, $\NOTENAME$, or some finished proof of
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    76
$\HAVENAME$, $\SHOWNAME$ etc.  The $\MOREOVER$ and $\ULTIMATELY$ commands are
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    77
similar to $\ALSO$ and $\FINALLY$, but only collect further results in
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    78
$calculation$ without applying any rules yet.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    79
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    80
Also note that the automatic term abbreviation ``$\dots$'' has its canonical
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    81
application with calculational proofs.  It refers to the argument\footnote{The
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    82
  argument of a curried infix expression is its right-hand side.} of the
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    83
preceding statement.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    84
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    85
Isabelle/Isar calculations are implicitly subject to block structure in the
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    86
sense that new threads of calculational reasoning are commenced for any new
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    87
block (as opened by a local goal, for example).  This means that, apart from
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    88
being able to nest calculations, there is no separate \emph{begin-calculation}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    89
command required.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    90
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    91
\medskip
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    92
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    93
The Isar calculation proof commands may be defined as
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    94
follows:\footnote{Internal bookkeeping such as proper handling of
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    95
  block-structure has been suppressed.}
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    96
\begin{matharray}{rcl}
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    97
  \ALSO@0 & \equiv & \NOTE{calculation}{this} \\
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
    98
  \ALSO@{n+1} & \equiv & \NOTE{calculation}{trans~[OF~calculation~this]} \\[0.5ex]
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
    99
  \FINALLY & \equiv & \ALSO~\FROM{calculation} \\
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   100
  \MOREOVER & \equiv & \NOTE{calculation}{calculation~this} \\
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   101
  \ULTIMATELY & \equiv & \MOREOVER~\FROM{calculation} \\
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   102
\end{matharray}
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   103
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   104
\begin{rail}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   105
  ('also' | 'finally') transrules? comment?
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   106
  ;
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   107
  ('moreover' | 'ultimately') comment?
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   108
  ;
8507
d22fcea34cb7 untag: only name arg;
wenzelm
parents: 8483
diff changeset
   109
  'trans' (() | 'add' | 'del')
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   110
  ;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   111
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   112
  transrules: '(' thmrefs ')' interest?
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   113
  ;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   114
\end{rail}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   115
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   116
\begin{descr}
8547
wenzelm
parents: 8517
diff changeset
   117
\item [$\ALSO~(\vec a)$] maintains the auxiliary $calculation$ register as
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   118
  follows.  The first occurrence of $\ALSO$ in some calculational thread
7905
wenzelm
parents: 7897
diff changeset
   119
  initializes $calculation$ by $this$. Any subsequent $\ALSO$ on the same
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   120
  level of block-structure updates $calculation$ by some transitivity rule
7458
bb282845ca77 updated;
wenzelm
parents: 7396
diff changeset
   121
  applied to $calculation$ and $this$ (in that order).  Transitivity rules are
11095
2ffaf1e1e101 updated;
wenzelm
parents: 10858
diff changeset
   122
  picked from the current context, unless alternative rules are given as
2ffaf1e1e101 updated;
wenzelm
parents: 10858
diff changeset
   123
  explicit arguments.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   124
8547
wenzelm
parents: 8517
diff changeset
   125
\item [$\FINALLY~(\vec a)$] maintaining $calculation$ in the same way as
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   126
  $\ALSO$, and concludes the current calculational thread.  The final result
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   127
  is exhibited as fact for forward chaining towards the next goal. Basically,
7987
wenzelm
parents: 7981
diff changeset
   128
  $\FINALLY$ just abbreviates $\ALSO~\FROM{calculation}$.  Note that
wenzelm
parents: 7981
diff changeset
   129
  ``$\FINALLY~\SHOW{}{\Var{thesis}}~\DOT$'' and
wenzelm
parents: 7981
diff changeset
   130
  ``$\FINALLY~\HAVE{}{\phi}~\DOT$'' are typical idioms for concluding
wenzelm
parents: 7981
diff changeset
   131
  calculational proofs.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   132
8619
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   133
\item [$\MOREOVER$ and $\ULTIMATELY$] are analogous to $\ALSO$ and $\FINALLY$,
63a0e1502e41 added 'moreover' and 'ultimately';
wenzelm
parents: 8594
diff changeset
   134
  but collect results only, without applying rules.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   135
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   136
\item [$\isarkeyword{print_trans_rules}$] prints the list of transitivity
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   137
  rules declared in the current context.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   138
8547
wenzelm
parents: 8517
diff changeset
   139
\item [$trans$] declares theorems as transitivity rules.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   140
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   141
\end{descr}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   142
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   143
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   144
\section{Named local contexts (cases)}\label{sec:cases}
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   145
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   146
\indexisarcmd{case}\indexisarcmd{print-cases}
10548
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   147
\indexisaratt{case-names}\indexisaratt{params}\indexisaratt{consumes}
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   148
\begin{matharray}{rcl}
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   149
  \isarcmd{case} & : & \isartrans{proof(state)}{proof(state)} \\
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   150
  \isarcmd{print_cases}^* & : & \isarkeep{proof} \\
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   151
  case_names & : & \isaratt \\
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   152
  params & : & \isaratt \\
10548
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   153
  consumes & : & \isaratt \\
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   154
\end{matharray}
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   155
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   156
Basically, Isar proof contexts are built up explicitly using commands like
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   157
$\FIXNAME$, $\ASSUMENAME$ etc.\ (see \S\ref{sec:proof-context}).  In typical
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   158
verification tasks this can become hard to manage, though.  In particular, a
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   159
large number of local contexts may emerge from case analysis or induction over
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   160
inductive sets and types.
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   161
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   162
\medskip
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   163
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   164
The $\CASENAME$ command provides a shorthand to refer to certain parts of
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   165
logical context symbolically.  Proof methods may provide an environment of
8507
d22fcea34cb7 untag: only name arg;
wenzelm
parents: 8483
diff changeset
   166
named ``cases'' of the form $c\colon \vec x, \vec \phi$.  Then the effect of
d22fcea34cb7 untag: only name arg;
wenzelm
parents: 8483
diff changeset
   167
$\CASE{c}$ is exactly the same as $\FIX{\vec x}~\ASSUME{c}{\vec\phi}$.
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   168
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   169
It is important to note that $\CASENAME$ does \emph{not} provide any means to
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   170
peek at the current goal state, which is treated as strictly non-observable in
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   171
Isar!  Instead, the cases considered here usually emerge in a canonical way
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   172
from certain pieces of specification that appear in the theory somewhere else
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   173
(e.g.\ in an inductive definition, or recursive function).  See also
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   174
\S\ref{sec:induct-method} for more details of how this works in HOL.
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   175
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   176
\medskip
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   177
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   178
Named cases may be exhibited in the current proof context only if both the
8547
wenzelm
parents: 8517
diff changeset
   179
proof method and the rules involved support this.  Case names and parameters
wenzelm
parents: 8517
diff changeset
   180
of basic rules may be declared by hand as well, by using appropriate
wenzelm
parents: 8517
diff changeset
   181
attributes.  Thus variant versions of rules that have been derived manually
wenzelm
parents: 8517
diff changeset
   182
may be used in advanced case analysis later.
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   183
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   184
\railalias{casenames}{case\_names}
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   185
\railterm{casenames}
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   186
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   187
\begin{rail}
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   188
  'case' nameref attributes?
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   189
  ;
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   190
  casenames (name + )
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   191
  ;
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   192
  'params' ((name * ) + 'and')
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   193
  ;
10548
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   194
  'consumes' nat?
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   195
  ;
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   196
\end{rail}
8547
wenzelm
parents: 8517
diff changeset
   197
%FIXME bug in rail
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   198
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   199
\begin{descr}
8507
d22fcea34cb7 untag: only name arg;
wenzelm
parents: 8483
diff changeset
   200
\item [$\CASE{c}$] invokes a named local context $c\colon \vec x, \vec \phi$,
8547
wenzelm
parents: 8517
diff changeset
   201
  as provided by an appropriate proof method (such as $cases$ and $induct$ in
wenzelm
parents: 8517
diff changeset
   202
  Isabelle/HOL, see \S\ref{sec:induct-method}).  The command $\CASE{c}$
wenzelm
parents: 8517
diff changeset
   203
  abbreviates $\FIX{\vec x}~\ASSUME{c}{\vec\phi}$.
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   204
\item [$\isarkeyword{print_cases}$] prints all local contexts of the current
8547
wenzelm
parents: 8517
diff changeset
   205
  state, using Isar proof language notation.  This is a diagnostic command;
wenzelm
parents: 8517
diff changeset
   206
  $undo$ does not apply.
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   207
\item [$case_names~\vec c$] declares names for the local contexts of premises
10627
wenzelm
parents: 10548
diff changeset
   208
  of some theorem; $\vec c$ refers to the \emph{suffix} of the list of
wenzelm
parents: 10548
diff changeset
   209
  premises.
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   210
\item [$params~\vec p@1 \dots \vec p@n$] renames the innermost parameters of
8547
wenzelm
parents: 8517
diff changeset
   211
  premises $1, \dots, n$ of some theorem.  An empty list of names may be given
wenzelm
parents: 8517
diff changeset
   212
  to skip positions, leaving the present parameters unchanged.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   213
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   214
  Note that the default usage of case rules does \emph{not} directly expose
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   215
  parameters to the proof context (see also \S\ref{sec:induct-method-proper}).
10548
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   216
\item [$consumes~n$] declares the number of ``major premises'' of a rule,
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   217
  i.e.\ the number of facts to be consumed when it is applied by an
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   218
  appropriate proof method (cf.\ \S\ref{sec:induct-method}).  The default
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   219
  value of $consumes$ is $n = 1$, which is appropriate for the usual kind of
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   220
  cases and induction rules for inductive sets (cf.\ \S\ref{sec:inductive}).
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   221
  Rules without any $consumes$ declaration given are treated as if
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   222
  $consumes~0$ had been specified.
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   223
  
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   224
  Note that explicit $consumes$ declarations are only rarely needed; this is
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   225
  already taken care of automatically by the higher-level $cases$ and $induct$
e8c774c12105 'consumes' att;
wenzelm
parents: 10318
diff changeset
   226
  declarations, see also \S\ref{sec:induct-att}.
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   227
\end{descr}
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   228
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   229
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   230
\section{Generalized existence}\label{sec:obtain}
7135
wenzelm
parents:
diff changeset
   231
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   232
\indexisarcmd{obtain}
7135
wenzelm
parents:
diff changeset
   233
\begin{matharray}{rcl}
9480
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   234
  \isarcmd{obtain} & : & \isartrans{proof(state)}{proof(prove)} \\
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   235
\end{matharray}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   236
9480
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   237
Generalized existence means that additional elements with certain properties
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   238
may introduced in the current context.  Technically, the $\OBTAINNAME$
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   239
language element is like a declaration of $\FIXNAME$ and $\ASSUMENAME$ (see
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   240
also see \S\ref{sec:proof-context}), together with a soundness proof of its
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   241
additional claim.  According to the nature of existential reasoning,
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   242
assumptions get eliminated from any result exported from the context later,
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   243
provided that the corresponding parameters do \emph{not} occur in the
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   244
conclusion.
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   245
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   246
\begin{rail}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   247
  'obtain' (vars + 'and') comment? \\ 'where' (assm comment? + 'and')
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   248
  ;
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   249
\end{rail}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   250
9480
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   251
$\OBTAINNAME$ is defined as a derived Isar command as follows, where $\vec b$
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   252
shall refer to (optional) facts indicated for forward chaining.
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   253
\begin{matharray}{l}
9480
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   254
  \langle facts~\vec b\rangle \\
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   255
  \OBTAIN{\vec x}{a}{\vec \phi}~~\langle proof\rangle \equiv {} \\[1ex]
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   256
  \quad \BG \\
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   257
  \qquad \FIX{thesis} \\
10160
wenzelm
parents: 10154
diff changeset
   258
  \qquad \ASSUME{that~[simp, intro]}{\All{\vec x} \vec\phi \Imp thesis} \\
9480
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   259
  \qquad \FROM{\vec b}~\HAVE{}{thesis}~~\langle proof\rangle \\
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   260
  \quad \EN \\
10154
wenzelm
parents: 10031
diff changeset
   261
  \quad \FIX{\vec x}~\ASSUMENAME^\ast~a\colon~\vec\phi \\
7135
wenzelm
parents:
diff changeset
   262
\end{matharray}
wenzelm
parents:
diff changeset
   263
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   264
Typically, the soundness proof is relatively straight-forward, often just by
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   265
canonical automated tools such as $\BY{simp}$ (see \S\ref{sec:simp}) or
9480
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   266
$\BY{blast}$ (see \S\ref{sec:classical-auto}).  Accordingly, the ``$that$''
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   267
reduction above is declared as simplification and introduction rule.
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   268
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   269
\medskip
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   270
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   271
In a sense, $\OBTAINNAME$ represents at the level of Isar proofs what would be
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   272
meta-logical existential quantifiers and conjunctions.  This concept has a
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   273
broad range of useful applications, ranging from plain elimination (or even
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   274
introduction) of object-level existentials and conjunctions, to elimination
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   275
over results of symbolic evaluation of recursive definitions, for example.
9480
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   276
Also note that $\OBTAINNAME$ without parameters acts much like $\HAVENAME$,
7afb808b6b3e updated 'obtain';
wenzelm
parents: 9438
diff changeset
   277
where the result is treated as an assumption.
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   278
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   279
10031
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
   280
\section{Miscellaneous methods and attributes}\label{sec:misc-methods}
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   281
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   282
\indexisarmeth{unfold}\indexisarmeth{fold}\indexisarmeth{insert}
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   283
\indexisarmeth{erule}\indexisarmeth{drule}\indexisarmeth{frule}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   284
\indexisarmeth{fail}\indexisarmeth{succeed}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   285
\begin{matharray}{rcl}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   286
  unfold & : & \isarmeth \\
10741
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   287
  fold & : & \isarmeth \\
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   288
  insert & : & \isarmeth \\[0.5ex]
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   289
  erule^* & : & \isarmeth \\
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   290
  drule^* & : & \isarmeth \\
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   291
  frule^* & : & \isarmeth \\[0.5ex]
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   292
  succeed & : & \isarmeth \\
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   293
  fail & : & \isarmeth \\
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   294
\end{matharray}
7135
wenzelm
parents:
diff changeset
   295
wenzelm
parents:
diff changeset
   296
\begin{rail}
10741
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   297
  ('fold' | 'unfold' | 'insert') thmrefs
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   298
  ;
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   299
  ('erule' | 'drule' | 'frule') ('('nat')')? thmrefs
7135
wenzelm
parents:
diff changeset
   300
  ;
wenzelm
parents:
diff changeset
   301
\end{rail}
wenzelm
parents:
diff changeset
   302
7167
wenzelm
parents: 7141
diff changeset
   303
\begin{descr}
8547
wenzelm
parents: 8517
diff changeset
   304
\item [$unfold~\vec a$ and $fold~\vec a$] expand and fold back again the given
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   305
  meta-level definitions throughout all goals; any facts provided are inserted
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   306
  into the goal and subject to rewriting as well.
10741
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   307
\item [$insert~\vec a$] inserts theorems as facts into all goals of the proof
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   308
  state.  Note that current facts indicated for forward chaining are ignored.
8547
wenzelm
parents: 8517
diff changeset
   309
\item [$erule~\vec a$, $drule~\vec a$, and $frule~\vec a$] are similar to the
wenzelm
parents: 8517
diff changeset
   310
  basic $rule$ method (see \S\ref{sec:pure-meth-att}), but apply rules by
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   311
  elim-resolution, destruct-resolution, and forward-resolution, respectively
10741
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   312
  \cite{isabelle-ref}.  The optional natural number argument (default $0$)
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   313
  specifies additional assumption steps to be performed.
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   314
  
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   315
  Note that these methods are improper ones, mainly serving for
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   316
  experimentation and tactic script emulation.  Different modes of basic rule
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   317
  application are usually expressed in Isar at the proof language level,
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   318
  rather than via implicit proof state manipulations.  For example, a proper
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   319
  single-step elimination would be done using the basic $rule$ method, with
e56ac1863f2c 'insert' made proper;
wenzelm
parents: 10627
diff changeset
   320
  forward chaining of current facts.
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   321
\item [$succeed$] yields a single (unchanged) result; it is the identity of
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   322
  the ``\texttt{,}'' method combinator (cf.\ \S\ref{sec:syn-meth}).
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   323
\item [$fail$] yields an empty result sequence; it is the identity of the
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   324
  ``\texttt{|}'' method combinator (cf.\ \S\ref{sec:syn-meth}).
7167
wenzelm
parents: 7141
diff changeset
   325
\end{descr}
7135
wenzelm
parents:
diff changeset
   326
10318
wenzelm
parents: 10223
diff changeset
   327
\indexisaratt{tagged}\indexisaratt{untagged}
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   328
\indexisaratt{THEN}\indexisaratt{COMP}
10318
wenzelm
parents: 10223
diff changeset
   329
\indexisaratt{where}\indexisaratt{unfolded}\indexisaratt{folded}
wenzelm
parents: 10223
diff changeset
   330
\indexisaratt{standard}\indexisaratt{elim-format}
wenzelm
parents: 10223
diff changeset
   331
\indexisaratt{no-vars}\indexisaratt{exported}
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   332
\begin{matharray}{rcl}
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   333
  tagged & : & \isaratt \\
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   334
  untagged & : & \isaratt \\[0.5ex]
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   335
  THEN & : & \isaratt \\
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   336
  COMP & : & \isaratt \\[0.5ex]
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   337
  where & : & \isaratt \\[0.5ex]
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   338
  unfolded & : & \isaratt \\
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   339
  folded & : & \isaratt \\[0.5ex]
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   340
  standard & : & \isaratt \\
9941
fe05af7ec816 renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents: 9936
diff changeset
   341
  elim_format & : & \isaratt \\
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
   342
  no_vars^* & : & \isaratt \\
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   343
  exported^* & : & \isaratt \\
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   344
\end{matharray}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   345
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   346
\begin{rail}
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   347
  'tagged' (nameref+)
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   348
  ;
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   349
  'untagged' name
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   350
  ;
10154
wenzelm
parents: 10031
diff changeset
   351
  ('THEN' | 'COMP') ('[' nat ']')? thmref
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   352
  ;
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   353
  'where' (name '=' term * 'and')
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   354
  ;
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   355
  ('unfolded' | 'folded') thmrefs
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   356
  ;
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   357
\end{rail}
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   358
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   359
\begin{descr}
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   360
\item [$tagged~name~args$ and $untagged~name$] add and remove $tags$ of some
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   361
  theorem.  Tags may be any list of strings that serve as comment for some
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   362
  tools (e.g.\ $\LEMMANAME$ causes the tag ``$lemma$'' to be added to the
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   363
  result).  The first string is considered the tag name, the rest its
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   364
  arguments.  Note that untag removes any tags of the same name.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   365
\item [$THEN~n~a$ and $COMP~n~a$] compose rules.  $THEN$ resolves with the
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   366
  $n$-th premise of $a$; the $COMP$ version skips the automatic lifting
8547
wenzelm
parents: 8517
diff changeset
   367
  process that is normally intended (cf.\ \texttt{RS} and \texttt{COMP} in
wenzelm
parents: 8517
diff changeset
   368
  \cite[\S5]{isabelle-ref}).
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   369
\item [$where~\vec x = \vec t$] perform named instantiation of schematic
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   370
  variables occurring in a theorem.  Unlike instantiation tactics such as
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   371
  $rule_tac$ (see \S\ref{sec:tactic-commands}), actual schematic variables
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   372
  have to be specified (e.g.\ $\Var{x@3}$).
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   373
\item [$unfolded~\vec a$ and $folded~\vec a$] expand and fold back again the
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   374
  given meta-level definitions throughout a rule.
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   375
\item [$standard$] puts a theorem into the standard form of object-rules, just
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   376
  as the ML function \texttt{standard} (see \cite[\S5]{isabelle-ref}).
9941
fe05af7ec816 renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents: 9936
diff changeset
   377
\item [$elim_format$] turns a destruction rule into elimination rule format;
fe05af7ec816 renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents: 9936
diff changeset
   378
  see also the ML function \texttt{make\_elim} (see \cite{isabelle-ref}).
9232
96722b04f2ae added no_vars att;
wenzelm
parents: 9005
diff changeset
   379
\item [$no_vars$] replaces schematic variables by free ones; this is mainly
96722b04f2ae added no_vars att;
wenzelm
parents: 9005
diff changeset
   380
  for tuning output of pretty printed theorems.
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   381
\item [$exported$] lifts a local result out of the current proof context,
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   382
  generalizing all fixed variables and discharging all assumptions.  Note that
8547
wenzelm
parents: 8517
diff changeset
   383
  proper incremental export is already done as part of the basic Isar
wenzelm
parents: 8517
diff changeset
   384
  machinery.  This attribute is mainly for experimentation.
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   385
\end{descr}
7135
wenzelm
parents:
diff changeset
   386
wenzelm
parents:
diff changeset
   387
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   388
\section{Tactic emulations}\label{sec:tactics}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   389
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   390
The following improper proof methods emulate traditional tactics.  These admit
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   391
direct access to the goal state, which is normally considered harmful!  In
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   392
particular, this may involve both numbered goal addressing (default 1), and
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   393
dynamic instantiation within the scope of some subgoal.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   394
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   395
\begin{warn}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   396
  Dynamic instantiations are read and type-checked according to a subgoal of
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   397
  the current dynamic goal state, rather than the static proof context!  In
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   398
  particular, locally fixed variables and term abbreviations may not be
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   399
  included in the term specifications.  Thus schematic variables are left to
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   400
  be solved by unification with certain parts of the subgoal involved.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   401
\end{warn}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   402
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   403
Note that the tactic emulation proof methods in Isabelle/Isar are consistently
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   404
named $foo_tac$.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   405
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   406
\indexisarmeth{rule-tac}\indexisarmeth{erule-tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   407
\indexisarmeth{drule-tac}\indexisarmeth{frule-tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   408
\indexisarmeth{cut-tac}\indexisarmeth{thin-tac}
9642
d8d1f70024bd fixed indexing;
wenzelm
parents: 9614
diff changeset
   409
\indexisarmeth{subgoal-tac}\indexisarmeth{rename-tac}
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   410
\indexisarmeth{rotate-tac}\indexisarmeth{tactic}
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   411
\begin{matharray}{rcl}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   412
  rule_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   413
  erule_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   414
  drule_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   415
  frule_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   416
  cut_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   417
  thin_tac^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   418
  subgoal_tac^* & : & \isarmeth \\
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   419
  rename_tac^* & : & \isarmeth \\
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   420
  rotate_tac^* & : & \isarmeth \\
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   421
  tactic^* & : & \isarmeth \\
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   422
\end{matharray}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   423
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   424
\railalias{ruletac}{rule\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   425
\railterm{ruletac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   426
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   427
\railalias{eruletac}{erule\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   428
\railterm{eruletac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   429
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   430
\railalias{druletac}{drule\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   431
\railterm{druletac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   432
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   433
\railalias{fruletac}{frule\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   434
\railterm{fruletac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   435
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   436
\railalias{cuttac}{cut\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   437
\railterm{cuttac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   438
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   439
\railalias{thintac}{thin\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   440
\railterm{thintac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   441
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   442
\railalias{subgoaltac}{subgoal\_tac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   443
\railterm{subgoaltac}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   444
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   445
\railalias{renametac}{rename\_tac}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   446
\railterm{renametac}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   447
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   448
\railalias{rotatetac}{rotate\_tac}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   449
\railterm{rotatetac}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   450
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   451
\begin{rail}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   452
  ( ruletac | eruletac | druletac | fruletac | cuttac | thintac ) goalspec?
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   453
  ( insts thmref | thmrefs )
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   454
  ;
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   455
  subgoaltac goalspec? (prop +)
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   456
  ;
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   457
  renametac goalspec? (name +)
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   458
  ;
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   459
  rotatetac goalspec? int?
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   460
  ;
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   461
  'tactic' text
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   462
  ;
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   463
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   464
  insts: ((name '=' term) + 'and') 'in'
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   465
  ;
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   466
\end{rail}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   467
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   468
\begin{descr}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   469
\item [$rule_tac$ etc.] do resolution of rules with explicit instantiation.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   470
  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
   471
  \cite[\S3]{isabelle-ref}).
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   472
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   473
  Note that multiple rules may be only given there is no instantiation.  Then
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   474
  $rule_tac$ is the same as \texttt{resolve_tac} in ML (see
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   475
  \cite[\S3]{isabelle-ref}).
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   476
\item [$cut_tac$] inserts facts into the proof state as assumption of a
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   477
  subgoal, see also \texttt{cut_facts_tac} in \cite[\S3]{isabelle-ref}.  Note
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   478
  that the scope of schmatic variables is spread over the main goal statement.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   479
  Instantiations may be given as well, see also ML tactic
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   480
  \texttt{cut_inst_tac} in \cite[\S3]{isabelle-ref}.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   481
\item [$thin_tac~\phi$] deletes the specified assumption from a subgoal; note
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   482
  that $\phi$ may contain schematic variables.  See also \texttt{thin_tac} in
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   483
  \cite[\S3]{isabelle-ref}.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   484
\item [$subgoal_tac~\phi$] adds $\phi$ as an assumption to a subgoal.  See
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   485
  also \texttt{subgoal_tac} and \texttt{subgoals_tac} in
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   486
  \cite[\S3]{isabelle-ref}.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   487
\item [$rename_tac~\vec x$] renames parameters of a goal according to the list
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   488
  $\vec x$, which refers to the \emph{suffix} of variables.
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   489
\item [$rotate_tac~n$] rotates the assumptions of a goal by $n$ positions:
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   490
  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
   491
  negative; the default value is $1$.  See also \texttt{rotate_tac} in
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   492
  \cite[\S3]{isabelle-ref}.
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   493
\item [$tactic~text$] produces a proof method from any ML text of type
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   494
  \texttt{tactic}.  Apart from the usual ML environment and the current
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   495
  implicit theory context, the ML code may refer to the following locally
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   496
  bound values:
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   497
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   498
%%FIXME ttbox produces too much trailing space (why?)
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   499
{\footnotesize\begin{verbatim}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   500
val ctxt  : Proof.context
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   501
val facts : thm list
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   502
val thm   : string -> thm
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   503
val thms  : string -> thm list
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   504
\end{verbatim}}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   505
  Here \texttt{ctxt} refers to the current proof context, \texttt{facts}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   506
  indicates any current facts for forward-chaining, and
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   507
  \texttt{thm}~/~\texttt{thms} retrieve named facts (including global
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   508
  theorems) from the context.
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   509
\end{descr}
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   510
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   511
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   512
\section{The Simplifier}\label{sec:simplifier}
7135
wenzelm
parents:
diff changeset
   513
7321
wenzelm
parents: 7319
diff changeset
   514
\subsection{Simplification methods}\label{sec:simp}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   515
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   516
\indexisarmeth{simp}\indexisarmeth{simp-all}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   517
\begin{matharray}{rcl}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   518
  simp & : & \isarmeth \\
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   519
  simp_all & : & \isarmeth \\
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   520
\end{matharray}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   521
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   522
\railalias{simpall}{simp\_all}
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   523
\railterm{simpall}
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   524
8704
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   525
\railalias{noasm}{no\_asm}
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   526
\railterm{noasm}
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   527
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   528
\railalias{noasmsimp}{no\_asm\_simp}
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   529
\railterm{noasmsimp}
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   530
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   531
\railalias{noasmuse}{no\_asm\_use}
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   532
\railterm{noasmuse}
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   533
11128
48c63b87566e index mod syntax;
wenzelm
parents: 11100
diff changeset
   534
\indexouternonterm{simpmod}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   535
\begin{rail}
8706
wenzelm
parents: 8704
diff changeset
   536
  ('simp' | simpall) ('!' ?) opt? (simpmod * )
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   537
  ;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   538
8811
6ec0c8f9d68d improved syntax of method options (no_asm) etc;
wenzelm
parents: 8706
diff changeset
   539
  opt: '(' (noasm | noasmsimp | noasmuse) ')'
8704
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   540
  ;
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   541
  simpmod: ('add' | 'del' | 'only' | 'cong' (() | 'add' | 'del') |
9847
32ce11c3f6b1 added 'iff' modifier;
wenzelm
parents: 9799
diff changeset
   542
    'split' (() | 'add' | 'del')) ':' thmrefs
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   543
  ;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   544
\end{rail}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   545
7321
wenzelm
parents: 7319
diff changeset
   546
\begin{descr}
8547
wenzelm
parents: 8517
diff changeset
   547
\item [$simp$] invokes Isabelle's simplifier, after declaring additional rules
8594
d2e2a3df6871 rail token vs. terminal;
wenzelm
parents: 8547
diff changeset
   548
  according to the arguments given.  Note that the \railtterm{only} modifier
8547
wenzelm
parents: 8517
diff changeset
   549
  first removes all other rewrite rules, congruences, and looper tactics
8594
d2e2a3df6871 rail token vs. terminal;
wenzelm
parents: 8547
diff changeset
   550
  (including splits), and then behaves like \railtterm{add}.
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   551
  
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   552
  \medskip The \railtterm{cong} modifiers add or delete Simplifier congruence
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   553
  rules (see also \cite{isabelle-ref}), the default is to add.
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   554
  
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   555
  \medskip The \railtterm{split} modifiers add or delete rules for the
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   556
  Splitter (see also \cite{isabelle-ref}), the default is to add.  This works
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   557
  only if the Simplifier method has been properly setup to include the
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   558
  Splitter (all major object logics such HOL, HOLCF, FOL, ZF do this already).
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   559
\item [$simp_all$] is similar to $simp$, but acts on all goals.
7321
wenzelm
parents: 7319
diff changeset
   560
\end{descr}
wenzelm
parents: 7319
diff changeset
   561
8704
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   562
By default, the Simplifier methods are based on \texttt{asm_full_simp_tac}
8706
wenzelm
parents: 8704
diff changeset
   563
internally \cite[\S10]{isabelle-ref}, which means that assumptions are both
wenzelm
parents: 8704
diff changeset
   564
simplified as well as used in simplifying the conclusion.  In structured
wenzelm
parents: 8704
diff changeset
   565
proofs this is usually quite well behaved in practice: just the local premises
wenzelm
parents: 8704
diff changeset
   566
of the actual goal are involved, additional facts may inserted via explicit
wenzelm
parents: 8704
diff changeset
   567
forward-chaining (using $\THEN$, $\FROMNAME$ etc.).  The full context of
wenzelm
parents: 8704
diff changeset
   568
assumptions is only included if the ``$!$'' (bang) argument is given, which
wenzelm
parents: 8704
diff changeset
   569
should be used with some care, though.
7321
wenzelm
parents: 7319
diff changeset
   570
8704
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   571
Additional Simplifier options may be specified to tune the behavior even
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   572
further: $(no_asm)$ means assumptions are ignored completely (cf.\
8811
6ec0c8f9d68d improved syntax of method options (no_asm) etc;
wenzelm
parents: 8706
diff changeset
   573
\texttt{simp_tac}), $(no_asm_simp)$ means assumptions are used in the
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   574
simplification of the conclusion but are not themselves simplified (cf.\
8811
6ec0c8f9d68d improved syntax of method options (no_asm) etc;
wenzelm
parents: 8706
diff changeset
   575
\texttt{asm_simp_tac}), and $(no_asm_use)$ means assumptions are simplified
6ec0c8f9d68d improved syntax of method options (no_asm) etc;
wenzelm
parents: 8706
diff changeset
   576
but are not used in the simplification of each other or the conclusion (cf.
8704
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   577
\texttt{full_simp_tac}).
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   578
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   579
\medskip
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   580
f76f41f24c44 Simplifier options;
wenzelm
parents: 8667
diff changeset
   581
The Splitter package is usually configured to work as part of the Simplifier.
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   582
The effect of repeatedly applying \texttt{split_tac} can be simulated by
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   583
$(simp~only\colon~split\colon~\vec a)$.  There is also a separate $split$
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   584
method available for single-step case splitting, see \S\ref{sec:basic-eq}.
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   585
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   586
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   587
\subsection{Declaring rules}
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   588
8667
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
   589
\indexisarcmd{print-simpset}
8638
21cb46716f32 added 'cong' att;
wenzelm
parents: 8619
diff changeset
   590
\indexisaratt{simp}\indexisaratt{split}\indexisaratt{cong}
7321
wenzelm
parents: 7319
diff changeset
   591
\begin{matharray}{rcl}
10154
wenzelm
parents: 10031
diff changeset
   592
  print_simpset^* & : & \isarkeep{theory~|~proof} \\
7321
wenzelm
parents: 7319
diff changeset
   593
  simp & : & \isaratt \\
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   594
  cong & : & \isaratt \\
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   595
  split & : & \isaratt \\
7321
wenzelm
parents: 7319
diff changeset
   596
\end{matharray}
wenzelm
parents: 7319
diff changeset
   597
wenzelm
parents: 7319
diff changeset
   598
\begin{rail}
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   599
  ('simp' | 'cong' | 'split') (() | 'add' | 'del')
7321
wenzelm
parents: 7319
diff changeset
   600
  ;
wenzelm
parents: 7319
diff changeset
   601
\end{rail}
wenzelm
parents: 7319
diff changeset
   602
wenzelm
parents: 7319
diff changeset
   603
\begin{descr}
8667
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
   604
\item [$print_simpset$] prints the collection of rules declared to the
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
   605
  Simplifier, which is also known as ``simpset'' internally
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
   606
  \cite{isabelle-ref}.  This is a diagnostic command; $undo$ does not apply.
8547
wenzelm
parents: 8517
diff changeset
   607
\item [$simp$] declares simplification rules.
8638
21cb46716f32 added 'cong' att;
wenzelm
parents: 8619
diff changeset
   608
\item [$cong$] declares congruence rules.
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   609
\item [$split$] declares case split rules.
7321
wenzelm
parents: 7319
diff changeset
   610
\end{descr}
7319
wenzelm
parents: 7315
diff changeset
   611
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   612
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   613
\subsection{Forward simplification}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   614
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   615
\indexisaratt{simplified}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   616
\begin{matharray}{rcl}
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   617
  simplified & : & \isaratt \\
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   618
\end{matharray}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   619
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   620
\begin{rail}
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   621
  'simplified' opt?
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   622
  ;
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   623
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   624
  opt: '(' (noasm | noasmsimp | noasmuse) ')'
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   625
  ;
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   626
\end{rail}
7905
wenzelm
parents: 7897
diff changeset
   627
9905
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   628
\begin{descr}
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   629
\item [$simplified$] causes a theorem to be simplified according to the
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   630
  current Simplifier context (there are no separate arguments for declaring
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   631
  additional rules).  By default the result is fully simplified, including
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   632
  assumptions and conclusion.  The options $no_asm$ etc.\ restrict the
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   633
  Simplifier in the same way as the for the $simp$ method (see
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   634
  \S\ref{sec:simp}).
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   635
  
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   636
  The $simplified$ operation should be used only very rarely, usually for
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   637
  experimentation only.
14a71104a498 improved att names;
wenzelm
parents: 9847
diff changeset
   638
\end{descr}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   639
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   640
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   641
\section{Basic equational reasoning}\label{sec:basic-eq}
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   642
9703
bf65780eed02 added 'split' method;
wenzelm
parents: 9642
diff changeset
   643
\indexisarmeth{subst}\indexisarmeth{hypsubst}\indexisarmeth{split}\indexisaratt{symmetric}
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   644
\begin{matharray}{rcl}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   645
  subst & : & \isarmeth \\
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   646
  hypsubst^* & : & \isarmeth \\
9703
bf65780eed02 added 'split' method;
wenzelm
parents: 9642
diff changeset
   647
  split & : & \isarmeth \\
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   648
  symmetric & : & \isaratt \\
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   649
\end{matharray}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   650
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   651
\begin{rail}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   652
  'subst' thmref
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   653
  ;
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   654
  'split' ('(' 'asm' ')')? thmrefs
9703
bf65780eed02 added 'split' method;
wenzelm
parents: 9642
diff changeset
   655
  ;
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   656
\end{rail}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   657
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   658
These methods and attributes provide basic facilities for equational reasoning
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   659
that are intended for specialized applications only.  Normally, single step
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   660
reasoning would be performed by calculation (see \S\ref{sec:calculation}),
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   661
while the Simplifier is the canonical tool for automated normalization (see
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   662
\S\ref{sec:simplifier}).
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   663
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   664
\begin{descr}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   665
\item [$subst~thm$] performs a single substitution step using rule $thm$,
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   666
  which may be either a meta or object equality.
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   667
\item [$hypsubst$] performs substitution using some assumption.
9703
bf65780eed02 added 'split' method;
wenzelm
parents: 9642
diff changeset
   668
\item [$split~thms$] performs single-step case splitting using rules $thms$.
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   669
  By default, splitting is performed in the conclusion of a goal; the $asm$
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   670
  option indicates to operate on assumptions instead.
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   671
  
9703
bf65780eed02 added 'split' method;
wenzelm
parents: 9642
diff changeset
   672
  Note that the $simp$ method already involves repeated application of split
bf65780eed02 added 'split' method;
wenzelm
parents: 9642
diff changeset
   673
  rules as declared in the current context (see \S\ref{sec:simp}).
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   674
\item [$symmetric$] applies the symmetry rule of meta or object equality.
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   675
\end{descr}
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   676
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   677
9847
32ce11c3f6b1 added 'iff' modifier;
wenzelm
parents: 9799
diff changeset
   678
\section{The Classical Reasoner}\label{sec:classical}
7135
wenzelm
parents:
diff changeset
   679
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   680
\subsection{Basic methods}\label{sec:classical-basic}
7321
wenzelm
parents: 7319
diff changeset
   681
7974
34245feb6e82 improved;
wenzelm
parents: 7905
diff changeset
   682
\indexisarmeth{rule}\indexisarmeth{intro}
34245feb6e82 improved;
wenzelm
parents: 7905
diff changeset
   683
\indexisarmeth{elim}\indexisarmeth{default}\indexisarmeth{contradiction}
7321
wenzelm
parents: 7319
diff changeset
   684
\begin{matharray}{rcl}
wenzelm
parents: 7319
diff changeset
   685
  rule & : & \isarmeth \\
wenzelm
parents: 7319
diff changeset
   686
  intro & : & \isarmeth \\
wenzelm
parents: 7319
diff changeset
   687
  elim & : & \isarmeth \\
wenzelm
parents: 7319
diff changeset
   688
  contradiction & : & \isarmeth \\
wenzelm
parents: 7319
diff changeset
   689
\end{matharray}
wenzelm
parents: 7319
diff changeset
   690
wenzelm
parents: 7319
diff changeset
   691
\begin{rail}
8547
wenzelm
parents: 8517
diff changeset
   692
  ('rule' | 'intro' | 'elim') thmrefs?
7321
wenzelm
parents: 7319
diff changeset
   693
  ;
wenzelm
parents: 7319
diff changeset
   694
\end{rail}
wenzelm
parents: 7319
diff changeset
   695
wenzelm
parents: 7319
diff changeset
   696
\begin{descr}
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   697
\item [$rule$] as offered by the classical reasoner is a refinement over the
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   698
  primitive one (see \S\ref{sec:pure-meth-att}).  In case that no rules are
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   699
  provided as arguments, it automatically determines elimination and
7321
wenzelm
parents: 7319
diff changeset
   700
  introduction rules from the context (see also \S\ref{sec:classical-mod}).
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   701
  This is made the default method for basic proof steps, such as $\PROOFNAME$
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   702
  and ``$\DDOT$'' (two dots), see also \S\ref{sec:proof-steps} and
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   703
  \S\ref{sec:pure-meth-att}.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   704
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   705
\item [$intro$ and $elim$] repeatedly refine some goal by intro- or
7905
wenzelm
parents: 7897
diff changeset
   706
  elim-resolution, after having inserted any facts.  Omitting the arguments
8547
wenzelm
parents: 8517
diff changeset
   707
  refers to any suitable rules declared in the context, otherwise only the
wenzelm
parents: 8517
diff changeset
   708
  explicitly given ones may be applied.  The latter form admits better control
wenzelm
parents: 8517
diff changeset
   709
  of what actually happens, thus it is very appropriate as an initial method
wenzelm
parents: 8517
diff changeset
   710
  for $\PROOFNAME$ that splits up certain connectives of the goal, before
wenzelm
parents: 8517
diff changeset
   711
  entering the actual sub-proof.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   712
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   713
\item [$contradiction$] solves some goal by contradiction, deriving any result
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   714
  from both $\neg A$ and $A$.  Facts, which are guaranteed to participate, may
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   715
  appear in either order.
7321
wenzelm
parents: 7319
diff changeset
   716
\end{descr}
wenzelm
parents: 7319
diff changeset
   717
wenzelm
parents: 7319
diff changeset
   718
7981
wenzelm
parents: 7974
diff changeset
   719
\subsection{Automated methods}\label{sec:classical-auto}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   720
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   721
\indexisarmeth{blast}\indexisarmeth{fast}\indexisarmeth{slow}
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   722
\indexisarmeth{best}\indexisarmeth{safe}\indexisarmeth{clarify}
7321
wenzelm
parents: 7319
diff changeset
   723
\begin{matharray}{rcl}
9780
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
   724
  blast & : & \isarmeth \\
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
   725
  fast & : & \isarmeth \\
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   726
  slow & : & \isarmeth \\
9780
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
   727
  best & : & \isarmeth \\
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
   728
  safe & : & \isarmeth \\
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
   729
  clarify & : & \isarmeth \\
7321
wenzelm
parents: 7319
diff changeset
   730
\end{matharray}
wenzelm
parents: 7319
diff changeset
   731
11128
48c63b87566e index mod syntax;
wenzelm
parents: 11100
diff changeset
   732
\indexouternonterm{clamod}
7321
wenzelm
parents: 7319
diff changeset
   733
\begin{rail}
7905
wenzelm
parents: 7897
diff changeset
   734
  'blast' ('!' ?) nat? (clamod * )
7321
wenzelm
parents: 7319
diff changeset
   735
  ;
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   736
  ('fast' | 'slow' | 'best' | 'safe' | 'clarify') ('!' ?) (clamod * )
7321
wenzelm
parents: 7319
diff changeset
   737
  ;
wenzelm
parents: 7319
diff changeset
   738
9408
d3d56e1d2ec1 classical atts now intro! / intro / intro?;
wenzelm
parents: 9232
diff changeset
   739
  clamod: (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del') ':' thmrefs
7321
wenzelm
parents: 7319
diff changeset
   740
  ;
wenzelm
parents: 7319
diff changeset
   741
\end{rail}
wenzelm
parents: 7319
diff changeset
   742
wenzelm
parents: 7319
diff changeset
   743
\begin{descr}
wenzelm
parents: 7319
diff changeset
   744
\item [$blast$] refers to the classical tableau prover (see \texttt{blast_tac}
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   745
  in \cite[\S11]{isabelle-ref}).  The optional argument specifies a
10858
wenzelm
parents: 10741
diff changeset
   746
  user-supplied search bound (default 20).
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   747
\item [$fast$, $slow$, $best$, $safe$, and $clarify$] refer to the generic
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   748
  classical reasoner.  See \texttt{fast_tac}, \texttt{slow_tac},
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   749
  \texttt{best_tac}, \texttt{safe_tac}, and \texttt{clarify_tac} in
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   750
  \cite[\S11]{isabelle-ref} for more information.
7321
wenzelm
parents: 7319
diff changeset
   751
\end{descr}
wenzelm
parents: 7319
diff changeset
   752
wenzelm
parents: 7319
diff changeset
   753
Any of above methods support additional modifiers of the context of classical
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   754
rules.  Their semantics is analogous to the attributes given in
8547
wenzelm
parents: 8517
diff changeset
   755
\S\ref{sec:classical-mod}.  Facts provided by forward chaining are
wenzelm
parents: 8517
diff changeset
   756
inserted\footnote{These methods usually cannot make proper use of actual rules
wenzelm
parents: 8517
diff changeset
   757
  inserted that way, though.} into the goal before doing the search.  The
wenzelm
parents: 8517
diff changeset
   758
``!''~argument causes the full context of assumptions to be included as well.
wenzelm
parents: 8517
diff changeset
   759
This is slightly less hazardous than for the Simplifier (see
wenzelm
parents: 8517
diff changeset
   760
\S\ref{sec:simp}).
7321
wenzelm
parents: 7319
diff changeset
   761
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   762
9847
32ce11c3f6b1 added 'iff' modifier;
wenzelm
parents: 9799
diff changeset
   763
\subsection{Combined automated methods}\label{sec:clasimp}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   764
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   765
\indexisarmeth{auto}\indexisarmeth{force}\indexisarmeth{clarsimp}
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   766
\indexisarmeth{fastsimp}\indexisarmeth{slowsimp}\indexisarmeth{bestsimp}
7321
wenzelm
parents: 7319
diff changeset
   767
\begin{matharray}{rcl}
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   768
  auto & : & \isarmeth \\
7321
wenzelm
parents: 7319
diff changeset
   769
  force & : & \isarmeth \\
9438
6131037f8a11 removed slow, slow_best methods;
wenzelm
parents: 9408
diff changeset
   770
  clarsimp & : & \isarmeth \\
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   771
  fastsimp & : & \isarmeth \\
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   772
  slowsimp & : & \isarmeth \\
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   773
  bestsimp & : & \isarmeth \\
7321
wenzelm
parents: 7319
diff changeset
   774
\end{matharray}
wenzelm
parents: 7319
diff changeset
   775
11128
48c63b87566e index mod syntax;
wenzelm
parents: 11100
diff changeset
   776
\indexouternonterm{clasimpmod}
7321
wenzelm
parents: 7319
diff changeset
   777
\begin{rail}
9780
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
   778
  'auto' '!'? (nat nat)? (clasimpmod * )
d25d6a977ea6 added 'safe' method;
wenzelm
parents: 9711
diff changeset
   779
  ;
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   780
  ('force' | 'clarsimp' | 'fastsimp' | 'slowsimp' | 'bestsimp') '!'? (clasimpmod * )
7321
wenzelm
parents: 7319
diff changeset
   781
  ;
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   782
9711
75df6a20b0b3 'cong' modifiers;
wenzelm
parents: 9703
diff changeset
   783
  clasimpmod: ('simp' (() | 'add' | 'del' | 'only') |
10031
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
   784
    ('cong' | 'split') (() | 'add' | 'del') |
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
   785
    'iff' (((() | 'add') '?'?) | 'del') |
9408
d3d56e1d2ec1 classical atts now intro! / intro / intro?;
wenzelm
parents: 9232
diff changeset
   786
    (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del')) ':' thmrefs
7321
wenzelm
parents: 7319
diff changeset
   787
\end{rail}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   788
7321
wenzelm
parents: 7319
diff changeset
   789
\begin{descr}
9799
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   790
\item [$auto$, $force$, $clarsimp$, $fastsimp$, $slowsimp$, and $bestsimp$]
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   791
  provide access to Isabelle's combined simplification and classical reasoning
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   792
  tactics.  These correspond to \texttt{auto_tac}, \texttt{force_tac},
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   793
  \texttt{clarsimp_tac}, and Classical Reasoner tactics with the Simplifier
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   794
  added as wrapper, see \cite[\S11]{isabelle-ref} for more information.  The
038b018f86f5 'split' method: '(asm)' option;
wenzelm
parents: 9780
diff changeset
   795
  modifier arguments correspond to those given in \S\ref{sec:simp} and
9606
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   796
  \S\ref{sec:classical-auto}.  Just note that the ones related to the
1bf495402ae9 moved tactic emulation methods here;
wenzelm
parents: 9480
diff changeset
   797
  Simplifier are prefixed by \railtterm{simp} here.
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
   798
7987
wenzelm
parents: 7981
diff changeset
   799
  Facts provided by forward chaining are inserted into the goal before doing
wenzelm
parents: 7981
diff changeset
   800
  the search.  The ``!''~argument causes the full context of assumptions to be
wenzelm
parents: 7981
diff changeset
   801
  included as well.
7321
wenzelm
parents: 7319
diff changeset
   802
\end{descr}
wenzelm
parents: 7319
diff changeset
   803
7987
wenzelm
parents: 7981
diff changeset
   804
8483
b437907f9b26 Named local contexts (cases);
wenzelm
parents: 8203
diff changeset
   805
\subsection{Declaring rules}\label{sec:classical-mod}
7135
wenzelm
parents:
diff changeset
   806
8667
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
   807
\indexisarcmd{print-claset}
7391
b7ca64c8fa64 'iff' attribute;
wenzelm
parents: 7356
diff changeset
   808
\indexisaratt{intro}\indexisaratt{elim}\indexisaratt{dest}
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
   809
\indexisaratt{iff}\indexisaratt{rule}
7321
wenzelm
parents: 7319
diff changeset
   810
\begin{matharray}{rcl}
10154
wenzelm
parents: 10031
diff changeset
   811
  print_claset^* & : & \isarkeep{theory~|~proof} \\
7321
wenzelm
parents: 7319
diff changeset
   812
  intro & : & \isaratt \\
wenzelm
parents: 7319
diff changeset
   813
  elim & : & \isaratt \\
wenzelm
parents: 7319
diff changeset
   814
  dest & : & \isaratt \\
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
   815
  rule & : & \isaratt \\
7391
b7ca64c8fa64 'iff' attribute;
wenzelm
parents: 7356
diff changeset
   816
  iff & : & \isaratt \\
7321
wenzelm
parents: 7319
diff changeset
   817
\end{matharray}
7135
wenzelm
parents:
diff changeset
   818
7321
wenzelm
parents: 7319
diff changeset
   819
\begin{rail}
9408
d3d56e1d2ec1 classical atts now intro! / intro / intro?;
wenzelm
parents: 9232
diff changeset
   820
  ('intro' | 'elim' | 'dest') ('!' | () | '?')
7321
wenzelm
parents: 7319
diff changeset
   821
  ;
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
   822
  'rule' 'del'
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
   823
  ;
10031
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
   824
  'iff' (((() | 'add') '?'?) | 'del')
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
   825
  ;
7321
wenzelm
parents: 7319
diff changeset
   826
\end{rail}
7135
wenzelm
parents:
diff changeset
   827
7321
wenzelm
parents: 7319
diff changeset
   828
\begin{descr}
8667
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
   829
\item [$print_claset$] prints the collection of rules declared to the
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
   830
  Classical Reasoner, which is also known as ``simpset'' internally
4230d17073ea print_simpset / print_claset command;
wenzelm
parents: 8638
diff changeset
   831
  \cite{isabelle-ref}.  This is a diagnostic command; $undo$ does not apply.
8517
062e6cd78534 obtain;
wenzelm
parents: 8507
diff changeset
   832
\item [$intro$, $elim$, and $dest$] declare introduction, elimination, and
11332
11ab8c8ce694 extended doc for iff attribute
oheimb
parents: 11128
diff changeset
   833
  destruction rules, respectively.  By default, rules are considered as
9408
d3d56e1d2ec1 classical atts now intro! / intro / intro?;
wenzelm
parents: 9232
diff changeset
   834
  \emph{unsafe} (i.e.\ not applied blindly without backtracking), while a
d3d56e1d2ec1 classical atts now intro! / intro / intro?;
wenzelm
parents: 9232
diff changeset
   835
  single ``!'' classifies as \emph{safe}, and ``?'' as \emph{extra} (i.e.\ not
d3d56e1d2ec1 classical atts now intro! / intro / intro?;
wenzelm
parents: 9232
diff changeset
   836
  applied in the search-oriented automated methods, but only in single-step
d3d56e1d2ec1 classical atts now intro! / intro / intro?;
wenzelm
parents: 9232
diff changeset
   837
  methods such as $rule$).
11332
11ab8c8ce694 extended doc for iff attribute
oheimb
parents: 11128
diff changeset
   838
\item [$rule~del$] deletes introduction, elimination, or destruction rules from
9936
f080397656d8 renamed "delrule" to "rule del";
wenzelm
parents: 9905
diff changeset
   839
  the context.
11442
8682a88c3d6a slight improvement for iff attribute
oheimb
parents: 11333
diff changeset
   840
\item [$iff$] declares a (possibly conditional) ``safe'' rule to the context in
8682a88c3d6a slight improvement for iff attribute
oheimb
parents: 11333
diff changeset
   841
  several ways.   The rule is declared as a rewrite rule to the Simplifier. 
8682a88c3d6a slight improvement for iff attribute
oheimb
parents: 11333
diff changeset
   842
  Furthermore, it is 
11332
11ab8c8ce694 extended doc for iff attribute
oheimb
parents: 11128
diff changeset
   843
  declared in several ways (depending on its structure) to the Classical 
11ab8c8ce694 extended doc for iff attribute
oheimb
parents: 11128
diff changeset
   844
  Reasoner for aggressive use, which would normally be indicated by ``!'').
11ab8c8ce694 extended doc for iff attribute
oheimb
parents: 11128
diff changeset
   845
  If the rule is an equivalence, the two corresponding implications are 
11469
57b072f00626 removed the warning from [iff]
oheimb
parents: 11442
diff changeset
   846
  declared as introduction and destruction rules. Otherwise, 
57b072f00626 removed the warning from [iff]
oheimb
parents: 11442
diff changeset
   847
  if the rule is an inequality, the corresponding negation elimination rule
11442
8682a88c3d6a slight improvement for iff attribute
oheimb
parents: 11333
diff changeset
   848
  is declared, else the rule itself is declared as an introduction rule.
10031
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
   849
  
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
   850
  The ``?'' version of $iff$ declares ``extra'' Classical Reasoner rules only,
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
   851
  and omits the Simplifier declaration.  Thus the declaration does not have
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
   852
  any effect on automated proof tools, but only on simple methods such as
12fd0fcf755a attribute / modifier 'iff': support "?" mode;
wenzelm
parents: 9941
diff changeset
   853
  $rule$ (see \S\ref{sec:misc-methods}).
7321
wenzelm
parents: 7319
diff changeset
   854
\end{descr}
7135
wenzelm
parents:
diff changeset
   855
8203
2fcc6017cb72 intro/elim/dest attributes: changed ! / !! flags to ? / ??;
wenzelm
parents: 8195
diff changeset
   856
11691
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   857
\section{Proof by cases and induction}\label{sec:induct-method}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   858
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   859
\subsection{Proof methods}\label{sec:induct-method-proper}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   860
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   861
\indexisarmeth{cases}\indexisarmeth{induct}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   862
\begin{matharray}{rcl}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   863
  cases & : & \isarmeth \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   864
  induct & : & \isarmeth \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   865
\end{matharray}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   866
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   867
The $cases$ and $induct$ methods provide a uniform interface to case analysis
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   868
and induction over datatypes, inductive sets, and recursive functions.  The
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   869
corresponding rules may be specified and instantiated in a casual manner.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   870
Furthermore, these methods provide named local contexts that may be invoked
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   871
via the $\CASENAME$ proof command within the subsequent proof text (cf.\ 
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   872
\S\ref{sec:cases}).  This accommodates compact proof texts even when reasoning
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   873
about large specifications.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   874
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   875
Note that the full spectrum of this generic functionality is currently only
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   876
supported by Isabelle/HOL, when used in conjunction with advanced definitional
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   877
packages (see especially \S\ref{sec:datatype} and \S\ref{sec:inductive}).
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   878
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   879
\begin{rail}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   880
  'cases' spec
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   881
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   882
  'induct' spec
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   883
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   884
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   885
  spec: open? args rule? params?
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   886
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   887
  open: '(' 'open' ')'
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   888
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   889
  args: (insts * 'and') 
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   890
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   891
  rule: ('type' | 'set') ':' nameref | 'rule' ':' thmref
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   892
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   893
  params: 'of' ':' insts
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   894
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   895
\end{rail}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   896
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   897
\begin{descr}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   898
\item [$cases~insts~R~ps$] applies method $rule$ with an appropriate case
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   899
  distinction theorem, instantiated to the subjects $insts$.  Symbolic case
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   900
  names are bound according to the rule's local contexts.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   901
  
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   902
  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
   903
  passed to the $cases$ method:
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   904
  \begin{matharray}{llll}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   905
    \Text{facts}    &       & \Text{arguments} & \Text{rule} \\\hline
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   906
                    & cases &           & \Text{classical case split} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   907
                    & cases & t         & \Text{datatype exhaustion (type of $t$)} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   908
    \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
   909
    \dots           & cases & \dots ~ R & \Text{explicit rule $R$} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   910
  \end{matharray}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   911
  
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   912
  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
   913
  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
   914
  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
   915
  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
   916
  usually the same for all cases).
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   917
  
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   918
  Additional parameters may be specified as $ps$; these are applied after the
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   919
  primary instantiation in the same manner as by the $of$ attribute (cf.\ 
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   920
  \S\ref{sec:pure-meth-att}).  This feature is rarely needed in practice; a
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   921
  typical application would be to specify additional arguments for rules
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   922
  stemming from parameterized inductive definitions (see also
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   923
  \S\ref{sec:inductive}).
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   924
  
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   925
  The $open$ option causes the parameters of the new local contexts to be
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   926
  exposed to the current proof context.  Thus local variables stemming from
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   927
  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
   928
  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
   929
  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
   930
  less robust proof texts.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   931
  
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   932
\item [$induct~insts~R~ps$] is analogous to the $cases$ method, but refers to
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   933
  induction rules, which are determined as follows:
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   934
  \begin{matharray}{llll}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   935
    \Text{facts}    &        & \Text{arguments} & \Text{rule} \\\hline
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   936
                    & induct & P ~ x ~ \dots & \Text{datatype induction (type of $x$)} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   937
    \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
   938
    \dots           & induct & \dots ~ R     & \Text{explicit rule $R$} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   939
  \end{matharray}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   940
  
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   941
  Several instantiations may be given, each referring to some part of a mutual
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   942
  inductive definition or datatype --- only related partial induction rules
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   943
  may be used together, though.  Any of the lists of terms $P, x, \dots$
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   944
  refers to the \emph{suffix} of variables present in the induction rule.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   945
  This enables the writer to specify only induction variables, or both
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   946
  predicates and variables, for example.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   947
  
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   948
  Additional parameters (including the $open$ option) may be given in the same
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   949
  way as for $cases$, see above.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   950
\end{descr}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   951
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   952
Above methods produce named local contexts (cf.\ \S\ref{sec:cases}), as
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   953
determined by the instantiated rule \emph{before} it has been applied to the
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   954
internal proof state.\footnote{As a general principle, Isar proof text may
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   955
  never refer to parts of proof states directly.} Thus proper use of symbolic
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   956
cases usually require the rule to be instantiated fully, as far as the
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   957
emerging local contexts and subgoals are concerned.  In particular, for
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   958
induction both the predicates and variables have to be specified.  Otherwise
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   959
the $\CASENAME$ command would refuse to invoke cases containing schematic
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   960
variables.  Furthermore the resulting local goal statement is bound to the
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   961
term variable $\Var{case}$\indexisarvar{case} --- for each case where it is
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   962
fully specified.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   963
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   964
The $\isarkeyword{print_cases}$ command (\S\ref{sec:cases}) prints all named
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   965
cases present in the current proof state.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   966
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   967
\medskip
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   968
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   969
It is important to note that there is a fundamental difference of the $cases$
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   970
and $induct$ methods in handling of non-atomic goal statements: $cases$ just
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   971
applies a certain rule in backward fashion, splitting the result into new
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   972
goals with the local contexts being augmented in a purely monotonic manner.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   973
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   974
In contrast, $induct$ passes the full goal statement through the ``recursive''
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   975
course involved in the induction.  Thus the original statement is basically
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   976
replaced by separate copies, corresponding to the induction hypotheses and
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   977
conclusion; the original goal context is no longer available.  This behavior
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   978
allows \emph{strengthened induction predicates} to be expressed concisely as
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   979
meta-level rule statements, i.e.\ $\All{\vec x} \vec\phi \Imp \psi$ to
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   980
indicate ``variable'' parameters $\vec x$ and ``recursive'' assumptions
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   981
$\vec\phi$.  Also note that local definitions may be expressed as $\All{\vec
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   982
  x} n \equiv t[\vec x] \Imp \phi[n]$, with induction over $n$.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   983
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   984
\medskip
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   985
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   986
Facts presented to either method are consumed according to the number of
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   987
``major premises'' of the rule involved (see also \S\ref{sec:induct-att} and
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   988
\S\ref{sec:cases}), which is usually $0$ for plain cases and induction rules
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   989
of datatypes etc.\ and $1$ for rules of inductive sets and the like.  The
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   990
remaining facts are inserted into the goal verbatim before the actual $cases$
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   991
or $induct$ rule is applied (thus facts may be even passed through an
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   992
induction).
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   993
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   994
Note that whenever facts are present, the default rule selection scheme would
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   995
provide a ``set'' rule only, with the first fact consumed and the rest
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   996
inserted into the goal.  In order to pass all facts into a ``type'' rule
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   997
instead, one would have to specify this explicitly, e.g.\ by appending
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   998
``$type: name$'' to the method argument.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
   999
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1000
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1001
\subsection{Declaring rules}\label{sec:induct-att}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1002
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1003
\indexisarcmd{print-induct-rules}\indexisaratt{cases}\indexisaratt{induct}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1004
\begin{matharray}{rcl}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1005
  \isarcmd{print_induct_rules}^* & : & \isarkeep{theory~|~proof} \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1006
  cases & : & \isaratt \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1007
  induct & : & \isaratt \\
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1008
\end{matharray}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1009
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1010
\begin{rail}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1011
  'cases' spec
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1012
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1013
  'induct' spec
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1014
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1015
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1016
  spec: ('type' | 'set') ':' nameref
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1017
  ;
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1018
\end{rail}
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1019
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1020
The $cases$ and $induct$ attributes augment the corresponding context of rules
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1021
for reasoning about inductive sets and types.  The standard rules are already
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1022
declared by advanced definitional packages.  For special applications, these
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1023
may be replaced manually by variant versions.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1024
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1025
Refer to the $case_names$ and $ps$ attributes (see \S\ref{sec:cases}) to
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1026
adjust names of cases and parameters of a rule.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1027
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1028
The $consumes$ declaration (cf.\ \S\ref{sec:cases}) is taken care of
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1029
automatically (if none had been given already): $consumes~0$ is specified for
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1030
``type'' rules and $consumes~1$ for ``set'' rules.
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1031
fc9bd420162c induct/cases made generic, removed simplified/stripped options;
wenzelm
parents: 11469
diff changeset
  1032
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1033
%%% Local Variables:
7135
wenzelm
parents:
diff changeset
  1034
%%% mode: latex
wenzelm
parents:
diff changeset
  1035
%%% TeX-master: "isar-ref"
9614
8ca1fc75230e renamed 'RS' to 'THEN';
wenzelm
parents: 9606
diff changeset
  1036
%%% End: