src/Doc/Tutorial/Rules/Basic.thy
author wenzelm
Fri, 19 Jul 2013 17:35:12 +0200
changeset 52709 0e4bacf21e77
parent 48985 5386df44a037
child 57512 cc97b347b301
permissions -rw-r--r--
turned pattern unify flag into configuration option (global only);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13756
diff changeset
     1
theory Basic imports Main begin
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     2
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     3
lemma conj_rule: "\<lbrakk> P; Q \<rbrakk> \<Longrightarrow> P \<and> (Q \<and> P)"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     4
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     5
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     6
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     7
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     8
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     9
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    10
    
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    11
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    12
lemma disj_swap: "P | Q \<Longrightarrow> Q | P"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    13
apply (erule disjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    14
 apply (rule disjI2)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    15
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    16
apply (rule disjI1)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    17
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    18
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    19
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    20
lemma conj_swap: "P \<and> Q \<Longrightarrow> Q \<and> P"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    21
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    22
 apply (drule conjunct2)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    23
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    24
apply (drule conjunct1)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    25
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    26
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    27
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    28
lemma imp_uncurry: "P \<longrightarrow> Q \<longrightarrow> R \<Longrightarrow> P \<and> Q \<longrightarrow> R"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    29
apply (rule impI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    30
apply (erule conjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    31
apply (drule mp)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    32
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    33
apply (drule mp)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    34
  apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    35
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    36
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    37
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    38
text {*
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    39
by eliminates uses of assumption and done
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    40
*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    41
13550
5a176b8dda84 removal of blast.overloaded
paulson
parents: 12408
diff changeset
    42
lemma imp_uncurry': "P \<longrightarrow> Q \<longrightarrow> R \<Longrightarrow> P \<and> Q \<longrightarrow> R"
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    43
apply (rule impI)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    44
apply (erule conjE)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    45
apply (drule mp)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    46
 apply assumption
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    47
by (drule mp)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    48
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    49
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    50
text {*
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    51
substitution
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    52
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    53
@{thm[display] ssubst}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    54
\rulename{ssubst}
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
    55
*}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    56
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    57
lemma "\<lbrakk> x = f x; P(f x) \<rbrakk> \<Longrightarrow> P x"
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    58
by (erule ssubst)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    59
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    60
text {*
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    61
also provable by simp (re-orients)
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
    62
*}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    63
11182
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    64
text {*
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    65
the subst method
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    66
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    67
@{thm[display] mult_commute}
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    68
\rulename{mult_commute}
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    69
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    70
this would fail:
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    71
apply (simp add: mult_commute) 
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
    72
*}
11182
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    73
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    74
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    75
lemma "\<lbrakk>P x y z; Suc x < y\<rbrakk> \<Longrightarrow> f z = x*y"
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    76
txt{*
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    77
@{subgoals[display,indent=0,margin=65]}
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
    78
*}
11182
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    79
apply (subst mult_commute) 
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    80
txt{*
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    81
@{subgoals[display,indent=0,margin=65]}
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
    82
*}
11182
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    83
oops
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    84
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    85
(*exercise involving THEN*)
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    86
lemma "\<lbrakk>P x y z; Suc x < y\<rbrakk> \<Longrightarrow> f z = x*y"
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    87
apply (rule mult_commute [THEN ssubst]) 
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    88
oops
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    89
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    90
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
    91
lemma "\<lbrakk>x = f x; triple (f x) (f x) x\<rbrakk> \<Longrightarrow> triple x x x"
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    92
apply (erule ssubst) 
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    93
  --{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    94
back --{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    95
back --{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    96
back --{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    97
back --{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    98
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    99
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   100
11182
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   101
lemma "\<lbrakk> x = f x; triple (f x) (f x) x \<rbrakk> \<Longrightarrow> triple x x x"
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   102
apply (erule ssubst, assumption)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   103
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   104
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   105
text{*
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   106
or better still 
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   107
*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   108
11182
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   109
lemma "\<lbrakk> x = f x; triple (f x) (f x) x \<rbrakk> \<Longrightarrow> triple x x x"
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   110
by (erule ssubst)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   111
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   112
11182
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   113
lemma "\<lbrakk> x = f x; triple (f x) (f x) x \<rbrakk> \<Longrightarrow> triple x x x"
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   114
apply (erule_tac P="\<lambda>u. triple u u x" in ssubst)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   115
apply (assumption)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   116
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   117
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   118
11182
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   119
lemma "\<lbrakk> x = f x; triple (f x) (f x) x \<rbrakk> \<Longrightarrow> triple x x x"
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   120
by (erule_tac P="\<lambda>u. triple u u x" in ssubst)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   121
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   122
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   123
text {*
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   124
negation
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   125
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   126
@{thm[display] notI}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   127
\rulename{notI}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   128
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   129
@{thm[display] notE}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   130
\rulename{notE}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   131
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   132
@{thm[display] classical}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   133
\rulename{classical}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   134
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   135
@{thm[display] contrapos_pp}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   136
\rulename{contrapos_pp}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   137
11407
138919f1a135 tweaks for new version
paulson
parents: 11244
diff changeset
   138
@{thm[display] contrapos_pn}
138919f1a135 tweaks for new version
paulson
parents: 11244
diff changeset
   139
\rulename{contrapos_pn}
138919f1a135 tweaks for new version
paulson
parents: 11244
diff changeset
   140
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   141
@{thm[display] contrapos_np}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   142
\rulename{contrapos_np}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   143
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   144
@{thm[display] contrapos_nn}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   145
\rulename{contrapos_nn}
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   146
*}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   147
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   148
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   149
lemma "\<lbrakk>\<not>(P\<longrightarrow>Q); \<not>(R\<longrightarrow>Q)\<rbrakk> \<Longrightarrow> R"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   150
apply (erule_tac Q="R\<longrightarrow>Q" in contrapos_np)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   151
        --{* @{subgoals[display,indent=0,margin=65]} *}
12390
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11458
diff changeset
   152
apply (intro impI)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   153
        --{* @{subgoals[display,indent=0,margin=65]} *}
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   154
by (erule notE)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   155
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   156
text {*
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   157
@{thm[display] disjCI}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   158
\rulename{disjCI}
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   159
*}
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   160
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   161
lemma "(P \<or> Q) \<and> R \<Longrightarrow> P \<or> Q \<and> R"
12408
2884148a9fe9 intro and elim now require arguments
paulson
parents: 12390
diff changeset
   162
apply (intro disjCI conjI)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   163
        --{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   164
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   165
apply (elim conjE disjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   166
 apply assumption
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   167
        --{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   168
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   169
by (erule contrapos_np, rule conjI)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   170
text{*
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   171
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{6}}\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   172
\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   173
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   174
{\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R\ {\isasymLongrightarrow}\ P\ {\isasymor}\ Q\ {\isasymand}\ R\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   175
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ Q\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   176
\ {\isadigit{2}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ R
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   177
*}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   178
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   179
11182
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   180
text{*rule_tac, etc.*}
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   181
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   182
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   183
lemma "P&Q"
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   184
apply (rule_tac P=P and Q=Q in conjI)
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   185
oops
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   186
e123a50aa949 minor fixes
paulson
parents: 11154
diff changeset
   187
13756
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   188
text{*unification failure trace *}
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   189
52709
0e4bacf21e77 turned pattern unify flag into configuration option (global only);
wenzelm
parents: 48985
diff changeset
   190
declare [[unify_trace_failure = true]]
13756
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   191
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   192
lemma "P(a, f(b, g(e,a), b), a) \<Longrightarrow> P(a, f(b, g(c,a), b), a)"
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   193
txt{*
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   194
@{subgoals[display,indent=0,margin=65]}
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   195
apply assumption
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   196
Clash: e =/= c
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   197
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   198
Clash: == =/= Trueprop
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   199
*}
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   200
oops
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   201
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   202
lemma "\<forall>x y. P(x,y) --> P(y,x)"
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   203
apply auto
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   204
txt{*
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   205
@{subgoals[display,indent=0,margin=65]}
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   206
apply assumption
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   207
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   208
Clash: bound variable x (depth 1) =/= bound variable y (depth 0)
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   209
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   210
Clash: == =/= Trueprop
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   211
Clash: == =/= Trueprop
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   212
*}
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   213
oops
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   214
52709
0e4bacf21e77 turned pattern unify flag into configuration option (global only);
wenzelm
parents: 48985
diff changeset
   215
declare [[unify_trace_failure = false]]
13756
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   216
41abb61ecce9 new material for trace_unify_fail
paulson
parents: 13550
diff changeset
   217
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   218
text{*Quantifiers*}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   219
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   220
text {*
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   221
@{thm[display] allI}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   222
\rulename{allI}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   223
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   224
@{thm[display] allE}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   225
\rulename{allE}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   226
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   227
@{thm[display] spec}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   228
\rulename{spec}
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   229
*}
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   230
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   231
lemma "\<forall>x. P x \<longrightarrow> P x"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   232
apply (rule allI)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   233
by (rule impI)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   234
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   235
lemma "(\<forall>x. P \<longrightarrow> Q x) \<Longrightarrow> P \<longrightarrow> (\<forall>x. Q x)"
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   236
apply (rule impI, rule allI)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   237
apply (drule spec)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   238
by (drule mp)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   239
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   240
text{*rename_tac*}
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   241
lemma "x < y \<Longrightarrow> \<forall>x y. P x (f y)"
12390
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11458
diff changeset
   242
apply (intro allI)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   243
        --{* @{subgoals[display,indent=0,margin=65]} *}
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   244
apply (rename_tac v w)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   245
        --{* @{subgoals[display,indent=0,margin=65]} *}
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   246
oops
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   247
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   248
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   249
lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (h x); P a\<rbrakk> \<Longrightarrow> P(h (h a))"
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   250
apply (frule spec)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   251
        --{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   252
apply (drule mp, assumption)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   253
apply (drule spec)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   254
        --{* @{subgoals[display,indent=0,margin=65]} *}
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   255
by (drule mp)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   256
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   257
lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (f x); P a\<rbrakk> \<Longrightarrow> P(f (f a))"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   258
by blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   259
11234
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   260
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   261
text{*
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   262
the existential quantifier*}
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   263
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   264
text {*
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   265
@{thm[display]"exI"}
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   266
\rulename{exI}
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   267
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   268
@{thm[display]"exE"}
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   269
\rulename{exE}
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   270
*}
11234
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   271
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   272
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   273
text{*
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   274
instantiating quantifiers explicitly by rule_tac and erule_tac*}
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   275
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   276
lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (h x); P a\<rbrakk> \<Longrightarrow> P(h (h a))"
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   277
apply (frule spec)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   278
        --{* @{subgoals[display,indent=0,margin=65]} *}
11234
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   279
apply (drule mp, assumption)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   280
        --{* @{subgoals[display,indent=0,margin=65]} *}
11234
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   281
apply (drule_tac x = "h a" in spec)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   282
        --{* @{subgoals[display,indent=0,margin=65]} *}
11234
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   283
by (drule mp)
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   284
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   285
text {*
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   286
@{thm[display]"dvd_def"}
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   287
\rulename{dvd_def}
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   288
*}
11234
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   289
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   290
lemma mult_dvd_mono: "\<lbrakk>i dvd m; j dvd n\<rbrakk> \<Longrightarrow> i*j dvd (m*n :: nat)"
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   291
apply (simp add: dvd_def)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   292
        --{* @{subgoals[display,indent=0,margin=65]} *}
11234
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   293
apply (erule exE) 
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   294
        --{* @{subgoals[display,indent=0,margin=65]} *}
11234
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   295
apply (erule exE) 
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   296
        --{* @{subgoals[display,indent=0,margin=65]} *}
11407
138919f1a135 tweaks for new version
paulson
parents: 11244
diff changeset
   297
apply (rename_tac l)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   298
        --{* @{subgoals[display,indent=0,margin=65]} *}
11407
138919f1a135 tweaks for new version
paulson
parents: 11244
diff changeset
   299
apply (rule_tac x="k*l" in exI) 
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32833
diff changeset
   300
        --{* @{subgoals[display,indent=0,margin=65]} *}
11234
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   301
apply simp
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   302
done
6902638af59e quantifier instantiation
paulson
parents: 11182
diff changeset
   303
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   304
text{*
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   305
Hilbert-epsilon theorems*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   306
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   307
text{*
11458
09a6c44a48ea numerous stylistic changes and indexing
paulson
parents: 11456
diff changeset
   308
@{thm[display] the_equality[no_vars]}
09a6c44a48ea numerous stylistic changes and indexing
paulson
parents: 11456
diff changeset
   309
\rulename{the_equality}
09a6c44a48ea numerous stylistic changes and indexing
paulson
parents: 11456
diff changeset
   310
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   311
@{thm[display] some_equality[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   312
\rulename{some_equality}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   313
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   314
@{thm[display] someI[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   315
\rulename{someI}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   316
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   317
@{thm[display] someI2[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   318
\rulename{someI2}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   319
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   320
@{thm[display] someI_ex[no_vars]}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   321
\rulename{someI_ex}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   322
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   323
needed for examples
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   324
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   325
@{thm[display] inv_def[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   326
\rulename{inv_def}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   327
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   328
@{thm[display] Least_def[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   329
\rulename{Least_def}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   330
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   331
@{thm[display] order_antisym[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   332
\rulename{order_antisym}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   333
*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   334
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   335
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   336
lemma "inv Suc (Suc n) = n"
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   337
by (simp add: inv_def)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   338
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   339
text{*but we know nothing about inv Suc 0*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   340
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   341
theorem Least_equality:
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   342
     "\<lbrakk> P (k::nat);  \<forall>x. P x \<longrightarrow> k \<le> x \<rbrakk> \<Longrightarrow> (LEAST x. P(x)) = k"
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11407
diff changeset
   343
apply (simp add: Least_def)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   344
 
11458
09a6c44a48ea numerous stylistic changes and indexing
paulson
parents: 11456
diff changeset
   345
txt{*
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   346
@{subgoals[display,indent=0,margin=65]}
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   347
*}
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   348
   
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11407
diff changeset
   349
apply (rule the_equality)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   350
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   351
txt{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   352
@{subgoals[display,indent=0,margin=65]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   353
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   354
first subgoal is existence; second is uniqueness
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   355
*}
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   356
by (auto intro: order_antisym)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   357
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   358
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   359
theorem axiom_of_choice:
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   360
     "(\<forall>x. \<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)"
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   361
apply (rule exI, rule allI)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   362
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   363
txt{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   364
@{subgoals[display,indent=0,margin=65]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   365
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   366
state after intro rules
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   367
*}
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   368
apply (drule spec, erule exE)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   369
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   370
txt{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   371
@{subgoals[display,indent=0,margin=65]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   372
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   373
applying @text{someI} automatically instantiates
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   374
@{term f} to @{term "\<lambda>x. SOME y. P x y"}
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   375
*}
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   376
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   377
by (rule someI)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   378
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   379
(*both can be done by blast, which however hasn't been introduced yet*)
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   380
lemma "[| P (k::nat);  \<forall>x. P x \<longrightarrow> k \<le> x |] ==> (LEAST x. P(x)) = k"
11154
042015819774 for the change to LEAST
paulson
parents: 11080
diff changeset
   381
apply (simp add: Least_def LeastM_def)
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   382
by (blast intro: some_equality order_antisym)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   383
13550
5a176b8dda84 removal of blast.overloaded
paulson
parents: 12408
diff changeset
   384
theorem axiom_of_choice': "(\<forall>x. \<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)"
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   385
apply (rule exI [of _  "\<lambda>x. SOME y. P x y"])
42209
bc7d938991e0 Deletion of all semicolons, because they interfere with Proof General
paulson
parents: 38798
diff changeset
   386
by (blast intro: someI)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   387
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   388
text{*end of Epsilon section*}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   389
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   390
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   391
lemma "(\<exists>x. P x) \<or> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<or> Q x"
12390
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11458
diff changeset
   392
apply (elim exE disjE)
12408
2884148a9fe9 intro and elim now require arguments
paulson
parents: 12390
diff changeset
   393
 apply (intro exI disjI1)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   394
 apply assumption
12408
2884148a9fe9 intro and elim now require arguments
paulson
parents: 12390
diff changeset
   395
apply (intro exI disjI2)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   396
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   397
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   398
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   399
lemma "(P\<longrightarrow>Q) \<or> (Q\<longrightarrow>P)"
12390
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11458
diff changeset
   400
apply (intro disjCI impI)
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11458
diff changeset
   401
apply (elim notE)
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11458
diff changeset
   402
apply (intro impI)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   403
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   404
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   405
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   406
lemma "(P\<or>Q)\<and>(P\<or>R) \<Longrightarrow> P \<or> (Q\<and>R)"
12390
2fa13b499975 adapted intr/elim uses;
wenzelm
parents: 11458
diff changeset
   407
apply (intro disjCI conjI)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   408
apply (elim conjE disjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   409
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   410
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   411
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   412
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   413
(*apply elim*)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   414
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   415
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   416
lemma "(\<exists>x. P \<and> Q x) \<Longrightarrow> P \<and> (\<exists>x. Q x)"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   417
apply (erule exE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   418
apply (erule conjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   419
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   420
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   421
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   422
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   423
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   424
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   425
lemma "(\<exists>x. P x) \<and> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<and> Q x"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   426
apply (erule conjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   427
apply (erule exE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   428
apply (erule exE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   429
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   430
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   431
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   432
oops
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   433
11407
138919f1a135 tweaks for new version
paulson
parents: 11244
diff changeset
   434
lemma "\<forall>y. R y y \<Longrightarrow> \<exists>x. \<forall>y. R x y"
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   435
apply (rule exI) 
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   436
  --{* @{subgoals[display,indent=0,margin=65]} *}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   437
apply (rule allI) 
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   438
  --{* @{subgoals[display,indent=0,margin=65]} *}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   439
apply (drule spec) 
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   440
  --{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   441
oops
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   442
11407
138919f1a135 tweaks for new version
paulson
parents: 11244
diff changeset
   443
lemma "\<forall>x. \<exists>y. x=y"
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   444
apply (rule allI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   445
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   446
apply (rule refl)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   447
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   448
11407
138919f1a135 tweaks for new version
paulson
parents: 11244
diff changeset
   449
lemma "\<exists>x. \<forall>y. x=y"
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   450
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   451
apply (rule allI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   452
oops
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   453
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   454
end