444 proof(rule unique_chain [OF _ dp1 dp2 neq]) |
444 proof(rule unique_chain [OF _ dp1 dp2 neq]) |
445 from unique_depend[OF vt] |
445 from unique_depend[OF vt] |
446 show "\<And>a b c. \<lbrakk>(a, b) \<in> depend s; (a, c) \<in> depend s\<rbrakk> \<Longrightarrow> b = c" by auto |
446 show "\<And>a b c. \<lbrakk>(a, b) \<in> depend s; (a, c) \<in> depend s\<rbrakk> \<Longrightarrow> b = c" by auto |
447 qed |
447 qed |
448 |
448 |
449 lemma dependents_child_unique: |
449 lemma dependants_child_unique: |
450 fixes s th th1 th2 th3 |
450 fixes s th th1 th2 th3 |
451 assumes vt: "vt s" |
451 assumes vt: "vt s" |
452 and ch1: "(Th th1, Th th) \<in> child s" |
452 and ch1: "(Th th1, Th th) \<in> child s" |
453 and ch2: "(Th th2, Th th) \<in> child s" |
453 and ch2: "(Th th2, Th th) \<in> child s" |
454 and dp1: "th3 \<in> dependents s th1" |
454 and dp1: "th3 \<in> dependants s th1" |
455 and dp2: "th3 \<in> dependents s th2" |
455 and dp2: "th3 \<in> dependants s th2" |
456 shows "th1 = th2" |
456 shows "th1 = th2" |
457 proof - |
457 proof - |
458 { assume neq: "th1 \<noteq> th2" |
458 { assume neq: "th1 \<noteq> th2" |
459 from dp1 have dp1: "(Th th3, Th th1) \<in> (depend s)^+" |
459 from dp1 have dp1: "(Th th3, Th th1) \<in> (depend s)^+" |
460 by (simp add:s_dependents_def eq_depend) |
460 by (simp add:s_dependants_def eq_depend) |
461 from dp2 have dp2: "(Th th3, Th th2) \<in> (depend s)^+" |
461 from dp2 have dp2: "(Th th3, Th th2) \<in> (depend s)^+" |
462 by (simp add:s_dependents_def eq_depend) |
462 by (simp add:s_dependants_def eq_depend) |
463 from unique_depend_p[OF vt dp1 dp2] and neq |
463 from unique_depend_p[OF vt dp1 dp2] and neq |
464 have "(Th th1, Th th2) \<in> (depend s)\<^sup>+ \<or> (Th th2, Th th1) \<in> (depend s)\<^sup>+" by auto |
464 have "(Th th1, Th th2) \<in> (depend s)\<^sup>+ \<or> (Th th2, Th th1) \<in> (depend s)\<^sup>+" by auto |
465 hence False |
465 hence False |
466 proof |
466 proof |
467 assume "(Th th1, Th th2) \<in> (depend s)\<^sup>+ " |
467 assume "(Th th1, Th th2) \<in> (depend s)\<^sup>+ " |
477 fixes s th |
477 fixes s th |
478 assumes vt: "vt s" |
478 assumes vt: "vt s" |
479 shows "cp s th = Max ({preced th s} \<union> (cp s ` children s th))" |
479 shows "cp s th = Max ({preced th s} \<union> (cp s ` children s th))" |
480 proof(unfold cp_eq_cpreced_f cpreced_def) |
480 proof(unfold cp_eq_cpreced_f cpreced_def) |
481 let ?f = "(\<lambda>th. preced th s)" |
481 let ?f = "(\<lambda>th. preced th s)" |
482 show "Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th)) = |
482 show "Max ((\<lambda>th. preced th s) ` ({th} \<union> dependants (wq s) th)) = |
483 Max ({preced th s} \<union> (\<lambda>th. Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th))) ` children s th)" |
483 Max ({preced th s} \<union> (\<lambda>th. Max ((\<lambda>th. preced th s) ` ({th} \<union> dependants (wq s) th))) ` children s th)" |
484 proof(cases " children s th = {}") |
484 proof(cases " children s th = {}") |
485 case False |
485 case False |
486 have "(\<lambda>th. Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th))) ` children s th = |
486 have "(\<lambda>th. Max ((\<lambda>th. preced th s) ` ({th} \<union> dependants (wq s) th))) ` children s th = |
487 {Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) | th' . th' \<in> children s th}" |
487 {Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) | th' . th' \<in> children s th}" |
488 (is "?L = ?R") |
488 (is "?L = ?R") |
489 by auto |
489 by auto |
490 also have "\<dots> = |
490 also have "\<dots> = |
491 Max ` {((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) | th' . th' \<in> children s th}" |
491 Max ` {((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) | th' . th' \<in> children s th}" |
492 (is "_ = Max ` ?C") |
492 (is "_ = Max ` ?C") |
493 by auto |
493 by auto |
494 finally have "Max ?L = Max (Max ` ?C)" by auto |
494 finally have "Max ?L = Max (Max ` ?C)" by auto |
495 also have "\<dots> = Max (\<Union> ?C)" |
495 also have "\<dots> = Max (\<Union> ?C)" |
496 proof(rule Max_Union[symmetric]) |
496 proof(rule Max_Union[symmetric]) |
497 from children_dependents[of s th] finite_threads[OF vt] and dependents_threads[OF vt, of th] |
497 from children_dependants[of s th] finite_threads[OF vt] and dependants_threads[OF vt, of th] |
498 show "finite {(\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th') |th'. th' \<in> children s th}" |
498 show "finite {(\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th') |th'. th' \<in> children s th}" |
499 by (auto simp:finite_subset) |
499 by (auto simp:finite_subset) |
500 next |
500 next |
501 from False |
501 from False |
502 show "{(\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th') |th'. th' \<in> children s th} \<noteq> {}" |
502 show "{(\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th') |th'. th' \<in> children s th} \<noteq> {}" |
503 by simp |
503 by simp |
504 next |
504 next |
505 show "\<And>A. A \<in> {(\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th') |th'. th' \<in> children s th} \<Longrightarrow> |
505 show "\<And>A. A \<in> {(\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th') |th'. th' \<in> children s th} \<Longrightarrow> |
506 finite A \<and> A \<noteq> {}" |
506 finite A \<and> A \<noteq> {}" |
507 apply (auto simp:finite_subset) |
507 apply (auto simp:finite_subset) |
508 proof - |
508 proof - |
509 fix th' |
509 fix th' |
510 from finite_threads[OF vt] and dependents_threads[OF vt, of th'] |
510 from finite_threads[OF vt] and dependants_threads[OF vt, of th'] |
511 show "finite ((\<lambda>th. preced th s) ` dependents (wq s) th')" by (auto simp:finite_subset) |
511 show "finite ((\<lambda>th. preced th s) ` dependants (wq s) th')" by (auto simp:finite_subset) |
512 qed |
512 qed |
513 qed |
513 qed |
514 also have "\<dots> = Max ((\<lambda>th. preced th s) ` dependents (wq s) th)" |
514 also have "\<dots> = Max ((\<lambda>th. preced th s) ` dependants (wq s) th)" |
515 (is "Max ?A = Max ?B") |
515 (is "Max ?A = Max ?B") |
516 proof - |
516 proof - |
517 have "?A = ?B" |
517 have "?A = ?B" |
518 proof |
518 proof |
519 show "\<Union>{(\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th') |th'. th' \<in> children s th} |
519 show "\<Union>{(\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th') |th'. th' \<in> children s th} |
520 \<subseteq> (\<lambda>th. preced th s) ` dependents (wq s) th" |
520 \<subseteq> (\<lambda>th. preced th s) ` dependants (wq s) th" |
521 proof |
521 proof |
522 fix x |
522 fix x |
523 assume "x \<in> \<Union>{(\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th') |th'. th' \<in> children s th}" |
523 assume "x \<in> \<Union>{(\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th') |th'. th' \<in> children s th}" |
524 then obtain th' where |
524 then obtain th' where |
525 th'_in: "th' \<in> children s th" |
525 th'_in: "th' \<in> children s th" |
526 and x_in: "x \<in> ?f ` ({th'} \<union> dependents (wq s) th')" by auto |
526 and x_in: "x \<in> ?f ` ({th'} \<union> dependants (wq s) th')" by auto |
527 hence "x = ?f th' \<or> x \<in> (?f ` dependents (wq s) th')" by auto |
527 hence "x = ?f th' \<or> x \<in> (?f ` dependants (wq s) th')" by auto |
528 thus "x \<in> ?f ` dependents (wq s) th" |
528 thus "x \<in> ?f ` dependants (wq s) th" |
529 proof |
529 proof |
530 assume "x = preced th' s" |
530 assume "x = preced th' s" |
531 with th'_in and children_dependents |
531 with th'_in and children_dependants |
532 show "x \<in> (\<lambda>th. preced th s) ` dependents (wq s) th" by auto |
532 show "x \<in> (\<lambda>th. preced th s) ` dependants (wq s) th" by auto |
533 next |
533 next |
534 assume "x \<in> (\<lambda>th. preced th s) ` dependents (wq s) th'" |
534 assume "x \<in> (\<lambda>th. preced th s) ` dependants (wq s) th'" |
535 moreover note th'_in |
535 moreover note th'_in |
536 ultimately show " x \<in> (\<lambda>th. preced th s) ` dependents (wq s) th" |
536 ultimately show " x \<in> (\<lambda>th. preced th s) ` dependants (wq s) th" |
537 by (unfold cs_dependents_def children_def child_def, auto simp:eq_depend) |
537 by (unfold cs_dependants_def children_def child_def, auto simp:eq_depend) |
538 qed |
538 qed |
539 qed |
539 qed |
540 next |
540 next |
541 show "?f ` dependents (wq s) th |
541 show "?f ` dependants (wq s) th |
542 \<subseteq> \<Union>{?f ` ({th'} \<union> dependents (wq s) th') |th'. th' \<in> children s th}" |
542 \<subseteq> \<Union>{?f ` ({th'} \<union> dependants (wq s) th') |th'. th' \<in> children s th}" |
543 proof |
543 proof |
544 fix x |
544 fix x |
545 assume x_in: "x \<in> (\<lambda>th. preced th s) ` dependents (wq s) th" |
545 assume x_in: "x \<in> (\<lambda>th. preced th s) ` dependants (wq s) th" |
546 then obtain th' where |
546 then obtain th' where |
547 eq_x: "x = ?f th'" and dp: "(Th th', Th th) \<in> (depend s)^+" |
547 eq_x: "x = ?f th'" and dp: "(Th th', Th th) \<in> (depend s)^+" |
548 by (auto simp:cs_dependents_def eq_depend) |
548 by (auto simp:cs_dependants_def eq_depend) |
549 from depend_children[OF dp] |
549 from depend_children[OF dp] |
550 have "th' \<in> children s th \<or> (\<exists>th3. th3 \<in> children s th \<and> (Th th', Th th3) \<in> (depend s)\<^sup>+)" . |
550 have "th' \<in> children s th \<or> (\<exists>th3. th3 \<in> children s th \<and> (Th th', Th th3) \<in> (depend s)\<^sup>+)" . |
551 thus "x \<in> \<Union>{(\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th') |th'. th' \<in> children s th}" |
551 thus "x \<in> \<Union>{(\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th') |th'. th' \<in> children s th}" |
552 proof |
552 proof |
553 assume "th' \<in> children s th" |
553 assume "th' \<in> children s th" |
554 with eq_x |
554 with eq_x |
555 show "x \<in> \<Union>{(\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th') |th'. th' \<in> children s th}" |
555 show "x \<in> \<Union>{(\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th') |th'. th' \<in> children s th}" |
556 by auto |
556 by auto |
557 next |
557 next |
558 assume "\<exists>th3. th3 \<in> children s th \<and> (Th th', Th th3) \<in> (depend s)\<^sup>+" |
558 assume "\<exists>th3. th3 \<in> children s th \<and> (Th th', Th th3) \<in> (depend s)\<^sup>+" |
559 then obtain th3 where th3_in: "th3 \<in> children s th" |
559 then obtain th3 where th3_in: "th3 \<in> children s th" |
560 and dp3: "(Th th', Th th3) \<in> (depend s)\<^sup>+" by auto |
560 and dp3: "(Th th', Th th3) \<in> (depend s)\<^sup>+" by auto |
561 show "x \<in> \<Union>{(\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th') |th'. th' \<in> children s th}" |
561 show "x \<in> \<Union>{(\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th') |th'. th' \<in> children s th}" |
562 proof - |
562 proof - |
563 from dp3 |
563 from dp3 |
564 have "th' \<in> dependents (wq s) th3" |
564 have "th' \<in> dependants (wq s) th3" |
565 by (auto simp:cs_dependents_def eq_depend) |
565 by (auto simp:cs_dependants_def eq_depend) |
566 with eq_x th3_in show ?thesis by auto |
566 with eq_x th3_in show ?thesis by auto |
567 qed |
567 qed |
568 qed |
568 qed |
569 qed |
569 qed |
570 qed |
570 qed |
571 thus ?thesis by simp |
571 thus ?thesis by simp |
572 qed |
572 qed |
573 finally have "Max ((\<lambda>th. preced th s) ` dependents (wq s) th) = Max (?L)" |
573 finally have "Max ((\<lambda>th. preced th s) ` dependants (wq s) th) = Max (?L)" |
574 (is "?X = ?Y") by auto |
574 (is "?X = ?Y") by auto |
575 moreover have "Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th)) = |
575 moreover have "Max ((\<lambda>th. preced th s) ` ({th} \<union> dependants (wq s) th)) = |
576 max (?f th) ?X" |
576 max (?f th) ?X" |
577 proof - |
577 proof - |
578 have "Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th)) = |
578 have "Max ((\<lambda>th. preced th s) ` ({th} \<union> dependants (wq s) th)) = |
579 Max ({?f th} \<union> ?f ` (dependents (wq s) th))" by simp |
579 Max ({?f th} \<union> ?f ` (dependants (wq s) th))" by simp |
580 also have "\<dots> = max (Max {?f th}) (Max (?f ` (dependents (wq s) th)))" |
580 also have "\<dots> = max (Max {?f th}) (Max (?f ` (dependants (wq s) th)))" |
581 proof(rule Max_Un, auto) |
581 proof(rule Max_Un, auto) |
582 from finite_threads[OF vt] and dependents_threads[OF vt, of th] |
582 from finite_threads[OF vt] and dependants_threads[OF vt, of th] |
583 show "finite ((\<lambda>th. preced th s) ` dependents (wq s) th)" by (auto simp:finite_subset) |
583 show "finite ((\<lambda>th. preced th s) ` dependants (wq s) th)" by (auto simp:finite_subset) |
584 next |
584 next |
585 assume "dependents (wq s) th = {}" |
585 assume "dependants (wq s) th = {}" |
586 with False and children_dependents show False by auto |
586 with False and children_dependants show False by auto |
587 qed |
587 qed |
588 also have "\<dots> = max (?f th) ?X" by simp |
588 also have "\<dots> = max (?f th) ?X" by simp |
589 finally show ?thesis . |
589 finally show ?thesis . |
590 qed |
590 qed |
591 moreover have "Max ({preced th s} \<union> |
591 moreover have "Max ({preced th s} \<union> |
592 (\<lambda>th. Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th))) ` children s th) = |
592 (\<lambda>th. Max ((\<lambda>th. preced th s) ` ({th} \<union> dependants (wq s) th))) ` children s th) = |
593 max (?f th) ?Y" |
593 max (?f th) ?Y" |
594 proof - |
594 proof - |
595 have "Max ({preced th s} \<union> |
595 have "Max ({preced th s} \<union> |
596 (\<lambda>th. Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th))) ` children s th) = |
596 (\<lambda>th. Max ((\<lambda>th. preced th s) ` ({th} \<union> dependants (wq s) th))) ` children s th) = |
597 max (Max {preced th s}) ?Y" |
597 max (Max {preced th s}) ?Y" |
598 proof(rule Max_Un, auto) |
598 proof(rule Max_Un, auto) |
599 from finite_threads[OF vt] dependents_threads[OF vt, of th] children_dependents [of s th] |
599 from finite_threads[OF vt] dependants_threads[OF vt, of th] children_dependants [of s th] |
600 show "finite ((\<lambda>th. Max (insert (preced th s) ((\<lambda>th. preced th s) ` dependents (wq s) th))) ` |
600 show "finite ((\<lambda>th. Max (insert (preced th s) ((\<lambda>th. preced th s) ` dependants (wq s) th))) ` |
601 children s th)" |
601 children s th)" |
602 by (auto simp:finite_subset) |
602 by (auto simp:finite_subset) |
603 next |
603 next |
604 assume "children s th = {}" |
604 assume "children s th = {}" |
605 with False show False by auto |
605 with False show False by auto |
646 by (unfold s_def depend_set_unchanged, auto) |
646 by (unfold s_def depend_set_unchanged, auto) |
647 |
647 |
648 lemma eq_cp_pre: |
648 lemma eq_cp_pre: |
649 fixes th' |
649 fixes th' |
650 assumes neq_th: "th' \<noteq> th" |
650 assumes neq_th: "th' \<noteq> th" |
651 and nd: "th \<notin> dependents s th'" |
651 and nd: "th \<notin> dependants s th'" |
652 shows "cp s th' = cp s' th'" |
652 shows "cp s th' = cp s' th'" |
653 apply (unfold cp_eq_cpreced cpreced_def) |
653 apply (unfold cp_eq_cpreced cpreced_def) |
654 proof - |
654 proof - |
655 have eq_dp: "\<And> th. dependents (wq s) th = dependents (wq s') th" |
655 have eq_dp: "\<And> th. dependants (wq s) th = dependants (wq s') th" |
656 by (unfold cs_dependents_def, auto simp:eq_dep eq_depend) |
656 by (unfold cs_dependants_def, auto simp:eq_dep eq_depend) |
657 moreover { |
657 moreover { |
658 fix th1 |
658 fix th1 |
659 assume "th1 \<in> {th'} \<union> dependents (wq s') th'" |
659 assume "th1 \<in> {th'} \<union> dependants (wq s') th'" |
660 hence "th1 = th' \<or> th1 \<in> dependents (wq s') th'" by auto |
660 hence "th1 = th' \<or> th1 \<in> dependants (wq s') th'" by auto |
661 hence "preced th1 s = preced th1 s'" |
661 hence "preced th1 s = preced th1 s'" |
662 proof |
662 proof |
663 assume "th1 = th'" |
663 assume "th1 = th'" |
664 with eq_preced[OF neq_th] |
664 with eq_preced[OF neq_th] |
665 show "preced th1 s = preced th1 s'" by simp |
665 show "preced th1 s = preced th1 s'" by simp |
666 next |
666 next |
667 assume "th1 \<in> dependents (wq s') th'" |
667 assume "th1 \<in> dependants (wq s') th'" |
668 with nd and eq_dp have "th1 \<noteq> th" |
668 with nd and eq_dp have "th1 \<noteq> th" |
669 by (auto simp:eq_depend cs_dependents_def s_dependents_def eq_dep) |
669 by (auto simp:eq_depend cs_dependants_def s_dependants_def eq_dep) |
670 from eq_preced[OF this] show "preced th1 s = preced th1 s'" by simp |
670 from eq_preced[OF this] show "preced th1 s = preced th1 s'" by simp |
671 qed |
671 qed |
672 } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) = |
672 } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = |
673 ((\<lambda>th. preced th s') ` ({th'} \<union> dependents (wq s') th'))" |
673 ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" |
674 by (auto simp:image_def) |
674 by (auto simp:image_def) |
675 thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) = |
675 thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = |
676 Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependents (wq s') th'))" by simp |
676 Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp |
677 qed |
677 qed |
678 |
678 |
679 lemma no_dependents: |
679 lemma no_dependants: |
680 assumes "th' \<noteq> th" |
680 assumes "th' \<noteq> th" |
681 shows "th \<notin> dependents s th'" |
681 shows "th \<notin> dependants s th'" |
682 proof |
682 proof |
683 assume h: "th \<in> dependents s th'" |
683 assume h: "th \<in> dependants s th'" |
684 from step_back_step [OF vt_s[unfolded s_def]] |
684 from step_back_step [OF vt_s[unfolded s_def]] |
685 have "step s' (Set th prio)" . |
685 have "step s' (Set th prio)" . |
686 hence "th \<in> runing s'" by (cases, simp) |
686 hence "th \<in> runing s'" by (cases, simp) |
687 hence rd_th: "th \<in> readys s'" |
687 hence rd_th: "th \<in> readys s'" |
688 by (simp add:readys_def runing_def) |
688 by (simp add:readys_def runing_def) |
689 from h have "(Th th, Th th') \<in> (depend s')\<^sup>+" |
689 from h have "(Th th, Th th') \<in> (depend s')\<^sup>+" |
690 by (unfold s_dependents_def, unfold eq_depend, unfold eq_dep, auto) |
690 by (unfold s_dependants_def, unfold eq_depend, unfold eq_dep, auto) |
691 from tranclD[OF this] |
691 from tranclD[OF this] |
692 obtain z where "(Th th, z) \<in> depend s'" by auto |
692 obtain z where "(Th th, z) \<in> depend s'" by auto |
693 with rd_th show "False" |
693 with rd_th show "False" |
694 apply (case_tac z, auto simp:readys_def s_waiting_def s_depend_def s_waiting_def cs_waiting_def) |
694 apply (case_tac z, auto simp:readys_def s_waiting_def s_depend_def s_waiting_def cs_waiting_def) |
695 by (fold wq_def, blast) |
695 by (fold wq_def, blast) |
1350 lemma eq_cp: |
1350 lemma eq_cp: |
1351 fixes th' |
1351 fixes th' |
1352 shows "cp s th' = cp s' th'" |
1352 shows "cp s th' = cp s' th'" |
1353 apply (unfold cp_eq_cpreced cpreced_def) |
1353 apply (unfold cp_eq_cpreced cpreced_def) |
1354 proof - |
1354 proof - |
1355 have eq_dp: "\<And> th. dependents (wq s) th = dependents (wq s') th" |
1355 have eq_dp: "\<And> th. dependants (wq s) th = dependants (wq s') th" |
1356 apply (unfold cs_dependents_def, unfold eq_depend) |
1356 apply (unfold cs_dependants_def, unfold eq_depend) |
1357 proof - |
1357 proof - |
1358 from eq_child |
1358 from eq_child |
1359 have "\<And>th. {th'. (Th th', Th th) \<in> (child s)\<^sup>+} = {th'. (Th th', Th th) \<in> (child s')\<^sup>+}" |
1359 have "\<And>th. {th'. (Th th', Th th) \<in> (child s)\<^sup>+} = {th'. (Th th', Th th) \<in> (child s')\<^sup>+}" |
1360 by simp |
1360 by simp |
1361 with child_depend_eq[OF vt_s] child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]] |
1361 with child_depend_eq[OF vt_s] child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]] |
1362 show "\<And>th. {th'. (Th th', Th th) \<in> (depend s)\<^sup>+} = {th'. (Th th', Th th) \<in> (depend s')\<^sup>+}" |
1362 show "\<And>th. {th'. (Th th', Th th) \<in> (depend s)\<^sup>+} = {th'. (Th th', Th th) \<in> (depend s')\<^sup>+}" |
1363 by simp |
1363 by simp |
1364 qed |
1364 qed |
1365 moreover { |
1365 moreover { |
1366 fix th1 |
1366 fix th1 |
1367 assume "th1 \<in> {th'} \<union> dependents (wq s') th'" |
1367 assume "th1 \<in> {th'} \<union> dependants (wq s') th'" |
1368 hence "th1 = th' \<or> th1 \<in> dependents (wq s') th'" by auto |
1368 hence "th1 = th' \<or> th1 \<in> dependants (wq s') th'" by auto |
1369 hence "preced th1 s = preced th1 s'" |
1369 hence "preced th1 s = preced th1 s'" |
1370 proof |
1370 proof |
1371 assume "th1 = th'" |
1371 assume "th1 = th'" |
1372 show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def) |
1372 show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def) |
1373 next |
1373 next |
1374 assume "th1 \<in> dependents (wq s') th'" |
1374 assume "th1 \<in> dependants (wq s') th'" |
1375 show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def) |
1375 show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def) |
1376 qed |
1376 qed |
1377 } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) = |
1377 } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = |
1378 ((\<lambda>th. preced th s') ` ({th'} \<union> dependents (wq s') th'))" |
1378 ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" |
1379 by (auto simp:image_def) |
1379 by (auto simp:image_def) |
1380 thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) = |
1380 thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = |
1381 Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependents (wq s') th'))" by simp |
1381 Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp |
1382 qed |
1382 qed |
1383 |
1383 |
1384 end |
1384 end |
1385 |
1385 |
1386 locale step_P_cps = |
1386 locale step_P_cps = |
1494 lemma eq_cp: |
1494 lemma eq_cp: |
1495 fixes th' |
1495 fixes th' |
1496 shows "cp s th' = cp s' th'" |
1496 shows "cp s th' = cp s' th'" |
1497 apply (unfold cp_eq_cpreced cpreced_def) |
1497 apply (unfold cp_eq_cpreced cpreced_def) |
1498 proof - |
1498 proof - |
1499 have eq_dp: "\<And> th. dependents (wq s) th = dependents (wq s') th" |
1499 have eq_dp: "\<And> th. dependants (wq s) th = dependants (wq s') th" |
1500 apply (unfold cs_dependents_def, unfold eq_depend) |
1500 apply (unfold cs_dependants_def, unfold eq_depend) |
1501 proof - |
1501 proof - |
1502 from eq_child |
1502 from eq_child |
1503 have "\<And>th. {th'. (Th th', Th th) \<in> (child s)\<^sup>+} = {th'. (Th th', Th th) \<in> (child s')\<^sup>+}" |
1503 have "\<And>th. {th'. (Th th', Th th) \<in> (child s)\<^sup>+} = {th'. (Th th', Th th) \<in> (child s')\<^sup>+}" |
1504 by auto |
1504 by auto |
1505 with child_depend_eq[OF vt_s] child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]] |
1505 with child_depend_eq[OF vt_s] child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]] |
1506 show "\<And>th. {th'. (Th th', Th th) \<in> (depend s)\<^sup>+} = {th'. (Th th', Th th) \<in> (depend s')\<^sup>+}" |
1506 show "\<And>th. {th'. (Th th', Th th) \<in> (depend s)\<^sup>+} = {th'. (Th th', Th th) \<in> (depend s')\<^sup>+}" |
1507 by simp |
1507 by simp |
1508 qed |
1508 qed |
1509 moreover { |
1509 moreover { |
1510 fix th1 |
1510 fix th1 |
1511 assume "th1 \<in> {th'} \<union> dependents (wq s') th'" |
1511 assume "th1 \<in> {th'} \<union> dependants (wq s') th'" |
1512 hence "th1 = th' \<or> th1 \<in> dependents (wq s') th'" by auto |
1512 hence "th1 = th' \<or> th1 \<in> dependants (wq s') th'" by auto |
1513 hence "preced th1 s = preced th1 s'" |
1513 hence "preced th1 s = preced th1 s'" |
1514 proof |
1514 proof |
1515 assume "th1 = th'" |
1515 assume "th1 = th'" |
1516 show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def) |
1516 show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def) |
1517 next |
1517 next |
1518 assume "th1 \<in> dependents (wq s') th'" |
1518 assume "th1 \<in> dependants (wq s') th'" |
1519 show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def) |
1519 show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def) |
1520 qed |
1520 qed |
1521 } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) = |
1521 } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = |
1522 ((\<lambda>th. preced th s') ` ({th'} \<union> dependents (wq s') th'))" |
1522 ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" |
1523 by (auto simp:image_def) |
1523 by (auto simp:image_def) |
1524 thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) = |
1524 thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = |
1525 Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependents (wq s') th'))" by simp |
1525 Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp |
1526 qed |
1526 qed |
1527 |
1527 |
1528 end |
1528 end |
1529 |
1529 |
1530 context step_P_cps_ne |
1530 context step_P_cps_ne |
1595 shows "((n1, Th th') \<in> (child s)^+) = ((n1, Th th') \<in> (child s')^+)" |
1595 shows "((n1, Th th') \<in> (child s)^+) = ((n1, Th th') \<in> (child s')^+)" |
1596 by (insert eq_child_left[OF nd] eq_child_right, auto) |
1596 by (insert eq_child_left[OF nd] eq_child_right, auto) |
1597 |
1597 |
1598 lemma eq_cp: |
1598 lemma eq_cp: |
1599 fixes th' |
1599 fixes th' |
1600 assumes nd: "th \<notin> dependents s th'" |
1600 assumes nd: "th \<notin> dependants s th'" |
1601 shows "cp s th' = cp s' th'" |
1601 shows "cp s th' = cp s' th'" |
1602 apply (unfold cp_eq_cpreced cpreced_def) |
1602 apply (unfold cp_eq_cpreced cpreced_def) |
1603 proof - |
1603 proof - |
1604 have nd': "(Th th, Th th') \<notin> (child s)^+" |
1604 have nd': "(Th th, Th th') \<notin> (child s)^+" |
1605 proof |
1605 proof |
1606 assume "(Th th, Th th') \<in> (child s)\<^sup>+" |
1606 assume "(Th th, Th th') \<in> (child s)\<^sup>+" |
1607 with child_depend_eq[OF vt_s] |
1607 with child_depend_eq[OF vt_s] |
1608 have "(Th th, Th th') \<in> (depend s)\<^sup>+" by simp |
1608 have "(Th th, Th th') \<in> (depend s)\<^sup>+" by simp |
1609 with nd show False |
1609 with nd show False |
1610 by (simp add:s_dependents_def eq_depend) |
1610 by (simp add:s_dependants_def eq_depend) |
1611 qed |
1611 qed |
1612 have eq_dp: "dependents (wq s) th' = dependents (wq s') th'" |
1612 have eq_dp: "dependants (wq s) th' = dependants (wq s') th'" |
1613 proof(auto) |
1613 proof(auto) |
1614 fix x assume " x \<in> dependents (wq s) th'" |
1614 fix x assume " x \<in> dependants (wq s) th'" |
1615 thus "x \<in> dependents (wq s') th'" |
1615 thus "x \<in> dependants (wq s') th'" |
1616 apply (auto simp:cs_dependents_def eq_depend) |
1616 apply (auto simp:cs_dependants_def eq_depend) |
1617 proof - |
1617 proof - |
1618 assume "(Th x, Th th') \<in> (depend s)\<^sup>+" |
1618 assume "(Th x, Th th') \<in> (depend s)\<^sup>+" |
1619 with child_depend_eq[OF vt_s] have "(Th x, Th th') \<in> (child s)\<^sup>+" by simp |
1619 with child_depend_eq[OF vt_s] have "(Th x, Th th') \<in> (child s)\<^sup>+" by simp |
1620 with eq_child[OF nd'] have "(Th x, Th th') \<in> (child s')^+" by simp |
1620 with eq_child[OF nd'] have "(Th x, Th th') \<in> (child s')^+" by simp |
1621 with child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]] |
1621 with child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]] |
1622 show "(Th x, Th th') \<in> (depend s')\<^sup>+" by simp |
1622 show "(Th x, Th th') \<in> (depend s')\<^sup>+" by simp |
1623 qed |
1623 qed |
1624 next |
1624 next |
1625 fix x assume "x \<in> dependents (wq s') th'" |
1625 fix x assume "x \<in> dependants (wq s') th'" |
1626 thus "x \<in> dependents (wq s) th'" |
1626 thus "x \<in> dependants (wq s) th'" |
1627 apply (auto simp:cs_dependents_def eq_depend) |
1627 apply (auto simp:cs_dependants_def eq_depend) |
1628 proof - |
1628 proof - |
1629 assume "(Th x, Th th') \<in> (depend s')\<^sup>+" |
1629 assume "(Th x, Th th') \<in> (depend s')\<^sup>+" |
1630 with child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]] |
1630 with child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]] |
1631 have "(Th x, Th th') \<in> (child s')\<^sup>+" by simp |
1631 have "(Th x, Th th') \<in> (child s')\<^sup>+" by simp |
1632 with eq_child[OF nd'] have "(Th x, Th th') \<in> (child s)^+" by simp |
1632 with eq_child[OF nd'] have "(Th x, Th th') \<in> (child s)^+" by simp |
1877 proof(cases) |
1877 proof(cases) |
1878 assume "th \<notin> threads s'" |
1878 assume "th \<notin> threads s'" |
1879 with in_th show ?thesis by simp |
1879 with in_th show ?thesis by simp |
1880 qed |
1880 qed |
1881 qed |
1881 qed |
1882 have eq_dp: "\<And> th. dependents (wq s) th = dependents (wq s') th" |
1882 have eq_dp: "\<And> th. dependants (wq s) th = dependants (wq s') th" |
1883 by (unfold cs_dependents_def, auto simp:eq_dep eq_depend) |
1883 by (unfold cs_dependants_def, auto simp:eq_dep eq_depend) |
1884 moreover { |
1884 moreover { |
1885 fix th1 |
1885 fix th1 |
1886 assume "th1 \<in> {th'} \<union> dependents (wq s') th'" |
1886 assume "th1 \<in> {th'} \<union> dependants (wq s') th'" |
1887 hence "th1 = th' \<or> th1 \<in> dependents (wq s') th'" by auto |
1887 hence "th1 = th' \<or> th1 \<in> dependants (wq s') th'" by auto |
1888 hence "preced th1 s = preced th1 s'" |
1888 hence "preced th1 s = preced th1 s'" |
1889 proof |
1889 proof |
1890 assume "th1 = th'" |
1890 assume "th1 = th'" |
1891 with neq_th |
1891 with neq_th |
1892 show "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def) |
1892 show "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def) |
1893 next |
1893 next |
1894 assume "th1 \<in> dependents (wq s') th'" |
1894 assume "th1 \<in> dependants (wq s') th'" |
1895 with nd and eq_dp have "th1 \<noteq> th" |
1895 with nd and eq_dp have "th1 \<noteq> th" |
1896 by (auto simp:eq_depend cs_dependents_def s_dependents_def eq_dep) |
1896 by (auto simp:eq_depend cs_dependants_def s_dependants_def eq_dep) |
1897 thus "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def) |
1897 thus "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def) |
1898 qed |
1898 qed |
1899 } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) = |
1899 } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = |
1900 ((\<lambda>th. preced th s') ` ({th'} \<union> dependents (wq s') th'))" |
1900 ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" |
1901 by (auto simp:image_def) |
1901 by (auto simp:image_def) |
1902 thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) = |
1902 thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = |
1903 Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependents (wq s') th'))" by simp |
1903 Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp |
1904 qed |
1904 qed |
1905 |
1905 |
1906 lemma nil_dependents: "dependents s th = {}" |
1906 lemma nil_dependants: "dependants s th = {}" |
1907 proof - |
1907 proof - |
1908 from step_back_step[OF vt_s[unfolded s_def]] |
1908 from step_back_step[OF vt_s[unfolded s_def]] |
1909 show ?thesis |
1909 show ?thesis |
1910 proof(cases) |
1910 proof(cases) |
1911 assume "th \<notin> threads s'" |
1911 assume "th \<notin> threads s'" |
1912 from not_thread_holdents[OF step_back_vt[OF vt_s[unfolded s_def]] this] |
1912 from not_thread_holdents[OF step_back_vt[OF vt_s[unfolded s_def]] this] |
1913 have hdn: " holdents s' th = {}" . |
1913 have hdn: " holdents s' th = {}" . |
1914 have "dependents s' th = {}" |
1914 have "dependants s' th = {}" |
1915 proof - |
1915 proof - |
1916 { assume "dependents s' th \<noteq> {}" |
1916 { assume "dependants s' th \<noteq> {}" |
1917 then obtain th' where dp: "(Th th', Th th) \<in> (depend s')^+" |
1917 then obtain th' where dp: "(Th th', Th th) \<in> (depend s')^+" |
1918 by (auto simp:s_dependents_def eq_depend) |
1918 by (auto simp:s_dependants_def eq_depend) |
1919 from tranclE[OF this] obtain cs' where |
1919 from tranclE[OF this] obtain cs' where |
1920 "(Cs cs', Th th) \<in> depend s'" by (auto simp:s_depend_def) |
1920 "(Cs cs', Th th) \<in> depend s'" by (auto simp:s_depend_def) |
1921 with hdn |
1921 with hdn |
1922 have False by (auto simp:holdents_test) |
1922 have False by (auto simp:holdents_test) |
1923 } thus ?thesis by auto |
1923 } thus ?thesis by auto |
1924 qed |
1924 qed |
1925 thus ?thesis |
1925 thus ?thesis |
1926 by (unfold s_def s_dependents_def eq_depend depend_create_unchanged, simp) |
1926 by (unfold s_def s_dependants_def eq_depend depend_create_unchanged, simp) |
1927 qed |
1927 qed |
1928 qed |
1928 qed |
1929 |
1929 |
1930 lemma eq_cp_th: "cp s th = preced th s" |
1930 lemma eq_cp_th: "cp s th = preced th s" |
1931 apply (unfold cp_eq_cpreced cpreced_def) |
1931 apply (unfold cp_eq_cpreced cpreced_def) |
1932 by (insert nil_dependents, unfold s_dependents_def cs_dependents_def, auto) |
1932 by (insert nil_dependants, unfold s_dependants_def cs_dependants_def, auto) |
1933 |
1933 |
1934 end |
1934 end |
1935 |
1935 |
1936 |
1936 |
1937 locale step_exit_cps = |
1937 locale step_exit_cps = |
1966 with bk show ?thesis |
1966 with bk show ?thesis |
1967 apply (unfold runing_def readys_def s_waiting_def s_depend_def) |
1967 apply (unfold runing_def readys_def s_waiting_def s_depend_def) |
1968 by (auto simp:cs_waiting_def wq_def) |
1968 by (auto simp:cs_waiting_def wq_def) |
1969 qed |
1969 qed |
1970 qed |
1970 qed |
1971 have eq_dp: "\<And> th. dependents (wq s) th = dependents (wq s') th" |
1971 have eq_dp: "\<And> th. dependants (wq s) th = dependants (wq s') th" |
1972 by (unfold cs_dependents_def, auto simp:eq_dep eq_depend) |
1972 by (unfold cs_dependants_def, auto simp:eq_dep eq_depend) |
1973 moreover { |
1973 moreover { |
1974 fix th1 |
1974 fix th1 |
1975 assume "th1 \<in> {th'} \<union> dependents (wq s') th'" |
1975 assume "th1 \<in> {th'} \<union> dependants (wq s') th'" |
1976 hence "th1 = th' \<or> th1 \<in> dependents (wq s') th'" by auto |
1976 hence "th1 = th' \<or> th1 \<in> dependants (wq s') th'" by auto |
1977 hence "preced th1 s = preced th1 s'" |
1977 hence "preced th1 s = preced th1 s'" |
1978 proof |
1978 proof |
1979 assume "th1 = th'" |
1979 assume "th1 = th'" |
1980 with neq_th |
1980 with neq_th |
1981 show "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def) |
1981 show "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def) |
1982 next |
1982 next |
1983 assume "th1 \<in> dependents (wq s') th'" |
1983 assume "th1 \<in> dependants (wq s') th'" |
1984 with nd and eq_dp have "th1 \<noteq> th" |
1984 with nd and eq_dp have "th1 \<noteq> th" |
1985 by (auto simp:eq_depend cs_dependents_def s_dependents_def eq_dep) |
1985 by (auto simp:eq_depend cs_dependants_def s_dependants_def eq_dep) |
1986 thus "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def) |
1986 thus "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def) |
1987 qed |
1987 qed |
1988 } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) = |
1988 } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = |
1989 ((\<lambda>th. preced th s') ` ({th'} \<union> dependents (wq s') th'))" |
1989 ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" |
1990 by (auto simp:image_def) |
1990 by (auto simp:image_def) |
1991 thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')) = |
1991 thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = |
1992 Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependents (wq s') th'))" by simp |
1992 Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp |
1993 qed |
1993 qed |
1994 |
1994 |
1995 end |
1995 end |
1996 end |
1996 end |
1997 |
1997 |