src/Doc/Isar_Ref/Quick_Reference.thy
author wenzelm
Mon Feb 15 14:55:44 2016 +0100 (2016-02-15)
changeset 62337 d3996d5873dd
parent 62278 c04e97be39d3
child 63039 1a20fd9cf281
permissions -rw-r--r--
proper syntax;
wenzelm@61656
     1
(*:maxLineLen=78:*)
wenzelm@61656
     2
wenzelm@26779
     3
theory Quick_Reference
wenzelm@42651
     4
imports Base Main
wenzelm@26779
     5
begin
wenzelm@26779
     6
wenzelm@58618
     7
chapter \<open>Isabelle/Isar quick reference \label{ap:refcard}\<close>
wenzelm@26779
     8
wenzelm@58618
     9
section \<open>Proof commands\<close>
wenzelm@26779
    10
wenzelm@62278
    11
subsection \<open>Main grammar \label{ap:main-grammar}\<close>
wenzelm@62270
    12
wenzelm@62270
    13
text \<open>
wenzelm@62270
    14
  \begin{tabular}{rcl}
wenzelm@62270
    15
    \<open>main\<close> & = & \<^theory_text>\<open>notepad begin "statement\<^sup>*" end\<close> \\
wenzelm@62270
    16
    & \<open>|\<close> & \<^theory_text>\<open>theorem name: props "proof"\<close> \\
wenzelm@62270
    17
    & \<open>|\<close> & \<^theory_text>\<open>theorem name:\<close> \\
wenzelm@62270
    18
    & & \quad\<^theory_text>\<open>fixes "var\<^sup>+"\<close> \\
wenzelm@62270
    19
    & & \quad\<^theory_text>\<open>assumes name: props\<close> \\
wenzelm@62270
    20
    & & \quad\<^theory_text>\<open>shows name: props "proof"\<close> \\
wenzelm@62270
    21
    \<open>proof\<close> & = & \<^theory_text>\<open>"refinement\<^sup>*" proof "method\<^sup>?" "statement\<^sup>*" qed "method\<^sup>?"\<close> \\
wenzelm@62270
    22
    & \<open>|\<close> & \<^theory_text>\<open>"refinement\<^sup>*" done\<close> \\
wenzelm@62270
    23
    \<open>refinement\<close> & = &  \<^theory_text>\<open>apply method\<close> \\
wenzelm@62270
    24
    & \<open>|\<close> & \<^theory_text>\<open>supply facts\<close> \\
wenzelm@62270
    25
    & \<open>|\<close> & \<^theory_text>\<open>subgoal "proof"\<close> \\
wenzelm@62270
    26
    & \<open>|\<close> & \<^theory_text>\<open>subgoal for "var\<^sup>+" "proof"\<close> \\
wenzelm@62270
    27
    & \<open>|\<close> & \<^theory_text>\<open>using facts\<close> \\
wenzelm@62270
    28
    & \<open>|\<close> & \<^theory_text>\<open>unfolding facts\<close> \\
wenzelm@62270
    29
    \<open>statement\<close> & = & \<^theory_text>\<open>{ "statement\<^sup>*" }\<close> \\
wenzelm@62270
    30
    & \<open>|\<close> & \<^theory_text>\<open>next\<close> \\
wenzelm@62270
    31
    & \<open>|\<close> & \<^theory_text>\<open>note name = facts\<close> \\
wenzelm@62270
    32
    & \<open>|\<close> & \<^theory_text>\<open>let "term" = "term"\<close> \\
wenzelm@62270
    33
    & \<open>|\<close> & \<^theory_text>\<open>write name  (mixfix)\<close> \\
wenzelm@62270
    34
    & \<open>|\<close> & \<^theory_text>\<open>fix "var\<^sup>+"\<close> \\
wenzelm@62270
    35
    & \<open>|\<close> & \<^theory_text>\<open>assume name: props\<close> \\
wenzelm@62337
    36
    & \<open>|\<close> & \<^theory_text>\<open>assume name: props if props for "var\<^sup>+"\<close> \\
wenzelm@62270
    37
    & \<open>|\<close> & \<^theory_text>\<open>then"\<^sup>?" goal\<close> \\
wenzelm@62270
    38
    \<open>goal\<close> & = & \<^theory_text>\<open>have name: props "proof"\<close> \\
wenzelm@62270
    39
    & \<open>|\<close> & \<^theory_text>\<open>have name: props if name: props for "var\<^sup>+" "proof"\<close> \\
