src/HOL/UNITY/ELT.thy
 author paulson Sat Feb 08 16:05:33 2003 +0100 (2003-02-08) changeset 13812 91713a1915ee parent 13798 4c1a53627500 child 13819 78f5885b76a9 permissions -rw-r--r--
converting HOL/UNITY to use unconditional fairness
```     1 (*  Title:      HOL/UNITY/ELT
```
```     2     ID:         \$Id\$
```
```     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
```
```     4     Copyright   1999  University of Cambridge
```
```     5
```
```     6 leadsTo strengthened with a specification of the allowable sets transient parts
```
```     7
```
```     8 TRY INSTEAD (to get rid of the {} and to gain strong induction)
```
```     9
```
```    10   elt :: "['a set set, 'a program, 'a set] => ('a set) set"
```
```    11
```
```    12 inductive "elt CC F B"
```
```    13   intros
```
```    14
```
```    15     Weaken:  "A <= B ==> A : elt CC F B"
```
```    16
```
```    17     ETrans:  "[| F : A ensures A';  A-A' : CC;  A' : elt CC F B |]
```
```    18 	      ==> A : elt CC F B"
```
```    19
```
```    20     Union:  "{A. A: S} : Pow (elt CC F B) ==> (Union S) : elt CC F B"
```
```    21
```
```    22   monos Pow_mono
```
```    23 *)
```
```    24
```
```    25 header{*Progress Under Allowable Sets*}
```
```    26
```
```    27 theory ELT = Project:
```
```    28
```
```    29 consts
```
```    30
```
```    31   (*LEADS-TO constant for the inductive definition*)
```
```    32   elt :: "['a set set, 'a program] => ('a set * 'a set) set"
```
```    33
```
```    34
```
```    35 inductive "elt CC F"
```
```    36  intros
```
```    37
```
```    38    Basis:  "[| F : A ensures B;  A-B : (insert {} CC) |] ==> (A,B) : elt CC F"
```
```    39
```
```    40    Trans:  "[| (A,B) : elt CC F;  (B,C) : elt CC F |] ==> (A,C) : elt CC F"
```
```    41
```
```    42    Union:  "ALL A: S. (A,B) : elt CC F ==> (Union S, B) : elt CC F"
```
```    43
```
```    44
```
```    45 constdefs
```
```    46
```
```    47   (*the set of all sets determined by f alone*)
```
```    48   givenBy :: "['a => 'b] => 'a set set"
```
```    49     "givenBy f == range (%B. f-` B)"
```
```    50
```
```    51   (*visible version of the LEADS-TO relation*)
```
```    52   leadsETo :: "['a set, 'a set set, 'a set] => 'a program set"
```
```    53                                         ("(3_/ leadsTo[_]/ _)" [80,0,80] 80)
```
```    54     "leadsETo A CC B == {F. (A,B) : elt CC F}"
```
```    55
```
```    56   LeadsETo :: "['a set, 'a set set, 'a set] => 'a program set"
```
```    57                                         ("(3_/ LeadsTo[_]/ _)" [80,0,80] 80)
```
```    58     "LeadsETo A CC B ==
```
```    59       {F. F : (reachable F Int A) leadsTo[(%C. reachable F Int C) ` CC] B}"
```
```    60
```
```    61
```
```    62 (*** givenBy ***)
```
```    63
```
```    64 lemma givenBy_id [simp]: "givenBy id = UNIV"
```
```    65 by (unfold givenBy_def, auto)
```
```    66
```
```    67 lemma givenBy_eq_all: "(givenBy v) = {A. ALL x:A. ALL y. v x = v y --> y: A}"
```
```    68 apply (unfold givenBy_def, safe)
```
```    69 apply (rule_tac  x = "v ` ?u" in image_eqI, auto)
```
```    70 done
```
```    71
```
```    72 lemma givenByI: "(!!x y. [| x:A;  v x = v y |] ==> y: A) ==> A: givenBy v"
```
```    73 by (subst givenBy_eq_all, blast)
```
```    74
```
```    75 lemma givenByD: "[| A: givenBy v;  x:A;  v x = v y |] ==> y: A"
```
```    76 by (unfold givenBy_def, auto)
```
```    77
```
```    78 lemma empty_mem_givenBy [iff]: "{} : givenBy v"
```
```    79 by (blast intro!: givenByI)
```
```    80
```
```    81 lemma givenBy_imp_eq_Collect: "A: givenBy v ==> EX P. A = {s. P(v s)}"
```
```    82 apply (rule_tac x = "%n. EX s. v s = n & s : A" in exI)
```
```    83 apply (simp (no_asm_use) add: givenBy_eq_all)
```
```    84 apply blast
```
```    85 done
```
```    86
```
```    87 lemma Collect_mem_givenBy: "{s. P(v s)} : givenBy v"
```
```    88 by (unfold givenBy_def, best)
```
```    89
```
```    90 lemma givenBy_eq_Collect: "givenBy v = {A. EX P. A = {s. P(v s)}}"
```
```    91 by (blast intro: Collect_mem_givenBy givenBy_imp_eq_Collect)
```
```    92
```
```    93 (*preserving v preserves properties given by v*)
```
```    94 lemma preserves_givenBy_imp_stable:
```
```    95      "[| F : preserves v;  D : givenBy v |] ==> F : stable D"
```
```    96 by (force simp add: preserves_subset_stable [THEN subsetD] givenBy_eq_Collect)
```
```    97
```
```    98 lemma givenBy_o_subset: "givenBy (w o v) <= givenBy v"
```
```    99 apply (simp (no_asm) add: givenBy_eq_Collect)
```
```   100 apply best
```
```   101 done
```
```   102
```
```   103 lemma givenBy_DiffI:
```
```   104      "[| A : givenBy v;  B : givenBy v |] ==> A-B : givenBy v"
```
```   105 apply (simp (no_asm_use) add: givenBy_eq_Collect)
```
```   106 apply safe
```
```   107 apply (rule_tac x = "%z. ?R z & ~ ?Q z" in exI)
```
```   108 apply (tactic "deepen_tac (set_cs addSIs [equalityI]) 0 1")
```
```   109 done
```
```   110
```
```   111
```
```   112 (** Standard leadsTo rules **)
```
```   113
```
```   114 lemma leadsETo_Basis [intro]:
```
```   115      "[| F: A ensures B;  A-B: insert {} CC |] ==> F : A leadsTo[CC] B"
```
```   116 apply (unfold leadsETo_def)
```
```   117 apply (blast intro: elt.Basis)
```
```   118 done
```
```   119
```
```   120 lemma leadsETo_Trans:
```
```   121      "[| F : A leadsTo[CC] B;  F : B leadsTo[CC] C |] ==> F : A leadsTo[CC] C"
```
```   122 apply (unfold leadsETo_def)
```
```   123 apply (blast intro: elt.Trans)
```
```   124 done
```
```   125
```
```   126
```
```   127 (*Useful with cancellation, disjunction*)
```
```   128 lemma leadsETo_Un_duplicate:
```
```   129      "F : A leadsTo[CC] (A' Un A') ==> F : A leadsTo[CC] A'"
```
```   130 apply (simp add: Un_ac)
```
```   131 done
```
```   132
```
```   133 lemma leadsETo_Un_duplicate2:
```
```   134      "F : A leadsTo[CC] (A' Un C Un C) ==> F : A leadsTo[CC] (A' Un C)"
```
```   135 by (simp add: Un_ac)
```
```   136
```
```   137 (*The Union introduction rule as we should have liked to state it*)
```
```   138 lemma leadsETo_Union:
```
```   139     "(!!A. A : S ==> F : A leadsTo[CC] B) ==> F : (Union S) leadsTo[CC] B"
```
```   140 apply (unfold leadsETo_def)
```
```   141 apply (blast intro: elt.Union)
```
```   142 done
```
```   143
```
```   144 lemma leadsETo_UN:
```
```   145     "(!!i. i : I ==> F : (A i) leadsTo[CC] B)
```
```   146      ==> F : (UN i:I. A i) leadsTo[CC] B"
```
```   147 apply (subst Union_image_eq [symmetric])
```
```   148 apply (blast intro: leadsETo_Union)
```
```   149 done
```
```   150
```
```   151 (*The INDUCTION rule as we should have liked to state it*)
```
```   152 lemma leadsETo_induct:
```
```   153   "[| F : za leadsTo[CC] zb;
```
```   154       !!A B. [| F : A ensures B;  A-B : insert {} CC |] ==> P A B;
```
```   155       !!A B C. [| F : A leadsTo[CC] B; P A B; F : B leadsTo[CC] C; P B C |]
```
```   156                ==> P A C;
```
```   157       !!B S. ALL A:S. F : A leadsTo[CC] B & P A B ==> P (Union S) B
```
```   158    |] ==> P za zb"
```
```   159 apply (unfold leadsETo_def)
```
```   160 apply (drule CollectD)
```
```   161 apply (erule elt.induct, blast+)
```
```   162 done
```
```   163
```
```   164
```
```   165 (** New facts involving leadsETo **)
```
```   166
```
```   167 lemma leadsETo_mono: "CC' <= CC ==> (A leadsTo[CC'] B) <= (A leadsTo[CC] B)"
```
```   168 apply safe
```
```   169 apply (erule leadsETo_induct)
```
```   170 prefer 3 apply (blast intro: leadsETo_Union)
```
```   171 prefer 2 apply (blast intro: leadsETo_Trans)
```
```   172 apply (blast intro: leadsETo_Basis)
```
```   173 done
```
```   174
```
```   175 lemma leadsETo_Trans_Un:
```
```   176      "[| F : A leadsTo[CC] B;  F : B leadsTo[DD] C |]
```
```   177       ==> F : A leadsTo[CC Un DD] C"
```
```   178 by (blast intro: leadsETo_mono [THEN subsetD] leadsETo_Trans)
```
```   179
```
```   180 lemma leadsETo_Union_Int:
```
```   181  "(!!A. A : S ==> F : (A Int C) leadsTo[CC] B)
```
```   182   ==> F : (Union S Int C) leadsTo[CC] B"
```
```   183 apply (unfold leadsETo_def)
```
```   184 apply (simp only: Int_Union_Union)
```
```   185 apply (blast intro: elt.Union)
```
```   186 done
```
```   187
```
```   188 (*Binary union introduction rule*)
```
```   189 lemma leadsETo_Un:
```
```   190      "[| F : A leadsTo[CC] C; F : B leadsTo[CC] C |]
```
```   191       ==> F : (A Un B) leadsTo[CC] C"
```
```   192 apply (subst Un_eq_Union)
```
```   193 apply (blast intro: leadsETo_Union)
```
```   194 done
```
```   195
```
```   196 lemma single_leadsETo_I:
```
```   197      "(!!x. x : A ==> F : {x} leadsTo[CC] B) ==> F : A leadsTo[CC] B"
```
```   198 apply (subst UN_singleton [symmetric], rule leadsETo_UN, blast)
```
```   199 done
```
```   200
```
```   201
```
```   202 lemma subset_imp_leadsETo: "A<=B ==> F : A leadsTo[CC] B"
```
```   203 by (simp add: subset_imp_ensures [THEN leadsETo_Basis] Diff_eq_empty_iff [THEN iffD2])
```
```   204
```
```   205 lemmas empty_leadsETo = empty_subsetI [THEN subset_imp_leadsETo, simp]
```
```   206
```
```   207
```
```   208
```
```   209 (** Weakening laws **)
```
```   210
```
```   211 lemma leadsETo_weaken_R:
```
```   212      "[| F : A leadsTo[CC] A';  A'<=B' |] ==> F : A leadsTo[CC] B'"
```
```   213 apply (blast intro: subset_imp_leadsETo leadsETo_Trans)
```
```   214 done
```
```   215
```
```   216 lemma leadsETo_weaken_L [rule_format]:
```
```   217      "[| F : A leadsTo[CC] A'; B<=A |] ==> F : B leadsTo[CC] A'"
```
```   218 apply (blast intro: leadsETo_Trans subset_imp_leadsETo)
```
```   219 done
```
```   220
```
```   221 (*Distributes over binary unions*)
```
```   222 lemma leadsETo_Un_distrib:
```
```   223      "F : (A Un B) leadsTo[CC] C  =
```
```   224       (F : A leadsTo[CC] C & F : B leadsTo[CC] C)"
```
```   225 apply (blast intro: leadsETo_Un leadsETo_weaken_L)
```
```   226 done
```
```   227
```
```   228 lemma leadsETo_UN_distrib:
```
```   229      "F : (UN i:I. A i) leadsTo[CC] B  =
```
```   230       (ALL i : I. F : (A i) leadsTo[CC] B)"
```
```   231 apply (blast intro: leadsETo_UN leadsETo_weaken_L)
```
```   232 done
```
```   233
```
```   234 lemma leadsETo_Union_distrib:
```
```   235      "F : (Union S) leadsTo[CC] B  =  (ALL A : S. F : A leadsTo[CC] B)"
```
```   236 apply (blast intro: leadsETo_Union leadsETo_weaken_L)
```
```   237 done
```
```   238
```
```   239 lemma leadsETo_weaken:
```
```   240      "[| F : A leadsTo[CC'] A'; B<=A; A'<=B';  CC' <= CC |]
```
```   241       ==> F : B leadsTo[CC] B'"
```
```   242 apply (drule leadsETo_mono [THEN subsetD], assumption)
```
```   243 apply (blast del: subsetCE intro: leadsETo_weaken_R leadsETo_weaken_L leadsETo_Trans)
```
```   244 done
```
```   245
```
```   246 lemma leadsETo_givenBy:
```
```   247      "[| F : A leadsTo[CC] A';  CC <= givenBy v |]
```
```   248       ==> F : A leadsTo[givenBy v] A'"
```
```   249 by (blast intro: empty_mem_givenBy leadsETo_weaken)
```
```   250
```
```   251
```
```   252 (*Set difference*)
```
```   253 lemma leadsETo_Diff:
```
```   254      "[| F : (A-B) leadsTo[CC] C; F : B leadsTo[CC] C |]
```
```   255       ==> F : A leadsTo[CC] C"
```
```   256 by (blast intro: leadsETo_Un leadsETo_weaken)
```
```   257
```
```   258
```
```   259 (*Binary union version*)
```
```   260 lemma leadsETo_Un_Un:
```
```   261      "[| F : A leadsTo[CC] A';  F : B leadsTo[CC] B' |]
```
```   262       ==> F : (A Un B) leadsTo[CC] (A' Un B')"
```
```   263 by (blast intro: leadsETo_Un leadsETo_weaken_R)
```
```   264
```
```   265
```
```   266 (** The cancellation law **)
```
```   267
```
```   268 lemma leadsETo_cancel2:
```
```   269      "[| F : A leadsTo[CC] (A' Un B); F : B leadsTo[CC] B' |]
```
```   270       ==> F : A leadsTo[CC] (A' Un B')"
```
```   271 by (blast intro: leadsETo_Un_Un subset_imp_leadsETo leadsETo_Trans)
```
```   272
```
```   273 lemma leadsETo_cancel1:
```
```   274      "[| F : A leadsTo[CC] (B Un A'); F : B leadsTo[CC] B' |]
```
```   275     ==> F : A leadsTo[CC] (B' Un A')"
```
```   276 apply (simp add: Un_commute)
```
```   277 apply (blast intro!: leadsETo_cancel2)
```
```   278 done
```
```   279
```
```   280 lemma leadsETo_cancel_Diff1:
```
```   281      "[| F : A leadsTo[CC] (B Un A'); F : (B-A') leadsTo[CC] B' |]
```
```   282     ==> F : A leadsTo[CC] (B' Un A')"
```
```   283 apply (rule leadsETo_cancel1)
```
```   284  prefer 2 apply assumption
```
```   285 apply simp_all
```
```   286 done
```
```   287
```
```   288
```
```   289
```
```   290 (** PSP: Progress-Safety-Progress **)
```
```   291
```
```   292 (*Special case of PSP: Misra's "stable conjunction"*)
```
```   293 lemma e_psp_stable:
```
```   294    "[| F : A leadsTo[CC] A';  F : stable B;  ALL C:CC. C Int B : CC |]
```
```   295     ==> F : (A Int B) leadsTo[CC] (A' Int B)"
```
```   296 apply (unfold stable_def)
```
```   297 apply (erule leadsETo_induct)
```
```   298 prefer 3 apply (blast intro: leadsETo_Union_Int)
```
```   299 prefer 2 apply (blast intro: leadsETo_Trans)
```
```   300 apply (rule leadsETo_Basis)
```
```   301 prefer 2 apply (force simp add: Diff_Int_distrib2 [symmetric])
```
```   302 apply (simp add: ensures_def Diff_Int_distrib2 [symmetric] Int_Un_distrib2 [symmetric])
```
```   303 apply (blast intro: transient_strengthen constrains_Int)
```
```   304 done
```
```   305
```
```   306 lemma e_psp_stable2:
```
```   307      "[| F : A leadsTo[CC] A'; F : stable B;  ALL C:CC. C Int B : CC |]
```
```   308       ==> F : (B Int A) leadsTo[CC] (B Int A')"
```
```   309 by (simp (no_asm_simp) add: e_psp_stable Int_ac)
```
```   310
```
```   311 lemma e_psp:
```
```   312      "[| F : A leadsTo[CC] A'; F : B co B';
```
```   313          ALL C:CC. C Int B Int B' : CC |]
```
```   314       ==> F : (A Int B') leadsTo[CC] ((A' Int B) Un (B' - B))"
```
```   315 apply (erule leadsETo_induct)
```
```   316 prefer 3 apply (blast intro: leadsETo_Union_Int)
```
```   317 (*Transitivity case has a delicate argument involving "cancellation"*)
```
```   318 apply (rule_tac  leadsETo_Un_duplicate2)
```
```   319 apply (erule_tac  leadsETo_cancel_Diff1)
```
```   320 prefer 2
```
```   321  apply (simp add: Int_Diff Diff_triv)
```
```   322  apply (blast intro: leadsETo_weaken_L dest: constrains_imp_subset)
```
```   323 (*Basis case*)
```
```   324 apply (rule leadsETo_Basis)
```
```   325 apply (blast intro: psp_ensures)
```
```   326 apply (subgoal_tac "A Int B' - (Ba Int B Un (B' - B)) = (A - Ba) Int B Int B'")
```
```   327 apply auto
```
```   328 done
```
```   329
```
```   330 lemma e_psp2:
```
```   331      "[| F : A leadsTo[CC] A'; F : B co B';
```
```   332          ALL C:CC. C Int B Int B' : CC |]
```
```   333       ==> F : (B' Int A) leadsTo[CC] ((B Int A') Un (B' - B))"
```
```   334 by (simp add: e_psp Int_ac)
```
```   335
```
```   336
```
```   337 (*** Special properties involving the parameter [CC] ***)
```
```   338
```
```   339 (*??IS THIS NEEDED?? or is it just an example of what's provable??*)
```
```   340 lemma gen_leadsETo_imp_Join_leadsETo:
```
```   341      "[| F: (A leadsTo[givenBy v] B);  G : preserves v;
```
```   342          F Join G : stable C |]
```
```   343       ==> F Join G : ((C Int A) leadsTo[(%D. C Int D) ` givenBy v] B)"
```
```   344 apply (erule leadsETo_induct)
```
```   345   prefer 3
```
```   346   apply (subst Int_Union)
```
```   347   apply (blast intro: leadsETo_UN)
```
```   348 prefer 2
```
```   349  apply (blast intro: e_psp_stable2 [THEN leadsETo_weaken_L] leadsETo_Trans)
```
```   350 apply (rule leadsETo_Basis)
```
```   351 apply (auto simp add: Diff_eq_empty_iff [THEN iffD2] Int_Diff ensures_def givenBy_eq_Collect Join_transient)
```
```   352 prefer 3 apply (blast intro: transient_strengthen)
```
```   353 apply (drule_tac  P1 = P in preserves_subset_stable [THEN subsetD])
```
```   354 apply (drule_tac P1 = P in preserves_subset_stable [THEN subsetD])
```
```   355 apply (unfold stable_def)
```
```   356 apply (blast intro: constrains_Int [THEN constrains_weaken])+
```
```   357 done
```
```   358
```
```   359 (**** Relationship with traditional "leadsTo", strong & weak ****)
```
```   360
```
```   361 (** strong **)
```
```   362
```
```   363 lemma leadsETo_subset_leadsTo: "(A leadsTo[CC] B) <= (A leadsTo B)"
```
```   364 apply safe
```
```   365 apply (erule leadsETo_induct)
```
```   366 prefer 3 apply (blast intro: leadsTo_Union)
```
```   367 prefer 2 apply (blast intro: leadsTo_Trans, blast)
```
```   368 done
```
```   369
```
```   370 lemma leadsETo_UNIV_eq_leadsTo: "(A leadsTo[UNIV] B) = (A leadsTo B)"
```
```   371 apply safe
```
```   372 apply (erule leadsETo_subset_leadsTo [THEN subsetD])
```
```   373 (*right-to-left case*)
```
```   374 apply (erule leadsTo_induct)
```
```   375 prefer 3 apply (blast intro: leadsETo_Union)
```
```   376 prefer 2 apply (blast intro: leadsETo_Trans, blast)
```
```   377 done
```
```   378
```
```   379 (**** weak ****)
```
```   380
```
```   381 lemma LeadsETo_eq_leadsETo:
```
```   382      "A LeadsTo[CC] B =
```
```   383         {F. F : (reachable F Int A) leadsTo[(%C. reachable F Int C) ` CC]
```
```   384         (reachable F Int B)}"
```
```   385 apply (unfold LeadsETo_def)
```
```   386 apply (blast dest: e_psp_stable2 intro: leadsETo_weaken)
```
```   387 done
```
```   388
```
```   389 (*** Introduction rules: Basis, Trans, Union ***)
```
```   390
```
```   391 lemma LeadsETo_Trans:
```
```   392      "[| F : A LeadsTo[CC] B;  F : B LeadsTo[CC] C |]
```
```   393       ==> F : A LeadsTo[CC] C"
```
```   394 apply (simp add: LeadsETo_eq_leadsETo)
```
```   395 apply (blast intro: leadsETo_Trans)
```
```   396 done
```
```   397
```
```   398 lemma LeadsETo_Union:
```
```   399      "(!!A. A : S ==> F : A LeadsTo[CC] B) ==> F : (Union S) LeadsTo[CC] B"
```
```   400 apply (simp add: LeadsETo_def)
```
```   401 apply (subst Int_Union)
```
```   402 apply (blast intro: leadsETo_UN)
```
```   403 done
```
```   404
```
```   405 lemma LeadsETo_UN:
```
```   406      "(!!i. i : I ==> F : (A i) LeadsTo[CC] B)
```
```   407       ==> F : (UN i:I. A i) LeadsTo[CC] B"
```
```   408 apply (simp only: Union_image_eq [symmetric])
```
```   409 apply (blast intro: LeadsETo_Union)
```
```   410 done
```
```   411
```
```   412 (*Binary union introduction rule*)
```
```   413 lemma LeadsETo_Un:
```
```   414      "[| F : A LeadsTo[CC] C; F : B LeadsTo[CC] C |]
```
```   415       ==> F : (A Un B) LeadsTo[CC] C"
```
```   416 apply (subst Un_eq_Union)
```
```   417 apply (blast intro: LeadsETo_Union)
```
```   418 done
```
```   419
```
```   420 (*Lets us look at the starting state*)
```
```   421 lemma single_LeadsETo_I:
```
```   422      "(!!s. s : A ==> F : {s} LeadsTo[CC] B) ==> F : A LeadsTo[CC] B"
```
```   423 apply (subst UN_singleton [symmetric], rule LeadsETo_UN, blast)
```
```   424 done
```
```   425
```
```   426 lemma subset_imp_LeadsETo:
```
```   427      "A <= B ==> F : A LeadsTo[CC] B"
```
```   428 apply (simp (no_asm) add: LeadsETo_def)
```
```   429 apply (blast intro: subset_imp_leadsETo)
```
```   430 done
```
```   431
```
```   432 lemmas empty_LeadsETo = empty_subsetI [THEN subset_imp_LeadsETo, standard]
```
```   433
```
```   434 lemma LeadsETo_weaken_R [rule_format]:
```
```   435      "[| F : A LeadsTo[CC] A';  A' <= B' |] ==> F : A LeadsTo[CC] B'"
```
```   436 apply (simp (no_asm_use) add: LeadsETo_def)
```
```   437 apply (blast intro: leadsETo_weaken_R)
```
```   438 done
```
```   439
```
```   440 lemma LeadsETo_weaken_L [rule_format]:
```
```   441      "[| F : A LeadsTo[CC] A';  B <= A |] ==> F : B LeadsTo[CC] A'"
```
```   442 apply (simp (no_asm_use) add: LeadsETo_def)
```
```   443 apply (blast intro: leadsETo_weaken_L)
```
```   444 done
```
```   445
```
```   446 lemma LeadsETo_weaken:
```
```   447      "[| F : A LeadsTo[CC'] A';
```
```   448          B <= A;  A' <= B';  CC' <= CC |]
```
```   449       ==> F : B LeadsTo[CC] B'"
```
```   450 apply (simp (no_asm_use) add: LeadsETo_def)
```
```   451 apply (blast intro: leadsETo_weaken)
```
```   452 done
```
```   453
```
```   454 lemma LeadsETo_subset_LeadsTo: "(A LeadsTo[CC] B) <= (A LeadsTo B)"
```
```   455 apply (unfold LeadsETo_def LeadsTo_def)
```
```   456 apply (blast intro: leadsETo_subset_leadsTo [THEN subsetD])
```
```   457 done
```
```   458
```
```   459 (*Postcondition can be strengthened to (reachable F Int B) *)
```
```   460 lemma reachable_ensures:
```
```   461      "F : A ensures B ==> F : (reachable F Int A) ensures B"
```
```   462 apply (rule stable_ensures_Int [THEN ensures_weaken_R], auto)
```
```   463 done
```
```   464
```
```   465 lemma lel_lemma:
```
```   466      "F : A leadsTo B ==> F : (reachable F Int A) leadsTo[Pow(reachable F)] B"
```
```   467 apply (erule leadsTo_induct)
```
```   468   apply (blast intro: reachable_ensures leadsETo_Basis)
```
```   469  apply (blast dest: e_psp_stable2 intro: leadsETo_Trans leadsETo_weaken_L)
```
```   470 apply (subst Int_Union)
```
```   471 apply (blast intro: leadsETo_UN)
```
```   472 done
```
```   473
```
```   474 lemma LeadsETo_UNIV_eq_LeadsTo: "(A LeadsTo[UNIV] B) = (A LeadsTo B)"
```
```   475 apply safe
```
```   476 apply (erule LeadsETo_subset_LeadsTo [THEN subsetD])
```
```   477 (*right-to-left case*)
```
```   478 apply (unfold LeadsETo_def LeadsTo_def)
```
```   479 apply (fast elim: lel_lemma [THEN leadsETo_weaken])
```
```   480 done
```
```   481
```
```   482
```
```   483 (**** EXTEND/PROJECT PROPERTIES ****)
```
```   484
```
```   485 lemma (in Extend) givenBy_o_eq_extend_set: "givenBy (v o f) = extend_set h ` (givenBy v)"
```
```   486 apply (simp (no_asm) add: givenBy_eq_Collect)
```
```   487 apply best
```
```   488 done
```
```   489
```
```   490 lemma (in Extend) givenBy_eq_extend_set: "givenBy f = range (extend_set h)"
```
```   491 apply (simp (no_asm) add: givenBy_eq_Collect)
```
```   492 apply best
```
```   493 done
```
```   494
```
```   495 lemma (in Extend) extend_set_givenBy_I:
```
```   496      "D : givenBy v ==> extend_set h D : givenBy (v o f)"
```
```   497 apply (simp (no_asm_use) add: givenBy_eq_all)
```
```   498 apply blast
```
```   499 done
```
```   500
```
```   501 lemma (in Extend) leadsETo_imp_extend_leadsETo:
```
```   502      "F : A leadsTo[CC] B
```
```   503       ==> extend h F : (extend_set h A) leadsTo[extend_set h ` CC]
```
```   504                        (extend_set h B)"
```
```   505 apply (erule leadsETo_induct)
```
```   506   apply (force intro: leadsETo_Basis subset_imp_ensures
```
```   507                simp add: extend_ensures extend_set_Diff_distrib [symmetric])
```
```   508  apply (blast intro: leadsETo_Trans)
```
```   509 apply (simp add: leadsETo_UN extend_set_Union)
```
```   510 done
```
```   511
```
```   512
```
```   513 (*This version's stronger in the "ensures" precondition
```
```   514   BUT there's no ensures_weaken_L*)
```
```   515 lemma (in Extend) Join_project_ensures_strong:
```
```   516      "[| project h C G ~: transient (project_set h C Int (A-B)) |
```
```   517            project_set h C Int (A - B) = {};
```
```   518          extend h F Join G : stable C;
```
```   519          F Join project h C G : (project_set h C Int A) ensures B |]
```
```   520       ==> extend h F Join G : (C Int extend_set h A) ensures (extend_set h B)"
```
```   521 apply (subst Int_extend_set_lemma [symmetric])
```
```   522 apply (rule Join_project_ensures)
```
```   523 apply (auto simp add: Int_Diff)
```
```   524 done
```
```   525
```
```   526 (*NOT WORKING.  MODIFY AS IN Project.thy
```
```   527 lemma (in Extend) pld_lemma:
```
```   528      "[| extend h F Join G : stable C;
```
```   529          F Join project h C G : (project_set h C Int A) leadsTo[(%D. project_set h C Int D)`givenBy v] B;
```
```   530          G : preserves (v o f) |]
```
```   531       ==> extend h F Join G :
```
```   532             (C Int extend_set h (project_set h C Int A))
```
```   533             leadsTo[(%D. C Int extend_set h D)`givenBy v]  (extend_set h B)"
```
```   534 apply (erule leadsETo_induct)
```
```   535   prefer 3
```
```   536   apply (simp del: UN_simps add: Int_UN_distrib leadsETo_UN extend_set_Union)
```
```   537  prefer 2
```
```   538  apply (blast intro: e_psp_stable2 [THEN leadsETo_weaken_L] leadsETo_Trans)
```
```   539 txt{*Base case is hard*}
```
```   540 apply auto
```
```   541 apply (force intro: leadsETo_Basis subset_imp_ensures)
```
```   542 apply (rule leadsETo_Basis)
```
```   543  prefer 2
```
```   544  apply (simp add: Int_Diff Int_extend_set_lemma extend_set_Diff_distrib [symmetric])
```
```   545 apply (rule Join_project_ensures_strong)
```
```   546 apply (auto intro: project_stable_project_set simp add: Int_left_absorb)
```
```   547 apply (simp (no_asm_simp) add: stable_ensures_Int [THEN ensures_weaken_R] Int_lower2 project_stable_project_set extend_stable_project_set)
```
```   548 done
```
```   549
```
```   550 lemma (in Extend) project_leadsETo_D_lemma:
```
```   551      "[| extend h F Join G : stable C;
```
```   552          F Join project h C G :
```
```   553              (project_set h C Int A)
```
```   554              leadsTo[(%D. project_set h C Int D)`givenBy v] B;
```
```   555          G : preserves (v o f) |]
```
```   556       ==> extend h F Join G : (C Int extend_set h A)
```
```   557             leadsTo[(%D. C Int extend_set h D)`givenBy v] (extend_set h B)"
```
```   558 apply (rule pld_lemma [THEN leadsETo_weaken])
```
```   559 apply (auto simp add: split_extended_all)
```
```   560 done
```
```   561
```
```   562 lemma (in Extend) project_leadsETo_D:
```
```   563      "[| F Join project h UNIV G : A leadsTo[givenBy v] B;
```
```   564          G : preserves (v o f) |]
```
```   565       ==> extend h F Join G : (extend_set h A)
```
```   566             leadsTo[givenBy (v o f)] (extend_set h B)"
```
```   567 apply (cut_tac project_leadsETo_D_lemma [of _ _ UNIV], auto)
```
```   568 apply (erule leadsETo_givenBy)
```
```   569 apply (rule givenBy_o_eq_extend_set [THEN equalityD2])
```
```   570 done
```
```   571
```
```   572 lemma (in Extend) project_LeadsETo_D:
```
```   573      "[| F Join project h (reachable (extend h F Join G)) G
```
```   574              : A LeadsTo[givenBy v] B;
```
```   575          G : preserves (v o f) |]
```
```   576       ==> extend h F Join G :
```
```   577             (extend_set h A) LeadsTo[givenBy (v o f)] (extend_set h B)"
```
```   578 apply (cut_tac subset_refl [THEN stable_reachable, THEN project_leadsETo_D_lemma])
```
```   579 apply (auto simp add: LeadsETo_def)
```
```   580  apply (erule leadsETo_mono [THEN  rev_subsetD])
```
```   581  apply (blast intro: extend_set_givenBy_I)
```
```   582 apply (simp add: project_set_reachable_extend_eq [symmetric])
```
```   583 done
```
```   584
```
```   585 lemma (in Extend) extending_leadsETo:
```
```   586      "(ALL G. extend h F ok G --> G : preserves (v o f))
```
```   587       ==> extending (%G. UNIV) h F
```
```   588                 (extend_set h A leadsTo[givenBy (v o f)] extend_set h B)
```
```   589                 (A leadsTo[givenBy v] B)"
```
```   590 apply (unfold extending_def)
```
```   591 apply (auto simp add: project_leadsETo_D)
```
```   592 done
```
```   593
```
```   594 lemma (in Extend) extending_LeadsETo:
```
```   595      "(ALL G. extend h F ok G --> G : preserves (v o f))
```
```   596       ==> extending (%G. reachable (extend h F Join G)) h F
```
```   597                 (extend_set h A LeadsTo[givenBy (v o f)] extend_set h B)
```
```   598                 (A LeadsTo[givenBy v]  B)"
```
```   599 apply (unfold extending_def)
```
```   600 apply (blast intro: project_LeadsETo_D)
```
```   601 done
```
```   602 *)
```
```   603
```
```   604
```
```   605 (*** leadsETo in the precondition ***)
```
```   606
```
```   607 (*Lemma for the Trans case*)
```
```   608 lemma (in Extend) pli_lemma:
```
```   609      "[| extend h F Join G : stable C;
```
```   610          F Join project h C G
```
```   611            : project_set h C Int project_set h A leadsTo project_set h B |]
```
```   612       ==> F Join project h C G
```
```   613             : project_set h C Int project_set h A leadsTo
```
```   614               project_set h C Int project_set h B"
```
```   615 apply (rule psp_stable2 [THEN leadsTo_weaken_L])
```
```   616 apply (auto simp add: project_stable_project_set extend_stable_project_set)
```
```   617 done
```
```   618
```
```   619 lemma (in Extend) project_leadsETo_I_lemma:
```
```   620      "[| extend h F Join G : stable C;
```
```   621          extend h F Join G :
```
```   622            (C Int A) leadsTo[(%D. C Int D)`givenBy f]  B |]
```
```   623   ==> F Join project h C G
```
```   624     : (project_set h C Int project_set h (C Int A)) leadsTo (project_set h B)"
```
```   625 apply (erule leadsETo_induct)
```
```   626   prefer 3
```
```   627   apply (simp only: Int_UN_distrib project_set_Union)
```
```   628   apply (blast intro: leadsTo_UN)
```
```   629  prefer 2 apply (blast intro: leadsTo_Trans pli_lemma)
```
```   630 apply (simp add: givenBy_eq_extend_set)
```
```   631 apply (rule leadsTo_Basis)
```
```   632 apply (blast intro: ensures_extend_set_imp_project_ensures)
```
```   633 done
```
```   634
```
```   635 lemma (in Extend) project_leadsETo_I:
```
```   636      "extend h F Join G : (extend_set h A) leadsTo[givenBy f] (extend_set h B)
```
```   637       ==> F Join project h UNIV G : A leadsTo B"
```
```   638 apply (rule project_leadsETo_I_lemma [THEN leadsTo_weaken], auto)
```
```   639 done
```
```   640
```
```   641 lemma (in Extend) project_LeadsETo_I:
```
```   642      "extend h F Join G : (extend_set h A) LeadsTo[givenBy f] (extend_set h B)
```
```   643       ==> F Join project h (reachable (extend h F Join G)) G
```
```   644            : A LeadsTo B"
```
```   645 apply (simp (no_asm_use) add: LeadsTo_def LeadsETo_def)
```
```   646 apply (rule project_leadsETo_I_lemma [THEN leadsTo_weaken])
```
```   647 apply (auto simp add: project_set_reachable_extend_eq [symmetric])
```
```   648 done
```
```   649
```
```   650 lemma (in Extend) projecting_leadsTo:
```
```   651      "projecting (%G. UNIV) h F
```
```   652                  (extend_set h A leadsTo[givenBy f] extend_set h B)
```
```   653                  (A leadsTo B)"
```
```   654 apply (unfold projecting_def)
```
```   655 apply (force dest: project_leadsETo_I)
```
```   656 done
```
```   657
```
```   658 lemma (in Extend) projecting_LeadsTo:
```
```   659      "projecting (%G. reachable (extend h F Join G)) h F
```
```   660                  (extend_set h A LeadsTo[givenBy f] extend_set h B)
```
```   661                  (A LeadsTo B)"
```
```   662 apply (unfold projecting_def)
```
```   663 apply (force dest: project_LeadsETo_I)
```
```   664 done
```
```   665
```
```   666 end
```