-
Notifications
You must be signed in to change notification settings - Fork 0
/
Uprop.v
4846 lines (3880 loc) · 140 KB
/
Uprop.v
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
(** * Uprop.v : Properties of operators on [[0,1]] *)
From Coq Require Export Arith ZArith.
From Coq Require Export Lia.
From ALEA Require Import Utheory.
Set Implicit Arguments.
Module Univ_prop (Univ : Universe).
Include Univ.
Hint Resolve Unit Udiff_0_1 Unth_prop: core.
Hint Resolve Uplus_sym Uplus_assoc Umult_sym Umult_assoc: core.
Hint Resolve Uinv_one Uinv_opp_left Uinv_plus_left Umult_div Udiv_le_one Udiv_by_zero: core.
Hint Resolve Uplus_zero_left Umult_one_left Udistr_plus_right Udistr_inv_right: core.
Hint Resolve Uplus_le_compat_right Umult_le_compat_right Uinv_le_compat: core.
Hint Resolve lub_le le_lub Uplus_right_continuous Umult_right_continuous: core.
(* lub_eq_mult lub_eq_plus_cte_left.*)
Hint Resolve Ule_total Ule_class: core.
Open Scope U_scope.
(** ** Direct consequences of axioms *)
Lemma Ueq_class : forall x y:U, class (x==y).
red; intros.
apply Ole_antisym;
apply Ule_class; intuition.
Qed.
Lemma Ueq_double_neg : forall x y : U, ~ ~x == y -> x == y.
exact Ueq_class.
Qed.
Hint Resolve Ueq_class: core.
Hint Immediate Ueq_double_neg: core.
Lemma Ule_orc : forall x y : U, orc (x<=y) ( ~ x<=y).
auto.
Qed.
Arguments Ule_orc : clear implicits.
Lemma Ueq_orc : forall x y:U, orc (x==y) ( ~ x==y).
auto.
Qed.
Arguments Ueq_orc : clear implicits.
Lemma Upos : forall x:U, 0 <= x.
auto.
Qed.
Lemma Ule_0_1 : 0 <= 1.
auto.
Qed.
Hint Resolve Upos Ule_0_1: core.
(** - Inverse order on U *)
Definition UI : ord := Iord U.
(** ** Properties of == derived from properties of $\le$ *)
Lemma Uplus_le_compat_left : forall x y z:U, x <= y -> x + z <= y + z.
intros; rewrite (Uplus_sym x z); rewrite (Uplus_sym y z); auto.
Qed.
Hint Resolve Uplus_le_compat_left: core.
Lemma Uplus_eq_compat_left : forall x y z:U, x == y -> x + z == y + z.
intros; apply Ole_antisym; auto.
Qed.
Hint Resolve Uplus_eq_compat_left: core.
Lemma Uplus_eq_compat_right : forall x y z:U, x == y -> (z + x) == (z + y).
intros; apply Oeq_trans with (x + z); auto.
apply Oeq_trans with (y + z); auto.
Qed.
Add Morphism Uplus with signature
(Ole (o:=U)) ++> (Ole (o:=U)) ++> (Ole (o:=U))
as Uplus_le_compat_morph.
intros; apply Ole_trans with (x+y0); auto.
Qed.
Lemma Uplus_le_compat : forall x y z t, x <= y -> z <= t -> x +z <= y + t.
intros; apply Ole_trans with (x+t); auto.
Qed.
Hint Immediate Uplus_le_compat: core.
Definition UPlus := le_compat2_mon Uplus_le_compat.
Definition UPlus_simpl : forall x y, UPlus x y = x+y.
trivial.
Qed.
Lemma Uplus_continuous2 : continuous2 UPlus.
apply continuous2_sym.
simpl; auto.
intro k; apply continuous_eq_compat with (2:=Uplus_right_continuous k).
apply fmon_eq_intro; intro m; auto.
Qed.
Hint Resolve Uplus_continuous2: core.
Lemma Umult_le_compat_left : forall x y z:U, x <= y -> x * z <= y * z.
intros; rewrite (Umult_sym x z); rewrite (Umult_sym y z); auto.
Qed.
Hint Resolve Umult_le_compat_left: core.
Add Morphism Umult
with signature (Ole (o:=U)) ++> (Ole (o:=U)) ++> (Ole (o:=U)) as Umult_le_compat_morph.
intros x1 x2 H1 x3 x4 H2; apply Ole_trans with (x1 * x4); auto.
Qed.
Hint Immediate Umult_le_compat_morph: core.
Lemma Umult_le_compat : forall x y z t, x <= y -> z <= t -> x * z <= y * t.
intros; apply Ole_trans with (x*t); auto.
Qed.
Hint Immediate Umult_le_compat: core.
Definition UMult := le_compat2_mon Umult_le_compat.
Lemma Umult_eq_compat_left : forall x y z:U, x == y -> (x * z) == (y * z).
intros; apply Ole_antisym; auto.
Qed.
Hint Resolve Umult_eq_compat_left: core.
Lemma Umult_eq_compat_right : forall x y z:U, x == y -> (z * x) == (z * y).
intros; apply Oeq_trans with (x * z); auto.
apply Oeq_trans with (y * z); auto.
Qed.
Hint Resolve Uplus_eq_compat_right Umult_eq_compat_right: core.
Definition UMult_simpl : forall x y, UMult x y = x*y.
trivial.
Qed.
Lemma Umult_continuous2 : continuous2 UMult.
apply continuous2_sym.
simpl; auto.
intro k; apply continuous_eq_compat with (2:=Umult_right_continuous k).
apply fmon_eq_intro; intro m; auto.
Qed.
Hint Resolve Umult_continuous2: core.
(** ** [U] is a setoid *)
Add Morphism Uplus with signature Oeq (O:=U) ==> Oeq (O:=U) ==> Oeq (O:=U)
as Uplus_eq_compat.
intros x1 x2 eq1 x3 x4 eq2; apply Oeq_trans with (x1+x4); auto.
Qed.
Add Morphism Umult with signature Oeq (O:=U) ==> Oeq (O:=U) ==> Oeq (O:=U)
as Umult_eq_compat.
intros x1 x2 eq1 x3 x4 eq2; apply Oeq_trans with (x1 * x4); auto.
Qed.
Hint Immediate Umult_eq_compat Uplus_eq_compat: core.
Add Morphism Uinv with signature Oeq (O:=U) ==> Oeq (O:=U) as Uinv_eq_compat.
intros; apply Ole_antisym; auto.
Qed.
Definition UInv : UI -m> U.
exists (fun (x:UI) => [1-]x); red; intros; auto.
Defined.
Definition UInv_simpl : forall x, UInv x = [1-]x.
trivial.
Qed.
Lemma Ule_eq_compat :
forall x1 x2 : U, x1 == x2 -> forall x3 x4 : U, x3 == x4 -> x1 <= x3 -> x2 <= x4.
intros x1 x2 eq1 x3 x4 eq2; elim (Ole_eq_compat_iff eq1 eq2); auto.
Qed.
(** ** Definition and properties of $x<y$ *)
Definition Ult (r1 r2:U) : Prop := ~ (r2 <= r1).
Infix "<" := Ult : U_scope.
Hint Unfold Ult: core.
Add Morphism Ult with signature Oeq (O:=U) ==> Oeq (O:=U) ==> iff as Ult_eq_compat_iff.
unfold Ult, not; intros x1 x2 eq1 x3 x4 eq2.
generalize (Ole_eq_compat_iff eq2 eq1); intuition.
Qed.
Lemma Ult_eq_compat :
forall x1 x2 : U, x1 == x2 -> forall x3 x4 : U, x3 == x4 -> x1 < x3 -> x2 < x4.
intros x1 x2 eq1 x3 x4 eq2; elim (Ult_eq_compat_iff eq1 eq2); auto.
Qed.
Lemma Ult_class : forall x y, class (x<y).
unfold Ult; auto.
Qed.
Hint Resolve Ult_class: core.
(* begin hide *)
(** Tactic for left normal form with respect to associativity *)
Ltac norm_assoc_left :=
match goal with
| |- context [(Uplus ?X1 (Uplus ?X2 ?X3))]
=> (setoid_rewrite (Uplus_assoc X1 X2 X3))
end.
Ltac norm_assoc_right :=
match goal with
| |- context [(Uplus (Uplus ?X1 ?X2) ?X3)]
=> (setoid_rewrite <- (Uplus_assoc X1 X2 X3))
end.
(* end hide *)
(** *** Properties of $x \leq y$ *)
Lemma Ule_zero_eq : forall x:U, x <= 0 -> x == 0.
intros; apply Ole_antisym; auto.
Qed.
Lemma Uge_one_eq : forall x:U, 1 <= x -> x == 1.
intros; apply Ole_antisym; auto.
Qed.
Hint Immediate Ule_zero_eq Uge_one_eq: core.
(** *** Properties of $x < y$ *)
Lemma Ult_neq : forall x y:U, x < y -> ~x == y.
unfold Ult; red; auto.
Qed.
Lemma Ult_neq_rev : forall x y:U, x < y -> ~y == x.
unfold Ult; red; auto.
Qed.
Lemma Ult_trans : forall x y z, x<y -> y<z -> x <z.
repeat red; intros.
apply (Ule_total y z); intros; auto.
apply H; apply Ole_trans with z; auto.
Qed.
Lemma Ult_le : forall x y:U, x < y -> x <= y.
unfold Ult; intros; apply Ule_class; repeat red; intros.
assert (x < x).
apply Ult_trans with y; auto.
apply H1; auto.
Qed.
Lemma Ule_diff_lt : forall x y : U, x <= y -> ~x==y -> x < y.
red; intuition.
Qed.
Hint Immediate Ult_neq Ult_neq_rev Ult_le: core.
Hint Resolve Ule_diff_lt: core.
Lemma Ult_neq_zero : forall x, ~0 == x -> 0 < x.
auto.
Qed.
Hint Resolve Ule_total Ult_neq_zero: core.
(** ** Properties of $+$ and $\times$ *)
Lemma Udistr_plus_left : forall x y z, y <= [1-] z -> x * (y + z) == x * y + x * z.
intros.
rewrite (Umult_sym x (y+z)).
rewrite (Umult_sym x y).
rewrite (Umult_sym x z);auto.
Qed.
Lemma Udistr_inv_left : forall x y, [1-](x * y) == (x * ([1-] y)) + [1-] x.
intros.
setoid_rewrite (Umult_sym x y).
setoid_rewrite (Udistr_inv_right y x); auto.
Qed.
Hint Resolve Uinv_eq_compat Udistr_plus_left Udistr_inv_left: core.
Lemma Uplus_perm2 : forall x y z:U, x + (y + z) == y + (x + z).
intros; setoid_rewrite (Uplus_assoc x y z).
setoid_rewrite (Uplus_sym x y); auto.
Qed.
Lemma Umult_perm2 : forall x y z:U, x * (y * z) == y * (x * z).
intros; setoid_rewrite (Umult_assoc x y z).
setoid_rewrite (Umult_sym x y); auto.
Qed.
Lemma Uplus_perm3 : forall x y z : U, (x + (y + z)) == z + (x + y).
intros; setoid_rewrite (Uplus_assoc x y z); auto.
Qed.
Lemma Umult_perm3 : forall x y z : U, (x * (y * z)) == z * (x * y).
intros; setoid_rewrite (Umult_assoc x y z); auto.
Qed.
Hint Resolve Uplus_perm2 Umult_perm2 Uplus_perm3 Umult_perm3: core.
Lemma Uplus_zero_right : forall x:U, x + 0 == x.
intros; setoid_rewrite (Uplus_sym x 0); auto.
Qed.
Hint Resolve Uplus_zero_right: core.
(* ** Properties of [1-] *)
Lemma Uinv_zero : [1-] 0 == 1.
apply Oeq_trans with (([1-] (0 + 0))+0); auto.
apply Oeq_trans with ([1-] (0 + 0)); auto.
setoid_rewrite (Uplus_zero_right 0); auto.
Qed.
Hint Resolve Uinv_zero: core.
Lemma Uinv_opp_right : forall x, x + [1-] x == 1.
intros; apply Oeq_trans with ([1-] x + x); auto.
Qed.
Hint Resolve Uinv_opp_right: core.
Lemma Uinv_inv : forall x : U, [1-] [1-] x == x.
intros; apply Oeq_trans with ([1-] (x + [1-] x) + x); auto.
apply Oeq_sym; auto.
setoid_rewrite (Uinv_opp_right x); setoid_rewrite Uinv_one; auto.
Qed.
Hint Resolve Uinv_inv: core.
Lemma Uinv_simpl : forall x y : U, [1-] x == [1-] y -> x == y.
intros; setoid_rewrite <- (Uinv_inv x);
setoid_rewrite <- (Uinv_inv y); auto.
Qed.
Hint Immediate Uinv_simpl: core.
Lemma Umult_decomp : forall x y, x == x * y + x * [1-]y.
intros; apply Oeq_trans with (x * (y + [1-]y)); auto.
apply Oeq_trans with (x * 1); auto.
rewrite Umult_sym; auto.
Qed.
Hint Resolve Umult_decomp: core.
(** ** More properties on [+] and [*] and [Uinv] *)
(*
Lemma Umult_le_compat_right : forall x y z: U, x <= y -> (z * x) <= (z * y).
intros; setoid_rewrite (Umult_sym z x); setoid_rewrite (Umult_sym z y).
apply Umult_le_compat_left; trivial.
Qed.
Hint Resolve Umult_le_compat_right: core.
*)
Lemma Umult_one_right : forall x:U, x * 1 == x.
intros; setoid_rewrite (Umult_sym x 1); auto.
Qed.
Hint Resolve Umult_one_right: core.
Lemma Umult_one_right_eq : forall x y:U, y == 1 -> x * y == x.
intros; rewrite H; auto.
Qed.
Hint Resolve Umult_one_right_eq: core.
Lemma Umult_one_left_eq : forall x y:U, x == 1 -> x * y == y.
intros; rewrite H; auto.
Qed.
Hint Resolve Umult_one_left_eq: core.
Lemma Udistr_plus_left_le : forall x y z : U, x * (y + z) <= x * y + x * z.
intros; apply (Ule_total y ([1-]z)); intros; auto.
apply Ole_trans with (x * ([1-]z+z)).
rewrite Uinv_opp_left; auto.
rewrite Udistr_plus_left; auto.
Qed.
Lemma Uplus_eq_simpl_right :
forall x y z:U, z <= [1-] x -> z <= [1-] y -> (x + z) == (y + z) -> x == y.
intros; apply Ole_antisym.
apply Uplus_le_simpl_right with z; auto.
apply Uplus_le_simpl_right with z; auto.
Qed.
Lemma Ule_plus_right : forall x y, x <= x + y.
intros; apply Ule_eq_compat with (x + 0) (x + y); auto.
Qed.
Lemma Ule_plus_left : forall x y, y <= x + y.
intros; apply Ule_eq_compat with (0 + y) (x + y); auto.
Qed.
Hint Resolve Ule_plus_right Ule_plus_left: core.
Lemma Ule_mult_right : forall x y, x * y <= x .
intros; apply Ule_eq_compat with (x * y) (x * 1); auto.
Qed.
Lemma Ule_mult_left : forall x y, x * y <= y.
intros; apply Ule_eq_compat with (x * y) (1 * y); auto.
Qed.
Hint Resolve Ule_mult_right Ule_mult_left: core.
Lemma Uinv_le_perm_right : forall x y:U, x <= [1-] y -> y <= [1-] x.
intros; apply Ole_trans with ([1-] ([1-] y)); auto.
Qed.
Hint Immediate Uinv_le_perm_right: core.
Lemma Uinv_le_perm_left : forall x y:U, [1-] x <= y -> [1-] y <= x.
intros; apply Ole_trans with ([1-] ([1-] x)); auto.
Qed.
Hint Immediate Uinv_le_perm_left: core.
Lemma Uinv_le_simpl : forall x y:U, [1-] x <= [1-] y -> y <= x.
intros; apply Ole_trans with ([1-] ([1-] x)); auto.
Qed.
Hint Immediate Uinv_le_simpl: core.
Lemma Uinv_double_le_simpl_right : forall x y, x<=y -> x <= [1-][1-]y.
intros; apply Uinv_le_perm_right; auto.
Qed.
Hint Resolve Uinv_double_le_simpl_right: core.
Lemma Uinv_double_le_simpl_left : forall x y, x<=y -> [1-][1-]x <= y.
intros; apply Uinv_le_perm_left; auto.
Qed.
Hint Resolve Uinv_double_le_simpl_left: core.
Lemma Uinv_eq_perm_left : forall x y:U, x == [1-] y -> [1-] x == y.
intros; apply Oeq_trans with ([1-] ([1-] y)); auto.
Qed.
Hint Immediate Uinv_eq_perm_left: core.
Lemma Uinv_eq_perm_right : forall x y:U, [1-] x == y -> x == [1-] y.
intros; apply Oeq_trans with ([1-] ([1-] x)); auto.
Qed.
Hint Immediate Uinv_eq_perm_right: core.
Lemma Uinv_eq_simpl : forall x y:U, [1-] x == [1-] y -> x == y.
intros; apply Oeq_trans with ([1-] ([1-] x)); auto.
Qed.
Hint Immediate Uinv_eq_simpl: core.
Lemma Uinv_double_eq_simpl_right : forall x y, x==y -> x == [1-][1-]y.
intros; apply Uinv_eq_perm_right; auto.
Qed.
Hint Resolve Uinv_double_eq_simpl_right: core.
Lemma Uinv_double_eq_simpl_left : forall x y, x==y -> [1-][1-]x == y.
intros; apply Uinv_eq_perm_left; auto.
Qed.
Hint Resolve Uinv_double_eq_simpl_left: core.
Lemma Uinv_plus_right : forall x y, y <= [1-] x -> [1-] (x + y) + y == [1-] x.
intros; setoid_rewrite (Uplus_sym x y); auto.
Qed.
Hint Resolve Uinv_plus_right: core.
Lemma Uplus_eq_simpl_left :
forall x y z:U, x <= [1-] y -> x <= [1-] z -> (x + y) == (x + z) -> y == z.
intros x y z H1 H2; setoid_rewrite (Uplus_sym x y); setoid_rewrite (Uplus_sym x z); auto.
intros; apply Uplus_eq_simpl_right with x; auto.
Qed.
Lemma Uplus_eq_zero_left : forall x y:U, x <= [1-] y -> (x + y) == y -> x == 0.
intros; apply Uplus_eq_simpl_right with y; auto.
setoid_rewrite H0; auto.
Qed.
Lemma Uinv_le_trans : forall x y z t, x <= [1-] y -> z<=x -> t<=y -> z<= [1-] t.
intros; apply Ole_trans with x; auto.
apply Ole_trans with ([1-] y); auto.
Qed.
Lemma Uinv_plus_left_le : forall x y, [1-]y <= [1-](x+y) +x.
intros; apply (Ule_total y ([1-]x)); auto; intros.
rewrite Uinv_plus_left; auto.
apply Ole_trans with x; auto.
Qed.
Lemma Uinv_plus_right_le : forall x y, [1-]x <= [1-](x+y) +y.
intros; apply (Ule_total y ([1-]x)); auto; intros.
rewrite Uinv_plus_right; auto.
apply Ole_trans with y; auto.
Qed.
Hint Resolve Uinv_plus_left_le Uinv_plus_right_le: core.
(** ** Disequality *)
Lemma neq_sym : forall x y:U, ~x==y -> ~y==x.
red; intros; apply H; auto.
Qed.
Hint Immediate neq_sym: core.
Lemma Uinv_neq_compat : forall x y, ~x == y -> ~ [1-] x == [1-] y.
red; intros; apply H; auto.
Qed.
Lemma Uinv_neq_simpl : forall x y, ~ [1-] x == [1-] y-> ~x == y.
red; intros; apply H; auto.
Qed.
Hint Resolve Uinv_neq_compat: core.
Hint Immediate Uinv_neq_simpl: core.
Lemma Uinv_neq_left : forall x y, ~x == [1-] y -> ~ [1-] x == y.
red; intros; apply H; auto.
Qed.
Lemma Uinv_neq_right : forall x y, ~ [1-] x == y -> ~x == [1-] y.
red; intros; apply H; auto.
Qed.
(** *** Properties of [<] *)
Lemma Ult_antirefl : forall x:U, ~x < x.
unfold Ult; intuition.
Qed.
Lemma Ult_0_1 : (0 < 1).
red; intuition.
Qed.
Lemma Ule_lt_trans : forall x y z:U, x <= y -> y < z -> x < z.
unfold Ult; intuition.
apply H0; apply Ole_trans with x; trivial.
Qed.
Lemma Ult_le_trans : forall x y z:U, x < y -> y <= z -> x < z.
unfold Ult; intuition.
apply H; apply Ole_trans with z; trivial.
Qed.
Hint Resolve Ult_0_1 Ult_antirefl: core.
Lemma Ule_neq_zero : forall (x y:U), ~0 == x -> x <= y -> ~ 0 == y.
red; intros.
apply H.
apply Ole_antisym; auto; rewrite H1; trivial.
Qed.
Lemma Uplus_neq_zero_left : forall x y, ~0 == x -> ~0 == x+y.
intros; apply Ult_neq.
apply Ult_le_trans with x; auto.
Qed.
Lemma Uplus_neq_zero_right : forall x y, ~0 == y -> ~0 == x+y.
intros; apply Ult_neq.
apply Ult_le_trans with y; auto.
Qed.
Lemma not_Ult_le : forall x y, ~x < y -> y <= x.
intros; apply Ule_class; auto.
Qed.
Lemma Ule_not_lt : forall x y, x <= y -> ~y < x.
repeat red; intros.
apply H0; auto.
Qed.
Hint Immediate not_Ult_le Ule_not_lt: core.
Theorem Uplus_le_simpl_left : forall x y z : U, z <= [1-] x -> z + x <= z + y -> x <= y.
intros.
apply Uplus_le_simpl_right with z; auto.
apply Ole_trans with (z + x); auto.
apply Ole_trans with (z + y); auto.
Qed.
Lemma Uplus_lt_compat_left : forall x y z:U, z <= [1-] y -> x < y -> (x + z) < (y + z).
unfold Ult; intuition.
apply H0; apply Uplus_le_simpl_right with z; trivial.
Qed.
Lemma Uplus_lt_compat_right : forall x y z:U, z <= [1-] y -> x < y -> (z + x) < (z + y).
intros; setoid_rewrite (Uplus_sym z x).
intros; setoid_rewrite (Uplus_sym z y).
apply Uplus_lt_compat_left; auto.
Qed.
Hint Resolve Uplus_lt_compat_right Uplus_lt_compat_left: core.
Lemma Uplus_lt_compat :
forall x y z t:U, z <= [1-] x -> t <= [1-] y -> x < y -> z < t -> (x + z) < (y + t).
intros; apply Ult_trans with (y + z); auto.
apply Uplus_lt_compat_left; auto.
apply Ole_trans with t; auto.
Qed.
Hint Immediate Uplus_lt_compat: core.
Lemma Uplus_lt_simpl_left : forall x y z:U, z <= [1-] y -> (z + x) < (z + y) -> x < y.
unfold lt; repeat red; intros.
apply H0; auto.
Qed.
Lemma Uplus_lt_simpl_right : forall x y z:U, z <= [1-] y -> (x + z) < (y + z) -> x < y.
unfold lt; repeat red; intros.
apply H0; auto.
Qed.
Lemma Uplus_one_le : forall x y, x + y == 1 -> [1-] y <= x.
intros; apply Ule_class; red; intros.
assert (x < [1-] y); auto.
assert (x + y < [1-] y + y); auto.
assert (x + y < 1); auto.
setoid_rewrite <- (Uinv_opp_left y); auto.
Qed.
Hint Immediate Uplus_one_le: core.
Theorem Uplus_eq_zero : forall x, x <= [1-] x -> (x + x) == x -> x == 0.
intros x H1 H2; apply Uplus_eq_simpl_left with x; auto.
setoid_rewrite H2; auto.
Qed.
Lemma Umult_zero_left : forall x, 0 * x == 0.
intros; apply Uinv_simpl.
setoid_rewrite (Udistr_inv_right 0 x); auto.
setoid_rewrite Uinv_zero.
setoid_rewrite (Umult_one_left x); auto.
Qed.
Hint Resolve Umult_zero_left: core.
Lemma Umult_zero_right : forall x, (x * 0) == 0.
intros; setoid_rewrite (Umult_sym x 0); auto.
Qed.
Hint Resolve Uplus_eq_zero Umult_zero_right: core.
Lemma Umult_zero_left_eq : forall x y, x == 0 -> x * y == 0.
intros; rewrite H; auto.
Qed.
Lemma Umult_zero_right_eq : forall x y, y == 0 -> x * y == 0.
intros; rewrite H; auto.
Qed.
Lemma Umult_zero_eq : forall x y z, x == 0 -> x * y == x * z.
intros; rewrite H.
rewrite Umult_zero_left; auto.
Qed.
(** *** Compatibility of operations with respect to order. *)
Lemma Umult_le_simpl_right : forall x y z, ~0 == z -> (x * z) <= (y * z) -> x <= y.
intros; apply Umult_le_simpl_left with z; auto.
setoid_rewrite (Umult_sym z x);
setoid_rewrite (Umult_sym z y);trivial.
Qed.
Hint Resolve Umult_le_simpl_right: core.
Lemma Umult_simpl_right : forall x y z, ~0 == z -> (x * z) == (y * z) -> x == y.
intros; apply Ole_antisym; auto.
apply Umult_le_simpl_right with z; auto.
apply Umult_le_simpl_right with z; auto.
Qed.
Lemma Umult_simpl_left : forall x y z, ~0 == x -> (x * y) == (x * z) -> y == z.
intros; apply Ole_antisym; auto.
apply Umult_le_simpl_left with x; auto.
apply Umult_le_simpl_left with x; auto.
Qed.
Lemma Umult_lt_compat_left : forall x y z, ~0 == z-> x < y -> (x * z) < (y * z).
unfold Ult,not;intros.
apply H0; apply Umult_le_simpl_right with z; auto.
Qed.
Lemma Umult_lt_compat_right : forall x y z, ~0 == z -> x < y -> (z * x) < (z * y).
unfold Ult,not;intros.
apply H0; apply Umult_le_simpl_left with z; auto.
Qed.
Lemma Umult_lt_simpl_right : forall x y z, ~0 == z -> (x * z) < (y * z) -> x < y.
unfold Ult,not;intros.
apply H0; auto.
Qed.
Lemma Umult_lt_simpl_left : forall x y z, ~0 == z -> (z * x) < (z * y) -> x < y.
unfold Ult,not;intros.
apply H0; auto.
Qed.
Hint Resolve Umult_lt_compat_left Umult_lt_compat_right: core.
Lemma Umult_zero_simpl_right : forall x y, 0 == x*y -> ~0 == x -> 0 == y.
intros.
apply Umult_simpl_left with x; auto.
rewrite (Umult_zero_right x); trivial.
Qed.
Lemma Umult_zero_simpl_left : forall x y, 0 == x*y -> ~0 == y -> 0 == x.
intros.
apply Umult_simpl_right with y; auto.
rewrite (Umult_zero_left y); trivial.
Qed.
Lemma Umult_neq_zero : forall x y, ~0 == x -> ~0 == y -> ~0 == x*y.
red; intros.
apply H0; apply Umult_zero_simpl_right with x; trivial.
Qed.
Hint Resolve Umult_neq_zero: core.
Lemma Umult_lt_zero : forall x y, 0 < x -> 0 < y -> 0 < x*y.
auto.
Qed.
Hint Resolve Umult_lt_zero: core.
Lemma Umult_lt_compat : forall x y z t, x < y -> z < t -> x * z < y * t.
intros.
assert (0<y); auto.
apply Ule_lt_trans with x; auto.
assert (0<t); auto.
apply Ule_lt_trans with z; auto.
apply (Ueq_orc 0 z); auto; intros.
rewrite <- H3.
rewrite Umult_zero_right; auto.
apply Ult_trans with (y * z); auto.
Qed.
(** *** More Properties *)
Lemma Uplus_one : forall x y, [1-] x <= y -> x + y == 1.
intros; apply Ole_antisym; auto.
apply Ole_trans with (x + [1-] x); auto.
Qed.
Hint Resolve Uplus_one: core.
Lemma Uplus_one_right : forall x, x + 1 == 1.
auto.
Qed.
Lemma Uplus_one_left : forall x:U, 1 + x == 1.
auto.
Qed.
Hint Resolve Uplus_one_right Uplus_one_left: core.
Lemma Uinv_mult_simpl : forall x y z t, x <= [1-] y -> (x * z) <= [1-] (y * t).
intros; apply Ole_trans with x; auto.
intros; apply Ole_trans with ([1-] y); auto.
Qed.
Hint Resolve Uinv_mult_simpl: core.
Lemma Umult_inv_plus : forall x y, x * [1-] y + y == x + y * [1-] x.
intros; apply Oeq_trans with (x * [1-] y + y * ([1-] x + x)).
setoid_rewrite (Uinv_opp_left x); auto.
assert (H:[1-] x <= [1-] x); auto.
rewrite (Udistr_plus_left y ([1-] x) x H).
apply Oeq_trans with (x * [1-] y + y * x + y * [1-] x).
norm_assoc_right; auto.
rewrite (Umult_sym y x).
assert (H1:[1-] y <= [1-] y); auto.
rewrite <- (Udistr_plus_left x ([1-]y) y H1).
setoid_rewrite (Uinv_opp_left y); auto.
Qed.
Hint Resolve Umult_inv_plus: core.
Lemma Umult_inv_plus_le : forall x y z, y <= z -> x * [1-] y + y <= x * [1-] z + z.
intros.
setoid_rewrite (Umult_inv_plus x y);
setoid_rewrite (Umult_inv_plus x z); auto.
Qed.
Hint Resolve Umult_inv_plus_le: core.
Lemma Uplus_lt_Uinv : forall x y, x+y < 1 -> x <= [1-] y.
intros; apply (Ule_total x ([1-]y)); intro; auto.
case H.
rewrite Uplus_one; auto.
Qed.
Lemma Uinv_lt_perm_left: forall x y : U, [1-] x < y -> [1-] y < x.
unfold Ult; intuition.
Qed.
Lemma Uinv_lt_perm_right: forall x y : U, x < [1-] y -> y < [1-] x.
unfold Ult; intuition.
Qed.
Hint Immediate Uinv_lt_perm_left Uinv_lt_perm_right: core.
Lemma Uinv_lt_one : forall x, 0 < x -> [1-]x < 1.
intros; assert ([1-]1 < x); auto.
rewrite Uinv_one; auto.
Qed.
Lemma Uinv_lt_zero : forall x, x < 1 -> 0 < [1-]x.
intros; assert (x < [1-]0); auto.
rewrite Uinv_zero; auto.
Qed.
Hint Resolve Uinv_lt_one Uinv_lt_zero: core.
Lemma orc_inv_plus_one : forall x y, orc (x<=[1-]y) (x+y==1).
intros; apply (Ule_total x ([1-]y)); intro; auto.
apply class_orc; trivial.
Qed.
Lemma Umult_lt_right : forall p q, p <1 -> 0 < q -> p * q < q.
intros.
apply Ult_le_trans with (1 * q); auto.
Qed.
Lemma Umult_lt_left : forall p q, 0 < p -> q < 1 -> p * q < p.
intros.
apply Ult_le_trans with (p * 1); auto.
Qed.
Hint Resolve Umult_lt_right Umult_lt_left: core.
(** ** Definition of $x^n$ *)
Fixpoint Uexp (x:U) (n:nat) {struct n} : U :=
match n with 0 => 1 | (S p) => x * Uexp x p end.
Infix "^" := Uexp : U_scope.
Lemma Uexp_1 : forall x, x^1==x.
simpl; auto.
Qed.
Lemma Uexp_0 : forall x, x^0==1.
simpl; auto.
Qed.
Lemma Uexp_zero : forall n, (0<n)%nat -> 0^n==0.
destruct n; simpl; intro; auto.
casetype False; lia.
Qed.
Lemma Uexp_one : forall n, 1^n==1.
induction n; simpl; auto.
Qed.
Lemma Uexp_le_compat_right :
forall x n m, (n<=m)%nat -> x^m <= x^n.
induction 1; simpl; auto.
apply Ole_trans with (x^m); auto.
Qed.
Lemma Uexp_le_compat_left : forall x y n, x<=y -> x^n <= y^n.
induction n; simpl; intros; auto.
apply Ole_trans with (x * (y^n)); auto.
Qed.
Hint Resolve Uexp_le_compat_left Uexp_le_compat_right: core.
Lemma Uexp_le_compat : forall x y (n m:natO), x<=y -> n<=m -> x^m <= y^n.
intros; apply Ole_trans with (x^n); auto.
Qed.
Definition UExp : UI-m>natO-m>UI.
apply le_compat2_mon with (f:=Uexp:UI->natO->UI); simpl; intros; auto.
apply Uexp_le_compat; trivial.
Defined.
Add Morphism Uexp with signature Oeq (O:=U) ==> eq (A:=nat) ==> Oeq (O:=U) as Uexp_eq_compat.
intros; apply Ole_antisym; auto.
Qed.
Lemma Uexp_inv_S : forall x n, ([1-]x^(S n))==x*([1-]x^n)+[1-]x.
simpl; auto.
Qed.
Lemma Uexp_lt_compat : forall p q n, (O<n)%nat->(p<q)->(p^n<q^n).
induction n; simpl; intros; auto.
casetype False; lia.
destruct n; auto.
apply Umult_lt_compat; auto with arith.
Qed.
Hint Resolve Uexp_lt_compat: core.
Lemma Uexp_lt_zero : forall p n, (0<p)->(0<p^n).
destruct n; intros; auto.
rewrite <- (Uexp_zero (n:=S n)); auto with arith.
Qed.
Hint Resolve Uexp_lt_zero: core.
Lemma Uexp_lt_one : forall p n, (0<n)%nat->(p<1)->(p^n<1).
intros; rewrite <- (Uexp_one n); auto with arith.
Qed.
Hint Resolve Uexp_lt_one: core.
Lemma Uexp_lt_antimon: forall p n m, (n<m)%nat-> 0<p -> p < 1 -> p^m < p^n.
induction 1; simpl; intros; auto with arith.
apply Ult_trans with (p*p^n); auto with arith.
Qed.
Hint Resolve Uexp_lt_antimon: core.
(** *** Properties of division *)
Lemma Udiv_mult : forall x y, ~0==y -> x <= y -> (x/y)*y == x.
intros; rewrite Umult_sym; auto.
Qed.
Hint Resolve Udiv_mult: core.
Lemma Umult_div_le : forall x y, y * (x / y) <= x.
intros; apply (Ueq_orc 0 y); auto; intros.
apply Ole_trans with (0 * (x/y)); auto.
rewrite Umult_zero_left; auto.
intros; apply (Ule_total x y); auto; intros.
rewrite Udiv_le_one; auto.
rewrite Umult_one_right; auto.
Qed.
Hint Resolve Umult_div_le: core.
Lemma Udiv_mult_le : forall x y, (x/y)*y <= x.
intros; rewrite Umult_sym; auto.
Qed.
Hint Resolve Udiv_mult_le: core.
Lemma Udiv_le_compat_left : forall x y z, x <= y -> x/z <= y/z.
intros; apply (Ueq_orc 0 z); auto; intros.
rewrite (Udiv_by_zero x); auto.
intros; apply (Ule_total y z); auto; intros.
apply Umult_le_simpl_right with z; auto.
rewrite (Udiv_mult x); auto.
rewrite (Udiv_mult y); auto.
apply Ole_trans with y; auto.
rewrite (Udiv_le_one y); auto.
Qed.
Hint Resolve Udiv_le_compat_left: core.
Lemma Udiv_eq_compat_left : forall x y z, x == y -> x/z == y/z.
intros; apply Ole_antisym; auto.
Qed.
Hint Resolve Udiv_eq_compat_left: core.
Lemma Umult_div_le_left : forall x y z, ~0==y -> x*y<=z -> x <= z/y.
intros; apply (Ule_total y z); auto; intros.
rewrite (Udiv_le_one z); auto.
apply Umult_le_simpl_right with y; auto.
apply Ole_trans with z; auto.
rewrite (Udiv_mult z H); auto.
Qed.
Lemma Udiv_le_compat_right : forall x y z, ~0==y -> y <= z -> x/z <= x/y.
intros; assert ( ~ 0 == z).
apply Ule_neq_zero with y; auto.
apply (Ule_total z x); auto; intros.
rewrite Udiv_le_one; auto.
rewrite Udiv_le_one; auto.
apply Ole_trans with z; trivial.
apply Umult_div_le_left; auto.
apply Ole_trans with (x/z * z); auto.
Qed.
Hint Resolve Udiv_le_compat_right: core.
Lemma Udiv_eq_compat_right : forall x y z, y == z -> x/z == x/y.
intros; apply (Ueq_orc 0 y); auto; intros.
assert (0==z).
rewrite <- H; auto.
repeat rewrite Udiv_by_zero; auto.
assert ( ~ 0 == z).
apply Ule_neq_zero with y; auto.
apply Ole_antisym; auto.
Qed.
Hint Resolve Udiv_eq_compat_right: core.
Add Morphism Udiv with signature Oeq (O:=U) ==> Oeq (O:=U) ==> Oeq (O:=U) as Udiv_eq_compat.
intros.
apply Oeq_trans with (x/y0); auto.
Qed.
Add Morphism Udiv with signature Ole (o:=U) ++> Oeq (O:=U) ==> Ole (o:=U) as Udiv_le_compat.
intros.
apply Ole_trans with (x/y0); auto.
Qed.
Lemma Umult_div_eq : forall x y z, ~0==y -> x*y==z -> x == z/y.
intros; apply Umult_simpl_right with y; auto.
assert (z<=y).
apply Ole_trans with (x*y); auto.
apply Oeq_trans with z; auto.
apply Oeq_sym; auto.
Qed.
Lemma Umult_div_le_right : forall x y z, x <= y*z -> x/z <= y.
intros; apply (Ueq_orc 0 z); auto; intros.
rewrite Udiv_by_zero; auto.
apply Umult_le_simpl_right with z; auto.
assert (x<=z).
apply Ole_trans with (y*z); auto.
rewrite (Udiv_mult x H0); auto.
Qed.
Lemma Udiv_le : forall x y, ~0==y -> x <= x/y.
intros; apply Umult_div_le_left; auto.
Qed.
Lemma Udiv_zero : forall x, 0/x==0.
intros; apply (Ueq_orc 0 x); auto; intros.
apply Oeq_sym; apply Umult_div_eq; auto.
Qed.
Hint Resolve Udiv_zero: core.