8 From Charpentier and Chandy, |
8 From Charpentier and Chandy, |
9 Examples of Program Composition Illustrating the Use of Universal Properties |
9 Examples of Program Composition Illustrating the Use of Universal Properties |
10 In J. Rolim (editor), Parallel and Distributed Processing, |
10 In J. Rolim (editor), Parallel and Distributed Processing, |
11 Spriner LNCS 1586 (1999), pages 1215-1227. |
11 Spriner LNCS 1586 (1999), pages 1215-1227. |
12 *) |
12 *) |
|
13 |
|
14 header{*A Family of Similar Counters: Version with Compatibility*} |
13 |
15 |
14 theory Counterc = UNITY_Main: |
16 theory Counterc = UNITY_Main: |
15 |
17 |
16 typedecl state |
18 typedecl state |
17 arities state :: type |
19 arities state :: type |
60 lemma sum_ext [rule_format]: |
62 lemma sum_ext [rule_format]: |
61 "(\<forall>i. i<I --> c s' i = c s i) --> (sum I s' = sum I s)" |
63 "(\<forall>i. i<I --> c s' i = c s i) --> (sum I s' = sum I s)" |
62 by (induct_tac "I", auto) |
64 by (induct_tac "I", auto) |
63 |
65 |
64 lemma sumj_ext [rule_format]: |
66 lemma sumj_ext [rule_format]: |
65 "(\<forall>j. j<I & j~=i --> c s' j = c s j) --> (sumj I i s' = sumj I i s)" |
67 "(\<forall>j. j<I & j\<noteq>i --> c s' j = c s j) --> (sumj I i s' = sumj I i s)" |
66 apply (induct_tac "I", safe) |
68 apply (induct_tac "I", safe) |
67 apply (auto intro!: sum_ext) |
69 apply (auto intro!: sum_ext) |
68 done |
70 done |
69 |
71 |
70 |
72 |
87 lemma p2: "Component i \<in> stable {s. C s = (c s) i + k}" |
89 lemma p2: "Component i \<in> stable {s. C s = (c s) i + k}" |
88 by (simp add: Component_def, constrains) |
90 by (simp add: Component_def, constrains) |
89 |
91 |
90 lemma p3: |
92 lemma p3: |
91 "[| OK I Component; i\<in>I |] |
93 "[| OK I Component; i\<in>I |] |
92 ==> Component i \<in> stable {s. \<forall>j\<in>I. j~=i --> c s j = c k j}" |
94 ==> Component i \<in> stable {s. \<forall>j\<in>I. j\<noteq>i --> c s j = c k j}" |
93 apply simp |
95 apply simp |
94 apply (unfold Component_def mk_total_program_def) |
96 apply (unfold Component_def mk_total_program_def) |
95 apply (simp (no_asm_use) add: stable_def constrains_def) |
97 apply (simp (no_asm_use) add: stable_def constrains_def) |
96 apply blast |
98 apply blast |
97 done |
99 done |
98 |
100 |
99 |
101 |
100 lemma p2_p3_lemma1: |
102 lemma p2_p3_lemma1: |
101 "[| OK {i. i<I} Component; i<I |] ==> |
103 "[| OK {i. i<I} Component; i<I |] ==> |
102 \<forall>k. Component i \<in> stable ({s. C s = c s i + sumj I i k} Int |
104 \<forall>k. Component i \<in> stable ({s. C s = c s i + sumj I i k} Int |
103 {s. \<forall>j\<in>{i. i<I}. j~=i --> c s j = c k j})" |
105 {s. \<forall>j\<in>{i. i<I}. j\<noteq>i --> c s j = c k j})" |
104 by (blast intro: stable_Int [OF p2 p3]) |
106 by (blast intro: stable_Int [OF p2 p3]) |
105 |
107 |
106 lemma p2_p3_lemma2: |
108 lemma p2_p3_lemma2: |
107 "(\<forall>k. F \<in> stable ({s. C s = (c s) i + sumj I i k} Int |
109 "(\<forall>k. F \<in> stable ({s. C s = (c s) i + sumj I i k} Int |
108 {s. \<forall>j\<in>{i. i<I}. j~=i --> c s j = c k j})) |
110 {s. \<forall>j\<in>{i. i<I}. j\<noteq>i --> c s j = c k j})) |
109 ==> (F \<in> stable {s. C s = c s i + sumj I i s})" |
111 ==> (F \<in> stable {s. C s = c s i + sumj I i s})" |
110 apply (simp add: constrains_def stable_def) |
112 apply (simp add: constrains_def stable_def) |
111 apply (force intro!: sumj_ext) |
113 apply (force intro!: sumj_ext) |
112 done |
114 done |
113 |
115 |
120 |
122 |
121 (* Compositional correctness *) |
123 (* Compositional correctness *) |
122 lemma safety: |
124 lemma safety: |
123 "[| 0<I; OK {i. i<I} Component |] |
125 "[| 0<I; OK {i. i<I} Component |] |
124 ==> (\<Squnion>i\<in>{i. i<I}. (Component i)) \<in> invariant {s. C s = sum I s}" |
126 ==> (\<Squnion>i\<in>{i. i<I}. (Component i)) \<in> invariant {s. C s = sum I s}" |
125 apply (unfold invariant_def) |
127 apply (simp (no_asm) add: invariant_def JN_stable sum_sumj_eq2) |
126 apply (simp (no_asm) add: JN_stable sum_sumj_eq2) |
|
127 apply (auto intro!: sum0 p2_p3) |
128 apply (auto intro!: sum0 p2_p3) |
128 done |
129 done |
129 |
130 |
130 end |
131 end |