doc-src/TutorialI/Rules/Basic.thy
author paulson
Mon, 22 Jan 2001 11:01:49 +0100
changeset 10957 2a4a50e7ddf2
parent 10843 f2e4e383dbca
child 11080 22855d091249
permissions -rw-r--r--
rename_tac example; tidying to use @subgoals
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
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   127
lemma "(P \<or> Q) \<and> R \<Longrightarrow> P \<or> Q \<and> R"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   128
apply intro
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   129
	--{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   130
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   131
apply (elim conjE disjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   132
 apply assumption
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   133
	--{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   134
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   135
by (erule contrapos_np, rule conjI)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   136
text{*
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   137
proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{6}}\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   138
\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   139
goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   140
{\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R\ {\isasymLongrightarrow}\ P\ {\isasymor}\ Q\ {\isasymand}\ R\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   141
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ Q\isanewline
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   142
\ {\isadigit{2}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ R
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   143
*}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   144
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   145
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   146
text{*Quantifiers*}
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   147
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   148
lemma "\<forall>x. P x \<longrightarrow> P x"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   149
apply (rule allI)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   150
by (rule impI)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   151
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   152
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
   153
apply (rule impI, rule allI)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   154
apply (drule spec)
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   155
by (drule mp)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   156
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   157
text{*NEW: rename_tac*}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   158
lemma "x < y \<Longrightarrow> \<forall>x y. P x (f y)"
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   159
apply intro
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   160
	--{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   161
apply (rename_tac v w)
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   162
	--{* @{subgoals[display,indent=0,margin=65]} *}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   163
oops
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   164
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   165
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   166
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
   167
apply (frule spec)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   168
	--{* @{subgoals[display,indent=0,margin=65]} *}
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   169
apply (drule mp, assumption)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   170
apply (drule spec)
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   171
	--{* @{subgoals[display,indent=0,margin=65]} *}
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   172
by (drule mp)
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   173
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   174
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   175
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
   176
by blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   177
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   178
text{*
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   179
Hilbert-epsilon theorems*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   180
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   181
text{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   182
@{thm[display] some_equality[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   183
\rulename{some_equality}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   184
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   185
@{thm[display] someI[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   186
\rulename{someI}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   187
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   188
@{thm[display] someI2[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   189
\rulename{someI2}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   190
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   191
needed for examples
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   192
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   193
@{thm[display] inv_def[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   194
\rulename{inv_def}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   195
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   196
@{thm[display] Least_def[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   197
\rulename{Least_def}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   198
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   199
@{thm[display] order_antisym[no_vars]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   200
\rulename{order_antisym}
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
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   203
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   204
lemma "inv Suc (Suc x) = x"
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   205
by (simp add: inv_def)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   206
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   207
text{*but we know nothing about inv Suc 0*}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   208
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   209
theorem Least_equality:
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   210
     "\<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
   211
apply (simp add: Least_def)
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
txt{*omit maybe?
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   214
@{subgoals[display,indent=0,margin=65]}
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
   
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   217
apply (rule some_equality)
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
txt{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   220
@{subgoals[display,indent=0,margin=65]}
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
first subgoal is existence; second is uniqueness
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   223
*};
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   224
by (auto intro: order_antisym)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   225
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
theorem axiom_of_choice:
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   228
     "(\<forall>x. \<exists> y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)"
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   229
apply (rule exI, rule allI)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   230
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   231
txt{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   232
@{subgoals[display,indent=0,margin=65]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   233
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   234
state after intro rules
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
apply (drule spec, erule exE)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   237
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   238
txt{*
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   239
@{subgoals[display,indent=0,margin=65]}
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   240
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   241
applying @text{someI} automatically instantiates
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   242
@{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
   243
*};
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   244
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   245
by (rule someI)
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
(*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
   248
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
   249
apply (simp add: Least_def)
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   250
by (blast intro: some_equality order_antisym);
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   251
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   252
theorem axiom_of_choice: "(\<forall>x. \<exists> y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)"
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   253
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
   254
by (blast intro: someI);
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   255
10957
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   256
text{*end of Epsilon section*}
2a4a50e7ddf2 rename_tac example; tidying to use @subgoals
paulson
parents: 10843
diff changeset
   257
10843
f2e4e383dbca introduction of "by" and a few examples of SOME
paulson
parents: 10341
diff changeset
   258
10295
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   259
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
   260
apply elim
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   261
 apply intro
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   262
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   263
apply (intro exI disjI2) (*or else we get disjCI*)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   264
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   265
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   266
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   267
lemma "(P\<longrightarrow>Q) \<or> (Q\<longrightarrow>P)"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   268
apply intro
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   269
apply elim
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   270
apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   271
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   272
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   273
lemma "(P\<or>Q)\<and>(P\<or>R) \<Longrightarrow> P \<or> (Q\<and>R)"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   274
apply intro
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   275
apply (elim conjE disjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   276
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   277
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   278
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   279
apply blast
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   280
(*apply elim*)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   281
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   282
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   283
lemma "(\<exists>x. P \<and> Q x) \<Longrightarrow> P \<and> (\<exists>x. Q x)"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   284
apply (erule exE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   285
apply (erule conjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   286
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   287
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   288
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   289
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   290
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   291
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   292
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
   293
apply (erule conjE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   294
apply (erule exE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   295
apply (erule exE)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   296
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   297
apply (rule conjI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   298
 apply assumption
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   299
oops
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   300
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   301
lemma "\<forall> z. R z z \<Longrightarrow> \<exists>x. \<forall> y. R x y"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   302
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   303
apply (rule allI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   304
apply (drule spec)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   305
oops
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   306
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   307
lemma "\<forall>x. \<exists> y. x=y"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   308
apply (rule allI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   309
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   310
apply (rule refl)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   311
done
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   312
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   313
lemma "\<exists>x. \<forall> y. x=y"
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   314
apply (rule exI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   315
apply (rule allI)
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   316
oops
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   317
8eb12693cead the Rules chapter and theories
paulson
parents:
diff changeset
   318
end