wenzelm@62270
    40
    & \<open>|\<close> & \<^theory_text>\<open>show name: props "proof"\<close> \\
wenzelm@62270
    41
    & \<open>|\<close> & \<^theory_text>\<open>show name: props if name: props for "var\<^sup>+" "proof"\<close> \\
wenzelm@62270
    42
  \end{tabular}
wenzelm@62270
    43
\<close>
wenzelm@62270
    44
wenzelm@62270
    45
wenzelm@62270
    46
subsection \<open>Primitives\<close>
wenzelm@26779
    47
wenzelm@58618
    48
text \<open>
wenzelm@26779
    49
  \begin{tabular}{ll}
wenzelm@62270
    50
    \<^theory_text>\<open>fix x\<close> & augment context by \<open>\<And>x. \<box>\<close> \\
wenzelm@62270
    51
    \<^theory_text>\<open>assume a: A\<close> & augment context by \<open>A \<Longrightarrow> \<box>\<close> \\
wenzelm@62270
    52
    \<^theory_text>\<open>then\<close> & indicate forward chaining of facts \\
wenzelm@62270
    53
    \<^theory_text>\<open>have a: A\<close> & prove local result \\
wenzelm@62270
    54
    \<^theory_text>\<open>show a: A\<close> & prove local result, refining some goal \\
wenzelm@62270
    55
    \<^theory_text>\<open>using a\<close> & indicate use of additional facts \\
wenzelm@62270
    56
    \<^theory_text>\<open>unfolding a\<close> & unfold definitional equations \\
wenzelm@62270
    57
    \<^theory_text>\<open>proof m\<^sub>1 \<dots> qed m\<^sub>2\<close> & indicate proof structure and refinements \\
wenzelm@62270
    58
    \<^theory_text>\<open>{ \<dots> }\<close> & indicate explicit blocks \\
wenzelm@62270
    59
    \<^theory_text>\<open>next\<close> & switch proof blocks \\
wenzelm@62270
    60
    \<^theory_text>\<open>note a = b\<close> & reconsider and declare facts \\
wenzelm@62270
    61
    \<^theory_text>\<open>let p = t\<close> & abbreviate terms by higher-order matching \\
wenzelm@62270
    62
    \<^theory_text>\<open>write c  (mx)\<close> & declare local mixfix syntax \\
wenzelm@26852
    63
  \end{tabular}
wenzelm@58618
    64
\<close>
wenzelm@26779
    65
wenzelm@26779
    66
wenzelm@58618
    67
subsection \<open>Abbreviations and synonyms\<close>
wenzelm@26779
    68
wenzelm@58618
    69
text \<open>
wenzelm@26852
    70
  \begin{tabular}{rcl}
wenzelm@62270
    71
    \<^theory_text>\<open>by m\<^sub>1 m\<^sub>2\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>proof m\<^sub>1 qed m\<^sub>2\<close> \\
wenzelm@62270
    72
    \<^theory_text>\<open>..\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>by standard\<close> \\
wenzelm@62270
    73
    \<^theory_text>\<open>.\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>by this\<close> \\
wenzelm@62270
    74
    \<^theory_text>\<open>from a\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>note a then\<close> \\
wenzelm@62270
    75
    \<^theory_text>\<open>with a\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>from a and this\<close> \\
wenzelm@62270
    76
    \<^theory_text>\<open>from this\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>then\<close> \\
wenzelm@26852
    77
  \end{tabular}
wenzelm@58618
    78
\<close>
wenzelm@26779
    79
wenzelm@26779
    80
wenzelm@58618
    81
subsection \<open>Derived elements\<close>
wenzelm@26779
    82
wenzelm@58618
    83
text \<open>
wenzelm@26852
    84
  \begin{tabular}{rcl}
wenzelm@62270
    85
    \<^theory_text>\<open>also"\<^sub>0"\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>note calculation = this\<close> \\
wenzelm@62270
    86
    \<^theory_text>\<open>also"\<^sub>n\<^sub>+\<^sub>1"\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>note calculation = trans [OF calculation this]\<close> \\
wenzelm@62270
    87
    \<^theory_text>\<open>finally\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>also from calculation\<close> \\[0.5ex]
wenzelm@62270
    88
    \<^theory_text>\<open>moreover\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>note calculation = calculation this\<close> \\
