CookBook/Tactical.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 30 Jan 2009 08:24:48 +0000
changeset 93 62fb91f86908
child 95 7235374f34c8
permissions -rw-r--r--
added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
93
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory Tactical
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports Base
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
chapter {* Tactical Reasoning\label{chp:tactical} *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
  The main reason for descending to the ML-level of Isabelle is to be able to
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  implement automatic proof procedures. Such proof procedures usually lessen
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
  considerably the burden of manual reasoning, for example, when introducing
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
  new definitions. These proof procedures are centred around refining a goal
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
  state using tactics. This is similar to the @{text apply}-style reasoning at
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  the user level, where goals are modified in a sequence of proof steps until
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
  all of them are solved.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
section {* Tactical Reasoning *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  To see how tactics work, let us first transcribe a simple @{text apply}-style proof 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
  into ML. Consider the following proof.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
lemma disj_swap: "P \<or> Q \<Longrightarrow> Q \<or> P"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
apply(erule disjE)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
apply(rule disjI2)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
apply(assumption)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
apply(rule disjI1)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
apply(assumption)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
  This proof translates to the following ML-code.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
@{ML_response_fake [display,gray]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
"let
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
  val ctxt = @{context}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
  val goal = @{prop \"P \<or> Q \<Longrightarrow> Q \<or> P\"}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
in
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  Goal.prove ctxt [\"P\", \"Q\"] [] goal 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
   (fn _ => 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
      etac @{thm disjE} 1
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
      THEN rtac @{thm disjI2} 1
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
      THEN atac 1
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
      THEN rtac @{thm disjI1} 1
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
      THEN atac 1)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
end" "?P \<or> ?Q \<Longrightarrow> ?Q \<or> ?P"}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
  To start the proof, the function @{ML "Goal.prove"}~@{text "ctxt xs As C
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
  tac"} sets up a goal state for proving the goal @{text C} under the
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  assumptions @{text As} (empty in the proof at hand) with the variables
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  @{text xs} that will be generalised once the goal is proved (in our case
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  @{text P} and @{text Q}). The @{text "tac"} is the tactic that proves the goal;
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
  it can make use of the local assumptions (there are none in this example). 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
  The functions @{ML etac}, @{ML rtac} and @{ML atac} correspond to 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
  @{text erule}, @{text rule} and @{text assumption}, respectively. 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
  The operator @{ML THEN} strings tactics together.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
  \begin{readmore}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
  To learn more about the function @{ML Goal.prove} see \isccite{sec:results} and
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
  the file @{ML_file "Pure/goal.ML"}. For more information about the internals of goals see 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
  \isccite{sec:tactical-goals}. 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
  \end{readmore}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
  Note that we used antiquotations for referencing the theorems. We could also
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
  just have written @{ML "etac disjE 1"} and so on, but this is considered bad
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  style. The reason is that the binding for @{ML disjE} can be re-assigned by 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
  the user and thus one does not have complete control over which theorem is
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
  actually applied. This problem is nicely prevented by using antiquotations, 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
  because then the theorems are fixed statically at compile-time.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
  During the development of automatic proof procedures, it will often be necessary 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
  to test a tactic on examples. This can be conveniently 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
  done with the command \isacommand{apply}@{text "(tactic \<verbopen> \<dots> \<verbclose>)"}. 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
  Consider the following sequence of tactics
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
ML{*val foo_tac = 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
      (etac @{thm disjE} 1
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
       THEN rtac @{thm disjI2} 1
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
       THEN atac 1
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
       THEN rtac @{thm disjI1} 1
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
       THEN atac 1)*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
text {* and the Isabelle proof: *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
lemma "P \<or> Q \<Longrightarrow> Q \<or> P"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
apply(tactic {* foo_tac *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
  The apply-step applies the @{ML foo_tac} and therefore solves the goal completely.  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
  Inside @{text "tactic \<verbopen> \<dots> \<verbclose>"} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
  we can call any function that returns a tactic.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
  As can be seen, each tactic in @{ML foo_tac} has a hard-coded number that
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
  stands for the subgoal analysed by the tactic. In our case, we only focus on the first
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
  subgoal. This is sometimes wanted, but usually not. To avoid the explicit numbering in the 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
  tactic, you can write
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
ML{*val foo_tac' = 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
      (etac @{thm disjE} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
       THEN' rtac @{thm disjI2} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
       THEN' atac 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
       THEN' rtac @{thm disjI1} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
       THEN' atac)*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
text {* 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
  and then give the number for the subgoal explicitly when the tactic is
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
  called. So in the next proof we discharge first the second subgoal,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
  and after that the first.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
lemma "P1 \<or> Q1 \<Longrightarrow> Q1 \<or> P1"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
   and "P2 \<or> Q2 \<Longrightarrow> Q2 \<or> P2"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
apply(tactic {* foo_tac' 2 *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
apply(tactic {* foo_tac' 1 *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
  The tactic @{ML foo_tac} is very specific for analysing goals of the form
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
  @{prop "P \<or> Q \<Longrightarrow> Q \<or> P"}. If the goal is not of this form, then @{ML foo_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
  throws the error message about an empty result sequence---meaning the tactic
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
  failed. The reason for this message is that tactics are functions that map 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
  a goal state to a (lazy) sequence of successor states, hence the type of a 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
  tactic is
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
  @{text [display, gray] "type tactic = thm -> thm Seq.seq"}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
  Consequently, if a tactic fails, then it returns the empty sequence. This
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
  is by the way the default behaviour for a failing tactic; tactics should 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
  not raise exceptions.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
  In the following example there are two possibilities for how to apply the tactic.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
lemma "\<lbrakk>P \<or> Q; P \<or> Q\<rbrakk> \<Longrightarrow> Q \<or> P"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
apply(tactic {* foo_tac' 1 *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
back
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
  The application of the tactic results in a sequence of two possible
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
  proofs. The Isabelle command \isacommand{back} allows us to explore both 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
  possibilities.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
  \begin{readmore}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
  See @{ML_file "Pure/General/seq.ML"} for the implementation of lazy
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
  sequences. However in day-to-day Isabelle programming, one rarely 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
  constructs sequences explicitly, but uses the predefined functions
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
  instead. See @{ML_file "Pure/tactic.ML"} and 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
  @{ML_file "Pure/tctical.ML"} for the code of basic tactics and tactic
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
  combinators; see also Chapters 3 and 4 in 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
  the old Isabelle Reference Manual.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
  \end{readmore}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
section {* Basic Tactics *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
lemma shows "False \<Longrightarrow> False"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
apply(tactic {* atac 1 *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
lemma shows "True \<and> True"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
apply(tactic {* rtac @{thm conjI} 1 *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
txt {* @{subgoals [display]} *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
(*<*)oops(*>*)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
lemma 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
  shows "Foo"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
  and "True \<and> True"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
apply(tactic {* rtac @{thm conjI} 2 *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
txt {* @{subgoals [display]} *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   180
(*<*)oops(*>*)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   181
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   182
lemma shows "False \<and> False \<Longrightarrow> False"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
apply(tactic {* etac @{thm conjE} 1 *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
txt {* @{subgoals [display]} *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
(*<*)oops(*>*)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   186
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
lemma shows "False \<and> True \<Longrightarrow> False"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
apply(tactic {* dtac @{thm conjunct2} 1 *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
txt {* @{subgoals [display]} *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
(*<*)oops(*>*)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
  similarly @{ML ftac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
text {* diagnostics *} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
lemma shows "True \<Longrightarrow> False"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
apply(tactic {* print_tac "foo message" *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
(*<*)oops(*>*)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
  @{ML PRIMITIVE}? @{ML SUBGOAL} see page 32 in ref
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   205
text {* 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
  @{ML all_tac} @{ML no_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   209
section {* Operations on Tactics *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   210
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   211
text {* THEN *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   212
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   213
lemma shows "(True \<and> True) \<and> False"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   214
apply(tactic {* (rtac @{thm conjI} 1) THEN (rtac @{thm conjI} 1) *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
txt {* @{subgoals [display]} *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
(*<*)oops(*>*)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   217
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   218
lemma shows "True \<and> False"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   219
apply(tactic {* (rtac @{thm disjI1} 1) ORELSE (rtac @{thm conjI} 1) *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   220
txt {* @{subgoals [display]} *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   221
(*<*)oops(*>*)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   222
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   223
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   224
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   225
  @{ML EVERY} @{ML REPEAT} @{ML SUBPROOF}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   226
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   227
  @{ML rewrite_goals_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   228
  @{ML cut_facts_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   229
  @{ML ObjectLogic.full_atomize_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   230
  @{ML ObjectLogic.rulify_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   231
  @{ML resolve_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   232
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   233
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   234
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   235
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   236
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   237
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   238
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   239
  A goal (or goal state) is a special @{ML_type thm}, which by
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   240
  convention is an implication of the form:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   241
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   242
  @{text[display] "A\<^isub>1 \<Longrightarrow> \<dots> \<Longrightarrow> A\<^isub>n \<Longrightarrow> #(C)"}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   243
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   244
  where @{term C} is the goal to be proved and the @{term "A\<^isub>i"} are the open 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   245
  subgoals. 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   246
  Since the goal @{term C} can potentially be an implication, there is a
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   247
  @{text "#"} wrapped around it, which prevents that premises are 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   248
  misinterpreted as open subgoals. The wrapper @{text "# :: prop \<Rightarrow>
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   249
  prop"} is just the identity function and used as a syntactic marker. 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   250
  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   251
 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   252
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   253
 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   254
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   255
  While tactics can operate on the subgoals (the @{text "A\<^isub>i"} above), they 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   256
  are expected to leave the conclusion @{term C} intact, with the 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   257
  exception of possibly instantiating schematic variables. 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   258
 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   259
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   260
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   261
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   262
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   263
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   264
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   265
end