CookBook/Tactical.thy
author Christian Urban <urbanc@in.tum.de>
Wed, 04 Feb 2009 20:26:38 +0000
changeset 95 7235374f34c8
parent 93 62fb91f86908
child 99 de625e5f6a36
permissions -rw-r--r--
added some preliminary notes about SUBPROOF
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
95
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   201
text {* Let us assume the following four string conversion functions: *}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   202
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   203
ML{*fun str_of_cterm ctxt t =  
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   204
   Syntax.string_of_term ctxt (term_of t)
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   205
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   206
fun str_of_cterms ctxt ts =  
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   207
  commas (map (str_of_cterm ctxt) ts)
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   208
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   209
fun str_of_thm ctxt thm =
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   210
  let
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   211
    val {prop, ...} = crep_thm thm
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   212
  in 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   213
    str_of_cterm ctxt prop
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   214
  end
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   215
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   216
fun str_of_thms ctxt thms =  
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   217
  commas (map (str_of_thm ctxt) thms)*}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   218
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   219
text {*
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   220
  and the following function
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   221
*}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   222
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   223
ML{*fun sp_tac {prems, params, asms, concl, context, schematics} = 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   224
  let 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   225
    val str_of_params = str_of_cterms context params
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   226
    val str_of_asms = str_of_cterms context asms
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   227
    val str_of_concl = str_of_cterm context concl
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   228
    val str_of_prems = str_of_thms context prems   
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   229
    val str_of_schms = str_of_cterms context (snd schematics)    
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   230
 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   231
    val _ = (warning ("params: " ^ str_of_params);
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   232
             warning ("schematics: " ^ str_of_schms);
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   233
             warning ("asms: " ^ str_of_asms);
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   234
             warning ("concl: " ^ str_of_concl);
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   235
             warning ("prems: " ^ str_of_prems))
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   236
  in
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   237
    no_tac 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   238
  end*}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   239
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   240
text {*
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   241
  then the tactic @{ML SUBPROOF} fixes the parameters and binds the various components
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   242
  of a proof state into a record. For example 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   243
*}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   244
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   245
lemma 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   246
  shows "\<And>x y. A x y \<Longrightarrow> B y x \<longrightarrow> C (?z y) x"
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   247
apply(tactic {* SUBPROOF sp_tac @{context} 1 *})?
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   248
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   249
txt {*
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   250
  prints out 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   251
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   252
  \begin{center}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   253
  \begin{tabular}{ll}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   254
  params:     & @{term x}, @{term y}\\
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   255
  schematics: & @{term z}\\
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   256
  asms:       & @{term "A x y"}\\
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   257
  concl:      & @{term "B y x \<longrightarrow> C (z y) x"}\\
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   258
  prems:      & @{term "A x y"}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   259
  \end{tabular}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   260
  \end{center}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   261
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   262
  Continuing the proof script with
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   263
*}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   264
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   265
apply(rule impI)
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   266
apply(tactic {* SUBPROOF sp_tac @{context} 1 *})?
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   267
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   268
txt {*
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   269
  prints out 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   270
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   271
  \begin{center}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   272
  \begin{tabular}{ll}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   273
  params:     & @{term x}, @{term y}\\
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   274
  schematics: & @{term z}\\
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   275
  asms:       & @{term "A x y"}, @{term "B y x"}\\
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   276
  concl:      & @{term "C (z y) x"}\\
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   277
  prems:      & @{term "A x y"}, @{term "B y x"}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   278
  \end{tabular}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   279
  \end{center}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   280
*}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   281
(*<*)oops(*>*)
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   282
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   283
93
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   284
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   285
  @{ML PRIMITIVE}? @{ML SUBGOAL} see page 32 in ref
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   286
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   287
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   288
text {* 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   289
  @{ML all_tac} @{ML no_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   290
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   291
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   292
section {* Operations on Tactics *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   293
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   294
text {* THEN *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   295
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   296
lemma shows "(True \<and> True) \<and> False"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   297
apply(tactic {* (rtac @{thm conjI} 1) THEN (rtac @{thm conjI} 1) *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   298
txt {* @{subgoals [display]} *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   299
(*<*)oops(*>*)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   300
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   301
lemma shows "True \<and> False"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   302
apply(tactic {* (rtac @{thm disjI1} 1) ORELSE (rtac @{thm conjI} 1) *})
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   303
txt {* @{subgoals [display]} *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   304
(*<*)oops(*>*)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   305
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   306
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   307
text {*
95
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   308
  @{ML EVERY} @{ML REPEAT} 
93
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   309
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   310
  @{ML rewrite_goals_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   311
  @{ML cut_facts_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   312
  @{ML ObjectLogic.full_atomize_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   313
  @{ML ObjectLogic.rulify_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   314
  @{ML resolve_tac}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   315
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   316
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   317
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   318
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   319
text {*
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   320
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   321
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   322
  A goal (or goal state) is a special @{ML_type thm}, which by
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   323
  convention is an implication of the form:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   324
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   325
  @{text[display] "A\<^isub>1 \<Longrightarrow> \<dots> \<Longrightarrow> A\<^isub>n \<Longrightarrow> #(C)"}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   326
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   327
  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
   328
  subgoals. 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   329
  Since the goal @{term C} can potentially be an implication, there is a
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   330
  @{text "#"} wrapped around it, which prevents that premises are 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   331
  misinterpreted as open subgoals. The wrapper @{text "# :: prop \<Rightarrow>
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   332
  prop"} is just the identity function and used as a syntactic marker. 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   333
  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   334
 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   335
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   336
 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   337
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   338
  While tactics can operate on the subgoals (the @{text "A\<^isub>i"} above), they 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   339
  are expected to leave the conclusion @{term C} intact, with the 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   340
  exception of possibly instantiating schematic variables. 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   341
 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   342
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   343
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   344
*}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   345
95
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   346
section {* Structured Proofs *}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   347
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   348
lemma True
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   349
proof
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   350
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   351
  {
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   352
    fix A B C
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   353
    assume r: "A & B \<Longrightarrow> C"
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   354
    assume A B
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   355
    then have "A & B" ..
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   356
    then have C by (rule r)
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   357
  }
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   358
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   359
  {
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   360
    fix A B C
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   361
    assume r: "A & B \<Longrightarrow> C"
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   362
    assume A B
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   363
    note conjI [OF this]
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   364
    note r [OF this]
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   365
  }
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   366
oops
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   367
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   368
ML {* fun prop ctxt s =
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   369
  Thm.cterm_of (ProofContext.theory_of ctxt) (Syntax.read_prop ctxt s) *}
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   370
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   371
ML {* 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   372
  val ctxt0 = @{context};
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   373
  val ctxt = ctxt0;
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   374
  val (_, ctxt) = Variable.add_fixes ["A", "B", "C"] ctxt;
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   375
  val ([r], ctxt) = Assumption.add_assumes [prop ctxt "A & B \<Longrightarrow> C"] ctxt;
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   376
  val (this, ctxt) = Assumption.add_assumes [prop ctxt "A", prop ctxt "B"] ctxt;
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   377
  val this = [@{thm conjI} OF this]; 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   378
  val this = r OF this;
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   379
  val this = Assumption.export false ctxt ctxt0 this 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   380
  val this = Variable.export ctxt ctxt0 [this] 
7235374f34c8 added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents: 93
diff changeset
   381
*}
93
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   382
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   383
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   384
end