src/HOL/Library/While_Combinator.thy
changeset 74974 7733c794cfea
parent 69593 3dda49e08b9d
equal deleted inserted replaced
74973:a565a2889b49 74974:7733c794cfea
   237    apply blast
   237    apply blast
   238   apply (erule wf_subset)
   238   apply (erule wf_subset)
   239   apply blast
   239   apply blast
   240   done
   240   done
   241 
   241 
       
   242 text \<open>Combine invariant preservation and variant decrease in one goal:\<close>
       
   243 theorem while_rule2:
       
   244   "[| P s;
       
   245       !!s. [| P s; b s  |] ==> P (c s) \<and> (c s, s) \<in> r;
       
   246       !!s. [| P s; \<not> b s  |] ==> Q s;
       
   247       wf r |] ==>
       
   248    Q (while b c s)"
       
   249 using while_rule[of P] by metis
       
   250 
   242 text\<open>Proving termination:\<close>
   251 text\<open>Proving termination:\<close>
   243 
   252 
   244 theorem wf_while_option_Some:
   253 theorem wf_while_option_Some:
   245   assumes "wf {(t, s). (P s \<and> b s) \<and> t = c s}"
   254   assumes "wf {(t, s). (P s \<and> b s) \<and> t = c s}"
   246   and "\<And>s. P s \<Longrightarrow> b s \<Longrightarrow> P(c s)" and "P s"
   255   and "\<And>s. P s \<Longrightarrow> b s \<Longrightarrow> P(c s)" and "P s"