-
Notifications
You must be signed in to change notification settings - Fork 1
/
ring.v
1383 lines (1223 loc) · 36.9 KB
/
ring.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
Set Implicit Arguments.
Unset Strict Implicit.
Require Export lci.
Module Ring.
Section Laws.
Variables (pl ml : E2).
Definition distrib_l g := (forall a, inc a g -> forall b, inc b g -> forall c, inc c g ->
ml c (pl a b) = pl (ml c a) (ml c b)).
Definition distrib_r g :=(forall a, inc a g -> forall b, inc b g -> forall c, inc c g ->
ml (pl a b) c = pl (ml a c) (ml b c)).
Definition distributes g := A (distrib_l g) (distrib_r g).
Definition is_ring g e u :=
A (is_group pl g e)
(A (commutative pl g)
(A (is_monoid ml g u)
(distributes g))).
Definition is_quasiring a e u :=
A (is_monoid pl a e)
(A (is_monoid ml a u)
(A (distributes a)
(A (forall x, inc x a -> ml e x = e)
(forall x, inc x a -> ml x e = e)))).
Lemma ring_0_multr : forall g e u, is_ring g e u ->
forall x, inc x (g) -> ml x e = e.
Proof.
ir. uh H;ee.
uh H;uh H2;uh H3;ee.
assert (is_regular pl g). apply group_is_regular with e. uhg;ee;am.
uh H10;ee.
apply H10 with (ml x e);au.
ap H2;am.
ap H2;am.
wr H3;au. uh H6;ee. rw H12;au.
rw H12;au.
Qed.
Lemma ring_0_multl : forall g e u, is_ring g e u ->
forall x, inc x (g) -> ml e x = e.
Proof.
ir. uh H;ee.
uh H;uh H2;uh H3;ee.
assert (is_regular pl g). apply group_is_regular with e. uhg;ee;am.
uh H10;ee.
apply H10 with (ml e x);au.
ap H2;am.
ap H2;am.
wr H4;au. uh H6;ee. rw H12;au.
rw H12;au.
Qed.
Lemma ring_is_quasiring : forall g e u, is_ring g e u -> is_quasiring g e u.
Proof.
ir;uhg;ee;try am.
ap group_is_monoid;am.
eapply ring_0_multl. am.
eapply ring_0_multr. am.
Qed.
Definition is_integral g e := forall a, inc a (g) -> forall b, inc b (g) ->
ml a b = e -> (a=e \/ b=e).
Lemma integral_rw : forall g e u, is_ring g e u -> is_integral g e ->
forall a b, inc a (g) -> inc b (g) ->
(ml a b = e) = ((a=e)\/(b=e)).
Proof.
ir. ap iff_eq;ir.
ap H0. am. am. am.
nin H3;subst.
apply ring_0_multl with g u. am. am.
apply ring_0_multr with g u;am.
Qed.
Lemma minus_u_multl : forall g e u, is_ring g e u -> forall x, inc x (g) ->
ml (inverse_of pl g e u) x = inverse_of pl g e x.
Proof.
ir.
assert (are_inverse pl g e x (inverse_of pl g e x)). ap group_inverse_of. am. am.
uh H1;ee. assert (is_regular pl g). apply group_is_regular with e;am.
uh H5;ee.
apply H6 with x. am. uh H;ee. uh H8;ee. ap H8. ap group_inverse_inc. am.
am. am. ap group_inverse_inc. am. am.
rw H4.
replace (pl (ml (inverse_of pl g e u) x) x) with (pl (ml (inverse_of pl g e u) x) (ml u x)).
uh H;ee. uh H9;ee.
wr H10. assert (are_inverse pl g e u (inverse_of pl g e u)). ap group_inverse_of.
am. am. uh H11;ee. rw H14. apply ring_0_multl with g u. uhg;ee. am. am. am. uhg;ee;am.
am. ap group_inverse_inc;am. am. am. uh H;ee. uh H8;ee.
uh H10;ee. rw H13. tv. am.
Qed.
Lemma minus_u_multr : forall g e u, is_ring g e u -> forall x, inc x (g) ->
ml x (inverse_of pl g e u) = inverse_of pl g e x.
Proof.
ir.
assert (are_inverse pl g e x (inverse_of pl g e x)). ap group_inverse_of. am. am.
uh H1;ee. assert (is_regular pl g). apply group_is_regular with e;am.
uh H5;ee.
apply H6 with x. am. uh H;ee. uh H8;ee. ap H8. am. ap group_inverse_inc. am.
am. am.
rw H4.
replace (pl (ml x (inverse_of pl g e u)) x) with (pl (ml x (inverse_of pl g e u)) (ml x u)).
uh H;ee. uh H9;ee.
wr H9. assert (are_inverse pl g e u (inverse_of pl g e u)). ap group_inverse_of.
am. am. uh H11;ee. rw H14. apply ring_0_multr with g u. uhg;ee. am. am. am. uhg;ee;am.
am. ap group_inverse_inc;am. am. am. uh H;ee. uh H8;ee.
uh H10;ee. rw H12. tv. am.
Qed.
Lemma inverse_ml_insert_left : forall g e u, is_ring g e u ->
forall a b, inc a g -> inc b g ->
inverse_of pl g e (ml a b) = ml (inverse_of pl g e a) b.
Proof.
ir. eapply inverse_unicity.
ap group_is_monoid. am.
ap group_inverse_of. am. uh H;ee. uh H3;ee. au.
erewrite <-minus_u_multl.
Focus 2. ap H.
uh H;ee. uh H3;ee.
wr H6;au. rw minus_u_multl;au.
ap group_inverse_of. am. au.
uhg;ee; au. uhg;ee;am.
ap group_inverse_inc;am. am.
Qed.
Lemma inverse_ml_insert_right : forall g e u, is_ring g e u ->
forall a b, inc a g -> inc b g ->
inverse_of pl g e (ml a b) = ml a (inverse_of pl g e b).
Proof.
ir. eapply inverse_unicity.
ap group_is_monoid. am.
ap group_inverse_of. am. uh H;ee. uh H3;ee. au.
erewrite <-minus_u_multr.
Focus 2. ap H.
uh H;ee. uh H3;ee.
rw H6;au. rw minus_u_multr;au.
ap group_inverse_of. am. au.
uhg;ee; au. uhg;ee;am.
ap group_inverse_inc;am. am.
Qed.
Lemma integral_quasiregular_left : forall g e u, is_ring g e u -> is_integral g e ->
forall a b c, inc a g -> inc b g -> inc c g -> a<>e ->
ml a b = ml a c -> b = c.
Proof.
ir.
assert (are_inverse pl g e (ml a b) (inverse_of pl g e (ml a c))).
rw H5. ap group_inverse_of. am. uh H;ee. uh H7;ee;au.
uh H6;ee.
uh H;ee. uh H12;ee.
erewrite inverse_ml_insert_right in H8. Focus 2.
uhg;ee. am. am. ap H11. uhg;ee;am.
wri H12 H8;au.
uh H0;ee. apply H0 in H8. nin H8.
ap False_rect. au.
assert (is_regular pl g). eapply group_is_regular;am.
uh H14;ee. apply H15 with (inverse_of pl g e c).
ap group_inverse_inc;am. am. am.
rw H8. assert (are_inverse pl g e c (inverse_of pl g e c)). ap group_inverse_of;am.
symmetry;am. am.
uh H;ee;ap H. am. ap group_inverse_inc;au. uhg;ee;am.
ap group_inverse_inc;am. am. am.
Qed.
Lemma integral_quasiregular_right : forall g e u, is_ring g e u -> is_integral g e ->
forall a b c, inc a g -> inc b g -> inc c g -> a<>e ->
ml b a = ml c a -> b = c.
Proof.
ir.
assert (are_inverse pl g e (ml b a) (inverse_of pl g e (ml c a))).
rw H5. ap group_inverse_of. am. uh H;ee. uh H7;ee;au.
uh H6;ee.
uh H;ee. uh H12;ee.
erewrite inverse_ml_insert_left in H9. Focus 2.
uhg;ee. am. am. ap H11. uhg;ee;am.
wri H13 H9;au.
uh H0;ee. apply H0 in H9. nin H9.
assert (is_regular pl g). eapply group_is_regular;am.
uh H14;ee. apply H14 with (inverse_of pl g e c).
ap group_inverse_inc;am. am. am.
rw H9. assert (are_inverse pl g e c (inverse_of pl g e c)). ap group_inverse_of;am.
symmetry;am.
ap False_rect;au.
uh H;ee;ap H;au. ap group_inverse_inc;au. uhg;ee;am. am.
ap group_inverse_inc;am. am. am.
Qed.
Lemma integral_injective_l : forall g e u, is_ring g e u -> is_integral g e ->
forall a, inc a g -> a<>e -> Application.injective g g (ml a).
Proof.
ir;uhg;ee;uhg;ir.
ap H. am. am.
eapply integral_quasiregular_left. am. am.
ap H1. am. am. am. am.
Qed.
Lemma integral_injective_r : forall g e u, is_ring g e u -> is_integral g e ->
forall a, inc a g -> a<>e -> Application.injective g g (fun x => ml x a).
Proof.
ir;uhg;ee;uhg;ir.
ap H. am. am.
eapply integral_quasiregular_right. am. am.
ap H1. am. am. am. am.
Qed.
End Laws.
End Ring. Export Ring.
Module Ideal.
Section Law.
Variables (pl ml : E2) (a e u : E).
Hypothesis (rgH : is_ring pl ml a e u).
Definition is_ideal b :=
A (is_subgroup pl a e b)
(A (forall x, inc x (b) -> forall y, inc y (a) -> inc (ml x y) (b))
(forall x, inc x (b) -> forall y, inc y (a) -> inc (ml y x) (b))).
Definition ideal_of x := Im (fun z => ml x z) a.
Definition is_principal_ideal b := is_ideal b & (exists x, inc x (a) & b = ideal_of x).
Definition is_principal_ring := forall b, is_ideal b -> is_principal_ideal b.
Lemma ideal_of_ideal : commutative ml a ->
forall x, inc x (a) ->
is_principal_ideal (ideal_of x).
Proof.
ir. uhg. ee.
uhg;ee.
ap subgroup_show. am.
uf ideal_of. uhg;ir. apply Im_ex in H1;nin H1;ee;subst.
ap rgH;am.
exists e. ap Im_show_inc. exists e. ee. ap rgH.
symmetry;eapply ring_0_multr. ap rgH. am.
ir. ufi ideal_of H1;apply Im_ex in H1;nin H1;ee;subst.
ufi ideal_of H2;apply Im_ex in H2;nin H2;ee;subst.
cp rgH. uh H3;ee. uh H6;ee. wr H6;au.
ap Im_inc. ap H3. am. am.
ir. ufi ideal_of H1;apply Im_ex in H1;nin H1;ee;subst.
erewrite inverse_ml_insert_right. Focus 2. ap rgH.
ap Im_inc. ap group_inverse_inc;am.
am. am.
Focus 3. exists x. ee;au.
ir. ufi ideal_of H1;apply Im_ex in H1;nin H1;ee;subst.
cp rgH. uh H3;ee. uh H5;ee. wr H8;au.
ap Im_inc;au.
ir.
ufi ideal_of H1;apply Im_ex in H1;nin H1;ee;subst.
cp rgH. uh H3;ee. uh H5;ee. rw H8;au.
replace (ml y x) with (ml x y);au.
wr H8;au. ap Im_inc;au.
Qed.
Lemma principal_is_ideal : forall b, is_principal_ideal b -> is_ideal b.
Proof.
ir. uh H. nin H;ee. am.
Qed.
End Law.
Section Division.
Variables (pl ml : E2) (a e u : E).
Hypotheses (rgH : is_ring pl ml a e u)
(comH : commutative ml a).
Definition divides x y := exists z, inc z (a) & y = ml x z.
Lemma divide_ideal_rw : forall x y, inc x (a) -> inc y (a) ->
divides x y = (sub (ideal_of ml a y) (ideal_of ml a x)).
Proof.
ir. ap iff_eq;ir.
nin H1;ee. subst.
uhg;ir. ufi ideal_of H2;apply Im_ex in H2;nin H2;ee;subst.
cp rgH.
uh H3;ee. uh H5;ee. wr H8;au.
ap Im_inc. au.
uhg.
assert (inc y (ideal_of ml a y)).
ap Im_show_inc. exists u. ee. am.
symmetry;ap rgH. am. apply H1 in H2. apply Im_ex in H2. nin H2;ee;subst.
exists x0;ee;au.
Qed.
Lemma divides_refl : forall x, inc x a -> divides x x.
Proof.
ir. uhg.
exists u;ee. am.
symmetry. ap rgH. am.
Qed.
Lemma divides_transitiveT : forall x y z, inc x (a) -> inc y (a) -> inc z (a) ->
divides x y -> divides y z -> divides x z.
Proof.
ir. rw divide_ideal_rw;au. rwi divide_ideal_rw H3;rwi divide_ideal_rw H2;au.
uhg;ir;au.
Qed.
End Division.
End Ideal.
Module SubRing.
Section Law.
Variables (pl ml : E2).
Definition is_subring a e u b :=
A (sub (b) (a))
(is_ring pl ml b e u).
Lemma subring_subgroup : forall a e u b, is_subring a e u b -> is_subgroup pl a e b.
Proof.
ir. uhg. ee. am. am.
Qed.
Lemma show_ring_by_subring : forall b e u, (exists a, is_subring a e u b) -> is_ring pl ml b e u.
Proof.
ir. nin H. am.
Qed.
Lemma show_subring : forall a e u b, is_ring pl ml a e u ->
is_subgroup pl a e b ->
inc u (b) ->
(forall x, inc x b -> forall y, inc y b -> inc (ml x y) b) ->
is_subring a e u b.
Proof.
ir. assert (sub b a). am.
uhg;ee. am.
uhg. ee. am.
uhg;ir. ap H. au. au.
uh H;ee.
uhg;ee. am.
uhg;ee. am.
ir. ap H5. au.
ir. ap H5;au.
uhg;ir. ap H5;au.
uhg; ee;uhg;ir.
ap H;au. ap H;au.
Qed.
End Law.
End SubRing. Export SubRing.
Module Field.
Definition is_field pl ml a e u :=
A (is_ring pl ml a e u)
(forall x, inc x a -> x<>e -> inversible ml a u x).
Lemma field_integral : forall pl ml a e u, is_field pl ml a e u ->
is_integral ml a e. ir.
Proof.
uhg. ir.
apply by_cases with (a0 = e);ir.
left;am.
cp H3. apply H in H3.
nin H3;uh H3;ee.
assert (x<>e). uhg;ir.
rwi H8 H7. uh H;ee. cp H. rwi (ring_0_multl H) H7.
ap H4. uh H10;ee. uh H12;ee. uh H14;ee. symmetry. wr H16.
wr H7. symmetry. eapply ring_0_multr. ap H.
am. am. am.
assert (b = ml x e).
wr H2. uh H;ee. uh H;ee.
uh H11;ee. rw H14;try am. rw H7. symmetry.
ap H13;am.
right. rw H9. eapply ring_0_multr. ap H. am. am.
Qed.
Lemma field_mult_quasireg_l : forall pl ml g e u, is_field pl ml g e u ->
forall a b c, inc a g -> inc b g -> inc c g -> a<>e ->
ml a b = ml a c -> b = c.
Proof.
ir. eapply integral_quasiregular_left. ap H. eapply field_integral.
ap H. ap H0. am. am. am. am.
Qed.
Lemma field_mult_quasireg_r : forall pl ml g e u, is_field pl ml g e u ->
forall a b c, inc a g -> inc b g -> inc c g -> a<>e ->
ml b a = ml c a -> b = c.
Proof.
ir. eapply integral_quasiregular_right. ap H. eapply field_integral.
ap H. ap H0. am. am. am. am.
Qed.
Lemma field_mult_group : forall pl ml a e u, is_field pl ml a e u -> e<>u ->
is_group ml (Z a (fun x => x <> e)) u.
Proof.
ir.
assert (is_lci ml (Z a (fun x : E => x <> e))).
uhg;ir. Ztac;au. Ztac;au.
ap Z_inc. ap H;am.
uhg;ir. apply (field_integral H) in H5;try am.
nin H5;au.
uhg;ee. am.
uhg;ee. ap Z_inc. am. uhg;ir;au.
ir. Ztac;au.
ap H. am.
ir. ap H. Ztac;au.
uhg;ir. Ztac;au;Ztac;au;Ztac;au.
ap H;am.
ir.
Ztac;au. uh H;ee. cp (H4 x H2 H3).
nin H5.
exists x0.
uhg;ee. ap Z_inc;am.
ap Z_inc. am. uhg;ir;subst.
uh H5;ee. rwi (ring_0_multr H) H7. ap H0;am.
am.
am. am.
Qed.
Lemma field_inverse_of : forall pl ml a e u, is_field pl ml a e u ->
forall x, inc x (Z a (fun x => x<>e)) ->
are_inverse ml (Z a (fun x => x<>e)) u x (inverse_of ml a u x).
Proof.
ir. Ztac;au.
uh H;ee. cp (H2 x H0 H1).
apply inversible_inverse_of in H3.
uhg;ee;try am.
ap Z_inc;am. ap Z_inc. am.
uhg;ir;uh H3;ee.
rwi H4 H7. rwi (ring_0_multl H) H7;try am.
ap H1. replace x with (ml u x). wr H7.
ap (ring_0_multl H). am.
ap H. am.
am.
Qed.
End Field. Export Field.
(*
Module Fraction_field.
Export Quotient.
Section Law.
Variables (pl ml : E2) (r e u : E).
Hypotheses (rgH : is_ring pl ml r e u) (iH : is_integral ml r e) (cH : commutative ml r).
Hypothesis (uH : u<>e).
Definition qEquiv x y := ml (P x) (Q y) = ml (P y) (Q x).
Lemma qEquiv_zEquiv : qEquiv = Group_of_Monoid.zEquiv ml.
Proof.
uf Group_of_Monoid.zEquiv. ap arrow_extensionality;ir.
ap arrow_extensionality;ir. uf qEquiv. tv.
Qed.
Definition qBase := product r (Z r (fun x => x <> e)).
Lemma qEquiv_equivalence : is_equivalence qBase qEquiv.
Proof.
uhg;ee.
ir. uf qEquiv. tv.
ir. uhg. uh H1. symmetry. am.
ir. uh H2;uh H3.
uhg.
apply product_pr in H;ee. clear H;Ztac;clear H5.
apply product_pr in H0;ee. clear H0;Ztac;clear H7.
apply product_pr in H1;ee. clear H1;Ztac;clear H9.
cp (integral_quasiregular_right rgH iH).
apply H9 with (Q y).
am. ap rgH;am. ap rgH;am.
am.
assert (is_lci ml r). am.
rw cH;au. cp rgH. uh H12;ee. clear H11;clear H12;clear H13;clear H15.
uh H14. ee. rw H13;try am.
rwi cH H2;try am. rw H2.
symmetry. symmetry in H3.
rw cH;au. rw H13;try am.
rwi cH H3;try am. rw H3.
symmetry. rw cH;au. rw H13;try am.
rw (cH H1 H5). tv.
Qed.
Definition qF := quotient qBase qEquiv.
Definition qMl0 x y := J (ml (P x) (P y)) (ml (Q x) (Q y)).
Lemma qMl0_lci : is_lci qMl0 qBase.
Proof.
uhg;ir.
uf qMl0. apply product_pr in H;apply product_pr in H0.
ap product_pair_inc. ap rgH. am. am.
ee. Ztac;clear H2;Ztac;clear H4.
ap Z_inc. ap rgH;am.
uhg;ir. apply iH in H4. nin H4;au. am. am.
Qed.
Lemma qMl0_compat : forall a b, inc a r -> inc b r -> b<>e ->
forall a' b', inc a' r -> inc b' r -> b'<>e ->
qEquiv (J a b) (J a' b') ->
forall c d, inc c r -> inc d r -> d<>e ->
forall c' d', inc c' r -> inc d' r -> d'<>e ->
qEquiv (J c d) (J c' d') ->
qEquiv (qMl0 (J a b) (J c d)) (qMl0 (J a' b') (J c' d')).
Proof.
uf qEquiv;uf qMl0;ir.
clear_pr. clear_pr_in H12. clear_pr_in H5.
transitivity (ml (ml a b') (ml c d')).
assert (forall f:E1, forall x y, x=y -> f x = f y). ir. rw H13;tv.
assert (is_lci ml r). am. assert (associative ml r). am.
wr H15;au. symmetry. wr H15;au. ap H13.
rw cH;au. wr H15;au.
rw H5. rw H12.
assert (forall f:E1, forall x y, x=y -> f x = f y). ir. rw H13;tv.
assert (is_lci ml r). am. assert (associative ml r). am.
wr H15;au. symmetry. wr H15;au. ap H13.
rw cH;au. wr H15;au.
Qed.
Lemma qMl0_compat0 : forall a, inc a qBase -> forall a', inc a' qBase -> qEquiv a a' ->
forall b, inc b qBase -> forall b', inc b' qBase -> qEquiv b b' ->
qEquiv (qMl0 a b) (qMl0 a' b').
Proof.
ir.
apply product_pr in H;apply product_pr in H0;apply product_pr in H2;apply product_pr in H3;ee.
apply pair_recov in H;apply pair_recov in H0;apply pair_recov in H2;apply pair_recov in H3.
wr H;wr H0;wr H2;wr H3.
ap qMl0_compat;try am.
eapply Z_sub. am. apply Z_pr in H12;am.
eapply Z_sub. am. apply Z_pr in H10;am.
uhg. clear_pr. am.
eapply Z_sub. am. apply Z_pr in H8;am.
eapply Z_sub. am. apply Z_pr in H6;am.
uhg;clear_pr;am.
Qed.
Notation "[ x ]" := (class_of qBase qEquiv x).
Definition qMl x y := [ qMl0 (rep x) (rep y) ].
Lemma qMl_lci : is_lci qMl qF.
Proof.
uhg;ir.
uf qF;uf qMl;uf qMl0.
cp (in_quotient_is_class H). cp (in_quotient_is_class H0).
ap class_of_in_quotient.
ap qMl0_lci. assert (sub x qBase).
uh H1;ee. uh H1;ee. am.
ap H3. eapply class_rep_inc. ap H1.
assert (sub y qBase).
uh H2;ee. uh H2;ee. am.
ap H3. eapply class_rep_inc. ap H2.
Qed.
Lemma qMl_rep_rw0 : forall x y, inc x qBase -> inc y qBase ->
qMl [x] [y] = [ qMl0 x y ].
Proof.
ir. uf qMl.
ap related_classes_eq. ap qMl0_lci.
cp (class_sub (class_of_class qEquiv H)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
cp (class_sub (class_of_class qEquiv H0)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
ap qMl0_lci;am.
ap qMl0_compat0.
cp (class_sub (class_of_class qEquiv H)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
am.
eapply equivalent_related.
ap qEquiv_equivalence.
uhg. ee.
cp (class_sub (class_of_class qEquiv H)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
am.
ap class_of_rep. ap class_of_in_quotient. am.
cp (class_sub (class_of_class qEquiv H0)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
am.
eapply equivalent_related.
ap qEquiv_equivalence.
uhg. ee.
cp (class_sub (class_of_class qEquiv H0)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
am. ap class_of_rep.
ap class_of_in_quotient. am.
Qed.
Lemma qMl_rep_rw : forall a b, inc a r -> inc b r -> b<>e ->
forall c d, inc c r -> inc d r -> d<>e ->
qMl [J a b] [J c d] = [J (ml a c) (ml b d)].
Proof.
ir. rw qMl_rep_rw0. uf qMl0. clear_pr.
tv. ap product_pair_inc. am. ap Z_inc;am.
ap product_pair_inc. am. ap Z_inc;am.
Qed.
Definition qU := [ J u u ].
Lemma qU_inc : inc qU qF.
Proof.
ap class_of_in_quotient. ap product_pair_inc.
am. ap Z_inc. am. am.
Qed.
Lemma qMl_comm : commutative qMl qF.
Proof.
uhg;ir.
cp (class_of_rep H). cp (class_of_rep H0).
assert (inc (rep x) qBase).
eapply class_sub. ap in_quotient_is_class. ap H.
eapply class_rep_inc. ap in_quotient_is_class. ap H.
assert (inc (rep y) qBase).
eapply class_sub. ap in_quotient_is_class. ap H0.
eapply class_rep_inc. ap in_quotient_is_class. ap H0.
apply product_pr in H3;apply product_pr in H4;ee.
uf qMl. uf qMl0.
Ztac;clear H6;Ztac;clear H8.
rw (cH H7 H5). rw (cH H6 H9). tv.
Qed.
Lemma qRep_inc : forall x, inc x qF -> inc (rep x) qBase.
Proof.
ir.
eapply class_sub. ap in_quotient_is_class. ap H.
eapply class_rep_inc. ap in_quotient_is_class. ap H.
Qed.
Lemma qF_mult_monoid : is_monoid qMl qF qU.
Proof.
uhg;ee. ap qMl_lci.
uhg. assert (forall x : E, inc x qF -> qMl x qU = x).
ir. uf qU.
assert (inc (rep x) qBase).
eapply class_sub. ap in_quotient_is_class. ap H.
eapply class_rep_inc. ap in_quotient_is_class. ap H.
apply product_pr in H0;ee.
Ztac;clear H2.
assert ([rep x] = x). ap class_of_rep. am.
wr H2. rw qMl_rep_rw0.
uf qMl0. clear_pr.
cp rgH. uh H5;ee. uh H7;ee.
uh H9;ee. rw H11. rw H11. rw pair_recov. tv.
am. am. am. ap product_inc;try am. ap Z_inc;am.
ap product_pair_inc. am. ap Z_inc;am.
ee;try am.
ap qU_inc.
ir. rw qMl_comm. ap H. am.
ap qU_inc. am.
uhg;ir.
cp (class_of_rep H). cp (class_of_rep H0). cp (class_of_rep H1).
cp (qRep_inc H);cp (qRep_inc H0);cp (qRep_inc H1).
replace (qMl y z) with ([ qMl0 (rep y) (rep z)]).
replace (qMl x y) with ([ qMl0 (rep x) (rep y)]).
wr H2. rw qMl_rep_rw0.
rw H2. wr H4. rw qMl_rep_rw0.
rw H4.
uf qMl0. clear_pr.
apply product_pr in H5;ee;apply product_pr in H6;ee;apply product_pr in H7;ee.
Ztac;clear H13;Ztac;clear H11;Ztac;clear H9.
assert (is_lci ml r). am. assert (associative ml r). am.
rw H18;au. rw H18;au.
ap qMl0_lci;am. am. am. ap qMl0_lci;am.
uf qMl. tv. uf qMl. tv.
Qed.
Definition qE := [J e u].
Lemma qE_inc : inc qE qF.
Proof.
ap class_of_in_quotient. ap product_pair_inc.
am. ap Z_inc;am.
Qed.
Lemma qF_mult_inversible0 : forall a b, inc (J a b) qBase -> [J a b] <> qE ->
inversible qMl qF qU [J a b].
Proof.
ir.
exists [J b a].
apply product_pair_pr in H;ee;Ztac. clear H1.
uhg.
assert (aH : a<>e).
uhg;ir;subst. ap H0.
ap related_classes_eq. ap product_pair_inc.
am. ap Z_inc;am.
ap product_pair_inc.
am. ap Z_inc;am.
uhg;clear_pr.
rw (ring_0_multl rgH);try am. rw (ring_0_multl rgH);try am.
tv.
assert (preH : qMl [J a b] [J b a] = qU).
rw qMl_rep_rw.
rw cH;try am.
uf qU. ap related_classes_eq.
ap product_pair_inc. ap rgH;am.
ap Z_inc. ap rgH;am. uhg;ir.
apply iH in H1. nin H1;au.
am. am. ap product_pair_inc. am. ap Z_inc;am.
uhg;clear_pr.
assert (is_neutre ml r u). am.
uh H1;ee. rw H4;au. rw H5;au.
ap rgH;am. ap rgH;am.
am. am. am. am. am. am.
ee. ap class_of_in_quotient. ap product_pair_inc. am.
ap Z_inc;am.
ap class_of_in_quotient;ap product_pair_inc.
am. ap Z_inc;am.
am.
rw qMl_comm. am.
ap class_of_in_quotient;ap product_pair_inc.
am. ap Z_inc;am.
ap class_of_in_quotient;ap product_pair_inc.
am. ap Z_inc;am.
Qed.
Lemma qE_reps : forall x, inc x r -> x<>e ->
[J e x] = qE.
Proof.
ir. uf qE.
ap related_classes_eq.
ap product_pair_inc.
am. ap Z_inc;am.
ap product_pair_inc.
am. ap Z_inc;am.
uhg;clear_pr.
rw (ring_0_multl rgH). rw (ring_0_multl rgH).
tv. am. am.
Qed.
Lemma reps_qE : forall a b, inc a r -> inc b r -> b<>e ->
[J a b] = qE -> a=e.
Proof.
ir.
ufi qE H2.
assert (qEquiv (J a b) (J e u)). eapply equivalent_related.
ap qEquiv_equivalence. uhg;ee.
ap product_pair_inc. am. ap Z_inc;am.
ap product_pair_inc. am. ap Z_inc;am.
am.
uh H3;clear_pr_in H3.
rwi (ring_0_multl rgH) H3. apply iH in H3.
nin H3. am. ap False_rect;au.
am. am. am.
Qed.
Lemma qF_simplify : forall x, inc x r -> x<>e ->
forall a b, inc a r -> inc b r -> b<>e ->
[J (ml x a) (ml x b)] = [J a b].
Proof.
ir.
ap related_classes_eq.
ap product_pair_inc. ap rgH;am.
ap Z_inc. ap rgH;am.
uhg;ir. apply iH in H4. nin H4;au.
am. am.
apply product_pair_inc. am. ap Z_inc;am.
uhg;clear_pr.
assert (associative ml r). am.
wr H4;try am.
symmetry. rw cH;au.
wr H4;try am. rw (cH H1 H2). tv.
ap rgH;am.
Qed.
(* a/b + c/d = (ad + cb)/(bd)*)
Definition qPl0 x y := let a := P x in let b := Q x in let c := P y in let d := Q y in
J (pl (ml a d) (ml c b)) (ml b d).
Lemma qPl0_lci : forall x y, inc x qBase -> inc y qBase -> inc (qPl0 x y) qBase.
Proof.
ir. apply product_pr in H;apply product_pr in H0;ee.
Ztac;clear H2;Ztac;clear H4.
ap product_pair_inc.
repeat (ap rgH;try am).
ap Z_inc. ap rgH;am.
uhg;ir. apply iH in H4;try am.
nin H4;au.
Qed.
Lemma qPl0_comm : commutative qPl0 qBase.
Proof.
uhg;ir.
uf qPl0. cp rgH. uh H1;ee.
apply product_pr in H;apply product_pr in H0;ee.
Ztac;clear H6;Ztac;clear H8.
rw H2. rw (cH H9 H6). tv.
ap rgH;am. ap rgH;am.
Qed.
Notation "x + y" := (pl x y).
Notation "x * y" := (ml x y).
Lemma qPl0_compat : forall a b, inc a r -> inc b r -> b<>e ->
forall a' b', inc a' r -> inc b' r -> b'<>e ->
qEquiv (J a b) (J a' b') ->
forall c d, inc c r -> inc d r -> d<>e ->
forall c' d', inc c' r -> inc d' r -> d'<>e ->
qEquiv (J c d) (J c' d') ->
qEquiv (qPl0 (J a b) (J c d)) (qPl0 (J a' b') (J c' d')).
Proof.
ir.
uh H5;clear_pr_in H5;uh H12;clear_pr_in H12.
uhg. uf qPl0. clear_pr.
cp rgH.
cp (integral_quasiregular_right rgH iH).
cp (integral_quasiregular_left rgH iH).
uh H13;ee.
uh H13;ee;uh H17;ee.
rw H23;au.
uh H18;ee.
rw H24;au.
replace (a*d*b') with (a*b'*d).
Focus 2. wr H23;au. wr H23;au. rw (cH H3 H7). tv.
rw H5.
symmetry. rw (cH H0 H7).
rw H23;au. rw H24;au.
replace (c'*b'*d) with (c'*d*b').
Focus 2. wr H23;au;wr H23;au. rw (cH H7 H3). tv.
wr H12.
rw H24;au. rw H24;au.
replace (a' * d' * d * b) with (a' * b * d * d').
replace (c * d' * b' * b) with (c * b * b' * d').
tv.
wr H23;au. wr H23;au. wr H23;au.
rw (cH H3 H0).
assert (inc (b*b') r). ap rgH;am.
wr H23;au. rw (cH H10 H25).
wr H23;au.
wr H23;au. wr H23;au. wr H23;au.
rw (cH H7 H0).
assert (inc (b*d) r). ap rgH;am.
wr H23;au. rw (cH H10 H25).
wr H23;au.
Qed.
Lemma qPl0_compat0 : forall a, inc a qBase -> forall a', inc a' qBase -> qEquiv a a' ->
forall b, inc b qBase -> forall b', inc b' qBase -> qEquiv b b' ->
qEquiv (qPl0 a b) (qPl0 a' b').
Proof.
ir.
apply product_pr in H;apply product_pr in H0;apply product_pr in H2;apply product_pr in H3;ee.
apply pair_recov in H;apply pair_recov in H0;apply pair_recov in H2;apply pair_recov in H3.
wr H;wr H0;wr H2;wr H3.
ap qPl0_compat;try am.
eapply Z_sub. am. apply Z_pr in H12;am.
eapply Z_sub. am. apply Z_pr in H10;am.
uhg. clear_pr. am.
eapply Z_sub. am. apply Z_pr in H8;am.
eapply Z_sub. am. apply Z_pr in H6;am.
uhg;clear_pr;am.
Qed.
Definition qPl x y := [qPl0 (rep x) (rep y)].
Lemma qPl_rep_rw0 : forall x y, inc x qBase -> inc y qBase ->
qPl [x] [y] = [ qPl0 x y ].
Proof.
ir. uf qPl.
ap related_classes_eq. ap qPl0_lci.
cp (class_sub (class_of_class qEquiv H)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
cp (class_sub (class_of_class qEquiv H0)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
ap qPl0_lci;am.
ap qPl0_compat0.
cp (class_sub (class_of_class qEquiv H)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
am.
eapply equivalent_related.
ap qEquiv_equivalence.
uhg. ee.
cp (class_sub (class_of_class qEquiv H)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
am.
ap class_of_rep. ap class_of_in_quotient. am.
cp (class_sub (class_of_class qEquiv H0)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
am.
eapply equivalent_related.
ap qEquiv_equivalence.
uhg. ee.
cp (class_sub (class_of_class qEquiv H0)).
ap H1. eapply class_rep_inc. ap class_of_class. am.
am. ap class_of_rep.
ap class_of_in_quotient. am.
Qed.
Lemma qPl_rep_rw : forall a b, inc a r -> inc b r -> b<>e ->
forall c d, inc c r -> inc d r -> d<>e ->
qPl [J a b] [J c d] = [J (pl (ml a d) (ml c b)) (ml b d)].
Proof.
ir. rw qPl_rep_rw0. uf qPl0. clear_pr.
tv. ap product_pair_inc. am. ap Z_inc;am.
ap product_pair_inc. am. ap Z_inc;am.
Qed.
Lemma qPl_lci : is_lci qPl qF.
Proof.
uhg;ir.
uf qPl. ap class_of_in_quotient.
cp (in_quotient_is_class H);cp (in_quotient_is_class H0).
ap qPl0_lci.
assert (sub x qBase).
uh H1;ee. uh H1;ee. am.
ap H3. eapply class_rep_inc. ap H1.
assert (sub y qBase).
uh H2;ee. uh H2;ee. am.
ap H3. eapply class_rep_inc. ap H2.
Qed.
Lemma qPl_comm : commutative qPl qF.
Proof.
uhg;ir.
uf qPl. rw qPl0_comm. tv.
eapply class_sub. ap in_quotient_is_class. ap H.
eapply class_rep_inc. ap in_quotient_is_class. ap H.
eapply class_sub. ap in_quotient_is_class. ap H0.
eapply class_rep_inc. ap in_quotient_is_class. ap H0.
Qed.
Lemma qF_add_group : is_group qPl qF qE.
Proof.
assert (is_neutre qPl qF qE).
uf qE.
uhg. assert (forall x : E, inc x qF -> qPl x [J e u] = x).
ir.
cp (in_quotient_is_class H).
cp (class_of_rep H).
wr H1.
assert (inc (rep x) qBase).
eapply class_sub. ap in_quotient_is_class. ap H.
eapply class_rep_inc. ap in_quotient_is_class. ap H.
apply product_pr in H2;ee. Ztac;clear H4.
rw qPl_rep_rw0. uf qPl0. clear_pr.
rw (ring_0_multl rgH).
cp rgH. uh H4;ee. uh H8;ee.
uh H10;ee. rw H12. rw H12. uh H4;ee.
uh H14;ee. rw H17.
rw (pair_recov H2). tv.
am. am. am. am. ap product_inc. am.
am. ap Z_inc;am. ap product_pair_inc.
ap rgH. ap Z_inc;try ap rgH;am.
ee;au.
ap class_of_in_quotient. ap product_pair_inc.
am. ap Z_inc;am.
ir. rw qPl_comm. ap H;am.
ap class_of_in_quotient. ap product_pair_inc.
am. ap Z_inc;am.
am.
uhg;ee.
ap qPl_lci. am.
uhg;ir.
cp (class_of_rep H0). cp (class_of_rep H1).
cp (class_of_rep H2).
cp (qRep_inc H0). cp (qRep_inc H1). cp (qRep_inc H2).
wr H3. replace (qPl y z) with [qPl0 (rep y) (rep z)].
rw qPl_rep_rw0. rw H3.
replace (qPl x y) with ([qPl0 (rep x) (rep y)]).
wr H5. rw qPl_rep_rw0. rw H5.
uf qPl0. clear_pr.
assert ((P (rep x) * (Q (rep y) * Q (rep z)) +
(P (rep y) * Q (rep z) + P (rep z) * Q (rep y)) * Q (rep x)) = ((P (rep x) * Q (rep y) + P (rep y) * Q (rep x)) * Q (rep z) +
P (rep z) * (Q (rep x) * Q (rep y)))).
cp rgH. uh H9;ee.
uh H12;ee. uh H9;ee.
uh H11;ee.