-
Notifications
You must be signed in to change notification settings - Fork 0
/
HPGCL_Expected_Running_Time.thy
2114 lines (1742 loc) · 81.3 KB
/
HPGCL_Expected_Running_Time.thy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\<^marker>\<open>creator "Maximilian P. L. Haslbeck"\<close>
chapter \<open>A Calculus for the expected running time of hpGCL\<close>
theory HPGCL_Expected_Running_Time
imports QSL_For_Potentials
HPGCL "HOL-Eisbach.Eisbach" "Differential_Game_Logic.Lib"
begin
paragraph \<open>Summary\<close>
text \<open>This theory introduces the expected running time (ERT) calculus
for hpGCL.
We use the ert calculus for pGCL and extend it to heap manipulating programs.
This theory is experimental.\<close>
lemma propagate_star: "\<And>var val. (A \<star>\<^sub>p Q) ((fst h)(var := val), snd h) = ((\<lambda>(s,h). A (s(var := val), h)) \<star>\<^sub>p (\<lambda>(s,h). Q (s(var := val), h))) h"
"\<And>var val. (A \<star>\<^sub>p Q) (x(var := val), y) = ((\<lambda>(s,h). A (s(var := val), h)) \<star>\<^sub>p (\<lambda>(s,h). Q (s(var := val), h))) (x,y)"
unfolding star_pot_method_alt''
by(auto simp add: split_beta)
method simp_ennreal = (simp del: ennreal_half ennreal_numeral ennreal_1
add: ennreal_1[symmetric] ennreal_numeral[symmetric]
ennreal_minus ennreal_mult[symmetric] divide_ennreal
ennreal_plus[symmetric] )
thm divide_ennreal ennreal_minus
definition pt :: "(stack \<Rightarrow> addrs) \<Rightarrow> (stack \<Rightarrow> val) \<Rightarrow> stack \<times> heap \<Rightarrow> ennreal"
("[_ \<mapsto> _]" [56,51] 56) where
"pt e e' \<equiv> (\<lambda>(s,h). if dom (map_of_heap h) = {e s} \<and> h (e s) = TRIV (e' s) then 0 else top)"
lemma pt_emb: "pt e e' = emb\<^sub>p (ptb e e')"
unfolding pt_def emb\<^sub>p_alt ptb_def by auto
subsection \<open>the "allocated pointer predicate"\<close>
definition ptany :: "(stack \<Rightarrow> addrs) \<Rightarrow> stack \<times> heap \<Rightarrow> ennreal"
("[_ \<mapsto> -]" [56] 56) where
"ptany e \<equiv> (\<lambda>(s,h). if dom (map_of_heap h) = {e s} then 0 else top)"
lemma ptany_emb: "ptany e = emb\<^sub>p (ptanyb e )"
unfolding ptany_def emb\<^sub>p_alt ptanyb_def by auto
term "(P -\<star>\<^sub>p Q)"
primrec ert :: "hpgcl \<Rightarrow> (stack \<times> heap \<Rightarrow> ennreal) \<Rightarrow> stack \<times> heap \<Rightarrow> ennreal" where
"ert Skip X = (\<lambda>x. X x + 1)"
| "ert (Seq c1 c2) X = ert c1 (ert c2 X)"
(* | "ert (Coin c1 p c2) X = (\<lambda>s. p * ert c1 X s + (1-p) * ert c2 X s)" *)
| "ert (If b c1 c2) X = (\<lambda>(s,h). (if b s then ert c1 X (s,h) else ert c2 X (s,h)))"
| "ert (While b c) X = lfp (\<lambda>Y (s,h). 1 + (if b s then ert c Y (s,h) else X (s,h) ))"
| "ert (Assign v e) X = (\<lambda>(s,h). X (s(v:=e s),h) + 1)"
| "ert (New x ve) X = (\<lambda>(s,h). Sup { (( (pt (\<lambda>_. a) ve)) -\<star>\<^sub>p (\<lambda>(s,h). X (s(x:=a),h))) (s,h) |a::int. True } + 1 )"
| "ert (Free ae) X = (\<lambda>x. ((ptany ae) \<star>\<^sub>p X) x + 1)"
| "ert (Lookup x ae) X =
(\<lambda>(s,h). Inf { ((pt ae (\<lambda>_. val)) \<star>\<^sub>p ( (pt ae (\<lambda>_. val)) -\<star>\<^sub>p (\<lambda>(s,h). X (s(x:=val),h)))) (s,h)
|val::int. True } + 1)"
| "ert (Update ae ve) X = (\<lambda>h. (ptany ae \<star>\<^sub>p (( (pt ae ve)) -\<star>\<^sub>p X)) h + 1)"
lemma sup_continuous_ert: "sup_continuous (ert P)"
apply (induction P)
(* apply (auto intro!: order_continuous_intros sup_continuous_lfp''[THEN sup_continuous_applyD]
dest: sup_continuous_compose sup_continuous_applyD) *)
oops
lemma ert_If_alt: "ert (If b c1 c2) X = inf (emb\<^sub>p (\<lambda>(s,h). b s) + ert c1 X) (emb\<^sub>p (\<lambda>(s,h). \<not>b s) + ert c2 X)"
by(auto simp add: sup_fun_def emb\<^sub>p_alt top_add split: if_splits prod.splits)
text \<open>sub-distributivity of \<open>\<star>\<^sub>p\<close> over inf \<close>
lemma sub_distributivity_of_star_over_inf:
"(X \<star>\<^sub>p (inf Y Z)) \<ge> inf (X \<star>\<^sub>p Y) (X \<star>\<^sub>p Z)"
unfolding star_pot_method_alt'
apply(rule le_funI)
apply auto
proof -
fix a b
let ?f = "(\<lambda>(x,y). X (a, x) + Y (a, y))"
let ?g = "(\<lambda>(x,y). X (a, x) + Z (a, y))"
have "inf (Inf {X (a, x) + Y (a, y) |x y. b = x + y \<and> x ## y}) (Inf {X (a, x) + Z (a, y) |x y. b = x + y \<and> x ## y})
= inf (Inf (?f `{(x,y) |x y. b = x + y \<and> x ## y})) (Inf (?g ` {(x,y) |x y. b = x + y \<and> x ## y}))"
apply (rule arg_cong2[where f=inf]) apply(rule arg_cong[where f=Inf]) apply auto
apply(rule arg_cong[where f=Inf]) apply auto done
also have "\<dots> = (INF a\<in>{(x,y) |x y. b = x + y \<and> x ## y}. inf (?f a) (?g a))"
apply(subst INF_inf_distrib) by simp
also have "\<dots> \<le> Inf {X (a, x) + ENNREAL_PLUS.fsup Y Z (a, y) |x y. b = x + y \<and> x ## y}"
apply(rule Inf_mono)
apply auto
subgoal for x y
apply(rule exI[where x=x])
apply(rule exI[where x=y]) apply auto
by (simp add: ENNREAL_PLUS.sup_times_distrib)
done
finally show " inf (Inf {X (a, x) + Y (a, y) |x y. b = x + y \<and> x ## y})
(Inf {X (a, x) + Z (a, y) |x y. b = x + y \<and> x ## y})
\<le> Inf {X (a, x) + ENNREAL_PLUS.fsup Y Z (a, y) |x y. b = x + y \<and> x ## y}"
.
qed
lemma sub_distributivity_of_star_over_inf':
"((inf Y Z) \<star>\<^sub>p X ) \<ge> inf (Y \<star>\<^sub>p X) (Z \<star>\<^sub>p X)"
apply(subst (3) star_pot_method_commute)
apply(subst (1) star_pot_method_commute)
apply(subst (2) star_pot_method_commute)
apply(subst sub_distributivity_of_star_over_inf)
by simp
lemma ert_mono:
"f\<le>g \<Longrightarrow> ert c f \<le> ert c g"
proof (induct c arbitrary: f g)
case Skip
then show ?case by (auto simp: le_fun_def)
next
case (Assign x1 x2)
then show ?case by (auto simp: le_fun_def)
next
case (Seq c1 c2)
then show ?case by (auto simp: le_fun_def)
(*next
case (Coin c1 x2 c2)
then show ?case
apply (auto simp: le_fun_def)
apply(rule add_mono)
subgoal apply(rule mult_left_mono) by auto
subgoal apply(rule mult_left_mono) by auto
done *)
next
case (If x1 c1 c2)
then show ?case
by (auto simp: le_fun_def)
next
case (While x1 c)
then show ?case
apply (auto simp: )
apply(rule lfp_mono) by (auto simp: le_fun_def)
next
case (New x1 x2)
then show ?case
apply (auto simp: le_fun_def)
apply (rule Sup_mono)
apply safe
apply auto
subgoal for a b ab
apply(rule exI[where x="([(\<lambda>_. ab) \<mapsto> x2] -\<star>\<^sub>p (\<lambda>(s, h). g (s(x1 := ab), h))) (a, b)"])
apply safe apply(rule exI[where x=ab]) apply simp
apply(rule wand_pot_method_Rmono) by auto
done
next
case (Free x)
then show ?case
by (auto simp: le_fun_def intro: star_pot_method_mono)
next
case (Lookup x1 x2)
then show ?case
apply (auto simp: le_fun_def)
apply (rule Inf_mono)
apply safe
apply auto
subgoal for a b val
apply(rule exI[where x=" ([x2 \<mapsto> (\<lambda>_. val)] \<star>\<^sub>p [x2 \<mapsto> (\<lambda>_. val)] -\<star>\<^sub>p (\<lambda>(s, h). f (s(x1 := val), h))) (a, b)"])
apply safe apply(rule exI[where x=val]) apply simp
apply(rule star_pot_method_mono) apply simp
apply(rule wand_pot_method_Rmono) by auto
done
next
case (Update x1 x2)
then show ?case
by (auto simp: le_fun_def intro!: star_pot_method_mono wand_pot_method_Rmono)
qed
lemma ert_mono':
"f\<le>g \<Longrightarrow> ert c f x\<le> ert c g x"
using ert_mono
by (simp add: le_funD)
definition chara where
"chara b c X Y = (\<lambda>(s,h). 1 + (if b s then ert c Y (s,h) else X (s,h)))"
thm lfp_lowerbound
theorem invariant_rule:
assumes "chara b c X I \<le> I"
shows "ert (While b c) X \<le> I"
using assms by(auto intro: lfp_lowerbound simp add: chara_def)
subsection \<open>Dollar Assertion\<close>
definition dollar where
"dollar c = (\<lambda>(s,h). if h=0 then c else \<infinity>)"
lemma plus_as_dollar_conv: "\<And>Q a c. Q a + c = (Q \<star>\<^sub>p dollar c) a"
unfolding dollar_def star_pot_method_alt''
apply auto
apply(rule antisym)
subgoal apply(rule Inf_greatest) apply auto
by (simp add: add_top)
subgoal for Q a b apply(rule Inf_lower)
apply ( rule image_eqI[where x="(b,0)"]) apply simp apply simp done
done
lemma plus_as_dollar_conv': "\<And>Q. (\<lambda>a. Q a + c) = (Q \<star>\<^sub>p dollar c)"
apply (rule ext) by(rule plus_as_dollar_conv)
lemma ert_New_alt: "ert (New x ve) X =
((\<lambda>(s,h). (SUP a\<in>UNIV. (( (pt (\<lambda>_. a) ve)) -\<star>\<^sub>p (\<lambda>(s,h). X (s(x:=a),h))) (s,h)) ) \<star>\<^sub>p dollar 1) "
apply simp
apply(rule ext) apply simp
unfolding plus_as_dollar_conv[symmetric]
apply simp
apply(rule arg_cong[where f=Sup]) by auto
lemma ert_Lookup_alt: "ert (Lookup x ae) X =
((\<lambda>(s,h). (INF val\<in>UNIV. ((pt ae (\<lambda>_. val)) \<star>\<^sub>p ( (pt ae (\<lambda>_. val)) -\<star>\<^sub>p (\<lambda>(s,h). X (s(x:=val),h)))) (s,h)
)) \<star>\<^sub>p dollar 1)"
apply simp
apply(rule ext) apply simp
unfolding plus_as_dollar_conv[symmetric]
apply simp
apply(rule arg_cong[where f=Inf]) by auto
subsection \<open>Hoare triples\<close>
definition "Hoare_triple \<Phi> c \<Psi> \<equiv> \<Phi> \<ge> ert c \<Psi>"
lemma Hoare_tripleI[intro]: "\<Phi> \<ge> ert c \<Psi> \<Longrightarrow> Hoare_triple \<Phi> c \<Psi>"
unfolding Hoare_triple_def .
lemma Hoare_tripleD: "Hoare_triple \<Phi> c \<Psi> \<Longrightarrow> \<Phi> \<ge> ert c \<Psi>"
unfolding Hoare_triple_def .
subsection \<open>Quantitative Frame Rule\<close>
lemma Assign_propagates_star: "x1 \<notin> Vars \<Pi> \<Longrightarrow>
((\<lambda>(s, h). \<Psi> (s(x1 := x2 s), h)) \<star>\<^sub>p \<Pi>) (a, b)
= ( \<Psi> \<star>\<^sub>p \<Pi>) (a(x1 := x2 a), b)"
unfolding star_pot_method_alt'
apply simp
apply(rule arg_cong[where f=Inf])
apply auto
subgoal for xa y
apply(rule exI[where x=xa])
apply(rule exI[where x=y])
apply safe
apply(drule not_in_Vars_upd_okay[where s=a and v="x2 a" and h=y])
by simp
subgoal for xa y
apply(rule exI[where x=xa])
apply(rule exI[where x=y])
apply safe
apply(drule not_in_Vars_upd_okay[where s=a and v="x2 a" and h=y])
by simp
done
lemma quantitative_frame_rule_aux: "(Mod c1 \<union> Mod c2) \<inter> Vars \<Pi> = {}
\<Longrightarrow> Mod c1 \<inter> Vars \<Pi> = {} \<and> Mod c2 \<inter> Vars \<Pi> = {}" by auto
lemma theorem_3_11_3': "pure\<^sub>p X \<Longrightarrow> ((X + Y) \<star>\<^sub>p Z) = (X + (Y \<star>\<^sub>p Z))"
unfolding plus_fun_def
using theorem_3_11_3[of X Y Z]
.
lemma zz: "(a::ennreal) * Inf G \<le> (INF x\<in>G. a * x)"
apply(rule Inf_greatest)
apply auto
by (simp add: ENNREAL_PLUS.Sup_upper mult_left_mono)
lemma zz2: "ENNREAL_PLUS.SUPR {f (x,y) |x y. ba = x + y \<and> x ## y} g
= ENNREAL_PLUS.SUPR {(x,y)|x y. ba = x + y \<and> x ## y} (g o f)"
apply auto
apply(rule arg_cong[where f=Inf]) by auto
(*
lemma blab: "((\<lambda>s. a*F s+b*G s) \<star>\<^sub>p (\<lambda>s. a*F' s+b*G' s)) \<ge> (\<lambda>s. a*(F\<star>\<^sub>pF') s+b*(G\<star>\<^sub>pG') s)"
unfolding star_pot_method_alt'
apply(rule le_funI)
apply auto
apply(rule order.trans)
apply(rule add_mono)
apply(rule zz) apply(rule zz)
supply [[unify_trace_failure]]
apply(subst zz2)
apply(rule order.trans)
using ENNREAL_PLUS.SUP_times_distrib2_general
apply(rule ENNREAL_PLUS.SUP_times_distrib2_general)
sorry
*)
lemma qfr_aux1: "Sup ((\<lambda>x. Inf ((\<lambda>y. (f x y)::ennreal)`Y) )`X) \<le> Inf ((\<lambda>y. Sup ((\<lambda>x. f x y)`X))`Y)"
by (simp add: ENNREAL_PLUS.SUP_least ENNREAL_PLUS.SUP_upper SUP_mono')
lemma star_pot_method_alt''':
"(P \<star>\<^sub>p Q) = (\<lambda>(s,h). INF (x,y)\<in> { (x, y). x ## y}. if h=x+y then P(s,x) + Q(s,y) else top )"
unfolding star_pot_method_alt'
apply(rule ext)
apply auto
apply(rule antisym)
subgoal
by (smt ENNREAL_PLUS.bot_least Inf_greatest Inf_lower imageE mem_Collect_eq split_beta)
subgoal
apply(rule Inf_greatest)
apply auto apply(rule Inf_lower2)
by auto
done
lemma SUP_to_UNIV: "(SUP h\<in>M. f h) = (SUP h\<in>UNIV. if h\<in>M then f h else (bot::'b::complete_lattice))"
apply(rule antisym)
subgoal
apply(rule Sup_least)
apply(rule Sup_upper2) by auto
subgoal
by (smt SUP_least Sup_upper ccSUP_empty empty_iff image_eqI)
done
lemma INF_to_UNIV: "(INF h\<in>M. f h) = (INF h\<in>UNIV. if h\<in>M then f h else (top::'b::complete_lattice))"
apply(rule antisym)
subgoal
by (smt INF_greatest Inf_lower image_eqI top_greatest)
subgoal
apply(rule Inf_greatest)
apply auto apply(rule Inf_lower2)
by auto
done
lemma If_Inf_commute: "(if b then Inf (f`G) else bot) \<le> Inf ((\<lambda>x. (if b then (f x)::ennreal else bot))`G) "
apply(cases b) by auto
lemma If_Sup_commute_bot: "(if b then Sup (f`G) else bot) \<le> Sup ((\<lambda>x. (if b then (f x)::ennreal else bot))`G) "
apply(cases b) by auto
lemma If_Sup_commute_top: "(if b then Sup (f`G) else top) \<ge> Sup ((\<lambda>x. (if b then (f x)::ennreal else top))`G) "
apply(cases b) by auto
lemma tta: "(if b then x - y else bot) \<le> (if b then x else bot) - (y::ennreal)"
by(auto)
thm ENNREAL_PLUS.Sup_mult_right_distrib
lemma INF_ennreal_add_const_local2:
fixes f g :: "_ \<Rightarrow> ennreal"
shows "(INF i\<in>A. f i + c) = (INF i\<in>A. f i) + c"
apply(cases "A={}")
subgoal by simp
subgoal
using continuous_at_Inf_mono[of "\<lambda>x. x + c" "f`A"]
using continuous_add[of "at_right (Inf (f ` A))", of "\<lambda>x. x" "\<lambda>x. c"]
by (auto simp: image_comp mono_def)
done
thm continuous_diff
thm continuous_add
lemma "Inf (f`X) - c = Inf ((\<lambda>x. (f x::ennreal) - c)`X)"
apply(cases "X={}")
subgoal by simp
subgoal
oops
text \<open>
The following lemma can also be stated using monotone functions @{term f} and @{term g}. But then
the continuity assumption needs to be for all cardinals, not only countable.
\<close>
lemma lfp_parallel_induct[consumes 2, case_names bot step cont]:
assumes f: "sup_continuous f" and g: "sup_continuous g"
assumes bot: "R bot bot"
assumes step: "\<And>x y. R x y \<Longrightarrow> R (f x) (g y)"
assumes cont: "\<And>X Y. (\<And>i::nat. R (X i) (Y i)) \<Longrightarrow> mono X \<Longrightarrow> mono Y \<Longrightarrow> R (SUP i. X i) (SUP i. Y i)"
shows "R (lfp f) (lfp g)"
unfolding f[THEN sup_continuous_lfp] g[THEN sup_continuous_lfp]
proof (rule cont)
show "incseq (\<lambda>i. (f ^^ i) bot)" "incseq (\<lambda>i. (g ^^ i) bot)"
by (intro mono_funpow f[THEN sup_continuous_mono] g[THEN sup_continuous_mono])+
show "R ((f ^^ i) bot) ((g ^^ i) bot)" for i
by (induction i) (auto intro: bot step)
qed
lemma ennreal_SUP_add_left_le:
fixes c :: ennreal
shows "(SUP i\<in>I. f i + c) \<le> (SUP i\<in>I. f i) + c"
apply(cases "I={}")
apply simp
apply(subst ennreal_SUP_add_left) apply auto
done
lemma INF_ennreal_add_const:
fixes f g :: "_ \<Rightarrow> ennreal"
shows "(INF i. f i + c) = (INF i. f i) + c"
using continuous_at_Inf_mono[of "\<lambda>x. x + c" "f`UNIV"]
using continuous_add[of "at_right (Inf (range f))", of "\<lambda>x. x" "\<lambda>x. c"]
by (auto simp: mono_def image_comp)
lemma INF_ennreal_const_add'':
fixes f :: "_ \<Rightarrow> ennreal"
shows " c + Inf (f`X) = Inf ((\<lambda>x. c + f x)`X)"
using INF_ennreal_const_add' by metis
abbreviation "Supl \<equiv> ENNREAL_PLUS.INFI"
abbreviation "Infl \<equiv> ENNREAL_PLUS.SUPR"
lemma INF_to_UNIV': "Infl B (\<lambda>x. if b x then f x else \<infinity>) = Infl (B \<inter> {x. b x}) f "
apply(rule antisym)
subgoal
by (smt ENNREAL_PLUS.SUP_mono Int_Collect eq_iff)
subgoal
apply(rule Inf_greatest)
apply auto apply(rule Inf_lower2)
by auto
done
lemma INF_to_UNIV'': "Infl B (\<lambda>(x,y). if b (x,y) then f (x,y) else \<infinity>) = Infl (B \<inter> {(x,y). b (x,y)}) f "
using INF_to_UNIV' by auto
definition "pt_m ae e = ((pt ae e)\<star>\<^sub>p(emb\<^sub>p (\<lambda>_. True)))"
lemma pt_m_0orinf: "pt_m ae e sh \<in> {\<infinity>, 0}"
unfolding pt_m_def pt_emb
apply(simp only: star_pot_method_pred_range) done
lemma all_pt_false_if_pt_m_false':
assumes "pt_m ae e (s, h) = top"
shows "\<forall>h1 h2. ((h1 ## h2 \<and> h=h1+h2) \<longrightarrow> pt ae e (s, h1) = top)"
proof (rule ccontr)
assume "\<not> (\<forall>h1 h2. h1 ## h2 \<and> h = h1 + h2 \<longrightarrow> ([ae \<mapsto> e]) (s, h1) = top)"
then have "\<exists>h1 h2. h1 ## h2 \<and> h = h1 + h2 \<and> ([ae \<mapsto> e]) (s, h1) \<noteq> top" by auto
then obtain h1 h2 where p: "h1 ## h2" "h = h1 + h2" and "([ae \<mapsto> e]) (s, h1) \<noteq> top" by auto
then have t: "([ae \<mapsto> e]) (s, h1) < top"
using nn by blast
have "pt_m ae e (s, h) \<le> ([ae \<mapsto> e]) (s, h1)"
unfolding pt_m_def
unfolding star_pot_method_alt''
apply auto
apply(rule Inf_lower)
apply(rule image_eqI[where x="(h1,h2)"])
using p by (auto simp: emb\<^sub>p_alt)
also note t
finally show "False" using assms by simp
qed
lemma "dom (map_of_heap h) = {x. h x \<noteq> ZERO}"
unfolding dom_def map_of_heap_def by (auto split: tsa_opt.splits)
(* TODO: cleanup this mess *)
lemma one_part_and_the_other:
fixes h1 :: "int \<Rightarrow> int tsa_opt"
assumes "h1##h2" " h=h1+h2"
assumes "h1'##h2' " " h=h1'+h2'"
assumes "h1=h1'"
shows "h2=h2'"
proof -
from assms(1,2) have a: "dom (map_of_heap h1) \<union> dom (map_of_heap h2) = dom (map_of_heap h)"
unfolding plus_tsa_opt_def plus_fun_def map_of_heap_def apply (auto split: tsa_opt.splits)
apply (metis sep_disj_fun_def sep_disj_tsa_opt_def tsa_opt.distinct(1))
apply (metis sep_disj_fun_def sep_disj_tsa_opt_def tsa_opt.distinct(1))
done
from assms(3,4) have b: "dom (map_of_heap h1') \<union> dom (map_of_heap h2') = dom (map_of_heap h)"
unfolding plus_tsa_opt_def plus_fun_def map_of_heap_def apply (auto split: tsa_opt.splits)
apply (metis sep_disj_fun_def sep_disj_tsa_opt_def tsa_opt.distinct(1))
apply (metis sep_disj_fun_def sep_disj_tsa_opt_def tsa_opt.distinct(1))
done
from assms(1) have c: "dom (map_of_heap h1) \<inter> dom (map_of_heap h2) = {}"
unfolding plus_tsa_opt_def sep_disj_fun_def sep_disj_tsa_opt_def plus_fun_def map_of_heap_def apply (auto split: tsa_opt.splits)
by (metis tsa_opt.distinct(1))
from assms(3) have d: "dom (map_of_heap h1') \<inter> dom (map_of_heap h2') = {}"
unfolding plus_tsa_opt_def sep_disj_fun_def sep_disj_tsa_opt_def plus_fun_def map_of_heap_def apply (auto split: tsa_opt.splits)
by (metis tsa_opt.distinct(1))
have f: "\<And>A A' B B' C. A=A' \<Longrightarrow> A \<union> B = C \<Longrightarrow> A' \<union> B' = C \<Longrightarrow> A \<inter> B = {} \<Longrightarrow> A' \<inter> B' = {} \<Longrightarrow> B = B'" by blast
have s: "dom (map_of_heap h2) = dom (map_of_heap h2')" apply(rule f[OF _ a b c d]) using assms(5) by simp
from assms(1,2) have z: "\<And>x. x\<in>dom (map_of_heap h2) \<Longrightarrow> h2 x = h x"
unfolding plus_tsa_opt_def plus_fun_def map_of_heap_def apply (auto split: tsa_opt.splits)
by (metis sep_disj_fun_def sep_disj_tsa_opt_def tsa_opt.distinct(1))
from assms(3,4) have z': "\<And>x. x\<in>dom (map_of_heap h2') \<Longrightarrow> h2' x = h x"
unfolding plus_tsa_opt_def plus_fun_def map_of_heap_def apply (auto split: tsa_opt.splits)
by (metis sep_disj_fun_def sep_disj_tsa_opt_def tsa_opt.distinct(1))
show "h2=h2'"
apply(rule ext)
subgoal for x
apply(cases "x\<in>dom (map_of_heap h2')")
subgoal using z z' s by simp
subgoal using s
by (metis domIff map_of_heap_def option.distinct(1) tsa_opt.case_eq_if)
done
done
qed
lemma pt_precise_easy:
assumes "pt ae e (s,h1) = 0"
assumes "pt ae e (s,h1') = 0"
shows "h1=h1'"
proof (rule ccontr)
assume n: "h1 \<noteq> h1'"
from assms(1) have 1: "\<forall>a. (a= ae s \<or> h1 a = ZERO)"
unfolding pt_def apply auto unfolding map_of_heap_def
apply (auto split: if_splits)
by (metis domIff option.distinct(1) singleton_iff tsa_opt.case_eq_if)
from assms(2) have 2: "\<forall>a. (a= ae s \<or> h1' a = ZERO)"
unfolding pt_def apply auto unfolding map_of_heap_def
apply (auto split: if_splits)
by (metis domIff option.distinct(1) singleton_iff tsa_opt.case_eq_if)
from n 1 2 have K: "h1 (ae s) \<noteq> h1' (ae s)"
by (metis ext)
have a1: "h1 (ae s) = TRIV (e s)" using 1
using assms(1) unfolding pt_def by (auto split: if_splits)
have a2: "h1' (ae s) = TRIV (e s)"
using assms(2) pt_def by (auto split: if_splits)
from K a1 a2 show False by simp
qed
lemma pt_precise:
assumes "h1##h2 \<and> h=h1+h2 \<and> pt ae e (s,h1) = 0"
assumes "h1'##h2' \<and> h=h1'+h2' \<and> pt ae e (s,h1') = 0"
shows "h1=h1'"
proof (rule ccontr)
assume n: "h1 \<noteq> h1'"
from assms(1) have 1: "\<forall>a. (a= ae s \<or> h1 a = ZERO)"
unfolding pt_def apply auto unfolding map_of_heap_def
apply (auto split: if_splits)
by (metis domIff option.distinct(1) singleton_iff tsa_opt.case_eq_if)
from assms(2) have 2: "\<forall>a. (a= ae s \<or> h1' a = ZERO)"
unfolding pt_def apply auto unfolding map_of_heap_def
apply (auto split: if_splits)
by (metis domIff option.distinct(1) singleton_iff tsa_opt.case_eq_if)
from n 1 2 have K: "h1 (ae s) \<noteq> h1' (ae s)"
by (metis ext)
have a1: "h1 (ae s) \<noteq> ZERO" using 1
using assms(1) pt_def by auto
have a2: "h1' (ae s) \<noteq> ZERO"
using assms(2) pt_def by auto
from assms(1) a1 have K1: "h (ae s) = h1 (ae s)"
by (metis plus_fun' sep_disj_fun_def sep_disj_tsa_opt_def triv_Z_lower2(1))
from assms(2) a2 have K2: "h (ae s) = h1' (ae s)"
by (metis plus_fun' sep_disj_fun_def sep_disj_tsa_opt_def triv_Z_lower2(1))
from K K1 K2 show False by simp
qed
lemma pt_precise':
assumes "h1##h2" "h=h1+h2" "pt ae e (s,h1) = 0"
assumes "h1'##h2'" "h=h1'+h2'" "h1~=h1'"
shows "pt ae e (s,h1') \<noteq> 0"
using pt_precise[of h1 h2 h ae e s] assms by blast
lemma pt_precise'b:
assumes "h1##h2" "h=h1+h2" "pt ae e (s,h1) = 0"
assumes "h1'##h2'" "h=h1'+h2'" "h1~=h1'"
shows "~ ptb ae e (s,h1')"
using pt_precise[of h1 h2 h ae e s] assms unfolding pt_emb emb\<^sub>p_alt
by meson
lemma pt_precise'':
assumes "h1##h2" "h=h1+h2" "pt ae e (s,h1) = 0"
assumes "h1'##h2'" "h=h1'+h2'" "h1~=h1'"
shows "pt ae e (s,h1') = top"
using pt_precise'[OF assms]
using pt_def by auto
lemma exists_pt_true_if_pt_m_true:
assumes "pt_m ae e (s, h) = 0"
shows "(\<exists>h1 h2. h1##h2 \<and> h=h1+h2 \<and> pt ae e (s,h1) = 0)"
proof (rule ccontr)
assume "~(\<exists>h1 h2. h1##h2 \<and> h=h1+h2 \<and> pt ae e (s,h1) = 0)"
then have "\<forall>h1 h2. h1##h2 \<and> h=h1+h2 \<longrightarrow> pt ae e (s,h1) \<noteq> 0" by blast
then have "\<And>h1 h2. h1##h2 \<Longrightarrow> h=h1+h2 \<Longrightarrow> pt ae e (s,h1) = \<infinity>"
unfolding pt_def by auto
then have "\<infinity> \<le> pt_m ae e (s, h)"
unfolding pt_m_def
unfolding star_pot_method_alt''
apply simp
apply(rule Inf_greatest)
by auto
then show False using assms by auto
qed
lemma exists_pt_true_if_pt_m_true:
assumes "pt_m ae e (s, h) = 0"
shows "(\<exists>h1 h2. h1##h2 \<and> h=h1+h2 \<and> pt ae e (s,h1) = 0 \<and> (\<forall>h1'. h\<noteq>h1 \<longrightarrow> pt ae e (s,h1') = \<infinity>) )"
oops
lemma all_pt_false_if_pt_m_false:
assumes "pt_m ae e (s, h) = \<infinity>"
shows "h1 ## h2 \<Longrightarrow> h=h1+h2 \<Longrightarrow> pt ae e (s, h1) = \<infinity>"
using assms all_pt_false_if_pt_m_false' unfolding infinity_ennreal_def by blast
lemma lemmaB1': "((pt ae e) \<star>\<^sub>p ( (pt ae e) -\<star>\<^sub>p X)) (s,h) = (pt_m ae e + X) (s,h)"
proof (cases "pt_m ae e (s,h) = 0")
case True
from exists_pt_true_if_pt_m_true[OF True]
obtain h1 h2 where A: "h1 ## h2" "h = h1 + h2" "([ae \<mapsto> e]) (s, h1) = 0"
by auto
thm pt_precise
have aga: "{h'. h2 ## h' \<and> ptb ae e (s, h')}
= {h1}"
apply auto
subgoal apply(rule pt_precise_easy[OF _ A(3)]) unfolding pt_emb emb\<^sub>p_alt by simp
subgoal using A by (simp add: sep_disj_commute)
subgoal using A(3) unfolding pt_emb emb\<^sub>p_alt by (auto split: if_splits)
done
have "((pt ae e) \<star>\<^sub>p ( (pt ae e) -\<star>\<^sub>p X)) (s,h)
= Infl {(x, y). h = x + y \<and> x ## y} (\<lambda>(x, y). ([ae \<mapsto> e]) (s, x) + ([ae \<mapsto> e] -\<star>\<^sub>p X) (s, y))"
unfolding star_pot_method_alt'' apply simp done
also have "\<dots> = Infl {(x, y). h = x + y \<and> x ## y} (\<lambda>(x, y).
(if x=h1 \<and> y=h2 then ([ae \<mapsto> e]) (s, h1) + ([ae \<mapsto> e] -\<star>\<^sub>p X) (s, h2) else \<infinity> ))"
apply(rule INF_cong) apply simp
apply auto
subgoal using pt_precise''[OF A] by simp
subgoal using pt_precise''[OF A] one_part_and_the_other[OF A(1,2)]
by blast
done
also have "\<dots> = Infl {(x,y). h = x+ y \<and> x##y \<and> x=h1 \<and> y=h2} (\<lambda>_. ([ae \<mapsto> e]) (s, h1) + ([ae \<mapsto> e] -\<star>\<^sub>p X) (s, h2))"
apply(rule antisym)
subgoal
apply(rule Inf_mono) by auto
subgoal
apply(rule Inf_greatest)
by auto
done
also have "\<dots> = ([ae \<mapsto> e]) (s, h1) + ([ae \<mapsto> e] -\<star>\<^sub>p X) (s, h2)"
apply(subst INF_constant) using A(1,2) by auto
also have "\<dots> = ([ae \<mapsto> e] -\<star>\<^sub>p X) (s, h2)"
using A(3) by simp
also have "\<dots> = Supl {h'. h2 ## h' \<and> ptb ae e (s, h')} (\<lambda>h'. X (s, h2 + h'))"
unfolding pt_emb wand_pot_method_emb_alt apply simp done
also have "\<dots> = X (s, h2 + h1)"
unfolding aga apply simp done
also have "\<dots> = X (s, h)"
using A(1,2) sep_add_commute by fastforce
also have "\<dots> = (pt_m ae e + X) (s,h)"
using True apply simp done
finally show ?thesis .
next
case False
with pt_m_0orinf have *: "pt_m ae e (s,h) = \<infinity>" by fast
have "((pt ae e) \<star>\<^sub>p ( (pt ae e) -\<star>\<^sub>p X)) (s,h)
= Infl {(x, y). h = x + y \<and> x ## y} (\<lambda>(x,y). ([ae \<mapsto> e]) (s, x) + ([ae \<mapsto> e] -\<star>\<^sub>p X) (s, y))"
unfolding star_pot_method_alt'' apply simp done
also have "\<dots> = Infl {(x, y). h = x + y \<and> x ## y} (\<lambda>(x,y). \<infinity> + ([ae \<mapsto> e] -\<star>\<^sub>p X) (s, y))"
apply(rule INF_cong)
apply auto
subgoal for a b
using all_pt_false_if_pt_m_false[OF *, of a] unfolding infinity_ennreal_def by blast
done
also have "\<dots> = \<infinity>"
by simp
also have "\<dots> = (pt_m ae e + X) (s,h)"
using * by simp
finally show ?thesis .
qed
lemma lemmaB1: "((pt ae e) \<star>\<^sub>p ( (pt ae e) -\<star>\<^sub>p X)) = (pt_m ae e + X) "
apply(rule ext)
apply(case_tac x) apply safe
apply(rule lemmaB1') done
lemma pt_m_reduce: "a ## b \<Longrightarrow> pt_m x2 e (s, a + b) \<le> pt_m x2 e (s, a)"
unfolding pt_m_def
unfolding star_pot_method_alt'' apply auto
apply(rule INF_mono) apply auto
subgoal for x y
apply(rule exI[where x=x])
apply(rule exI[where x="y+b"])
apply safe
subgoal using sep_add_assoc sep_add_disjD by blast
subgoal using sep_disj_addI3 by auto
subgoal by (simp add: emb\<^sub>p_alt)
done
done
lemma ert_Lookup_alt': "ert (Lookup x ae) X =
((\<lambda>(s,h). (INF val\<in>UNIV. (pt_m ae (\<lambda>_. val) + (\<lambda>(s,h). X (s(x:=val),h))) (s,h))) \<star>\<^sub>p dollar 1)"
unfolding ert_Lookup_alt
apply(subst lemmaB1) by auto
lemma Inf_swap: "\<And>X f. Infl UNIV (\<lambda>u. Infl X (\<lambda>x. f u x)) = Infl X (\<lambda>x. Infl UNIV (\<lambda>u. f u x))"
using ENNREAL_PLUS.SUP_commute by blast
text \<open>Appendix B.12 in @{cite batzPOPL19}\<close>
lemma quantitative_frame_rule:
shows "Mod c \<inter> Vars \<Pi> = {} \<Longrightarrow> ert c (\<Psi> \<star>\<^sub>p \<Pi>) \<le> (ert c \<Psi> \<star>\<^sub>p \<Pi>)"
proof (induct c arbitrary: \<Psi>)
case Skip
then show ?case
apply (simp add: plus_as_dollar_conv )
apply(subst (2) star_pot_method_commute)
apply(subst (3) star_pot_method_commute)
apply(subst star_pot_method_assoc[symmetric])
by simp
next
case (Assign x1 x2)
then show ?case
apply (simp add: plus_as_dollar_conv )
apply(rule le_funI)
apply auto
apply(subst Assign_propagates_star) apply simp
apply(subst (2) star_pot_method_commute)
apply(subst (3) star_pot_method_commute)
apply(subst star_pot_method_assoc[symmetric])
by simp
next
case (Seq c1 c2)
then show ?case
apply (auto intro!: ert_mono)
apply (drule quantitative_frame_rule_aux)
apply(rule order.trans)
apply(rule ert_mono[where g="ert c2 \<Psi> \<star>\<^sub>p \<Pi>"])
by simp_all
(*next
case (Coin c1 x2 c2)
{
fix a b
have "x2 * ert c1 (\<Psi> \<star>\<^sub>p \<Pi>) (a, b) + (1 - x2) * ert c2 (\<Psi> \<star>\<^sub>p \<Pi>) (a, b)
\<le> G" sorry
also have "\<dots> \<le> ((\<lambda>a. x2 * ert c1 \<Psi> a + (1 - x2) * ert c2 \<Psi> a) \<star>\<^sub>p \<Pi>) (a, b)"
sorry
also have "\<dots> \<le> ((\<lambda>a. x2 * ert c1 \<Psi> a + (1 - x2) * ert c2 \<Psi> a) \<star>\<^sub>p (x2 * \<Pi> + (1-x2) * \<Pi>)) (a, b)"
sorry
finally have "x2 * ert c1 (\<Psi> \<star>\<^sub>p \<Pi>) (a, b) + (1 - x2) * ert c2 (\<Psi> \<star>\<^sub>p \<Pi>) (a, b)
\<le> ((\<lambda>a. x2 * ert c1 \<Psi> a + (1 - x2) * ert c2 \<Psi> a) \<star>\<^sub>p \<Pi>) (a, b)"
.
}
from Coin show ?case
apply (auto simp: le_fun_def)
using theorem_3_11_3
apply(rule add_mono)
sorry *)
next
case (If x1 c1 c2)
then show ?case
unfolding ert_If_alt Mod.simps
apply -
apply (drule quantitative_frame_rule_aux)
apply(rule order.trans[OF _ sub_distributivity_of_star_over_inf'])
apply(subst theorem_3_11_3')
subgoal
unfolding emb\<^sub>p_alt pure\<^sub>p_alt by auto
apply(subst theorem_3_11_3')
subgoal
unfolding emb\<^sub>p_alt pure\<^sub>p_alt by auto
apply(rule inf_mono)
subgoal
(* supply [[unify_trace_failure]] *)
apply(rule le_funI)
apply(simp only: plus_fun_def)
apply(rule add_left_mono) by (auto simp add: le_fun_def)
subgoal
(* supply [[unify_trace_failure]] *)
apply(rule le_funI)
apply(simp only: plus_fun_def)
apply(rule add_left_mono) by (auto simp add: le_fun_def)
done
next
case (While x1 c)
let ?f = "(\<lambda>Y (s, h). 1 + (if x1 s then ert c Y (s, h) else (\<Psi> \<star>\<^sub>p \<Pi>) (s, h)))"
let ?g = "(\<lambda>Y (s, h). 1 + (if x1 s then ert c Y (s, h) else \<Psi> (s, h)))"
have fg: "mono ?f" "mono ?g"
by (auto intro!: monoI ert_mono le_funI ert_mono[THEN le_funD])
thm lfp_lockstep_induct[where f="?f"]
show ?case
apply clarsimp
proof(induct rule: lfp_lockstep_induct[where f="?f" and g="?g"])
case monof
then show ?case using fg by simp
next
case monog
then show ?case using fg by simp
next
case (step A B)
have *: "\<And>a b. Inf {ert c B (a, x) + \<Pi> (a, y) |x y. b = x + y \<and> x ## y}
= Inf ((\<lambda>(x,y). ert c B (a, x) + \<Pi> (a, y))`{(x,y)|x y. b = x + y \<and> x ## y})"
apply(rule arg_cong[where f=Inf]) by auto
have **: "\<And>a b. Inf {1+ ert c B (a, x) + \<Pi> (a, y) |x y. b = x + y \<and> x ## y}
= Inf ((\<lambda>(x,y). 1+ ert c B (a, x) + \<Pi> (a, y))`{(x,y)|x y. b = x + y \<and> x ## y})"
apply(rule arg_cong[where f=Inf]) by auto
have ***: "\<And>a b. Inf {\<Psi> (a, x) + \<Pi> (a, y) |x y. b = x + y \<and> x ## y}
= Inf ((\<lambda>(x,y). \<Psi> (a, x) + \<Pi> (a, y))`{(x,y)|x y. b = x + y \<and> x ## y})"
apply(rule arg_cong[where f=Inf]) by auto
have ****: "\<And>a b. Inf {1 + \<Psi> (a, x) + \<Pi> (a, y) |x y. b = x + y \<and> x ## y}
= Inf ((\<lambda>(x,y). 1 + \<Psi> (a, x) + \<Pi> (a, y))`{(x,y)|x y. b = x + y \<and> x ## y})"
apply(rule arg_cong[where f=Inf]) by auto
show ?case
apply -
apply (rule le_funI)
apply auto
apply(rule order.trans)
apply(rule add_left_mono)
apply(rule ert_mono')
apply(rule step(3))
apply(rule order.trans)
apply(rule add_left_mono)
apply(rule While(1)[THEN le_funD])
subgoal using While(2) by auto
subgoal unfolding star_pot_method_alt
apply auto
unfolding *
apply(subst INF_ennreal_const_add'')
unfolding **
apply(rule INF_mono) by force
subgoal unfolding star_pot_method_alt
apply auto
unfolding ***
apply(subst INF_ennreal_const_add'')
unfolding ****
apply(rule INF_mono) by force
done
next
case (union M)
show ?case
unfolding fst_proj_def snd_proj_def
apply(rule Sup_least) apply auto
subgoal for A B
using union[rule_format, of "(A,B)"] apply simp
apply(rule order.trans)
apply(assumption)
apply(rule le_funI)
apply(rule star_pot_method_mono) apply(rule Sup_upper) by auto
done
qed
next
case (New x1 x2)
then have tt: "\<And>y a ma . \<Pi> (a(x1 := ma), y) = \<Pi> (a, y)"
by (simp add: not_in_Vars_upd_okay)
show ?case
unfolding ert_New_alt
apply(rule le_funI)
apply(subst (1) star_pot_method_assoc[symmetric])
apply(subst (4) star_pot_method_commute)
apply(subst (1) star_pot_method_assoc)
apply(rule star_pot_method_mono[rotated]) apply simp
apply simp
apply(case_tac sh) apply simp
proof -
fix s h
have " Supl UNIV (\<lambda>a. ([(\<lambda>_. a) \<mapsto> x2] -\<star>\<^sub>p (\<lambda>(s, h). (\<Psi> \<star>\<^sub>p \<Pi>) (s(x1 := a), h))) (s,h))
\<le> Supl UNIV (\<lambda>x. ([(\<lambda>_. x) \<mapsto> x2] -\<star>\<^sub>p
(\<lambda>(s, h). Infl {(x, y). h = x + y \<and> x ## y}
(\<lambda>(xa, y). \<Psi> (s(x1 := x), xa) + \<Pi> (s(x1 := x), y)))) (s,h))"
unfolding star_pot_method_alt'' by simp
also have "\<dots> \<le> Supl UNIV (\<lambda>x. ([(\<lambda>_. x) \<mapsto> x2] -\<star>\<^sub>p (\<lambda>(s, h). Infl {(x, y). h = x + y \<and> x ## y} (\<lambda>(xa, y). \<Psi> (s(x1 := x), xa) + \<Pi> (s, y)))) (s,h))"
apply(subst tt) by simp
also have "\<dots> \<le> Supl UNIV (\<lambda>x. Supl {h'. h ## h' \<and> ptb (\<lambda>_. x) x2 (s, h')}
(\<lambda>h'. Infl {(h1, h2). h + h' = h1 + h2 \<and> h1 ## h2} (\<lambda>(h1, h2). \<Psi> (s(x1 := x), h1) + \<Pi> (s, h2))))"
unfolding pt_emb wand_pot_method_emb_alt by simp
also have "\<dots> \<le> Supl UNIV (\<lambda>x. Supl {h'. h ## h' \<and> ptb (\<lambda>_. x) x2 (s, h')}
(\<lambda>h'. Infl {(h1, h2). h = h1 + h2 \<and> h1 ## h2} (\<lambda>(h1, h2). \<Psi> (s(x1 := x), h1 + h') + \<Pi> (s, h2))))"
\<comment> \<open>choose h' \<subseteq> h1\<close>
apply(rule SUP_mono)
apply auto
subgoal for x
apply(rule exI[where x=x])
apply(rule SUP_mono) apply auto
subgoal for h'
apply(rule exI[where x="h'"]) apply auto
apply(rule INF_mono) apply auto
subgoal for a b apply(rule exI[where x="a + h'"])
apply(rule exI[where x="b"]) apply auto
subgoal
by (metis sep_add_assoc sep_add_commute sep_add_disjD sep_add_disjI1)
subgoal
using sep_add_disjI1 by blast
done
done
done
done
also have "\<dots> \<le> Infl {(x, y). h = x + y \<and> x ## y} (\<lambda>x. case x of (x, y) \<Rightarrow> Supl UNIV (\<lambda>xa. Supl {h'. x ## h' \<and> ptb (\<lambda>_. xa) x2 (s, h')} (\<lambda>xaa. \<Psi> (s(x1 := xa), x + xaa)+ \<Pi> (s, y))) )"
apply(rule order.trans)
apply(rule SUP_mono')
apply(rule qfr_aux1)
apply(rule order.trans)
apply(rule qfr_aux1)
apply(rule INF_mono)
subgoal for m
apply(rule bexI[where x=m]) apply auto
apply(rule SUP_mono) apply auto
subgoal for x y a apply(rule exI[where x=a])
apply(rule Sup_mono)
apply auto
using sep_add_disjD by blast
done
done
also have "\<dots> \<le> Infl {(x, y). h = x + y \<and> x ## y} (\<lambda>x. case x of (x, y) \<Rightarrow> Supl UNIV (\<lambda>xa. Supl {h'. x ## h' \<and> ptb (\<lambda>_. xa) x2 (s, h')} (\<lambda>xaa. \<Psi> (s(x1 := xa), x + xaa))) + \<Pi> (s, y))"
apply(rule INF_mono)
subgoal for m
apply(rule bexI[where x=m])
apply auto
apply(rule order.trans[rotated])
apply(rule ennreal_SUP_add_left_le)
apply(rule SUP_mono)
subgoal for x y u
apply(rule bexI[where x=u]) apply auto
apply(rule ennreal_SUP_add_left_le) done
done
done
also have "\<dots> \<le> Infl {(x, y). h = x + y \<and> x ## y} (\<lambda>x. case x of (x, y) \<Rightarrow> Supl UNIV (\<lambda>a. ([(\<lambda>_. a) \<mapsto> x2] -\<star>\<^sub>p (\<lambda>(s, h). \<Psi> (s(x1 := a), h))) (s, x)) + \<Pi> (s, y))"
unfolding pt_emb wand_pot_method_emb_alt apply simp done
also have "\<dots> \<le> ((\<lambda>(s, h). Supl UNIV (\<lambda>a. ([(\<lambda>_. a) \<mapsto> x2] -\<star>\<^sub>p (\<lambda>(s, h). \<Psi> (s(x1 := a), h))) (s, h))) \<star>\<^sub>p \<Pi>) (s,h)"
unfolding star_pot_method_alt'' apply simp done
finally show " Supl UNIV (\<lambda>a. ([(\<lambda>_. a) \<mapsto> x2] -\<star>\<^sub>p (\<lambda>(s, h). (\<Psi> \<star>\<^sub>p \<Pi>) (s(x1 := a), h))) (s,h))
\<le> ((\<lambda>(s, h). Supl UNIV (\<lambda>a. ([(\<lambda>_. a) \<mapsto> x2] -\<star>\<^sub>p (\<lambda>(s, h). \<Psi> (s(x1 := a), h))) (s, h))) \<star>\<^sub>p \<Pi>) (s,h)"
.
qed
next
case (Free x)
then show ?case
apply simp
apply(rule le_funI)
unfolding plus_as_dollar_conv' plus_as_dollar_conv
by(auto simp: star_pot_method_commute star_pot_method_commute_c)
next
case (Lookup x1 x2)
then have tt: "\<And>y a ma . \<Pi> (a(x1 := ma), y) = \<Pi> (a, y)"
by (simp add: not_in_Vars_upd_okay)
show ?case
unfolding ert_Lookup_alt'