src/HOL/HoareParallel/RG_Examples.thy
changeset 27651 16a26996c30e
parent 16733 236dfafbeb63
child 27676 55676111ed69
equal deleted inserted replaced
27650:7a4baad05495 27651:16a26996c30e
     1 header {* \section{Examples} *}
     1 header {* \section{Examples} *}
     2 
     2 
     3 theory RG_Examples imports RG_Syntax begin
     3 theory RG_Examples
       
     4 imports RG_Syntax
       
     5 begin
     4 
     6 
     5 lemmas definitions [simp]= stable_def Pre_def Rely_def Guar_def Post_def Com_def 
     7 lemmas definitions [simp]= stable_def Pre_def Rely_def Guar_def Post_def Com_def 
     6 
     8 
     7 subsection {* Set Elements of an Array to Zero *}
     9 subsection {* Set Elements of an Array to Zero *}
     8 
    10 
   289       apply force
   291       apply force
   290      apply fastsimp
   292      apply fastsimp
   291     apply force
   293     apply force
   292    apply force
   294    apply force
   293   apply(rule Basic)
   295   apply(rule Basic)
   294      apply simp
   296      apply (simp add: mod_add_self2)
   295      apply clarify
   297      apply clarify
   296      apply simp
   298      apply simp
   297      apply(case_tac "X x (j mod n)\<le> j")
   299      apply (case_tac "X x (j mod n) \<le> j")
   298       apply(drule le_imp_less_or_eq)
   300      apply (drule le_imp_less_or_eq)
   299       apply(erule disjE)
   301      apply (erule disjE)
   300        apply(drule_tac j=j and n=n and i="j mod n" and a="X x (j mod n)" in mod_aux)
   302      apply (drule_tac j=j and n=n and i="j mod n" and a="X x (j mod n)" in mod_aux)
   301         apply assumption+
   303      apply auto
   302        apply simp+
       
   303     apply clarsimp
       
   304     apply fastsimp
       
   305 apply force+
       
   306 done
   304 done
   307 
   305 
   308 text {* Same but with a list as auxiliary variable: *}
   306 text {* Same but with a list as auxiliary variable: *}
   309 
   307 
   310 record Example3_list =
   308 record Example3_list =
   346     apply force
   344     apply force
   347    apply force
   345    apply force
   348   apply(rule Basic)
   346   apply(rule Basic)
   349      apply simp
   347      apply simp
   350      apply clarify
   348      apply clarify
   351      apply simp
   349      apply (simp add: mod_add_self2)
   352      apply(rule allI)
   350      apply(rule allI)
   353      apply(rule impI)+
   351      apply(rule impI)+
   354      apply(case_tac "X x ! i\<le> j")
   352      apply(case_tac "X x ! i\<le> j")
   355       apply(drule le_imp_less_or_eq)
   353       apply(drule le_imp_less_or_eq)
   356       apply(erule disjE)
   354       apply(erule disjE)
   357        apply(drule_tac j=j and n=n and i=i and a="X x ! i" in mod_aux)
   355        apply(drule_tac j=j and n=n and i=i and a="X x ! i" in mod_aux)
   358         apply assumption+
   356      apply auto
   359        apply simp
       
   360 apply force+
       
   361 done
   357 done
   362 
   358 
   363 end
   359 end