src/Doc/Tutorial/Rules/Basic.thy
changeset 67406 23307fd33906
parent 65953 440fe0937b92
child 67443 3abf6a722518
equal deleted inserted replaced
67405:e9ab4ad7bd15 67406:23307fd33906
    33 apply (drule mp)
    33 apply (drule mp)
    34   apply assumption
    34   apply assumption
    35  apply assumption
    35  apply assumption
    36 done
    36 done
    37 
    37 
    38 text {*
    38 text \<open>
    39 by eliminates uses of assumption and done
    39 by eliminates uses of assumption and done
    40 *}
    40 \<close>
    41 
    41 
    42 lemma imp_uncurry': "P \<longrightarrow> Q \<longrightarrow> R \<Longrightarrow> P \<and> Q \<longrightarrow> R"
    42 lemma imp_uncurry': "P \<longrightarrow> Q \<longrightarrow> R \<Longrightarrow> P \<and> Q \<longrightarrow> R"
    43 apply (rule impI)
    43 apply (rule impI)
    44 apply (erule conjE)
    44 apply (erule conjE)
    45 apply (drule mp)
    45 apply (drule mp)
    46  apply assumption
    46  apply assumption
    47 by (drule mp)
    47 by (drule mp)
    48 
    48 
    49 
    49 
    50 text {*
    50 text \<open>
    51 substitution
    51 substitution
    52 
    52 
    53 @{thm[display] ssubst}
    53 @{thm[display] ssubst}
    54 \rulename{ssubst}
    54 \rulename{ssubst}
    55 *}
    55 \<close>
    56 
    56 
    57 lemma "\<lbrakk> x = f x; P(f x) \<rbrakk> \<Longrightarrow> P x"
    57 lemma "\<lbrakk> x = f x; P(f x) \<rbrakk> \<Longrightarrow> P x"
    58 by (erule ssubst)
    58 by (erule ssubst)
    59 
    59 
    60 text {*
    60 text \<open>
    61 also provable by simp (re-orients)
    61 also provable by simp (re-orients)
    62 *}
    62 \<close>
    63 
    63 
    64 text {*
    64 text \<open>
    65 the subst method
    65 the subst method
    66 
    66 
    67 @{thm[display] mult.commute}
    67 @{thm[display] mult.commute}
    68 \rulename{mult.commute}
    68 \rulename{mult.commute}
    69 
    69 
    70 this would fail:
    70 this would fail:
    71 apply (simp add: mult.commute) 
    71 apply (simp add: mult.commute) 
    72 *}
    72 \<close>
    73 
    73 
    74 
    74 
    75 lemma "\<lbrakk>P x y z; Suc x < y\<rbrakk> \<Longrightarrow> f z = x*y"
    75 lemma "\<lbrakk>P x y z; Suc x < y\<rbrakk> \<Longrightarrow> f z = x*y"
    76 txt{*
    76 txt\<open>
    77 @{subgoals[display,indent=0,margin=65]}
    77 @{subgoals[display,indent=0,margin=65]}
    78 *}
    78 \<close>
    79 apply (subst mult.commute) 
    79 apply (subst mult.commute) 
    80 txt{*
    80 txt\<open>
    81 @{subgoals[display,indent=0,margin=65]}
    81 @{subgoals[display,indent=0,margin=65]}
    82 *}
    82 \<close>
    83 oops
    83 oops
    84 
    84 
    85 (*exercise involving THEN*)
    85 (*exercise involving THEN*)
    86 lemma "\<lbrakk>P x y z; Suc x < y\<rbrakk> \<Longrightarrow> f z = x*y"
    86 lemma "\<lbrakk>P x y z; Suc x < y\<rbrakk> \<Longrightarrow> f z = x*y"
    87 apply (rule mult.commute [THEN ssubst]) 
    87 apply (rule mult.commute [THEN ssubst]) 
    88 oops
    88 oops
    89 
    89 
    90 
    90 
    91 lemma "\<lbrakk>x = f x; triple (f x) (f x) x\<rbrakk> \<Longrightarrow> triple x x x"
    91 lemma "\<lbrakk>x = f x; triple (f x) (f x) x\<rbrakk> \<Longrightarrow> triple x x x"
    92 apply (erule ssubst) 
    92 apply (erule ssubst) 
    93   --{* @{subgoals[display,indent=0,margin=65]} *}
    93   \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
    94 back --{* @{subgoals[display,indent=0,margin=65]} *}
    94 back \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
    95 back --{* @{subgoals[display,indent=0,margin=65]} *}
    95 back \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
    96 back --{* @{subgoals[display,indent=0,margin=65]} *}
    96 back \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
    97 back --{* @{subgoals[display,indent=0,margin=65]} *}
    97 back \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
    98 apply assumption
    98 apply assumption
    99 done
    99 done
   100 
   100 
   101 lemma "\<lbrakk> x = f x; triple (f x) (f x) x \<rbrakk> \<Longrightarrow> triple x x x"
   101 lemma "\<lbrakk> x = f x; triple (f x) (f x) x \<rbrakk> \<Longrightarrow> triple x x x"
   102 apply (erule ssubst, assumption)
   102 apply (erule ssubst, assumption)
   103 done
   103 done
   104 
   104 
   105 text{*
   105 text\<open>
   106 or better still 
   106 or better still 
   107 *}
   107 \<close>
   108 
   108 
   109 lemma "\<lbrakk> x = f x; triple (f x) (f x) x \<rbrakk> \<Longrightarrow> triple x x x"
   109 lemma "\<lbrakk> x = f x; triple (f x) (f x) x \<rbrakk> \<Longrightarrow> triple x x x"
   110 by (erule ssubst)
   110 by (erule ssubst)
   111 
   111 
   112 
   112 
   118 
   118 
   119 lemma "\<lbrakk> x = f x; triple (f x) (f x) x \<rbrakk> \<Longrightarrow> triple x x x"
   119 lemma "\<lbrakk> x = f x; triple (f x) (f x) x \<rbrakk> \<Longrightarrow> triple x x x"
   120 by (erule_tac P="\<lambda>u. triple u u x" in ssubst)
   120 by (erule_tac P="\<lambda>u. triple u u x" in ssubst)
   121 
   121 
   122 
   122 
   123 text {*
   123 text \<open>
   124 negation
   124 negation
   125 
   125 
   126 @{thm[display] notI}
   126 @{thm[display] notI}
   127 \rulename{notI}
   127 \rulename{notI}
   128 
   128 
   141 @{thm[display] contrapos_np}
   141 @{thm[display] contrapos_np}
   142 \rulename{contrapos_np}
   142 \rulename{contrapos_np}
   143 
   143 
   144 @{thm[display] contrapos_nn}
   144 @{thm[display] contrapos_nn}
   145 \rulename{contrapos_nn}
   145 \rulename{contrapos_nn}
   146 *}
   146 \<close>
   147 
   147 
   148 
   148 
   149 lemma "\<lbrakk>\<not>(P\<longrightarrow>Q); \<not>(R\<longrightarrow>Q)\<rbrakk> \<Longrightarrow> R"
   149 lemma "\<lbrakk>\<not>(P\<longrightarrow>Q); \<not>(R\<longrightarrow>Q)\<rbrakk> \<Longrightarrow> R"
   150 apply (erule_tac Q="R\<longrightarrow>Q" in contrapos_np)
   150 apply (erule_tac Q="R\<longrightarrow>Q" in contrapos_np)
   151         --{* @{subgoals[display,indent=0,margin=65]} *}
   151         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   152 apply (intro impI)
   152 apply (intro impI)
   153         --{* @{subgoals[display,indent=0,margin=65]} *}
   153         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   154 by (erule notE)
   154 by (erule notE)
   155 
   155 
   156 text {*
   156 text \<open>
   157 @{thm[display] disjCI}
   157 @{thm[display] disjCI}
   158 \rulename{disjCI}
   158 \rulename{disjCI}
   159 *}
   159 \<close>
   160 
   160 
   161 lemma "(P \<or> Q) \<and> R \<Longrightarrow> P \<or> Q \<and> R"
   161 lemma "(P \<or> Q) \<and> R \<Longrightarrow> P \<or> Q \<and> R"
   162 apply (intro disjCI conjI)
   162 apply (intro disjCI conjI)
   163         --{* @{subgoals[display,indent=0,margin=65]} *}
   163         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   164 
   164 
   165 apply (elim conjE disjE)
   165 apply (elim conjE disjE)
   166  apply assumption
   166  apply assumption
   167         --{* @{subgoals[display,indent=0,margin=65]} *}
   167         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   168 
   168 
   169 by (erule contrapos_np, rule conjI)
   169 by (erule contrapos_np, rule conjI)
   170 text{*
   170 text\<open>
   171 proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{6}}\isanewline
   171 proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{6}}\isanewline
   172 \isanewline
   172 \isanewline
   173 goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
   173 goal\ {\isacharparenleft}lemma{\isacharparenright}{\isacharcolon}\isanewline
   174 {\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R\ {\isasymLongrightarrow}\ P\ {\isasymor}\ Q\ {\isasymand}\ R\isanewline
   174 {\isacharparenleft}P\ {\isasymor}\ Q{\isacharparenright}\ {\isasymand}\ R\ {\isasymLongrightarrow}\ P\ {\isasymor}\ Q\ {\isasymand}\ R\isanewline
   175 \ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ Q\isanewline
   175 \ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ Q\isanewline
   176 \ {\isadigit{2}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ R
   176 \ {\isadigit{2}}{\isachardot}\ {\isasymlbrakk}R{\isacharsemicolon}\ Q{\isacharsemicolon}\ {\isasymnot}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ R
   177 *}
   177 \<close>
   178 
   178 
   179 
   179 
   180 text{*rule_tac, etc.*}
   180 text\<open>rule_tac, etc.\<close>
   181 
   181 
   182 
   182 
   183 lemma "P&Q"
   183 lemma "P&Q"
   184 apply (rule_tac P=P and Q=Q in conjI)
   184 apply (rule_tac P=P and Q=Q in conjI)
   185 oops
   185 oops
   186 
   186 
   187 
   187 
   188 text{*unification failure trace *}
   188 text\<open>unification failure trace\<close>
   189 
   189 
   190 declare [[unify_trace_failure = true]]
   190 declare [[unify_trace_failure = true]]
   191 
   191 
   192 lemma "P(a, f(b, g(e,a), b), a) \<Longrightarrow> P(a, f(b, g(c,a), b), a)"
   192 lemma "P(a, f(b, g(e,a), b), a) \<Longrightarrow> P(a, f(b, g(c,a), b), a)"
   193 txt{*
   193 txt\<open>
   194 @{subgoals[display,indent=0,margin=65]}
   194 @{subgoals[display,indent=0,margin=65]}
   195 apply assumption
   195 apply assumption
   196 Clash: e =/= c
   196 Clash: e =/= c
   197 
   197 
   198 Clash: == =/= Trueprop
   198 Clash: == =/= Trueprop
   199 *}
   199 \<close>
   200 oops
   200 oops
   201 
   201 
   202 lemma "\<forall>x y. P(x,y) --> P(y,x)"
   202 lemma "\<forall>x y. P(x,y) --> P(y,x)"
   203 apply auto
   203 apply auto
   204 txt{*
   204 txt\<open>
   205 @{subgoals[display,indent=0,margin=65]}
   205 @{subgoals[display,indent=0,margin=65]}
   206 apply assumption
   206 apply assumption
   207 
   207 
   208 Clash: bound variable x (depth 1) =/= bound variable y (depth 0)
   208 Clash: bound variable x (depth 1) =/= bound variable y (depth 0)
   209 
   209 
   210 Clash: == =/= Trueprop
   210 Clash: == =/= Trueprop
   211 Clash: == =/= Trueprop
   211 Clash: == =/= Trueprop
   212 *}
   212 \<close>
   213 oops
   213 oops
   214 
   214 
   215 declare [[unify_trace_failure = false]]
   215 declare [[unify_trace_failure = false]]
   216 
   216 
   217 
   217 
   218 text{*Quantifiers*}
   218 text\<open>Quantifiers\<close>
   219 
   219 
   220 text {*
   220 text \<open>
   221 @{thm[display] allI}
   221 @{thm[display] allI}
   222 \rulename{allI}
   222 \rulename{allI}
   223 
   223 
   224 @{thm[display] allE}
   224 @{thm[display] allE}
   225 \rulename{allE}
   225 \rulename{allE}
   226 
   226 
   227 @{thm[display] spec}
   227 @{thm[display] spec}
   228 \rulename{spec}
   228 \rulename{spec}
   229 *}
   229 \<close>
   230 
   230 
   231 lemma "\<forall>x. P x \<longrightarrow> P x"
   231 lemma "\<forall>x. P x \<longrightarrow> P x"
   232 apply (rule allI)
   232 apply (rule allI)
   233 by (rule impI)
   233 by (rule impI)
   234 
   234 
   235 lemma "(\<forall>x. P \<longrightarrow> Q x) \<Longrightarrow> P \<longrightarrow> (\<forall>x. Q x)"
   235 lemma "(\<forall>x. P \<longrightarrow> Q x) \<Longrightarrow> P \<longrightarrow> (\<forall>x. Q x)"
   236 apply (rule impI, rule allI)
   236 apply (rule impI, rule allI)
   237 apply (drule spec)
   237 apply (drule spec)
   238 by (drule mp)
   238 by (drule mp)
   239 
   239 
   240 text{*rename_tac*}
   240 text\<open>rename_tac\<close>
   241 lemma "x < y \<Longrightarrow> \<forall>x y. P x (f y)"
   241 lemma "x < y \<Longrightarrow> \<forall>x y. P x (f y)"
   242 apply (intro allI)
   242 apply (intro allI)
   243         --{* @{subgoals[display,indent=0,margin=65]} *}
   243         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   244 apply (rename_tac v w)
   244 apply (rename_tac v w)
   245         --{* @{subgoals[display,indent=0,margin=65]} *}
   245         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   246 oops
   246 oops
   247 
   247 
   248 
   248 
   249 lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (h x); P a\<rbrakk> \<Longrightarrow> P(h (h a))"
   249 lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (h x); P a\<rbrakk> \<Longrightarrow> P(h (h a))"
   250 apply (frule spec)
   250 apply (frule spec)
   251         --{* @{subgoals[display,indent=0,margin=65]} *}
   251         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   252 apply (drule mp, assumption)
   252 apply (drule mp, assumption)
   253 apply (drule spec)
   253 apply (drule spec)
   254         --{* @{subgoals[display,indent=0,margin=65]} *}
   254         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   255 by (drule mp)
   255 by (drule mp)
   256 
   256 
   257 lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (f x); P a\<rbrakk> \<Longrightarrow> P(f (f a))"
   257 lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (f x); P a\<rbrakk> \<Longrightarrow> P(f (f a))"
   258 by blast
   258 by blast
   259 
   259 
   260 
   260 
   261 text{*
   261 text\<open>
   262 the existential quantifier*}
   262 the existential quantifier\<close>
   263 
   263 
   264 text {*
   264 text \<open>
   265 @{thm[display]"exI"}
   265 @{thm[display]"exI"}
   266 \rulename{exI}
   266 \rulename{exI}
   267 
   267 
   268 @{thm[display]"exE"}
   268 @{thm[display]"exE"}
   269 \rulename{exE}
   269 \rulename{exE}
   270 *}
   270 \<close>
   271 
   271 
   272 
   272 
   273 text{*
   273 text\<open>
   274 instantiating quantifiers explicitly by rule_tac and erule_tac*}
   274 instantiating quantifiers explicitly by rule_tac and erule_tac\<close>
   275 
   275 
   276 lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (h x); P a\<rbrakk> \<Longrightarrow> P(h (h a))"
   276 lemma "\<lbrakk>\<forall>x. P x \<longrightarrow> P (h x); P a\<rbrakk> \<Longrightarrow> P(h (h a))"
   277 apply (frule spec)
   277 apply (frule spec)
   278         --{* @{subgoals[display,indent=0,margin=65]} *}
   278         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   279 apply (drule mp, assumption)
   279 apply (drule mp, assumption)
   280         --{* @{subgoals[display,indent=0,margin=65]} *}
   280         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   281 apply (drule_tac x = "h a" in spec)
   281 apply (drule_tac x = "h a" in spec)
   282         --{* @{subgoals[display,indent=0,margin=65]} *}
   282         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   283 by (drule mp)
   283 by (drule mp)
   284 
   284 
   285 text {*
   285 text \<open>
   286 @{thm[display]"dvd_def"}
   286 @{thm[display]"dvd_def"}
   287 \rulename{dvd_def}
   287 \rulename{dvd_def}
   288 *}
   288 \<close>
   289 
   289 
   290 lemma mult_dvd_mono: "\<lbrakk>i dvd m; j dvd n\<rbrakk> \<Longrightarrow> i*j dvd (m*n :: nat)"
   290 lemma mult_dvd_mono: "\<lbrakk>i dvd m; j dvd n\<rbrakk> \<Longrightarrow> i*j dvd (m*n :: nat)"
   291 apply (simp add: dvd_def)
   291 apply (simp add: dvd_def)
   292         --{* @{subgoals[display,indent=0,margin=65]} *}
   292         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   293 apply (erule exE) 
   293 apply (erule exE) 
   294         --{* @{subgoals[display,indent=0,margin=65]} *}
   294         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   295 apply (erule exE) 
   295 apply (erule exE) 
   296         --{* @{subgoals[display,indent=0,margin=65]} *}
   296         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   297 apply (rename_tac l)
   297 apply (rename_tac l)
   298         --{* @{subgoals[display,indent=0,margin=65]} *}
   298         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   299 apply (rule_tac x="k*l" in exI) 
   299 apply (rule_tac x="k*l" in exI) 
   300         --{* @{subgoals[display,indent=0,margin=65]} *}
   300         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   301 apply simp
   301 apply simp
   302 done
   302 done
   303 
   303 
   304 text{*
   304 text\<open>
   305 Hilbert-epsilon theorems*}
   305 Hilbert-epsilon theorems\<close>
   306 
   306 
   307 text{*
   307 text\<open>
   308 @{thm[display] the_equality[no_vars]}
   308 @{thm[display] the_equality[no_vars]}
   309 \rulename{the_equality}
   309 \rulename{the_equality}
   310 
   310 
   311 @{thm[display] some_equality[no_vars]}
   311 @{thm[display] some_equality[no_vars]}
   312 \rulename{some_equality}
   312 \rulename{some_equality}
   328 @{thm[display] Least_def[no_vars]}
   328 @{thm[display] Least_def[no_vars]}
   329 \rulename{Least_def}
   329 \rulename{Least_def}
   330 
   330 
   331 @{thm[display] order_antisym[no_vars]}
   331 @{thm[display] order_antisym[no_vars]}
   332 \rulename{order_antisym}
   332 \rulename{order_antisym}
   333 *}
   333 \<close>
   334 
   334 
   335 
   335 
   336 lemma "inv Suc (Suc n) = n"
   336 lemma "inv Suc (Suc n) = n"
   337 by (simp add: inv_def)
   337 by (simp add: inv_def)
   338 
   338 
   339 text{*but we know nothing about inv Suc 0*}
   339 text\<open>but we know nothing about inv Suc 0\<close>
   340 
   340 
   341 theorem Least_equality:
   341 theorem Least_equality:
   342      "\<lbrakk> P (k::nat);  \<forall>x. P x \<longrightarrow> k \<le> x \<rbrakk> \<Longrightarrow> (LEAST x. P(x)) = k"
   342      "\<lbrakk> P (k::nat);  \<forall>x. P x \<longrightarrow> k \<le> x \<rbrakk> \<Longrightarrow> (LEAST x. P(x)) = k"
   343 apply (simp add: Least_def)
   343 apply (simp add: Least_def)
   344  
   344  
   345 txt{*
   345 txt\<open>
   346 @{subgoals[display,indent=0,margin=65]}
   346 @{subgoals[display,indent=0,margin=65]}
   347 *}
   347 \<close>
   348    
   348    
   349 apply (rule the_equality)
   349 apply (rule the_equality)
   350 
   350 
   351 txt{*
   351 txt\<open>
   352 @{subgoals[display,indent=0,margin=65]}
   352 @{subgoals[display,indent=0,margin=65]}
   353 
   353 
   354 first subgoal is existence; second is uniqueness
   354 first subgoal is existence; second is uniqueness
   355 *}
   355 \<close>
   356 by (auto intro: order_antisym)
   356 by (auto intro: order_antisym)
   357 
   357 
   358 
   358 
   359 theorem axiom_of_choice:
   359 theorem axiom_of_choice:
   360      "(\<forall>x. \<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)"
   360      "(\<forall>x. \<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)"
   361 apply (rule exI, rule allI)
   361 apply (rule exI, rule allI)
   362 
   362 
   363 txt{*
   363 txt\<open>
   364 @{subgoals[display,indent=0,margin=65]}
   364 @{subgoals[display,indent=0,margin=65]}
   365 
   365 
   366 state after intro rules
   366 state after intro rules
   367 *}
   367 \<close>
   368 apply (drule spec, erule exE)
   368 apply (drule spec, erule exE)
   369 
   369 
   370 txt{*
   370 txt\<open>
   371 @{subgoals[display,indent=0,margin=65]}
   371 @{subgoals[display,indent=0,margin=65]}
   372 
   372 
   373 applying @text{someI} automatically instantiates
   373 applying @text{someI} automatically instantiates
   374 @{term f} to @{term "\<lambda>x. SOME y. P x y"}
   374 @{term f} to @{term "\<lambda>x. SOME y. P x y"}
   375 *}
   375 \<close>
   376 
   376 
   377 by (rule someI)
   377 by (rule someI)
   378 
   378 
   379 (*both can be done by blast, which however hasn't been introduced yet*)
   379 (*both can be done by blast, which however hasn't been introduced yet*)
   380 lemma "[| P (k::nat);  \<forall>x. P x \<longrightarrow> k \<le> x |] ==> (LEAST x. P(x)) = k"
   380 lemma "[| P (k::nat);  \<forall>x. P x \<longrightarrow> k \<le> x |] ==> (LEAST x. P(x)) = k"
   383 
   383 
   384 theorem axiom_of_choice': "(\<forall>x. \<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)"
   384 theorem axiom_of_choice': "(\<forall>x. \<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. P x (f x)"
   385 apply (rule exI [of _  "\<lambda>x. SOME y. P x y"])
   385 apply (rule exI [of _  "\<lambda>x. SOME y. P x y"])
   386 by (blast intro: someI)
   386 by (blast intro: someI)
   387 
   387 
   388 text{*end of Epsilon section*}
   388 text\<open>end of Epsilon section\<close>
   389 
   389 
   390 
   390 
   391 lemma "(\<exists>x. P x) \<or> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<or> Q x"
   391 lemma "(\<exists>x. P x) \<or> (\<exists>x. Q x) \<Longrightarrow> \<exists>x. P x \<or> Q x"
   392 apply (elim exE disjE)
   392 apply (elim exE disjE)
   393  apply (intro exI disjI1)
   393  apply (intro exI disjI1)
   431  apply assumption
   431  apply assumption
   432 oops
   432 oops
   433 
   433 
   434 lemma "\<forall>y. R y y \<Longrightarrow> \<exists>x. \<forall>y. R x y"
   434 lemma "\<forall>y. R y y \<Longrightarrow> \<exists>x. \<forall>y. R x y"
   435 apply (rule exI) 
   435 apply (rule exI) 
   436   --{* @{subgoals[display,indent=0,margin=65]} *}
   436   \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   437 apply (rule allI) 
   437 apply (rule allI) 
   438   --{* @{subgoals[display,indent=0,margin=65]} *}
   438   \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   439 apply (drule spec) 
   439 apply (drule spec) 
   440   --{* @{subgoals[display,indent=0,margin=65]} *}
   440   \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   441 oops
   441 oops
   442 
   442 
   443 lemma "\<forall>x. \<exists>y. x=y"
   443 lemma "\<forall>x. \<exists>y. x=y"
   444 apply (rule allI)
   444 apply (rule allI)
   445 apply (rule exI)
   445 apply (rule exI)