-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterval_Rat.thy
2150 lines (2047 loc) · 107 KB
/
Interval_Rat.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
theory Interval_Rat
imports
Complex_Main
"./Syntax"
begin
(*datatype num =
POS_INF
| NEG_INF
| RAT rat*)
type_synonym num = rat
type_synonym rstate = "ident \<Rightarrow> real"
type_synonym nstate = "(ident + ident) \<Rightarrow> num"
named_theorems rep_simps "Simplifications for representation functions"
(* Note: 0x80000000 is never used. This way there's no awkward asymmetry but I can still use existing
* support for 2's complement *)
(*inductive repe ::"word \<Rightarrow> real \<Rightarrow> bool" (infix "\<equiv>\<^sub>E" 10)
where
repPOS_INF:"r \<ge> real_of_int (sint POS_INF) \<Longrightarrow> repe POS_INF r"
| repNEG_INF:"r \<le> real_of_int (sint NEG_INF) \<Longrightarrow> repe NEG_INF r"
| repINT: "(sint w) < real_of_int(sint POS_INF) \<Longrightarrow> (sint w) > real_of_int(sint NEG_INF) \<Longrightarrow> repe w (sint w)"*)
(*
inductive_simps
repePos_simps[rep_simps]:"repe POS_INF r"
and repeNeg_simps[rep_simps]:"repe NEG_INF r"
and repeInt_simps[rep_simps]:"repe w (sint w)"
*)
definition repU ::"num \<Rightarrow> real \<Rightarrow> bool" (infix "\<equiv>\<^sub>U" 10)
where "repU num r \<equiv> Ratreal num \<ge> r"
lemma repU_leq:"repU num r \<Longrightarrow> r \<le> Ratreal num "
unfolding repU_def
using order_trans by auto
definition repL ::"word \<Rightarrow> real \<Rightarrow> bool" (infix "\<equiv>\<^sub>L" 10)
where "repL w r \<equiv> Ratreal w \<le> r "
lemma repL_geq:"repL w r \<Longrightarrow> r' \<ge> r \<Longrightarrow> repL w r'"
unfolding repL_def
using order_trans by auto
definition repP ::"word * word \<Rightarrow> real \<Rightarrow> bool" (infix "\<equiv>\<^sub>P" 10)
where "repP w r \<equiv> let (w1, w2) = w in repL w1 r \<and> repU w2 r"
inductive rtsem :: "trm \<Rightarrow> rstate \<Rightarrow> real \<Rightarrow> bool" ("([_]_ \<down> _)" 10)
where
rtsem_Const:"([Const q]\<nu> \<down> Ratreal q)"
| rtsem_Var:"([Var x]\<nu> \<down> \<nu> x)"
| rtsem_Plus:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> ([Plus \<theta>\<^sub>1 \<theta>\<^sub>2]\<nu> \<down> (r\<^sub>1 + r\<^sub>2))"
| rtsem_Times:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> ([Times \<theta>\<^sub>1 \<theta>\<^sub>2]\<nu> \<down> (r\<^sub>1 * r\<^sub>2))"
| rtsem_Div:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> ([Div \<theta>\<^sub>1 \<theta>\<^sub>2]\<nu> \<down> (r\<^sub>1 / r\<^sub>2))"
| rtsem_Max:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> ([Max \<theta>\<^sub>1 \<theta>\<^sub>2]\<nu> \<down> (max r\<^sub>1 r\<^sub>2))"
| rtsem_Min:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> ([Min \<theta>\<^sub>1 \<theta>\<^sub>2]\<nu> \<down> (min r\<^sub>1 r\<^sub>2))"
| rtsem_Abs:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1)\<rbrakk> \<Longrightarrow> ([Abs \<theta>\<^sub>1]\<nu> \<down> (abs r\<^sub>1))"
| rtsem_Neg:"([\<theta>]\<nu> \<down> r) \<Longrightarrow> ([Neg \<theta>]\<nu> \<down> -r)"
inductive_simps
rtsem_Const_simps[simp] : "([(Const w)]\<nu> \<down> r)"
and rtsem_Var_simps[simp] : "([Var x]\<nu> \<down> r)"
and rtsem_PlusU_simps[simp] : "([Plus \<theta>\<^sub>1 \<theta>\<^sub>2]\<nu> \<down> r)"
and rtsem_TimesU_simps[simp] : "([Times \<theta>\<^sub>1 \<theta>\<^sub>2]\<nu> \<down> r)"
and rtsem_Abs_simps[simp] : "([Abs \<theta>] \<nu> \<down> r)"
and rtsem_Max_simps[simp] : "([Max \<theta>\<^sub>1 \<theta>\<^sub>2] \<nu> \<down> r)"
and rtsem_Min_simps[simp] : "([Min \<theta>\<^sub>1 \<theta>\<^sub>2] \<nu> \<down> r)"
and rtsem_Div_simps[simp] : "([Div \<theta>\<^sub>1 \<theta>\<^sub>2] \<nu> \<down> r)"
and rtsem_Neg_simps[simp] : "([Neg \<theta>] \<nu> \<down> r)"
definition set_less :: "real set \<Rightarrow> real set \<Rightarrow> bool" (infix "<\<^sub>S" 10)
where "set_less A B \<equiv> (\<forall> x y. x \<in> A \<and> y \<in> B \<longrightarrow> x < y)"
definition set_geq :: "real set \<Rightarrow> real set \<Rightarrow> bool" (infix "\<ge>\<^sub>S" 10)
where "set_geq A B \<equiv> (\<forall> x y. x \<in> A \<and> y \<in> B \<longrightarrow> x \<ge> y)"
inductive rfsem :: "formula \<Rightarrow> rstate \<Rightarrow> bool \<Rightarrow> bool" ("([_]_) \<downharpoonright> _" 20)
where
rLeT:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> r\<^sub>1 < r\<^sub>2 \<Longrightarrow> ([Le \<theta>\<^sub>1 \<theta>\<^sub>2] \<nu> \<downharpoonright> True)"
| rLeF:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> r\<^sub>1 \<ge> r\<^sub>2 \<Longrightarrow> ([Le \<theta>\<^sub>1 \<theta>\<^sub>2] \<nu> \<downharpoonright> False)"
| rLeqT:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> r\<^sub>1 \<le> r\<^sub>2 \<Longrightarrow> ([Leq \<theta>\<^sub>1 \<theta>\<^sub>2] \<nu> \<downharpoonright> True)"
| rLeqF:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> r\<^sub>1 > r\<^sub>2 \<Longrightarrow> ([Leq \<theta>\<^sub>1 \<theta>\<^sub>2] \<nu> \<downharpoonright> False)"
| rEqualsT:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> r\<^sub>1 = r\<^sub>2 \<Longrightarrow> ([Equals \<theta>\<^sub>1 \<theta>\<^sub>2] \<nu> \<downharpoonright> True)"
| rEqualsF:"\<lbrakk>([\<theta>\<^sub>1]\<nu> \<down> r\<^sub>1); ([\<theta>\<^sub>2]\<nu> \<down> r\<^sub>2)\<rbrakk> \<Longrightarrow> r\<^sub>1 \<noteq> r\<^sub>2 \<Longrightarrow> ([Equals \<theta>\<^sub>1 \<theta>\<^sub>2] \<nu> \<downharpoonright> False)"
| rAndT:"\<lbrakk>([\<phi>]\<nu> \<downharpoonright> True); ([\<psi>]\<nu> \<downharpoonright> True)\<rbrakk> \<Longrightarrow> ([And \<phi> \<psi>]\<nu> \<downharpoonright> True)"
| rAndF1:"([\<phi>]\<nu> \<downharpoonright> False) \<Longrightarrow> ([And \<phi> \<psi>]\<nu> \<downharpoonright> False)"
| rAndF2:"([\<psi>]\<nu> \<downharpoonright> False) \<Longrightarrow> ([And \<phi> \<psi>]\<nu> \<downharpoonright> False)"
| rOrT1:"([\<phi>]\<nu> \<downharpoonright> True) \<Longrightarrow> ([Or \<phi> \<psi>]\<nu> \<downharpoonright> True)"
| rOrT2:"([\<psi>]\<nu> \<downharpoonright> True) \<Longrightarrow> ([Or \<phi> \<psi>]\<nu> \<downharpoonright> True)"
| rOrF:"\<lbrakk>([\<phi>]\<nu> \<downharpoonright> False) ;([\<psi>]\<nu> \<downharpoonright> False)\<rbrakk> \<Longrightarrow> ([And \<phi> \<psi>]\<nu> \<downharpoonright> False)"
| rNotT:"([\<phi>]\<nu> \<downharpoonright> False) \<Longrightarrow> ([(Not \<phi>)]\<nu> \<downharpoonright> True)"
| rNotF:"([\<phi>]\<nu> \<downharpoonright> True) \<Longrightarrow> ([(Not \<phi>)]\<nu> \<downharpoonright> False)"
inductive_simps
rfsem_Gr_simps[simp]: "([Le \<theta>\<^sub>1 \<theta>\<^sub>2]\<nu> \<downharpoonright> b)"
and rfsem_Leq_simps[simp]: "([Leq \<theta>\<^sub>1 \<theta>\<^sub>2]\<nu> \<downharpoonright> b)"
and rfsem_Equals_simps[simp]: "([Equals \<theta>\<^sub>1 \<theta>\<^sub>2]\<nu> \<downharpoonright> b)"
and rfsem_And_simps[simp]: "([And \<phi> \<psi>]\<nu> \<downharpoonright> b)"
and rfsem_Or_simps[simp]: "([(Or \<phi> \<psi>)]\<nu> \<downharpoonright> b)"
and rfsem_Not_simps[simp]: "([Not \<phi>]\<nu> \<downharpoonright> b)"
inductive rpsem :: "hp \<Rightarrow> rstate \<Rightarrow> rstate \<Rightarrow> bool" ("([_]_) \<downharpoonleft> _" 20)
where
rTest[simp]:"\<lbrakk>([\<phi>]\<nu> \<downharpoonright> True); \<nu> = \<omega>\<rbrakk> \<Longrightarrow> ([? \<phi>]\<nu> \<downharpoonleft> \<omega>)"
| rSeq[simp]:"\<lbrakk>([\<alpha>]\<nu> \<downharpoonleft> \<mu>); ([\<beta>]\<mu> \<downharpoonleft> \<omega>)\<rbrakk> \<Longrightarrow> ([\<alpha>;; \<beta>]\<nu> \<downharpoonleft> \<omega>)"
| rAssign[simp]:"\<lbrakk>([\<theta>]\<nu> \<down> r); \<omega> = (\<nu> (x := r))\<rbrakk> \<Longrightarrow> ([Assign x \<theta>]\<nu> \<downharpoonleft> \<omega>)"
| rChoice1[simp]:"([\<alpha>]\<nu> \<downharpoonleft> \<omega>) \<Longrightarrow> ([Choice \<alpha> \<beta>]\<nu> \<downharpoonleft> \<omega>)"
| rChoice2[simp]:"([\<beta>]\<nu> \<downharpoonleft> \<omega>) \<Longrightarrow> ([Choice \<alpha> \<beta>]\<nu> \<downharpoonleft> \<omega>)"
inductive_simps
rpsem_Test_simps[simp]: "([? \<phi>]\<nu> \<downharpoonleft> b)"
and rpsem_Seq_simps[simp]: "([\<alpha>;; \<beta>]\<nu> \<downharpoonleft> b)"
and rpsem_Assign_simps[simp]: "([Assign x \<theta>]\<nu> \<downharpoonleft> b)"
and rpsem_Choice_simps[simp]: "([Choice \<alpha> \<beta>]\<nu> \<downharpoonleft> b)"
lemma int_not_posinf:
assumes b1:"real_of_int (sint ra) < real_of_int (sint POS_INF)"
assumes b2:"real_of_int (sint NEG_INF) < real_of_int (sint ra)"
shows "ra \<noteq> POS_INF"
using b1 b2 unfolding POS_INF_def NEG_INF_def by auto
lemma int_not_neginf:
assumes b1:" real_of_int (sint ra) < real_of_int (sint POS_INF)"
assumes b2:" real_of_int (sint NEG_INF) < real_of_int (sint ra)"
shows "ra \<noteq> NEG_INF"
using b1 b2 unfolding POS_INF_def NEG_INF_def by auto
fun pu :: "word \<Rightarrow> word \<Rightarrow> word"
where "pu w1 w2 = w1 + w2"
(*
quotient_type real = "nat \<Rightarrow> rat" / partial: realrel
morphisms rep_real Real
by (rule part_equivp_realrel)
*)
lemma pu_lemma:
assumes up1:"w\<^sub>1 \<equiv>\<^sub>U (r\<^sub>1::real)"
assumes up2:"w\<^sub>2 \<equiv>\<^sub>U (r\<^sub>2::real)"
shows "pu w\<^sub>1 w\<^sub>2 \<equiv>\<^sub>U (r\<^sub>1 + r\<^sub>2)"
proof -
have hom:"\<And>x y. (real_of_rat x \<le> real_of_rat y) = (x \<le> y)"
using real_less_eq_code by auto
have plus:"Real.Real (\<lambda>n. rep_real r\<^sub>1 n) + Real.Real (\<lambda>n. rep_real r\<^sub>2 n)
= Real.Real (\<lambda>n. rep_real r\<^sub>1 n + rep_real r\<^sub>2 n)"
apply(rule add_Real)
by (metis Quotient_real Quotient_rel_rep realrel_def)+
then have rev:"Real.Real (\<lambda>n. rep_real r\<^sub>1 n + rep_real r\<^sub>2 n) = Real.Real (\<lambda>n. rep_real r\<^sub>1 n) + Real.Real (\<lambda>n. rep_real r\<^sub>2 n)"
by auto
from up1 up2 have u1:"r\<^sub>1 \<le> real_of_rat w\<^sub>1"
and u2:"r\<^sub>2 \<le> real_of_rat w\<^sub>2" unfolding repU_def by auto
have cancel:"\<And>x. Real.Real (rep_real x) = x"
using Quotient_real Quotient_rel_rep realrel_def Quotient_abs_rep by fastforce
show ?thesis
apply(auto simp add: repU_def)
apply(auto simp add: plus_real_def)
apply(auto simp add: rev cancel)
using u1 u2 by (simp add: add_mono_thms_linordered_semiring(1) of_rat_add)
qed
fun pl :: "word \<Rightarrow> word \<Rightarrow> word"
where "pl w1 w2 = w1 + w2"
lemma pl_lemma:
assumes lo1:"w\<^sub>1 \<equiv>\<^sub>L (r\<^sub>1::real)"
assumes lo2:"w\<^sub>2 \<equiv>\<^sub>L (r\<^sub>2::real)"
shows "pl w\<^sub>1 w\<^sub>2 \<equiv>\<^sub>L (r\<^sub>1 + r\<^sub>2)"
proof -
have hom:"\<And>x y. (real_of_rat x \<le> real_of_rat y) = (x \<le> y)"
using real_less_eq_code by auto
have plus:"Real.Real (\<lambda>n. rep_real r\<^sub>1 n) + Real.Real (\<lambda>n. rep_real r\<^sub>2 n)
= Real.Real (\<lambda>n. rep_real r\<^sub>1 n + rep_real r\<^sub>2 n)"
apply(rule add_Real)
by (metis Quotient_real Quotient_rel_rep realrel_def)+
then have rev:"Real.Real (\<lambda>n. rep_real r\<^sub>1 n + rep_real r\<^sub>2 n) = Real.Real (\<lambda>n. rep_real r\<^sub>1 n) + Real.Real (\<lambda>n. rep_real r\<^sub>2 n)"
by auto
from lo1 lo2 have l1:"real_of_rat w\<^sub>1 \<le> r\<^sub>1"
and l2:"real_of_rat w\<^sub>2 \<le> r\<^sub>2" unfolding repL_def by auto
have cancel:"\<And>x. Real.Real (rep_real x) = x"
using Quotient_real Quotient_rel_rep realrel_def Quotient_abs_rep by fastforce
show ?thesis
apply(auto simp add: repU_def)
apply(auto simp add: plus_real_def)
apply(auto simp add: rev cancel)
using add_mono_thms_linordered_semiring
by (metis lo1 lo2 real_plus_code repL_def)
qed
fun wmax :: "word \<Rightarrow> word \<Rightarrow> word"
where "wmax w\<^sub>1 w\<^sub>2 = (if w\<^sub>1 < w\<^sub>2 then w\<^sub>2 else w\<^sub>1)"
lemma wmax_lemma:
assumes eq1:"(Ratreal w\<^sub>1 = r\<^sub>1)"
assumes eq2:"(Ratreal w\<^sub>2 = r\<^sub>2)"
shows "Ratreal (wmax w\<^sub>1 w\<^sub>2) = (max r\<^sub>1 r\<^sub>2)"
proof -
from eq1 eq2 have e1:"real_of_rat w\<^sub>1 = r\<^sub>1"
and e2:"real_of_rat w\<^sub>2 = r\<^sub>2" unfolding repL_def by auto
have leq_imp:"w\<^sub>1 < w\<^sub>2 \<Longrightarrow> real_of_rat w\<^sub>1 < real_of_rat w\<^sub>2"
by (simp add: of_rat_less)
have nleq_imp:"\<not>(w\<^sub>1 < w\<^sub>2) \<Longrightarrow> \<not>(real_of_rat w\<^sub>1 < real_of_rat w\<^sub>2)"
by (simp add: of_rat_less)
show ?thesis
apply(auto)
using e1 e2 leq_imp nleq_imp by linarith+
qed
fun wtimes :: "word \<Rightarrow> word \<Rightarrow> word"
where "wtimes w1 w2 = w1 * w2"
lemma wtimes_exact:
assumes eq1:"Ratreal w1 = r1"
assumes eq2:"Ratreal w2 = r2"
shows "Ratreal (wtimes w1 w2) = r1 * r2"
proof -
from eq1 eq2 have e1:"real_of_rat w1 = r1"
and e2:"real_of_rat w2 = r2" unfolding repL_def by auto
have leq_imp:"w1 < w2 \<Longrightarrow> real_of_rat w1 < real_of_rat w2"
by (simp add: of_rat_less)
have nleq_imp:"\<not>(w1 < w2) \<Longrightarrow> \<not>(real_of_rat w1 < real_of_rat w2)"
by (simp add: of_rat_less)
show ?thesis
using e1 e2 apply(auto)
by (simp add: of_rat_mult)
qed
fun tu :: "word \<Rightarrow> word \<Rightarrow> word \<Rightarrow> word \<Rightarrow> word"
where "tu w1l w1u w2l w2u =
wmax (wmax (wtimes w1l w2l) (wtimes w1u w2l))
(wmax (wtimes w1l w2u) (wtimes w1u w2u))"
lemma max_repU1:
assumes up1:"w\<^sub>1 \<equiv>\<^sub>U r\<^sub>1"
assumes up2:"w\<^sub>2 \<equiv>\<^sub>U r\<^sub>2"
shows "wmax w\<^sub>1 w\<^sub>2 \<equiv>\<^sub>U r\<^sub>1"
using wmax_lemma assms repU_def
using le_max_iff_disj
proof -
have hom:"\<And>x y. (real_of_rat x \<le> real_of_rat y) = (x \<le> y)"
using real_less_eq_code by auto
from up1 up2 have u1:"r\<^sub>1 \<le> real_of_rat w\<^sub>1"
and u2:"r\<^sub>2 \<le> real_of_rat w\<^sub>2" unfolding repU_def by auto
have cancel:"\<And>x. Real.Real (rep_real x) = x"
using Quotient_real Quotient_rel_rep realrel_def Quotient_abs_rep by fastforce
show ?thesis
apply(auto simp add: repU_def)
by (meson less_eq_rat_def of_rat_less_eq order_trans u1)+
qed
lemma max_repU2:
assumes up1:"w\<^sub>1 \<equiv>\<^sub>U r\<^sub>1"
assumes up2:"w\<^sub>2 \<equiv>\<^sub>U r\<^sub>2"
shows "wmax w\<^sub>1 w\<^sub>2 \<equiv>\<^sub>U r\<^sub>2"
proof -
have hom:"\<And>x y. (real_of_rat x \<le> real_of_rat y) = (x \<le> y)"
using real_less_eq_code by auto
from up1 up2 have u1:"r\<^sub>1 \<le> real_of_rat w\<^sub>1"
and u2:"r\<^sub>2 \<le> real_of_rat w\<^sub>2" unfolding repU_def by auto
have cancel:"\<And>x. Real.Real (rep_real x) = x"
using Quotient_real Quotient_rel_rep realrel_def Quotient_abs_rep by fastforce
show ?thesis
apply(auto simp add: repU_def)
using less_eq_rat_def of_rat_less_eq order_trans u1 u2 apply blast
using less_eq_rat_def of_rat_less_eq order_trans u1 u2 le_cases order_trans less_eq_rat_def
by metis
qed
lemma ivl_zero_case:
fixes l1 u1 l2 u2 :: real
assumes ivl1:"l1 \<le> u1"
assumes ivl2:"l2 \<le> u2"
shows
"(l1 \<le> 0 \<and> 0 \<le> u1 \<and> l2 \<le> 0 \<and> 0 \<le> u2)
\<or>(l1 \<le> 0 \<and> 0 \<le> u1 \<and> 0 \<le> l2)
\<or>(l1 \<le> 0 \<and> 0 \<le> u1 \<and> u2 \<le> 0)
\<or>(0 \<le> l1 \<and> l2 \<le> 0 \<and> 0 \<le> u2)
\<or>(u1 \<le> 0 \<and> l2 \<le> 0 \<and> 0 \<le> u2)
\<or>(u1 \<le> 0 \<and> u2 \<le> 0)
\<or>(u1 \<le> 0 \<and> 0 \<le> l2)
\<or>(0 \<le> l1 \<and> u2 \<le> 0)
\<or>(0 \<le> l1 \<and> 0 \<le> l2)"
using ivl1 ivl2
by (metis le_cases)
lemma case_ivl_zero:
fixes l1 u1 l2 u2 :: real
assumes ivl1:"l1 \<le> u1"
assumes ivl2:"l2 \<le> u2"
shows
"((l1 \<le> 0 \<and> 0 \<le> u1 \<and> l2 \<le> 0 \<and> 0 \<le> u2) \<Longrightarrow> P) \<Longrightarrow>
((l1 \<le> 0 \<and> 0 \<le> u1 \<and> 0 \<le> l2) \<Longrightarrow> P) \<Longrightarrow>
((l1 \<le> 0 \<and> 0 \<le> u1 \<and> u2 \<le> 0) \<Longrightarrow> P) \<Longrightarrow>
((0 \<le> l1 \<and> l2 \<le> 0 \<and> 0 \<le> u2) \<Longrightarrow> P) \<Longrightarrow>
((u1 \<le> 0 \<and> l2 \<le> 0 \<and> 0 \<le> u2) \<Longrightarrow> P) \<Longrightarrow>
((u1 \<le> 0 \<and> u2 \<le> 0) \<Longrightarrow> P) \<Longrightarrow>
((u1 \<le> 0 \<and> 0 \<le> l2) \<Longrightarrow> P) \<Longrightarrow>
((0 \<le> l1 \<and> u2 \<le> 0) \<Longrightarrow> P) \<Longrightarrow>
((0 \<le> l1 \<and> 0 \<le> l2) \<Longrightarrow> P) \<Longrightarrow> P"
using ivl1 ivl2
by (metis le_cases)
lemmas silly_lemma = mult_le_cancel_left
lemmas real_mult_le_mult_iff = silly_lemma
lemma tu_lemma:
assumes u1:"u\<^sub>1 \<equiv>\<^sub>U (r\<^sub>1::real)"
assumes u2:"u\<^sub>2 \<equiv>\<^sub>U (r\<^sub>2::real)"
assumes l1:"l\<^sub>1 \<equiv>\<^sub>L (r\<^sub>1::real)"
assumes l2:"l\<^sub>2 \<equiv>\<^sub>L (r\<^sub>2::real)"
shows "tu l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>U (r\<^sub>1 * r\<^sub>2)"
proof -
obtain rl1 rl2 ru1 ru2 :: real
where gru1:"ru1 \<ge> r\<^sub>1" and gru2:"ru2 \<ge> r\<^sub>2" and grl1:"rl1 \<le> r\<^sub>1" and grl2:"rl2 \<le> r\<^sub>2"
and eru1:"Ratreal u\<^sub>1 = ru1" and eru2:"Ratreal u\<^sub>2 = ru2" and erl1:"Ratreal l\<^sub>1 = rl1" and erl2:"Ratreal l\<^sub>2 = rl2"
using u1 u2 l1 l2 unfolding repU_def repL_def by auto
have timesuu:"(Ratreal (wtimes u\<^sub>1 u\<^sub>2)::real) = ((ru1 * ru2)::real)"
using wtimes_exact[OF eru1 eru2]
by(auto simp add: of_rat_Real)
have timesul:"Ratreal (wtimes u\<^sub>1 l\<^sub>2) = ru1 * rl2"
using wtimes_exact[OF eru1 erl2] by auto
have timeslu:"Ratreal (wtimes l\<^sub>1 u\<^sub>2) = rl1 * ru2"
using wtimes_exact[OF erl1 eru2] by auto
have timesll:"Ratreal (wtimes l\<^sub>1 l\<^sub>2) = rl1 * rl2"
using wtimes_exact[OF erl1 erl2] by auto
have maxt12:"Ratreal (wmax (wtimes l\<^sub>1 l\<^sub>2) (wtimes u\<^sub>1 l\<^sub>2)) = max (rl1 * rl2) (ru1 * rl2)"
by (rule wmax_lemma[OF timesll timesul])
have maxt34:"Ratreal (wmax (wtimes l\<^sub>1 u\<^sub>2) (wtimes u\<^sub>1 u\<^sub>2)) = max (rl1 * ru2) (ru1 * ru2)"
by (rule wmax_lemma[OF timeslu timesuu])
have bigMax:"Ratreal (wmax (wmax (wtimes l\<^sub>1 l\<^sub>2) (wtimes u\<^sub>1 l\<^sub>2)) (wmax (wtimes l\<^sub>1 u\<^sub>2) (wtimes u\<^sub>1 u\<^sub>2)))
= max (max (rl1 * rl2) (ru1 * rl2)) (max (rl1 * ru2) (ru1 * ru2))"
by (rule wmax_lemma[OF maxt12 maxt34])
obtain maxt12val :: real where maxU12:"wmax (wtimes l\<^sub>1 l\<^sub>2) (wtimes u\<^sub>1 l\<^sub>2) \<equiv>\<^sub>U max (rl1 * rl2) (ru1 * rl2)"
using maxt12 unfolding repU_def by auto
obtain maxt34val :: real where maxU34:"wmax (wtimes l\<^sub>1 u\<^sub>2) (wtimes u\<^sub>1 u\<^sub>2) \<equiv>\<^sub>U max (rl1 * ru2) (ru1 * ru2)"
using maxt34 unfolding repU_def by auto
obtain bigMaxU:"wmax (wmax (wtimes l\<^sub>1 l\<^sub>2) (wtimes u\<^sub>1 l\<^sub>2)) (wmax (wtimes l\<^sub>1 u\<^sub>2) (wtimes u\<^sub>1 u\<^sub>2))
\<equiv>\<^sub>U max (max (rl1 * rl2) (ru1 * rl2)) (max (rl1 * ru2) (ru1 * ru2))"
using bigMax unfolding repU_def by linarith
have ivl1:"rl1 \<le> ru1" using grl1 gru1 by auto
have ivl2:"rl2 \<le> ru2" using grl2 gru2 by auto
let ?thesis = "tu l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>U r\<^sub>1 * r\<^sub>2"
show ?thesis
apply(rule case_ivl_zero[OF ivl1 ivl2])
proof -
assume "rl1 \<le> 0 \<and> 0 \<le> ru1 \<and> rl2 \<le> 0 \<and> 0 \<le> ru2"
then have geq1:"ru1 \<ge> 0" and geq2:"ru2 \<ge> 0" by auto
have case1:"r\<^sub>1 \<ge> 0 \<Longrightarrow> r\<^sub>2 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<ge> 0"
assume r2:"r\<^sub>2 \<ge> 0"
have g1:"ru1 * ru2 \<ge> ru1 * r\<^sub>2"
using r1 geq1 geq2 grl2 gru2
by (simp add: mult_left_mono )
have g2:"ru1 * r\<^sub>2 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 geq1 geq2 grl1 grl2 gru1 gru2
by (simp add: mult_right_mono)
from g1 and g2
have up:"ru1 * ru2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up
eru1 eru2 erl1 erl2
max_repU2[OF maxU12]
max_repU2[OF maxU34]
max_repU2[OF bigMaxU]
repU_def timesuu tu.simps
by (metis wmax.elims)
qed
have case2:"r\<^sub>1 \<le> 0 \<Longrightarrow> r\<^sub>2 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<le> 0"
assume r2:"r\<^sub>2 \<ge> 0"
have g1:"ru1 * ru2 \<ge> 0"
using r1 geq1 geq2 grl2 gru2 by (simp)
have g2:"0 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 by (simp add: mult_le_0_iff)
from g1 and g2
have up:"ru1 * ru2 \<ge> r\<^sub>1 * r\<^sub>2" by auto
show ?thesis
using up
maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] repU_def tu.simps timesuu
by (metis max.coboundedI1 max.commute maxt34)
qed
have case3:"r\<^sub>1 \<ge> 0 \<Longrightarrow> r\<^sub>2 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<ge> 0"
assume r2:"r\<^sub>2 \<le> 0"
have g1:"ru1 * ru2 \<ge> 0"
using r1 geq1 geq2 grl2 gru2
by (simp)
have g2:"0 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2
by (simp add: mult_le_0_iff)
from g1 and g2
have up:"ru1 * ru2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up
maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.coboundedI1 max.commute maxt34
by (metis repU_def tu.simps)
qed
have case4:"r\<^sub>1 \<le> 0 \<Longrightarrow> r\<^sub>2 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<le> 0"
assume r2:"r\<^sub>2 \<le> 0"
have g1:"rl1 * rl2 \<ge> rl1 * r\<^sub>2"
using r1 r2 geq1 geq2 grl1 grl2 gru1 gru2
using \<open>rl1 \<le> 0 \<and> 0 \<le> ru1 \<and> rl2 \<le> 0 \<and> 0 \<le> ru2\<close> less_eq_real_def
by (metis mult_left_mono_neg)
have g2:"rl1 * r\<^sub>2 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 geq1 geq2 grl1 grl2 gru1 gru2 \<open>rl1 \<le> 0 \<and> 0 \<le> ru1 \<and> rl2 \<le> 0 \<and> 0 \<le> ru2\<close> mult.commute
by (metis mult_left_mono_neg)
from g1 and g2
have up:"rl1 * rl2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.commute maxt34
by (metis max_repU1 repU_def timesll tu.simps)
qed
show "tu l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>U r\<^sub>1 * r\<^sub>2"
using case1 case2 case3 case4 le_cases by blast
next
assume bounds:"rl1 \<le> 0 \<and> 0 \<le> ru1 \<and> 0 \<le> rl2"
have r2:"r\<^sub>2 \<ge> 0" using bounds dual_order.trans grl2 by blast
have case1:"r\<^sub>1 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<ge> 0"
have g1:"ru1 * ru2 \<ge> ru1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_left_mono by blast
have g2:"ru1 * r\<^sub>2 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_right_mono by blast
from g1 and g2
have up:"ru1 * ru2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.coboundedI1 max.commute maxt34
by (metis repU_def tu.simps)
qed
have case2:"r\<^sub>1 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<le> 0"
have g1:"ru1 * ru2 \<ge> 0"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_left_mono
by (simp add: mult_less_0_iff less_le_trans not_less)
have g2:"0 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_right_mono
by (simp add: mult_le_0_iff)
from g1 and g2
have up:"ru1 * ru2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.coboundedI1 max.commute maxt34
by (metis repU_def tu.simps)
qed
show "tu l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>U r\<^sub>1 * r\<^sub>2"
using case1 case2 le_cases by blast
next
assume bounds:"rl1 \<le> 0 \<and> 0 \<le> ru1 \<and> ru2 \<le> 0"
have r2:"r\<^sub>2 \<le> 0" using bounds dual_order.trans gru2 by blast
have case1:"r\<^sub>1 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<ge> 0"
have g1:"rl1 * rl2 \<ge> 0"
using r1 r2 bounds grl1 grl2 gru1 gru2 mult_less_0_iff less_le_trans not_less
by metis
have g2:"0 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_right_mono
by (simp add: mult_le_0_iff)
from g1 and g2
have up:"rl1 * rl2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.commute maxt34
by (metis max_repU2 max_repU1 repU_def timesll tu.simps)
qed
have case2:"r\<^sub>1 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<le> 0"
have g1:"rl1 * rl2 \<ge> rl1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
by (metis mult_left_mono_neg)
have g2:"rl1 * r\<^sub>2 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 mult.commute
by (metis mult_left_mono_neg)
from g1 and g2
have up:"rl1 * rl2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.commute maxt34
by (metis max_repU1 repU_def timesll tu.simps)
qed
show "tu l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>U r\<^sub>1 * r\<^sub>2"
using case1 case2 le_cases by blast
next
assume bounds:"0 \<le> rl1 \<and> rl2 \<le> 0 \<and> 0 \<le> ru2"
have r1:"r\<^sub>1 \<ge> 0" using bounds dual_order.trans grl1 by blast
have case1:"r\<^sub>2 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r2:"r\<^sub>2 \<ge> 0"
have g1:"ru1 * ru2 \<ge> ru1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_left_mono
using leD leI less_le_trans by metis
have g2:"ru1 * r\<^sub>2 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_right_mono by blast
from g1 and g2
have up:"ru1 * ru2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.coboundedI1 max.commute maxt34
by (metis repU_def tu.simps)
qed
have case2:"r\<^sub>2 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r2:"r\<^sub>2 \<le> 0"
have g1:"ru1 * ru2 \<ge> 0"
using r1 bounds grl2 gru2 gru1 leD leI less_le_trans by auto
have g2:"0 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2
by (simp add: mult_le_0_iff)
from g1 and g2
have up:"ru1 * ru2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.coboundedI1 max.commute maxt34
by (metis repU_def tu.simps)
qed
show "tu l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>U r\<^sub>1 * r\<^sub>2"
using case1 case2 le_cases by blast
next
assume bounds:"ru1 \<le> 0 \<and> rl2 \<le> 0 \<and> 0 \<le> ru2"
have r1:"r\<^sub>1 \<le> 0" using bounds dual_order.trans gru1 by blast
have case1:"r\<^sub>2 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r2:"r\<^sub>2 \<ge> 0"
have g1:"ru1 * rl2 \<ge> 0"
using r1 r2 bounds grl1 grl2 gru1 gru2 mult_less_0_iff not_less
by metis
have g2:"0 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
by (simp add: mult_le_0_iff)
from g1 and g2
have up:"ru1 * rl2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.commute maxt34
by (metis max_repU1 repU_def timesul tu.simps)
qed
have case2:"r\<^sub>2 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r2:"r\<^sub>2 \<le> 0"
have lower:"rl1 \<le> 0" using bounds dual_order.trans grl1 r1 by blast
have g1:"rl1 * rl2 \<ge> rl1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 less_eq(1) less_le_trans not_less silly_lemma
by metis
have g2:"rl1 * r\<^sub>2 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 mult.commute not_le lower silly_lemma
by metis
from g1 and g2
have up:"rl1 * rl2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.commute maxt34
by (metis max_repU1 repU_def timesll tu.simps)
qed
show "tu l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>U r\<^sub>1 * r\<^sub>2"
using case1 case2 le_cases by blast
next
assume bounds:"ru1 \<le> 0 \<and> ru2 \<le> 0"
have r1:"r\<^sub>1 \<le> 0" using bounds dual_order.trans gru1 by blast
have r2:"r\<^sub>2 \<le> 0" using bounds dual_order.trans gru2 by blast
have lower1:"rl1 \<le> 0" using bounds dual_order.trans grl1 r1 by blast
have lower2:"rl2 \<le> 0" using bounds dual_order.trans grl2 r2 by blast
have g1:"rl1 * rl2 \<ge> rl1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 less_eq(1) silly_lemma less_le_trans not_less
by metis
have g2:"rl1 * r\<^sub>2 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 mult.commute not_le lower1 lower2 silly_lemma
by metis
from g1 and g2
have up:"rl1 * rl2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.commute maxt34
by (metis max_repU1 repU_def timesll tu.simps)
next
assume bounds:"ru1 \<le> 0 \<and> 0 \<le> rl2"
have r1:"r\<^sub>1 \<le> 0" using bounds dual_order.trans gru1 by blast
have r2:"r\<^sub>2 \<ge> 0" using bounds dual_order.trans grl2 by blast
have lower1:"rl1 \<le> 0" using bounds dual_order.trans grl1 r1 by blast
have lower2:"rl2 \<ge> 0" using bounds by auto
have upper1:"ru1 \<le> 0" using bounds by auto
have upper2:"ru2 \<ge> 0" using bounds dual_order.trans gru2 r2 by blast
have g1:"ru1 * rl2 \<ge> ru1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 not_less upper1 lower2 silly_lemma
by metis
have g2:"ru1 * r\<^sub>2 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 upper1 r2 mult_right_mono gru1 by metis
from g1 and g2
have up:"ru1 * rl2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] maxt34
by (metis max_repU1 repU_def timesul tu.simps)
next
assume bounds:"0 \<le> rl1 \<and> ru2 \<le> 0"
have r1:"r\<^sub>1 \<ge> 0" using bounds dual_order.trans grl1 by blast
have r2:"r\<^sub>2 \<le> 0" using bounds dual_order.trans gru2 by blast
have lower1:"rl1 \<ge> 0" using bounds by auto
have lower2:"rl2 \<le> 0" using dual_order.trans grl2 r2 by blast
have upper1:"ru1 \<ge> 0" using dual_order.trans gru1 u1 r1 by blast
have upper2:"ru2 \<le> 0" using bounds by auto
have g1:"rl1 * ru2 \<ge> rl1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 not_less upper2 lower1 silly_lemma
by metis
have g2:"rl1 * r\<^sub>2 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 lower1 r2 not_less gru2 gru1 grl1 grl2
by (metis silly_lemma mult.commute)
from g1 and g2
have up:"rl1 * ru2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show "tu l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>U r\<^sub>1 * r\<^sub>2"
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.coboundedI1 max.commute maxt34
by (metis repU_def tu.simps)
next
assume bounds:"0 \<le> rl1 \<and> 0 \<le> rl2"
have r1:"r\<^sub>1 \<ge> 0" using bounds dual_order.trans grl1 by blast
have r2:"r\<^sub>2 \<ge> 0" using bounds dual_order.trans grl2 by blast
have lower1:"rl1 \<ge> 0" using bounds by auto
have lower2:"rl2 \<ge> 0" using bounds by auto
have upper1:"ru1 \<ge> 0" using dual_order.trans gru1 u1 r1 by blast
have upper2:"ru2 \<ge> 0" using dual_order.trans gru2 u2 r2 bounds by blast
have g1:"ru1 * ru2 \<ge> ru1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 mult_left_mono leD leI less_le_trans by metis
have g2:"ru1 * r\<^sub>2 \<ge> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 mult_right_mono by metis
from g1 and g2
have up:"ru1 * ru2 \<ge> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims max_repU2 max_repU2[OF maxU12] max_repU2[OF maxU34] max_repU2[OF bigMaxU] max.coboundedI1 max.commute maxt34
by (metis repU_def tu.simps)
qed
qed
fun wmin :: "word \<Rightarrow> word \<Rightarrow> word"
where "wmin w\<^sub>1 w\<^sub>2 =
(if w\<^sub>1 < w\<^sub>2 then w\<^sub>1 else w\<^sub>2)"
lemma wmin_lemma:
assumes eq1:"Ratreal w\<^sub>1 = (r\<^sub>1::real)"
assumes eq2:"Ratreal w\<^sub>2 = (r\<^sub>2::real)"
shows "Ratreal (wmin w\<^sub>1 w\<^sub>2) = (min r\<^sub>1 r\<^sub>2)"
proof -
from eq1 eq2 have e1:"real_of_rat w\<^sub>1 = r\<^sub>1"
and e2:"real_of_rat w\<^sub>2 = r\<^sub>2" unfolding repL_def by auto
have leq_imp:"w\<^sub>1 < w\<^sub>2 \<Longrightarrow> real_of_rat w\<^sub>1 < real_of_rat w\<^sub>2"
by (simp add: of_rat_less)
have nleq_imp:"\<not>(w\<^sub>1 < w\<^sub>2) \<Longrightarrow> \<not>(real_of_rat w\<^sub>1 < real_of_rat w\<^sub>2)"
by (simp add: of_rat_less)
show ?thesis
apply(auto)
using e1 e2 leq_imp nleq_imp by linarith+
qed
lemma min_repU1:
assumes "w1 \<equiv>\<^sub>L x"
assumes "w2 \<equiv>\<^sub>L y"
shows "wmin w1 w2 \<equiv>\<^sub>L x "
using wmin_lemma assms repL_def
by (auto simp add: min_le_iff_disj)
lemma min_repU2:
assumes "w1 \<equiv>\<^sub>L y"
assumes "w2 \<equiv>\<^sub>L x"
shows "wmin w1 w2 \<equiv>\<^sub>L x"
using wmin_lemma assms repL_def
by (auto simp add: min_le_iff_disj)
fun tl :: "word \<Rightarrow> word \<Rightarrow> word \<Rightarrow> word \<Rightarrow> word"
where "tl w1l w1u w2l w2u =
wmin (wmin (wtimes w1l w2l) (wtimes w1u w2l))
(wmin (wtimes w1l w2u) (wtimes w1u w2u))"
lemmas real_zero_le_0_iff = zero_le_mult_iff
lemma tl_lemma:
assumes u1:"u\<^sub>1 \<equiv>\<^sub>U (r\<^sub>1::real)"
assumes u2:"u\<^sub>2 \<equiv>\<^sub>U (r\<^sub>2::real)"
assumes l1:"l\<^sub>1 \<equiv>\<^sub>L (r\<^sub>1::real)"
assumes l2:"l\<^sub>2 \<equiv>\<^sub>L (r\<^sub>2::real)"
shows "tl l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>L (r\<^sub>1 * r\<^sub>2)"
proof -
obtain rl1 rl2 ru1 ru2 :: real
where gru1:"ru1 \<ge> r\<^sub>1" and gru2:"ru2 \<ge> r\<^sub>2" and grl1:"rl1 \<le> r\<^sub>1" and grl2:"rl2 \<le> r\<^sub>2"
and eru1:"Ratreal u\<^sub>1 = ru1" and eru2:"Ratreal u\<^sub>2 = ru2" and erl1:"Ratreal l\<^sub>1 = rl1" and erl2:"Ratreal l\<^sub>2 = rl2"
using u1 u2 l1 l2 unfolding repU_def repL_def by auto
have timesuu:"Ratreal (wtimes u\<^sub>1 u\<^sub>2) = ru1 * ru2"
using wtimes_exact[OF eru1 eru2] by auto
have timesul:"Ratreal (wtimes u\<^sub>1 l\<^sub>2) = ru1 * rl2"
using wtimes_exact[OF eru1 erl2] by auto
have timeslu:"Ratreal (wtimes l\<^sub>1 u\<^sub>2) = rl1 * ru2"
using wtimes_exact[OF erl1 eru2] by auto
have timesll:"Ratreal (wtimes l\<^sub>1 l\<^sub>2) = rl1 * rl2"
using wtimes_exact[OF erl1 erl2] by auto
have maxt12:"Ratreal (wmin (wtimes l\<^sub>1 l\<^sub>2) (wtimes u\<^sub>1 l\<^sub>2)) = min (rl1 * rl2) (ru1 * rl2)"
by (rule wmin_lemma[OF timesll timesul])
have maxt34:"Ratreal (wmin (wtimes l\<^sub>1 u\<^sub>2) (wtimes u\<^sub>1 u\<^sub>2)) = min (rl1 * ru2) (ru1 * ru2)"
by (rule wmin_lemma[OF timeslu timesuu])
have bigMax:"Ratreal (wmin (wmin (wtimes l\<^sub>1 l\<^sub>2) (wtimes u\<^sub>1 l\<^sub>2)) (wmin (wtimes l\<^sub>1 u\<^sub>2) (wtimes u\<^sub>1 u\<^sub>2)))
= min (min(rl1 * rl2) (ru1 * rl2)) (min (rl1 * ru2) (ru1 * ru2))"
by (rule wmin_lemma[OF maxt12 maxt34])
obtain maxt12val :: real where maxU12:"wmin (wtimes l\<^sub>1 l\<^sub>2) (wtimes u\<^sub>1 l\<^sub>2) \<equiv>\<^sub>L min (rl1 * rl2) (ru1 * rl2)"
using maxt12 unfolding repL_def by auto
obtain maxt34val :: real where maxU34:"wmin (wtimes l\<^sub>1 u\<^sub>2) (wtimes u\<^sub>1 u\<^sub>2) \<equiv>\<^sub>L min (rl1 * ru2) (ru1 * ru2)"
using maxt34 unfolding repL_def by auto
obtain bigMaxU:"wmin (wmin (wtimes l\<^sub>1 l\<^sub>2) (wtimes u\<^sub>1 l\<^sub>2)) (wmin (wtimes l\<^sub>1 u\<^sub>2) (wtimes u\<^sub>1 u\<^sub>2))
\<equiv>\<^sub>L min (min (rl1 * rl2) (ru1 * rl2)) (min (rl1 * ru2) (ru1 * ru2))"
using bigMax unfolding repL_def by linarith
have ivl1:"rl1 \<le> ru1" using grl1 gru1 by auto
have ivl2:"rl2 \<le> ru2" using grl2 gru2 by auto
let ?thesis = "tl l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>L r\<^sub>1 * r\<^sub>2"
show ?thesis
apply(rule case_ivl_zero[OF ivl1 ivl2])
proof -
assume "rl1 \<le> 0 \<and> 0 \<le> ru1 \<and> rl2 \<le> 0 \<and> 0 \<le> ru2"
then have geq1:"ru1 \<ge> 0" and geq2:"ru2 \<ge> 0"
and geq3:"rl1 \<le> 0" and geq4:"rl2 \<le> 0" by auto
have case1:"r\<^sub>1 \<ge> 0 \<Longrightarrow> r\<^sub>2 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<ge> 0"
assume r2:"r\<^sub>2 \<ge> 0"
have g1:"rl1 * ru2 \<le> 0"
using r1 geq1 geq2 geq3 geq4 grl2 gru2 mult_le_0_iff by blast
have g2:"0 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 geq1 geq2 grl1 grl2 gru1 gru2
by (simp)
from g1 and g2
have up:"rl1 * ru2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up eru1 eru2 erl1 erl2 min_repU1 min_repU2 repL_def repU_def timeslu tl.simps wmin.elims
by (metis bigMax min_le_iff_disj)
qed
have case2:"r\<^sub>1 \<le> 0 \<Longrightarrow> r\<^sub>2 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<le> 0"
assume r2:"r\<^sub>2 \<ge> 0"
have g1:"rl1 * ru2 \<le> rl1 * r\<^sub>2"
using r1 geq1 geq2 grl2 gru2
by (metis silly_lemma geq3 leD)
have g2:"rl1 * r\<^sub>2 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 geq1 geq2 grl2 gru2
by (simp add: mult_right_mono grl1)
from g1 and g2
have up:"rl1 * ru2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
by (metis up maxU12 min_repU2 repL_def tl.simps min.coboundedI1 maxt34)
qed
have case3:"r\<^sub>1 \<ge> 0 \<Longrightarrow> r\<^sub>2 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<ge> 0"
assume r2:"r\<^sub>2 \<le> 0"
have g1:"ru1 * rl2 \<le> ru1 * r\<^sub>2"
using r1 r2 geq1 geq2 grl2 gru2
by (simp add: mult_left_mono)
have g2:"ru1 * r\<^sub>2 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 geq1 geq2 grl1 grl2 gru1 gru2 mult_minus_right mult_right_mono
by (simp add: mult_right_mono_neg)
from g1 and g2
have up:"ru1 * rl2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmin.elims min_repU2 min_repU1 maxt34 timesul
by (metis repL_def tl.simps)
qed
have case4:"r\<^sub>1 \<le> 0 \<Longrightarrow> r\<^sub>2 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<le> 0"
assume r2:"r\<^sub>2 \<le> 0"
have g1:"ru1 * rl2 \<le> 0"
using r1 r2 geq1 geq2 grl1 grl2 gru1 gru2 \<open>rl1 \<le> 0 \<and> 0 \<le> ru1 \<and> rl2 \<le> 0 \<and> 0 \<le> ru2\<close> mult_less_0_iff less_eq_real_def not_less
by auto
have g2:"0 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 geq1 geq2 grl1 grl2 gru1 gru2
by (metis mult_less_0_iff not_less)
from g1 and g2
have up:"ru1 * rl2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
by (metis up maxU12 maxU34 wmin.elims min_repU1 min_repU2 repL_def timesul tl.simps)
qed
show "tl l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>L r\<^sub>1 * r\<^sub>2"
using case1 case2 case3 case4 le_cases by blast
next
assume bounds:"rl1 \<le> 0 \<and> 0 \<le> ru1 \<and> 0 \<le> rl2"
have r2:"r\<^sub>2 \<ge> 0" using bounds dual_order.trans grl2 by blast
have case1:"r\<^sub>1 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<ge> 0"
have g1:"rl1 * rl2 \<le> 0"
using r1 r2 bounds grl1 grl2 gru1 gru2
by (simp add: mult_le_0_iff)
have g2:"0 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
by (simp)
from g1 and g2
have up:"rl1 * rl2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
by (metis repL_def timesll tl.simps up maxU12 maxU34 wmin.elims min_repU2 min_repU1)
qed
have case2:"r\<^sub>1 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<le> 0"
have bound:"ru2 \<ge> 0"
using r1 r2 bounds grl1 grl2 gru1 gru2
using dual_order.trans by auto
then have g1:"rl1 * ru2 \<le> rl1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_left_mono_neg by blast
have g2:"rl1 * r\<^sub>2 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 mult_le_0_iff mult_le_cancel_right by fastforce
from g1 and g2
have up:"rl1 * ru2 \<le> r\<^sub>1 * r\<^sub>2" by auto
show ?thesis
using Ratreal_def of_rat_less repL_def timeslu up wtimes.elims
by (smt \<open>\<And>thesis. (wmin (wmin (wtimes l\<^sub>1 l\<^sub>2) (wtimes u\<^sub>1 l\<^sub>2)) (wmin (wtimes l\<^sub>1 u\<^sub>2) (wtimes u\<^sub>1 u\<^sub>2)) \<equiv>\<^sub>L min (min (rl1 * rl2) (ru1 * rl2)) (min (rl1 * ru2) (ru1 * ru2)) \<Longrightarrow> thesis) \<Longrightarrow> thesis\<close> tl.elims)
qed
show "tl l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>L r\<^sub>1 * r\<^sub>2"
using case1 case2 le_cases by blast
next
assume bounds:"rl1 \<le> 0 \<and> 0 \<le> ru1 \<and> ru2 \<le> 0"
have r2:"r\<^sub>2 \<le> 0" using bounds dual_order.trans gru2 by blast
have case1:"r\<^sub>1 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<ge> 0"
have bound:"rl2 \<le> 0"
using r1 r2 bounds grl1 grl2 gru1 gru2
using dual_order.trans by auto
then have g1:"ru1 * rl2 \<le> ru1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
by (simp add: mult_left_mono)
have p1:"\<And>a::real. (0 \<le> - a) = (a \<le> 0)"
by(auto)
have p2:"\<And>a b::real. (- a \<le> - b) = (b \<le> a)" by auto
have g2:"ru1 * r\<^sub>2 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 p1 p2
by (simp add: mult_right_mono_neg)
from g1 and g2
have up:"ru1 * rl2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using bigMaxU repL_def up by auto
qed
have case2:"r\<^sub>1 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r1:"r\<^sub>1 \<le> 0"
have g1:"ru1 * ru2 \<le> 0"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_le_0_iff by blast
have g2:"0 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 real_zero_le_0_iff by blast
from g1 and g2
have up:"ru1 * ru2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmin.elims min_repU2 min_repU1
min.coboundedI1 min.commute maxt34
by (smt repL_def tl.simps)
qed
show "tl l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>L r\<^sub>1 * r\<^sub>2"
using case1 case2 le_cases by blast
next
assume bounds:"0 \<le> rl1 \<and> rl2 \<le> 0 \<and> 0 \<le> ru2"
have r1:"r\<^sub>1 \<ge> 0" using bounds dual_order.trans grl1 by blast
have bound:"0 \<le> ru1" using r1 bounds grl1 grl2 gru1 gru2
using dual_order.trans by auto
have case1:"r\<^sub>2 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r2:"r\<^sub>2 \<ge> 0"
have g1:"rl1 * rl2 \<le> 0"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_le_0_iff by blast
have g2:"0 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
using real_zero_le_0_iff by blast
from g1 and g2
have up:"rl1 * rl2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims min_repU2 min_repU1
min.coboundedI1 min.commute maxt12 maxt34
using repL_def timesll tl.simps
by metis
qed
have case2:"r\<^sub>2 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r2:"r\<^sub>2 \<le> 0"
have g1:"ru1 * rl2 \<le> ru1 * r\<^sub>2"
using r1 bounds bound grl1 grl2 gru1 r2 gru2
using mult_left_mono by blast
have g2:"ru1 * r\<^sub>2 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds bound grl1 grl2 gru1 r2 gru2
proof -
have "\<forall>e ea. r\<^sub>2 * ea \<le> r\<^sub>2 * e \<or> \<not> e \<le> ea"
using r2 by (metis mult_left_mono_neg)
then show ?thesis
by (metis gru1 mult.commute)
qed
from g1 and g2
have up:"ru1 * rl2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmin.elims min_repU2 min_repU1 maxt34
by (metis repL_def timesul tl.simps)
qed
show "tl l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>L r\<^sub>1 * r\<^sub>2"
using case1 case2 le_cases by blast
next
assume bounds:"ru1 \<le> 0 \<and> rl2 \<le> 0 \<and> 0 \<le> ru2"
have r1:"r\<^sub>1 \<le> 0" using bounds dual_order.trans gru1 by blast
have bound:"rl1 \<le> 0" using r1 bounds grl1 grl2 gru1 gru2
using dual_order.trans by auto
have case1:"r\<^sub>2 \<ge> 0 \<Longrightarrow> ?thesis"
proof -
assume r2:"r\<^sub>2 \<ge> 0"
have g1:"rl1 * ru2 \<le> rl1 * r\<^sub>2"
using r1 r2 bounds bound grl1 grl2 gru1 gru2
by (metis real_mult_le_mult_iff leD)
have g2:"rl1 * r\<^sub>2 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_right_mono
by (simp add: mult_le_0_iff)
from g1 and g2
have up:"rl1 * ru2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmax.elims min_repU2 min_repU1
min.coboundedI1 min.commute maxt34
by (metis min_repU2 repL_def tl.simps)
qed
have case2:"r\<^sub>2 \<le> 0 \<Longrightarrow> ?thesis"
proof -
assume r2:"r\<^sub>2 \<le> 0"
have lower:"rl1 \<le> 0" using bounds dual_order.trans grl1 r1 by blast
have g1:"ru1 * ru2 \<le> 0"
using r1 r2 bounds grl1 grl2 gru1 gru2
using mult_le_0_iff by blast
have g2:"0 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2
by (simp add: real_zero_le_0_iff)
from g1 and g2
have up:"ru1 * ru2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU wmin.elims min_repU2 min_repU1
min.coboundedI1 min.commute maxt34
by (metis repL_def tl.simps)
qed
show "tl l\<^sub>1 u\<^sub>1 l\<^sub>2 u\<^sub>2 \<equiv>\<^sub>L r\<^sub>1 * r\<^sub>2"
using case1 case2 le_cases by blast
next
assume bounds:"ru1 \<le> 0 \<and> ru2 \<le> 0"
have r1:"r\<^sub>1 \<le> 0" using bounds dual_order.trans gru1 by blast
have r2:"r\<^sub>2 \<le> 0" using bounds dual_order.trans gru2 by blast
have lower1:"rl1 \<le> 0" using bounds dual_order.trans grl1 r1 by blast
have lower2:"rl2 \<le> 0" using bounds dual_order.trans grl2 r2 by blast
have g1:"ru1 * ru2 \<le> ru1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2
using not_less silly_lemma
by metis
have g2:"ru1 * r\<^sub>2 \<le> r\<^sub>1 * r\<^sub>2"
using r1 r2 bounds grl1 grl2 gru1 gru2 real_mult_le_mult_iff mult.commute not_le lower1 lower2
by (metis mult_right_mono_neg)
from g1 and g2
have up:"ru1 * ru2 \<le> r\<^sub>1 * r\<^sub>2"
by auto
show ?thesis
using up maxU12 maxU34 bigMaxU
wmin.elims min_repU2 min_repU1
min.coboundedI1 min.commute maxt34
by (smt repL_def tl.simps)
next
assume bounds:"ru1 \<le> 0 \<and> 0 \<le> rl2"