File: theorems.tex

package info (click to toggle)
hol88 2.02.19940316-35
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 65,988 kB
  • ctags: 21,623
  • sloc: ml: 199,939; ansic: 9,666; sh: 7,118; makefile: 6,095; lisp: 2,747; yacc: 894; sed: 201; cpp: 87; awk: 5
file content (2443 lines) | stat: -rw-r--r-- 68,322 bytes parent folder | download | duplicates (5)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
\chapter{Pre-proved Theorems}\input{theorems-intro}\section{Definitions of Basic Logical Constants}\THEOREM AND\_DEF bool
|- $/\ = (\t1 t2. !t. (t1 ==> t2 ==> t) ==> t)
\ENDTHEOREM
\THEOREM EXISTS\_DEF bool
|- $? = (\P. P($@ P))
\ENDTHEOREM
\THEOREM EXISTS\_UNIQUE\_DEF bool
|- $?! = (\P. $? P /\ (!x y. P x /\ P y ==> (x = y)))
\ENDTHEOREM
\THEOREM F\_DEF bool
|- F = (!t. t)
\ENDTHEOREM
\THEOREM FORALL\_DEF bool
|- $! = (\P. P = (\x. T))
\ENDTHEOREM
\THEOREM NOT\_DEF bool
|- $~ = (\t. t ==> F)
\ENDTHEOREM
\THEOREM OR\_DEF bool
|- $\/ = (\t1 t2. !t. (t1 ==> t) ==> (t2 ==> t) ==> t)
\ENDTHEOREM
\THEOREM T\_DEF bool
|- T = ((\x. x) = (\x. x))
\ENDTHEOREM
\section{Constants for syntactic abbreviations}\THEOREM ARB bool
|- ARB = (@x. T)
\ENDTHEOREM
\THEOREM COND\_DEF bool
|- COND =
   (\t t1 t2. @x. ((t = T) ==> (x = t1)) /\ ((t = F) ==> (x = t2)))
\ENDTHEOREM

\THEOREM LET\_DEF bool
|- LET = (\f x. f x)
\ENDTHEOREM
\THEOREM RES\_ABSTRACT bool
|- !P B. RES_ABSTRACT P B = (\x. (P x => B x | ARB))
\ENDTHEOREM
\THEOREM RES\_EXISTS bool
|- !P B. RES_EXISTS P B = (?x. P x /\ B x)
\ENDTHEOREM
\THEOREM RES\_FORALL bool
|- !P B. RES_FORALL P B = (!x. P x ==> B x)
\ENDTHEOREM
\THEOREM RES\_SELECT bool
|- !P B. RES_SELECT P B = (@x. P x /\ B x)
\ENDTHEOREM
\section{Axioms}\THEOREM ARB\_THM bool
|- $= = $=
\ENDTHEOREM
\THEOREM BOOL\_CASES\_AX bool
|- !t. (t = T) \/ (t = F)
\ENDTHEOREM
\THEOREM ETA\_AX bool
|- !t. (\x. t x) = t
\ENDTHEOREM
\THEOREM IMP\_ANTISYM\_AX bool
|- !t1 t2. (t1 ==> t2) ==> (t2 ==> t1) ==> (t1 = t2)
\ENDTHEOREM
\THEOREM INFINITY\_AX ind
|- ?f. ONE_ONE f /\ ~ONTO f
\ENDTHEOREM
\THEOREM SELECT\_AX bool
|- !P x. P x ==> P($@ P)
\ENDTHEOREM
\section{Logical tautologies}\THEOREM AND1\_THM {\none}
|- !t1 t2. t1 /\ t2 ==> t1 
\ENDTHEOREM
\THEOREM AND2\_THM {\none}
|- !t1 t2. t1 /\ t2 ==> t2 
\ENDTHEOREM
\THEOREM AND\_CLAUSES {\none}
|- !t. (T /\ t) = t /\
       (t /\ T) = t /\
       (F /\ t) = F /\
       (t /\ F) = F /\
       (t /\ t) = t
\ENDTHEOREM
\THEOREM AND\_IMP\_INTRO {\none}
|- !t1 t2 t3. t1 ==> t2 ==> t3 = t1 /\ t2 ==> t3
\ENDTHEOREM

\THEOREM AND\_INTRO\_THM {\none}
|- !t1 t2. t1 ==> t2 ==> t1 /\ t2
\ENDTHEOREM
\THEOREM BOOL\_EQ\_DISTINCT {\none}
|- ~(T = F) /\ ~(F = T)
\ENDTHEOREM

\THEOREM COND\_ABS {\none}
|- !b f g. (\x. (b => f x | g x)) = (b => f | g)
\ENDTHEOREM

\THEOREM COND\_CLAUSES {\none}
|- !t1 t2. ((T => t1 | t2) = t1) /\ ((F => t1 | t2) = t2)
\ENDTHEOREM

\THEOREM COND\_EXPAND {\none}
|- !b t1 t2. (b => t1 | t2) = (~b \/ t1) /\ (b \/ t2)
\ENDTHEOREM

\THEOREM COND\_ID {\none}
|- !b t. (b => t | t) = t
\ENDTHEOREM

\THEOREM COND\_RAND {\none}
|- !f b x y. f(b => x | y) = (b => f x | f y)
\ENDTHEOREM

\THEOREM COND\_RATOR {\none}
|- !b f g x. (b => f | g)x = (b => f x | g x)
\ENDTHEOREM

\THEOREM CONJ\_ASSOC {\none}
|- !t1 t2 t3. t1 /\ (t2 /\ t3) = (t1 /\ t2) /\ t3
\ENDTHEOREM
\THEOREM CONJ\_SYM {\none}
|- !t1 t2. (t1 /\ t2) = (t2 /\ t1)
\ENDTHEOREM
\THEOREM DE\_MORGAN\_THM {\none}
|- !t1 t2. (~(t1 /\ t2) = ~t1 \/ ~t2) /\ (~(t1 \/ t2) = ~t1 /\ ~t2)
\ENDTHEOREM

\THEOREM DISJ\_ASSOC {\none}
|- !t1 t2 t3. t1 \/ t2 \/ t3 = (t1 \/ t2) \/ t3
\ENDTHEOREM

\THEOREM DISJ\_SYM {\none}
|- !t1 t2. t1 \/ t2 = t2 \/ t1
\ENDTHEOREM

\THEOREM EQ\_CLAUSES {\none}
|- !t.
    ((T = t) = t) /\ ((t = T) = t) /\ ((F = t) = ~t) /\ ((t = F) = ~t)
\ENDTHEOREM

\THEOREM EQ\_EXPAND {\none}
|- !t1 t2. (t1 = t2) = t1 /\ t2 \/ ~t1 /\ ~t2
\ENDTHEOREM

\THEOREM EQ\_IMP\_THM {\none}
|- !t1 t2. (t1 = t2) = (t1 ==> t2) /\ (t2 ==> t1)
\ENDTHEOREM

\THEOREM EQ\_REFL {\none}
|- !x:*. x = x
\ENDTHEOREM
\THEOREM EQ\_SYM {\none}
|- !x:* y:*. (x = y) ==> (y = x)
\ENDTHEOREM
\THEOREM EQ\_SYM\_EQ {\none}
|- !x y. (x = y) = (y = x)
\ENDTHEOREM

\THEOREM EQ\_TRANS {\none}
|- !x:* y:* z:*. (x = y) /\ (y = z) ==> (x = z)
\ENDTHEOREM
\THEOREM EXCLUDED\_MIDDLE {\none}
|- !t. t \/ ~t
\ENDTHEOREM
\THEOREM EXISTS\_SIMP {\none}
|- !t. (?x. t) = t
\ENDTHEOREM

\THEOREM FALSITY {\none}
|- !t. F ==> t
\ENDTHEOREM
\THEOREM F\_IMP {\none}
|- !t. ~t ==>(t ==> F)
\ENDTHEOREM
\THEOREM FORALL\_SIMP {\none}
|- !t. (!x. t) = t
\ENDTHEOREM

\THEOREM IMP\_CLAUSES {\none}
|- !t. (T ==> t) = t /\
       (t ==> T) = T /\
       (F ==> t) = T /\
       (t ==> t) = t /\
       (t ==> F) = ~t
\ENDTHEOREM
\THEOREM IMP\_DISJ\_THM {\none}
|- !t1 t2. t1 ==> t2 = ~t1 \/ t2
\ENDTHEOREM

\THEOREM IMP\_F {\none}
|- !t.(t ==> F) ==> ~t
\ENDTHEOREM
\THEOREM IMP\_F\_EQ\_F {\none}
|- !t. t ==> F = (t = F)
\ENDTHEOREM

\THEOREM IS\_ASSUMPTION\_OF bool
|- !t1 t2. t1 IS_ASSUMPTION_OF t2 = t1 ==> t2
\ENDTHEOREM
\THEOREM LEFT\_AND\_OVER\_OR {\none}
|- !t1 t2 t3. t1 /\ (t2 \/ t3) = t1 /\ t2 \/ t1 /\ t3
\ENDTHEOREM
\THEOREM LEFT\_OR\_OVER\_AND {\none}
|- !t1 t2 t3. t1 \/ t2 /\ t3 = (t1 \/ t2) /\ (t1 \/ t3)
\ENDTHEOREM
\THEOREM NOT\_AND {\none}
|- !t. ~(t /\ ~t) 
\ENDTHEOREM
\THEOREM NOT\_CLAUSES {\none}
|- (!t. ~~t = t) /\ (~T = F) /\ (~F = T) 
\ENDTHEOREM

\THEOREM NOT\_F {\none}
|- !t. ~t ==> (t=F) 
\ENDTHEOREM
\THEOREM NOT\_IMP {\none}
|- !t1 t2. ~(t1 ==> t2) = t1 /\ ~t2
\ENDTHEOREM

\THEOREM OR\_CLAUSES {\none}
|- !t. (T \/ t) = T /\
       (t \/ T) = T /\
       (F \/ t) = t /\
       (t \/ F) = t /\
       (t \/ t) = t
\ENDTHEOREM
\THEOREM OR\_ELIM\_THM {\none}
|- !t t1 t2. (t1 \/ t2) ==> (t1 ==> t) ==> (t2 ==> t) ==> t 
\ENDTHEOREM
\THEOREM OR\_IMP\_THM {\none}
|- !t1 t2. (t1 = t2 \/ t1) = t2 ==> t1
\ENDTHEOREM

\THEOREM OR\_INTRO\_THM1 {\none}
|- !t1 t2. t1 ==> t1 \/ t2
\ENDTHEOREM
\THEOREM OR\_INTRO\_THM2 {\none}
|- !t1 t2. t2 ==> t1 \/ t2
\ENDTHEOREM
\THEOREM REFL\_CLAUSE {\none}
|- !x. (x = x) = T
\ENDTHEOREM

\THEOREM RIGHT\_AND\_OVER\_OR {\none}
|- !t1 t2 t3. (t2 \/ t3) /\ t1 = t2 /\ t1 \/ t3 /\ t1
\ENDTHEOREM
\THEOREM RIGHT\_OR\_OVER\_AND {\none}
|- !t1 t2 t3. t2 /\ t3 \/ t1 = (t2 \/ t1) /\ (t3 \/ t1)
\ENDTHEOREM
\THEOREM SELECT\_REFL {\none}
|- !x. (@y. y = x) = x
\ENDTHEOREM
\THEOREM SELECT\_UNIQUE {\none}
|- !P x. (!y. P y = (y = x)) ==> ($@ P = x)
\ENDTHEOREM
\THEOREM TRUTH {\none}
|- T
\ENDTHEOREM
\section{Theorems about functions}\THEOREM ABS\_SIMP {\none}
|- !t1 t2. (\x. t1)t2 = t1
\ENDTHEOREM

\THEOREM ASSOC\_CONJ fun
|- ASSOC $/\
\ENDTHEOREM
\THEOREM ASSOC\_DEF fun
|- !f. ASSOC f = (!x y z. f x(f y z) = f(f x y)z)
\ENDTHEOREM
\THEOREM ASSOC\_DISJ fun
|- ASSOC $\/
\ENDTHEOREM
\THEOREM COMM\_DEF fun
|- !f. COMM f = (!x y. f x y = f y x)
\ENDTHEOREM
\THEOREM EQ\_EXT {\none}
|- !f g. (!x. f x = g x) ==> (f = g)
\ENDTHEOREM
\THEOREM FCOMM\_ASSOC fun
|- !f. FCOMM f f = ASSOC f
\ENDTHEOREM
\THEOREM FCOMM\_DEF fun
|- !f g. FCOMM f g = (!x y z. g x(f y z) = f(g x y)z)
\ENDTHEOREM
\THEOREM FUN\_EQ\_LEMMA arithmetic
|- !f x1 x2. f x1 /\ ~f x2 ==> ~(x1 = x2)
\ENDTHEOREM

