doc-src/TutorialI/Rules/Basic.thy
changeset 32960 69916a850301
parent 32833 f3716d1a2e48
child 38798 89f273ab1d42
equal deleted inserted replaced
32959:23a8c5ac35f8 32960:69916a850301
     1 (* ID:         $Id$ *)
       
     2 theory Basic imports Main begin
     1 theory Basic imports Main begin
     3 
     2 
     4 lemma conj_rule: "\<lbrakk> P; Q \<rbrakk> \<Longrightarrow> P \<and> (Q \<and> P)"
     3 lemma conj_rule: "\<lbrakk> P; Q \<rbrakk> \<Longrightarrow> P \<and> (Q \<and> P)"
     5 apply (rule conjI)
     4 apply (rule conjI)
     6  apply assumption
     5  apply assumption
   147 *};
   146 *};
   148 
   147 
   149 
   148 
   150 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"
   151 apply (erule_tac Q="R\<longrightarrow>Q" in contrapos_np)
   150 apply (erule_tac Q="R\<longrightarrow>Q" in contrapos_np)
   152 	--{* @{subgoals[display,indent=0,margin=65]} *}
   151         --{* @{subgoals[display,indent=0,margin=65]} *}
   153 apply (intro impI)
   152 apply (intro impI)
   154 	--{* @{subgoals[display,indent=0,margin=65]} *}
   153         --{* @{subgoals[display,indent=0,margin=65]} *}
   155 by (erule notE)
   154 by (erule notE)
   156 
   155 
   157 text {*
   156 text {*
   158 @{thm[display] disjCI}
   157 @{thm[display] disjCI}
   159 \rulename{disjCI}
   158 \rulename{disjCI}
   160 *};
   159 *};
   161 
   160 
   162 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"
   163 apply (intro disjCI conjI)
   162 apply (intro disjCI conjI)
   164 	--{* @{subgoals[display,indent=0,margin=65]} *}
   163         --{* @{subgoals[display,indent=0,margin=65]} *}
   165 
   164 
   166 apply (elim conjE disjE)
   165 apply (elim conjE disjE)
   167  apply assumption
   166  apply assumption
   168 	--{* @{subgoals[display,indent=0,margin=65]} *}
   167         --{* @{subgoals[display,indent=0,margin=65]} *}
   169 
   168 
   170 by (erule contrapos_np, rule conjI)
   169 by (erule contrapos_np, rule conjI)
   171 text{*
   170 text{*
   172 proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{6}}\isanewline
   171 proof\ {\isacharparenleft}prove{\isacharparenright}{\isacharcolon}\ step\ {\isadigit{6}}\isanewline
   173 \isanewline
   172 \isanewline
   239 by (drule mp)
   238 by (drule mp)
   240 
   239 
   241 text{*rename_tac*}
   240 text{*rename_tac*}
   242 lemma "x < y \<Longrightarrow> \<forall>x y. P x (f y)"
   241 lemma "x < y \<Longrightarrow> \<forall>x y. P x (f y)"
   243 apply (intro allI)
   242 apply (intro allI)
   244 	--{* @{subgoals[display,indent=0,margin=65]} *}
   243         --{* @{subgoals[display,indent=0,margin=65]} *}
   245 apply (rename_tac v w)
   244 apply (rename_tac v w)
   246 	--{* @{subgoals[display,indent=0,margin=65]} *}
   245         --{* @{subgoals[display,indent=0,margin=65]} *}
   247 oops
   246 oops
   248 
   247 
   249 
   248 
   250 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))"
   251 apply (frule spec)
   250 apply (frule spec)
   252 	--{* @{subgoals[display,indent=0,margin=65]} *}
   251         --{* @{subgoals[display,indent=0,margin=65]} *}
   253 apply (drule mp, assumption)
   252 apply (drule mp, assumption)
   254 apply (drule spec)
   253 apply (drule spec)
   255 	--{* @{subgoals[display,indent=0,margin=65]} *}
   254         --{* @{subgoals[display,indent=0,margin=65]} *}
   256 by (drule mp)
   255 by (drule mp)
   257 
   256 
   258 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))"
   259 by blast
   258 by blast
   260 
   259 
   274 text{*
   273 text{*
   275 instantiating quantifiers explicitly by rule_tac and erule_tac*}
   274 instantiating quantifiers explicitly by rule_tac and erule_tac*}
   276 
   275 
   277 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))"
   278 apply (frule spec)
   277 apply (frule spec)
   279 	--{* @{subgoals[display,indent=0,margin=65]} *}
   278         --{* @{subgoals[display,indent=0,margin=65]} *}
   280 apply (drule mp, assumption)
   279 apply (drule mp, assumption)
   281 	--{* @{subgoals[display,indent=0,margin=65]} *}
   280         --{* @{subgoals[display,indent=0,margin=65]} *}
   282 apply (drule_tac x = "h a" in spec)
   281 apply (drule_tac x = "h a" in spec)
   283 	--{* @{subgoals[display,indent=0,margin=65]} *}
   282         --{* @{subgoals[display,indent=0,margin=65]} *}
   284 by (drule mp)
   283 by (drule mp)
   285 
   284 
   286 text {*
   285 text {*
   287 @{thm[display]"dvd_def"}
   286 @{thm[display]"dvd_def"}
   288 \rulename{dvd_def}
   287 \rulename{dvd_def}
   289 *};
   288 *};
   290 
   289 
   291 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)"
   292 apply (simp add: dvd_def)
   291 apply (simp add: dvd_def)
   293 	--{* @{subgoals[display,indent=0,margin=65]} *}
   292         --{* @{subgoals[display,indent=0,margin=65]} *}
   294 apply (erule exE) 
   293 apply (erule exE) 
   295 	--{* @{subgoals[display,indent=0,margin=65]} *}
   294         --{* @{subgoals[display,indent=0,margin=65]} *}
   296 apply (erule exE) 
   295 apply (erule exE) 
   297 	--{* @{subgoals[display,indent=0,margin=65]} *}
   296         --{* @{subgoals[display,indent=0,margin=65]} *}
   298 apply (rename_tac l)
   297 apply (rename_tac l)
   299 	--{* @{subgoals[display,indent=0,margin=65]} *}
   298         --{* @{subgoals[display,indent=0,margin=65]} *}
   300 apply (rule_tac x="k*l" in exI) 
   299 apply (rule_tac x="k*l" in exI) 
   301 	--{* @{subgoals[display,indent=0,margin=65]} *}
   300         --{* @{subgoals[display,indent=0,margin=65]} *}
   302 apply simp
   301 apply simp
   303 done
   302 done
   304 
   303 
   305 text{*
   304 text{*
   306 Hilbert-epsilon theorems*}
   305 Hilbert-epsilon theorems*}