doc-src/TutorialI/Rules/Basic.thy
author paulson
Wed, 07 Feb 2001 16:37:24 +0100
changeset 11080 22855d091249
parent 10957 2a4a50e7ddf2
child 11154 042015819774
permissions -rw-r--r--
various revisions in response to comments from Tobias
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10341
6eb91805a012 added the $Id:$ line
paulson
parents: 10295
diff changeset
     1
(* ID:         $Id$ *)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     2
theory Basic = Main:
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     3
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     4
lemma conj_rule: "\<lbrakk> P; Q \<rbrakk> \<Longrightarrow> P \<and> (Q \<and> P)"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     5
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     6
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     7
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     8
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
     9
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    10
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    11
    
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    12
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    13
lemma disj_swap: "P | Q \<Longrightarrow> Q | P"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    14
apply (erule disjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    15
 apply (rule disjI2)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    16
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    17
apply (rule disjI1)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    18
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    19
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    20
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    21
lemma conj_swap: "P \<and> Q \<Longrightarrow> Q \<and> P"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    22
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    23
 apply (drule conjunct2)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    24
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    25
apply (drule conjunct1)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    26
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    27
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    28
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    29
lemma imp_uncurry: "P \<longrightarrow> Q \<longrightarrow> R \<Longrightarrow> P \<and> Q \<longrightarrow> R"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    30
apply (rule impI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    31
apply (erule conjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    32
apply (drule mp)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    33
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    34
apply (drule mp)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    35
  apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    36
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    37
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    38
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    39
text {*
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    40
by eliminates uses of assumption and done
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    41
*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    42
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    43
lemma imp_uncurry: "P \<longrightarrow> Q \<longrightarrow> R \<Longrightarrow> P \<and> Q \<longrightarrow> R"
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    44
apply (rule impI)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    45
apply (erule conjE)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    46
apply (drule mp)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    47
 apply assumption
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    48
by (drule mp)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    49
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    50
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    51
text {*
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    52
substitution
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    53
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    54
@{thm[display] ssubst}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    55
\rulename{ssubst}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    56
*};
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    57
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    58
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
    59
by (erule ssubst)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    60
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    61
text {*
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    62
also provable by simp (re-orients)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    63
*};
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    64
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    65
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x"
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    66
apply (erule ssubst) 
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    67
  --{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    68
back --{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    69
back --{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    70
back --{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    71
back --{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    72
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    73
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    74
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    75
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    76
apply (erule ssubst, assumption)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    77
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    78
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    79
text{*
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
    80
or better still 
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    81
*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    82
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    83
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x"
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    84
by (erule ssubst)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    85
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    86
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    87
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x"
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    88
apply (erule_tac P="\<lambda>u. P u u x" in ssubst)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    89
apply (assumption)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    90
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    91
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    92
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    93
lemma "\<lbrakk> x = f x; P (f x) (f x) x \<rbrakk> \<Longrightarrow> P x x x"
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    94
by (erule_tac P="\<lambda>u. P u u x" in ssubst)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    95
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
    96
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    97
text {*
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    98
negation
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
    99
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   100
@{thm[display] notI}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   101
\rulename{notI}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   102
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   103
@{thm[display] notE}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   104
\rulename{notE}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   105
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   106
@{thm[display] classical}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   107
\rulename{classical}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   108
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   109
@{thm[display] contrapos_pp}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   110
\rulename{contrapos_pp}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   111
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   112
@{thm[display] contrapos_np}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   113
\rulename{contrapos_np}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   114
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   115
@{thm[display] contrapos_nn}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   116
\rulename{contrapos_nn}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   117
*};
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   118
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   119
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   120
lemma "\<lbrakk>\<not>(P\<longrightarrow>Q); \<not>(R\<longrightarrow>Q)\<rbrakk> \<Longrightarrow> R"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   121
apply (erule_tac Q="R\<longrightarrow>Q" in contrapos_np)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   122
	--{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   123
apply intro
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   124
	--{* @{subgoals[display,indent=0,margin=65]} *}
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   125
by (erule notE)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   126
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   127
text {*
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   128
@{thm[display] disjCI}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   129
\rulename{disjCI}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   130
*};
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   131
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   132
lemma "(P \<or> Q) \<and> R \<Longrightarrow> P \<or> Q \<and> R"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   133
apply intro
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   134
	--{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   135
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   136
apply (elim conjE disjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   137
 apply assumption
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   138
	--{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   139
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   140
by (erule contrapos_np, rule conjI)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   141
text{*
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   142
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{6}}\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   143
\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   144
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   145
{\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R\ {\isasymLongrightarrow}\ P\ {\isasymor}\ Q\ {\isasymand}\ R\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   146
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ Q\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   147
\ {\isadigit{2}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ R
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   148
*}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   149
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   150
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   151
text{*Quantifiers*}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   152
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   153
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   154
text {*
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   155
@{thm[display] allI}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   156
\rulename{allI}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   157
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   158
@{thm[display] allE}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   159
\rulename{allE}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   160
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   161
@{thm[display] spec}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   162
\rulename{spec}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   163
*};
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   164
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   165
lemma "\<forall>x. P x \<longrightarrow> P x"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   166
apply (rule allI)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   167
by (rule impI)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   168
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   169
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
   170
apply (rule impI, rule allI)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   171
apply (drule spec)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   172
by (drule mp)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   173
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   174
text{*rename_tac*}
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   175
lemma "x < y \<Longrightarrow> \<forall>x y. P x (f y)"
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   176
apply intro
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   177
	--{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   178
apply (rename_tac v w)
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   179
	--{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   180
oops
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   181
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   182
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   183
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
   184
apply (frule spec)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   185
	--{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   186
apply (drule mp, assumption)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   187
apply (drule spec)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   188
	--{* @{subgoals[display,indent=0,margin=65]} *}
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   189
by (drule mp)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   190
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   191
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   192
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
   193
by blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   194
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   195
text{*
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   196
Hilbert-epsilon theorems*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   197
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   198
text{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   199
@{thm[display] some_equality[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   200
\rulename{some_equality}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   201
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   202
@{thm[display] someI[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   203
\rulename{someI}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   204
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   205
@{thm[display] someI2[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   206
\rulename{someI2}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   207
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   208
@{thm[display] someI_ex[no_vars]}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   209
\rulename{someI_ex}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   210
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   211
needed for examples
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   212
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   213
@{thm[display] inv_def[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   214
\rulename{inv_def}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   215
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   216
@{thm[display] Least_def[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   217
\rulename{Least_def}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   218
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   219
@{thm[display] order_antisym[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   220
\rulename{order_antisym}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   221
*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   222
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   223
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   224
lemma "inv Suc (Suc n) = n"
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   225
by (simp add: inv_def)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   226
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   227
text{*but we know nothing about inv Suc 0*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   228
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   229
theorem Least_equality:
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   230
     "\<lbrakk> P (k::nat);  \<forall>x. P x \<longrightarrow> k \<le> x \<rbrakk> \<Longrightarrow> (LEAST x. P(x)) = k"
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   231
apply (simp add: Least_def)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   232
 
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   233
txt{*omit maybe?
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   234
@{subgoals[display,indent=0,margin=65]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   235
*};
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   236
   
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   237
apply (rule some_equality)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   238
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   239
txt{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   240
@{subgoals[display,indent=0,margin=65]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   241
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   242
first subgoal is existence; second is uniqueness
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   243
*};
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   244
by (auto intro: order_antisym)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   245
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   246
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   247
theorem axiom_of_choice:
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   248
     "(\<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
   249
apply (rule exI, rule allI)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   250
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   251
txt{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   252
@{subgoals[display,indent=0,margin=65]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   253
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   254
state after intro rules
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   255
*};
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   256
apply (drule spec, erule exE)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   257
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   258
txt{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   259
@{subgoals[display,indent=0,margin=65]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   260
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   261
applying @text{someI} automatically instantiates
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   262
@{term f} to @{term "\<lambda>x. SOME y. P x y"}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   263
*};
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   264
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   265
by (rule someI)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   266
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   267
(*both can be done by blast, which however hasn't been introduced yet*)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   268
lemma "[| P (k::nat);  \<forall>x. P x \<longrightarrow> k \<le> x |] ==> (LEAST x. P(x)) = k";
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   269
apply (simp add: Least_def)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   270
by (blast intro: some_equality order_antisym);
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   271
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   272
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
   273
apply (rule exI [of _  "\<lambda>x. SOME y. P x y"])
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   274
by (blast intro: someI);
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   275
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   276
text{*end of Epsilon section*}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   277
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   278
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   279
lemma "(\<exists>x. P x) \<or> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<or> Q x"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   280
apply elim
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   281
 apply intro
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   282
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   283
apply (intro exI disjI2) (*or else we get disjCI*)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   284
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   285
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   286
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   287
lemma "(P\<longrightarrow>Q) \<or> (Q\<longrightarrow>P)"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   288
apply intro
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   289
apply elim
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   290
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   291
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   292
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   293
lemma "(P\<or>Q)\<and>(P\<or>R) \<Longrightarrow> P \<or> (Q\<and>R)"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   294
apply intro
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   295
apply (elim conjE disjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   296
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   297
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   298
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   299
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   300
(*apply elim*)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   301
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   302
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   303
lemma "(\<exists>x. P \<and> Q x) \<Longrightarrow> P \<and> (\<exists>x. Q x)"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   304
apply (erule exE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   305
apply (erule conjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   306
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   307
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   308
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   309
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   310
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   311
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   312
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
   313
apply (erule conjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   314
apply (erule exE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   315
apply (erule exE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   316
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   317
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   318
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   319
oops
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   320
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   321
lemma "\<forall> y. R y y \<Longrightarrow> \<exists>x. \<forall> y. R x y"
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   322
apply (rule exI) 
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   323
  --{* @{subgoals[display,indent=0,margin=65]} *}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   324
apply (rule allI) 
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   325
  --{* @{subgoals[display,indent=0,margin=65]} *}
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   326
apply (drule spec) 
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10957
diff changeset
   327
  --{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   328
oops
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   329
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   330
lemma "\<forall>x. \<exists> y. x=y"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   331
apply (rule allI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   332
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   333
apply (rule refl)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   334
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   335
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   336
lemma "\<exists>x. \<forall> y. x=y"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   337
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   338
apply (rule allI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   339
oops
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   340
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   341
end