\THEOREM LEFT\_ID\_DEF fun
|- !f e. LEFT_ID f e = (!x. f e x = x)
\ENDTHEOREM
\THEOREM MONOID\_CONJ\_T fun
|- MONOID $/\ T
\ENDTHEOREM
\THEOREM MONOID\_DEF fun
|- !f e. MONOID f e = ASSOC f /\ RIGHT_ID f e /\ LEFT_ID f e
\ENDTHEOREM
\THEOREM MONOID\_DISJ\_F fun
|- MONOID $\/ F
\ENDTHEOREM
\THEOREM ONE\_ONE\_DEF bool
|- !f. ONE_ONE f = (!x1 x2. (f x1 = f x2) ==> (x1 = x2))
\ENDTHEOREM
\THEOREM ONTO\_DEF bool
|- !f. ONTO f = (!y. ?x. y = f x)
\ENDTHEOREM
\THEOREM RIGHT\_ID\_DEF fun
|- !f e. RIGHT_ID f e = (!x. f x e = x)
\ENDTHEOREM
\section{Theorems about the type {\tt one}}\THEOREM one\_axiom one
|- !f g. f = g
\ENDTHEOREM
\THEOREM one\_Axiom one
|- !e. ?! fn. fn one = e
\ENDTHEOREM
\THEOREM one\_DEF one
|- one = (@x. T)
\ENDTHEOREM
\THEOREM one one
|- !v. v = one
\ENDTHEOREM
\THEOREM one\_TY\_DEF one
|- ?rep. TYPE_DEFINITION(\b. b)rep
\ENDTHEOREM
\section{Theorems about combinators}\THEOREM I\_DEF combin
|- I = S K K
\ENDTHEOREM
\THEOREM I\_o\_ID combin
|- !f. (I o f = f) /\ (f o I = f)
\ENDTHEOREM
\THEOREM I\_THM combin
|- !x. I x = x
\ENDTHEOREM
\THEOREM K\_DEF combin
|- K = (\x y. x)
\ENDTHEOREM
\THEOREM K\_THM combin
|- !x y. K x y = x
\ENDTHEOREM
\THEOREM o\_ASSOC combin
|- !f g h. f o (g o h) = (f o g) o h
\ENDTHEOREM
\THEOREM o\_DEF combin
|- !f g. f o g = (\x. f(g x))
\ENDTHEOREM
\THEOREM o\_THM combin
|- !f g x. (f o g)x = f(g x)
\ENDTHEOREM
\THEOREM S\_DEF combin
|- S = (\f g x. f x(g x))
\ENDTHEOREM
\THEOREM S\_THM combin
|- !f g x. S f g x = f x(g x)
\ENDTHEOREM
\section{Theorems about pairs}\THEOREM COMMA\_DEF bool
|- !x y. x,y = (@p. REP_prod p = MK_PAIR x y)
\ENDTHEOREM
\THEOREM CURRY\_DEF bool
|- !f x y. CURRY f x y = f(x,y)
\ENDTHEOREM
\THEOREM FST\_DEF bool
|- !p. FST p = (@x. ?y. MK_PAIR x y = REP_prod p)
\ENDTHEOREM
\THEOREM FST bool
|- !x y. FST(x,y) = x
\ENDTHEOREM
\THEOREM IS\_PAIR\_DEF bool
|- !p. IS_PAIR p = (?x y. p = MK_PAIR x y)
\ENDTHEOREM
\THEOREM PAIR bool
|- !x. FST x,SND x = x
\ENDTHEOREM
\THEOREM PAIR\_EQ bool
|- !x y a b. (x,y = a,b) = (x = a) /\ (y = b)
\ENDTHEOREM
\THEOREM PAIR\_EXISTS bool
|- ?p. IS_PAIR p
\ENDTHEOREM
\THEOREM prod\_TY\_DEF bool
|- ?rep. TYPE_DEFINITION IS_PAIR rep
\ENDTHEOREM
\THEOREM REP\_prod bool
|- REP_prod =
   (@rep.
     (!p' p''. (rep p' = rep p'') ==> (p' = p'')) /\
     (!p. IS_PAIR p = (?p'. p = rep p')))
\ENDTHEOREM
\THEOREM SND\_DEF bool
|- !p. SND p = (@y. ?x. MK_PAIR x y = REP_prod p)
\ENDTHEOREM
\THEOREM SND bool
|- !x y. SND(x,y) = y
\ENDTHEOREM
\THEOREM UNCURRY\_DEF bool
|- !f x y. UNCURRY f(x,y) = f x y
\ENDTHEOREM
\section{Theorems about disjoint sums}\THEOREM INL\_DEF sum
|- !e. INL e = ABS_sum(\b x y. (x = e) /\ b)
\ENDTHEOREM
\THEOREM INL sum
|- !x. ISL x ==> (INL(OUTL x) = x)
\ENDTHEOREM
\THEOREM INR\_DEF sum
|- !e. INR e = ABS_sum(\b x y. (y = e) /\ ~b)
\ENDTHEOREM
\THEOREM INR sum
|- !x. ISR x ==> (INR(OUTR x) = x)
\ENDTHEOREM
\THEOREM ISL sum
|- (!x. ISL(INL x)) /\ (!y. ~ISL(INR y))
\ENDTHEOREM
\THEOREM ISL\_OR\_ISR sum
|- !x. ISL x \/ ISR x
\ENDTHEOREM
\THEOREM ISR sum
|- (!x. ISR(INR x)) /\ (!y. ~ISR(INL y))
\ENDTHEOREM
\THEOREM IS\_SUM\_REP sum
|- !f.
    IS_SUM_REP f =
    (?v1 v2.
      (f = (\b x y. (x = v1) /\ b)) \/ (f = (\b x y. (y = v2) /\ ~b)))
\ENDTHEOREM
\THEOREM OUTL sum
|- !x. OUTL(INL x) = x
\ENDTHEOREM
\THEOREM OUTR sum
|- !x. OUTR(INR x) = x
\ENDTHEOREM
\THEOREM sum\_axiom sum
|- !f g. ?! h. (h o INL = f) /\ (h o INR = g)
\ENDTHEOREM
\THEOREM sum\_Axiom sum
|- !f g. ?! h. (!x. h(INL x) = f x) /\ (!x. h(INR x) = g x)
\ENDTHEOREM
\THEOREM sum\_ISO\_DEF sum
|- (!a. ABS_sum(REP_sum a) = a) /\
   (!r. IS_SUM_REP r = (REP_sum(ABS_sum r) = r))
\ENDTHEOREM
\THEOREM sum\_TY\_DEF sum
|- ?rep. TYPE_DEFINITION IS_SUM_REP rep
\ENDTHEOREM
\section{Theorems about arithmetic}\THEOREM ADD\_0 arithmetic
|- !m. m + 0 = m
\ENDTHEOREM
\THEOREM ADD1 arithmetic
|- !m. SUC m = m + 1
\ENDTHEOREM
\THEOREM ADD\_ASSOC arithmetic
|- !m n p. m + (n + p) = (m + n) + p
\ENDTHEOREM
\THEOREM ADD\_CLAUSES arithmetic
|- (0 + m = m) /\
   (m + 0 = m) /\
   ((SUC m) + n = SUC(m + n)) /\
   (m + (SUC n) = SUC(m + n))
\ENDTHEOREM
\THEOREM ADD arithmetic
|- (!n. 0 + n = n) /\ (!m n. (SUC m) + n = SUC(m + n))
\ENDTHEOREM
\THEOREM ADD\_EQ\_0 arithmetic
|- !m n. (m + n = 0) = (m = 0) /\ (n = 0)
\ENDTHEOREM
\THEOREM ADD\_EQ\_SUB arithmetic
|- !m n p. n <= p ==> ((m + n = p) = (m = p - n))
\ENDTHEOREM
\THEOREM ADD\_INV\_0 arithmetic
|- !m n. (m + n = m) ==> (n = 0)
\ENDTHEOREM
\THEOREM ADD\_INV\_0\_EQ arithmetic
|- !m n. (m + n = m) = (n = 0)
\ENDTHEOREM
\THEOREM ADD\_MONO\_LESS\_EQ arithmetic
|- !m n p. (m + n) <= (m + p) = n <= p
\ENDTHEOREM
\THEOREM ADD\_SUB arithmetic
|- !a c. (a + c) - c = a
\ENDTHEOREM
\THEOREM ADD\_SUC arithmetic
|- !m n. SUC(m + n) = m + (SUC n)
\ENDTHEOREM
\THEOREM ADD\_SYM arithmetic
|- !m n. m + n = n + m
\ENDTHEOREM
\THEOREM ASSOC\_ADD arithmetic
|- ASSOC $+
\ENDTHEOREM
\THEOREM ASSOC\_MULT arithmetic
|- ASSOC $*
\ENDTHEOREM
\THEOREM CANCEL\_SUB arithmetic
|- !p n m. p <= n /\ p <= m ==> ((n - p = m - p) = (n = m))
\ENDTHEOREM
\THEOREM DA arithmetic
|- !k n. 0 < n ==> (?r q. (k = (q * n) + r) /\ r < n)
\ENDTHEOREM
\THEOREM DIVISION arithmetic
|- !n.
    0 < n ==> (!k. (k = ((k DIV n) * n) + (k MOD n)) /\ (k MOD n) < n)
\ENDTHEOREM
\THEOREM DIV\_LESS\_EQ arithmetic
|- !n. 0 < n ==> (!k. (k DIV n) <= k)
\ENDTHEOREM
\THEOREM DIV\_MULT arithmetic
|- !n r. r < n ==> (!q. ((q * n) + r) DIV n = q)
\ENDTHEOREM
\THEOREM DIV\_UNIQUE arithmetic
|- !n k q. (?r. (k = (q * n) + r) /\ r < n) ==> (k DIV n = q)
\ENDTHEOREM
\THEOREM EQ\_LESS prim\_rec
|- !n. (SUC m = n) ==> m < n
\ENDTHEOREM
\THEOREM EQ\_LESS\_EQ arithmetic
|- !m n. (m = n) = m <= n /\ n <= m
\ENDTHEOREM
\THEOREM EQ\_MONO\_ADD\_EQ arithmetic
|- !m n p. (m + p = n + p) = (m = n)
\ENDTHEOREM
\THEOREM EVEN\_ADD arithmetic
|- !m n. EVEN(m + n) = (EVEN m = EVEN n)
\ENDTHEOREM
\THEOREM EVEN\_AND\_ODD arithmetic
|- !n. ~(EVEN n /\ ODD n)
\ENDTHEOREM
\THEOREM EVEN arithmetic
|- (EVEN 0 = T) /\ (!n. EVEN(SUC n) = ~EVEN n)
\ENDTHEOREM
\THEOREM EVEN\_DOUBLE arithmetic
|- !n. EVEN(2 * n)
\ENDTHEOREM
\THEOREM EVEN\_EXISTS arithmetic
|- !n. EVEN n = (?m. n = 2 * m)
\ENDTHEOREM
\THEOREM EVEN\_MULT arithmetic
|- !m n. EVEN(m * n) = EVEN m \/ EVEN n
\ENDTHEOREM
\THEOREM EVEN\_ODD arithmetic
|- !n. EVEN n = ~ODD n
\ENDTHEOREM
\THEOREM EVEN\_ODD\_EXISTS arithmetic
|- !n. (EVEN n ==> (?m. n = 2 * m)) /\ (ODD n ==> (?m. n = SUC(2 * m)))
\ENDTHEOREM
\THEOREM EVEN\_OR\_ODD arithmetic
|- !n. EVEN n \/ ODD n
\ENDTHEOREM
\THEOREM EXP\_ADD arithmetic
|- !p q n. n EXP (p + q) = (n EXP p) * (n EXP q)
\ENDTHEOREM
\THEOREM EXP arithmetic
|- (!m. m EXP 0 = 1) /\ (!m n. m EXP (SUC n) = m * (m EXP n))
\ENDTHEOREM
\THEOREM FACT arithmetic
|- (FACT 0 = 1) /\ (!n. FACT(SUC n) = (SUC n) * (FACT n))
\ENDTHEOREM
\THEOREM FACT\_LESS arithmetic
|- !n. 0 < (FACT n)
\ENDTHEOREM
\THEOREM FUN\_EQ\_LEMMA arithmetic
|- !f x1 x2. f x1 /\ ~f x2 ==> ~(x1 = x2)
\ENDTHEOREM
\THEOREM GREATER arithmetic
|- !m n. m > n = n < m
\ENDTHEOREM
\THEOREM GREATER\_EQ arithmetic
|- !n m. n >= m = m <= n
\ENDTHEOREM
\THEOREM GREATER\_OR\_EQ arithmetic
|- !m n. m >= n = m > n \/ (m = n)
\ENDTHEOREM
\THEOREM INDUCTION num
|- !P. P 0 /\ (!n. P n ==> P(SUC n)) ==> (!n. P n)
\ENDTHEOREM
\THEOREM INV\_PRE\_EQ arithmetic
|- !m n. 0 < m /\ 0 < n ==> ((PRE m = PRE n) = (m = n))
\ENDTHEOREM
\THEOREM INV\_PRE\_LESS arithmetic
|- !m. 0 < m ==> (!n. (PRE m) < (PRE n) = m < n)
\ENDTHEOREM
\THEOREM INV\_PRE\_LESS\_EQ arithmetic
|- !n. 0 < n ==> (!m. (PRE m) <= (PRE n) = m <= n)
\ENDTHEOREM
\THEOREM INV\_SUC num
|- !m n. (SUC m = SUC n) ==> (m = n)
\ENDTHEOREM
\THEOREM INV\_SUC\_EQ prim\_rec
|- !m n. (SUC m = SUC n) = (m = n)
\ENDTHEOREM
\THEOREM IS\_NUM\_REP num
|- !m.
    IS_NUM_REP m =
    (!P. P ZERO_REP /\ (!n. P n ==> P(SUC_REP n)) ==> P m)
\ENDTHEOREM
\THEOREM LEFT\_ADD\_DISTRIB arithmetic
|- !m n p. p * (m + n) = (p * m) + (p * n)
\ENDTHEOREM
\THEOREM LEFT\_ID\_ADD\_0 arithmetic
|- LEFT_ID $+ 0
\ENDTHEOREM
\THEOREM LEFT\_ID\_MULT\_1 arithmetic
|- LEFT_ID $* 1
\ENDTHEOREM
\THEOREM LEFT\_SUB\_DISTRIB arithmetic
|- !m n p. p * (m - n) = (p * m) - (p * n)
\ENDTHEOREM
\THEOREM LESS\_0\_0 prim\_rec
|- 0 < (SUC 0)
\ENDTHEOREM
\THEOREM LESS\_0\_CASES arithmetic
|- !m. (0 = m) \/ 0 < m
\ENDTHEOREM
\THEOREM LESS\_0 prim\_rec
|- !n. 0 < (SUC n)
\ENDTHEOREM
\THEOREM LESS\_ADD\_1 arithmetic
|- !m n. n < m ==> (?p. m = n + (p + 1))
\ENDTHEOREM
\THEOREM LESS\_ADD arithmetic
|- !m n. n < m ==> (?p. p + n = m)
\ENDTHEOREM
\THEOREM LESS\_ADD\_NONZERO arithmetic
|- !m n. ~(n = 0) ==> m < (m + n)
\ENDTHEOREM
\THEOREM LESS\_ADD\_SUC arithmetic
|- !m n. m < (m + (SUC n))
\ENDTHEOREM
\THEOREM LESS\_ANTISYM arithmetic
|- !m n. ~(m < n /\ n < m)
\ENDTHEOREM
\THEOREM LESS\_CASES arithmetic
|- !m n. m < n \/ n <= m
\ENDTHEOREM
\THEOREM LESS\_CASES\_IMP arithmetic
|- !m n. ~m < n /\ ~(m = n) ==> n < m
\ENDTHEOREM
\THEOREM LESS prim\_rec
|- !m n. m < n = (?P. (!n'. P(SUC n') ==> P n') /\ P m /\ ~P n)
\ENDTHEOREM
\THEOREM LESS\_EQ\_0 arithmetic
|- !n. n <= 0 = (n = 0)
\ENDTHEOREM
\THEOREM LESS\_EQ\_ADD arithmetic
|- !m n. m <= (m + n)
\ENDTHEOREM
\THEOREM LESS\_EQ\_ADD\_SUB arithmetic
|- !c b. c <= b ==> (!a. (a + b) - c = a + (b - c))
\ENDTHEOREM
\THEOREM LESS\_EQ\_ANTISYM arithmetic
|- !m n. ~(m < n /\ n <= m)
\ENDTHEOREM
\THEOREM LESS\_EQ\_CASES arithmetic
|- !m n. m <= n \/ n <= m
\ENDTHEOREM
\THEOREM LESS\_EQ arithmetic
|- !m n. m < n = (SUC m) <= n
\ENDTHEOREM
\THEOREM LESS\_EQ\_EXISTS arithmetic
|- !m n. m <= n = (?p. n = m + p)
\ENDTHEOREM
\THEOREM LESS\_EQ\_IMP\_LESS\_SUC arithmetic
|- !n m. n <= m ==> n < (SUC m)
\ENDTHEOREM
\THEOREM LESS\_EQ\_LESS\_EQ\_MONO arithmetic
|- !m n p q. m <= p /\ n <= q ==> (m + n) <= (p + q)
\ENDTHEOREM
\THEOREM LESS\_EQ\_LESS\_TRANS arithmetic
|- !m n p. m <= n /\ n < p ==> m < p
\ENDTHEOREM
\THEOREM LESS\_EQ\_MONO\_ADD\_EQ arithmetic
|- !m n p. (m + p) <= (n + p) = m <= n
\ENDTHEOREM
\THEOREM LESS\_EQ\_MONO arithmetic
|- !n m. (SUC n) <= (SUC m) = n <= m
\ENDTHEOREM
\THEOREM LESS\_EQ\_REFL arithmetic
|- !m. m <= m
\ENDTHEOREM
\THEOREM LESS\_EQ\_SUB\_LESS arithmetic
|- !a b. b <= a ==> (!c. (a - b) < c = a < (b + c))
\ENDTHEOREM
\THEOREM LESS\_EQ\_SUC\_REFL arithmetic
|- !m. m <= (SUC m)
\ENDTHEOREM
\THEOREM LESS\_EQ\_TRANS arithmetic
|- !m n p. m <= n /\ n <= p ==> m <= p
\ENDTHEOREM
\THEOREM LESS\_EQUAL\_ADD arithmetic
|- !m n. m <= n ==> (?p. n = m + p)
\ENDTHEOREM
\THEOREM LESS\_EQUAL\_ANTISYM arithmetic
|- !n m. n <= m /\ m <= n ==> (n = m)
\ENDTHEOREM
\THEOREM LESS\_EXP\_SUC\_MONO arithmetic
|- !n m. ((SUC(SUC m)) EXP n) < ((SUC(SUC m)) EXP (SUC n))
\ENDTHEOREM
\THEOREM LESS\_IMP\_LESS\_ADD arithmetic
|- !n m. n < m ==> (!p. n < (m + p))
\ENDTHEOREM
\THEOREM LESS\_IMP\_LESS\_OR\_EQ arithmetic
|- !m n. m < n ==> m <= n
\ENDTHEOREM
\THEOREM LESS\_LEMMA1 prim\_rec
|- !m n. m < (SUC n) ==> (m = n) \/ m < n
\ENDTHEOREM
\THEOREM LESS\_LEMMA2 prim\_rec
|- !m n. (m = n) \/ m < n ==> m < (SUC n)
\ENDTHEOREM
\THEOREM LESS\_LESS\_CASES arithmetic
|- !m n. (m = n) \/ m < n \/ n < m
\ENDTHEOREM
\THEOREM LESS\_LESS\_EQ\_TRANS arithmetic
|- !m n p. m < n /\ n <= p ==> m < p
\ENDTHEOREM
\THEOREM LESS\_LESS\_SUC arithmetic
|- !m n. ~(m < n /\ n < (SUC m))
\ENDTHEOREM
\THEOREM LESS\_MOD arithmetic
|- !n k. k < n ==> (k MOD n = k)
\ENDTHEOREM
\THEOREM LESS\_MONO\_ADD arithmetic
|- !m n p. m < n ==> (m + p) < (n + p)
\ENDTHEOREM
\THEOREM LESS\_MONO\_ADD\_EQ arithmetic
|- !m n p. (m + p) < (n + p) = m < n
\ENDTHEOREM
\THEOREM LESS\_MONO\_ADD\_INV arithmetic
|- !m n p. (m + p) < (n + p) ==> m < n
\ENDTHEOREM
\THEOREM LESS\_MONO prim\_rec
|- !m n. m < n ==> (SUC m) < (SUC n)
\ENDTHEOREM
\THEOREM LESS\_MONO\_EQ arithmetic
|- !m n. (SUC m) < (SUC n) = m < n
\ENDTHEOREM
\THEOREM LESS\_MONO\_MULT arithmetic
|- !m n p. m <= n ==> (m * p) <= (n * p)
\ENDTHEOREM
\THEOREM LESS\_MONO\_REV arithmetic
|- !m n. (SUC m) < (SUC n) ==> m < n
\ENDTHEOREM
\THEOREM LESS\_MULT2 arithmetic
|- !m n. 0 < m /\ 0 < n ==> 0 < (m * n)
\ENDTHEOREM
\THEOREM LESS\_MULT\_MONO arithmetic
|- !m i n. ((SUC n) * m) < ((SUC n) * i) = m < i
\ENDTHEOREM
\THEOREM LESS\_NOT\_EQ prim\_rec
|- !m n. m < n ==> ~(m = n)
\ENDTHEOREM
\THEOREM LESS\_NOT\_SUC arithmetic
|- !m n. m < n /\ ~(n = SUC m) ==> (SUC m) < n
\ENDTHEOREM
\THEOREM LESS\_OR arithmetic
|- !m n. m < n ==> (SUC m) <= n
\ENDTHEOREM
\THEOREM LESS\_OR\_EQ\_ADD arithmetic
|- !n m. n < m \/ (?p. n = p + m)
\ENDTHEOREM
\THEOREM LESS\_OR\_EQ arithmetic
|- !m n. m <= n = m < n \/ (m = n)
\ENDTHEOREM
\THEOREM LESS\_REFL prim\_rec
|- !n. ~n < n
\ENDTHEOREM
\THEOREM LESS\_SUB\_ADD\_LESS arithmetic
|- !n m i. i < (n - m) ==> (i + m) < n
\ENDTHEOREM
\THEOREM LESS\_SUC prim\_rec
|- !m n. m < n ==> m < (SUC n)
\ENDTHEOREM
\THEOREM LESS\_SUC\_EQ\_COR arithmetic
|- !m n. m < n /\ ~(SUC m = n) ==> (SUC m) < n
\ENDTHEOREM
\THEOREM LESS\_SUC\_IMP prim\_rec
|- !m n. m < (SUC n) ==> ~(m = n) ==> m < n
\ENDTHEOREM
\THEOREM LESS\_SUC\_NOT arithmetic
|- !m n. m < n ==> ~n < (SUC m)
\ENDTHEOREM
\THEOREM LESS\_SUC\_REFL prim\_rec
|- !n. n < (SUC n)
\ENDTHEOREM
\THEOREM LESS\_SUC\_SUC prim\_rec
|- !m. m < (SUC m) /\ m < (SUC(SUC m))
\ENDTHEOREM
\THEOREM LESS\_THM prim\_rec
|- !m n. m < (SUC n) = (m = n) \/ m < n
\ENDTHEOREM
\THEOREM LESS\_TRANS arithmetic
|- !m n p. m < n /\ n < p ==> m < p
\ENDTHEOREM
\THEOREM MOD\_EQ\_0 arithmetic
|- !n. 0 < n ==> (!k. (k * n) MOD n = 0)
\ENDTHEOREM
\THEOREM MOD\_MOD arithmetic
|- !n. 0 < n ==> (!k. (k MOD n) MOD n = k MOD n)
\ENDTHEOREM
\THEOREM MOD\_MULT arithmetic
|- !n r. r < n ==> (!q. ((q * n) + r) MOD n = r)
\ENDTHEOREM
\THEOREM MOD\_ONE arithmetic
|- !k. k MOD (SUC 0) = 0
\ENDTHEOREM
\THEOREM MOD\_PLUS arithmetic
|- !n. 0 < n ==> (!j k. ((j MOD n) + (k MOD n)) MOD n = (j + k) MOD n)
\ENDTHEOREM
\THEOREM MOD\_TIMES arithmetic
|- !n. 0 < n ==> (!q r. ((q * n) + r) MOD n = r MOD n)
\ENDTHEOREM
\THEOREM MOD\_UNIQUE arithmetic
|- !n k r. (?q. (k = (q * n) + r) /\ r < n) ==> (k MOD n = r)
\ENDTHEOREM
\THEOREM MONOID\_ADD\_0 arithmetic
|- MONOID $+ 0
\ENDTHEOREM
\THEOREM MONOID\_MULT\_1 arithmetic
|- MONOID $* 1
\ENDTHEOREM
\THEOREM MULT\_0 arithmetic
|- !m. m * 0 = 0
\ENDTHEOREM
\THEOREM MULT\_ASSOC arithmetic
|- !m n p. m * (n * p) = (m * n) * p
\ENDTHEOREM
\THEOREM MULT\_CLAUSES arithmetic
|- !m n.
    (0 * m = 0) /\
    (m * 0 = 0) /\
    (1 * m = m) /\
    (m * 1 = m) /\
    ((SUC m) * n = (m * n) + n) /\
    (m * (SUC n) = m + (m * n))
\ENDTHEOREM
\THEOREM MULT arithmetic
|- (!n. 0 * n = 0) /\ (!m n. (SUC m) * n = (m * n) + n)
\ENDTHEOREM
\THEOREM MULT\_EQ\_0 arithmetic
|- !m n. (m * n = 0) = (m = 0) \/ (n = 0)
\ENDTHEOREM
\THEOREM MULT\_EXP\_MONO arithmetic
|- !p q n m. (n * ((SUC q) EXP p) = m * ((SUC q) EXP p)) = (n = m)
\ENDTHEOREM
\THEOREM MULT\_LEFT\_1 arithmetic
|- !m. 1 * m = m
\ENDTHEOREM
\THEOREM MULT\_LESS\_EQ\_SUC arithmetic
|- !m n p. m <= n = ((SUC p) * m) <= ((SUC p) * n)
\ENDTHEOREM
\THEOREM MULT\_MONO\_EQ arithmetic
|- !m i n. ((SUC n) * m = (SUC n) * i) = (m = i)
\ENDTHEOREM
\THEOREM MULT\_RIGHT\_1 arithmetic
|- !m. m * 1 = m
\ENDTHEOREM
\THEOREM MULT\_SUC arithmetic
|- !m n. m * (SUC n) = m + (m * n)
\ENDTHEOREM
\THEOREM MULT\_SUC\_EQ arithmetic
|- !p m n. (n * (SUC p) = m * (SUC p)) = (n = m)
\ENDTHEOREM
\THEOREM MULT\_SYM arithmetic
|- !m n. m * n = n * m
\ENDTHEOREM
\THEOREM NOT\_EXP\_0 arithmetic
|- !m n. ~((SUC n) EXP m = 0)
\ENDTHEOREM
\THEOREM NOT\_GREATER arithmetic
|- !m n. ~m > n = m <= n
\ENDTHEOREM
\THEOREM NOT\_GREATER\_EQ arithmetic
|- !m n. ~m >= n = (SUC m) <= n
\ENDTHEOREM
\THEOREM NOT\_LEQ arithmetic
|- !m n. ~m <= n = (SUC n) <= m
\ENDTHEOREM
\THEOREM NOT\_LESS\_0 prim\_rec
|- !n. ~n < 0
\ENDTHEOREM
\THEOREM NOT\_LESS arithmetic
|- !m n. ~m < n = n <= m
\ENDTHEOREM
\THEOREM NOT\_LESS\_EQ prim\_rec
|- !m n. (m = n) ==> ~m < n
\ENDTHEOREM
\THEOREM NOT\_LESS\_EQUAL arithmetic
|- !m n. ~m <= n = n < m
\ENDTHEOREM
\THEOREM NOT\_NUM\_EQ arithmetic
|- !m n. ~(m = n) = (SUC m) <= n \/ (SUC n) <= m
\ENDTHEOREM
\THEOREM NOT\_ODD\_EQ\_EVEN arithmetic
|- !n m. ~(SUC(n + n) = m + m)
\ENDTHEOREM
\THEOREM NOT\_SUC\_ADD\_LESS\_EQ arithmetic
|- !m n. ~(SUC(m + n)) <= m
\ENDTHEOREM
\THEOREM NOT\_SUC num
|- !n. ~(SUC n = 0)
\ENDTHEOREM
\THEOREM NOT\_SUC\_LESS\_EQ\_0 arithmetic
|- !n. ~(SUC n) <= 0
\ENDTHEOREM
\THEOREM NOT\_SUC\_LESS\_EQ arithmetic
|- !n m. ~(SUC n) <= m = m <= n
\ENDTHEOREM
\THEOREM num\_Axiom prim\_rec
|- !e f. ?! fn. (fn 0 = e) /\ (!n. fn(SUC n) = f(fn n)n)
\ENDTHEOREM
\THEOREM num\_CASES arithmetic
|- !m. (m = 0) \/ (?n. m = SUC n)
\ENDTHEOREM
\THEOREM num\_ISO\_DEF num
|- (!a. ABS_num(REP_num a) = a) /\
   (!r. IS_NUM_REP r = (REP_num(ABS_num r) = r))
\ENDTHEOREM
\THEOREM num\_TY\_DEF num
|- ?rep. TYPE_DEFINITION IS_NUM_REP rep
\ENDTHEOREM
\THEOREM ODD\_ADD arithmetic
|- !m n. ODD(m + n) = ~(ODD m = ODD n)
\ENDTHEOREM
\THEOREM ODD arithmetic
|- (ODD 0 = F) /\ (!n. ODD(SUC n) = ~ODD n)
\ENDTHEOREM
\THEOREM ODD\_DOUBLE arithmetic
|- !n. ODD(SUC(2 * n))
\ENDTHEOREM
\THEOREM ODD\_EVEN arithmetic
|- !n. ODD n = ~EVEN n
\ENDTHEOREM
\THEOREM ODD\_EXISTS arithmetic
|- !n. ODD n = (?m. n = SUC(2 * m))
\ENDTHEOREM
\THEOREM ODD\_MULT arithmetic
|- !m n. ODD(m * n) = ODD m /\ ODD n
\ENDTHEOREM
\THEOREM ODD\_OR\_EVEN arithmetic
|- !n. ?m. (n = (SUC(SUC 0)) * m) \/ (n = ((SUC(SUC 0)) * m) + 1)
\ENDTHEOREM
\THEOREM OR\_LESS arithmetic
|- !m n. (SUC m) <= n ==> m < n
\ENDTHEOREM
\THEOREM PRE\_DEF prim\_rec
|- !m. PRE m = ((m = 0) => 0 | (@n. m = SUC n))
\ENDTHEOREM
\THEOREM PRE prim\_rec
|- (PRE 0 = 0) /\ (!m. PRE(SUC m) = m)
\ENDTHEOREM
\THEOREM PRE\_SUB1 arithmetic
|- !m. PRE m = m - 1
\ENDTHEOREM
\THEOREM PRE\_SUB arithmetic
|- !m n. PRE(m - n) = (PRE m) - n
\ENDTHEOREM
\THEOREM PRE\_SUC\_EQ arithmetic
|- !m n. 0 < n ==> ((m = PRE n) = (SUC m = n))
\ENDTHEOREM
\THEOREM PRIM\_REC prim\_rec
|- !x f m. PRIM_REC x f m = PRIM_REC_FUN x f m(PRE m)
\ENDTHEOREM
\THEOREM PRIM\_REC\_EQN prim\_rec
|- !x f.
    (!n. PRIM_REC_FUN x f 0 n = x) /\
    (!m n. PRIM_REC_FUN x f(SUC m)n = f(PRIM_REC_FUN x f m(PRE n))n)
\ENDTHEOREM
\THEOREM PRIM\_REC\_FUN prim\_rec
|- !x f. PRIM_REC_FUN x f = SIMP_REC(\n. x)(\fun n. f(fun(PRE n))n)
\ENDTHEOREM
\THEOREM PRIM\_REC\_THM prim\_rec
|- !x f.
    (PRIM_REC x f 0 = x) /\
    (!m. PRIM_REC x f(SUC m) = f(PRIM_REC x f m)m)
\ENDTHEOREM
\THEOREM RIGHT\_ADD\_DISTRIB arithmetic
|- !m n p. (m + n) * p = (m * p) + (n * p)
\ENDTHEOREM
\THEOREM RIGHT\_ID\_ADD\_0 arithmetic
|- RIGHT_ID $+ 0
\ENDTHEOREM
\THEOREM RIGHT\_ID\_MULT\_1 arithmetic
|- RIGHT_ID $* 1
\ENDTHEOREM
\THEOREM RIGHT\_SUB\_DISTRIB arithmetic
|- !m n p. (m - n) * p = (m * p) - (n * p)
\ENDTHEOREM
\THEOREM SIMP\_REC prim\_rec
|- !x f n. SIMP_REC x f n = SIMP_REC_FUN x f(SUC n)n
\ENDTHEOREM
\THEOREM SIMP\_REC\_EXISTS prim\_rec
|- !x f n. ?fun. SIMP_REC_REL fun x f n
\ENDTHEOREM
\THEOREM SIMP\_REC\_FUN prim\_rec
|- !x f n. SIMP_REC_FUN x f n = (@fun. SIMP_REC_REL fun x f n)
\ENDTHEOREM
\THEOREM SIMP\_REC\_FUN\_LEMMA prim\_rec
|- (?fun. SIMP_REC_REL fun x f n) =
   (SIMP_REC_FUN x f n 0 = x) /\
   (!m. m < n ==> (SIMP_REC_FUN x f n(SUC m) = f(SIMP_REC_FUN x f n m)))
\ENDTHEOREM
\THEOREM SIMP\_REC\_REL prim\_rec
|- !fun x f n.
    SIMP_REC_REL fun x f n =
    (fun 0 = x) /\ (!m. m < n ==> (fun(SUC m) = f(fun m)))
\ENDTHEOREM
\THEOREM SIMP\_REC\_THM prim\_rec
|- !x f.
    (SIMP_REC x f 0 = x) /\
    (!m. SIMP_REC x f(SUC m) = f(SIMP_REC x f m))
\ENDTHEOREM
\THEOREM SUB\_0 arithmetic
|- !m. (0 - m = 0) /\ (m - 0 = m)
\ENDTHEOREM
\THEOREM SUB\_ADD arithmetic
|- !m n. n <= m ==> ((m - n) + n = m)
\ENDTHEOREM
\THEOREM SUB\_CANCEL arithmetic
|- !p n m. n <= p /\ m <= p ==> ((p - n = p - m) = (n = m))
\ENDTHEOREM
\THEOREM SUB arithmetic
|- (!m. 0 - m = 0) /\ (!m n. (SUC m) - n = (m < n => 0 | SUC(m - n)))
\ENDTHEOREM
\THEOREM SUB\_EQ\_0 arithmetic
|- !m n. (m - n = 0) = m <= n
\ENDTHEOREM
\THEOREM SUB\_EQ\_EQ\_0 arithmetic
|- !m n. (m - n = m) = (m = 0) \/ (n = 0)
\ENDTHEOREM
\THEOREM SUB\_EQUAL\_0 arithmetic
|- !c. c - c = 0
\ENDTHEOREM
\THEOREM SUB\_LEFT\_ADD arithmetic
|- !m n p. m + (n - p) = (n <= p => m | (m + n) - p)
\ENDTHEOREM
\THEOREM SUB\_LEFT\_EQ arithmetic
|- !m n p. (m = n - p) = (m + p = n) \/ m <= 0 /\ n <= p
\ENDTHEOREM
\THEOREM SUB\_LEFT\_GREATER arithmetic
|- !m n p. m > (n - p) = (m + p) > n /\ m > 0
\ENDTHEOREM
\THEOREM SUB\_LEFT\_GREATER\_EQ arithmetic
|- !m n p. m >= (n - p) = (m + p) >= n
\ENDTHEOREM
\THEOREM SUB\_LEFT\_LESS arithmetic
|- !m n p. m < (n - p) = (m + p) < n
\ENDTHEOREM
\THEOREM SUB\_LEFT\_LESS\_EQ arithmetic
|- !m n p. m <= (n - p) = (m + p) <= n \/ m <= 0
\ENDTHEOREM
\THEOREM SUB\_LEFT\_SUB arithmetic
|- !m n p. m - (n - p) = (n <= p => m | (m + p) - n)
\ENDTHEOREM
\THEOREM SUB\_LEFT\_SUC arithmetic
|- !m n. SUC(m - n) = (m <= n => SUC 0 | (SUC m) - n)
\ENDTHEOREM
\THEOREM SUB\_LESS\_0 arithmetic
|- !n m. m < n = 0 < (n - m)
\ENDTHEOREM
\THEOREM SUB\_LESS\_EQ\_ADD arithmetic
|- !m p. m <= p ==> (!n. (p - m) <= n = p <= (m + n))
\ENDTHEOREM
\THEOREM SUB\_LESS\_EQ arithmetic
|- !n m. (n - m) <= n
\ENDTHEOREM
\THEOREM SUB\_LESS\_OR arithmetic
|- !m n. n < m ==> n <= (m - 1)
\ENDTHEOREM
\THEOREM SUB\_MONO\_EQ arithmetic
|- !n m. (SUC n) - (SUC m) = n - m
\ENDTHEOREM
\THEOREM SUB\_PLUS arithmetic
|- !a b c. a - (b + c) = (a - b) - c
\ENDTHEOREM
\THEOREM SUB\_RIGHT\_ADD arithmetic
|- !m n p. (m - n) + p = (m <= n => p | (m + p) - n)
\ENDTHEOREM
\THEOREM SUB\_RIGHT\_EQ arithmetic
|- !m n p. (m - n = p) = (m = n + p) \/ m <= n /\ p <= 0
\ENDTHEOREM
\THEOREM SUB\_RIGHT\_GREATER arithmetic
|- !m n p. (m - n) > p = m > (n + p)
\ENDTHEOREM
\THEOREM SUB\_RIGHT\_GREATER\_EQ arithmetic
|- !m n p. (m - n) >= p = m >= (n + p) \/ 0 >= p
\ENDTHEOREM
\THEOREM SUB\_RIGHT\_LESS arithmetic
|- !m n p. (m - n) < p = m < (n + p) /\ 0 < p
\ENDTHEOREM
\THEOREM SUB\_RIGHT\_LESS\_EQ arithmetic
|- !m n p. (m - n) <= p = m <= (n + p)
\ENDTHEOREM
\THEOREM SUB\_RIGHT\_SUB arithmetic
|- !m n p. (m - n) - p = m - (n + p)
\ENDTHEOREM
\THEOREM SUB\_SUB arithmetic
|- !b c. c <= b ==> (!a. a - (b - c) = (a + c) - b)
\ENDTHEOREM
\THEOREM SUC\_ADD\_SYM arithmetic
|- !m n. SUC(m + n) = (SUC n) + m
\ENDTHEOREM
\THEOREM SUC\_DEF num
|- !m. SUC m = ABS_num(SUC_REP(REP_num m))
\ENDTHEOREM
\THEOREM SUC\_ID prim\_rec
|- !n. ~(SUC n = n)
\ENDTHEOREM
\THEOREM SUC\_LESS prim\_rec
|- !m n. (SUC m) < n ==> m < n
\ENDTHEOREM
\THEOREM SUC\_NOT arithmetic
|- !n. ~(0 = SUC n)
\ENDTHEOREM
\THEOREM SUC\_ONE\_ADD arithmetic
|- !n. SUC n = 1 + n
\ENDTHEOREM
\THEOREM SUC\_REP\_DEF num
|- SUC_REP = (@f. ONE_ONE f /\ ~ONTO f)
\ENDTHEOREM
\THEOREM SUC\_SUB1 arithmetic
|- !m. (SUC m) - 1 = m
\ENDTHEOREM
\THEOREM TIMES2 arithmetic
|- !n. 2 * n = n + n
\ENDTHEOREM
\THEOREM WOP arithmetic
|- !P. (?n. P n) ==> (?n. P n /\ (!m. m < n ==> ~P m))
\ENDTHEOREM
\THEOREM ZERO\_DEF num
|- 0 = ABS_num ZERO_REP
\ENDTHEOREM
\THEOREM ZERO\_DIV arithmetic
|- !n. 0 < n ==> (0 DIV n = 0)
\ENDTHEOREM
\THEOREM ZERO\_LESS\_EQ arithmetic
|- !n. 0 <= n
\ENDTHEOREM
\THEOREM ZERO\_LESS\_EXP arithmetic
|- !m n. 0 < ((SUC n) EXP m)
\ENDTHEOREM
\THEOREM ZERO\_MOD arithmetic
|- !n. 0 < n ==> (0 MOD n = 0)
\ENDTHEOREM
\THEOREM ZERO\_REP\_DEF num
|- ZERO_REP = (@x. !y. ~(x = SUC_REP y))
\ENDTHEOREM
\section{Theorems about lists}\THEOREM ALL\_EL\_APPEND list
|- !P l1 l2. ALL_EL P(APPEND l1 l2) = ALL_EL P l1 /\ ALL_EL P l2
\ENDTHEOREM
\THEOREM ALL\_EL\_BUTFIRSTN list
|- !P l.
    ALL_EL P l ==> (!m. m <= (LENGTH l) ==> ALL_EL P(BUTFIRSTN m l))
\ENDTHEOREM
\THEOREM ALL\_EL\_BUTLASTN list
|- !P l. ALL_EL P l ==> (!m. m <= (LENGTH l) ==> ALL_EL P(BUTLASTN m l))
\ENDTHEOREM
\THEOREM ALL\_EL\_CONJ list
|- !P Q l. ALL_EL(\x. P x /\ Q x)l = ALL_EL P l /\ ALL_EL Q l
\ENDTHEOREM
\THEOREM ALL\_EL list
|- (!P. ALL_EL P[] = T) /\
   (!P x l. ALL_EL P(CONS x l) = P x /\ ALL_EL P l)
\ENDTHEOREM
\THEOREM ALL\_EL\_FIRSTN list
|- !P l. ALL_EL P l ==> (!m. m <= (LENGTH l) ==> ALL_EL P(FIRSTN m l))
\ENDTHEOREM
\THEOREM ALL\_EL\_FOLDL list
|- !P l. ALL_EL P l = FOLDL(\l' x. l' /\ P x)T l
\ENDTHEOREM
\THEOREM ALL\_EL\_FOLDL\_MAP list
|- !P l. ALL_EL P l = FOLDL $/\ T(MAP P l)
\ENDTHEOREM
\THEOREM ALL\_EL\_FOLDR list
|- !P l. ALL_EL P l = FOLDR(\x l'. P x /\ l')T l
\ENDTHEOREM
\THEOREM ALL\_EL\_FOLDR\_MAP list
|- !P l. ALL_EL P l = FOLDR $/\ T(MAP P l)
\ENDTHEOREM
\THEOREM ALL\_EL\_LASTN list
|- !P l. ALL_EL P l ==> (!m. m <= (LENGTH l) ==> ALL_EL P(LASTN m l))
\ENDTHEOREM
\THEOREM ALL\_EL\_MAP list
|- !P f l. ALL_EL P(MAP f l) = ALL_EL(P o f)l
\ENDTHEOREM
\THEOREM ALL\_EL\_REPLICATE list
|- !x n. ALL_EL($= x)(REPLICATE n x)
\ENDTHEOREM
\THEOREM ALL\_EL\_REVERSE list
|- !P l. ALL_EL P(REVERSE l) = ALL_EL P l
\ENDTHEOREM
\THEOREM ALL\_EL\_SEG list
|- !P l.
    ALL_EL P l ==> (!m k. (m + k) <= (LENGTH l) ==> ALL_EL P(SEG m k l))
\ENDTHEOREM
\THEOREM ALL\_EL\_SNOC list
|- !P x l. ALL_EL P(SNOC x l) = ALL_EL P l /\ P x
\ENDTHEOREM
\THEOREM AND\_EL\_DEF list
|- AND_EL = ALL_EL I
\ENDTHEOREM
\THEOREM AND\_EL\_FOLDL list
|- !l. AND_EL l = FOLDL $/\ T l
\ENDTHEOREM
\THEOREM AND\_EL\_FOLDR list
|- !l. AND_EL l = FOLDR $/\ T l
\ENDTHEOREM
\THEOREM AP ltree
|- (!l. AP[]l = []) /\
   (!h t l. AP(CONS h t)l = CONS(h(HD l))(AP t(TL l)))
\ENDTHEOREM

\THEOREM APPEND\_ASSOC list
|- !l1 l2 l3. APPEND l1(APPEND l2 l3) = APPEND(APPEND l1 l2)l3
\ENDTHEOREM
\THEOREM APPEND\_BUTLAST\_LAST list
|- !l. ~(l = []) ==> (APPEND(BUTLAST l)[LAST l] = l)
\ENDTHEOREM
\THEOREM APPEND\_BUTLASTN\_BUTFIRSTN list
|- !m n l.
    (m + n = LENGTH l) ==> (APPEND(BUTLASTN m l)(BUTFIRSTN n l) = l)
\ENDTHEOREM
\THEOREM APPEND\_BUTLASTN\_LASTN list
|- !n l. n <= (LENGTH l) ==> (APPEND(BUTLASTN n l)(LASTN n l) = l)
\ENDTHEOREM
\THEOREM APPEND list
|- (!l. APPEND[]l = l) /\
   (!l1 l2 h. APPEND(CONS h l1)l2 = CONS h(APPEND l1 l2))
\ENDTHEOREM
\THEOREM APPEND\_FIRSTN\_BUTFIRSTN list
|- !n l. n <= (LENGTH l) ==> (APPEND(FIRSTN n l)(BUTFIRSTN n l) = l)
\ENDTHEOREM
\THEOREM APPEND\_FIRSTN\_LASTN list
|- !m n l. (m + n = LENGTH l) ==> (APPEND(FIRSTN n l)(LASTN m l) = l)
\ENDTHEOREM
\THEOREM APPEND\_FOLDL list
|- !l1 l2. APPEND l1 l2 = FOLDL(\l' x. SNOC x l')l1 l2
\ENDTHEOREM
\THEOREM APPEND\_FOLDR list
|- !l1 l2. APPEND l1 l2 = FOLDR CONS l2 l1
\ENDTHEOREM
\THEOREM APPEND\_LENGTH\_EQ list
|- !l1 l1'.
    (LENGTH l1 = LENGTH l1') ==>
    (!l2 l2'.
      (LENGTH l2 = LENGTH l2') ==>
      ((APPEND l1 l2 = APPEND l1' l2') = (l1 = l1') /\ (l2 = l2')))
\ENDTHEOREM
\THEOREM APPEND\_NIL list
|- (!l. APPEND l[] = l) /\ (!l. APPEND[]l = l)
\ENDTHEOREM
\THEOREM APPEND\_SNOC list
|- !l1 x l2. APPEND l1(SNOC x l2) = SNOC x(APPEND l1 l2)
\ENDTHEOREM
\THEOREM ASSOC\_APPEND list
|- ASSOC APPEND
\ENDTHEOREM
\THEOREM ASSOC\_FOLDL\_FLAT list
|- !f.
    ASSOC f ==>
    (!e.
      RIGHT_ID f e ==>
      (!l. FOLDL f e(FLAT l) = FOLDL f e(MAP(FOLDL f e)l)))
\ENDTHEOREM
\THEOREM ASSOC\_FOLDR\_FLAT list
|- !f.
    ASSOC f ==>
    (!e.
      LEFT_ID f e ==>
      (!l. FOLDR f e(FLAT l) = FOLDR f e(MAP(FOLDR f e)l)))
\ENDTHEOREM
\THEOREM BUTFIRSTN\_APPEND1 list
|- !n l1.
    n <= (LENGTH l1) ==>
    (!l2. BUTFIRSTN n(APPEND l1 l2) = APPEND(BUTFIRSTN n l1)l2)
\ENDTHEOREM
\THEOREM BUTFIRSTN\_APPEND2 list
|- !l1 n.
    (LENGTH l1) <= n ==>
    (!l2. BUTFIRSTN n(APPEND l1 l2) = BUTFIRSTN(n - (LENGTH l1))l2)
\ENDTHEOREM
\THEOREM BUTFIRSTN\_BUTFIRSTN list
|- !n m l.
    (n + m) <= (LENGTH l) ==>
    (BUTFIRSTN n(BUTFIRSTN m l) = BUTFIRSTN(n + m)l)
\ENDTHEOREM
\THEOREM BUTFIRSTN list
|- (!l. BUTFIRSTN 0 l = l) /\
   (!n x l. BUTFIRSTN(SUC n)(CONS x l) = BUTFIRSTN n l)
\ENDTHEOREM
\THEOREM BUTFIRSTN\_LASTN list
|- !n l. n <= (LENGTH l) ==> (BUTFIRSTN n l = LASTN((LENGTH l) - n)l)
\ENDTHEOREM
\THEOREM BUTFIRSTN\_LENGTH\_APPEND list
|- !l1 l2. BUTFIRSTN(LENGTH l1)(APPEND l1 l2) = l2
\ENDTHEOREM
\THEOREM BUTFIRSTN\_LENGTH\_NIL list
|- !l. BUTFIRSTN(LENGTH l)l = []
\ENDTHEOREM
\THEOREM BUTFIRSTN\_REVERSE list
|- !n l.
    n <= (LENGTH l) ==> (BUTFIRSTN n(REVERSE l) = REVERSE(BUTLASTN n l))
\ENDTHEOREM
\THEOREM BUTFIRSTN\_SEG list
|- !n l. n <= (LENGTH l) ==> (BUTFIRSTN n l = SEG((LENGTH l) - n)n l)
\ENDTHEOREM
\THEOREM BUTFIRSTN\_SNOC list
|- !n l.
    n <= (LENGTH l) ==>
    (!x. BUTFIRSTN n(SNOC x l) = SNOC x(BUTFIRSTN n l))
\ENDTHEOREM
\THEOREM BUTLAST\_DEF list
|- !l. BUTLAST l = SEG(PRE(LENGTH l))0 l
\ENDTHEOREM
\THEOREM BUTLAST list
|- !x l. BUTLAST(SNOC x l) = l
\ENDTHEOREM
\THEOREM BUTLASTN\_1 list
|- !l. ~(l = []) ==> (BUTLASTN 1 l = BUTLAST l)
\ENDTHEOREM
\THEOREM BUTLASTN\_APPEND1 list
|- !l2 n.
    (LENGTH l2) <= n ==>
    (!l1. BUTLASTN n(APPEND l1 l2) = BUTLASTN(n - (LENGTH l2))l1)
\ENDTHEOREM
\THEOREM BUTLASTN\_APPEND2 list
|- !n l1 l2.
    n <= (LENGTH l2) ==>
    (BUTLASTN n(APPEND l1 l2) = APPEND l1(BUTLASTN n l2))
\ENDTHEOREM
\THEOREM BUTLASTN\_BUTLAST list
|- !n l.
    n < (LENGTH l) ==> (BUTLASTN n(BUTLAST l) = BUTLAST(BUTLASTN n l))
\ENDTHEOREM
\THEOREM BUTLASTN\_BUTLASTN list
|- !m n l.
    (n + m) <= (LENGTH l) ==>
    (BUTLASTN n(BUTLASTN m l) = BUTLASTN(n + m)l)
\ENDTHEOREM
\THEOREM BUTLASTN\_CONS list
|- !n l.
    n <= (LENGTH l) ==>
    (!x. BUTLASTN n(CONS x l) = CONS x(BUTLASTN n l))
\ENDTHEOREM
\THEOREM BUTLASTN list
|- (!l. BUTLASTN 0 l = l) /\
   (!n x l. BUTLASTN(SUC n)(SNOC x l) = BUTLASTN n l)
\ENDTHEOREM
\THEOREM BUTLASTN\_FIRSTN list
|- !n l. n <= (LENGTH l) ==> (BUTLASTN n l = FIRSTN((LENGTH l) - n)l)
\ENDTHEOREM
\THEOREM BUTLASTN\_LASTN list
|- !m n l.
    m <= n /\ n <= (LENGTH l) ==>
    (BUTLASTN m(LASTN n l) = LASTN(n - m)(BUTLASTN m l))
\ENDTHEOREM
\THEOREM BUTLASTN\_LASTN\_NIL list
|- !n l. n <= (LENGTH l) ==> (BUTLASTN n(LASTN n l) = [])
\ENDTHEOREM
\THEOREM BUTLASTN\_LENGTH\_APPEND list
|- !l2 l1. BUTLASTN(LENGTH l2)(APPEND l1 l2) = l1
\ENDTHEOREM
\THEOREM BUTLASTN\_LENGTH\_CONS list
|- !l x. BUTLASTN(LENGTH l)(CONS x l) = [x]
\ENDTHEOREM
\THEOREM BUTLASTN\_LENGTH\_NIL list
|- !l. BUTLASTN(LENGTH l)l = []
\ENDTHEOREM
\THEOREM BUTLASTN\_MAP list
|- !n l.
    n <= (LENGTH l) ==> (!f. BUTLASTN n(MAP f l) = MAP f(BUTLASTN n l))
\ENDTHEOREM
\THEOREM BUTLASTN\_REVERSE list
|- !n l.
    n <= (LENGTH l) ==> (BUTLASTN n(REVERSE l) = REVERSE(BUTFIRSTN n l))
\ENDTHEOREM
\THEOREM BUTLASTN\_SEG list
|- !n l. n <= (LENGTH l) ==> (BUTLASTN n l = SEG((LENGTH l) - n)0 l)
\ENDTHEOREM
\THEOREM BUTLASTN\_SUC\_BUTLAST list
|- !n l. n < (LENGTH l) ==> (BUTLASTN(SUC n)l = BUTLASTN n(BUTLAST l))
\ENDTHEOREM
\THEOREM COMM\_ASSOC\_FOLDL\_REVERSE list
|- !f. COMM f ==> ASSOC f ==> (!e l. FOLDL f e(REVERSE l) = FOLDL f e l)
\ENDTHEOREM
\THEOREM COMM\_ASSOC\_FOLDR\_REVERSE list
|- !f. COMM f ==> ASSOC f ==> (!e l. FOLDR f e(REVERSE l) = FOLDR f e l)
\ENDTHEOREM
\THEOREM COMM\_MONOID\_FOLDL list
|- !f.
    COMM f ==>
    (!e'. MONOID f e' ==> (!e l. FOLDL f e l = f e(FOLDL f e' l)))
\ENDTHEOREM
\THEOREM COMM\_MONOID\_FOLDR list
|- !f.
    COMM f ==>
    (!e'. MONOID f e' ==> (!e l. FOLDR f e l = f e(FOLDR f e' l)))
\ENDTHEOREM
\THEOREM CONS\_11 list
|- !h t h' t'. (CONS h t = CONS h' t') = (h = h') /\ (t = t')
\ENDTHEOREM
\THEOREM CONS\_APPEND list
|- !x l. CONS x l = APPEND[x]l
\ENDTHEOREM
\THEOREM CONS\_DEF list
|- !h t.
    CONS h t =
    ABS_list
    ((\m. ((m = 0) => h | FST(REP_list t)(PRE m))),SUC(SND(REP_list t)))
\ENDTHEOREM
\THEOREM CONS list
|- !l. ~NULL l ==> (CONS(HD l)(TL l) = l)
\ENDTHEOREM
\THEOREM EL\_APPEND1 list
|- !n l1 l2. n < (LENGTH l1) ==> (EL n(APPEND l1 l2) = EL n l1)
\ENDTHEOREM
\THEOREM EL\_APPEND2 list
|- !l1 n.
    (LENGTH l1) <= n ==>
    (!l2. EL n(APPEND l1 l2) = EL(n - (LENGTH l1))l2)
\ENDTHEOREM
\THEOREM EL\_CONS list
|- !n. 0 < n ==> (!x l. EL n(CONS x l) = EL(PRE n)l)
\ENDTHEOREM
\THEOREM EL list
|- (!l. EL 0 l = HD l) /\ (!l n. EL(SUC n)l = EL n(TL l))
\ENDTHEOREM
\THEOREM EL\_ELL list
|- !n l. n < (LENGTH l) ==> (EL n l = ELL(PRE((LENGTH l) - n))l)
\ENDTHEOREM
\THEOREM EL\_IS\_EL list
|- !n l. n < (LENGTH l) ==> IS_EL(EL n l)l
\ENDTHEOREM
\THEOREM ELL\_0\_SNOC list
|- !l x. ELL 0(SNOC x l) = x
\ENDTHEOREM
\THEOREM ELL\_APPEND1 list
|- !l2 n.
    (LENGTH l2) <= n ==>
    (!l1. ELL n(APPEND l1 l2) = ELL(n - (LENGTH l2))l1)
\ENDTHEOREM
\THEOREM ELL\_APPEND2 list
|- !n l2. n < (LENGTH l2) ==> (!l1. ELL n(APPEND l1 l2) = ELL n l2)
\ENDTHEOREM
\THEOREM ELL\_CONS list
|- !n l. n < (LENGTH l) ==> (!x. ELL n(CONS x l) = ELL n l)
\ENDTHEOREM
\THEOREM ELL list
|- (!l. ELL 0 l = LAST l) /\ (!n l. ELL(SUC n)l = ELL n(BUTLAST l))
\ENDTHEOREM
\THEOREM ELL\_EL list
|- !n l. n < (LENGTH l) ==> (ELL n l = EL(PRE((LENGTH l) - n))l)
\ENDTHEOREM
\THEOREM EL\_LENGTH\_APPEND list
|- !l2 l1. ~NULL l2 ==> (EL(LENGTH l1)(APPEND l1 l2) = HD l2)
\ENDTHEOREM
\THEOREM EL\_LENGTH\_SNOC list
|- !l x. EL(LENGTH l)(SNOC x l) = x
\ENDTHEOREM
\THEOREM ELL\_IS\_EL list
|- !n l. n < (LENGTH l) ==> IS_EL(EL n l)l
\ENDTHEOREM
\THEOREM ELL\_LAST list
|- !l. ~NULL l ==> (ELL 0 l = LAST l)
\ENDTHEOREM
\THEOREM ELL\_LENGTH\_APPEND list
|- !l1 l2. ~NULL l1 ==> (ELL(LENGTH l2)(APPEND l1 l2) = LAST l1)
\ENDTHEOREM
\THEOREM ELL\_LENGTH\_CONS list
|- !l x. ELL(LENGTH l)(CONS x l) = x
\ENDTHEOREM
\THEOREM ELL\_LENGTH\_SNOC list
|- !l x. ELL(LENGTH l)(SNOC x l) = (NULL l => x | HD l)
\ENDTHEOREM
\THEOREM ELL\_MAP list
|- !n l f. n < (LENGTH l) ==> (ELL n(MAP f l) = f(ELL n l))
\ENDTHEOREM
\THEOREM ELL\_PRE\_LENGTH list
|- !l. ~(l = []) ==> (ELL(PRE(LENGTH l))l = HD l)
\ENDTHEOREM
\THEOREM ELL\_REVERSE list
|- !n l.
    n < (LENGTH l) ==> (ELL n(REVERSE l) = ELL(PRE((LENGTH l) - n))l)
\ENDTHEOREM
\THEOREM ELL\_REVERSE\_EL list
|- !n l. n < (LENGTH l) ==> (ELL n(REVERSE l) = EL n l)
\ENDTHEOREM
\THEOREM ELL\_SEG list
|- !n l. n < (LENGTH l) ==> (ELL n l = HD(SEG 1(PRE((LENGTH l) - n))l))
\ENDTHEOREM
\THEOREM ELL\_SNOC list
|- !n. 0 < n ==> (!x l. ELL n(SNOC x l) = ELL(PRE n)l)
\ENDTHEOREM
\THEOREM ELL\_SUC\_SNOC list
|- !n x l. ELL(SUC n)(SNOC x l) = ELL n l
\ENDTHEOREM
\THEOREM EL\_MAP list
|- !n l. n < (LENGTH l) ==> (!f. EL n(MAP f l) = f(EL n l))
\ENDTHEOREM
\THEOREM EL\_PRE\_LENGTH list
|- !l. ~(l = []) ==> (EL(PRE(LENGTH l))l = LAST l)
\ENDTHEOREM
\THEOREM EL\_REVERSE list
|- !n l. n < (LENGTH l) ==> (EL n(REVERSE l) = EL(PRE((LENGTH l) - n))l)
\ENDTHEOREM
\THEOREM EL\_REVERSE\_ELL list
|- !n l. n < (LENGTH l) ==> (EL n(REVERSE l) = ELL n l)
\ENDTHEOREM
\THEOREM EL\_SEG list
|- !n l. n < (LENGTH l) ==> (EL n l = HD(SEG 1 n l))
\ENDTHEOREM
\THEOREM EL\_SNOC list
|- !n l. n < (LENGTH l) ==> (!x. EL n(SNOC x l) = EL n l)
\ENDTHEOREM
\THEOREM EQ\_LIST list
|- !h1 h2.
    (h1 = h2) ==> (!l1 l2. (l1 = l2) ==> (CONS h1 l1 = CONS h2 l2))
\ENDTHEOREM
\THEOREM FCOMM\_FOLDL\_APPEND list
|- !f g.
    FCOMM f g ==>
    (!e.
      RIGHT_ID g e ==>
      (!l1 l2. FOLDL f e(APPEND l1 l2) = g(FOLDL f e l1)(FOLDL f e l2)))
\ENDTHEOREM
\THEOREM FCOMM\_FOLDL\_FLAT list
|- !f g.
    FCOMM f g ==>
    (!e.
      RIGHT_ID g e ==>
      (!l. FOLDL f e(FLAT l) = FOLDL g e(MAP(FOLDL f e)l)))
\ENDTHEOREM
\THEOREM FCOMM\_FOLDR\_APPEND list
|- !g f.
    FCOMM g f ==>
    (!e.
      LEFT_ID g e ==>
      (!l1 l2. FOLDR f e(APPEND l1 l2) = g(FOLDR f e l1)(FOLDR f e l2)))
\ENDTHEOREM
\THEOREM FCOMM\_FOLDR\_FLAT list
|- !g f.
    FCOMM g f ==>
    (!e.
      LEFT_ID g e ==>
      (!l. FOLDR f e(FLAT l) = FOLDR g e(MAP(FOLDR f e)l)))
\ENDTHEOREM
\THEOREM FILTER\_APPEND list
|- !f l1 l2. FILTER f(APPEND l1 l2) = APPEND(FILTER f l1)(FILTER f l2)
\ENDTHEOREM
\THEOREM FILTER\_COMM list
|- !f1 f2 l. FILTER f1(FILTER f2 l) = FILTER f2(FILTER f1 l)
\ENDTHEOREM
\THEOREM FILTER list
|- (!P. FILTER P[] = []) /\
   (!P x l.
     FILTER P(CONS x l) = (P x => CONS x(FILTER P l) | FILTER P l))
\ENDTHEOREM
\THEOREM FILTER\_FILTER list
|- !P Q l. FILTER P(FILTER Q l) = FILTER(\x. P x /\ Q x)l
\ENDTHEOREM
\THEOREM FILTER\_FLAT list
|- !P l. FILTER P(FLAT l) = FLAT(MAP(FILTER P)l)
\ENDTHEOREM
\THEOREM FILTER\_FOLDL list
|- !P l. FILTER P l = FOLDL(\l' x. (P x => SNOC x l' | l'))[]l
\ENDTHEOREM
\THEOREM FILTER\_FOLDR list
|- !P l. FILTER P l = FOLDR(\x l'. (P x => CONS x l' | l'))[]l
\ENDTHEOREM
\THEOREM FILTER\_IDEM list
|- !f l. FILTER f(FILTER f l) = FILTER f l
\ENDTHEOREM
\THEOREM FILTER\_MAP list
|- !f1 f2 l. FILTER f1(MAP f2 l) = MAP f2(FILTER(f1 o f2)l)
\ENDTHEOREM
\THEOREM FILTER\_REVERSE list
|- !P l. FILTER P(REVERSE l) = REVERSE(FILTER P l)
\ENDTHEOREM
\THEOREM FILTER\_SNOC list
|- !P x l. FILTER P(SNOC x l) = (P x => SNOC x(FILTER P l) | FILTER P l)
\ENDTHEOREM
\THEOREM FIRSTN\_APPEND1 list
|- !n l1.
    n <= (LENGTH l1) ==> (!l2. FIRSTN n(APPEND l1 l2) = FIRSTN n l1)
\ENDTHEOREM
\THEOREM FIRSTN\_APPEND2 list
|- !l1 n.
    (LENGTH l1) <= n ==>
    (!l2. FIRSTN n(APPEND l1 l2) = APPEND l1(FIRSTN(n - (LENGTH l1))l2))
\ENDTHEOREM
\THEOREM FIRSTN\_BUTLASTN list
|- !n l. n <= (LENGTH l) ==> (FIRSTN n l = BUTLASTN((LENGTH l) - n)l)
\ENDTHEOREM
\THEOREM FIRSTN list
|- (!l. FIRSTN 0 l = []) /\
   (!n x l. FIRSTN(SUC n)(CONS x l) = CONS x(FIRSTN n l))
\ENDTHEOREM
\THEOREM FIRSTN\_FIRSTN list
|- !m l.
    m <= (LENGTH l) ==>
    (!n. n <= m ==> (FIRSTN n(FIRSTN m l) = FIRSTN n l))
\ENDTHEOREM
\THEOREM FIRSTN\_LENGTH\_APPEND list
|- !l1 l2. FIRSTN(LENGTH l1)(APPEND l1 l2) = l1
\ENDTHEOREM
\THEOREM FIRSTN\_LENGTH\_ID list
|- !l. FIRSTN(LENGTH l)l = l
\ENDTHEOREM
\THEOREM FIRSTN\_REVERSE list
|- !n l. n <= (LENGTH l) ==> (FIRSTN n(REVERSE l) = REVERSE(LASTN n l))
\ENDTHEOREM
\THEOREM FIRSTN\_SEG list
|- !n l. n <= (LENGTH l) ==> (FIRSTN n l = SEG n 0 l)
\ENDTHEOREM
\THEOREM FIRSTN\_SNOC list
|- !n l. n <= (LENGTH l) ==> (!x. FIRSTN n(SNOC x l) = FIRSTN n l)
\ENDTHEOREM
\THEOREM FLAT\_APPEND list
|- !l1 l2. FLAT(APPEND l1 l2) = APPEND(FLAT l1)(FLAT l2)
\ENDTHEOREM
\THEOREM FLAT list
|- (FLAT[] = []) /\ (!h t. FLAT(CONS h t) = APPEND h(FLAT t))
\ENDTHEOREM
\THEOREM FLAT\_FLAT list
|- !l. FLAT(FLAT l) = FLAT(MAP FLAT l)
\ENDTHEOREM
\THEOREM FLAT\_FOLDL list
|- !l. FLAT l = FOLDL APPEND[]l
\ENDTHEOREM
\THEOREM FLAT\_FOLDR list
|- !l. FLAT l = FOLDR APPEND[]l
\ENDTHEOREM
\THEOREM FLAT\_REVERSE list
|- !l. FLAT(REVERSE l) = REVERSE(FLAT(MAP REVERSE l))
\ENDTHEOREM
\THEOREM FLAT\_SNOC list
|- !x l. FLAT(SNOC x l) = APPEND(FLAT l)x
\ENDTHEOREM
\THEOREM FOLDL\_APPEND list
|- !f e l1 l2. FOLDL f e(APPEND l1 l2) = FOLDL f(FOLDL f e l1)l2
\ENDTHEOREM
\THEOREM FOLDL list
|- (!f e. FOLDL f e[] = e) /\
   (!f e x l. FOLDL f e(CONS x l) = FOLDL f(f e x)l)
\ENDTHEOREM
\THEOREM FOLDL\_FILTER list
|- !f e P l. FOLDL f e(FILTER P l) = FOLDL(\x y. (P y => f x y | x))e l
\ENDTHEOREM
\THEOREM FOLDL\_FOLDR\_REVERSE list
|- !f e l. FOLDL f e l = FOLDR(\x y. f y x)e(REVERSE l)
\ENDTHEOREM
\THEOREM FOLDL\_MAP list
|- !f e g l. FOLDL f e(MAP g l) = FOLDL(\x y. f x(g y))e l
\ENDTHEOREM
\THEOREM FOLDL\_REVERSE list
|- !f e l. FOLDL f e(REVERSE l) = FOLDR(\x y. f y x)e l
\ENDTHEOREM
\THEOREM FOLDL\_SINGLE list
|- !f e x. FOLDL f e[x] = f e x
\ENDTHEOREM
\THEOREM FOLDL\_SNOC list
|- !f e x l. FOLDL f e(SNOC x l) = f(FOLDL f e l)x
\ENDTHEOREM
\THEOREM FOLDL\_SNOC\_NIL list
|- !l. FOLDL(\xs x. SNOC x xs)[]l = l
\ENDTHEOREM
\THEOREM FOLDR\_APPEND list
|- !f e l1 l2. FOLDR f e(APPEND l1 l2) = FOLDR f(FOLDR f e l2)l1
\ENDTHEOREM
\THEOREM FOLDR\_CONS\_NIL list
|- !l. FOLDR CONS[]l = l
\ENDTHEOREM
\THEOREM FOLDR list
|- (!f e. FOLDR f e[] = e) /\
   (!f e x l. FOLDR f e(CONS x l) = f x(FOLDR f e l))
\ENDTHEOREM
\THEOREM FOLDR\_FILTER list
|- !f e P l. FOLDR f e(FILTER P l) = FOLDR(\x y. (P x => f x y | y))e l
\ENDTHEOREM
\THEOREM FOLDR\_FILTER\_REVERSE list
|- !f.
    (!a b c. f a(f b c) = f b(f a c)) ==>
    (!e P l. FOLDR f e(FILTER P(REVERSE l)) = FOLDR f e(FILTER P l))
\ENDTHEOREM
\THEOREM FOLDR\_FOLDL list
|- !f e. MONOID f e ==> (!l. FOLDR f e l = FOLDL f e l)
\ENDTHEOREM
\THEOREM FOLDR\_FOLDL\_REVERSE list
|- !f e l. FOLDR f e l = FOLDL(\x y. f y x)e(REVERSE l)
\ENDTHEOREM
\THEOREM FOLDR\_MAP list
|- !f e g l. FOLDR f e(MAP g l) = FOLDR(\x y. f(g x)y)e l
\ENDTHEOREM
\THEOREM FOLDR\_MAP\_REVERSE list
|- !f.
    (!a b c. f a(f b c) = f b(f a c)) ==>
    (!e g l. FOLDR f e(MAP g(REVERSE l)) = FOLDR f e(MAP g l))
\ENDTHEOREM
\THEOREM FOLDR\_REVERSE list
|- !f e l. FOLDR f e(REVERSE l) = FOLDL(\x y. f y x)e l
\ENDTHEOREM
\THEOREM FOLDR\_SINGLE list
|- !f e x. FOLDR f e[x] = f x e
\ENDTHEOREM
\THEOREM FOLDR\_SNOC list
|- !f e x l. FOLDR f e(SNOC x l) = FOLDR f(f x e)l
\ENDTHEOREM
\THEOREM GENLIST list
|- (!f. GENLIST f 0 = []) /\
   (!f n. GENLIST f(SUC n) = SNOC(f n)(GENLIST f n))
\ENDTHEOREM
\THEOREM HD list
|- !h t. HD(CONS h t) = h
\ENDTHEOREM
\THEOREM IS\_EL\_APPEND list
|- !l1 l2 x. IS_EL x(APPEND l1 l2) = IS_EL x l1 \/ IS_EL x l2
\ENDTHEOREM
\THEOREM IS\_EL\_BUTFIRSTN list
|- !m l. m <= (LENGTH l) ==> (!x. IS_EL x(BUTFIRSTN m l) ==> IS_EL x l)
\ENDTHEOREM
\THEOREM IS\_EL\_BUTLASTN list
|- !m l. m <= (LENGTH l) ==> (!x. IS_EL x(BUTLASTN m l) ==> IS_EL x l)
\ENDTHEOREM
\THEOREM IS\_EL\_DEF list
|- !x l. IS_EL x l = SOME_EL($= x)l
\ENDTHEOREM
\THEOREM IS\_EL list
|- (!x. IS_EL x[] = F) /\
   (!y x l. IS_EL y(CONS x l) = (y = x) \/ IS_EL y l)
\ENDTHEOREM
\THEOREM IS\_EL\_FILTER list
|- !P x. P x ==> (!l. IS_EL x(FILTER P l) = IS_EL x l)
\ENDTHEOREM
\THEOREM IS\_EL\_FIRSTN list
|- !m l. m <= (LENGTH l) ==> (!x. IS_EL x(FIRSTN m l) ==> IS_EL x l)
\ENDTHEOREM
\THEOREM IS\_EL\_FOLDL list
|- !y l. IS_EL y l = FOLDL(\l' x. l' \/ (y = x))F l
\ENDTHEOREM
\THEOREM IS\_EL\_FOLDL\_MAP list
|- !x l. IS_EL x l = FOLDL $\/ F(MAP($= x)l)
\ENDTHEOREM
\THEOREM IS\_EL\_FOLDR list
|- !y l. IS_EL y l = FOLDR(\x l'. (y = x) \/ l')F l
\ENDTHEOREM
\THEOREM IS\_EL\_FOLDR\_MAP list
|- !x l. IS_EL x l = FOLDR $\/ F(MAP($= x)l)
\ENDTHEOREM
\THEOREM IS\_EL\_LASTN list
|- !m l. m <= (LENGTH l) ==> (!x. IS_EL x(LASTN m l) ==> IS_EL x l)
\ENDTHEOREM
\THEOREM IS\_EL\_REPLICATE list
|- !n. 0 < n ==> (!x. IS_EL x(REPLICATE n x))
\ENDTHEOREM
\THEOREM IS\_EL\_REVERSE list
|- !x l. IS_EL x(REVERSE l) = IS_EL x l
\ENDTHEOREM
\THEOREM IS\_EL\_SEG list
|- !n m l.
    (n + m) <= (LENGTH l) ==> (!x. IS_EL x(SEG n m l) ==> IS_EL x l)
\ENDTHEOREM
\THEOREM IS\_EL\_SNOC list
|- !y x l. IS_EL y(SNOC x l) = (y = x) \/ IS_EL y l
\ENDTHEOREM
\THEOREM IS\_EL\_SOME\_EL list
|- !x l. IS_EL x l = SOME_EL($= x)l
\ENDTHEOREM
\THEOREM IS\_list\_REP list
|- !r. IS_list_REP r = (?f n. r = (\m. (m < n => f m | (@x. T))),n)
\ENDTHEOREM
\THEOREM IS\_PREFIX\_APPEND list
|- !l1 l2. IS_PREFIX l1 l2 = (?l. l1 = APPEND l2 l)
\ENDTHEOREM
\THEOREM IS\_PREFIX list
|- (!l. IS_PREFIX l[] = T) /\
   (!x l. IS_PREFIX[](CONS x l) = F) /\
   (!x1 l1 x2 l2.
     IS_PREFIX(CONS x1 l1)(CONS x2 l2) = (x1 = x2) /\ IS_PREFIX l1 l2)
\ENDTHEOREM
\THEOREM IS\_PREFIX\_IS\_SUBLIST list
|- !l1 l2. IS_PREFIX l1 l2 ==> IS_SUBLIST l1 l2
\ENDTHEOREM
\THEOREM IS\_PREFIX\_PREFIX list
|- !P l. IS_PREFIX l(PREFIX P l)
\ENDTHEOREM
\THEOREM IS\_PREFIX\_REVERSE list
|- !l1 l2. IS_PREFIX(REVERSE l1)(REVERSE l2) = IS_SUFFIX l1 l2
\ENDTHEOREM
\THEOREM IS\_SUBLIST\_APPEND list
|- !l1 l2. IS_SUBLIST l1 l2 = (?l l'. l1 = APPEND l(APPEND l2 l'))
\ENDTHEOREM
\THEOREM IS\_SUBLIST list
|- (!l. IS_SUBLIST l[] = T) /\
   (!x l. IS_SUBLIST[](CONS x l) = F) /\
   (!x1 l1 x2 l2.
     IS_SUBLIST(CONS x1 l1)(CONS x2 l2) =
     (x1 = x2) /\ IS_PREFIX l1 l2 \/ IS_SUBLIST l1(CONS x2 l2))
\ENDTHEOREM
\THEOREM IS\_SUBLIST\_REVERSE list
|- !l1 l2. IS_SUBLIST(REVERSE l1)(REVERSE l2) = IS_SUBLIST l1 l2
\ENDTHEOREM
\THEOREM IS\_SUFFIX\_APPEND list
|- !l1 l2. IS_SUFFIX l1 l2 = (?l. l1 = APPEND l l2)
\ENDTHEOREM
\THEOREM IS\_SUFFIX list
|- (!l. IS_SUFFIX l[] = T) /\
   (!x l. IS_SUFFIX[](SNOC x l) = F) /\
   (!x1 l1 x2 l2.
     IS_SUFFIX(SNOC x1 l1)(SNOC x2 l2) = (x1 = x2) /\ IS_SUFFIX l1 l2)
\ENDTHEOREM
\THEOREM IS\_SUFFIX\_IS\_SUBLIST list
|- !l1 l2. IS_SUFFIX l1 l2 ==> IS_SUBLIST l1 l2
\ENDTHEOREM
\THEOREM IS\_SUFFIX\_REVERSE list
|- !l1 l2. IS_SUFFIX(REVERSE l1)(REVERSE l2) = IS_PREFIX l1 l2
\ENDTHEOREM
\THEOREM LAST\_DEF list
|- !l. LAST l = HD(SEG 1(PRE(LENGTH l))l)
\ENDTHEOREM
\THEOREM LAST list
|- !x l. LAST(SNOC x l) = x
\ENDTHEOREM
\THEOREM LAST\_LASTN\_LAST list
|- !n l. n <= (LENGTH l) ==> 0 < n ==> (LAST(LASTN n l) = LAST l)
\ENDTHEOREM
\THEOREM LASTN\_1 list
|- !l. ~(l = []) ==> (LASTN 1 l = [LAST l])
\ENDTHEOREM
\THEOREM LASTN\_APPEND1 list
|- !l2 n.
    (LENGTH l2) <= n ==>
    (!l1. LASTN n(APPEND l1 l2) = APPEND(LASTN(n - (LENGTH l2))l1)l2)
\ENDTHEOREM
\THEOREM LASTN\_APPEND2 list
|- !n l2. n <= (LENGTH l2) ==> (!l1. LASTN n(APPEND l1 l2) = LASTN n l2)
\ENDTHEOREM
\THEOREM LASTN\_BUTFIRSTN list
|- !n l. n <= (LENGTH l) ==> (LASTN n l = BUTFIRSTN((LENGTH l) - n)l)
\ENDTHEOREM
\THEOREM LASTN\_BUTLASTN list
|- !n m l.
    (n + m) <= (LENGTH l) ==>
    (LASTN n(BUTLASTN m l) = BUTLASTN m(LASTN(n + m)l))
\ENDTHEOREM
\THEOREM LASTN\_CONS list
|- !n l. n <= (LENGTH l) ==> (!x. LASTN n(CONS x l) = LASTN n l)
\ENDTHEOREM
\THEOREM LASTN list
|- (!l. LASTN 0 l = []) /\
   (!n x l. LASTN(SUC n)(SNOC x l) = SNOC x(LASTN n l))
\ENDTHEOREM
\THEOREM LASTN\_LASTN list
|- !l n m.
    m <= (LENGTH l) ==> n <= m ==> (LASTN n(LASTN m l) = LASTN n l)
\ENDTHEOREM
\THEOREM LASTN\_LENGTH\_APPEND list
|- !l1 l2. LASTN(LENGTH l2)(APPEND l1 l2) = l2
\ENDTHEOREM
\THEOREM LASTN\_LENGTH\_ID list
|- !l. LASTN(LENGTH l)l = l
\ENDTHEOREM
\THEOREM LASTN\_MAP list
|- !n l. n <= (LENGTH l) ==> (!f. LASTN n(MAP f l) = MAP f(LASTN n l))
\ENDTHEOREM
\THEOREM LASTN\_REVERSE list
|- !n l. n <= (LENGTH l) ==> (LASTN n(REVERSE l) = REVERSE(FIRSTN n l))
\ENDTHEOREM
\THEOREM LASTN\_SEG list
|- !n l. n <= (LENGTH l) ==> (LASTN n l = SEG n((LENGTH l) - n)l)
\ENDTHEOREM
\THEOREM LENGTH\_APPEND list
|- !l1 l2. LENGTH(APPEND l1 l2) = (LENGTH l1) + (LENGTH l2)
\ENDTHEOREM
\THEOREM LENGTH\_BUTFIRSTN list
|- !n l. n <= (LENGTH l) ==> (LENGTH(BUTFIRSTN n l) = (LENGTH l) - n)
\ENDTHEOREM
\THEOREM LENGTH\_BUTLAST list
|- !l. ~(l = []) ==> (LENGTH(BUTLAST l) = PRE(LENGTH l))
\ENDTHEOREM
\THEOREM LENGTH\_BUTLASTN list
|- !n l. n <= (LENGTH l) ==> (LENGTH(BUTLASTN n l) = (LENGTH l) - n)
\ENDTHEOREM
\THEOREM LENGTH\_CONS list
|- !l n.
    (LENGTH l = SUC n) = (?h l'. (LENGTH l' = n) /\ (l = CONS h l'))
\ENDTHEOREM
\THEOREM LENGTH list
|- (LENGTH[] = 0) /\ (!h t. LENGTH(CONS h t) = SUC(LENGTH t))
\ENDTHEOREM
\THEOREM LENGTH\_EQ\_CONS list
|- !P n.
    (!l. (LENGTH l = SUC n) ==> P l) =
    (!l. (LENGTH l = n) ==> (\l. !x. P(CONS x l))l)
\ENDTHEOREM
\THEOREM LENGTH\_EQ list
|- !x y. (x = y) ==> (LENGTH x = LENGTH y)
\ENDTHEOREM
\THEOREM LENGTH\_EQ\_NIL list
|- !P. (!l. (LENGTH l = 0) ==> P l) = P[]
\ENDTHEOREM
\THEOREM LENGTH\_FIRSTN list
|- !n l. n <= (LENGTH l) ==> (LENGTH(FIRSTN n l) = n)
\ENDTHEOREM
\THEOREM LENGTH\_FLAT list
|- !l. LENGTH(FLAT l) = SUM(MAP LENGTH l)
\ENDTHEOREM
\THEOREM LENGTH\_FOLDL list
|- !l. LENGTH l = FOLDL(\l' x. SUC l')0 l
\ENDTHEOREM
\THEOREM LENGTH\_FOLDR list
|- !l. LENGTH l = FOLDR(\x l'. SUC l')0 l
\ENDTHEOREM
\THEOREM LENGTH\_GENLIST list
|- !f n. LENGTH(GENLIST f n) = n
\ENDTHEOREM
\THEOREM LENGTH\_LASTN list
|- !n l. n <= (LENGTH l) ==> (LENGTH(LASTN n l) = n)
\ENDTHEOREM
\THEOREM LENGTH\_MAP2 list
|- !l1 l2.
    (LENGTH l1 = LENGTH l2) ==>
    (!f.
      (LENGTH(MAP2 f l1 l2) = LENGTH l1) /\
      (LENGTH(MAP2 f l1 l2) = LENGTH l2))
\ENDTHEOREM
\THEOREM LENGTH\_MAP list
|- !l f. LENGTH(MAP f l) = LENGTH l
\ENDTHEOREM
\THEOREM LENGTH\_NIL list
|- !l. (LENGTH l = 0) = (l = [])
\ENDTHEOREM
\THEOREM LENGTH\_NOT\_NULL list
|- !l. 0 < (LENGTH l) = ~NULL l
\ENDTHEOREM
\THEOREM LENGTH\_REPLICATE list
|- !n x. LENGTH(REPLICATE n x) = n
\ENDTHEOREM
\THEOREM LENGTH\_REVERSE list
|- !l. LENGTH(REVERSE l) = LENGTH l
\ENDTHEOREM
\THEOREM LENGTH\_SCANL list
|- !f e l. LENGTH(SCANL f e l) = SUC(LENGTH l)
\ENDTHEOREM
\THEOREM LENGTH\_SCANR list
|- !f e l. LENGTH(SCANR f e l) = SUC(LENGTH l)
\ENDTHEOREM
\THEOREM LENGTH\_SEG list
|- !n k l. (n + k) <= (LENGTH l) ==> (LENGTH(SEG n k l) = n)
\ENDTHEOREM
\THEOREM LENGTH\_SNOC list
|- !x l. LENGTH(SNOC x l) = SUC(LENGTH l)
\ENDTHEOREM
\THEOREM LENGTH\_UNZIP\_FST list
|- !l. LENGTH(UNZIP_FST l) = LENGTH l
\ENDTHEOREM
\THEOREM LENGTH\_UNZIP\_SND list
|- !l. LENGTH(UNZIP_SND l) = LENGTH l
\ENDTHEOREM
\THEOREM LENGTH\_ZIP list
|- !l1 l2.
    (LENGTH l1 = LENGTH l2) ==>
    (LENGTH(ZIP(l1,l2)) = LENGTH l1) /\ (LENGTH(ZIP(l1,l2)) = LENGTH l2)
\ENDTHEOREM
\THEOREM list\_Axiom list
|- !x f. ?! fn. (fn[] = x) /\ (!h t. fn(CONS h t) = f(fn t)h t)
\ENDTHEOREM
\THEOREM list\_CASES list
|- !l. (l = []) \/ (?t h. l = CONS h t)
\ENDTHEOREM
\THEOREM list\_INDUCT list
|- !P. P[] /\ (!t. P t ==> (!h. P(CONS h t))) ==> (!l. P l)
\ENDTHEOREM
\THEOREM list\_ISO\_DEF list
|- (!a. ABS_list(REP_list a) = a) /\
   (!r. IS_list_REP r = (REP_list(ABS_list r) = r))
\ENDTHEOREM
\THEOREM LIST\_NOT\_EQ list
|- !l1 l2. ~(l1 = l2) ==> (!h1 h2. ~(CONS h1 l1 = CONS h2 l2))
\ENDTHEOREM
\THEOREM list\_TY\_DEF list
|- ?rep. TYPE_DEFINITION IS_list_REP rep
\ENDTHEOREM
\THEOREM MAP2 list
|- (!f. MAP2 f[][] = []) /\
   (!f h1 t1 h2 t2.
     MAP2 f(CONS h1 t1)(CONS h2 t2) = CONS(f h1 h2)(MAP2 f t1 t2))
\ENDTHEOREM
\THEOREM MAP2\_ZIP list
|- !l1 l2.
    (LENGTH l1 = LENGTH l2) ==>
    (!f. MAP2 f l1 l2 = MAP(UNCURRY f)(ZIP(l1,l2)))
\ENDTHEOREM
\THEOREM MAP\_APPEND list
|- !f l1 l2. MAP f(APPEND l1 l2) = APPEND(MAP f l1)(MAP f l2)
\ENDTHEOREM
\THEOREM MAP list
|- (!f. MAP f[] = []) /\ (!f h t. MAP f(CONS h t) = CONS(f h)(MAP f t))
\ENDTHEOREM
\THEOREM MAP\_FILTER list
|- !f P l.
    (!x. P(f x) = P x) ==> (MAP f(FILTER P l) = FILTER P(MAP f l))
\ENDTHEOREM
\THEOREM MAP\_FLAT list
|- !f l. MAP f(FLAT l) = FLAT(MAP(MAP f)l)
\ENDTHEOREM
\THEOREM MAP\_FOLDL list
|- !f l. MAP f l = FOLDL(\l' x. SNOC(f x)l')[]l
\ENDTHEOREM
\THEOREM MAP\_FOLDR list
|- !f l. MAP f l = FOLDR(\x l'. CONS(f x)l')[]l
\ENDTHEOREM
\THEOREM MAP\_MAP\_o list
|- !f g l. MAP f(MAP g l) = MAP(f o g)l
\ENDTHEOREM
\THEOREM MAP\_o list
|- !f g. MAP(f o g) = (MAP f) o (MAP g)
\ENDTHEOREM
\THEOREM MAP\_REVERSE list
|- !f l. MAP f(REVERSE l) = REVERSE(MAP f l)
\ENDTHEOREM
\THEOREM MAP\_SNOC list
|- !f x l. MAP f(SNOC x l) = SNOC(f x)(MAP f l)
\ENDTHEOREM
\THEOREM MONOID\_APPEND\_NIL list
|- MONOID APPEND[]
\ENDTHEOREM
\THEOREM NIL\_DEF list
|- [] = ABS_list((\n. @e. T),0)
\ENDTHEOREM
\THEOREM NOT\_ALL\_EL\_SOME\_EL list
|- !P l. ~ALL_EL P l = SOME_EL($~ o P)l
\ENDTHEOREM
\THEOREM NOT\_CONS\_NIL list
|- !h t. ~(CONS h t = [])
\ENDTHEOREM
\THEOREM NOT\_EQ\_LIST list
|- !h1 h2. ~(h1 = h2) ==> (!l1 l2. ~(CONS h1 l1 = CONS h2 l2))
\ENDTHEOREM
\THEOREM NOT\_NIL\_CONS list
|- !h t. ~([] = CONS h t)
\ENDTHEOREM
\THEOREM NOT\_NIL\_SNOC list
|- !x l. ~([] = SNOC x l)
\ENDTHEOREM
\THEOREM NOT\_SNOC\_NIL list
|- !x l. ~(SNOC x l = [])
\ENDTHEOREM
\THEOREM NOT\_SOME\_EL\_ALL\_EL list
|- !P l. ~SOME_EL P l = ALL_EL($~ o P)l
\ENDTHEOREM
\THEOREM NULL\_DEF list
|- (NULL[] = T) /\ (!h t. NULL(CONS h t) = F)
\ENDTHEOREM
\THEOREM NULL list
|- NULL[] /\ (!h t. ~NULL(CONS h t))
\ENDTHEOREM
\THEOREM NULL\_EQ\_NIL list
|- !l. NULL l = (l = [])
\ENDTHEOREM
\THEOREM NULL\_FOLDL list
|- !l. NULL l = FOLDL(\x l'. F)T l
\ENDTHEOREM
\THEOREM NULL\_FOLDR list
|- !l. NULL l = FOLDR(\x l'. F)T l
\ENDTHEOREM
\THEOREM OR\_EL\_DEF list
|- OR_EL = SOME_EL I
\ENDTHEOREM
\THEOREM OR\_EL\_FOLDL list
|- !l. OR_EL l = FOLDL $\/ F l
\ENDTHEOREM
\THEOREM OR\_EL\_FOLDR list
|- !l. OR_EL l = FOLDR $\/ F l
\ENDTHEOREM
\THEOREM PART ltree
|- (!l. PART[]l = []) /\
   (!n t l.
     PART(CONS n t)l = CONS(FST(SPLIT n l))(PART t(SND(SPLIT n l))))
\ENDTHEOREM
\THEOREM PREFIX\_DEF list
|- !P l. PREFIX P l = FST(SPLITP($~ o P)l)
\ENDTHEOREM
\THEOREM PREFIX list
|- (!P. PREFIX P[] = []) /\
   (!P x l. PREFIX P(CONS x l) = (P x => CONS x(PREFIX P l) | []))
\ENDTHEOREM
\THEOREM PREFIX\_FOLDR list
|- !P l. PREFIX P l = FOLDR(\x l'. (P x => CONS x l' | []))[]l
\ENDTHEOREM
\THEOREM REPLICATE list
|- (!x. REPLICATE 0 x = []) /\
   (!n x. REPLICATE(SUC n)x = CONS x(REPLICATE n x))
\ENDTHEOREM
\THEOREM REVERSE\_APPEND list
|- !l1 l2. REVERSE(APPEND l1 l2) = APPEND(REVERSE l2)(REVERSE l1)
\ENDTHEOREM
\THEOREM REVERSE list
|- (REVERSE[] = []) /\ (!x l. REVERSE(CONS x l) = SNOC x(REVERSE l))
\ENDTHEOREM
\THEOREM REVERSE\_EQ\_NIL list
|- !l. (REVERSE l = []) = (l = [])
\ENDTHEOREM
\THEOREM REVERSE\_FLAT list
|- !l. REVERSE(FLAT l) = FLAT(REVERSE(MAP REVERSE l))
\ENDTHEOREM
\THEOREM REVERSE\_FOLDL list
|- !l. REVERSE l = FOLDL(\l' x. CONS x l')[]l
\ENDTHEOREM
\THEOREM REVERSE\_FOLDR list
|- !l. REVERSE l = FOLDR SNOC[]l
\ENDTHEOREM
\THEOREM REVERSE\_REVERSE list
|- !l. REVERSE(REVERSE l) = l
\ENDTHEOREM
\THEOREM REVERSE\_SNOC list
|- !x l. REVERSE(SNOC x l) = CONS x(REVERSE l)
\ENDTHEOREM
\THEOREM SCANL list
|- (!f e. SCANL f e[] = [e]) /\
   (!f e x l. SCANL f e(CONS x l) = CONS e(SCANL f(f e x)l))
\ENDTHEOREM
\THEOREM SCANR list
|- (!f e. SCANR f e[] = [e]) /\
   (!f e x l.
     SCANR f e(CONS x l) = CONS(f x(HD(SCANR f e l)))(SCANR f e l))
\ENDTHEOREM
\THEOREM SEG\_0\_SNOC list
|- !m l x. m <= (LENGTH l) ==> (SEG m 0(SNOC x l) = SEG m 0 l)
\ENDTHEOREM
\THEOREM SEG\_APPEND1 list
|- !n m l1.
    (n + m) <= (LENGTH l1) ==> (!l2. SEG n m(APPEND l1 l2) = SEG n m l1)
\ENDTHEOREM
\THEOREM SEG\_APPEND2 list
|- !l1 m n l2.
    (LENGTH l1) <= m /\ n <= (LENGTH l2) ==>
    (SEG n m(APPEND l1 l2) = SEG n(m - (LENGTH l1))l2)
\ENDTHEOREM
\THEOREM SEG\_APPEND list
|- !m l1 n l2.
    m < (LENGTH l1) /\
    (LENGTH l1) <= (n + m) /\
    (n + m) <= ((LENGTH l1) + (LENGTH l2)) ==>
    (SEG n m(APPEND l1 l2) =
     APPEND(SEG((LENGTH l1) - m)m l1)(SEG((n + m) - (LENGTH l1))0 l2))
\ENDTHEOREM
\THEOREM SEG list
|- (!k l. SEG 0 k l = []) /\
   (!m x l. SEG(SUC m)0(CONS x l) = CONS x(SEG m 0 l)) /\
   (!m k x l. SEG(SUC m)(SUC k)(CONS x l) = SEG(SUC m)k l)
\ENDTHEOREM
\THEOREM SEG\_FIRSTN\_BUTFISTN list
|- !n m l.
    (n + m) <= (LENGTH l) ==> (SEG n m l = FIRSTN n(BUTFIRSTN m l))
\ENDTHEOREM
\THEOREM SEG\_LASTN\_BUTLASTN list
|- !n m l.
    (n + m) <= (LENGTH l) ==>
    (SEG n m l = LASTN n(BUTLASTN((LENGTH l) - (n + m))l))
\ENDTHEOREM
\THEOREM SEG\_LENGTH\_ID list
|- !l. SEG(LENGTH l)0 l = l
\ENDTHEOREM
\THEOREM SEG\_LENGTH\_SNOC list
|- !l x. SEG 1(LENGTH l)(SNOC x l) = [x]
\ENDTHEOREM
\THEOREM SEG\_REVERSE list
|- !n m l.
    (n + m) <= (LENGTH l) ==>
    (SEG n m(REVERSE l) = REVERSE(SEG n((LENGTH l) - (n + m))l))
\ENDTHEOREM
\THEOREM SEG\_SEG list
|- !n1 m1 n2 m2 l.
    (n1 + m1) <= (LENGTH l) /\ (n2 + m2) <= n1 ==>
    (SEG n2 m2(SEG n1 m1 l) = SEG n2(m1 + m2)l)
\ENDTHEOREM
\THEOREM SEG\_SNOC list
|- !n m l. (n + m) <= (LENGTH l) ==> (!x. SEG n m(SNOC x l) = SEG n m l)
\ENDTHEOREM
\THEOREM SEG\_SUC\_CONS list
|- !m n l x. SEG m(SUC n)(CONS x l) = SEG m n l
\ENDTHEOREM
\THEOREM SNOC\_11 list
|- !x l x' l'. (SNOC x l = SNOC x' l') = (x = x') /\ (l = l')
\ENDTHEOREM
\THEOREM SNOC\_APPEND list
|- !x l. SNOC x l = APPEND l[x]
\ENDTHEOREM
\THEOREM SNOC\_Axiom list
|- !e f. ?! fn. (fn[] = e) /\ (!x l. fn(SNOC x l) = f(fn l)x l)
\ENDTHEOREM
\THEOREM SNOC\_CASES list
|- !l. (l = []) \/ (?l' x. l = SNOC x l')
\ENDTHEOREM
\THEOREM SNOC list
|- (!x. SNOC x[] = [x]) /\
   (!x x' l. SNOC x(CONS x' l) = CONS x'(SNOC x l))
\ENDTHEOREM
\THEOREM SNOC\_EQ\_LENGTH\_EQ list
|- !x1 l1 x2 l2. (SNOC x1 l1 = SNOC x2 l2) ==> (LENGTH l1 = LENGTH l2)
\ENDTHEOREM
\THEOREM SNOC\_FOLDR list
|- !x l. SNOC x l = FOLDR CONS[x]l
\ENDTHEOREM
\THEOREM SNOC\_INDUCT list
|- !P. P[] /\ (!l. P l ==> (!x. P(SNOC x l))) ==> (!l. P l)
\ENDTHEOREM
\THEOREM SNOC\_REVERSE\_CONS list
|- !x l. SNOC x l = REVERSE(CONS x(REVERSE l))
\ENDTHEOREM
\THEOREM SOME\_EL\_APPEND list
|- !P l1 l2. SOME_EL P(APPEND l1 l2) = SOME_EL P l1 \/ SOME_EL P l2
\ENDTHEOREM
\THEOREM SOME\_EL\_BUTFIRSTN list
|- !m l.
    m <= (LENGTH l) ==> (!P. SOME_EL P(BUTFIRSTN m l) ==> SOME_EL P l)
\ENDTHEOREM
\THEOREM SOME\_EL\_BUTLASTN list
|- !m l.
    m <= (LENGTH l) ==> (!P. SOME_EL P(BUTLASTN m l) ==> SOME_EL P l)
\ENDTHEOREM
\THEOREM SOME\_EL\_DISJ list
|- !P Q l. SOME_EL(\x. P x \/ Q x)l = SOME_EL P l \/ SOME_EL Q l
\ENDTHEOREM
\THEOREM SOME\_EL list
|- (!P. SOME_EL P[] = F) /\
   (!P x l. SOME_EL P(CONS x l) = P x \/ SOME_EL P l)
\ENDTHEOREM
\THEOREM SOME\_EL\_FIRSTN list
|- !m l. m <= (LENGTH l) ==> (!P. SOME_EL P(FIRSTN m l) ==> SOME_EL P l)
\ENDTHEOREM
\THEOREM SOME\_EL\_FOLDL list
|- !P l. SOME_EL P l = FOLDL(\l' x. l' \/ P x)F l
\ENDTHEOREM
\THEOREM SOME\_EL\_FOLDL\_MAP list
|- !P l. SOME_EL P l = FOLDL $\/ F(MAP P l)
\ENDTHEOREM
\THEOREM SOME\_EL\_FOLDR list
|- !P l. SOME_EL P l = FOLDR(\x l'. P x \/ l')F l
\ENDTHEOREM
\THEOREM SOME\_EL\_FOLDR\_MAP list
|- !P l. SOME_EL P l = FOLDR $\/ F(MAP P l)
\ENDTHEOREM
\THEOREM SOME\_EL\_LASTN list
|- !m l. m <= (LENGTH l) ==> (!P. SOME_EL P(LASTN m l) ==> SOME_EL P l)
\ENDTHEOREM
\THEOREM SOME\_EL\_MAP list
|- !P f l. SOME_EL P(MAP f l) = SOME_EL(P o f)l
\ENDTHEOREM
\THEOREM SOME\_EL\_REVERSE list
|- !P l. SOME_EL P(REVERSE l) = SOME_EL P l
\ENDTHEOREM
\THEOREM SOME\_EL\_SEG list
|- !m k l.
    (m + k) <= (LENGTH l) ==> (!P. SOME_EL P(SEG m k l) ==> SOME_EL P l)
\ENDTHEOREM
\THEOREM SOME\_EL\_SNOC list
|- !P x l. SOME_EL P(SNOC x l) = P x \/ SOME_EL P l
\ENDTHEOREM
\THEOREM SPLIT ltree
|- (!l. SPLIT 0 l = [],l) /\
   (!n l.
     SPLIT(SUC n)l =
     CONS(HD l)(FST(SPLIT n(TL l))),SND(SPLIT n(TL l)))
\ENDTHEOREM

\THEOREM SPLITP list
|- (!P. SPLITP P[] = [],[]) /\
   (!P x l.
     SPLITP P(CONS x l) =
     (P x => ([],CONS x l) | (CONS x(FST(SPLITP P l)),SND(SPLITP P l))))
\ENDTHEOREM
\THEOREM SUFFIX\_DEF list
|- !P l. SUFFIX P l = FOLDL(\l' x. (P x => SNOC x l' | []))[]l
\ENDTHEOREM
\THEOREM SUM\_APPEND list
|- !l1 l2. SUM(APPEND l1 l2) = (SUM l1) + (SUM l2)
\ENDTHEOREM
\THEOREM SUM list
|- (SUM[] = 0) /\ (!h t. SUM(CONS h t) = h + (SUM t))
\ENDTHEOREM
\THEOREM SUM\_FLAT list
|- !l. SUM(FLAT l) = SUM(MAP SUM l)
\ENDTHEOREM
\THEOREM SUM\_FOLDL list
|- !l. SUM l = FOLDL $+ 0 l
\ENDTHEOREM
\THEOREM SUM\_FOLDR list
|- !l. SUM l = FOLDR $+ 0 l
\ENDTHEOREM
\THEOREM SUM\_REVERSE list
|- !l. SUM(REVERSE l) = SUM l
\ENDTHEOREM
\THEOREM SUM\_SNOC list
|- !x l. SUM(SNOC x l) = (SUM l) + x
\ENDTHEOREM
\THEOREM TL list
|- !h t. TL(CONS h t) = t
\ENDTHEOREM
\THEOREM TL\_SNOC list
|- !x l. TL(SNOC x l) = (NULL l => [] | SNOC x(TL l))
\ENDTHEOREM
\THEOREM UNZIP list
|- (UNZIP[] = [],[]) /\
   (!x l.
     UNZIP(CONS x l) =
     CONS(FST x)(FST(UNZIP l)),CONS(SND x)(SND(UNZIP l)))
\ENDTHEOREM
\THEOREM UNZIP\_FST\_DEF list
|- !l. UNZIP_FST l = FST(UNZIP l)
\ENDTHEOREM
\THEOREM UNZIP\_SND\_DEF list
|- !l. UNZIP_SND l = SND(UNZIP l)
\ENDTHEOREM
\THEOREM UNZIP\_SNOC list
|- !x l.
    UNZIP(SNOC x l) =
    SNOC(FST x)(FST(UNZIP l)),SNOC(SND x)(SND(UNZIP l))
\ENDTHEOREM
\THEOREM UNZIP\_ZIP list
|- !l1 l2. (LENGTH l1 = LENGTH l2) ==> (UNZIP(ZIP(l1,l2)) = l1,l2)
\ENDTHEOREM
\THEOREM ZIP list
|- (ZIP([],[]) = []) /\
   (!x1 l1 x2 l2. ZIP(CONS x1 l1,CONS x2 l2) = CONS(x1,x2)(ZIP(l1,l2)))
\ENDTHEOREM
\THEOREM ZIP\_SNOC list
|- !l1 l2.
    (LENGTH l1 = LENGTH l2) ==>
    (!x1 x2. ZIP(SNOC x1 l1,SNOC x2 l2) = SNOC(x1,x2)(ZIP(l1,l2)))
\ENDTHEOREM
\THEOREM ZIP\_UNZIP list
|- !l. ZIP(UNZIP l) = l
\ENDTHEOREM
\section{Theorems about trees}\THEOREM AP ltree
|- (!l. AP[]l = []) /\
   (!h t l. AP(CONS h t)l = CONS(h(HD l))(AP t(TL l)))
\ENDTHEOREM
\THEOREM bht tree
|- bht =
   PRIM_REC
   (\tr. tr = node[])
   (\res n tr. ?trl. (tr = node trl) /\ ALL_EL res trl)
\ENDTHEOREM
\THEOREM dest\_node tree
|- !t. dest_node t = (@p. t = node p)
\ENDTHEOREM
\THEOREM HT tree
|- !t. HT t = (@n. bht n t /\ (!m. m < n ==> ~bht m t))
\ENDTHEOREM
\THEOREM Is\_ltree ltree
|- !t l. Is_ltree(t,l) = (Size t = LENGTH l)
\ENDTHEOREM
\THEOREM Is\_tree\_REP tree
|- Is_tree_REP = (\t. !P. (!tl. ALL_EL P tl ==> P(node_REP tl)) ==> P t)
\ENDTHEOREM
\THEOREM ltree\_Axiom ltree
|- !f. ?! fn. !v tl. fn(Node v tl) = f(MAP fn tl)v tl
\ENDTHEOREM
\THEOREM ltree\_Induct ltree
|- !P. (!t. ALL_EL P t ==> (!h. P(Node h t))) ==> (!l. P l)
\ENDTHEOREM
\THEOREM ltree\_ISO\_DEF ltree
|- (!a. ABS_ltree(REP_ltree a) = a) /\
   (!r. Is_ltree r = (REP_ltree(ABS_ltree r) = r))
\ENDTHEOREM
\THEOREM ltree\_TY\_DEF ltree
|- ?rep. TYPE_DEFINITION Is_ltree rep
\ENDTHEOREM
\THEOREM node\_11 tree
|- !tl1 tl2. (node tl1 = node tl2) = (tl1 = tl2)
\ENDTHEOREM
\THEOREM Node\_11 ltree
|- !v1 v2 trl1 trl2.
    (Node v1 trl1 = Node v2 trl2) = (v1 = v2) /\ (trl1 = trl2)
\ENDTHEOREM
\THEOREM node tree
|- !tl. node tl = ABS_tree(node_REP(MAP REP_tree tl))
\ENDTHEOREM
\THEOREM Node ltree
|- !v tl.
    Node v tl =
    ABS_ltree
    (node(MAP(FST o REP_ltree)tl),CONS v(FLAT(MAP(SND o REP_ltree)tl)))
\ENDTHEOREM
\THEOREM Node\_onto ltree
|- !l. ?v trl. l = Node v trl
\ENDTHEOREM
\THEOREM node\_REP tree
|- (node_REP[] = 0) /\
   (!h t. node_REP(CONS h t) = (SUC(h + h)) * (2 EXP (node_REP t)))
\ENDTHEOREM
\THEOREM PART ltree
|- (!l. PART[]l = []) /\
   (!n t l.
     PART(CONS n t)l = CONS(FST(SPLIT n l))(PART t(SND(SPLIT n l))))
\ENDTHEOREM
\THEOREM Size ltree
|- Size = (@fn. !tl. fn(node tl) = SUC(SUM(MAP fn tl)))
\ENDTHEOREM
\THEOREM SPLIT ltree
|- (!l. SPLIT 0 l = [],l) /\
   (!n l.
     SPLIT(SUC n)l = CONS(HD l)(FST(SPLIT n(TL l))),SND(SPLIT n(TL l)))
\ENDTHEOREM
\THEOREM tree\_Axiom tree
|- !f. ?! fn. !tl. fn(node tl) = f(MAP fn tl)tl
\ENDTHEOREM
\THEOREM tree\_Induct tree
|- !P. (!tl. ALL_EL P tl ==> P(node tl)) ==> (!t. P t)
\ENDTHEOREM
\THEOREM tree\_ISO\_DEF tree
|- (!a. ABS_tree(REP_tree a) = a) /\
   (!r. Is_tree_REP r = (REP_tree(ABS_tree r) = r))
\ENDTHEOREM
\THEOREM tree\_TY\_DEF tree
|- ?rep. TYPE_DEFINITION Is_tree_REP rep
\ENDTHEOREM
\THEOREM trf tree
|- !n f.
    trf n f =
    (@fn. !trl. (HT(node trl)) <= n ==> (fn(node trl) = f(MAP fn trl)))
\ENDTHEOREM
\section{Theorems used to define types}\THEOREM ABS\_REP\_THM BASIC-HOL
|- !P.
    (?rep. TYPE_DEFINITION P rep) ==>
    (?rep abs. (!a. abs(rep a) = a) /\ (!r. P r = (rep(abs r) = r)))
\ENDTHEOREM
\THEOREM exists\_TRP tydefs
|- !P. (?v. P v[]) ==> (?t. TRP P t)
\ENDTHEOREM
\THEOREM TRP\_DEF tydefs
|- !P. TRP P = (@trp. !v tl. trp(Node v tl) = P v tl /\ ALL_EL trp tl)
\ENDTHEOREM
\THEOREM TRP tydefs
|- !P v tl. TRP P(Node v tl) = P v tl /\ ALL_EL(TRP P)tl
\ENDTHEOREM
\THEOREM TY\_DEF\_THM tydefs
|- !REP ABS P.
    (!a. ABS(REP a) = a) /\ (!r. TRP P r = (REP(ABS r) = r)) ==>
    (!f.
      ?! fn.
       !v tl.
        P v(MAP REP tl) ==>
        (fn(ABS(Node v(MAP REP tl))) = f(MAP fn tl)v tl))
\ENDTHEOREM
\THEOREM TYPE\_DEFINITION bool
|- !P rep.
    TYPE_DEFINITION P rep =
    (!x' x''. (rep x' = rep x'') ==> (x' = x'')) /\
    (!x. P x = (?x'. x = rep x'))
\ENDTHEOREM