145 proof - |
145 proof - |
146 from assms[unfolded s_waiting_def, folded wq_def] |
146 from assms[unfolded s_waiting_def, folded wq_def] |
147 obtain th' where "th' \<in> set (wq s cs)" "th' = hd (wq s cs)" |
147 obtain th' where "th' \<in> set (wq s cs)" "th' = hd (wq s cs)" |
148 by (metis empty_iff hd_in_set list.set(1)) |
148 by (metis empty_iff hd_in_set list.set(1)) |
149 hence "holding s th' cs" |
149 hence "holding s th' cs" |
150 by (unfold s_holding_def, fold wq_def, auto) |
150 unfolding s_holding_def by auto |
151 from that[OF this] show ?thesis . |
151 from that[OF this] show ?thesis . |
152 qed |
152 qed |
153 |
153 |
154 |
154 |
155 text {* |
155 text {* |
157 @{term children} in @{term RAG} to the notion of @{term holding}. |
157 @{term children} in @{term RAG} to the notion of @{term holding}. |
158 It is a technical lemmas used to prove the two following lemmas. |
158 It is a technical lemmas used to prove the two following lemmas. |
159 *} |
159 *} |
160 lemma children_RAG_alt_def: |
160 lemma children_RAG_alt_def: |
161 "children (RAG (s::state)) (Th th) = Cs ` {cs. holding s th cs}" |
161 "children (RAG (s::state)) (Th th) = Cs ` {cs. holding s th cs}" |
162 by (unfold s_RAG_def, auto simp:children_def holding_eq) |
162 by (unfold s_RAG_def, auto simp:children_def s_holding_abv) |
163 |
163 |
164 text {* |
164 text {* |
165 The following two lemmas relate @{term holdents} and @{term cntCS} |
165 The following two lemmas relate @{term holdents} and @{term cntCS} |
166 to @{term children} in @{term RAG}, so that proofs about |
166 to @{term children} in @{term RAG}, so that proofs about |
167 @{term holdents} and @{term cntCS} can be carried out under |
167 @{term holdents} and @{term cntCS} can be carried out under |
277 two nodes are in @{term RAG}. |
277 two nodes are in @{term RAG}. |
278 *} |
278 *} |
279 lemma in_RAG_E: |
279 lemma in_RAG_E: |
280 assumes "(n1, n2) \<in> RAG (s::state)" |
280 assumes "(n1, n2) \<in> RAG (s::state)" |
281 obtains (waiting) th cs where "n1 = Th th" "n2 = Cs cs" "waiting s th cs" |
281 obtains (waiting) th cs where "n1 = Th th" "n2 = Cs cs" "waiting s th cs" |
282 | (holding) th cs where "n1 = Cs cs" "n2 = Th th" "holding s th cs" |
282 | (holding) th cs where "n1 = Cs cs" "n2 = Th th" "holding s th cs" |
283 using assms[unfolded s_RAG_def, folded waiting_eq holding_eq] |
283 using assms[unfolded s_RAG_def, folded s_waiting_abv s_holding_abv] |
284 by auto |
284 by auto |
285 |
285 |
286 text {* |
286 text {* |
287 The following lemmas are the simplification rules |
287 The following lemmas are the simplification rules |
288 for @{term count}, @{term cntP}, @{term cntV}. |
288 for @{term count}, @{term cntP}, @{term cntV}. |
582 apply (simp add: s_RAG_abv s_dependants_def wq_def) |
582 apply (simp add: s_RAG_abv s_dependants_def wq_def) |
583 by (simp add: rtrancl_eq_or_trancl s_RAG_abv s_dependants_def wq_def) |
583 by (simp add: rtrancl_eq_or_trancl s_RAG_abv s_dependants_def wq_def) |
584 thus ?thesis by simp |
584 thus ?thesis by simp |
585 qed |
585 qed |
586 thus ?thesis |
586 thus ?thesis |
587 by (metis (no_types, lifting) cp_eq cpreced_def eq_dependants |
587 by (metis (no_types, lifting) cp_eq cpreced_def2 f_image_eq |
588 f_image_eq the_preced_def) |
588 s_dependants_abv the_preced_def) |
589 qed |
589 qed |
590 |
590 |
591 text {* |
591 text {* |
592 The following is another definition of @{term cp}. |
592 The following is another definition of @{term cp}. |
593 *} |
593 *} |
623 moreover have "th2 = th''" |
623 moreover have "th2 = th''" |
624 proof - |
624 proof - |
625 from h1 have "cs' = cs" by simp |
625 from h1 have "cs' = cs" by simp |
626 from assms(2) cs_in[unfolded this] |
626 from assms(2) cs_in[unfolded this] |
627 have "holding s th'' cs" "holding s th2 cs" |
627 have "holding s th'' cs" "holding s th2 cs" |
628 by (unfold s_RAG_def, fold holding_eq, auto) |
628 by (unfold s_RAG_def, fold s_holding_abv, auto) |
629 from held_unique[OF this] |
629 from held_unique[OF this] |
630 show ?thesis by simp |
630 show ?thesis by simp |
631 qed |
631 qed |
632 ultimately show ?thesis using h(1,2) h1 by auto |
632 ultimately show ?thesis using h(1,2) h1 by auto |
633 next |
633 next |
988 assume otherwise: "th \<in> set (wq s cs)" |
988 assume otherwise: "th \<in> set (wq s cs)" |
989 from running_wqE[OF running_th_s this] |
989 from running_wqE[OF running_th_s this] |
990 obtain rest where eq_wq: "wq s cs = th#rest" by blast |
990 obtain rest where eq_wq: "wq s cs = th#rest" by blast |
991 with otherwise |
991 with otherwise |
992 have "holding s th cs" |
992 have "holding s th cs" |
993 by (unfold s_holding_def, fold wq_def, simp) |
993 unfolding s_holding_def by auto |
994 hence cs_th_RAG: "(Cs cs, Th th) \<in> RAG s" |
994 hence cs_th_RAG: "(Cs cs, Th th) \<in> RAG s" |
995 by (unfold s_RAG_def, fold holding_eq, auto) |
995 by (unfold s_RAG_def, fold s_holding_abv, auto) |
996 from pip_e[unfolded is_p] |
996 from pip_e[unfolded is_p] |
997 show False |
997 show False |
998 proof(cases) |
998 proof(cases) |
999 case (thread_P) |
999 case (thread_P) |
1000 with cs_th_RAG show ?thesis by auto |
1000 with cs_th_RAG show ?thesis by auto |
1166 lemma |
1166 lemma |
1167 th_not_in_wq: "th \<notin> set (wq s cs)" |
1167 th_not_in_wq: "th \<notin> set (wq s cs)" |
1168 proof - |
1168 proof - |
1169 from pip_e[unfolded is_exit] |
1169 from pip_e[unfolded is_exit] |
1170 show ?thesis |
1170 show ?thesis |
1171 by (cases, unfold holdents_def s_holding_def, fold wq_def, |
1171 apply(cases) |
1172 auto elim!:running_wqE) |
1172 unfolding holdents_def s_holding_def |
|
1173 by (metis (mono_tags, lifting) empty_iff list.sel(1) mem_Collect_eq running_wqE) |
1173 qed |
1174 qed |
1174 |
1175 |
1175 lemma wq_threads_kept: |
1176 lemma wq_threads_kept: |
1176 assumes "\<And> th' cs'. th' \<in> set (wq s cs') \<Longrightarrow> th' \<in> threads s" |
1177 assumes "\<And> th' cs'. th' \<in> set (wq s cs') \<Longrightarrow> th' \<in> threads s" |
1177 and "th' \<in> set (wq (e#s) cs')" |
1178 and "th' \<in> set (wq (e#s) cs')" |
1560 and "holding s t c" |
1561 and "holding s t c" |
1561 shows "holding (e#s) t c" |
1562 shows "holding (e#s) t c" |
1562 proof - |
1563 proof - |
1563 from assms(1) have "wq (e#s) c = wq s c" by auto |
1564 from assms(1) have "wq (e#s) c = wq s c" by auto |
1564 from assms(2)[unfolded s_holding_def, folded wq_def, |
1565 from assms(2)[unfolded s_holding_def, folded wq_def, |
1565 folded this, unfolded wq_def, folded s_holding_def] |
1566 folded this, folded s_holding_def] |
1566 show ?thesis . |
1567 show ?thesis . |
1567 qed |
1568 qed |
1568 |
1569 |
1569 lemma holding_esI1: |
1570 lemma holding_esI1: |
1570 assumes "holding s t c" |
1571 assumes "holding s t c" |
1622 using next_th_taker taker_def waiting_set_eq |
1623 using next_th_taker taker_def waiting_set_eq |
1623 by fastforce |
1624 by fastforce |
1624 |
1625 |
1625 lemma holding_taker: |
1626 lemma holding_taker: |
1626 shows "holding (e#s) taker cs" |
1627 shows "holding (e#s) taker cs" |
1627 by (unfold s_holding_def, fold wq_def, unfold wq_es_cs, |
1628 by (unfold s_holding_def, unfold wq_es_cs, |
1628 auto simp:neq_wq' taker_def) |
1629 auto simp:neq_wq' taker_def) |
1629 |
1630 |
1630 lemma waiting_esI2: |
1631 lemma waiting_esI2: |
1631 assumes "waiting s t cs" |
1632 assumes "waiting s t cs" |
1632 and "t \<noteq> taker" |
1633 and "t \<noteq> taker" |
1690 from that(1)[OF True this] show ?thesis . |
1691 from that(1)[OF True this] show ?thesis . |
1691 next |
1692 next |
1692 case False |
1693 case False |
1693 hence "wq (e#s) c = wq s c" by auto |
1694 hence "wq (e#s) c = wq s c" by auto |
1694 from assms[unfolded s_holding_def, folded wq_def, |
1695 from assms[unfolded s_holding_def, folded wq_def, |
1695 unfolded this, unfolded wq_def, folded s_holding_def] |
1696 unfolded this, folded s_holding_def] |
1696 have "holding s t c" . |
1697 have "holding s t c" . |
1697 from that(2)[OF False this] show ?thesis . |
1698 from that(2)[OF False this] show ?thesis . |
1698 qed |
1699 qed |
1699 |
1700 |
1700 end |
1701 end |
1793 show ?thesis by auto |
1794 show ?thesis by auto |
1794 next |
1795 next |
1795 case False |
1796 case False |
1796 hence "wq (e#s) c = wq s c" by auto |
1797 hence "wq (e#s) c = wq s c" by auto |
1797 from assms[unfolded s_holding_def, folded wq_def, |
1798 from assms[unfolded s_holding_def, folded wq_def, |
1798 unfolded this, unfolded wq_def, folded s_holding_def] |
1799 unfolded this, folded s_holding_def] |
1799 have "holding s t c" . |
1800 have "holding s t c" . |
1800 from that[OF False this] show ?thesis . |
1801 from that[OF False this] show ?thesis . |
1801 qed |
1802 qed |
1802 |
1803 |
1803 end |
1804 end |
1827 proof(cases rule:h_n.waiting_esE) |
1828 proof(cases rule:h_n.waiting_esE) |
1828 case 1 |
1829 case 1 |
1829 with waiting(1,2) |
1830 with waiting(1,2) |
1830 show ?thesis |
1831 show ?thesis |
1831 by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, |
1832 by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, |
1832 fold waiting_eq, auto) |
1833 fold s_waiting_abv, auto) |
1833 next |
1834 next |
1834 case 2 |
1835 case 2 |
1835 with waiting(1,2) |
1836 with waiting(1,2) |
1836 show ?thesis |
1837 show ?thesis |
1837 by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, |
1838 by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, |
1838 fold waiting_eq, auto) |
1839 fold s_waiting_abv, auto) |
1839 qed |
1840 qed |
1840 next |
1841 next |
1841 case True |
1842 case True |
1842 interpret h_e: valid_trace_v_e s e th cs |
1843 interpret h_e: valid_trace_v_e s e th cs |
1843 by (unfold_locales, insert True, simp) |
1844 by (unfold_locales, insert True, simp) |
1863 proof(cases rule:h_n.holding_esE) |
1864 proof(cases rule:h_n.holding_esE) |
1864 case 1 |
1865 case 1 |
1865 with holding(1,2) |
1866 with holding(1,2) |
1866 show ?thesis |
1867 show ?thesis |
1867 by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, |
1868 by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, |
1868 fold waiting_eq, auto) |
1869 fold s_waiting_abv, auto) |
1869 next |
1870 next |
1870 case 2 |
1871 case 2 |
1871 with holding(1,2) |
1872 with holding(1,2) |
1872 show ?thesis |
1873 show ?thesis |
1873 by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, |
1874 by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, |
1874 fold holding_eq, auto) |
1875 fold s_holding_abv, auto) |
1875 qed |
1876 qed |
1876 next |
1877 next |
1877 case True |
1878 case True |
1878 interpret h_e: valid_trace_v_e s e th cs |
1879 interpret h_e: valid_trace_v_e s e th cs |
1879 by (unfold_locales, insert True, simp) |
1880 by (unfold_locales, insert True, simp) |
1904 thus ?thesis |
1905 thus ?thesis |
1905 proof |
1906 proof |
1906 assume "n2 = Th h_n.taker \<and> n1 = Cs cs" |
1907 assume "n2 = Th h_n.taker \<and> n1 = Cs cs" |
1907 with h_n.holding_taker |
1908 with h_n.holding_taker |
1908 show ?thesis |
1909 show ?thesis |
1909 by (unfold s_RAG_def, fold holding_eq, auto) |
1910 by (unfold s_RAG_def, fold s_holding_abv, auto) |
1910 next |
1911 next |
1911 assume h: "(n1, n2) \<in> RAG s \<and> |
1912 assume h: "(n1, n2) \<in> RAG s \<and> |
1912 (n1 \<noteq> Cs cs \<or> n2 \<noteq> Th th) \<and> (n1 \<noteq> Th h_n.taker \<or> n2 \<noteq> Cs cs)" |
1913 (n1 \<noteq> Cs cs \<or> n2 \<noteq> Th th) \<and> (n1 \<noteq> Th h_n.taker \<or> n2 \<noteq> Cs cs)" |
1913 hence "(n1, n2) \<in> RAG s" by simp |
1914 hence "(n1, n2) \<in> RAG s" by simp |
1914 thus ?thesis |
1915 thus ?thesis |
1933 from h_n.waiting_esI2[OF waiting(3)[unfolded True] neq_th', folded True] |
1934 from h_n.waiting_esI2[OF waiting(3)[unfolded True] neq_th', folded True] |
1934 show ?thesis . |
1935 show ?thesis . |
1935 qed |
1936 qed |
1936 qed |
1937 qed |
1937 thus ?thesis using waiting(1,2) |
1938 thus ?thesis using waiting(1,2) |
1938 by (unfold s_RAG_def, fold waiting_eq, auto) |
1939 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
1939 next |
1940 next |
1940 case (holding th' cs') |
1941 case (holding th' cs') |
1941 from h this(1,2) |
1942 from h this(1,2) |
1942 have "cs' \<noteq> cs \<or> th' \<noteq> th" by auto |
1943 have "cs' \<noteq> cs \<or> th' \<noteq> th" by auto |
1943 hence "holding (e#s) th' cs'" |
1944 hence "holding (e#s) th' cs'" |
1949 assume "th' \<noteq> th" |
1950 assume "th' \<noteq> th" |
1950 from holding_esI1[OF holding(3) this] |
1951 from holding_esI1[OF holding(3) this] |
1951 show ?thesis . |
1952 show ?thesis . |
1952 qed |
1953 qed |
1953 thus ?thesis using holding(1,2) |
1954 thus ?thesis using holding(1,2) |
1954 by (unfold s_RAG_def, fold holding_eq, auto) |
1955 by (unfold s_RAG_def, fold s_holding_abv, auto) |
1955 qed |
1956 qed |
1956 qed |
1957 qed |
1957 next |
1958 next |
1958 case True |
1959 case True |
1959 interpret h_e: valid_trace_v_e s e th cs |
1960 interpret h_e: valid_trace_v_e s e th cs |
1965 show ?thesis |
1966 show ?thesis |
1966 proof(cases rule:in_RAG_E) |
1967 proof(cases rule:in_RAG_E) |
1967 case (waiting th' cs') |
1968 case (waiting th' cs') |
1968 from h_e.waiting_esI2[OF this(3)] |
1969 from h_e.waiting_esI2[OF this(3)] |
1969 show ?thesis using waiting(1,2) |
1970 show ?thesis using waiting(1,2) |
1970 by (unfold s_RAG_def, fold waiting_eq, auto) |
1971 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
1971 next |
1972 next |
1972 case (holding th' cs') |
1973 case (holding th' cs') |
1973 with h_s(2) |
1974 with h_s(2) |
1974 have "cs' \<noteq> cs \<or> th' \<noteq> th" by auto |
1975 have "cs' \<noteq> cs \<or> th' \<noteq> th" by auto |
1975 thus ?thesis |
1976 thus ?thesis |
1976 proof |
1977 proof |
1977 assume neq_cs: "cs' \<noteq> cs" |
1978 assume neq_cs: "cs' \<noteq> cs" |
1978 from holding_esI2[OF this holding(3)] |
1979 from holding_esI2[OF this holding(3)] |
1979 show ?thesis using holding(1,2) |
1980 show ?thesis using holding(1,2) |
1980 by (unfold s_RAG_def, fold holding_eq, auto) |
1981 by (unfold s_RAG_def, fold s_holding_abv, auto) |
1981 next |
1982 next |
1982 assume "th' \<noteq> th" |
1983 assume "th' \<noteq> th" |
1983 from holding_esI1[OF holding(3) this] |
1984 from holding_esI1[OF holding(3) this] |
1984 show ?thesis using holding(1,2) |
1985 show ?thesis using holding(1,2) |
1985 by (unfold s_RAG_def, fold holding_eq, auto) |
1986 by (unfold s_RAG_def, fold s_holding_abv, auto) |
1986 qed |
1987 qed |
1987 qed |
1988 qed |
1988 qed |
1989 qed |
1989 qed |
1990 qed |
1990 |
1991 |
2004 assumes "holding s th' cs'" |
2005 assumes "holding s th' cs'" |
2005 shows "holding (e#s) th' cs'" |
2006 shows "holding (e#s) th' cs'" |
2006 proof(cases "cs' = cs") |
2007 proof(cases "cs' = cs") |
2007 case False |
2008 case False |
2008 hence "wq (e#s) cs' = wq s cs'" by simp |
2009 hence "wq (e#s) cs' = wq s cs'" by simp |
2009 with assms show ?thesis unfolding holding_raw_def holding_eq by auto |
2010 with assms show ?thesis unfolding holding_raw_def s_holding_abv by auto |
2010 next |
2011 next |
2011 case True |
2012 case True |
2012 from assms[unfolded s_holding_def, folded wq_def] |
2013 from assms[unfolded s_holding_def, folded wq_def] |
2013 obtain rest where eq_wq: "wq s cs' = th'#rest" |
2014 obtain rest where eq_wq: "wq s cs' = th'#rest" |
2014 by (metis empty_iff list.collapse list.set(1)) |
2015 by (metis empty_iff list.collapse list.set(1)) |
2015 hence "wq (e#s) cs' = th'#(rest@[th])" |
2016 hence "wq (e#s) cs' = th'#(rest@[th])" |
2016 by (simp add: True wq_es_cs) |
2017 by (simp add: True wq_es_cs) |
2017 thus ?thesis |
2018 thus ?thesis |
2018 by (simp add: holding_raw_def holding_eq) |
2019 by (simp add: holding_raw_def s_holding_abv) |
2019 qed |
2020 qed |
2020 end |
2021 end |
2021 |
2022 |
2022 lemma (in valid_trace_p) th_not_waiting: "\<not> waiting s th c" |
2023 lemma (in valid_trace_p) th_not_waiting: "\<not> waiting s th c" |
2023 proof - |
2024 proof - |
2036 lemma holding_es_th_cs: |
2037 lemma holding_es_th_cs: |
2037 shows "holding (e#s) th cs" |
2038 shows "holding (e#s) th cs" |
2038 proof - |
2039 proof - |
2039 from wq_es_cs' |
2040 from wq_es_cs' |
2040 have "th \<in> set (wq (e#s) cs)" "th = hd (wq (e#s) cs)" by auto |
2041 have "th \<in> set (wq (e#s) cs)" "th = hd (wq (e#s) cs)" by auto |
2041 thus ?thesis unfolding holding_raw_def holding_eq by blast |
2042 thus ?thesis unfolding holding_raw_def s_holding_abv by blast |
2042 qed |
2043 qed |
2043 |
2044 |
2044 lemma RAG_edge: "(Cs cs, Th th) \<in> RAG (e#s)" |
2045 lemma RAG_edge: "(Cs cs, Th th) \<in> RAG (e#s)" |
2045 by (unfold s_RAG_def, fold holding_eq, insert holding_es_th_cs, auto) |
2046 by (unfold s_RAG_def, fold s_holding_abv, insert holding_es_th_cs, auto) |
2046 |
2047 |
2047 lemma waiting_esE: |
2048 lemma waiting_esE: |
2048 assumes "waiting (e#s) th' cs'" |
2049 assumes "waiting (e#s) th' cs'" |
2049 obtains "waiting s th' cs'" |
2050 obtains "waiting s th' cs'" |
2050 using assms |
2051 using assms |
2061 have "th' = th" by simp |
2062 have "th' = th" by simp |
2062 from that(2)[OF True this] show ?thesis . |
2063 from that(2)[OF True this] show ?thesis . |
2063 next |
2064 next |
2064 case False |
2065 case False |
2065 have "holding s th' cs'" using assms |
2066 have "holding s th' cs'" using assms |
2066 using False unfolding holding_raw_def holding_eq by auto |
2067 using False unfolding holding_raw_def s_holding_abv by auto |
2067 from that(1)[OF False this] show ?thesis . |
2068 from that(1)[OF False this] show ?thesis . |
2068 qed |
2069 qed |
2069 |
2070 |
2070 lemma RAG_es: "RAG (e # s) = RAG s \<union> {(Cs cs, Th th)}" (is "?L = ?R") |
2071 lemma RAG_es: "RAG (e # s) = RAG s \<union> {(Cs cs, Th th)}" (is "?L = ?R") |
2071 proof(rule rel_eqI) |
2072 proof(rule rel_eqI) |
2077 from this(3) |
2078 from this(3) |
2078 show ?thesis |
2079 show ?thesis |
2079 proof(cases rule:waiting_esE) |
2080 proof(cases rule:waiting_esE) |
2080 case 1 |
2081 case 1 |
2081 thus ?thesis using waiting(1,2) |
2082 thus ?thesis using waiting(1,2) |
2082 by (unfold s_RAG_def, fold waiting_eq, auto) |
2083 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
2083 qed |
2084 qed |
2084 next |
2085 next |
2085 case (holding th' cs') |
2086 case (holding th' cs') |
2086 from this(3) |
2087 from this(3) |
2087 show ?thesis |
2088 show ?thesis |
2088 proof(cases rule:holding_esE) |
2089 proof(cases rule:holding_esE) |
2089 case 1 |
2090 case 1 |
2090 with holding(1,2) |
2091 with holding(1,2) |
2091 show ?thesis by (unfold s_RAG_def, fold holding_eq, auto) |
2092 show ?thesis by (unfold s_RAG_def, fold s_holding_abv, auto) |
2092 next |
2093 next |
2093 case 2 |
2094 case 2 |
2094 with holding(1,2) show ?thesis by auto |
2095 with holding(1,2) show ?thesis by auto |
2095 qed |
2096 qed |
2096 qed |
2097 qed |
2104 thus ?thesis |
2105 thus ?thesis |
2105 proof(cases rule:in_RAG_E) |
2106 proof(cases rule:in_RAG_E) |
2106 case (waiting th' cs') |
2107 case (waiting th' cs') |
2107 from waiting_kept[OF this(3)] |
2108 from waiting_kept[OF this(3)] |
2108 show ?thesis using waiting(1,2) |
2109 show ?thesis using waiting(1,2) |
2109 by (unfold s_RAG_def, fold waiting_eq, auto) |
2110 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
2110 next |
2111 next |
2111 case (holding th' cs') |
2112 case (holding th' cs') |
2112 from holding_kept[OF this(3)] |
2113 from holding_kept[OF this(3)] |
2113 show ?thesis using holding(1,2) |
2114 show ?thesis using holding(1,2) |
2114 by (unfold s_RAG_def, fold holding_eq, auto) |
2115 by (unfold s_RAG_def, fold s_holding_abv, auto) |
2115 qed |
2116 qed |
2116 next |
2117 next |
2117 assume "n1 = Cs cs \<and> n2 = Th th" |
2118 assume "n1 = Cs cs \<and> n2 = Th th" |
2118 with holding_es_th_cs |
2119 with holding_es_th_cs |
2119 show ?thesis |
2120 show ?thesis |
2120 by (unfold s_RAG_def, fold holding_eq, auto) |
2121 by (unfold s_RAG_def, fold s_holding_abv, auto) |
2121 qed |
2122 qed |
2122 qed |
2123 qed |
2123 |
2124 |
2124 end |
2125 end |
2125 |
2126 |
2131 |
2132 |
2132 lemma wq_es_cs': "wq (e#s) cs = holder#waiters@[th]" |
2133 lemma wq_es_cs': "wq (e#s) cs = holder#waiters@[th]" |
2133 by (simp add: wq_es_cs wq_s_cs) |
2134 by (simp add: wq_es_cs wq_s_cs) |
2134 |
2135 |
2135 lemma waiting_es_th_cs: "waiting (e#s) th cs" |
2136 lemma waiting_es_th_cs: "waiting (e#s) th cs" |
2136 using th_not_in_wq waiting_eq wq_es_cs' wq_s_cs |
2137 using th_not_in_wq s_waiting_abv wq_es_cs' wq_s_cs |
2137 by (simp add: s_waiting_def wq_def wq_es_cs) |
2138 using Un_iff list.sel(1) list.set_intros(1) s_waiting_def |
|
2139 set_append wq_def wq_es_cs by auto |
2138 |
2140 |
2139 lemma RAG_edge: "(Th th, Cs cs) \<in> RAG (e#s)" |
2141 lemma RAG_edge: "(Th th, Cs cs) \<in> RAG (e#s)" |
2140 by (unfold s_RAG_def, fold waiting_eq, insert waiting_es_th_cs, auto) |
2142 by (unfold s_RAG_def, fold s_waiting_abv, insert waiting_es_th_cs, auto) |
2141 |
2143 |
2142 lemma holding_esE: |
2144 lemma holding_esE: |
2143 assumes "holding (e#s) th' cs'" |
2145 assumes "holding (e#s) th' cs'" |
2144 obtains "holding s th' cs'" |
2146 obtains "holding s th' cs'" |
2145 using assms |
2147 using assms |
2185 from this(3) |
2187 from this(3) |
2186 show ?thesis |
2188 show ?thesis |
2187 proof(cases rule:waiting_esE) |
2189 proof(cases rule:waiting_esE) |
2188 case 1 |
2190 case 1 |
2189 thus ?thesis using waiting(1,2) |
2191 thus ?thesis using waiting(1,2) |
2190 by (unfold s_RAG_def, fold waiting_eq, auto) |
2192 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
2191 next |
2193 next |
2192 case 2 |
2194 case 2 |
2193 thus ?thesis using waiting(1,2) by auto |
2195 thus ?thesis using waiting(1,2) by auto |
2194 qed |
2196 qed |
2195 next |
2197 next |
2212 thus ?thesis |
2214 thus ?thesis |
2213 proof(cases rule:in_RAG_E) |
2215 proof(cases rule:in_RAG_E) |
2214 case (waiting th' cs') |
2216 case (waiting th' cs') |
2215 from waiting_kept[OF this(3)] |
2217 from waiting_kept[OF this(3)] |
2216 show ?thesis using waiting(1,2) |
2218 show ?thesis using waiting(1,2) |
2217 by (unfold s_RAG_def, fold waiting_eq, auto) |
2219 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
2218 next |
2220 next |
2219 case (holding th' cs') |
2221 case (holding th' cs') |
2220 from holding_kept[OF this(3)] |
2222 from holding_kept[OF this(3)] |
2221 show ?thesis using holding(1,2) |
2223 show ?thesis using holding(1,2) |
2222 by (unfold s_RAG_def, fold holding_eq, auto) |
2224 by (unfold s_RAG_def, fold s_holding_abv, auto) |
2223 qed |
2225 qed |
2224 next |
2226 next |
2225 assume "n1 = Th th \<and> n2 = Cs cs" |
2227 assume "n1 = Th th \<and> n2 = Cs cs" |
2226 thus ?thesis using RAG_edge by auto |
2228 thus ?thesis using RAG_edge by auto |
2227 qed |
2229 qed |
2618 from tranclD[OF this] |
2620 from tranclD[OF this] |
2619 obtain cs' where h: "(Th taker, Cs cs') \<in> ?A" |
2621 obtain cs' where h: "(Th taker, Cs cs') \<in> ?A" |
2620 "(Th taker, Cs cs') \<in> RAG s" |
2622 "(Th taker, Cs cs') \<in> RAG s" |
2621 by (unfold s_RAG_def, auto) |
2623 by (unfold s_RAG_def, auto) |
2622 from this(2) have "waiting s taker cs'" |
2624 from this(2) have "waiting s taker cs'" |
2623 by (unfold s_RAG_def, fold waiting_eq, auto) |
2625 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
2624 from waiting_unique[OF this waiting_taker] |
2626 from waiting_unique[OF this waiting_taker] |
2625 have "cs' = cs" . |
2627 have "cs' = cs" . |
2626 from h(1)[unfolded this] show False by auto |
2628 from h(1)[unfolded this] show False by auto |
2627 qed |
2629 qed |
2628 ultimately show ?thesis by auto |
2630 ultimately show ?thesis by auto |
2653 by (unfold rtrancl_eq_or_trancl, auto) |
2655 by (unfold rtrancl_eq_or_trancl, auto) |
2654 from tranclD[OF this] |
2656 from tranclD[OF this] |
2655 obtain cs' where h: "(Th th, Cs cs') \<in> RAG s" |
2657 obtain cs' where h: "(Th th, Cs cs') \<in> RAG s" |
2656 by (unfold s_RAG_def, auto) |
2658 by (unfold s_RAG_def, auto) |
2657 hence "waiting s th cs'" |
2659 hence "waiting s th cs'" |
2658 by (unfold s_RAG_def, fold waiting_eq, auto) |
2660 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
2659 with th_not_waiting show False by auto |
2661 with th_not_waiting show False by auto |
2660 qed |
2662 qed |
2661 ultimately show ?thesis by auto |
2663 ultimately show ?thesis by auto |
2662 qed |
2664 qed |
2663 thus ?thesis by (unfold RAG_es, simp) |
2665 thus ?thesis by (unfold RAG_es, simp) |
2782 |
2784 |
2783 context valid_trace |
2785 context valid_trace |
2784 begin |
2786 begin |
2785 |
2787 |
2786 lemma unique_RAG: "\<lbrakk>(n, n1) \<in> RAG s; (n, n2) \<in> RAG s\<rbrakk> \<Longrightarrow> n1 = n2" |
2788 lemma unique_RAG: "\<lbrakk>(n, n1) \<in> RAG s; (n, n2) \<in> RAG s\<rbrakk> \<Longrightarrow> n1 = n2" |
2787 apply(unfold s_RAG_def, auto, fold waiting_eq holding_eq) |
2789 apply(unfold s_RAG_def, auto, fold s_waiting_abv s_holding_abv) |
2788 by(auto elim:waiting_unique held_unique) |
2790 by(auto elim:waiting_unique held_unique) |
2789 |
2791 |
2790 lemma sgv_RAG: "single_valued (RAG s)" |
2792 lemma sgv_RAG: "single_valued (RAG s)" |
2791 using unique_RAG by (auto simp:single_valued_def) |
2793 using unique_RAG by (auto simp:single_valued_def) |
2792 |
2794 |
2960 have "(node, b) \<in> ((RAG s)\<^sup>+)" by auto |
2962 have "(node, b) \<in> ((RAG s)\<^sup>+)" by auto |
2961 from tranclE[OF this] |
2963 from tranclE[OF this] |
2962 obtain n where "(n, b) \<in> RAG s" by auto |
2964 obtain n where "(n, b) \<in> RAG s" by auto |
2963 from this[unfolded Cs] |
2965 from this[unfolded Cs] |
2964 obtain th1 where "waiting s th1 cs" |
2966 obtain th1 where "waiting s th1 cs" |
2965 by (unfold s_RAG_def, fold waiting_eq, auto) |
2967 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
2966 from waiting_holding[OF this] |
2968 from waiting_holding[OF this] |
2967 obtain th2 where "holding s th2 cs" . |
2969 obtain th2 where "holding s th2 cs" . |
2968 hence "(Cs cs, Th th2) \<in> RAG s" |
2970 hence "(Cs cs, Th th2) \<in> RAG s" |
2969 by (unfold s_RAG_def, fold holding_eq, auto) |
2971 by (unfold s_RAG_def, fold s_holding_abv, auto) |
2970 with h_b(2)[unfolded Cs, rule_format] |
2972 with h_b(2)[unfolded Cs, rule_format] |
2971 have False by auto |
2973 have False by auto |
2972 thus ?thesis by auto |
2974 thus ?thesis by auto |
2973 qed auto |
2975 qed auto |
2974 have "th' \<in> readys s" |
2976 have "th' \<in> readys s" |
2975 proof - |
2977 proof - |
2976 from h_b(2)[unfolded eq_b] |
2978 from h_b(2)[unfolded eq_b] |
2977 have "\<forall>cs. \<not> waiting s th' cs" |
2979 have "\<forall>cs. \<not> waiting s th' cs" |
2978 by (unfold s_RAG_def, fold waiting_eq, auto) |
2980 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
2979 moreover have "th' \<in> threads s" |
2981 moreover have "th' \<in> threads s" |
2980 proof(rule rg_RAG_threads) |
2982 proof(rule rg_RAG_threads) |
2981 from tranclD[OF h_b(1), unfolded eq_b] |
2983 from tranclD[OF h_b(1), unfolded eq_b] |
2982 obtain z where "(z, Th th') \<in> (RAG s)" by auto |
2984 obtain z where "(z, Th th') \<in> (RAG s)" by auto |
2983 thus "Th th' \<in> Range (RAG s)" by auto |
2985 thus "Th th' \<in> Range (RAG s)" by auto |
3121 assume otherwise: "xs' \<noteq> []" |
3123 assume otherwise: "xs' \<noteq> []" |
3122 from rpath_plus[OF less_1(3) this] |
3124 from rpath_plus[OF less_1(3) this] |
3123 have "(Th th1, Th th2) \<in> (RAG s)\<^sup>+" . |
3125 have "(Th th1, Th th2) \<in> (RAG s)\<^sup>+" . |
3124 from tranclD[OF this] |
3126 from tranclD[OF this] |
3125 obtain cs where "waiting s th1 cs" |
3127 obtain cs where "waiting s th1 cs" |
3126 by (unfold s_RAG_def, fold waiting_eq, auto) |
3128 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
3127 with running_1 show False |
3129 with running_1 show False |
3128 by (unfold running_def readys_def, auto) |
3130 by (unfold running_def readys_def, auto) |
3129 qed |
3131 qed |
3130 ultimately have "xs2 = xs1" by simp |
3132 ultimately have "xs2 = xs1" by simp |
3131 from rpath_dest_eq[OF rp1 rp2[unfolded this]] |
3133 from rpath_dest_eq[OF rp1 rp2[unfolded this]] |
3137 assume otherwise: "xs' \<noteq> []" |
3139 assume otherwise: "xs' \<noteq> []" |
3138 from rpath_plus[OF less_2(3) this] |
3140 from rpath_plus[OF less_2(3) this] |
3139 have "(Th th2, Th th1) \<in> (RAG s)\<^sup>+" . |
3141 have "(Th th2, Th th1) \<in> (RAG s)\<^sup>+" . |
3140 from tranclD[OF this] |
3142 from tranclD[OF this] |
3141 obtain cs where "waiting s th2 cs" |
3143 obtain cs where "waiting s th2 cs" |
3142 by (unfold s_RAG_def, fold waiting_eq, auto) |
3144 by (unfold s_RAG_def, fold s_waiting_abv, auto) |
3143 with running_2 show False |
3145 with running_2 show False |
3144 by (unfold running_def readys_def, auto) |
3146 by (unfold running_def readys_def, auto) |
3145 qed |
3147 qed |
3146 ultimately have "xs2 = xs1" by simp |
3148 ultimately have "xs2 = xs1" by simp |
3147 from rpath_dest_eq[OF rp1 rp2[unfolded this]] |
3149 from rpath_dest_eq[OF rp1 rp2[unfolded this]] |
3230 hence "(Th th1, Th th2) \<in> (RAG s)^+" by (auto simp:ancestors_def) |
3232 hence "(Th th1, Th th2) \<in> (RAG s)^+" by (auto simp:ancestors_def) |
3231 from tranclD[OF this] |
3233 from tranclD[OF this] |
3232 obtain z where "(Th th1, z) \<in> RAG s" by auto |
3234 obtain z where "(Th th1, z) \<in> RAG s" by auto |
3233 from this[unfolded s_RAG_def, folded wq_def] |
3235 from this[unfolded s_RAG_def, folded wq_def] |
3234 obtain cs' where "waiting s th1 cs'" |
3236 obtain cs' where "waiting s th1 cs'" |
3235 by (auto simp:waiting_eq) |
3237 by (auto simp:s_waiting_abv) |
3236 with assms(1) show False by (auto simp:readys_def) |
3238 with assms(1) show False by (auto simp:readys_def) |
3237 qed |
3239 qed |
3238 next |
3240 next |
3239 case (less_2 xs3) |
3241 case (less_2 xs3) |
3240 from rpath_star[OF this(3)] |
3242 from rpath_star[OF this(3)] |
3249 hence "(Th th2, Th th1) \<in> (RAG s)^+" by (auto simp:ancestors_def) |
3251 hence "(Th th2, Th th1) \<in> (RAG s)^+" by (auto simp:ancestors_def) |
3250 from tranclD[OF this] |
3252 from tranclD[OF this] |
3251 obtain z where "(Th th2, z) \<in> RAG s" by auto |
3253 obtain z where "(Th th2, z) \<in> RAG s" by auto |
3252 from this[unfolded s_RAG_def, folded wq_def] |
3254 from this[unfolded s_RAG_def, folded wq_def] |
3253 obtain cs' where "waiting s th2 cs'" |
3255 obtain cs' where "waiting s th2 cs'" |
3254 by (auto simp:waiting_eq) |
3256 by (auto simp:s_waiting_abv) |
3255 with assms(2) show False by (auto simp:readys_def) |
3257 with assms(2) show False by (auto simp:readys_def) |
3256 qed |
3258 qed |
3257 qed |
3259 qed |
3258 } thus ?thesis by auto |
3260 } thus ?thesis by auto |
3259 qed |
3261 qed |
3423 |
3425 |
3424 context valid_trace_p_w |
3426 context valid_trace_p_w |
3425 begin |
3427 begin |
3426 |
3428 |
3427 lemma holding_s_holder: "holding s holder cs" |
3429 lemma holding_s_holder: "holding s holder cs" |
3428 by (unfold s_holding_def, fold wq_def, unfold wq_s_cs, auto) |
3430 by (unfold s_holding_def, unfold wq_s_cs, auto) |
3429 |
3431 |
3430 lemma holding_es_holder: "holding (e#s) holder cs" |
3432 lemma holding_es_holder: "holding (e#s) holder cs" |
3431 by (unfold s_holding_def, fold wq_def, unfold wq_es_cs wq_s_cs, auto) |
3433 by (unfold s_holding_def, unfold wq_es_cs wq_s_cs, auto) |
3432 |
3434 |
3433 lemma holdents_es: |
3435 lemma holdents_es: |
3434 shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") |
3436 shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") |
3435 proof - |
3437 proof - |
3436 { fix cs' |
3438 { fix cs' |
3446 next |
3448 next |
3447 case False |
3449 case False |
3448 hence "wq (e#s) cs' = wq s cs'" by simp |
3450 hence "wq (e#s) cs' = wq s cs'" by simp |
3449 from h[unfolded s_holding_def, folded wq_def, unfolded this] |
3451 from h[unfolded s_holding_def, folded wq_def, unfolded this] |
3450 show ?thesis |
3452 show ?thesis |
3451 by (unfold s_holding_def, fold wq_def, auto) |
3453 by (unfold s_holding_def, auto) |
3452 qed |
3454 qed |
3453 hence "cs' \<in> ?R" by (auto simp:holdents_def) |
3455 hence "cs' \<in> ?R" by (auto simp:holdents_def) |
3454 } moreover { |
3456 } moreover { |
3455 fix cs' |
3457 fix cs' |
3456 assume "cs' \<in> ?R" |
3458 assume "cs' \<in> ?R" |
3465 next |
3467 next |
3466 case False |
3468 case False |
3467 hence "wq s cs' = wq (e#s) cs'" by simp |
3469 hence "wq s cs' = wq (e#s) cs'" by simp |
3468 from h[unfolded s_holding_def, folded wq_def, unfolded this] |
3470 from h[unfolded s_holding_def, folded wq_def, unfolded this] |
3469 show ?thesis |
3471 show ?thesis |
3470 by (unfold s_holding_def, fold wq_def, auto) |
3472 by (unfold s_holding_def, auto) |
3471 qed |
3473 qed |
3472 hence "cs' \<in> ?L" by (auto simp:holdents_def) |
3474 hence "cs' \<in> ?L" by (auto simp:holdents_def) |
3473 } ultimately show ?thesis by auto |
3475 } ultimately show ?thesis by auto |
3474 qed |
3476 qed |
3475 |
3477 |
3596 with assms show False by simp |
3598 with assms show False by simp |
3597 qed |
3599 qed |
3598 from h_e[unfolded s_holding_def, folded wq_def, unfolded wq_neq_simp[OF this]] |
3600 from h_e[unfolded s_holding_def, folded wq_def, unfolded wq_neq_simp[OF this]] |
3599 have "th' \<in> set (wq s cs') \<and> th' = hd (wq s cs')" . |
3601 have "th' \<in> set (wq s cs') \<and> th' = hd (wq s cs')" . |
3600 hence "cs' \<in> ?R" |
3602 hence "cs' \<in> ?R" |
3601 by (unfold holdents_def s_holding_def, fold wq_def, auto) |
3603 by (unfold holdents_def s_holding_def, auto) |
3602 } moreover { |
3604 } moreover { |
3603 fix cs' |
3605 fix cs' |
3604 assume "cs' \<in> ?R" |
3606 assume "cs' \<in> ?R" |
3605 hence "holding s th' cs'" by (auto simp:holdents_def) |
3607 hence "holding s th' cs'" by (auto simp:holdents_def) |
3606 from holding_kept[OF this] |
3608 from holding_kept[OF this] |
3736 context valid_trace_v |
3738 context valid_trace_v |
3737 begin |
3739 begin |
3738 |
3740 |
3739 lemma holding_th_cs_s: |
3741 lemma holding_th_cs_s: |
3740 "holding s th cs" |
3742 "holding s th cs" |
3741 by (unfold s_holding_def, fold wq_def, unfold wq_s_cs, auto) |
3743 by (unfold s_holding_def, unfold wq_s_cs, auto) |
3742 |
3744 |
3743 lemma th_ready_s [simp]: "th \<in> readys s" |
3745 lemma th_ready_s [simp]: "th \<in> readys s" |
3744 using running_th_s |
3746 using running_th_s |
3745 by (unfold running_def readys_def, auto) |
3747 by (unfold running_def readys_def, auto) |
3746 |
3748 |
3929 case False |
3931 case False |
3930 hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp |
3932 hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp |
3931 from h have "holding (e#s) th' cs'" by (auto simp:holdents_def) |
3933 from h have "holding (e#s) th' cs'" by (auto simp:holdents_def) |
3932 from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq] |
3934 from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq] |
3933 show ?thesis |
3935 show ?thesis |
3934 by (unfold holdents_def s_holding_def, fold wq_def, auto) |
3936 by (unfold holdents_def s_holding_def, auto) |
3935 next |
3937 next |
3936 case True |
3938 case True |
3937 from h[unfolded this] |
3939 from h[unfolded this] |
3938 have "holding (e#s) th' cs" by (auto simp:holdents_def) |
3940 have "holding (e#s) th' cs" by (auto simp:holdents_def) |
3939 from held_unique[OF this holding_taker] |
3941 from held_unique[OF this holding_taker] |
3948 case False |
3950 case False |
3949 hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp |
3951 hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp |
3950 from h have "holding s th' cs'" by (auto simp:holdents_def) |
3952 from h have "holding s th' cs'" by (auto simp:holdents_def) |
3951 from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq] |
3953 from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq] |
3952 show ?thesis |
3954 show ?thesis |
3953 by (unfold holdents_def s_holding_def, fold wq_def, insert eq_wq, simp) |
3955 by (unfold holdents_def s_holding_def, insert eq_wq, simp) |
3954 next |
3956 next |
3955 case True |
3957 case True |
3956 from h[unfolded this] |
3958 from h[unfolded this] |
3957 have "holding s th' cs" by (auto simp:holdents_def) |
3959 have "holding s th' cs" by (auto simp:holdents_def) |
3958 from held_unique[OF this holding_th_cs_s] |
3960 from held_unique[OF this holding_th_cs_s] |
4105 case False |
4107 case False |
4106 hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp |
4108 hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp |
4107 from h have "holding (e#s) th' cs'" by (auto simp:holdents_def) |
4109 from h have "holding (e#s) th' cs'" by (auto simp:holdents_def) |
4108 from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq] |
4110 from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq] |
4109 show ?thesis |
4111 show ?thesis |
4110 by (unfold holdents_def s_holding_def, fold wq_def, auto) |
4112 by (unfold holdents_def s_holding_def, auto) |
4111 next |
4113 next |
4112 case True |
4114 case True |
4113 from h[unfolded this] |
4115 from h[unfolded this] |
4114 have "holding (e#s) th' cs" by (auto simp:holdents_def) |
4116 have "holding (e#s) th' cs" by (auto simp:holdents_def) |
4115 from this[unfolded s_holding_def, folded wq_def, |
4117 from this[unfolded s_holding_def, folded wq_def, |
4124 case False |
4126 case False |
4125 hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp |
4127 hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp |
4126 from h have "holding s th' cs'" by (auto simp:holdents_def) |
4128 from h have "holding s th' cs'" by (auto simp:holdents_def) |
4127 from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq] |
4129 from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq] |
4128 show ?thesis |
4130 show ?thesis |
4129 by (unfold holdents_def s_holding_def, fold wq_def, insert eq_wq, simp) |
4131 by (unfold holdents_def s_holding_def, insert eq_wq, simp) |
4130 next |
4132 next |
4131 case True |
4133 case True |
4132 from h[unfolded this] |
4134 from h[unfolded this] |
4133 have "holding s th' cs" by (auto simp:holdents_def) |
4135 have "holding s th' cs" by (auto simp:holdents_def) |
4134 from held_unique[OF this holding_th_cs_s] |
4136 from held_unique[OF this holding_th_cs_s] |
4313 shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") |
4315 shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") |
4314 proof - |
4316 proof - |
4315 { fix cs' |
4317 { fix cs' |
4316 assume h: "cs' \<in> ?L" |
4318 assume h: "cs' \<in> ?L" |
4317 hence "cs' \<in> ?R" |
4319 hence "cs' \<in> ?R" |
4318 by (unfold holdents_def s_holding_def, fold wq_def, |
4320 by (unfold holdents_def s_holding_def, unfold wq_kept, auto) |
4319 unfold wq_kept, auto) |
|
4320 } moreover { |
4321 } moreover { |
4321 fix cs' |
4322 fix cs' |
4322 assume h: "cs' \<in> ?R" |
4323 assume h: "cs' \<in> ?R" |
4323 hence "cs' \<in> ?L" |
4324 hence "cs' \<in> ?L" |
4324 by (unfold holdents_def s_holding_def, fold wq_def, |
4325 by (unfold holdents_def s_holding_def, unfold wq_kept, auto) |
4325 unfold wq_kept, auto) |
|
4326 } ultimately show ?thesis by auto |
4326 } ultimately show ?thesis by auto |
4327 qed |
4327 qed |
4328 |
4328 |
4329 lemma cntCS_kept [simp]: |
4329 lemma cntCS_kept [simp]: |
4330 assumes "th' \<noteq> th" |
4330 assumes "th' \<noteq> th" |
4430 lemma not_holding_th_es [simp]: "\<not> holding (e#s) th cs'" |
4430 lemma not_holding_th_es [simp]: "\<not> holding (e#s) th cs'" |
4431 proof |
4431 proof |
4432 assume "holding (e # s) th cs'" |
4432 assume "holding (e # s) th cs'" |
4433 from this[unfolded s_holding_def, folded wq_def, unfolded wq_kept] |
4433 from this[unfolded s_holding_def, folded wq_def, unfolded wq_kept] |
4434 have "holding s th cs'" |
4434 have "holding s th cs'" |
4435 by (unfold s_holding_def, fold wq_def, auto) |
4435 by (unfold s_holding_def, auto) |
4436 with not_holding_th_s |
4436 with not_holding_th_s |
4437 show False by simp |
4437 show False by simp |
4438 qed |
4438 qed |
4439 |
4439 |
4440 lemma ready_th_es [simp]: "th \<notin> readys (e#s)" |
4440 lemma ready_th_es [simp]: "th \<notin> readys (e#s)" |
4460 shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") |
4460 shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") |
4461 proof - |
4461 proof - |
4462 { fix cs' |
4462 { fix cs' |
4463 assume h: "cs' \<in> ?L" |
4463 assume h: "cs' \<in> ?L" |
4464 hence "cs' \<in> ?R" |
4464 hence "cs' \<in> ?R" |
4465 by (unfold holdents_def s_holding_def, fold wq_def, |
4465 by (unfold holdents_def s_holding_def, unfold wq_kept, auto) |
4466 unfold wq_kept, auto) |
|
4467 } moreover { |
4466 } moreover { |
4468 fix cs' |
4467 fix cs' |
4469 assume h: "cs' \<in> ?R" |
4468 assume h: "cs' \<in> ?R" |
4470 hence "cs' \<in> ?L" |
4469 hence "cs' \<in> ?L" |
4471 by (unfold holdents_def s_holding_def, fold wq_def, |
4470 by (unfold holdents_def s_holding_def, unfold wq_kept, auto) |
4472 unfold wq_kept, auto) |
|
4473 } ultimately show ?thesis by auto |
4471 } ultimately show ?thesis by auto |
4474 qed |
4472 qed |
4475 |
4473 |
4476 lemma cntCS_kept [simp]: |
4474 lemma cntCS_kept [simp]: |
4477 assumes "th' \<noteq> th" |
4475 assumes "th' \<noteq> th" |
4565 shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") |
4563 shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") |
4566 proof - |
4564 proof - |
4567 { fix cs' |
4565 { fix cs' |
4568 assume h: "cs' \<in> ?L" |
4566 assume h: "cs' \<in> ?L" |
4569 hence "cs' \<in> ?R" |
4567 hence "cs' \<in> ?R" |
4570 by (unfold holdents_def s_holding_def, fold wq_def, |
4568 by (unfold holdents_def s_holding_def, unfold wq_kept, auto) |
4571 unfold wq_kept, auto) |
|
4572 } moreover { |
4569 } moreover { |
4573 fix cs' |
4570 fix cs' |
4574 assume h: "cs' \<in> ?R" |
4571 assume h: "cs' \<in> ?R" |
4575 hence "cs' \<in> ?L" |
4572 hence "cs' \<in> ?L" |
4576 by (unfold holdents_def s_holding_def, fold wq_def, |
4573 by (unfold holdents_def s_holding_def, unfold wq_kept, auto) |
4577 unfold wq_kept, auto) |
|
4578 } ultimately show ?thesis by auto |
4574 } ultimately show ?thesis by auto |
4579 qed |
4575 qed |
4580 |
4576 |
4581 lemma cntCS_kept [simp]: |
4577 lemma cntCS_kept [simp]: |
4582 shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R") |
4578 shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R") |
4637 |
4633 |
4638 lemma cnp_cnv_cncs: "cntP s th' = cntV s th' + cntCS s th' + pvD s th'" |
4634 lemma cnp_cnv_cncs: "cntP s th' = cntV s th' + cntCS s th' + pvD s th'" |
4639 proof(induct rule:ind) |
4635 proof(induct rule:ind) |
4640 case Nil |
4636 case Nil |
4641 thus ?case |
4637 thus ?case |
4642 by (unfold cntP_def cntV_def pvD_def cntCS_def holdents_def |
4638 unfolding cntP_def cntV_def pvD_def cntCS_def holdents_def s_holding_def |
4643 s_holding_def, simp) |
4639 by(simp add: wq_def) |
4644 next |
4640 next |
4645 case (Cons s e) |
4641 case (Cons s e) |
4646 interpret vt_e: valid_trace_e s e using Cons by simp |
4642 interpret vt_e: valid_trace_e s e using Cons by simp |
4647 show ?case |
4643 show ?case |
4648 proof(cases e) |
4644 proof(cases e) |
4770 qed |
4766 qed |
4771 |
4767 |
4772 lemma count_eq_tRAG_plus: |
4768 lemma count_eq_tRAG_plus: |
4773 assumes "cntP s th = cntV s th" |
4769 assumes "cntP s th = cntV s th" |
4774 shows "{th'. (Th th', Th th) \<in> (tRAG s)^+} = {}" |
4770 shows "{th'. (Th th', Th th) \<in> (tRAG s)^+} = {}" |
4775 using assms eq_pv_dependants dependants_alt_def eq_dependants by auto |
4771 using assms count_eq_RAG_plus dependants_alt_def s_dependants_def by blast |
4776 |
4772 |
4777 lemma count_eq_tRAG_plus_Th: |
4773 lemma count_eq_tRAG_plus_Th: |
4778 assumes "cntP s th = cntV s th" |
4774 assumes "cntP s th = cntV s th" |
4779 shows "{Th th' | th'. (Th th', Th th) \<in> (tRAG s)^+} = {}" |
4775 shows "{Th th' | th'. (Th th', Th th) \<in> (tRAG s)^+} = {}" |
4780 using count_eq_tRAG_plus[OF assms] by auto |
4776 using count_eq_tRAG_plus[OF assms] by auto |
4878 proof(cases "th \<in> threads s") |
4874 proof(cases "th \<in> threads s") |
4879 case True |
4875 case True |
4880 with dtc |
4876 with dtc |
4881 have "th \<in> readys s" |
4877 have "th \<in> readys s" |
4882 by (unfold readys_def detached_def Field_def Domain_def Range_def, |
4878 by (unfold readys_def detached_def Field_def Domain_def Range_def, |
4883 auto simp:waiting_eq s_RAG_def) |
4879 auto simp:s_waiting_abv s_RAG_def) |
4884 with cncs_z show ?thesis using cnp_cnv_cncs by (simp add:pvD_def) |
4880 with cncs_z show ?thesis using cnp_cnv_cncs by (simp add:pvD_def) |
4885 next |
4881 next |
4886 case False |
4882 case False |
4887 with cncs_z and cnp_cnv_cncs show ?thesis by (simp add:pvD_def) |
4883 with cncs_z and cnp_cnv_cncs show ?thesis by (simp add:pvD_def) |
4888 qed |
4884 qed |