wenzelm@62270
    89
    \<^theory_text>\<open>ultimately\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>moreover from calculation\<close> \\[0.5ex]
wenzelm@62270
    90
    \<^theory_text>\<open>presume a: A\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>assume a: A\<close> \\
wenzelm@62270
    91
    \<^theory_text>\<open>def "x \<equiv> t"\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>fix x assume x_def: "x \<equiv> t"\<close> \\
wenzelm@62270
    92
    \<^theory_text>\<open>consider x where A | \<dots>\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>have thesis\<close> \\
wenzelm@62270
    93
    & & \quad \<^theory_text>\<open>if "\<And>x. A \<Longrightarrow> thesis" and \<dots> for thesis\<close> \\
wenzelm@62270
    94
    \<^theory_text>\<open>obtain x where a: A \<proof>\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>consider x where A \<proof>\<close> \\
wenzelm@62270
    95
    & & \<^theory_text>\<open>fix x assume a: A\<close> \\
wenzelm@62270
    96
    \<^theory_text>\<open>case c\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>fix x assume c: A\<close> \\
wenzelm@62270
    97
    \<^theory_text>\<open>sorry\<close> & \<open>\<approx>\<close> & \<^theory_text>\<open>by cheating\<close> \\
wenzelm@26852
    98
  \end{tabular}
wenzelm@58618
    99
\<close>
wenzelm@26779
   100
wenzelm@26779
   101
wenzelm@58618
   102
subsection \<open>Diagnostic commands\<close>
wenzelm@26779
   103
wenzelm@58618
   104
text \<open>
wenzelm@26779
   105
  \begin{tabular}{ll}
wenzelm@62270
   106
    \<^theory_text>\<open>typ \<tau>\<close> & print type \\
wenzelm@62270
   107
    \<^theory_text>\<open>term t\<close> & print term \\
wenzelm@62270
   108
    \<^theory_text>\<open>prop \<phi>\<close> & print proposition \\
wenzelm@62270
   109
    \<^theory_text>\<open>thm a\<close> & print fact \\
wenzelm@62270
   110
    \<^theory_text>\<open>print_statement a\<close> & print fact in long statement form \\
wenzelm@26779
   111
  \end{tabular}
wenzelm@58618
   112
\<close>
wenzelm@26779
   113
wenzelm@26779
   114
wenzelm@58618
   115
section \<open>Proof methods\<close>
wenzelm@26779
   116
wenzelm@58618
   117
text \<open>
wenzelm@26779
   118
  \begin{tabular}{ll}
wenzelm@61477
   119
    \multicolumn{2}{l}{\<^bold>\<open>Single steps (forward-chaining facts)\<close>} \\[0.5ex]
wenzelm@62270
   120
    @{method assumption} & apply some goal assumption \\
wenzelm@26779
   121
    @{method this} & apply current facts \\
wenzelm@61493
   122
    @{method rule}~\<open>a\<close> & apply some rule  \\
wenzelm@60618
   123
    @{method standard} & apply standard rule (default for @{command "proof"}) \\
wenzelm@61493
   124
    @{method contradiction} & apply \<open>\<not>\<close> elimination rule (any order) \\
wenzelm@61493
   125
    @{method cases}~\<open>t\<close> & case analysis (provides cases) \\
wenzelm@61493
   126
    @{method induct}~\<open>x\<close> & proof by induction (provides cases) \\[2ex]
wenzelm@26779
   127
wenzelm@61477
   128
    \multicolumn{2}{l}{\<^bold>\<open>Repeated steps (inserting facts)\<close>} \\[0.5ex]
wenzelm@26779
   129
    @{method "-"} & no rules \\
wenzelm@61493
   130
    @{method intro}~\<open>a\<close> & introduction rules \\
wenzelm@26779
   131
    @{method intro_classes} & class introduction rules \\
wenzelm@62270
   132
    @{method intro_locales} & locale introduction rules (without body) \\
wenzelm@62270
   133
    @{method unfold_locales} & locale introduction rules (with body) \\
wenzelm@61493
   134
    @{method elim}~\<open>a\<close> & elimination rules \\
wenzelm@61493
   135
    @{method unfold}~\<open>a\<close> & definitional rewrite rules \\[2ex]
wenzelm@26779
   136
wenzelm@61477
   137
    \multicolumn{2}{l}{\<^bold>\<open>Automated proof tools (inserting facts)\<close>} \\[0.5ex]
