thys4/posix/FBound.thy
changeset 589 86e0203db2da
parent 588 80e1114d6421
child 590 988e92a70704
equal deleted inserted replaced
588:80e1114d6421 589:86e0203db2da
   182   shows  "bitcode_agnostic bsimp"
   182   shows  "bitcode_agnostic bsimp"
   183   by (simp add: bitcode_agnostic_def bsimp_rerase)
   183   by (simp add: bitcode_agnostic_def bsimp_rerase)
   184 
   184 
   185 thm bsimp_rerase
   185 thm bsimp_rerase
   186 
   186 
   187 lemma cant1:
   187 
   188   shows "\<lbrakk> bsimp a = b; rerase a = rerase b; a = ASEQ bs r1 r2 \<rbrakk> \<Longrightarrow>
       
   189         \<exists>bs' r1' r2'. b = ASEQ bs' r1' r2' \<and> rerase r1' = rerase r1 \<and> rerase r2' = rerase r2"
       
   190   sorry
       
   191 
       
   192 
       
   193 
       
   194 (*"part is less than whole" thm for rrexp, since rrexp is always finite*)
       
   195 lemma rrexp_finite1:
       
   196   shows "\<lbrakk> bsimp_ASEQ bs1 (bsimp ra1) (bsimp ra2) = ASEQ bs2 rb1 rb2; ra1 ~1 rb1; ra2 ~1 rb2 \<rbrakk> \<Longrightarrow> rerase ra1 = rerase (bsimp ra1) "
       
   197   apply(case_tac ra1 )
       
   198         apply simp+
       
   199      apply(case_tac rb1)
       
   200            apply simp+
       
   201 
       
   202   sorry
       
   203 
   188 
   204 lemma unsure_unchanging:
   189 lemma unsure_unchanging:
   205   assumes "bsimp a = bsimp b"
   190   assumes "bsimp a = bsimp b"
   206 and "a ~1 b"
   191 and "a ~1 b"
   207 shows "a = b"
   192 shows "a = b"
   255   "r1 \<le>1 r1"
   240   "r1 \<le>1 r1"
   256 | "AZERO \<le>1 ASEQ bs AZERO r" 
   241 | "AZERO \<le>1 ASEQ bs AZERO r" 
   257 | "AZERO \<le>1 ASEQ bs r AZERO"
   242 | "AZERO \<le>1 ASEQ bs r AZERO"
   258 | "fuse (bs @ bs1) r2 \<le>1 ASEQ bs (AONE bs1) r2"
   243 | "fuse (bs @ bs1) r2 \<le>1 ASEQ bs (AONE bs1) r2"
   259 | " AALTs bs (rs1 @ rs) \<le>1 AALTs bs (rs1 @( AZERO # rs))"
   244 | " AALTs bs (rs1 @ rs) \<le>1 AALTs bs (rs1 @( AZERO # rs))"
   260 | "r2 \<le>1 r1 \<Longrightarrow> AALTs bs (rs1 @ r2 # rs) \<le>1 AALTs bs (rs1 @ r1 # rs)"
       
   261 | "AALTs bs1 (rsa @ (map (fuse bs1) rs1) @ rsb) \<le>1 AALTs bs1 (rsa @ (AALTs bs1 rs1) # rsb)"
   245 | "AALTs bs1 (rsa @ (map (fuse bs1) rs1) @ rsb) \<le>1 AALTs bs1 (rsa @ (AALTs bs1 rs1) # rsb)"
   262 | "rerase a1 = rerase a2 \<Longrightarrow> AALTs bs (rsa @ [a1] @ rsb @ rsc) \<le>1 AALTs bs (rsa @ [a1] @ rsb @ [a2] @ rsc) "
   246 | "rerase a1 = rerase a2 \<Longrightarrow> AALTs bs (rsa @ [a1] @ rsb @ rsc) \<le>1 AALTs bs (rsa @ [a1] @ rsb @ [a2] @ rsc) "
   263 | "r1 \<le>1 r2 \<Longrightarrow> r1  \<le>1 ASEQ bs (AONE bs1) r2"
   247 | "r1 \<le>1 r2 \<Longrightarrow> r1  \<le>1 ASEQ bs (AONE bs1) r2"
       
   248 | "r2 \<le>1 r1 \<Longrightarrow> AALTs bs (rs1 @ r2 # rs) \<le>1 AALTs bs (rs1 @ r1 # rs)"
       
   249 | "r2 \<le>1 r1 \<Longrightarrow> ASEQ bs r  r2 \<le>1 ASEQ bs r r1"
       
   250 | "r2 \<le>1 r1 \<Longrightarrow> ASEQ bs r2 r  \<le>1 ASEQ bs r1 r"
       
   251 | "r \<le>1 r' \<Longrightarrow> ASTAR bs r \<le>1 ASTAR bs r'"
       
   252 | "AZERO \<le>1 AALTs bs []"
       
   253 | "fuse bs r \<le>1 AALTs bs [r]"
       
   254 | "\<lbrakk>r1' \<le>1 r1;  r2' \<le>1 r2\<rbrakk> \<Longrightarrow> bsimp_ASEQ bs1 r1' r2' \<le>1 ASEQ bs1 r1 r2"
       
   255 
       
   256 lemma stupid_leq1_1:
       
   257   shows " rerase  r2 \<noteq> RSEQ r (RSEQ RONE (rerase r2))"
       
   258   apply(induct r2)
       
   259         apply simp+
       
   260   done
       
   261 
       
   262 lemma leq1_size:
       
   263   shows "r1 \<le>1 r2 \<Longrightarrow> asize r1 \<le> asize r2"
       
   264   apply (induct rule: leq1.induct)
       
   265                apply simp+
       
   266   apply (metis asize_rsize le_SucI le_add2 plus_1_eq_Suc rerase_fuse)
       
   267            apply simp
       
   268           apply simp
       
   269   
       
   270           apply (metis (mono_tags, lifting) asize_rsize comp_apply dual_order.eq_iff le_SucI map_eq_conv rerase_fuse)
       
   271   apply simp+
       
   272   apply (metis Suc_n_not_le_n asize_rsize linorder_le_cases rerase_fuse)
       
   273   apply(case_tac "r1' = AZERO")
       
   274    apply simp
       
   275   apply(case_tac "\<exists>bs1. r1' = AONE bs1")
       
   276    apply(erule exE)
       
   277    apply simp
       
   278   apply (metis asize_rsize le_SucI rerase_fuse trans_le_add2)
       
   279   by (smt (verit, best) Suc_eq_plus1 ab_semigroup_add_class.add_ac(1) add.commute add.right_neutral add_cancel_right_right add_mono_thms_linordered_semiring(1) asize.simps(5) asize_rsize nat_add_left_cancel_le order.trans order_trans plus_1_eq_Suc rSEQ_mono rerase_bsimp_ASEQ rsize.simps(5))
       
   280 
       
   281 
       
   282 
       
   283 lemma size_deciding_equality:
       
   284   shows "asize r1 \<noteq> asize r2 \<Longrightarrow> r1 \<noteq> r2 "
       
   285   apply auto
       
   286   done
       
   287 
       
   288 lemma size_deciding_equality2:
       
   289   shows "rerase r1 = rerase r2 \<Longrightarrow> asize r1 = asize r2"
       
   290   by (metis asize_rsize)
       
   291 
       
   292 lemma size_deciding_equality3:
       
   293   shows "asize r1 \<noteq> asize r2 \<Longrightarrow> rerase r1 \<noteq> rerase r2"
       
   294   by (metis asize_rsize)
       
   295 
       
   296 lemma size_deciding_equality4:
       
   297   shows "rerase a1 = r2 \<Longrightarrow> asize a1 = rsize r2"
       
   298   by (metis asize_rsize)
       
   299 
       
   300 lemma size_deciding_equality5:
       
   301   shows "asize a1 \<noteq> rsize r2 \<Longrightarrow>rerase a1 \<noteq> r2"
       
   302   by (metis asize_rsize)
       
   303 
       
   304 lemma leq1_trans1:
       
   305   shows " r1 \<le>1 r2 \<Longrightarrow>  rerase r1 \<noteq> RSEQ r (rerase r2)"
       
   306   apply(induct rule: leq1.induct)
       
   307                apply simp+
       
   308   using rerase_fuse stupid_leq1_1 apply presburger
       
   309            apply simp+
       
   310         apply(subgoal_tac "asize r1 \<noteq> rsize (RSEQ r (RSEQ RONE (rerase r2)))")
       
   311   using size_deciding_equality5 apply blast
       
   312   using asize_rsize leq1_size apply fastforce
       
   313        apply simp+
       
   314   apply(subgoal_tac "rsize (rerase (fuse bs ra)) \<noteq> rsize (RSEQ r (RALTS [rerase ra]))")
       
   315   
       
   316   apply force
       
   317   apply simp
       
   318   apply(simp add: asize_rsize)
       
   319   by (simp add: rerase_fuse size_deciding_equality4)
       
   320 
       
   321   
       
   322 
       
   323   
   264 
   324 
   265 lemma leq1_less_or_equal: shows
   325 lemma leq1_less_or_equal: shows
   266 "r1 \<le>1 r2 \<Longrightarrow> r1 = r2 \<or> rerase r1 \<noteq> rerase r2"
   326 "r1 \<le>1 r2 \<Longrightarrow> r1 = r2 \<or> rerase r1 \<noteq> rerase r2"
   267   apply(induct rule: leq1.induct)
   327   apply(induct rule: leq1.induct)
   268           apply simp+
   328                apply simp
   269   sorry
   329               apply simp
   270 
   330   apply simp
   271 lemma bsimp_leq1:
   331             apply (simp add: rerase_fuse)
   272   shows "bsimp r \<le>1 r"
   332            apply simp
   273 
   333   apply simp
   274   sorry
   334   using r_finite1 rerase_fuse apply force
   275 
   335          apply simp
   276 
   336         apply simp
   277 lemma arexpfiniteaux4_aux:
   337         apply(case_tac "r1 = r2")
   278   shows" \<lbrakk>rerase (bsimp_AALTs bs1 (distinctWith (flts (map bsimp rs)) eq1 {})) = RALTS (map rerase rs) \<rbrakk>
   338          apply simp
   279        \<Longrightarrow> map rerase (map bsimp rs) = map rerase rs"
   339         apply simp
   280   apply(induct rs)
   340   
       
   341   using leq1_trans1 apply presburger
       
   342        apply simp
       
   343       apply simp
       
   344      apply simp
       
   345     apply simp
   281    apply simp
   346    apply simp
   282   apply simp
   347   apply simp
   283   apply auto
   348   using r_finite1 rerase_fuse by auto
   284    prefer 2
   349 
   285 
   350 
   286   sorry
   351 
       
   352 
       
   353 
   287 
   354 
   288 lemma arexpfiniteaux4:
   355 lemma arexpfiniteaux4:
   289   shows"
   356   shows"
   290        \<lbrakk>\<And>x. \<lbrakk>x \<in> set rs; rerase (bsimp x) = rerase x\<rbrakk> \<Longrightarrow> bsimp x = x;
   357        \<lbrakk>\<And>x. \<lbrakk>x \<in> set rs; rerase (bsimp x) = rerase x\<rbrakk> \<Longrightarrow> bsimp x = x;
   291         rerase (bsimp_AALTs bs1 (distinctWith (flts (map bsimp rs)) eq1 {})) = RALTS (map rerase rs)\<rbrakk>
   358         rerase (bsimp_AALTs bs1 (distinctWith (flts (map bsimp rs)) eq1 {})) = RALTS (map rerase rs)\<rbrakk>
   341                       apply simp
   408                       apply simp
   342                       apply simp
   409                       apply simp
   343                       apply simp
   410                       apply simp
   344 
   411 
   345                       apply auto
   412                       apply auto
       
   413   
       
   414   sorry
       
   415 
       
   416 
       
   417 
       
   418 lemma bsimp_reduces:
       
   419   shows "bsimp r \<le>1 r"
       
   420   apply(induct rule: bsimp.induct)
       
   421         apply simp
   346   
   422   
   347   sorry
   423   sorry
   348 
   424 
   349 
   425 
   350 
   426 
   374 
   450 
   375 theorem bsimp_idem:
   451 theorem bsimp_idem:
   376   shows "bsimp (bsimp a) = bsimp a"
   452   shows "bsimp (bsimp a) = bsimp a"
   377   using bitcodes_unchanging bsimp_rerase rsimp_idem by auto
   453   using bitcodes_unchanging bsimp_rerase rsimp_idem by auto
   378 
   454 
       
   455 
   379 unused_thms
   456 unused_thms
   380 
   457 
   381 end
   458 end