src/Doc/Tutorial/Rules/Basic.thy
changeset 67443 3abf6a722518
parent 67406 23307fd33906
child 69597 ff784d5a5bfb
equal deleted inserted replaced
67442:f075640b8868 67443:3abf6a722518
    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   \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
    93   \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
    94 back \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
    94 back \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
    95 back \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
    95 back \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
    96 back \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
    96 back \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
    97 back \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
    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)
   146 \<close>
   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         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   151         \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   152 apply (intro impI)
   152 apply (intro impI)
   153         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   153         \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   154 by (erule notE)
   154 by (erule notE)
   155 
   155 
   156 text \<open>
   156 text \<open>
   157 @{thm[display] disjCI}
   157 @{thm[display] disjCI}
   158 \rulename{disjCI}
   158 \rulename{disjCI}
   159 \<close>
   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         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   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         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   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\<open>
   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
   238 by (drule mp)
   238 by (drule mp)
   239 
   239 
   240 text\<open>rename_tac\<close>
   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         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   243         \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   244 apply (rename_tac v w)
   244 apply (rename_tac v w)
   245         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   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         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   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         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   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 
   273 text\<open>
   273 text\<open>
   274 instantiating quantifiers explicitly by rule_tac and erule_tac\<close>
   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         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   278         \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   279 apply (drule mp, assumption)
   279 apply (drule mp, assumption)
   280         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   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         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   282         \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   283 by (drule mp)
   283 by (drule mp)
   284 
   284 
   285 text \<open>
   285 text \<open>
   286 @{thm[display]"dvd_def"}
   286 @{thm[display]"dvd_def"}
   287 \rulename{dvd_def}
   287 \rulename{dvd_def}
   288 \<close>
   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         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   292         \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   293 apply (erule exE) 
   293 apply (erule exE) 
   294         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   294         \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   295 apply (erule exE) 
   295 apply (erule exE) 
   296         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   296         \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   297 apply (rename_tac l)
   297 apply (rename_tac l)
   298         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   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         \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   300         \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   301 apply simp
   301 apply simp
   302 done
   302 done
   303 
   303 
   304 text\<open>
   304 text\<open>
   305 Hilbert-epsilon theorems\<close>
   305 Hilbert-epsilon theorems\<close>
   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   \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   436   \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   437 apply (rule allI) 
   437 apply (rule allI) 
   438   \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   438   \<comment> \<open>@{subgoals[display,indent=0,margin=65]}\<close>
   439 apply (drule spec) 
   439 apply (drule spec) 
   440   \<comment>\<open>@{subgoals[display,indent=0,margin=65]}\<close>
   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)