wenzelm@26779
   138
    @{method iprover} & intuitionistic proof search \\
wenzelm@26779
   139
    @{method blast}, @{method fast} & Classical Reasoner \\
wenzelm@26779
   140
    @{method simp}, @{method simp_all} & Simplifier (+ Splitter) \\
wenzelm@26779
   141
    @{method auto}, @{method force} & Simplifier + Classical Reasoner \\
wenzelm@26779
   142
    @{method arith} & Arithmetic procedures \\
wenzelm@26779
   143
  \end{tabular}
wenzelm@58618
   144
\<close>
wenzelm@26779
   145
wenzelm@26779
   146
wenzelm@58618
   147
section \<open>Attributes\<close>
wenzelm@26779
   148
wenzelm@58618
   149
text \<open>
wenzelm@26779
   150
  \begin{tabular}{ll}
wenzelm@61477
   151
    \multicolumn{2}{l}{\<^bold>\<open>Rules\<close>} \\[0.5ex]
wenzelm@61493
   152
    @{attribute OF}~\<open>a\<close> & rule resolved with facts (skipping ``\<open>_\<close>'') \\
wenzelm@61493
   153
    @{attribute of}~\<open>t\<close> & rule instantiated with terms (skipping ``\<open>_\<close>'') \\
wenzelm@61493
   154
    @{attribute "where"}~\<open>x = t\<close> & rule instantiated with terms, by variable name \\
wenzelm@26779
   155
    @{attribute symmetric} & resolution with symmetry rule \\
wenzelm@61493
   156
    @{attribute THEN}~\<open>b\<close> & resolution with another rule \\
wenzelm@26779
   157
    @{attribute rule_format} & result put into standard rule format \\
wenzelm@26779
   158
    @{attribute elim_format} & destruct rule turned into elimination rule format \\[1ex]
wenzelm@26779
   159
wenzelm@61477
   160
    \multicolumn{2}{l}{\<^bold>\<open>Declarations\<close>} \\[0.5ex]
wenzelm@26779
   161
    @{attribute simp} & Simplifier rule \\
wenzelm@26779
   162
    @{attribute intro}, @{attribute elim}, @{attribute dest} & Pure or Classical Reasoner rule \\
wenzelm@26779
   163
    @{attribute iff} & Simplifier + Classical Reasoner rule \\
wenzelm@26779
   164
    @{attribute split} & case split rule \\
wenzelm@26779
   165
    @{attribute trans} & transitivity rule \\
wenzelm@26779
   166
    @{attribute sym} & symmetry rule \\
wenzelm@26779
   167
  \end{tabular}
wenzelm@58618
   168
\<close>
wenzelm@26779
   169
wenzelm@26779
   170
wenzelm@58618
   171
section \<open>Rule declarations and methods\<close>
wenzelm@26779
   172
wenzelm@58618
   173
text \<open>
wenzelm@26779
   174
  \begin{tabular}{l|lllll}
wenzelm@26779
   175
      & @{method rule} & @{method iprover} & @{method blast} & @{method simp} & @{method auto} \\
wenzelm@26779
   176
      &                &                   & @{method fast} & @{method simp_all} & @{method force} \\
wenzelm@26779
   177
    \hline
wenzelm@61493
   178
    @{attribute Pure.elim}\<open>!\<close> @{attribute Pure.intro}\<open>!\<close>
wenzelm@61493
   179
      & \<open>\<times>\<close>    & \<open>\<times>\<close> \\
wenzelm@26779
   180
    @{attribute Pure.elim} @{attribute Pure.intro}
wenzelm@61493
   181
      & \<open>\<times>\<close>    & \<open>\<times>\<close> \\
wenzelm@61493
   182
    @{attribute elim}\<open>!\<close> @{attribute intro}\<open>!\<close>
wenzelm@61493
   183
      & \<open>\<times>\<close>    &                    & \<open>\<times>\<close>          &                     & \<open>\<times>\<close> \\
wenzelm@26779
   184
    @{attribute elim} @{attribute intro}
wenzelm@61493
   185
      & \<open>\<times>\<close>    &                    & \<open>\<times>\<close>          &                     & \<open>\<times>\<close> \\
wenzelm@26779
   186
    @{attribute iff}
wenzelm@61493
   187
      & \<open>\<times>\<close>    &                    & \<open>\<times>\<close>          & \<open>\<times>\<close>         & \<open>\<times>\<close> \\
