equal
deleted
inserted
replaced
3 Copyright 1999 University of Cambridge |
3 Copyright 1999 University of Cambridge |
4 |
4 |
5 lift_prog, etc: replication of components and arrays of processes. |
5 lift_prog, etc: replication of components and arrays of processes. |
6 *) |
6 *) |
7 |
7 |
8 section{*Replication of Components*} |
8 section\<open>Replication of Components\<close> |
9 |
9 |
10 theory Lift_prog imports Rename begin |
10 theory Lift_prog imports Rename begin |
11 |
11 |
12 definition insert_map :: "[nat, 'b, nat=>'b] => (nat=>'b)" where |
12 definition insert_map :: "[nat, 'b, nat=>'b] => (nat=>'b)" where |
13 "insert_map i z f k == if k<i then f k |
13 "insert_map i z f k == if k<i then f k |
42 lemma insert_map_delete_map_eq: "(insert_map i x (delete_map i g)) = g(i:=x)" |
42 lemma insert_map_delete_map_eq: "(insert_map i x (delete_map i g)) = g(i:=x)" |
43 apply (rule ext) |
43 apply (rule ext) |
44 apply (auto split add: nat_diff_split) |
44 apply (auto split add: nat_diff_split) |
45 done |
45 done |
46 |
46 |
47 subsection{*Injectiveness proof*} |
47 subsection\<open>Injectiveness proof\<close> |
48 |
48 |
49 lemma insert_map_inject1: "(insert_map i x f) = (insert_map i y g) ==> x=y" |
49 lemma insert_map_inject1: "(insert_map i x f) = (insert_map i y g) ==> x=y" |
50 by (drule_tac x = i in fun_cong, simp) |
50 by (drule_tac x = i in fun_cong, simp) |
51 |
51 |
52 lemma insert_map_inject2: "(insert_map i x f) = (insert_map i y g) ==> f=g" |
52 lemma insert_map_inject2: "(insert_map i x f) = (insert_map i y g) ==> f=g" |
75 lemma inj_lift_map: "inj (lift_map i)" |
75 lemma inj_lift_map: "inj (lift_map i)" |
76 apply (unfold lift_map_def) |
76 apply (unfold lift_map_def) |
77 apply (rule inj_onI, auto) |
77 apply (rule inj_onI, auto) |
78 done |
78 done |
79 |
79 |
80 subsection{*Surjectiveness proof*} |
80 subsection\<open>Surjectiveness proof\<close> |
81 |
81 |
82 lemma lift_map_drop_map_eq [simp]: "!!s. lift_map i (drop_map i s) = s" |
82 lemma lift_map_drop_map_eq [simp]: "!!s. lift_map i (drop_map i s) = s" |
83 apply (unfold lift_map_def drop_map_def) |
83 apply (unfold lift_map_def drop_map_def) |
84 apply (force simp add: insert_map_delete_map_eq) |
84 apply (force simp add: insert_map_delete_map_eq) |
85 done |
85 done |
119 (if i=j then insert_map i s f |
119 (if i=j then insert_map i s f |
120 else if i<j then insert_map j t (f(i:=s)) |
120 else if i<j then insert_map j t (f(i:=s)) |
121 else insert_map j t (f(i - Suc 0 := s)))" |
121 else insert_map j t (f(i - Suc 0 := s)))" |
122 apply (rule ext) |
122 apply (rule ext) |
123 apply (simp split add: nat_diff_split) |
123 apply (simp split add: nat_diff_split) |
124 txt{*This simplification is VERY slow*} |
124 txt\<open>This simplification is VERY slow\<close> |
125 done |
125 done |
126 |
126 |
127 lemma insert_map_eq_diff: |
127 lemma insert_map_eq_diff: |
128 "[| insert_map i s f = insert_map j t g; i\<noteq>j |] |
128 "[| insert_map i s f = insert_map j t g; i\<noteq>j |] |
129 ==> \<exists>g'. insert_map i s' f = insert_map j t g'" |
129 ==> \<exists>g'. insert_map i s' f = insert_map j t g'" |
138 apply (unfold lift_map_def, auto) |
138 apply (unfold lift_map_def, auto) |
139 apply (blast dest: insert_map_eq_diff) |
139 apply (blast dest: insert_map_eq_diff) |
140 done |
140 done |
141 |
141 |
142 |
142 |
143 subsection{*The Operator @{term lift_set}*} |
143 subsection\<open>The Operator @{term lift_set}\<close> |
144 |
144 |
145 lemma lift_set_empty [simp]: "lift_set i {} = {}" |
145 lemma lift_set_empty [simp]: "lift_set i {} = {}" |
146 by (unfold lift_set_def, auto) |
146 by (unfold lift_set_def, auto) |
147 |
147 |
148 lemma lift_set_iff: "(lift_map i x \<in> lift_set i A) = (x \<in> A)" |
148 lemma lift_set_iff: "(lift_map i x \<in> lift_set i A) = (x \<in> A)" |
168 apply (unfold lift_set_def) |
168 apply (unfold lift_set_def) |
169 apply (rule inj_lift_map [THEN image_set_diff]) |
169 apply (rule inj_lift_map [THEN image_set_diff]) |
170 done |
170 done |
171 |
171 |
172 |
172 |
173 subsection{*The Lattice Operations*} |
173 subsection\<open>The Lattice Operations\<close> |
174 |
174 |
175 lemma bij_lift [iff]: "bij (lift i)" |
175 lemma bij_lift [iff]: "bij (lift i)" |
176 by (simp add: lift_def) |
176 by (simp add: lift_def) |
177 |
177 |
178 lemma lift_SKIP [simp]: "lift i SKIP = SKIP" |
178 lemma lift_SKIP [simp]: "lift i SKIP = SKIP" |
182 by (simp add: lift_def) |
182 by (simp add: lift_def) |
183 |
183 |
184 lemma lift_JN [simp]: "lift j (JOIN I F) = (\<Squnion>i \<in> I. lift j (F i))" |
184 lemma lift_JN [simp]: "lift j (JOIN I F) = (\<Squnion>i \<in> I. lift j (F i))" |
185 by (simp add: lift_def) |
185 by (simp add: lift_def) |
186 |
186 |
187 subsection{*Safety: constrains, stable, invariant*} |
187 subsection\<open>Safety: constrains, stable, invariant\<close> |
188 |
188 |
189 lemma lift_constrains: |
189 lemma lift_constrains: |
190 "(lift i F \<in> (lift_set i A) co (lift_set i B)) = (F \<in> A co B)" |
190 "(lift i F \<in> (lift_set i A) co (lift_set i B)) = (F \<in> A co B)" |
191 by (simp add: lift_def lift_set_def rename_constrains) |
191 by (simp add: lift_def lift_set_def rename_constrains) |
192 |
192 |
208 |
208 |
209 lemma lift_Always: |
209 lemma lift_Always: |
210 "(lift i F \<in> Always (lift_set i A)) = (F \<in> Always A)" |
210 "(lift i F \<in> Always (lift_set i A)) = (F \<in> Always A)" |
211 by (simp add: lift_def lift_set_def rename_Always) |
211 by (simp add: lift_def lift_set_def rename_Always) |
212 |
212 |
213 subsection{*Progress: transient, ensures*} |
213 subsection\<open>Progress: transient, ensures\<close> |
214 |
214 |
215 lemma lift_transient: |
215 lemma lift_transient: |
216 "(lift i F \<in> transient (lift_set i A)) = (F \<in> transient A)" |
216 "(lift i F \<in> transient (lift_set i A)) = (F \<in> transient A)" |
217 by (simp add: lift_def lift_set_def rename_transient) |
217 by (simp add: lift_def lift_set_def rename_transient) |
218 |
218 |
331 apply (auto cong del: if_weak_cong |
331 apply (auto cong del: if_weak_cong |
332 simp add: lift_map_def eq_commute split_def o_def) |
332 simp add: lift_map_def eq_commute split_def o_def) |
333 done |
333 done |
334 |
334 |
335 |
335 |
336 subsection{*Lemmas to Handle Function Composition (o) More Consistently*} |
336 subsection\<open>Lemmas to Handle Function Composition (o) More Consistently\<close> |
337 |
337 |
338 (*Lets us prove one version of a theorem and store others*) |
338 (*Lets us prove one version of a theorem and store others*) |
339 lemma o_equiv_assoc: "f o g = h ==> f' o f o g = f' o h" |
339 lemma o_equiv_assoc: "f o g = h ==> f' o f o g = f' o h" |
340 by (simp add: fun_eq_iff o_def) |
340 by (simp add: fun_eq_iff o_def) |
341 |
341 |
351 apply (rule ext) |
351 apply (rule ext) |
352 apply (auto simp add: o_def lift_map_def) |
352 apply (auto simp add: o_def lift_map_def) |
353 done |
353 done |
354 |
354 |
355 |
355 |
356 subsection{*More lemmas about extend and project*} |
356 subsection\<open>More lemmas about extend and project\<close> |
357 |
357 |
358 text{*They could be moved to theory Extend or Project*} |
358 text\<open>They could be moved to theory Extend or Project\<close> |
359 |
359 |
360 lemma extend_act_extend_act: |
360 lemma extend_act_extend_act: |
361 "extend_act h' (extend_act h act) = |
361 "extend_act h' (extend_act h act) = |
362 extend_act (%(x,(y,y')). h'(h(x,y),y')) act" |
362 extend_act (%(x,(y,y')). h'(h(x,y),y')) act" |
363 apply (auto elim!: rev_bexI simp add: extend_act_def, blast) |
363 apply (auto elim!: rev_bexI simp add: extend_act_def, blast) |
373 {(x,x'). \<exists>s s' y y' z. (s,s') \<in> act & |
373 {(x,x'). \<exists>s s' y y' z. (s,s') \<in> act & |
374 h(x,y) = h'(s,z) & h(x',y') = h'(s',z)}" |
374 h(x,y) = h'(s,z) & h(x',y') = h'(s',z)}" |
375 by (simp add: extend_act_def project_act_def, blast) |
375 by (simp add: extend_act_def project_act_def, blast) |
376 |
376 |
377 |
377 |
378 subsection{*OK and "lift"*} |
378 subsection\<open>OK and "lift"\<close> |
379 |
379 |
380 lemma act_in_UNION_preserves_fst: |
380 lemma act_in_UNION_preserves_fst: |
381 "act \<subseteq> {(x,x'). fst x = fst x'} ==> act \<in> UNION (preserves fst) Acts" |
381 "act \<subseteq> {(x,x'). fst x = fst x'} ==> act \<in> UNION (preserves fst) Acts" |
382 apply (rule_tac a = "mk_program (UNIV,{act},UNIV) " in UN_I) |
382 apply (rule_tac a = "mk_program (UNIV,{act},UNIV) " in UN_I) |
383 apply (auto simp add: preserves_def stable_def constrains_def) |
383 apply (auto simp add: preserves_def stable_def constrains_def) |