forked from jrh13/hol-light
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCHANGES
26312 lines (19362 loc) · 893 KB
/
CHANGES
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
* *****************************************************************
* NB: This CHANGES file no longer gives a comprehensive list of *
* changes made to the system. In particular, most changes in the *
* Multivariate theories are excluded, simply because there are *
* so many of them that tracking them would be tedious. For more *
* detailed update lists, consult the git logs ("git log" if you *
* have the system downloaded) or the list of commits on the Web *
* page: https://github.com/jrh13/hol-light/commits/master *
* *****************************************************************
Thu 15th Sep 2022 EC/x25519.ml [new file]
Added a definition of x25519, the curve25519 x-coordinate mapping that
allows the y coordinate to live in an extension field, following
Bernstein's original paper and RFC-7748. This development includes the
auxiliary concept of a quadratic extension field, which is only used
to construct the special case (Z/(2^255-19))[sqrt(2)]). There are
two variants "purex25519" and "rfcx25519", with the latter adding the
specific prenormalization from the RFC (considering the inputs as
numbers).
curve25519x =
|- curve25519x f = f,ring_of_num f A_25519,ring_of_num f 1
curve25519x_curve25519 =
|- curve25519x (integer_mod_ring p_25519) = curve25519
curve25519x_group =
|- curve25519x_group f = montgomery_group (curve25519x f)
purex25519 =
|- !n q.
purex25519 (n,q) =
(@s. s < p_25519 /\
(!Q. Q IN group_carrier (curve25519x_group sqintmod_field) /\
montgomery_xmap sqintmod_field Q =
ring_of_num sqintmod_field q
==> montgomery_xmap sqintmod_field
(group_pow (curve25519x_group sqintmod_field) Q n) =
ring_of_num sqintmod_field s))
purex25519_def =
|- purex25519 (n,q) =
(if q MOD p_25519 = 0
then 0
else let X,Z = FST (x25519_ladder n (&q,&1)) in
let x = num_of_int (X rem &p_25519)
and z = num_of_int (Z rem &p_25519) in
if z = 0 then 0 else (x * inverse_mod p_25519 z) MOD p_25519)
quadratic_extension =
|- !a r.
quadratic_extension r a =
ring
(ring_carrier r CROSS ring_carrier r,
(ring_0 r,ring_0 r),
(ring_1 r,ring_0 r),
(\(x,y). ring_neg r x,ring_neg r y),
(\(x1,y1) (x2,y2). ring_add r x1 x2,ring_add r y1 y2),
(\(x1,y1) (x2,y2).
ring_add r (ring_mul r x1 x2)
(ring_mul r (ring_of_num r a) (ring_mul r y1 y2)),
ring_add r (ring_mul r x1 y2) (ring_mul r x2 y1)))
rfcx25519 =
|- rfcx25519 (n,q) =
purex25519 (2 EXP 254 + n MOD 2 EXP 254 - n MOD 8,q MOD 2 EXP 255)
sqintmod_field =
|- sqintmod_field = quadratic_extension (integer_mod_ring p_25519) 2
x25519_ladder =
|- x25519_ladder n P =
(if n = 0
then (&1,&0),P
else x25519_ladderstep (n MOD 2 = 1) P (x25519_ladder (n DIV 2) P))
x25519_ladderstep =
|- x25519_ladderstep b P (P0,P1) =
(if b
then montgomery_xzdiffadd curve25519 P P1 P0,
montgomery_xzdouble curve25519 P1
else montgomery_xzdouble curve25519 P0,
montgomery_xzdiffadd curve25519 P P1 P0)
CURVE25519X_CURVE25519_GROUP =
|- curve25519x_group (integer_mod_ring p_25519) = curve25519_group
CURVE25519X_GROUP =
|- !f. field f /\ ring_char f = p_25519
==> group_carrier (curve25519x_group f) =
montgomery_curve (curve25519x f) /\
group_id (curve25519x_group f) = NONE /\
group_inv (curve25519x_group f) = montgomery_neg (curve25519x f) /\
group_mul (curve25519x_group f) = montgomery_add (curve25519x f)
CURVE25519X_GROUP_GEN =
|- !f. field f /\ ~(ring_char f divides 14802493890)
==> group_carrier (curve25519x_group f) =
montgomery_curve (curve25519x f) /\
group_id (curve25519x_group f) = NONE /\
group_inv (curve25519x_group f) = montgomery_neg (curve25519x f) /\
group_mul (curve25519x_group f) = montgomery_add (curve25519x f)
FIELD_QUADRATIC_EXTENSION =
|- !r a.
field r /\
(!d. d IN ring_carrier r ==> ~(ring_pow r d 2 = ring_of_num r a))
==> field (quadratic_extension r a)
FIELD_SQINTMOD_FIELD =
|- field sqintmod_field
GROUP_POW_CURVE25519X_TORSION =
|- !f n.
field f /\ ring_char f = p_25519
==> group_pow (curve25519x_group f) (SOME (ring_0 f,ring_0 f)) n =
(if EVEN n then NONE else SOME (ring_0 f,ring_0 f))
MONTGOMERY_NONSINGULAR_CURVE25519X =
|- !f. field f /\ ring_char f = p_25519
==> montgomery_nonsingular (curve25519x f)
MONTGOMERY_NONSINGULAR_CURVE25519X_GEN =
|- !f. field f /\ ~(ring_char f divides 14802493890)
==> montgomery_nonsingular (curve25519x f)
PUREX25519 =
|- !f n q Q.
field f /\
ring_char f = p_25519 /\
Q IN group_carrier (curve25519x_group f) /\
montgomery_xmap f Q = ring_of_num f q
==> montgomery_xmap f (group_pow (curve25519x_group f) Q n) =
ring_of_num f (purex25519 (n,q))
PUREX25519_BOUND =
|- !n q. purex25519 (n,q) < p_25519
PUREX25519_LADDER =
|- !f x y n.
field f /\
ring_char f = p_25519 /\
SOME (ring_of_num f x,y) IN group_carrier (curve25519x_group f) /\
~(ring_of_num f x = ring_0 f)
==> (let (X,Z),X',Z' = x25519_ladder n (&x,&1) in
montgomery_xz f
(group_pow (curve25519x_group f) (SOME (ring_of_num f x,y)) n)
(ring_of_int f X,ring_of_int f Z) /\
montgomery_xz f
(group_pow (curve25519x_group f) (SOME (ring_of_num f x,y))
(n + 1))
(ring_of_int f X',ring_of_int f Z'))
PUREX25519_MOD =
|- !n q. purex25519 (n,q MOD p_25519) = purex25519 (n,q)
PUREX25519_UNIQUE =
|- !n q s.
purex25519 (n,q) = s <=>
s < p_25519 /\
(!Q. Q IN group_carrier (curve25519x_group sqintmod_field) /\
montgomery_xmap sqintmod_field Q = ring_of_num sqintmod_field q
==> montgomery_xmap sqintmod_field
(group_pow (curve25519x_group sqintmod_field) Q n) =
ring_of_num sqintmod_field s)
PUREX25519_UNIQUE_IMP =
|- !n q s.
s < p_25519 /\
(!f Q.
field f /\
ring_char f = p_25519 /\
Q IN group_carrier (curve25519x_group f) /\
montgomery_xmap f Q = ring_of_num f q
==> montgomery_xmap f (group_pow (curve25519x_group f) Q n) =
ring_of_num f s)
==> purex25519 (n,q) = s
QUADRATIC_EXTENSION =
|- (!r a.
ring_carrier (quadratic_extension r a) =
ring_carrier r CROSS ring_carrier r) /\
(!r a. ring_0 (quadratic_extension r a) = ring_0 r,ring_0 r) /\
(!r a. ring_1 (quadratic_extension r a) = ring_1 r,ring_0 r) /\
(!r a.
ring_neg (quadratic_extension r a) =
(\(x,y). ring_neg r x,ring_neg r y)) /\
(!r a.
ring_add (quadratic_extension r a) =
(\(x1,y1) (x2,y2). ring_add r x1 x2,ring_add r y1 y2)) /\
(!r a.
ring_mul (quadratic_extension r a) =
(\(x1,y1) (x2,y2).
ring_add r (ring_mul r x1 x2)
(ring_mul r (ring_of_num r a) (ring_mul r y1 y2)),
ring_add r (ring_mul r x1 y2) (ring_mul r x2 y1)))
RFCX25519_PUREX25519 =
|- !n q.
n IN {2 EXP 254 + 8 * i | i < 2 EXP 251} /\ q < 2 EXP 255
==> rfcx25519 (n,q) = purex25519 (n,q)
RING_CHAR_QUADRATIC_EXTENSION =
|- !r a. ring_char (quadratic_extension r a) = ring_char r
RING_CHAR_SQINTMOD_FIELD =
|- ring_char sqintmod_field = p_25519
RING_HOMOMORPHISM_INTO_QUADRATIC_EXTENSION =
|- !r a. ring_homomorphism (r,quadratic_extension r a) (\x. x,ring_0 r)
RING_MONOMORPHISM_INTO_QUADRATIC_EXTENSION =
|- !r a. ring_monomorphism (r,quadratic_extension r a) (\x. x,ring_0 r)
RING_OF_INT_QUADRATIC_EXTENSION =
|- !r a n.
ring_of_int (quadratic_extension r a) n = ring_of_int r n,ring_0 r
RING_OF_NUM_QUADRATIC_EXTENSION =
|- !r a n.
ring_of_num (quadratic_extension r a) n = ring_of_num r n,ring_0 r
SPECIALLY_NONSINGULAR_CURVE25519X =
|- !f X y.
field f /\
ring_char f = p_25519 /\
montgomery_curve (curve25519x f) (SOME (ring_of_num f X,y))
==> (y = ring_0 f <=> ring_of_num f X = ring_0 f)
SQUARE_ROOTS_SQINTMOD_FIELD =
|- !n. ?x. x IN ring_carrier sqintmod_field /\
ring_pow sqintmod_field x 2 = ring_of_num sqintmod_field n
Thu 15th Sep 2022 EC/montgomery.ml, EC/xzprojective.ml
Added a definition of the X coordinate mapping for Montgomery curves
(with zero default for the point at infinity) as used in the definition
of curve25519-related functions, and a few lemmas, mainly about that.
montgomery_xmap
|- montgomery_xmap f NONE = ring_0 f /\ montgomery_xmap f (SOME (x,y)) = x
GROUP_POW_MONTGOMERY_TORSION =
|- !f a b P n.
field f /\
~(ring_char f = 2) /\
a IN ring_carrier f /\
b IN ring_carrier f /\
montgomery_nonsingular (f,a,b)
==> group_pow (montgomery_group (f,a,b)) (SOME (ring_0 f,ring_0 f))
n =
(if EVEN n then NONE else SOME (ring_0 f,ring_0 f))
MONTGOMERY_XMAP_EQ_0
|- !f a b P.
field f /\
~(ring_char f = 2) /\
a IN ring_carrier f /\
b IN ring_carrier f /\
montgomery_nonsingular (f,a,b) /\
P IN group_carrier (montgomery_group (f,a,b))
==> (montgomery_xmap f P = ring_0 f <=>
P = NONE \/ P = SOME (ring_0 f,ring_0 f))
MONTGOMERY_XMAP_EQ_0_POW
|- !f a b P n.
field f /\
~(ring_char f = 2) /\
a IN ring_carrier f /\
b IN ring_carrier f /\
montgomery_nonsingular (f,a,b) /\
P IN group_carrier (montgomery_group (f,a,b)) /\
montgomery_xmap f P = ring_0 f
==> montgomery_xmap f (group_pow (montgomery_group (f,a,b)) P n) =
ring_0 f
MONTGOMERY_XZ_XMAP
|- !f P X.
field f /\ X IN ring_carrier f /\ ~(X = ring_0 f)
==> (montgomery_xz f P (X,ring_1 f) <=> montgomery_xmap f P = X)
Tue 13th Sep 2022 Library/ringtheory.ml
Added a miscellany of straightforward ring theory lemmas:
FIELD_NONTRIVIAL =
|- !f. field f ==> ~(ring_1 f = ring_0 f)
INTEGRAL_DOMAIN_NONTRIVIAL =
|- !r. integral_domain r ==> ~(ring_1 r = ring_0 r)
RING_CHAR_HOMOMORPHIC_IMAGE =
|- !r r' f. ring_homomorphism (r,r') f ==> ring_char r' divides ring_char r
RING_HOMOMORPHISM_FROM_INTEGER_MOD_RING =
|- !r p.
(?f. ring_homomorphism (integer_mod_ring p,r) f) <=>
ring_char r divides p
RING_HOMOMORPHISM_INTEGER_MOD_RING_OF_INT =
|- !r p.
ring_homomorphism (integer_mod_ring p,r) (ring_of_int r) <=>
ring_char r divides p
RING_MONOMORPHISM_FROM_INTEGER_MOD_RING =
|- !r p.
(?f. ring_monomorphism (integer_mod_ring p,r) f) <=> ring_char r = p
RING_MONOMORPHISM_INTEGER_MOD_RING_OF_INT =
|- !r p.
ring_monomorphism (integer_mod_ring p,r) (ring_of_int r) <=>
ring_char r = p
RING_OF_INT_CLAUSES =
|- (!r. ring_0 r = ring_of_int r (&0)) /\
(!r. ring_1 r = ring_of_int r (&1)) /\
(!r n. ring_neg r (ring_of_int r n) = ring_of_int r (--n)) /\
(!r m n.
ring_add r (ring_of_int r m) (ring_of_int r n) =
ring_of_int r (m + n)) /\
(!r m n.
ring_sub r (ring_of_int r m) (ring_of_int r n) =
ring_of_int r (m - n)) /\
(!r m n.
ring_mul r (ring_of_int r m) (ring_of_int r n) =
ring_of_int r (m * n)) /\
(!r m n. ring_pow r (ring_of_int r m) n = ring_of_int r (m pow n))
RING_OF_INT_REM =
|- !f n. ring_of_int f (n rem &(ring_char f)) = ring_of_int f n
RING_OF_NUM_CHAR =
|- !r. ring_of_num r (ring_char r) = ring_0 r
RING_OF_NUM_CLAUSES =
|- (!r. ring_0 r = ring_of_num r 0) /\
(!r. ring_1 r = ring_of_num r 1) /\
(!r m n.
ring_add r (ring_of_num r m) (ring_of_num r n) =
ring_of_num r (m + n)) /\
(!r m n.
ring_mul r (ring_of_num r m) (ring_of_num r n) =
ring_of_num r (m * n)) /\
(!r m n. ring_pow r (ring_of_num r m) n = ring_of_num r (m EXP n))
RING_OF_NUM_MOD =
|- !f n. ring_of_num f (n MOD ring_char f) = ring_of_num f n
as well as renaming the old RING_OF_INT_CLAUSES -> RING_OF_INT_CASES,
with the above theorem taking the name RING_OF_INT_CLAUSES.
Mon 12th Sep 2022 ind_types.ml
Added a natural dual to FORALL_OPTION_THM:
EXISTS_OPTION_THM =
|- !P. (?x. P x) <=> P NONE \/ ?a. P(SOME a)
Wed 7th Sep 2022 Library/ringtheory.ml
Fixed a trivial bug in RING_TAC that could make it fail on trivial
goals having no domain variables, e.g.
prove(`ring_0 r = ring_add r (ring_0 r) (ring_0 r)`,RING_TAC);;
Fri 26th Aug 2022 realarith.ml
Added an improvement from Chun Tian to REAL_LINEAR_PROVER, making
it automatically recognize strict positivity of "successor" terms
cast to reals, of the form `&(SUC n)`.
REAL_LT_NZ =
|- !n. ~(&n = &0) <=> (&0 < &n)
REAL_POS_LT =
|- !n. &0 < &(SUC n)
Tue 23rd Aug 2022 EC/passim
Added a few short names for the package of parameters defining some
common elliptic curves:
curve25519 =
|- curve25519 = integer_mod_ring p_25519,&A_25519,&1
nistp256 =
|- nistp256 =
integer_mod_ring p_256,ring_neg (integer_mod_ring p_256) (&3),&b_256
nistp384 =
|- nistp384 =
integer_mod_ring p_384,ring_neg (integer_mod_ring p_384) (&3),&b_384
nistp521 =
|- nistp521 =
integer_mod_ring p_521,ring_neg (integer_mod_ring p_521) (&3),&b_521
secp256k1 =
|- secp256k1 =
integer_mod_ring p_256k1,&0,&7
and a few additional Montgomery curve lemmas:
MONTGOMERY_NONSINGULAR_CURVE25519 =
|- montgomery_nonsingular curve25519
MONTGOMERY_STRONGLY_NONSINGULAR_CURVE25519 =
|- montgomery_strongly_nonsingular curve25519
MONTGOMERY_XZ_IN_CARRIER =
|- !P X Z.
montgomery_xz f P (X,Z)
==> X IN ring_carrier f /\ Z IN ring_carrier f
MONTGOMERY_XZDOUBLE_GROUP =
|- !f a b p n q.
field f /\
~(ring_char f = 2) /\
a IN ring_carrier f /\
b IN ring_carrier f /\
montgomery_nonsingular (f,a,b) /\
p IN group_carrier (montgomery_group (f,a,b)) /\
montgomery_xz f (group_pow (montgomery_group (f,a,b)) p n) q
==> montgomery_xz f (group_pow (montgomery_group (f,a,b)) p (2 * n))
(montgomery_xzdouble (f,a,b) q)
MONTGOMERY_XZDIFFADD_GROUP =
|- !f a b p n q qm qn.
field f /\
~(ring_char f = 2) /\
~(ring_char f = 3) /\
a IN ring_carrier f /\
b IN ring_carrier f /\
montgomery_nonsingular (f,a,b) /\
~(FST q = ring_0 f) /\
~(SND q = ring_0 f) /\
p IN group_carrier (montgomery_group (f,a,b)) /\
montgomery_xz f p q /\
montgomery_xz f (group_pow (montgomery_group (f,a,b)) p (n + 1)) qm /\
montgomery_xz f (group_pow (montgomery_group (f,a,b)) p n) qn
==> montgomery_xz f
(group_pow (montgomery_group (f,a,b)) p (2 * n + 1))
(montgomery_xzdiffadd (f,a,b) q qm qn)
Mon 1st Aug 2022 Library/words.ml
Added a straightforward variant of existing word lemmas:
REAL_VAL_WORD_XOR =
|- !x y.
&(val(word_xor x y)) =
(&(val x) + &(val y)) - &2 * &(val(word_and x y))
Wed 27th Jul 2022 tactics.ml, define.ml, meson.ml, Examples/holby.ml, Examples/mizar.ml, 100/e_is_transcendental.ml
Made "prove" explicitly check that the result does not include any
additional assumptions. This seems usually what is expected (if not
TAC_PROOF can be used directly). There were just a few places
where the original behavior was used essentially, and those have
been updated.
Mon 25th Jul 2022 EC/computegroup.ml
Slightly improved the efficiency of ECGROUP_MUL_CONV using a more
refined reduction strategy.
Mon 25th Jul 2022 pair.ml
Added SUBLET_CONV, to apply a conversion to the RHSs of the toplevel
let-term but neither expand it as with let_CONV nor apply the
conversion to the body, e.g.
# SUBLET_CONV NUM_ADD_CONV
`let x = 5 + 2 and y = 8 + 17 and z = 3 + 7 in x + y + z`;;
val it : thm =
|- (let x = 5 + 2 and y = 8 + 17 and z = 3 + 7 in x + y + z) =
(let x = 7 and y = 25 and z = 10 in x + y + z)
Tue 10th May 2022 EC/edwards448.ml [new file], Library/grouptheory.ml
Added a formalization of the "Goldilocks" curve edwards448, based on Mike
Hamburg's paper "Ed448-Goldilocks" (https://eprint.iacr.org/2015/625.pdf).
So far, we just have the Edwards form of it as in that paper. This is all
highly analogous to curve25519.ml, except that the group order computation
is a bit more involved: to avoid using a more refined Hasse-type bound
we need to do a bit of explicit analysis of the low-order points because
the group order is less than half of the very naive bound.
Also made a couple of trivial variable name tweaks to grouptheory.ml to
avoid name clashes with "decode" and "encode" when loaded with some other
theories.
Fri 22nd Apr 2022 GL/*
Added an update from Marco Maggesi and Cosimo Perini Brogi to their GL
provability logic theory. This now includes a decision procedure (GL_RULE
and GL_TAC) for the GL logic that will prove a valid formula or generate
a countermodel for an invalid one (stored in "!the_gl_countermodel").
This example, in the provability interpretation, corresponds to a
formalized Goedel's Second Incompleteness Theorem: if a system is
consistent it does not prove its own consistency. The file GL/decid.ml
has a number of applications of this kind:
# GL_RULE `|-- (Not (Box False) --> Not (Box (Not (Box False))))`;;
val it : thm = |- |-- (Not Box False --> Not Box Not Box False)
Wed 6th Apr 2022 EC/* [new directory], Examples/nist_curves.ml [deleted]
Replaced the increasingly unwieldy and poorly-named "nist_curves.ml"
file with a new directory "EC" (for Elliptic Curves) that develops
elliptic curve theory in a more systematic way, with separate files
for all the specific curves, as well as adding new material,
particularly around Edwards curves. The general short Weierstrass,
Montgomery and Edwards forms are defined and their properties derived
separately to minimize interdependencies, and here the only field
characteristic assumptions made are common or natural ones: char = 2
and char = 3 are excluded for short Weierstrass, just char = 2 is
excluded for Montgomery, and in principle there are no restrictions at
all on the Edwards theory (though "edwards_nonsingular" cannot be
satisfied in a *finite* field of characteristic 2 since then every
element is a square).
Wed 6th Apr 2022 lists.ml
Added a little clausal rewrite for BUTLAST:
BUTLAST_CLAUSES =
|- BUTLAST [] = [] /\
(!a. BUTLAST [a] = []) /\
(!a h t. BUTLAST(CONS a (CONS h t)) = CONS a (BUTLAST(CONS h t)))
Mon 4th Apr 2022 Library/ringtheory.ml
Fixed a prenormalization bug where RING_RULE and RING_TAC were not
handling the general case of "ring_of_num r n".
Fri 1st Apr 2022 Library/ringtheory.ml
Added a few more trivial theorems about terms involving inversion being
zero in a field and a handy collection of the various individual closure
properties (RING_ADD, RING_POW etc.) into a single clausal theorem:
FIELD_DIV_EQ_0 =
|- !f x y.
field f /\ x IN ring_carrier f /\ y IN ring_carrier f
==> (ring_div f x y = ring_0 f <=> x = ring_0 f \/ y = ring_0 f)
FIELD_INV_EQ_0 =
|- !f x.
field f /\ x IN ring_carrier f
==> (ring_inv f x = ring_0 f <=> x = ring_0 f)
RING_1_DIV =
|- !r x. x IN ring_carrier r ==> ring_div r (ring_1 r) x = ring_inv r x
RING_CLAUSES =
|- (!r. ring_0 r IN ring_carrier r) /\
(!r. ring_1 r IN ring_carrier r) /\
(!r n. ring_of_num r n IN ring_carrier r) /\
(!r x. x IN ring_carrier r ==> ring_neg r x IN ring_carrier r) /\
(!r x. x IN ring_carrier r ==> ring_inv r x IN ring_carrier r) /\
(!r x y.
x IN ring_carrier r /\ y IN ring_carrier r
==> ring_add r x y IN ring_carrier r) /\
(!r x y.
x IN ring_carrier r /\ y IN ring_carrier r
==> ring_sub r x y IN ring_carrier r) /\
(!r x y.
x IN ring_carrier r /\ y IN ring_carrier r
==> ring_mul r x y IN ring_carrier r) /\
(!r x y.
x IN ring_carrier r /\ y IN ring_carrier r
==> ring_div r x y IN ring_carrier r) /\
(!r x n. x IN ring_carrier r ==> ring_pow r x n IN ring_carrier r)
Tue 29th Mar 2022 Library/grouptheory.ml
Added a couple more lemmas about orders of powers in groups:
GROUP_ELEMENT_ORDER_EQ_MUL_GEN =
|- !G x k n.
x IN group_carrier G /\ ~(k = 0)
==> (group_element_order G x = k * n <=>
k divides group_element_order G x /\
group_element_order G (group_pow G x k) = n)
GROUP_ELEMENT_ORDER_EQ_MUL =
|- !G x k n.
x IN group_carrier G /\ ~(k = 0) /\ k divides n
==> (group_element_order G x = k * n <=>
group_element_order G (group_pow G x k) = n)
Wed 23rd Mar 2022 Library/ringtheory.ml
Added one more trivial rewrite that's handy to hide explicit case splits
over the trivial case of integers modulo:
IN_INTEGER_MOD_RING_CARRIER =
|- !n a.
a IN ring_carrier(integer_mod_ring n) <=>
&n = &0 \/ &0 <= a /\ a < &n
Wed 16th Mar 2022 Library/ringtheory.ml
Added some basic support for generic field automation to the ring theory,
adapted and extended from material already there in "nist_curves.ml".
This includes an elimination-based tactic FIELD_TAC as well as a more
directed "pull division terms up" tactic RING_PULL_DIV_TAC and its
contextual conversion RING_PULL_DIV_CONV, these based on the following
new clausal theorem:
|- !f. field f
==> (!x y n.
x IN ring_carrier f /\ y IN ring_carrier f
==> ring_pow f (ring_div f x y) n =
ring_div f (ring_pow f x n) (ring_pow f y n)) /\
(!x1 y1 x2 y2.
x1 IN ring_carrier f /\
x2 IN ring_carrier f /\
y1 IN ring_carrier f /\
y2 IN ring_carrier f
==> ring_div f (ring_div f x1 y1) (ring_div f x2 y2) =
ring_div f (ring_mul f x1 y2) (ring_mul f x2 y1)) /\
(!x1 x2 y.
x1 IN ring_carrier f /\
x2 IN ring_carrier f /\
y IN ring_carrier f /\
~(y = ring_0 f)
==> ring_add f (ring_div f x1 y) (ring_div f x2 y) =
ring_div f (ring_add f x1 x2) y /\
ring_sub f (ring_div f x1 y) (ring_div f x2 y) =
ring_div f (ring_sub f x1 x2) y /\
(ring_div f x1 y = ring_div f x2 y <=> x1 = x2) /\
ring_add f (ring_div f x1 y) x2 =
ring_div f (ring_add f x1 (ring_mul f x2 y)) y /\
ring_add f x1 (ring_div f x2 y) =
ring_div f (ring_add f (ring_mul f x1 y) x2) y /\
ring_sub f (ring_div f x1 y) x2 =
ring_div f (ring_sub f x1 (ring_mul f x2 y)) y /\
ring_sub f x1 (ring_div f x2 y) =
ring_div f (ring_sub f (ring_mul f x1 y) x2) y /\
ring_mul f (ring_div f x1 y) x2 =
ring_div f (ring_mul f x1 x2) y /\
ring_mul f x1 (ring_div f x2 y) =
ring_div f (ring_mul f x1 x2) y /\
(ring_div f x1 y = x2 <=> x1 = ring_mul f x2 y) /\
(x1 = ring_div f x2 y <=> ring_mul f x1 y = x2)) /\
(!x y.
x IN ring_carrier f /\
y IN ring_carrier f /\
~(x = ring_0 f) /\
~(y = ring_0 f)
==> ~(ring_mul f x y = ring_0 f)) /\
(!x n.
x IN ring_carrier f /\ ~(x = ring_0 f)
==> ~(ring_pow f x n = ring_0 f))
Wed 16th Mar 2022 Library/pocklington.ml
Removed some functions around primality proving from "nist_curves.ml" and
put them in the main "pocklington.ml" file, as well as filling out the
functions a bit. The new functions are:
general_certify_prime - Like certify_prime with any factorizing function
guided_certify_prime - Taking a set of hereditary sub-factors as a hint
extract_primes_from_certificate - Getting such sub-factor hints from number
GUIDED_PROVE_PRIME, PRIME_RULE - Proving primality with sub-factor hints
Mon 14th Mar 2022 Library/integer.ml
Did a bit of renaming to resolve a name clash with the core "int_coprime"
theorem from int.ml, renaming int_coprime -> INT_COPRIME and the former
INT_COPRIME -> INT_COPRIME_ALT in this file, so now:
int_coprime =
|- !a b. coprime(a,b) <=> (?x y. a * x + b * y = &1)
INT_COPRIME =
|- !a b.
coprime(a,b) <=> (!d. d divides a /\ d divides b ==> d divides &1)
INT_COPRIME_ALT =
|- !a b.
coprime(a,b) <=> (!d. d divides a /\ d divides b <=> d divides &1)
Fri 11th Mar 2022 Library/ringtheory.ml
Added a few more handy facts about "integer_mod_ring", as well
as defining the ring/field of real numbers explicitly as a ring
structure and proving the usual facts about that too:
real_ring =
|- real_ring = ring ((:real),&0,&1,(--),(+),(*))
FIELD_REAL_RING =
|- field real_ring
INTEGER_MOD_RING_CARRIER_REM =
|- !n x. x rem &n IN ring_carrier (integer_mod_ring n)
INTEGER_MOD_RING_CLAUSES =
|- ring_carrier (integer_mod_ring 0) = (:int) /\
(!n. 0 < n
==> ring_carrier (integer_mod_ring n) = {m | &0 <= m /\ m < &n}) /\
(!n. ring_0 (integer_mod_ring n) = &0) /\
(!n. ring_1 (integer_mod_ring n) = &1 rem &n) /\
(!n. ring_neg (integer_mod_ring n) = (\a. --a rem &n)) /\
(!n. ring_add (integer_mod_ring n) = (\a b. (a + b) rem &n)) /\
(!n. ring_sub (integer_mod_ring n) = (\a b. (a - b) rem &n)) /\
(!n. ring_mul (integer_mod_ring n) = (\a b. (a * b) rem &n)) /\
(!n. ring_pow (integer_mod_ring n) = (\a k. a pow k rem &n)) /\
(!n. ring_of_num (integer_mod_ring n) = (\k. &k rem &n)) /\
(!n. ring_of_int (integer_mod_ring n) = (\x. x rem &n))
INTEGER_MOD_RING_SUB =
|- !n. ring_sub (integer_mod_ring n) = (\a b. (a - b) rem &n)
INTEGRAL_DOMAIN_REAL_RING =
|- integral_domain real_ring
REAL_FIELD_CLAUSES =
|- ring_carrier real_ring = (:real) /\
ring_0 real_ring = &0 /\
ring_1 real_ring = &1 /\
ring_neg real_ring = (--) /\
ring_add real_ring = (+) /\
ring_mul real_ring = (*) /\
ring_of_num real_ring = & /\
ring_sub real_ring = (-) /\
ring_inv real_ring = inv /\
ring_div real_ring = (/) /\
ring_pow real_ring = (pow)
REAL_RING_CHAR =
|- ring_char real_ring = 0
REAL_RING_CLAUSES =
|- ring_carrier real_ring = (:real) /\
ring_0 real_ring = &0 /\
ring_1 real_ring = &1 /\
ring_neg real_ring = (--) /\
ring_add real_ring = (+) /\
ring_mul real_ring = (*)
REAL_RING_DIV =
|- ring_div real_ring = (/)
REAL_RING_INV =
|- ring_inv real_ring = inv
REAL_RING_OF_INT =
|- ring_of_int real_ring = real_of_int
REAL_RING_OF_NUM =
|- ring_of_num real_ring = &
REAL_RING_POW =
|- ring_pow real_ring = (pow)
REAL_RING_SUB =
|- ring_sub real_ring = (-)
Fri 4th Mar 2022 Examples/nist_curves.ml
Added a formalization of curve25519, and Montgomery curves in general,
to the increasingly inaccurately-named "nist_curves.ml" file. Mainly
for ease of re-use of the existing short Weierstrass material, the
properties of Montgomery operations are first derived from their
Weierstrass versions via the standard mapping, even defining the
"wei25519" curve as the short Weierstrass variant (nomenclature taken
from Struik's "Alternative Elliptic Curve Representations"). After
that, all the usual things are proved about curve25519, including the
y-free doubling and differential addition operations (following
Bernstein and Lange, "Montgomery cuves and the Montgomery ladder") and
a y-recovery formula (from Okeya and Sakurai). Also filled out the
earlier curve material with some additional facts, most interestingly
a standard easily computable endomorphism of secp256k1.
Thu 24th Feb 2022 Library/grouptheory.ml
Added this somewhat technical lemma which is handy for explicitly
creating a group as an isomorphic image and not then doing a
separate proof of group-ness and the isomorphism with the original:
CREATE_ISOMORPHIC_COPY_OF_GROUP =
|- !f g G s z i m.
z IN s /\
(!x. x IN group_carrier G ==> f x IN s /\ g (f x) = x) /\
(!y. y IN s ==> g y IN group_carrier G /\ f (g y) = y) /\
g z = group_id G /\
(!x. x IN s ==> i x = f (group_inv G (g x))) /\
(!x y. x IN s /\ y IN s ==> m x y = f (group_mul G (g x) (g y)))
==> group_isomorphisms (G,group (s,z,i,m)) (f,g) /\
group_carrier (group (s,z,i,m)) = s /\
group_id (group (s,z,i,m)) = z /\
group_inv (group (s,z,i,m)) = i /\
group_mul (group (s,z,i,m)) = m
Wed 23rd Feb 2022 Library/ringtheory.ml
Added an explicit conversion INTEGER_MOD_RING_RED_CONV for computing
terms in "integer_mod_ring n" (for nonzero n, the case of n = 0 being
just the integers anyway). This also adds the theorem:
RING_INV_INTEGER_MOD_RING =
|- !n a.
ring_inv (integer_mod_ring n) (&a) =
(if (n = 0 \/ ~(n = 1) /\ a < n) /\ coprime(a,n)
then &(inverse_mod n a) else &0)
This introduces a dependency on the Library/pocklington.ml file for
some additional material about "inverse_mod".
Wed 23rd Feb 2022 calc_num.ml, int.ml, Library/pocklington.ml
Moved EXP_MOD_CONV from "Library/pocklington.ml" into the core (in the
process slightly improving the implementation) and added an analogous
integer form INT_POW_REM_CONV.
Wed 23rd Feb 2022 Library/pocklington.ml
Added INVERSE_MOD_CONV, an explicit calculation conversion for modular
inverse terms of the form `inverse_mod m n` for numerals m and n.
Tue 7th Dec 2021 Library/words.ml
Added one more little missing lemma:
BIT_WORD_BITVAL =
|- !b i. bit i (word(bitval b):N word) <=> i = 0 /\ b
Thu 25th Nov 2021 Examples/nist_curves.ml
Added the other SECG curves defined over prime order fields: secp192k1,
secp224k1 and secp256k1 (the Bitcoin curve). This extends the existing
NIST curve material with the same verification of basic data like
number of points on the curve, and adds some possible computational
formulas in projective and Jacobian coordinates for Weierstrass curves
like these with a = 0.
Wed 10th Nov 2021 Library/words.ml
Added a new construct "bits_of_num" analogous to "bits_of_word" but
for actual numbers not words. The suite of theorems about it helps
with some kinds of "effectively bitwise" reasoning on natural numbers
such as pushing division and modulus w.r.t. powers of 2 through sums
based on the intuition that the bit patterns are not overlapping
(DIV_MOD_DISJOINT_BITS, DISJOINT_BITS_CLAUSES)
bits_of_num =
|- !n. bits_of_num n = {i | numbit i n}
BITSUM_BOUND =
|- !s k.
FINITE s
==> (nsum s (\i. 2 EXP i) < 2 EXP k <=> s SUBSET {i | i < k})
BITSUM_DIVIDES =
|- !s k.
FINITE s
==> (2 EXP k divides nsum s (\i. 2 EXP i) <=>
DISJOINT {i | i < k} s)
BITS_OF_NUM_0 =
|- bits_of_num 0 = {}
BITS_OF_NUM_1 =
|- bits_of_num 1 = {0}
BITS_OF_NUM_ADD =
|- !m n.
DISJOINT (bits_of_num m) (bits_of_num n)
==> bits_of_num(m + n) = bits_of_num m UNION bits_of_num n
BITS_OF_NUM_DISJOINT_NUMSEG_EQ =
|- !n k. DISJOINT {i | i < k} (bits_of_num n) <=> 2 EXP k divides n
BITS_OF_NUM_DIV =
|- !n k. bits_of_num(n DIV 2 EXP k) = {i | k + i IN bits_of_num n}
BITS_OF_NUM_EQ =
|- !m n. bits_of_num m = bits_of_num n <=> m = n
BITS_OF_NUM_GALOIS =
|- !n s. bits_of_num n = s <=> FINITE s /\ nsum s (\i. 2 EXP i) = n
BITS_OF_NUM_MOD =
|- !n k. bits_of_num(n MOD 2 EXP k) = {i | i IN bits_of_num n /\ i < k}
BITS_OF_NUM_MUL =
|- (!n k. bits_of_num(2 EXP k * n) = IMAGE (\i. k + i) (bits_of_num n)) /\
(!n k. bits_of_num(n * 2 EXP k) = IMAGE (\i. k + i) (bits_of_num n))
BITS_OF_NUM_MUL_ALT =
|- (!n k.
bits_of_num(2 EXP k * n) =
{i | k <= i /\ i - k IN bits_of_num n}) /\
(!n k.
bits_of_num(n * 2 EXP k) =
{i | k <= i /\ i - k IN bits_of_num n})
BITS_OF_NUM_NSUM =
|- !s. FINITE s ==> bits_of_num(nsum s (\i. 2 EXP i)) = s
BITS_OF_NUM_POW2 =
|- !k. bits_of_num(2 EXP k) = {k}
BITS_OF_NUM_SUBSET_NUMSEG_EQ =
|- !n k. bits_of_num n SUBSET {i | i < k} <=> n < 2 EXP k
BITS_OF_NUM_SUBSET_NUMSEG_LT =
|- !n. bits_of_num n SUBSET {i | i < n}
BITS_OF_NUM_VAL =
|- !x. bits_of_num(val x) = bits_of_word x
BITS_OF_WORD_WORD =
|- !n. bits_of_word (word n) = {i | i < dimindex (:N)} INTER bits_of_num n
DISJOINT_BITS_CLAUSES =
|- (!k h l.
l < 2 EXP k
==> DISJOINT (bits_of_num(2 EXP k * h)) (bits_of_num l)) /\
(!k h l.
l < 2 EXP k
==> DISJOINT (bits_of_num(h * 2 EXP k)) (bits_of_num l)) /\
(!k h l.
l < 2 EXP k
==> DISJOINT (bits_of_num l) (bits_of_num(2 EXP k * h))) /\
(!k h l.
l < 2 EXP k
==> DISJOINT (bits_of_num l) (bits_of_num(h * 2 EXP k))) /\
(!m n k.
DISJOINT (bits_of_num m) (bits_of_num n)
==> DISJOINT (bits_of_num(2 EXP k * m))
(bits_of_num(2 EXP k * n))) /\
(!m n k.
DISJOINT (bits_of_num m) (bits_of_num n)
==> DISJOINT (bits_of_num(m * 2 EXP k))
(bits_of_num(n * 2 EXP k))) /\
(!m n k.
DISJOINT (bits_of_num m) (bits_of_num n)
==> DISJOINT (bits_of_num(m DIV 2 EXP k))
(bits_of_num(n DIV 2 EXP k))) /\
(!m n k.
DISJOINT (bits_of_num m) (bits_of_num n)
==> DISJOINT (bits_of_num(m MOD 2 EXP k))
(bits_of_num(n MOD 2 EXP k)))
DISJOINT_BITS_HILO =
|- !k h l.
l < 2 EXP k ==> DISJOINT (bits_of_num(2 EXP k * h)) (bits_of_num l)
DIV_MOD_DISJOINT_BITS =
|- (!m n.
DISJOINT (bits_of_num m) (bits_of_num n)
==> (m + n) DIV 2 EXP k = m DIV 2 EXP k + n DIV 2 EXP k) /\
(!m n.
DISJOINT (bits_of_num m) (bits_of_num n)
==> (m + n) MOD 2 EXP k = m MOD 2 EXP k + n MOD 2 EXP k)
FINITE_BITS_OF_NUM =
|- !n. FINITE (bits_of_num n)
IN_BITS_OF_NUM =
|- !n i. i IN bits_of_num n <=> ODD (n DIV 2 EXP i)
NSUM_BITS_DIV =
|- !s k.
FINITE s
==> nsum s (\i. 2 EXP i) DIV 2 EXP k =
nsum {i | i IN s /\ k <= i} (\i. 2 EXP (i - k))
NSUM_BITS_EQ =
|- !s t.
FINITE s /\ FINITE t
==> (nsum s (\i. 2 EXP i) = nsum t (\i. 2 EXP i) <=> s = t)
NSUM_BITS_MOD =
|- !s k.
FINITE s
==> nsum s (\i. 2 EXP i) MOD 2 EXP k =
nsum {i | i IN s /\ i < k} (\i. 2 EXP i)
NSUM_BITS_OF_NUM =
|- !n. nsum (bits_of_num n) (\i. 2 EXP i) = n
Tue 9th Nov 2021 int.ml, real.ml, Library/words.ml
Added a few miscelleneous lemmas:
IVAL_WORD_CONG =
|- !n. (ival (word n) == &n) (mod (&2 pow dimindex(:N)))
MULT_DIV =
|- (!m n p. p divides m ==> (m * n) DIV p = m DIV p * n) /\