wenzelm@61493
   188
    @{attribute iff}\<open>?\<close>
wenzelm@61493
   189
      & \<open>\<times>\<close> \\
wenzelm@61493
   190
    @{attribute elim}\<open>?\<close> @{attribute intro}\<open>?\<close>
wenzelm@61493
   191
      & \<open>\<times>\<close> \\
wenzelm@26779
   192
    @{attribute simp}
wenzelm@61493
   193
      &                &                    &                      & \<open>\<times>\<close>         & \<open>\<times>\<close> \\
wenzelm@26779
   194
    @{attribute cong}
wenzelm@61493
   195
      &                &                    &                      & \<open>\<times>\<close>         & \<open>\<times>\<close> \\
wenzelm@26779
   196
    @{attribute split}
wenzelm@61493
   197
      &                &                    &                      & \<open>\<times>\<close>         & \<open>\<times>\<close> \\
wenzelm@26779
   198
  \end{tabular}
wenzelm@58618
   199
\<close>
wenzelm@26779
   200
wenzelm@26779
   201
wenzelm@62270
   202
section \<open>Proof scripts\<close>
wenzelm@26779
   203
wenzelm@58618
   204
subsection \<open>Commands\<close>
wenzelm@26779
   205
wenzelm@58618
   206
text \<open>
wenzelm@26779
   207
  \begin{tabular}{ll}
wenzelm@62270
   208
    \<^theory_text>\<open>apply m\<close> & apply proof method during backwards refinement \\
wenzelm@62270
   209
    \<^theory_text>\<open>apply_end m\<close> & apply proof method (as if in terminal position) \\
wenzelm@62270
   210
    \<^theory_text>\<open>supply a\<close> & supply facts during backwards refinement \\
wenzelm@62270
   211
    \<^theory_text>\<open>subgoal\<close> & nested proof during backwards refinement \\
wenzelm@62270
   212
    \<^theory_text>\<open>defer n\<close> & move subgoal to end \\
wenzelm@62270
   213
    \<^theory_text>\<open>prefer n\<close> & move subgoal to start \\
wenzelm@62270
   214
    \<^theory_text>\<open>back\<close> & backtrack last command \\
wenzelm@62270
   215
    \<^theory_text>\<open>done\<close> & complete proof \\
wenzelm@26779
   216
  \end{tabular}
wenzelm@58618
   217
\<close>
wenzelm@26779
   218
wenzelm@26779
   219
wenzelm@58618
   220
subsection \<open>Methods\<close>
wenzelm@26779
   221
wenzelm@58618
   222
text \<open>
wenzelm@26779
   223
  \begin{tabular}{ll}
wenzelm@61493
   224
    @{method rule_tac}~\<open>insts\<close> & resolution (with instantiation) \\
wenzelm@61493
   225
    @{method erule_tac}~\<open>insts\<close> & elim-resolution (with instantiation) \\
wenzelm@61493
   226
    @{method drule_tac}~\<open>insts\<close> & destruct-resolution (with instantiation) \\
wenzelm@61493
   227
    @{method frule_tac}~\<open>insts\<close> & forward-resolution (with instantiation) \\
wenzelm@61493
   228
    @{method cut_tac}~\<open>insts\<close> & insert facts (with instantiation) \\
wenzelm@61493
   229
    @{method thin_tac}~\<open>\<phi>\<close> & delete assumptions \\
wenzelm@61493
   230
    @{method subgoal_tac}~\<open>\<phi>\<close> & new claims \\
wenzelm@61493
   231
    @{method rename_tac}~\<open>x\<close> & rename innermost goal parameters \\
wenzelm@61493
   232
    @{method rotate_tac}~\<open>n\<close> & rotate assumptions of goal \\
wenzelm@61493
   233
    @{method tactic}~\<open>text\<close> & arbitrary ML tactic \\
wenzelm@61493
   234
    @{method case_tac}~\<open>t\<close> & exhaustion (datatypes) \\
wenzelm@61493
   235
    @{method induct_tac}~\<open>x\<close> & induction (datatypes) \\
wenzelm@61493
   236
    @{method ind_cases}~\<open>t\<close> & exhaustion + simplification (inductive predicates) \\
wenzelm@26779
   237
  \end{tabular}
wenzelm@58618
   238
\<close>
wenzelm@26779
   239
wenzelm@26779
   240
end