aboutsummaryrefslogtreecommitdiffhomepage
path: root/theories/Ints/num/NMake.v
blob: dbc893c84bbea3b8c2351ca286f6fcfa6d2e4fd6 (plain)
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
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
Require Import ZArith.
Require Import Basic_type.
Require Import ZnZ.
Require Import Zn2Z.
Require Import Nbasic.
Require Import GenMul.
Require Import GenDivn1.



Fixpoint plength (p: positive) : positive :=
  match p with 
    xH => xH
  | xO p1 => Psucc (plength p1)
  | xI p1 => Psucc (plength p1)
  end.

Definition pheight p := plength (Ppred (plength (Ppred p))).

Module Type W0Type.
 Parameter w : Set.
 Parameter w_op : znz_op w.
 Parameter w_spec : znz_spec w_op.
End W0Type.

Module Make (W0:W0Type).
 Import W0.

 Definition w0 := W0.w.
 Definition w1 := zn2z w0.
 Definition w2 := zn2z w1.
 Definition w3 := zn2z w2.
 Definition w4 := zn2z w3.
 Definition w5 := zn2z w4.
 Definition w6 := zn2z w5.
 Definition w7 := zn2z w6.
 Definition w8 := zn2z w7.
 Definition w9 := zn2z w8.
 Definition w10 := zn2z w9.
 Definition w11 := zn2z w10.
 Definition w12 := zn2z w11.

 Definition w0_op := W0.w_op.
 Definition w1_op := mk_zn2z_op w0_op.
 Definition w2_op := mk_zn2z_op w1_op.
 Definition w3_op := mk_zn2z_op w2_op.
 Definition w4_op := mk_zn2z_op_karatsuba w3_op.
 Definition w5_op := mk_zn2z_op_karatsuba w4_op.
 Definition w6_op := mk_zn2z_op_karatsuba w5_op.
 Definition w7_op := mk_zn2z_op_karatsuba w6_op.
 Definition w8_op := mk_zn2z_op_karatsuba w7_op.
 Definition w9_op := mk_zn2z_op_karatsuba w8_op.
 Definition w10_op := mk_zn2z_op_karatsuba w9_op.
 Definition w11_op := mk_zn2z_op_karatsuba w10_op.
 Definition w12_op := mk_zn2z_op_karatsuba w11_op.
 Definition w13_op := mk_zn2z_op_karatsuba w12_op.
 Definition w14_op := mk_zn2z_op_karatsuba w13_op.
 Definition w15_op := mk_zn2z_op_karatsuba w14_op.

 Section Make_op.
  Variable mk : forall w', znz_op w' -> znz_op (zn2z w').

  Fixpoint make_op_aux (n:nat) : znz_op (word w12 (S n)):=
   match n return znz_op (word w12 (S n)) with
   | O => w13_op
   | S n1 =>
     match n1 return znz_op (word w12 (S (S n1))) with
     | O => w14_op
     | S n2 =>
       match n2 return znz_op (word w12 (S (S (S n2)))) with
       | O => w15_op
       | S n3 => mk _ (mk _ (mk _ (make_op_aux n3)))
       end
     end
   end.

 End Make_op.

 Definition make_op := make_op_aux mk_zn2z_op_karatsuba.

 Inductive t_ : Set :=
  | N0 : w0 -> t_
  | N1 : w1 -> t_
  | N2 : w2 -> t_
  | N3 : w3 -> t_
  | N4 : w4 -> t_
  | N5 : w5 -> t_
  | N6 : w6 -> t_
  | N7 : w7 -> t_
  | N8 : w8 -> t_
  | N9 : w9 -> t_
  | N10 : w10 -> t_
  | N11 : w11 -> t_
  | N12 : w12 -> t_
  | Nn : forall n, word w12 (S n) -> t_.

 Definition t := t_.

 Definition w_0 := w0_op.(znz_0).

 Definition one0 := w0_op.(znz_1).
 Definition one1 := w1_op.(znz_1).
 Definition one2 := w2_op.(znz_1).
 Definition one3 := w3_op.(znz_1).
 Definition one4 := w4_op.(znz_1).
 Definition one5 := w5_op.(znz_1).
 Definition one6 := w6_op.(znz_1).
 Definition one7 := w7_op.(znz_1).
 Definition one8 := w8_op.(znz_1).
 Definition one9 := w9_op.(znz_1).
 Definition one10 := w10_op.(znz_1).
 Definition one11 := w11_op.(znz_1).
 Definition one12 := w12_op.(znz_1).

 Definition zero := N0 w_0.
 Definition one := N0 one0.

 Definition w0_succ_c := w0_op.(znz_succ_c).
 Definition w1_succ_c := w1_op.(znz_succ_c).
 Definition w2_succ_c := w2_op.(znz_succ_c).
 Definition w3_succ_c := w3_op.(znz_succ_c).
 Definition w4_succ_c := w4_op.(znz_succ_c).
 Definition w5_succ_c := w5_op.(znz_succ_c).
 Definition w6_succ_c := w6_op.(znz_succ_c).
 Definition w7_succ_c := w7_op.(znz_succ_c).
 Definition w8_succ_c := w8_op.(znz_succ_c).
 Definition w9_succ_c := w9_op.(znz_succ_c).
 Definition w10_succ_c := w10_op.(znz_succ_c).
 Definition w11_succ_c := w11_op.(znz_succ_c).
 Definition w12_succ_c := w12_op.(znz_succ_c).

 Definition w0_succ := w0_op.(znz_succ).
 Definition w1_succ := w1_op.(znz_succ).
 Definition w2_succ := w2_op.(znz_succ).
 Definition w3_succ := w3_op.(znz_succ).
 Definition w4_succ := w4_op.(znz_succ).
 Definition w5_succ := w5_op.(znz_succ).
 Definition w6_succ := w6_op.(znz_succ).
 Definition w7_succ := w7_op.(znz_succ).
 Definition w8_succ := w8_op.(znz_succ).
 Definition w9_succ := w9_op.(znz_succ).
 Definition w10_succ := w10_op.(znz_succ).
 Definition w11_succ := w11_op.(znz_succ).
 Definition w12_succ := w12_op.(znz_succ).

 Definition succ x :=
  match x with
  | N0 wx =>
    match w0_succ_c wx with
    | C0 r => N0 r
    | C1 r => N1 (WW one0 r)
    end
  | N1 wx =>
    match w1_succ_c wx with
    | C0 r => N1 r
    | C1 r => N2 (WW one1 r)
    end
  | N2 wx =>
    match w2_succ_c wx with
    | C0 r => N2 r
    | C1 r => N3 (WW one2 r)
    end
  | N3 wx =>
    match w3_succ_c wx with
    | C0 r => N3 r
    | C1 r => N4 (WW one3 r)
    end
  | N4 wx =>
    match w4_succ_c wx with
    | C0 r => N4 r
    | C1 r => N5 (WW one4 r)
    end
  | N5 wx =>
    match w5_succ_c wx with
    | C0 r => N5 r
    | C1 r => N6 (WW one5 r)
    end
  | N6 wx =>
    match w6_succ_c wx with
    | C0 r => N6 r
    | C1 r => N7 (WW one6 r)
    end
  | N7 wx =>
    match w7_succ_c wx with
    | C0 r => N7 r
    | C1 r => N8 (WW one7 r)
    end
  | N8 wx =>
    match w8_succ_c wx with
    | C0 r => N8 r
    | C1 r => N9 (WW one8 r)
    end
  | N9 wx =>
    match w9_succ_c wx with
    | C0 r => N9 r
    | C1 r => N10 (WW one9 r)
    end
  | N10 wx =>
    match w10_succ_c wx with
    | C0 r => N10 r
    | C1 r => N11 (WW one10 r)
    end
  | N11 wx =>
    match w11_succ_c wx with
    | C0 r => N11 r
    | C1 r => N12 (WW one11 r)
    end
  | N12 wx =>
    match w12_succ_c wx with
    | C0 r => N12 r
    | C1 r => Nn 0 (WW one12 r)
    end
  | Nn n wx =>
    let op := make_op n in
    match op.(znz_succ_c) wx with
    | C0 r => Nn n r
    | C1 r => Nn (S n) (WW op.(znz_1) r)
    end
  end.

 Definition extend1 :=
  Eval lazy beta zeta iota delta [extend]in extend 1.
 Definition extend2 :=
  Eval lazy beta zeta iota delta [extend]in extend 2.
 Definition extend3 :=
  Eval lazy beta zeta iota delta [extend]in extend 3.
 Definition extend4 :=
  Eval lazy beta zeta iota delta [extend]in extend 4.
 Definition extend5 :=
  Eval lazy beta zeta iota delta [extend]in extend 5.
 Definition extend6 :=
  Eval lazy beta zeta iota delta [extend]in extend 6.
 Definition extend7 :=
  Eval lazy beta zeta iota delta [extend]in extend 7.
 Definition extend8 :=
  Eval lazy beta zeta iota delta [extend]in extend 8.
 Definition extend9 :=
  Eval lazy beta zeta iota delta [extend]in extend 9.
 Definition extend10 :=
  Eval lazy beta zeta iota delta [extend]in extend 10.
 Definition extend11 :=
  Eval lazy beta zeta iota delta [extend]in extend 11.
 Definition extend12 :=
  Eval lazy beta zeta iota delta [extend]in extend 12.

 Definition w0_eq0 := w0_op.(znz_eq0).
 Definition w1_eq0 := w1_op.(znz_eq0).
 Definition w2_eq0 := w2_op.(znz_eq0).
 Definition w3_eq0 := w3_op.(znz_eq0).
 Definition w4_eq0 := w4_op.(znz_eq0).
 Definition w5_eq0 := w5_op.(znz_eq0).
 Definition w6_eq0 := w6_op.(znz_eq0).
 Definition w7_eq0 := w7_op.(znz_eq0).
 Definition w8_eq0 := w8_op.(znz_eq0).
 Definition w9_eq0 := w9_op.(znz_eq0).
 Definition w10_eq0 := w10_op.(znz_eq0).
 Definition w11_eq0 := w11_op.(znz_eq0).
 Definition w12_eq0 := w12_op.(znz_eq0).


 Definition w0_add_c := w0_op.(znz_add_c).
 Definition w1_add_c := w1_op.(znz_add_c).
 Definition w2_add_c := w2_op.(znz_add_c).
 Definition w3_add_c := w3_op.(znz_add_c).
 Definition w4_add_c := w4_op.(znz_add_c).
 Definition w5_add_c := w5_op.(znz_add_c).
 Definition w6_add_c := w6_op.(znz_add_c).
 Definition w7_add_c := w7_op.(znz_add_c).
 Definition w8_add_c := w8_op.(znz_add_c).
 Definition w9_add_c := w9_op.(znz_add_c).
 Definition w10_add_c := w10_op.(znz_add_c).
 Definition w11_add_c := w11_op.(znz_add_c).
 Definition w12_add_c := w12_op.(znz_add_c).

 Definition w0_add x y :=
  match w0_add_c x y with
  | C0 r => N0 r
  | C1 r => N1 (WW one0 r)
  end.
 Definition w1_add x y :=
  match w1_add_c x y with
  | C0 r => N1 r
  | C1 r => N2 (WW one1 r)
  end.
 Definition w2_add x y :=
  match w2_add_c x y with
  | C0 r => N2 r
  | C1 r => N3 (WW one2 r)
  end.
 Definition w3_add x y :=
  match w3_add_c x y with
  | C0 r => N3 r
  | C1 r => N4 (WW one3 r)
  end.
 Definition w4_add x y :=
  match w4_add_c x y with
  | C0 r => N4 r
  | C1 r => N5 (WW one4 r)
  end.
 Definition w5_add x y :=
  match w5_add_c x y with
  | C0 r => N5 r
  | C1 r => N6 (WW one5 r)
  end.
 Definition w6_add x y :=
  match w6_add_c x y with
  | C0 r => N6 r
  | C1 r => N7 (WW one6 r)
  end.
 Definition w7_add x y :=
  match w7_add_c x y with
  | C0 r => N7 r
  | C1 r => N8 (WW one7 r)
  end.
 Definition w8_add x y :=
  match w8_add_c x y with
  | C0 r => N8 r
  | C1 r => N9 (WW one8 r)
  end.
 Definition w9_add x y :=
  match w9_add_c x y with
  | C0 r => N9 r
  | C1 r => N10 (WW one9 r)
  end.
 Definition w10_add x y :=
  match w10_add_c x y with
  | C0 r => N10 r
  | C1 r => N11 (WW one10 r)
  end.
 Definition w11_add x y :=
  match w11_add_c x y with
  | C0 r => N11 r
  | C1 r => N12 (WW one11 r)
  end.
 Definition w12_add x y :=
  match w12_add_c x y with
  | C0 r => N12 r
  | C1 r => Nn 0 (WW one12 r)
  end.
 Definition addn n (x y : word w12 (S n)) :=
  let op := make_op n in
  match op.(znz_add_c) x y with
  | C0 r => Nn n r
  | C1 r => Nn (S n) (WW op.(znz_1) r)  end.

 Definition add x y :=
  match x, y with
  | N0 wx, N0 wy => w0_add wx wy 
  | N0 wx, N1 wy =>
    if w0_eq0 wx then y else w1_add (WW w_0 wx) wy
  | N0 wx, N2 wy =>
    if w0_eq0 wx then y else w2_add (extend1 w0 (WW w_0 wx)) wy
  | N0 wx, N3 wy =>
    if w0_eq0 wx then y else w3_add (extend2 w0 (WW w_0 wx)) wy
  | N0 wx, N4 wy =>
    if w0_eq0 wx then y else w4_add (extend3 w0 (WW w_0 wx)) wy
  | N0 wx, N5 wy =>
    if w0_eq0 wx then y else w5_add (extend4 w0 (WW w_0 wx)) wy
  | N0 wx, N6 wy =>
    if w0_eq0 wx then y else w6_add (extend5 w0 (WW w_0 wx)) wy
  | N0 wx, N7 wy =>
    if w0_eq0 wx then y else w7_add (extend6 w0 (WW w_0 wx)) wy
  | N0 wx, N8 wy =>
    if w0_eq0 wx then y else w8_add (extend7 w0 (WW w_0 wx)) wy
  | N0 wx, N9 wy =>
    if w0_eq0 wx then y else w9_add (extend8 w0 (WW w_0 wx)) wy
  | N0 wx, N10 wy =>
    if w0_eq0 wx then y else w10_add (extend9 w0 (WW w_0 wx)) wy
  | N0 wx, N11 wy =>
    if w0_eq0 wx then y else w11_add (extend10 w0 (WW w_0 wx)) wy
  | N0 wx, N12 wy =>
    if w0_eq0 wx then y else w12_add (extend11 w0 (WW w_0 wx)) wy
  | N0 wx, Nn n wy =>
    if w0_eq0 wx then y
    else addn n (extend n w12 (extend12 w0 (WW w_0 wx))) wy
  | N1 wx, N0 wy =>
    if w0_eq0 wy then x else w1_add wx (WW w_0 wy)
  | N1 wx, N1 wy => w1_add wx wy
  | N1 wx, N2 wy => w2_add (extend1 w0 wx) wy
  | N1 wx, N3 wy => w3_add (extend2 w0 wx) wy
  | N1 wx, N4 wy => w4_add (extend3 w0 wx) wy
  | N1 wx, N5 wy => w5_add (extend4 w0 wx) wy
  | N1 wx, N6 wy => w6_add (extend5 w0 wx) wy
  | N1 wx, N7 wy => w7_add (extend6 w0 wx) wy
  | N1 wx, N8 wy => w8_add (extend7 w0 wx) wy
  | N1 wx, N9 wy => w9_add (extend8 w0 wx) wy
  | N1 wx, N10 wy => w10_add (extend9 w0 wx) wy
  | N1 wx, N11 wy => w11_add (extend10 w0 wx) wy
  | N1 wx, N12 wy => w12_add (extend11 w0 wx) wy
  | N1 wx, Nn n wy => addn n (extend n w12 (extend12 w0 wx)) wy
  | N2 wx, N0 wy =>
    if w0_eq0 wy then x else w2_add wx (extend1 w0 (WW w_0 wy))
  | N2 wx, N1 wy => w2_add wx (extend1 w0 wy)
  | N2 wx, N2 wy => w2_add wx wy
  | N2 wx, N3 wy => w3_add (extend1 w1 wx) wy
  | N2 wx, N4 wy => w4_add (extend2 w1 wx) wy
  | N2 wx, N5 wy => w5_add (extend3 w1 wx) wy
  | N2 wx, N6 wy => w6_add (extend4 w1 wx) wy
  | N2 wx, N7 wy => w7_add (extend5 w1 wx) wy
  | N2 wx, N8 wy => w8_add (extend6 w1 wx) wy
  | N2 wx, N9 wy => w9_add (extend7 w1 wx) wy
  | N2 wx, N10 wy => w10_add (extend8 w1 wx) wy
  | N2 wx, N11 wy => w11_add (extend9 w1 wx) wy
  | N2 wx, N12 wy => w12_add (extend10 w1 wx) wy
  | N2 wx, Nn n wy => addn n (extend n w12 (extend11 w1 wx)) wy
  | N3 wx, N0 wy =>
    if w0_eq0 wy then x else w3_add wx (extend2 w0 (WW w_0 wy))
  | N3 wx, N1 wy => w3_add wx (extend2 w0 wy)
  | N3 wx, N2 wy => w3_add wx (extend1 w1 wy)
  | N3 wx, N3 wy => w3_add wx wy
  | N3 wx, N4 wy => w4_add (extend1 w2 wx) wy
  | N3 wx, N5 wy => w5_add (extend2 w2 wx) wy
  | N3 wx, N6 wy => w6_add (extend3 w2 wx) wy
  | N3 wx, N7 wy => w7_add (extend4 w2 wx) wy
  | N3 wx, N8 wy => w8_add (extend5 w2 wx) wy
  | N3 wx, N9 wy => w9_add (extend6 w2 wx) wy
  | N3 wx, N10 wy => w10_add (extend7 w2 wx) wy
  | N3 wx, N11 wy => w11_add (extend8 w2 wx) wy
  | N3 wx, N12 wy => w12_add (extend9 w2 wx) wy
  | N3 wx, Nn n wy => addn n (extend n w12 (extend10 w2 wx)) wy
  | N4 wx, N0 wy =>
    if w0_eq0 wy then x else w4_add wx (extend3 w0 (WW w_0 wy))
  | N4 wx, N1 wy => w4_add wx (extend3 w0 wy)
  | N4 wx, N2 wy => w4_add wx (extend2 w1 wy)
  | N4 wx, N3 wy => w4_add wx (extend1 w2 wy)
  | N4 wx, N4 wy => w4_add wx wy
  | N4 wx, N5 wy => w5_add (extend1 w3 wx) wy
  | N4 wx, N6 wy => w6_add (extend2 w3 wx) wy
  | N4 wx, N7 wy => w7_add (extend3 w3 wx) wy
  | N4 wx, N8 wy => w8_add (extend4 w3 wx) wy
  | N4 wx, N9 wy => w9_add (extend5 w3 wx) wy
  | N4 wx, N10 wy => w10_add (extend6 w3 wx) wy
  | N4 wx, N11 wy => w11_add (extend7 w3 wx) wy
  | N4 wx, N12 wy => w12_add (extend8 w3 wx) wy
  | N4 wx, Nn n wy => addn n (extend n w12 (extend9 w3 wx)) wy
  | N5 wx, N0 wy =>
    if w0_eq0 wy then x else w5_add wx (extend4 w0 (WW w_0 wy))
  | N5 wx, N1 wy => w5_add wx (extend4 w0 wy)
  | N5 wx, N2 wy => w5_add wx (extend3 w1 wy)
  | N5 wx, N3 wy => w5_add wx (extend2 w2 wy)
  | N5 wx, N4 wy => w5_add wx (extend1 w3 wy)
  | N5 wx, N5 wy => w5_add wx wy
  | N5 wx, N6 wy => w6_add (extend1 w4 wx) wy
  | N5 wx, N7 wy => w7_add (extend2 w4 wx) wy
  | N5 wx, N8 wy => w8_add (extend3 w4 wx) wy
  | N5 wx, N9 wy => w9_add (extend4 w4 wx) wy
  | N5 wx, N10 wy => w10_add (extend5 w4 wx) wy
  | N5 wx, N11 wy => w11_add (extend6 w4 wx) wy
  | N5 wx, N12 wy => w12_add (extend7 w4 wx) wy
  | N5 wx, Nn n wy => addn n (extend n w12 (extend8 w4 wx)) wy
  | N6 wx, N0 wy =>
    if w0_eq0 wy then x else w6_add wx (extend5 w0 (WW w_0 wy))
  | N6 wx, N1 wy => w6_add wx (extend5 w0 wy)
  | N6 wx, N2 wy => w6_add wx (extend4 w1 wy)
  | N6 wx, N3 wy => w6_add wx (extend3 w2 wy)
  | N6 wx, N4 wy => w6_add wx (extend2 w3 wy)
  | N6 wx, N5 wy => w6_add wx (extend1 w4 wy)
  | N6 wx, N6 wy => w6_add wx wy
  | N6 wx, N7 wy => w7_add (extend1 w5 wx) wy
  | N6 wx, N8 wy => w8_add (extend2 w5 wx) wy
  | N6 wx, N9 wy => w9_add (extend3 w5 wx) wy
  | N6 wx, N10 wy => w10_add (extend4 w5 wx) wy
  | N6 wx, N11 wy => w11_add (extend5 w5 wx) wy
  | N6 wx, N12 wy => w12_add (extend6 w5 wx) wy
  | N6 wx, Nn n wy => addn n (extend n w12 (extend7 w5 wx)) wy
  | N7 wx, N0 wy =>
    if w0_eq0 wy then x else w7_add wx (extend6 w0 (WW w_0 wy))
  | N7 wx, N1 wy => w7_add wx (extend6 w0 wy)
  | N7 wx, N2 wy => w7_add wx (extend5 w1 wy)
  | N7 wx, N3 wy => w7_add wx (extend4 w2 wy)
  | N7 wx, N4 wy => w7_add wx (extend3 w3 wy)
  | N7 wx, N5 wy => w7_add wx (extend2 w4 wy)
  | N7 wx, N6 wy => w7_add wx (extend1 w5 wy)
  | N7 wx, N7 wy => w7_add wx wy
  | N7 wx, N8 wy => w8_add (extend1 w6 wx) wy
  | N7 wx, N9 wy => w9_add (extend2 w6 wx) wy
  | N7 wx, N10 wy => w10_add (extend3 w6 wx) wy
  | N7 wx, N11 wy => w11_add (extend4 w6 wx) wy
  | N7 wx, N12 wy => w12_add (extend5 w6 wx) wy
  | N7 wx, Nn n wy => addn n (extend n w12 (extend6 w6 wx)) wy
  | N8 wx, N0 wy =>
    if w0_eq0 wy then x else w8_add wx (extend7 w0 (WW w_0 wy))
  | N8 wx, N1 wy => w8_add wx (extend7 w0 wy)
  | N8 wx, N2 wy => w8_add wx (extend6 w1 wy)
  | N8 wx, N3 wy => w8_add wx (extend5 w2 wy)
  | N8 wx, N4 wy => w8_add wx (extend4 w3 wy)
  | N8 wx, N5 wy => w8_add wx (extend3 w4 wy)
  | N8 wx, N6 wy => w8_add wx (extend2 w5 wy)
  | N8 wx, N7 wy => w8_add wx (extend1 w6 wy)
  | N8 wx, N8 wy => w8_add wx wy
  | N8 wx, N9 wy => w9_add (extend1 w7 wx) wy
  | N8 wx, N10 wy => w10_add (extend2 w7 wx) wy
  | N8 wx, N11 wy => w11_add (extend3 w7 wx) wy
  | N8 wx, N12 wy => w12_add (extend4 w7 wx) wy
  | N8 wx, Nn n wy => addn n (extend n w12 (extend5 w7 wx)) wy
  | N9 wx, N0 wy =>
    if w0_eq0 wy then x else w9_add wx (extend8 w0 (WW w_0 wy))
  | N9 wx, N1 wy => w9_add wx (extend8 w0 wy)
  | N9 wx, N2 wy => w9_add wx (extend7 w1 wy)
  | N9 wx, N3 wy => w9_add wx (extend6 w2 wy)
  | N9 wx, N4 wy => w9_add wx (extend5 w3 wy)
  | N9 wx, N5 wy => w9_add wx (extend4 w4 wy)
  | N9 wx, N6 wy => w9_add wx (extend3 w5 wy)
  | N9 wx, N7 wy => w9_add wx (extend2 w6 wy)
  | N9 wx, N8 wy => w9_add wx (extend1 w7 wy)
  | N9 wx, N9 wy => w9_add wx wy
  | N9 wx, N10 wy => w10_add (extend1 w8 wx) wy
  | N9 wx, N11 wy => w11_add (extend2 w8 wx) wy
  | N9 wx, N12 wy => w12_add (extend3 w8 wx) wy
  | N9 wx, Nn n wy => addn n (extend n w12 (extend4 w8 wx)) wy
  | N10 wx, N0 wy =>
    if w0_eq0 wy then x else w10_add wx (extend9 w0 (WW w_0 wy))
  | N10 wx, N1 wy => w10_add wx (extend9 w0 wy)
  | N10 wx, N2 wy => w10_add wx (extend8 w1 wy)
  | N10 wx, N3 wy => w10_add wx (extend7 w2 wy)
  | N10 wx, N4 wy => w10_add wx (extend6 w3 wy)
  | N10 wx, N5 wy => w10_add wx (extend5 w4 wy)
  | N10 wx, N6 wy => w10_add wx (extend4 w5 wy)
  | N10 wx, N7 wy => w10_add wx (extend3 w6 wy)
  | N10 wx, N8 wy => w10_add wx (extend2 w7 wy)
  | N10 wx, N9 wy => w10_add wx (extend1 w8 wy)
  | N10 wx, N10 wy => w10_add wx wy
  | N10 wx, N11 wy => w11_add (extend1 w9 wx) wy
  | N10 wx, N12 wy => w12_add (extend2 w9 wx) wy
  | N10 wx, Nn n wy => addn n (extend n w12 (extend3 w9 wx)) wy
  | N11 wx, N0 wy =>
    if w0_eq0 wy then x else w11_add wx (extend10 w0 (WW w_0 wy))
  | N11 wx, N1 wy => w11_add wx (extend10 w0 wy)
  | N11 wx, N2 wy => w11_add wx (extend9 w1 wy)
  | N11 wx, N3 wy => w11_add wx (extend8 w2 wy)
  | N11 wx, N4 wy => w11_add wx (extend7 w3 wy)
  | N11 wx, N5 wy => w11_add wx (extend6 w4 wy)
  | N11 wx, N6 wy => w11_add wx (extend5 w5 wy)
  | N11 wx, N7 wy => w11_add wx (extend4 w6 wy)
  | N11 wx, N8 wy => w11_add wx (extend3 w7 wy)
  | N11 wx, N9 wy => w11_add wx (extend2 w8 wy)
  | N11 wx, N10 wy => w11_add wx (extend1 w9 wy)
  | N11 wx, N11 wy => w11_add wx wy
  | N11 wx, N12 wy => w12_add (extend1 w10 wx) wy
  | N11 wx, Nn n wy => addn n (extend n w12 (extend2 w10 wx)) wy
  | N12 wx, N0 wy =>
    if w0_eq0 wy then x else w12_add wx (extend11 w0 (WW w_0 wy))
  | N12 wx, N1 wy => w12_add wx (extend11 w0 wy)
  | N12 wx, N2 wy => w12_add wx (extend10 w1 wy)
  | N12 wx, N3 wy => w12_add wx (extend9 w2 wy)
  | N12 wx, N4 wy => w12_add wx (extend8 w3 wy)
  | N12 wx, N5 wy => w12_add wx (extend7 w4 wy)
  | N12 wx, N6 wy => w12_add wx (extend6 w5 wy)
  | N12 wx, N7 wy => w12_add wx (extend5 w6 wy)
  | N12 wx, N8 wy => w12_add wx (extend4 w7 wy)
  | N12 wx, N9 wy => w12_add wx (extend3 w8 wy)
  | N12 wx, N10 wy => w12_add wx (extend2 w9 wy)
  | N12 wx, N11 wy => w12_add wx (extend1 w10 wy)
  | N12 wx, N12 wy => w12_add wx wy
  | N12 wx, Nn n wy => addn n (extend n w12 (extend1 w11 wx)) wy
  | Nn n wx, N0 wy =>
    if w0_eq0 wy then x
    else addn n wx (extend n w12 (extend12 w0 (WW w_0 wy)))
  | Nn n wx, N1 wy => addn n wx (extend n w12 (extend12 w0 wy))
  | Nn n wx, N2 wy => addn n wx (extend n w12 (extend11 w1 wy))
  | Nn n wx, N3 wy => addn n wx (extend n w12 (extend10 w2 wy))
  | Nn n wx, N4 wy => addn n wx (extend n w12 (extend9 w3 wy))
  | Nn n wx, N5 wy => addn n wx (extend n w12 (extend8 w4 wy))
  | Nn n wx, N6 wy => addn n wx (extend n w12 (extend7 w5 wy))
  | Nn n wx, N7 wy => addn n wx (extend n w12 (extend6 w6 wy))
  | Nn n wx, N8 wy => addn n wx (extend n w12 (extend5 w7 wy))
  | Nn n wx, N9 wy => addn n wx (extend n w12 (extend4 w8 wy))
  | Nn n wx, N10 wy => addn n wx (extend n w12 (extend3 w9 wy))
  | Nn n wx, N11 wy => addn n wx (extend n w12 (extend2 w10 wy))
  | Nn n wx, N12 wy => addn n wx (extend n w12 (extend1 w11 wy))
  | Nn n wx, Nn m wy =>
    match extend_to_max w12 n m wx wy with
    | inl wx' => addn m wx' wy
    | inr wy' => addn n wx wy'
    end
  end.

 Definition reduce_0 (x:w) := N0 x.
 Definition reduce_1 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w0_eq0 N0 N1.
 Definition reduce_2 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w1_eq0 reduce_1 N2.
 Definition reduce_3 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w2_eq0 reduce_2 N3.
 Definition reduce_4 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w3_eq0 reduce_3 N4.
 Definition reduce_5 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w4_eq0 reduce_4 N5.
 Definition reduce_6 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w5_eq0 reduce_5 N6.
 Definition reduce_7 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w6_eq0 reduce_6 N7.
 Definition reduce_8 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w7_eq0 reduce_7 N8.
 Definition reduce_9 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w8_eq0 reduce_8 N9.
 Definition reduce_10 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w9_eq0 reduce_9 N10.
 Definition reduce_11 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w10_eq0 reduce_10 N11.
 Definition reduce_12 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w11_eq0 reduce_11 N12.
 Definition reduce_13 :=
  Eval lazy beta iota delta[reduce_n1] in
   reduce_n1 _ _ zero w12_eq0 reduce_12 (Nn 0).
 Definition reduce_n n := 
  Eval lazy beta iota delta[reduce_n] in
   reduce_n _ _ zero reduce_13 Nn n.

 Definition w0_pred_c := w0_op.(znz_pred_c).
 Definition w1_pred_c := w1_op.(znz_pred_c).
 Definition w2_pred_c := w2_op.(znz_pred_c).
 Definition w3_pred_c := w3_op.(znz_pred_c).
 Definition w4_pred_c := w4_op.(znz_pred_c).
 Definition w5_pred_c := w5_op.(znz_pred_c).
 Definition w6_pred_c := w6_op.(znz_pred_c).
 Definition w7_pred_c := w7_op.(znz_pred_c).
 Definition w8_pred_c := w8_op.(znz_pred_c).
 Definition w9_pred_c := w9_op.(znz_pred_c).
 Definition w10_pred_c := w10_op.(znz_pred_c).
 Definition w11_pred_c := w11_op.(znz_pred_c).
 Definition w12_pred_c := w12_op.(znz_pred_c).

 Definition pred x :=
  match x with
  | N0 wx =>
    match w0_pred_c wx with
    | C0 r => reduce_0 r
    | C1 r => zero
    end
  | N1 wx =>
    match w1_pred_c wx with
    | C0 r => reduce_1 r
    | C1 r => zero
    end
  | N2 wx =>
    match w2_pred_c wx with
    | C0 r => reduce_2 r
    | C1 r => zero
    end
  | N3 wx =>
    match w3_pred_c wx with
    | C0 r => reduce_3 r
    | C1 r => zero
    end
  | N4 wx =>
    match w4_pred_c wx with
    | C0 r => reduce_4 r
    | C1 r => zero
    end
  | N5 wx =>
    match w5_pred_c wx with
    | C0 r => reduce_5 r
    | C1 r => zero
    end
  | N6 wx =>
    match w6_pred_c wx with
    | C0 r => reduce_6 r
    | C1 r => zero
    end
  | N7 wx =>
    match w7_pred_c wx with
    | C0 r => reduce_7 r
    | C1 r => zero
    end
  | N8 wx =>
    match w8_pred_c wx with
    | C0 r => reduce_8 r
    | C1 r => zero
    end
  | N9 wx =>
    match w9_pred_c wx with
    | C0 r => reduce_9 r
    | C1 r => zero
    end
  | N10 wx =>
    match w10_pred_c wx with
    | C0 r => reduce_10 r
    | C1 r => zero
    end
  | N11 wx =>
    match w11_pred_c wx with
    | C0 r => reduce_11 r
    | C1 r => zero
    end
  | N12 wx =>
    match w12_pred_c wx with
    | C0 r => reduce_12 r
    | C1 r => zero
    end
  | Nn n wx =>
    let op := make_op n in
    match op.(znz_pred_c) wx with
    | C0 r => reduce_n n r
    | C1 r => zero
    end
  end.


 Definition w0_sub_c := w0_op.(znz_sub_c).
 Definition w1_sub_c := w1_op.(znz_sub_c).
 Definition w2_sub_c := w2_op.(znz_sub_c).
 Definition w3_sub_c := w3_op.(znz_sub_c).
 Definition w4_sub_c := w4_op.(znz_sub_c).
 Definition w5_sub_c := w5_op.(znz_sub_c).
 Definition w6_sub_c := w6_op.(znz_sub_c).
 Definition w7_sub_c := w7_op.(znz_sub_c).
 Definition w8_sub_c := w8_op.(znz_sub_c).
 Definition w9_sub_c := w9_op.(znz_sub_c).
 Definition w10_sub_c := w10_op.(znz_sub_c).
 Definition w11_sub_c := w11_op.(znz_sub_c).
 Definition w12_sub_c := w12_op.(znz_sub_c).

 Definition w0_sub x y :=
  match w0_sub_c x y with
  | C0 r => reduce_0 r
  | C1 r => zero
  end.
 Definition w1_sub x y :=
  match w1_sub_c x y with
  | C0 r => reduce_1 r
  | C1 r => zero
  end.
 Definition w2_sub x y :=
  match w2_sub_c x y with
  | C0 r => reduce_2 r
  | C1 r => zero
  end.
 Definition w3_sub x y :=
  match w3_sub_c x y with
  | C0 r => reduce_3 r
  | C1 r => zero
  end.
 Definition w4_sub x y :=
  match w4_sub_c x y with
  | C0 r => reduce_4 r
  | C1 r => zero
  end.
 Definition w5_sub x y :=
  match w5_sub_c x y with
  | C0 r => reduce_5 r
  | C1 r => zero
  end.
 Definition w6_sub x y :=
  match w6_sub_c x y with
  | C0 r => reduce_6 r
  | C1 r => zero
  end.
 Definition w7_sub x y :=
  match w7_sub_c x y with
  | C0 r => reduce_7 r
  | C1 r => zero
  end.
 Definition w8_sub x y :=
  match w8_sub_c x y with
  | C0 r => reduce_8 r
  | C1 r => zero
  end.
 Definition w9_sub x y :=
  match w9_sub_c x y with
  | C0 r => reduce_9 r
  | C1 r => zero
  end.
 Definition w10_sub x y :=
  match w10_sub_c x y with
  | C0 r => reduce_10 r
  | C1 r => zero
  end.
 Definition w11_sub x y :=
  match w11_sub_c x y with
  | C0 r => reduce_11 r
  | C1 r => zero
  end.
 Definition w12_sub x y :=
  match w12_sub_c x y with
  | C0 r => reduce_12 r
  | C1 r => zero
  end.

 Definition subn n (x y : word w12 (S n)) :=
  let op := make_op n in
  match op.(znz_sub_c) x y with
  | C0 r => Nn n r
  | C1 r => Nn (S n) (WW op.(znz_1) r)  end.

 Definition sub x y :=
  match x, y with
  | N0 wx, N0 wy => w0_sub wx wy 
  | N0 wx, N1 wy =>
    if w0_eq0 wx then zero else w1_sub (WW w_0 wx) wy
  | N0 wx, N2 wy =>
    if w0_eq0 wx then zero else w2_sub (extend1 w0 (WW w_0 wx)) wy
  | N0 wx, N3 wy =>
    if w0_eq0 wx then zero else w3_sub (extend2 w0 (WW w_0 wx)) wy
  | N0 wx, N4 wy =>
    if w0_eq0 wx then zero else w4_sub (extend3 w0 (WW w_0 wx)) wy
  | N0 wx, N5 wy =>
    if w0_eq0 wx then zero else w5_sub (extend4 w0 (WW w_0 wx)) wy
  | N0 wx, N6 wy =>
    if w0_eq0 wx then zero else w6_sub (extend5 w0 (WW w_0 wx)) wy
  | N0 wx, N7 wy =>
    if w0_eq0 wx then zero else w7_sub (extend6 w0 (WW w_0 wx)) wy
  | N0 wx, N8 wy =>
    if w0_eq0 wx then zero else w8_sub (extend7 w0 (WW w_0 wx)) wy
  | N0 wx, N9 wy =>
    if w0_eq0 wx then zero else w9_sub (extend8 w0 (WW w_0 wx)) wy
  | N0 wx, N10 wy =>
    if w0_eq0 wx then zero else w10_sub (extend9 w0 (WW w_0 wx)) wy
  | N0 wx, N11 wy =>
    if w0_eq0 wx then zero else w11_sub (extend10 w0 (WW w_0 wx)) wy
  | N0 wx, N12 wy =>
    if w0_eq0 wx then zero else w12_sub (extend11 w0 (WW w_0 wx)) wy
  | N0 wx, Nn n wy =>
    if w0_eq0 wx then zero
    else subn n (extend n w12 (extend12 w0 (WW w_0 wx))) wy
  | N1 wx, N0 wy =>
    if w0_eq0 wy then x
    else w1_sub wx (WW w_0 wy)
  | N1 wx, N1 wy => w1_sub wx wy
  | N1 wx, N2 wy => w2_sub (extend1 w0 wx) wy
  | N1 wx, N3 wy => w3_sub (extend2 w0 wx) wy
  | N1 wx, N4 wy => w4_sub (extend3 w0 wx) wy
  | N1 wx, N5 wy => w5_sub (extend4 w0 wx) wy
  | N1 wx, N6 wy => w6_sub (extend5 w0 wx) wy
  | N1 wx, N7 wy => w7_sub (extend6 w0 wx) wy
  | N1 wx, N8 wy => w8_sub (extend7 w0 wx) wy
  | N1 wx, N9 wy => w9_sub (extend8 w0 wx) wy
  | N1 wx, N10 wy => w10_sub (extend9 w0 wx) wy
  | N1 wx, N11 wy => w11_sub (extend10 w0 wx) wy
  | N1 wx, N12 wy => w12_sub (extend11 w0 wx) wy
  | N1 wx, Nn n wy => subn n (extend n w12 (extend12 w0 wx)) wy
  | N2 wx, N0 wy =>
    if w0_eq0 wy then x
    else w2_sub wx (extend1 w0 (WW w_0 wy))
  | N2 wx, N1 wy => w2_sub wx (extend1 w0 wy)
  | N2 wx, N2 wy => w2_sub wx wy
  | N2 wx, N3 wy => w3_sub (extend1 w1 wx) wy
  | N2 wx, N4 wy => w4_sub (extend2 w1 wx) wy
  | N2 wx, N5 wy => w5_sub (extend3 w1 wx) wy
  | N2 wx, N6 wy => w6_sub (extend4 w1 wx) wy
  | N2 wx, N7 wy => w7_sub (extend5 w1 wx) wy
  | N2 wx, N8 wy => w8_sub (extend6 w1 wx) wy
  | N2 wx, N9 wy => w9_sub (extend7 w1 wx) wy
  | N2 wx, N10 wy => w10_sub (extend8 w1 wx) wy
  | N2 wx, N11 wy => w11_sub (extend9 w1 wx) wy
  | N2 wx, N12 wy => w12_sub (extend10 w1 wx) wy
  | N2 wx, Nn n wy => subn n (extend n w12 (extend11 w1 wx)) wy
  | N3 wx, N0 wy =>
    if w0_eq0 wy then x
    else w3_sub wx (extend2 w0 (WW w_0 wy))
  | N3 wx, N1 wy => w3_sub wx (extend2 w0 wy)
  | N3 wx, N2 wy => w3_sub wx (extend1 w1 wy)
  | N3 wx, N3 wy => w3_sub wx wy
  | N3 wx, N4 wy => w4_sub (extend1 w2 wx) wy
  | N3 wx, N5 wy => w5_sub (extend2 w2 wx) wy
  | N3 wx, N6 wy => w6_sub (extend3 w2 wx) wy
  | N3 wx, N7 wy => w7_sub (extend4 w2 wx) wy
  | N3 wx, N8 wy => w8_sub (extend5 w2 wx) wy
  | N3 wx, N9 wy => w9_sub (extend6 w2 wx) wy
  | N3 wx, N10 wy => w10_sub (extend7 w2 wx) wy
  | N3 wx, N11 wy => w11_sub (extend8 w2 wx) wy
  | N3 wx, N12 wy => w12_sub (extend9 w2 wx) wy
  | N3 wx, Nn n wy => subn n (extend n w12 (extend10 w2 wx)) wy
  | N4 wx, N0 wy =>
    if w0_eq0 wy then x
    else w4_sub wx (extend3 w0 (WW w_0 wy))
  | N4 wx, N1 wy => w4_sub wx (extend3 w0 wy)
  | N4 wx, N2 wy => w4_sub wx (extend2 w1 wy)
  | N4 wx, N3 wy => w4_sub wx (extend1 w2 wy)
  | N4 wx, N4 wy => w4_sub wx wy
  | N4 wx, N5 wy => w5_sub (extend1 w3 wx) wy
  | N4 wx, N6 wy => w6_sub (extend2 w3 wx) wy
  | N4 wx, N7 wy => w7_sub (extend3 w3 wx) wy
  | N4 wx, N8 wy => w8_sub (extend4 w3 wx) wy
  | N4 wx, N9 wy => w9_sub (extend5 w3 wx) wy
  | N4 wx, N10 wy => w10_sub (extend6 w3 wx) wy
  | N4 wx, N11 wy => w11_sub (extend7 w3 wx) wy
  | N4 wx, N12 wy => w12_sub (extend8 w3 wx) wy
  | N4 wx, Nn n wy => subn n (extend n w12 (extend9 w3 wx)) wy
  | N5 wx, N0 wy =>
    if w0_eq0 wy then x
    else w5_sub wx (extend4 w0 (WW w_0 wy))
  | N5 wx, N1 wy => w5_sub wx (extend4 w0 wy)
  | N5 wx, N2 wy => w5_sub wx (extend3 w1 wy)
  | N5 wx, N3 wy => w5_sub wx (extend2 w2 wy)
  | N5 wx, N4 wy => w5_sub wx (extend1 w3 wy)
  | N5 wx, N5 wy => w5_sub wx wy
  | N5 wx, N6 wy => w6_sub (extend1 w4 wx) wy
  | N5 wx, N7 wy => w7_sub (extend2 w4 wx) wy
  | N5 wx, N8 wy => w8_sub (extend3 w4 wx) wy
  | N5 wx, N9 wy => w9_sub (extend4 w4 wx) wy
  | N5 wx, N10 wy => w10_sub (extend5 w4 wx) wy
  | N5 wx, N11 wy => w11_sub (extend6 w4 wx) wy
  | N5 wx, N12 wy => w12_sub (extend7 w4 wx) wy
  | N5 wx, Nn n wy => subn n (extend n w12 (extend8 w4 wx)) wy
  | N6 wx, N0 wy =>
    if w0_eq0 wy then x
    else w6_sub wx (extend5 w0 (WW w_0 wy))
  | N6 wx, N1 wy => w6_sub wx (extend5 w0 wy)
  | N6 wx, N2 wy => w6_sub wx (extend4 w1 wy)
  | N6 wx, N3 wy => w6_sub wx (extend3 w2 wy)
  | N6 wx, N4 wy => w6_sub wx (extend2 w3 wy)
  | N6 wx, N5 wy => w6_sub wx (extend1 w4 wy)
  | N6 wx, N6 wy => w6_sub wx wy
  | N6 wx, N7 wy => w7_sub (extend1 w5 wx) wy
  | N6 wx, N8 wy => w8_sub (extend2 w5 wx) wy
  | N6 wx, N9 wy => w9_sub (extend3 w5 wx) wy
  | N6 wx, N10 wy => w10_sub (extend4 w5 wx) wy
  | N6 wx, N11 wy => w11_sub (extend5 w5 wx) wy
  | N6 wx, N12 wy => w12_sub (extend6 w5 wx) wy
  | N6 wx, Nn n wy => subn n (extend n w12 (extend7 w5 wx)) wy
  | N7 wx, N0 wy =>
    if w0_eq0 wy then x
    else w7_sub wx (extend6 w0 (WW w_0 wy))
  | N7 wx, N1 wy => w7_sub wx (extend6 w0 wy)
  | N7 wx, N2 wy => w7_sub wx (extend5 w1 wy)
  | N7 wx, N3 wy => w7_sub wx (extend4 w2 wy)
  | N7 wx, N4 wy => w7_sub wx (extend3 w3 wy)
  | N7 wx, N5 wy => w7_sub wx (extend2 w4 wy)
  | N7 wx, N6 wy => w7_sub wx (extend1 w5 wy)
  | N7 wx, N7 wy => w7_sub wx wy
  | N7 wx, N8 wy => w8_sub (extend1 w6 wx) wy
  | N7 wx, N9 wy => w9_sub (extend2 w6 wx) wy
  | N7 wx, N10 wy => w10_sub (extend3 w6 wx) wy
  | N7 wx, N11 wy => w11_sub (extend4 w6 wx) wy
  | N7 wx, N12 wy => w12_sub (extend5 w6 wx) wy
  | N7 wx, Nn n wy => subn n (extend n w12 (extend6 w6 wx)) wy
  | N8 wx, N0 wy =>
    if w0_eq0 wy then x
    else w8_sub wx (extend7 w0 (WW w_0 wy))
  | N8 wx, N1 wy => w8_sub wx (extend7 w0 wy)
  | N8 wx, N2 wy => w8_sub wx (extend6 w1 wy)
  | N8 wx, N3 wy => w8_sub wx (extend5 w2 wy)
  | N8 wx, N4 wy => w8_sub wx (extend4 w3 wy)
  | N8 wx, N5 wy => w8_sub wx (extend3 w4 wy)
  | N8 wx, N6 wy => w8_sub wx (extend2 w5 wy)
  | N8 wx, N7 wy => w8_sub wx (extend1 w6 wy)
  | N8 wx, N8 wy => w8_sub wx wy
  | N8 wx, N9 wy => w9_sub (extend1 w7 wx) wy
  | N8 wx, N10 wy => w10_sub (extend2 w7 wx) wy
  | N8 wx, N11 wy => w11_sub (extend3 w7 wx) wy
  | N8 wx, N12 wy => w12_sub (extend4 w7 wx) wy
  | N8 wx, Nn n wy => subn n (extend n w12 (extend5 w7 wx)) wy
  | N9 wx, N0 wy =>
    if w0_eq0 wy then x
    else w9_sub wx (extend8 w0 (WW w_0 wy))
  | N9 wx, N1 wy => w9_sub wx (extend8 w0 wy)
  | N9 wx, N2 wy => w9_sub wx (extend7 w1 wy)
  | N9 wx, N3 wy => w9_sub wx (extend6 w2 wy)
  | N9 wx, N4 wy => w9_sub wx (extend5 w3 wy)
  | N9 wx, N5 wy => w9_sub wx (extend4 w4 wy)
  | N9 wx, N6 wy => w9_sub wx (extend3 w5 wy)
  | N9 wx, N7 wy => w9_sub wx (extend2 w6 wy)
  | N9 wx, N8 wy => w9_sub wx (extend1 w7 wy)
  | N9 wx, N9 wy => w9_sub wx wy
  | N9 wx, N10 wy => w10_sub (extend1 w8 wx) wy
  | N9 wx, N11 wy => w11_sub (extend2 w8 wx) wy
  | N9 wx, N12 wy => w12_sub (extend3 w8 wx) wy
  | N9 wx, Nn n wy => subn n (extend n w12 (extend4 w8 wx)) wy
  | N10 wx, N0 wy =>
    if w0_eq0 wy then x
    else w10_sub wx (extend9 w0 (WW w_0 wy))
  | N10 wx, N1 wy => w10_sub wx (extend9 w0 wy)
  | N10 wx, N2 wy => w10_sub wx (extend8 w1 wy)
  | N10 wx, N3 wy => w10_sub wx (extend7 w2 wy)
  | N10 wx, N4 wy => w10_sub wx (extend6 w3 wy)
  | N10 wx, N5 wy => w10_sub wx (extend5 w4 wy)
  | N10 wx, N6 wy => w10_sub wx (extend4 w5 wy)
  | N10 wx, N7 wy => w10_sub wx (extend3 w6 wy)
  | N10 wx, N8 wy => w10_sub wx (extend2 w7 wy)
  | N10 wx, N9 wy => w10_sub wx (extend1 w8 wy)
  | N10 wx, N10 wy => w10_sub wx wy
  | N10 wx, N11 wy => w11_sub (extend1 w9 wx) wy
  | N10 wx, N12 wy => w12_sub (extend2 w9 wx) wy
  | N10 wx, Nn n wy => subn n (extend n w12 (extend3 w9 wx)) wy
  | N11 wx, N0 wy =>
    if w0_eq0 wy then x
    else w11_sub wx (extend10 w0 (WW w_0 wy))
  | N11 wx, N1 wy => w11_sub wx (extend10 w0 wy)
  | N11 wx, N2 wy => w11_sub wx (extend9 w1 wy)
  | N11 wx, N3 wy => w11_sub wx (extend8 w2 wy)
  | N11 wx, N4 wy => w11_sub wx (extend7 w3 wy)
  | N11 wx, N5 wy => w11_sub wx (extend6 w4 wy)
  | N11 wx, N6 wy => w11_sub wx (extend5 w5 wy)
  | N11 wx, N7 wy => w11_sub wx (extend4 w6 wy)
  | N11 wx, N8 wy => w11_sub wx (extend3 w7 wy)
  | N11 wx, N9 wy => w11_sub wx (extend2 w8 wy)
  | N11 wx, N10 wy => w11_sub wx (extend1 w9 wy)
  | N11 wx, N11 wy => w11_sub wx wy
  | N11 wx, N12 wy => w12_sub (extend1 w10 wx) wy
  | N11 wx, Nn n wy => subn n (extend n w12 (extend2 w10 wx)) wy
  | N12 wx, N0 wy =>
    if w0_eq0 wy then x
    else w12_sub wx (extend11 w0 (WW w_0 wy))
  | N12 wx, N1 wy => w12_sub wx (extend11 w0 wy)
  | N12 wx, N2 wy => w12_sub wx (extend10 w1 wy)
  | N12 wx, N3 wy => w12_sub wx (extend9 w2 wy)
  | N12 wx, N4 wy => w12_sub wx (extend8 w3 wy)
  | N12 wx, N5 wy => w12_sub wx (extend7 w4 wy)
  | N12 wx, N6 wy => w12_sub wx (extend6 w5 wy)
  | N12 wx, N7 wy => w12_sub wx (extend5 w6 wy)
  | N12 wx, N8 wy => w12_sub wx (extend4 w7 wy)
  | N12 wx, N9 wy => w12_sub wx (extend3 w8 wy)
  | N12 wx, N10 wy => w12_sub wx (extend2 w9 wy)
  | N12 wx, N11 wy => w12_sub wx (extend1 w10 wy)
  | N12 wx, N12 wy => w12_sub wx wy
  | N12 wx, Nn n wy => subn n (extend n w12 (extend1 w11 wx)) wy
  | Nn n wx, N0 wy =>
    if w0_eq0 wy then x
    else subn n wx (extend n w12 (extend12 w0 (WW w_0 wy)))
  | Nn n wx, N1 wy => subn n wx (extend n w12 (extend12 w0 wy))
  | Nn n wx, N2 wy => subn n wx (extend n w12 (extend11 w1 wy))
  | Nn n wx, N3 wy => subn n wx (extend n w12 (extend10 w2 wy))
  | Nn n wx, N4 wy => subn n wx (extend n w12 (extend9 w3 wy))
  | Nn n wx, N5 wy => subn n wx (extend n w12 (extend8 w4 wy))
  | Nn n wx, N6 wy => subn n wx (extend n w12 (extend7 w5 wy))
  | Nn n wx, N7 wy => subn n wx (extend n w12 (extend6 w6 wy))
  | Nn n wx, N8 wy => subn n wx (extend n w12 (extend5 w7 wy))
  | Nn n wx, N9 wy => subn n wx (extend n w12 (extend4 w8 wy))
  | Nn n wx, N10 wy => subn n wx (extend n w12 (extend3 w9 wy))
  | Nn n wx, N11 wy => subn n wx (extend n w12 (extend2 w10 wy))
  | Nn n wx, N12 wy => subn n wx (extend n w12 (extend1 w11 wy))
  | Nn n wx, Nn m wy =>
    match extend_to_max w12 n m wx wy with
    | inl wx' => subn m wx' wy
    | inr wy' => subn n wx wy'
    end
  end.

 Definition compare_0 := w0_op.(znz_compare).
 Definition comparen_0 :=
  compare_mn_1 w0 w0 w_0 compare_0 (compare_0 w_0) compare_0.
 Definition compare_1 := w1_op.(znz_compare).
 Definition comparen_1 :=
  compare_mn_1 w1 w1 W0 compare_1 (compare_1 W0) compare_1.
 Definition compare_2 := w2_op.(znz_compare).
 Definition comparen_2 :=
  compare_mn_1 w2 w2 W0 compare_2 (compare_2 W0) compare_2.
 Definition compare_3 := w3_op.(znz_compare).
 Definition comparen_3 :=
  compare_mn_1 w3 w3 W0 compare_3 (compare_3 W0) compare_3.
 Definition compare_4 := w4_op.(znz_compare).
 Definition comparen_4 :=
  compare_mn_1 w4 w4 W0 compare_4 (compare_4 W0) compare_4.
 Definition compare_5 := w5_op.(znz_compare).
 Definition comparen_5 :=
  compare_mn_1 w5 w5 W0 compare_5 (compare_5 W0) compare_5.
 Definition compare_6 := w6_op.(znz_compare).
 Definition comparen_6 :=
  compare_mn_1 w6 w6 W0 compare_6 (compare_6 W0) compare_6.
 Definition compare_7 := w7_op.(znz_compare).
 Definition comparen_7 :=
  compare_mn_1 w7 w7 W0 compare_7 (compare_7 W0) compare_7.
 Definition compare_8 := w8_op.(znz_compare).
 Definition comparen_8 :=
  compare_mn_1 w8 w8 W0 compare_8 (compare_8 W0) compare_8.
 Definition compare_9 := w9_op.(znz_compare).
 Definition comparen_9 :=
  compare_mn_1 w9 w9 W0 compare_9 (compare_9 W0) compare_9.
 Definition compare_10 := w10_op.(znz_compare).
 Definition comparen_10 :=
  compare_mn_1 w10 w10 W0 compare_10 (compare_10 W0) compare_10.
 Definition compare_11 := w11_op.(znz_compare).
 Definition comparen_11 :=
  compare_mn_1 w11 w11 W0 compare_11 (compare_11 W0) compare_11.
 Definition compare_12 := w12_op.(znz_compare).
 Definition comparen_12 :=
  compare_mn_1 w12 w12 W0 compare_12 (compare_12 W0) compare_12.

 Definition compare x y :=
  match x, y with
  | N0 wx, N0 wy => compare_0 wx wy
  | N0 wx, N1 wy => opp_compare (comparen_0 1 wy wx)
  | N0 wx, N2 wy => opp_compare (comparen_0 2 wy wx)
  | N0 wx, N3 wy => opp_compare (comparen_0 3 wy wx)
  | N0 wx, N4 wy => opp_compare (comparen_0 4 wy wx)
  | N0 wx, N5 wy => opp_compare (comparen_0 5 wy wx)
  | N0 wx, N6 wy => opp_compare (comparen_0 6 wy wx)
  | N0 wx, N7 wy => opp_compare (comparen_0 7 wy wx)
  | N0 wx, N8 wy => opp_compare (comparen_0 8 wy wx)
  | N0 wx, N9 wy => opp_compare (comparen_0 9 wy wx)
  | N0 wx, N10 wy => opp_compare (comparen_0 10 wy wx)
  | N0 wx, N11 wy => opp_compare (comparen_0 11 wy wx)
  | N0 wx, N12 wy => opp_compare (comparen_0 12 wy wx)
  | N0 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w0 w_0 compare_0 (compare_12 W0) (comparen_0 12) (S n) wy wx)
  | N1 wx, N0 wy => comparen_0 1 wx wy
  | N1 wx, N1 wy => compare_1 wx wy
  | N1 wx, N2 wy => opp_compare (comparen_1 1 wy wx)
  | N1 wx, N3 wy => opp_compare (comparen_1 2 wy wx)
  | N1 wx, N4 wy => opp_compare (comparen_1 3 wy wx)
  | N1 wx, N5 wy => opp_compare (comparen_1 4 wy wx)
  | N1 wx, N6 wy => opp_compare (comparen_1 5 wy wx)
  | N1 wx, N7 wy => opp_compare (comparen_1 6 wy wx)
  | N1 wx, N8 wy => opp_compare (comparen_1 7 wy wx)
  | N1 wx, N9 wy => opp_compare (comparen_1 8 wy wx)
  | N1 wx, N10 wy => opp_compare (comparen_1 9 wy wx)
  | N1 wx, N11 wy => opp_compare (comparen_1 10 wy wx)
  | N1 wx, N12 wy => opp_compare (comparen_1 11 wy wx)
  | N1 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w1 W0 compare_1 (compare_12 W0) (comparen_1 11) (S n) wy wx)
  | N2 wx, N0 wy => comparen_0 2 wx wy
  | N2 wx, N1 wy => comparen_1 1 wx wy
  | N2 wx, N2 wy => compare_2 wx wy
  | N2 wx, N3 wy => opp_compare (comparen_2 1 wy wx)
  | N2 wx, N4 wy => opp_compare (comparen_2 2 wy wx)
  | N2 wx, N5 wy => opp_compare (comparen_2 3 wy wx)
  | N2 wx, N6 wy => opp_compare (comparen_2 4 wy wx)
  | N2 wx, N7 wy => opp_compare (comparen_2 5 wy wx)
  | N2 wx, N8 wy => opp_compare (comparen_2 6 wy wx)
  | N2 wx, N9 wy => opp_compare (comparen_2 7 wy wx)
  | N2 wx, N10 wy => opp_compare (comparen_2 8 wy wx)
  | N2 wx, N11 wy => opp_compare (comparen_2 9 wy wx)
  | N2 wx, N12 wy => opp_compare (comparen_2 10 wy wx)
  | N2 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w2 W0 compare_2 (compare_12 W0) (comparen_2 10) (S n) wy wx)
  | N3 wx, N0 wy => comparen_0 3 wx wy
  | N3 wx, N1 wy => comparen_1 2 wx wy
  | N3 wx, N2 wy => comparen_2 1 wx wy
  | N3 wx, N3 wy => compare_3 wx wy
  | N3 wx, N4 wy => opp_compare (comparen_3 1 wy wx)
  | N3 wx, N5 wy => opp_compare (comparen_3 2 wy wx)
  | N3 wx, N6 wy => opp_compare (comparen_3 3 wy wx)
  | N3 wx, N7 wy => opp_compare (comparen_3 4 wy wx)
  | N3 wx, N8 wy => opp_compare (comparen_3 5 wy wx)
  | N3 wx, N9 wy => opp_compare (comparen_3 6 wy wx)
  | N3 wx, N10 wy => opp_compare (comparen_3 7 wy wx)
  | N3 wx, N11 wy => opp_compare (comparen_3 8 wy wx)
  | N3 wx, N12 wy => opp_compare (comparen_3 9 wy wx)
  | N3 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w3 W0 compare_3 (compare_12 W0) (comparen_3 9) (S n) wy wx)
  | N4 wx, N0 wy => comparen_0 4 wx wy
  | N4 wx, N1 wy => comparen_1 3 wx wy
  | N4 wx, N2 wy => comparen_2 2 wx wy
  | N4 wx, N3 wy => comparen_3 1 wx wy
  | N4 wx, N4 wy => compare_4 wx wy
  | N4 wx, N5 wy => opp_compare (comparen_4 1 wy wx)
  | N4 wx, N6 wy => opp_compare (comparen_4 2 wy wx)
  | N4 wx, N7 wy => opp_compare (comparen_4 3 wy wx)
  | N4 wx, N8 wy => opp_compare (comparen_4 4 wy wx)
  | N4 wx, N9 wy => opp_compare (comparen_4 5 wy wx)
  | N4 wx, N10 wy => opp_compare (comparen_4 6 wy wx)
  | N4 wx, N11 wy => opp_compare (comparen_4 7 wy wx)
  | N4 wx, N12 wy => opp_compare (comparen_4 8 wy wx)
  | N4 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w4 W0 compare_4 (compare_12 W0) (comparen_4 8) (S n) wy wx)
  | N5 wx, N0 wy => comparen_0 5 wx wy
  | N5 wx, N1 wy => comparen_1 4 wx wy
  | N5 wx, N2 wy => comparen_2 3 wx wy
  | N5 wx, N3 wy => comparen_3 2 wx wy
  | N5 wx, N4 wy => comparen_4 1 wx wy
  | N5 wx, N5 wy => compare_5 wx wy
  | N5 wx, N6 wy => opp_compare (comparen_5 1 wy wx)
  | N5 wx, N7 wy => opp_compare (comparen_5 2 wy wx)
  | N5 wx, N8 wy => opp_compare (comparen_5 3 wy wx)
  | N5 wx, N9 wy => opp_compare (comparen_5 4 wy wx)
  | N5 wx, N10 wy => opp_compare (comparen_5 5 wy wx)
  | N5 wx, N11 wy => opp_compare (comparen_5 6 wy wx)
  | N5 wx, N12 wy => opp_compare (comparen_5 7 wy wx)
  | N5 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w5 W0 compare_5 (compare_12 W0) (comparen_5 7) (S n) wy wx)
  | N6 wx, N0 wy => comparen_0 6 wx wy
  | N6 wx, N1 wy => comparen_1 5 wx wy
  | N6 wx, N2 wy => comparen_2 4 wx wy
  | N6 wx, N3 wy => comparen_3 3 wx wy
  | N6 wx, N4 wy => comparen_4 2 wx wy
  | N6 wx, N5 wy => comparen_5 1 wx wy
  | N6 wx, N6 wy => compare_6 wx wy
  | N6 wx, N7 wy => opp_compare (comparen_6 1 wy wx)
  | N6 wx, N8 wy => opp_compare (comparen_6 2 wy wx)
  | N6 wx, N9 wy => opp_compare (comparen_6 3 wy wx)
  | N6 wx, N10 wy => opp_compare (comparen_6 4 wy wx)
  | N6 wx, N11 wy => opp_compare (comparen_6 5 wy wx)
  | N6 wx, N12 wy => opp_compare (comparen_6 6 wy wx)
  | N6 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w6 W0 compare_6 (compare_12 W0) (comparen_6 6) (S n) wy wx)
  | N7 wx, N0 wy => comparen_0 7 wx wy
  | N7 wx, N1 wy => comparen_1 6 wx wy
  | N7 wx, N2 wy => comparen_2 5 wx wy
  | N7 wx, N3 wy => comparen_3 4 wx wy
  | N7 wx, N4 wy => comparen_4 3 wx wy
  | N7 wx, N5 wy => comparen_5 2 wx wy
  | N7 wx, N6 wy => comparen_6 1 wx wy
  | N7 wx, N7 wy => compare_7 wx wy
  | N7 wx, N8 wy => opp_compare (comparen_7 1 wy wx)
  | N7 wx, N9 wy => opp_compare (comparen_7 2 wy wx)
  | N7 wx, N10 wy => opp_compare (comparen_7 3 wy wx)
  | N7 wx, N11 wy => opp_compare (comparen_7 4 wy wx)
  | N7 wx, N12 wy => opp_compare (comparen_7 5 wy wx)
  | N7 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w7 W0 compare_7 (compare_12 W0) (comparen_7 5) (S n) wy wx)
  | N8 wx, N0 wy => comparen_0 8 wx wy
  | N8 wx, N1 wy => comparen_1 7 wx wy
  | N8 wx, N2 wy => comparen_2 6 wx wy
  | N8 wx, N3 wy => comparen_3 5 wx wy
  | N8 wx, N4 wy => comparen_4 4 wx wy
  | N8 wx, N5 wy => comparen_5 3 wx wy
  | N8 wx, N6 wy => comparen_6 2 wx wy
  | N8 wx, N7 wy => comparen_7 1 wx wy
  | N8 wx, N8 wy => compare_8 wx wy
  | N8 wx, N9 wy => opp_compare (comparen_8 1 wy wx)
  | N8 wx, N10 wy => opp_compare (comparen_8 2 wy wx)
  | N8 wx, N11 wy => opp_compare (comparen_8 3 wy wx)
  | N8 wx, N12 wy => opp_compare (comparen_8 4 wy wx)
  | N8 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w8 W0 compare_8 (compare_12 W0) (comparen_8 4) (S n) wy wx)
  | N9 wx, N0 wy => comparen_0 9 wx wy
  | N9 wx, N1 wy => comparen_1 8 wx wy
  | N9 wx, N2 wy => comparen_2 7 wx wy
  | N9 wx, N3 wy => comparen_3 6 wx wy
  | N9 wx, N4 wy => comparen_4 5 wx wy
  | N9 wx, N5 wy => comparen_5 4 wx wy
  | N9 wx, N6 wy => comparen_6 3 wx wy
  | N9 wx, N7 wy => comparen_7 2 wx wy
  | N9 wx, N8 wy => comparen_8 1 wx wy
  | N9 wx, N9 wy => compare_9 wx wy
  | N9 wx, N10 wy => opp_compare (comparen_9 1 wy wx)
  | N9 wx, N11 wy => opp_compare (comparen_9 2 wy wx)
  | N9 wx, N12 wy => opp_compare (comparen_9 3 wy wx)
  | N9 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w9 W0 compare_9 (compare_12 W0) (comparen_9 3) (S n) wy wx)
  | N10 wx, N0 wy => comparen_0 10 wx wy
  | N10 wx, N1 wy => comparen_1 9 wx wy
  | N10 wx, N2 wy => comparen_2 8 wx wy
  | N10 wx, N3 wy => comparen_3 7 wx wy
  | N10 wx, N4 wy => comparen_4 6 wx wy
  | N10 wx, N5 wy => comparen_5 5 wx wy
  | N10 wx, N6 wy => comparen_6 4 wx wy
  | N10 wx, N7 wy => comparen_7 3 wx wy
  | N10 wx, N8 wy => comparen_8 2 wx wy
  | N10 wx, N9 wy => comparen_9 1 wx wy
  | N10 wx, N10 wy => compare_10 wx wy
  | N10 wx, N11 wy => opp_compare (comparen_10 1 wy wx)
  | N10 wx, N12 wy => opp_compare (comparen_10 2 wy wx)
  | N10 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w10 W0 compare_10 (compare_12 W0) (comparen_10 2) (S n) wy wx)
  | N11 wx, N0 wy => comparen_0 11 wx wy
  | N11 wx, N1 wy => comparen_1 10 wx wy
  | N11 wx, N2 wy => comparen_2 9 wx wy
  | N11 wx, N3 wy => comparen_3 8 wx wy
  | N11 wx, N4 wy => comparen_4 7 wx wy
  | N11 wx, N5 wy => comparen_5 6 wx wy
  | N11 wx, N6 wy => comparen_6 5 wx wy
  | N11 wx, N7 wy => comparen_7 4 wx wy
  | N11 wx, N8 wy => comparen_8 3 wx wy
  | N11 wx, N9 wy => comparen_9 2 wx wy
  | N11 wx, N10 wy => comparen_10 1 wx wy
  | N11 wx, N11 wy => compare_11 wx wy
  | N11 wx, N12 wy => opp_compare (comparen_11 1 wy wx)
  | N11 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w11 W0 compare_11 (compare_12 W0) (comparen_11 1) (S n) wy wx)
  | N12 wx, N0 wy => comparen_0 12 wx wy
  | N12 wx, N1 wy => comparen_1 11 wx wy
  | N12 wx, N2 wy => comparen_2 10 wx wy
  | N12 wx, N3 wy => comparen_3 9 wx wy
  | N12 wx, N4 wy => comparen_4 8 wx wy
  | N12 wx, N5 wy => comparen_5 7 wx wy
  | N12 wx, N6 wy => comparen_6 6 wx wy
  | N12 wx, N7 wy => comparen_7 5 wx wy
  | N12 wx, N8 wy => comparen_8 4 wx wy
  | N12 wx, N9 wy => comparen_9 3 wx wy
  | N12 wx, N10 wy => comparen_10 2 wx wy
  | N12 wx, N11 wy => comparen_11 1 wx wy
  | N12 wx, N12 wy => compare_12 wx wy
  | N12 wx, Nn n wy =>
    opp_compare (compare_mn_1 w12 w12 W0 compare_12 (compare_12 W0) (comparen_12 0) (S n) wy wx)
  | Nn n wx, N0 wy =>
    compare_mn_1 w12 w0 w_0 compare_0 (compare_12 W0) (comparen_0 12) (S n) wx wy
  | Nn n wx, N1 wy =>
    compare_mn_1 w12 w1 W0 compare_1 (compare_12 W0) (comparen_1 11) (S n) wx wy
  | Nn n wx, N2 wy =>
    compare_mn_1 w12 w2 W0 compare_2 (compare_12 W0) (comparen_2 10) (S n) wx wy
  | Nn n wx, N3 wy =>
    compare_mn_1 w12 w3 W0 compare_3 (compare_12 W0) (comparen_3 9) (S n) wx wy
  | Nn n wx, N4 wy =>
    compare_mn_1 w12 w4 W0 compare_4 (compare_12 W0) (comparen_4 8) (S n) wx wy
  | Nn n wx, N5 wy =>
    compare_mn_1 w12 w5 W0 compare_5 (compare_12 W0) (comparen_5 7) (S n) wx wy
  | Nn n wx, N6 wy =>
    compare_mn_1 w12 w6 W0 compare_6 (compare_12 W0) (comparen_6 6) (S n) wx wy
  | Nn n wx, N7 wy =>
    compare_mn_1 w12 w7 W0 compare_7 (compare_12 W0) (comparen_7 5) (S n) wx wy
  | Nn n wx, N8 wy =>
    compare_mn_1 w12 w8 W0 compare_8 (compare_12 W0) (comparen_8 4) (S n) wx wy
  | Nn n wx, N9 wy =>
    compare_mn_1 w12 w9 W0 compare_9 (compare_12 W0) (comparen_9 3) (S n) wx wy
  | Nn n wx, N10 wy =>
    compare_mn_1 w12 w10 W0 compare_10 (compare_12 W0) (comparen_10 2) (S n) wx wy
  | Nn n wx, N11 wy =>
    compare_mn_1 w12 w11 W0 compare_11 (compare_12 W0) (comparen_11 1) (S n) wx wy
  | Nn n wx, N12 wy =>
    compare_mn_1 w12 w12 W0 compare_12 (compare_12 W0) (comparen_12 0) (S n) wx wy
  | Nn n wx, Nn m wy =>
    match extend_to_max w12 n m wx wy with
    | inl wx' => let op := make_op m in op.(znz_compare) wx' wy 
    | inr wy' => let op := make_op n in op.(znz_compare) wx wy' 
    end
  end.

 Definition eq_bool x y :=
  match compare x y with
  | Eq => true
  | _  => false
  end.

 Definition w0_mul_c := w0_op.(znz_mul_c).
 Definition w1_mul_c := w1_op.(znz_mul_c).
 Definition w2_mul_c := w2_op.(znz_mul_c).
 Definition w3_mul_c := w3_op.(znz_mul_c).
 Definition w4_mul_c := w4_op.(znz_mul_c).
 Definition w5_mul_c := w5_op.(znz_mul_c).
 Definition w6_mul_c := w6_op.(znz_mul_c).
 Definition w7_mul_c := w7_op.(znz_mul_c).
 Definition w8_mul_c := w8_op.(znz_mul_c).
 Definition w9_mul_c := w9_op.(znz_mul_c).
 Definition w10_mul_c := w10_op.(znz_mul_c).
 Definition w11_mul_c := w11_op.(znz_mul_c).
 Definition w12_mul_c := w12_op.(znz_mul_c).

 Definition w0_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w0 w_0 w0_succ w0_add_c w0_mul_c.
 Definition w1_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w1 W0 w1_succ w1_add_c w1_mul_c.
 Definition w2_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w2 W0 w2_succ w2_add_c w2_mul_c.
 Definition w3_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w3 W0 w3_succ w3_add_c w3_mul_c.
 Definition w4_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w4 W0 w4_succ w4_add_c w4_mul_c.
 Definition w5_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w5 W0 w5_succ w5_add_c w5_mul_c.
 Definition w6_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w6 W0 w6_succ w6_add_c w6_mul_c.
 Definition w7_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w7 W0 w7_succ w7_add_c w7_mul_c.
 Definition w8_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w8 W0 w8_succ w8_add_c w8_mul_c.
 Definition w9_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w9 W0 w9_succ w9_add_c w9_mul_c.
 Definition w10_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w10 W0 w10_succ w10_add_c w10_mul_c.
 Definition w11_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w11 W0 w11_succ w11_add_c w11_mul_c.
 Definition w12_mul_add :=
   Eval lazy beta delta [w_mul_add] in
     @w_mul_add w12 W0 w12_succ w12_add_c w12_mul_c.

 Definition w0_mul_add_n1 :=
  @gen_mul_add_n1 w0 w_0 w0_op.(znz_WW) w0_op.(znz_0W) w0_mul_add.
 Definition w1_mul_add_n1 :=
  @gen_mul_add_n1 w1 W0 w1_op.(znz_WW) w1_op.(znz_0W) w1_mul_add.
 Definition w2_mul_add_n1 :=
  @gen_mul_add_n1 w2 W0 w2_op.(znz_WW) w2_op.(znz_0W) w2_mul_add.
 Definition w3_mul_add_n1 :=
  @gen_mul_add_n1 w3 W0 w3_op.(znz_WW) w3_op.(znz_0W) w3_mul_add.
 Definition w4_mul_add_n1 :=
  @gen_mul_add_n1 w4 W0 w4_op.(znz_WW) w4_op.(znz_0W) w4_mul_add.
 Definition w5_mul_add_n1 :=
  @gen_mul_add_n1 w5 W0 w5_op.(znz_WW) w5_op.(znz_0W) w5_mul_add.
 Definition w6_mul_add_n1 :=
  @gen_mul_add_n1 w6 W0 w6_op.(znz_WW) w6_op.(znz_0W) w6_mul_add.
 Definition w7_mul_add_n1 :=
  @gen_mul_add_n1 w7 W0 w7_op.(znz_WW) w7_op.(znz_0W) w7_mul_add.
 Definition w8_mul_add_n1 :=
  @gen_mul_add_n1 w8 W0 w8_op.(znz_WW) w8_op.(znz_0W) w8_mul_add.
 Definition w9_mul_add_n1 :=
  @gen_mul_add_n1 w9 W0 w9_op.(znz_WW) w9_op.(znz_0W) w9_mul_add.
 Definition w10_mul_add_n1 :=
  @gen_mul_add_n1 w10 W0 w10_op.(znz_WW) w10_op.(znz_0W) w10_mul_add.
 Definition w11_mul_add_n1 :=
  @gen_mul_add_n1 w11 W0 w11_op.(znz_WW) w11_op.(znz_0W) w11_mul_add.
 Definition w12_mul_add_n1 :=
  @gen_mul_add_n1 w12 W0 w12_op.(znz_WW) w12_op.(znz_0W) w12_mul_add.

 Definition mul x y :=
  match x, y with
  | N0 wx, N0 wy =>
    reduce_1 (w0_mul_c wx wy)
  | N0 wx, N1 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 1 wy wx w_0 in
      if w0_eq0 w then N1 r
      else N2 (WW (WW w_0 w) r)
  | N0 wx, N2 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 2 wy wx w_0 in
      if w0_eq0 w then N2 r
      else N3 (WW (extend1 w0 (WW w_0 w)) r)
  | N0 wx, N3 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 3 wy wx w_0 in
      if w0_eq0 w then N3 r
      else N4 (WW (extend2 w0 (WW w_0 w)) r)
  | N0 wx, N4 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 4 wy wx w_0 in
      if w0_eq0 w then N4 r
      else N5 (WW (extend3 w0 (WW w_0 w)) r)
  | N0 wx, N5 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 5 wy wx w_0 in
      if w0_eq0 w then N5 r
      else N6 (WW (extend4 w0 (WW w_0 w)) r)
  | N0 wx, N6 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 6 wy wx w_0 in
      if w0_eq0 w then N6 r
      else N7 (WW (extend5 w0 (WW w_0 w)) r)
  | N0 wx, N7 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 7 wy wx w_0 in
      if w0_eq0 w then N7 r
      else N8 (WW (extend6 w0 (WW w_0 w)) r)
  | N0 wx, N8 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 8 wy wx w_0 in
      if w0_eq0 w then N8 r
      else N9 (WW (extend7 w0 (WW w_0 w)) r)
  | N0 wx, N9 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 9 wy wx w_0 in
      if w0_eq0 w then N9 r
      else N10 (WW (extend8 w0 (WW w_0 w)) r)
  | N0 wx, N10 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 10 wy wx w_0 in
      if w0_eq0 w then N10 r
      else N11 (WW (extend9 w0 (WW w_0 w)) r)
  | N0 wx, N11 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 11 wy wx w_0 in
      if w0_eq0 w then N11 r
      else N12 (WW (extend10 w0 (WW w_0 w)) r)
  | N0 wx, N12 wy =>
    if w0_eq0 wx then zero
    else
      let (w,r) := w0_mul_add_n1 12 wy wx w_0 in
      if w0_eq0 w then N12 r
      else Nn 0 (WW (extend11 w0 (WW w_0 w)) r)
  | N0 wx, Nn n wy =>
    if w0_eq0 wx then zero
    else
    let (w,r) := 
      gen_mul_add_mn1 w_0 (fun r => extend11 w0 (WW w_0 r))
      w12_op.(znz_0W) w12_op.(znz_WW)
      (w0_mul_add_n1 12) (S n) wy wx w_0 in
    if w0_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (extend12 w0 (WW w_0 w))) r)
  | N1 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 1 wx wy w_0 in
      if w0_eq0 w then N1 r
      else N2 (WW (WW w_0 w) r)
  | N1 wx, N1 wy =>
    N2 (w1_mul_c wx wy)
  | N1 wx, N2 wy =>
    let (w,r) := w1_mul_add_n1 1 wy wx W0 in
    if w1_eq0 w then N2 r
    else N3 (WW (extend1 w0 w) r)
  | N1 wx, N3 wy =>
    let (w,r) := w1_mul_add_n1 2 wy wx W0 in
    if w1_eq0 w then N3 r
    else N4 (WW (extend2 w0 w) r)
  | N1 wx, N4 wy =>
    let (w,r) := w1_mul_add_n1 3 wy wx W0 in
    if w1_eq0 w then N4 r
    else N5 (WW (extend3 w0 w) r)
  | N1 wx, N5 wy =>
    let (w,r) := w1_mul_add_n1 4 wy wx W0 in
    if w1_eq0 w then N5 r
    else N6 (WW (extend4 w0 w) r)
  | N1 wx, N6 wy =>
    let (w,r) := w1_mul_add_n1 5 wy wx W0 in
    if w1_eq0 w then N6 r
    else N7 (WW (extend5 w0 w) r)
  | N1 wx, N7 wy =>
    let (w,r) := w1_mul_add_n1 6 wy wx W0 in
    if w1_eq0 w then N7 r
    else N8 (WW (extend6 w0 w) r)
  | N1 wx, N8 wy =>
    let (w,r) := w1_mul_add_n1 7 wy wx W0 in
    if w1_eq0 w then N8 r
    else N9 (WW (extend7 w0 w) r)
  | N1 wx, N9 wy =>
    let (w,r) := w1_mul_add_n1 8 wy wx W0 in
    if w1_eq0 w then N9 r
    else N10 (WW (extend8 w0 w) r)
  | N1 wx, N10 wy =>
    let (w,r) := w1_mul_add_n1 9 wy wx W0 in
    if w1_eq0 w then N10 r
    else N11 (WW (extend9 w0 w) r)
  | N1 wx, N11 wy =>
    let (w,r) := w1_mul_add_n1 10 wy wx W0 in
    if w1_eq0 w then N11 r
    else N12 (WW (extend10 w0 w) r)
  | N1 wx, N12 wy =>
    let (w,r) := w1_mul_add_n1 11 wy wx W0 in
    if w1_eq0 w then N12 r
    else Nn 0 (WW (extend11 w0 w) r)
  | N1 wx, Nn n wy =>
    let (w,r) := 
      gen_mul_add_mn1 W0 (fun r => extend11 w0 r)
      w12_op.(znz_0W) w12_op.(znz_WW)
      (w1_mul_add_n1 11) (S n) wy wx W0 in
    if w1_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (extend12 w0 w)) r)
  | N2 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 2 wx wy w_0 in
      if w0_eq0 w then N2 r
      else N3 (WW (extend1 w0 (WW w_0 w)) r)
  | N2 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 1 wx wy W0 in
    if w1_eq0 w then N2 r
    else N3 (WW (extend1 w0 w) r)
  | N2 wx, N2 wy =>
    N3 (w2_mul_c wx wy)
  | N2 wx, N3 wy =>
    let (w,r) := w2_mul_add_n1 1 wy wx W0 in
    if w2_eq0 w then N3 r
    else N4 (WW (extend1 w1 w) r)
  | N2 wx, N4 wy =>
    let (w,r) := w2_mul_add_n1 2 wy wx W0 in
    if w2_eq0 w then N4 r
    else N5 (WW (extend2 w1 w) r)
  | N2 wx, N5 wy =>
    let (w,r) := w2_mul_add_n1 3 wy wx W0 in
    if w2_eq0 w then N5 r
    else N6 (WW (extend3 w1 w) r)
  | N2 wx, N6 wy =>
    let (w,r) := w2_mul_add_n1 4 wy wx W0 in
    if w2_eq0 w then N6 r
    else N7 (WW (extend4 w1 w) r)
  | N2 wx, N7 wy =>
    let (w,r) := w2_mul_add_n1 5 wy wx W0 in
    if w2_eq0 w then N7 r
    else N8 (WW (extend5 w1 w) r)
  | N2 wx, N8 wy =>
    let (w,r) := w2_mul_add_n1 6 wy wx W0 in
    if w2_eq0 w then N8 r
    else N9 (WW (extend6 w1 w) r)
  | N2 wx, N9 wy =>
    let (w,r) := w2_mul_add_n1 7 wy wx W0 in
    if w2_eq0 w then N9 r
    else N10 (WW (extend7 w1 w) r)
  | N2 wx, N10 wy =>
    let (w,r) := w2_mul_add_n1 8 wy wx W0 in
    if w2_eq0 w then N10 r
    else N11 (WW (extend8 w1 w) r)
  | N2 wx, N11 wy =>
    let (w,r) := w2_mul_add_n1 9 wy wx W0 in
    if w2_eq0 w then N11 r
    else N12 (WW (extend9 w1 w) r)
  | N2 wx, N12 wy =>
    let (w,r) := w2_mul_add_n1 10 wy wx W0 in
    if w2_eq0 w then N12 r
    else Nn 0 (WW (extend10 w1 w) r)
  | N2 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy (extend10 w1 wx) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | N3 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 3 wx wy w_0 in
      if w0_eq0 w then N3 r
      else N4 (WW (extend2 w0 (WW w_0 w)) r)
  | N3 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 2 wx wy W0 in
    if w1_eq0 w then N3 r
    else N4 (WW (extend2 w0 w) r)
  | N3 wx, N2 wy =>
    let (w,r) := w2_mul_add_n1 1 wx wy W0 in
    if w2_eq0 w then N3 r
    else N4 (WW (extend1 w1 w) r)
  | N3 wx, N3 wy =>
    N4 (w3_mul_c wx wy)
  | N3 wx, N4 wy =>
    let (w,r) := w3_mul_add_n1 1 wy wx W0 in
    if w3_eq0 w then N4 r
    else N5 (WW (extend1 w2 w) r)
  | N3 wx, N5 wy =>
    let (w,r) := w3_mul_add_n1 2 wy wx W0 in
    if w3_eq0 w then N5 r
    else N6 (WW (extend2 w2 w) r)
  | N3 wx, N6 wy =>
    let (w,r) := w3_mul_add_n1 3 wy wx W0 in
    if w3_eq0 w then N6 r
    else N7 (WW (extend3 w2 w) r)
  | N3 wx, N7 wy =>
    let (w,r) := w3_mul_add_n1 4 wy wx W0 in
    if w3_eq0 w then N7 r
    else N8 (WW (extend4 w2 w) r)
  | N3 wx, N8 wy =>
    let (w,r) := w3_mul_add_n1 5 wy wx W0 in
    if w3_eq0 w then N8 r
    else N9 (WW (extend5 w2 w) r)
  | N3 wx, N9 wy =>
    let (w,r) := w3_mul_add_n1 6 wy wx W0 in
    if w3_eq0 w then N9 r
    else N10 (WW (extend6 w2 w) r)
  | N3 wx, N10 wy =>
    let (w,r) := w3_mul_add_n1 7 wy wx W0 in
    if w3_eq0 w then N10 r
    else N11 (WW (extend7 w2 w) r)
  | N3 wx, N11 wy =>
    let (w,r) := w3_mul_add_n1 8 wy wx W0 in
    if w3_eq0 w then N11 r
    else N12 (WW (extend8 w2 w) r)
  | N3 wx, N12 wy =>
    let (w,r) := w3_mul_add_n1 9 wy wx W0 in
    if w3_eq0 w then N12 r
    else Nn 0 (WW (extend9 w2 w) r)
  | N3 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy (extend9 w2 wx) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | N4 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 4 wx wy w_0 in
      if w0_eq0 w then N4 r
      else N5 (WW (extend3 w0 (WW w_0 w)) r)
  | N4 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 3 wx wy W0 in
    if w1_eq0 w then N4 r
    else N5 (WW (extend3 w0 w) r)
  | N4 wx, N2 wy =>
    let (w,r) := w2_mul_add_n1 2 wx wy W0 in
    if w2_eq0 w then N4 r
    else N5 (WW (extend2 w1 w) r)
  | N4 wx, N3 wy =>
    let (w,r) := w3_mul_add_n1 1 wx wy W0 in
    if w3_eq0 w then N4 r
    else N5 (WW (extend1 w2 w) r)
  | N4 wx, N4 wy =>
    N5 (w4_mul_c wx wy)
  | N4 wx, N5 wy =>
    let (w,r) := w4_mul_add_n1 1 wy wx W0 in
    if w4_eq0 w then N5 r
    else N6 (WW (extend1 w3 w) r)
  | N4 wx, N6 wy =>
    let (w,r) := w4_mul_add_n1 2 wy wx W0 in
    if w4_eq0 w then N6 r
    else N7 (WW (extend2 w3 w) r)
  | N4 wx, N7 wy =>
    let (w,r) := w4_mul_add_n1 3 wy wx W0 in
    if w4_eq0 w then N7 r
    else N8 (WW (extend3 w3 w) r)
  | N4 wx, N8 wy =>
    let (w,r) := w4_mul_add_n1 4 wy wx W0 in
    if w4_eq0 w then N8 r
    else N9 (WW (extend4 w3 w) r)
  | N4 wx, N9 wy =>
    let (w,r) := w4_mul_add_n1 5 wy wx W0 in
    if w4_eq0 w then N9 r
    else N10 (WW (extend5 w3 w) r)
  | N4 wx, N10 wy =>
    let (w,r) := w4_mul_add_n1 6 wy wx W0 in
    if w4_eq0 w then N10 r
    else N11 (WW (extend6 w3 w) r)
  | N4 wx, N11 wy =>
    let (w,r) := w4_mul_add_n1 7 wy wx W0 in
    if w4_eq0 w then N11 r
    else N12 (WW (extend7 w3 w) r)
  | N4 wx, N12 wy =>
    let (w,r) := w4_mul_add_n1 8 wy wx W0 in
    if w4_eq0 w then N12 r
    else Nn 0 (WW (extend8 w3 w) r)
  | N4 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy (extend8 w3 wx) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | N5 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 5 wx wy w_0 in
      if w0_eq0 w then N5 r
      else N6 (WW (extend4 w0 (WW w_0 w)) r)
  | N5 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 4 wx wy W0 in
    if w1_eq0 w then N5 r
    else N6 (WW (extend4 w0 w) r)
  | N5 wx, N2 wy =>
    let (w,r) := w2_mul_add_n1 3 wx wy W0 in
    if w2_eq0 w then N5 r
    else N6 (WW (extend3 w1 w) r)
  | N5 wx, N3 wy =>
    let (w,r) := w3_mul_add_n1 2 wx wy W0 in
    if w3_eq0 w then N5 r
    else N6 (WW (extend2 w2 w) r)
  | N5 wx, N4 wy =>
    let (w,r) := w4_mul_add_n1 1 wx wy W0 in
    if w4_eq0 w then N5 r
    else N6 (WW (extend1 w3 w) r)
  | N5 wx, N5 wy =>
    N6 (w5_mul_c wx wy)
  | N5 wx, N6 wy =>
    let (w,r) := w5_mul_add_n1 1 wy wx W0 in
    if w5_eq0 w then N6 r
    else N7 (WW (extend1 w4 w) r)
  | N5 wx, N7 wy =>
    let (w,r) := w5_mul_add_n1 2 wy wx W0 in
    if w5_eq0 w then N7 r
    else N8 (WW (extend2 w4 w) r)
  | N5 wx, N8 wy =>
    let (w,r) := w5_mul_add_n1 3 wy wx W0 in
    if w5_eq0 w then N8 r
    else N9 (WW (extend3 w4 w) r)
  | N5 wx, N9 wy =>
    let (w,r) := w5_mul_add_n1 4 wy wx W0 in
    if w5_eq0 w then N9 r
    else N10 (WW (extend4 w4 w) r)
  | N5 wx, N10 wy =>
    let (w,r) := w5_mul_add_n1 5 wy wx W0 in
    if w5_eq0 w then N10 r
    else N11 (WW (extend5 w4 w) r)
  | N5 wx, N11 wy =>
    let (w,r) := w5_mul_add_n1 6 wy wx W0 in
    if w5_eq0 w then N11 r
    else N12 (WW (extend6 w4 w) r)
  | N5 wx, N12 wy =>
    let (w,r) := w5_mul_add_n1 7 wy wx W0 in
    if w5_eq0 w then N12 r
    else Nn 0 (WW (extend7 w4 w) r)
  | N5 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy (extend7 w4 wx) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | N6 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 6 wx wy w_0 in
      if w0_eq0 w then N6 r
      else N7 (WW (extend5 w0 (WW w_0 w)) r)
  | N6 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 5 wx wy W0 in
    if w1_eq0 w then N6 r
    else N7 (WW (extend5 w0 w) r)
  | N6 wx, N2 wy =>
    let (w,r) := w2_mul_add_n1 4 wx wy W0 in
    if w2_eq0 w then N6 r
    else N7 (WW (extend4 w1 w) r)
  | N6 wx, N3 wy =>
    let (w,r) := w3_mul_add_n1 3 wx wy W0 in
    if w3_eq0 w then N6 r
    else N7 (WW (extend3 w2 w) r)
  | N6 wx, N4 wy =>
    let (w,r) := w4_mul_add_n1 2 wx wy W0 in
    if w4_eq0 w then N6 r
    else N7 (WW (extend2 w3 w) r)
  | N6 wx, N5 wy =>
    let (w,r) := w5_mul_add_n1 1 wx wy W0 in
    if w5_eq0 w then N6 r
    else N7 (WW (extend1 w4 w) r)
  | N6 wx, N6 wy =>
    N7 (w6_mul_c wx wy)
  | N6 wx, N7 wy =>
    let (w,r) := w6_mul_add_n1 1 wy wx W0 in
    if w6_eq0 w then N7 r
    else N8 (WW (extend1 w5 w) r)
  | N6 wx, N8 wy =>
    let (w,r) := w6_mul_add_n1 2 wy wx W0 in
    if w6_eq0 w then N8 r
    else N9 (WW (extend2 w5 w) r)
  | N6 wx, N9 wy =>
    let (w,r) := w6_mul_add_n1 3 wy wx W0 in
    if w6_eq0 w then N9 r
    else N10 (WW (extend3 w5 w) r)
  | N6 wx, N10 wy =>
    let (w,r) := w6_mul_add_n1 4 wy wx W0 in
    if w6_eq0 w then N10 r
    else N11 (WW (extend4 w5 w) r)
  | N6 wx, N11 wy =>
    let (w,r) := w6_mul_add_n1 5 wy wx W0 in
    if w6_eq0 w then N11 r
    else N12 (WW (extend5 w5 w) r)
  | N6 wx, N12 wy =>
    let (w,r) := w6_mul_add_n1 6 wy wx W0 in
    if w6_eq0 w then N12 r
    else Nn 0 (WW (extend6 w5 w) r)
  | N6 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy (extend6 w5 wx) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | N7 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 7 wx wy w_0 in
      if w0_eq0 w then N7 r
      else N8 (WW (extend6 w0 (WW w_0 w)) r)
  | N7 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 6 wx wy W0 in
    if w1_eq0 w then N7 r
    else N8 (WW (extend6 w0 w) r)
  | N7 wx, N2 wy =>
    let (w,r) := w2_mul_add_n1 5 wx wy W0 in
    if w2_eq0 w then N7 r
    else N8 (WW (extend5 w1 w) r)
  | N7 wx, N3 wy =>
    let (w,r) := w3_mul_add_n1 4 wx wy W0 in
    if w3_eq0 w then N7 r
    else N8 (WW (extend4 w2 w) r)
  | N7 wx, N4 wy =>
    let (w,r) := w4_mul_add_n1 3 wx wy W0 in
    if w4_eq0 w then N7 r
    else N8 (WW (extend3 w3 w) r)
  | N7 wx, N5 wy =>
    let (w,r) := w5_mul_add_n1 2 wx wy W0 in
    if w5_eq0 w then N7 r
    else N8 (WW (extend2 w4 w) r)
  | N7 wx, N6 wy =>
    let (w,r) := w6_mul_add_n1 1 wx wy W0 in
    if w6_eq0 w then N7 r
    else N8 (WW (extend1 w5 w) r)
  | N7 wx, N7 wy =>
    N8 (w7_mul_c wx wy)
  | N7 wx, N8 wy =>
    let (w,r) := w7_mul_add_n1 1 wy wx W0 in
    if w7_eq0 w then N8 r
    else N9 (WW (extend1 w6 w) r)
  | N7 wx, N9 wy =>
    let (w,r) := w7_mul_add_n1 2 wy wx W0 in
    if w7_eq0 w then N9 r
    else N10 (WW (extend2 w6 w) r)
  | N7 wx, N10 wy =>
    let (w,r) := w7_mul_add_n1 3 wy wx W0 in
    if w7_eq0 w then N10 r
    else N11 (WW (extend3 w6 w) r)
  | N7 wx, N11 wy =>
    let (w,r) := w7_mul_add_n1 4 wy wx W0 in
    if w7_eq0 w then N11 r
    else N12 (WW (extend4 w6 w) r)
  | N7 wx, N12 wy =>
    let (w,r) := w7_mul_add_n1 5 wy wx W0 in
    if w7_eq0 w then N12 r
    else Nn 0 (WW (extend5 w6 w) r)
  | N7 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy (extend5 w6 wx) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | N8 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 8 wx wy w_0 in
      if w0_eq0 w then N8 r
      else N9 (WW (extend7 w0 (WW w_0 w)) r)
  | N8 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 7 wx wy W0 in
    if w1_eq0 w then N8 r
    else N9 (WW (extend7 w0 w) r)
  | N8 wx, N2 wy =>
    let (w,r) := w2_mul_add_n1 6 wx wy W0 in
    if w2_eq0 w then N8 r
    else N9 (WW (extend6 w1 w) r)
  | N8 wx, N3 wy =>
    let (w,r) := w3_mul_add_n1 5 wx wy W0 in
    if w3_eq0 w then N8 r
    else N9 (WW (extend5 w2 w) r)
  | N8 wx, N4 wy =>
    let (w,r) := w4_mul_add_n1 4 wx wy W0 in
    if w4_eq0 w then N8 r
    else N9 (WW (extend4 w3 w) r)
  | N8 wx, N5 wy =>
    let (w,r) := w5_mul_add_n1 3 wx wy W0 in
    if w5_eq0 w then N8 r
    else N9 (WW (extend3 w4 w) r)
  | N8 wx, N6 wy =>
    let (w,r) := w6_mul_add_n1 2 wx wy W0 in
    if w6_eq0 w then N8 r
    else N9 (WW (extend2 w5 w) r)
  | N8 wx, N7 wy =>
    let (w,r) := w7_mul_add_n1 1 wx wy W0 in
    if w7_eq0 w then N8 r
    else N9 (WW (extend1 w6 w) r)
  | N8 wx, N8 wy =>
    N9 (w8_mul_c wx wy)
  | N8 wx, N9 wy =>
    let (w,r) := w8_mul_add_n1 1 wy wx W0 in
    if w8_eq0 w then N9 r
    else N10 (WW (extend1 w7 w) r)
  | N8 wx, N10 wy =>
    let (w,r) := w8_mul_add_n1 2 wy wx W0 in
    if w8_eq0 w then N10 r
    else N11 (WW (extend2 w7 w) r)
  | N8 wx, N11 wy =>
    let (w,r) := w8_mul_add_n1 3 wy wx W0 in
    if w8_eq0 w then N11 r
    else N12 (WW (extend3 w7 w) r)
  | N8 wx, N12 wy =>
    let (w,r) := w8_mul_add_n1 4 wy wx W0 in
    if w8_eq0 w then N12 r
    else Nn 0 (WW (extend4 w7 w) r)
  | N8 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy (extend4 w7 wx) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | N9 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 9 wx wy w_0 in
      if w0_eq0 w then N9 r
      else N10 (WW (extend8 w0 (WW w_0 w)) r)
  | N9 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 8 wx wy W0 in
    if w1_eq0 w then N9 r
    else N10 (WW (extend8 w0 w) r)
  | N9 wx, N2 wy =>
    let (w,r) := w2_mul_add_n1 7 wx wy W0 in
    if w2_eq0 w then N9 r
    else N10 (WW (extend7 w1 w) r)
  | N9 wx, N3 wy =>
    let (w,r) := w3_mul_add_n1 6 wx wy W0 in
    if w3_eq0 w then N9 r
    else N10 (WW (extend6 w2 w) r)
  | N9 wx, N4 wy =>
    let (w,r) := w4_mul_add_n1 5 wx wy W0 in
    if w4_eq0 w then N9 r
    else N10 (WW (extend5 w3 w) r)
  | N9 wx, N5 wy =>
    let (w,r) := w5_mul_add_n1 4 wx wy W0 in
    if w5_eq0 w then N9 r
    else N10 (WW (extend4 w4 w) r)
  | N9 wx, N6 wy =>
    let (w,r) := w6_mul_add_n1 3 wx wy W0 in
    if w6_eq0 w then N9 r
    else N10 (WW (extend3 w5 w) r)
  | N9 wx, N7 wy =>
    let (w,r) := w7_mul_add_n1 2 wx wy W0 in
    if w7_eq0 w then N9 r
    else N10 (WW (extend2 w6 w) r)
  | N9 wx, N8 wy =>
    let (w,r) := w8_mul_add_n1 1 wx wy W0 in
    if w8_eq0 w then N9 r
    else N10 (WW (extend1 w7 w) r)
  | N9 wx, N9 wy =>
    N10 (w9_mul_c wx wy)
  | N9 wx, N10 wy =>
    let (w,r) := w9_mul_add_n1 1 wy wx W0 in
    if w9_eq0 w then N10 r
    else N11 (WW (extend1 w8 w) r)
  | N9 wx, N11 wy =>
    let (w,r) := w9_mul_add_n1 2 wy wx W0 in
    if w9_eq0 w then N11 r
    else N12 (WW (extend2 w8 w) r)
  | N9 wx, N12 wy =>
    let (w,r) := w9_mul_add_n1 3 wy wx W0 in
    if w9_eq0 w then N12 r
    else Nn 0 (WW (extend3 w8 w) r)
  | N9 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy (extend3 w8 wx) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | N10 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 10 wx wy w_0 in
      if w0_eq0 w then N10 r
      else N11 (WW (extend9 w0 (WW w_0 w)) r)
  | N10 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 9 wx wy W0 in
    if w1_eq0 w then N10 r
    else N11 (WW (extend9 w0 w) r)
  | N10 wx, N2 wy =>
    let (w,r) := w2_mul_add_n1 8 wx wy W0 in
    if w2_eq0 w then N10 r
    else N11 (WW (extend8 w1 w) r)
  | N10 wx, N3 wy =>
    let (w,r) := w3_mul_add_n1 7 wx wy W0 in
    if w3_eq0 w then N10 r
    else N11 (WW (extend7 w2 w) r)
  | N10 wx, N4 wy =>
    let (w,r) := w4_mul_add_n1 6 wx wy W0 in
    if w4_eq0 w then N10 r
    else N11 (WW (extend6 w3 w) r)
  | N10 wx, N5 wy =>
    let (w,r) := w5_mul_add_n1 5 wx wy W0 in
    if w5_eq0 w then N10 r
    else N11 (WW (extend5 w4 w) r)
  | N10 wx, N6 wy =>
    let (w,r) := w6_mul_add_n1 4 wx wy W0 in
    if w6_eq0 w then N10 r
    else N11 (WW (extend4 w5 w) r)
  | N10 wx, N7 wy =>
    let (w,r) := w7_mul_add_n1 3 wx wy W0 in
    if w7_eq0 w then N10 r
    else N11 (WW (extend3 w6 w) r)
  | N10 wx, N8 wy =>
    let (w,r) := w8_mul_add_n1 2 wx wy W0 in
    if w8_eq0 w then N10 r
    else N11 (WW (extend2 w7 w) r)
  | N10 wx, N9 wy =>
    let (w,r) := w9_mul_add_n1 1 wx wy W0 in
    if w9_eq0 w then N10 r
    else N11 (WW (extend1 w8 w) r)
  | N10 wx, N10 wy =>
    N11 (w10_mul_c wx wy)
  | N10 wx, N11 wy =>
    let (w,r) := w10_mul_add_n1 1 wy wx W0 in
    if w10_eq0 w then N11 r
    else N12 (WW (extend1 w9 w) r)
  | N10 wx, N12 wy =>
    let (w,r) := w10_mul_add_n1 2 wy wx W0 in
    if w10_eq0 w then N12 r
    else Nn 0 (WW (extend2 w9 w) r)
  | N10 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy (extend2 w9 wx) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | N11 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 11 wx wy w_0 in
      if w0_eq0 w then N11 r
      else N12 (WW (extend10 w0 (WW w_0 w)) r)
  | N11 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 10 wx wy W0 in
    if w1_eq0 w then N11 r
    else N12 (WW (extend10 w0 w) r)
  | N11 wx, N2 wy =>
    let (w,r) := w2_mul_add_n1 9 wx wy W0 in
    if w2_eq0 w then N11 r
    else N12 (WW (extend9 w1 w) r)
  | N11 wx, N3 wy =>
    let (w,r) := w3_mul_add_n1 8 wx wy W0 in
    if w3_eq0 w then N11 r
    else N12 (WW (extend8 w2 w) r)
  | N11 wx, N4 wy =>
    let (w,r) := w4_mul_add_n1 7 wx wy W0 in
    if w4_eq0 w then N11 r
    else N12 (WW (extend7 w3 w) r)
  | N11 wx, N5 wy =>
    let (w,r) := w5_mul_add_n1 6 wx wy W0 in
    if w5_eq0 w then N11 r
    else N12 (WW (extend6 w4 w) r)
  | N11 wx, N6 wy =>
    let (w,r) := w6_mul_add_n1 5 wx wy W0 in
    if w6_eq0 w then N11 r
    else N12 (WW (extend5 w5 w) r)
  | N11 wx, N7 wy =>
    let (w,r) := w7_mul_add_n1 4 wx wy W0 in
    if w7_eq0 w then N11 r
    else N12 (WW (extend4 w6 w) r)
  | N11 wx, N8 wy =>
    let (w,r) := w8_mul_add_n1 3 wx wy W0 in
    if w8_eq0 w then N11 r
    else N12 (WW (extend3 w7 w) r)
  | N11 wx, N9 wy =>
    let (w,r) := w9_mul_add_n1 2 wx wy W0 in
    if w9_eq0 w then N11 r
    else N12 (WW (extend2 w8 w) r)
  | N11 wx, N10 wy =>
    let (w,r) := w10_mul_add_n1 1 wx wy W0 in
    if w10_eq0 w then N11 r
    else N12 (WW (extend1 w9 w) r)
  | N11 wx, N11 wy =>
    N12 (w11_mul_c wx wy)
  | N11 wx, N12 wy =>
    let (w,r) := w11_mul_add_n1 1 wy wx W0 in
    if w11_eq0 w then N12 r
    else Nn 0 (WW (extend1 w10 w) r)
  | N11 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy (extend1 w10 wx) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | N12 wx, N0 wy =>
    if w0_eq0 wy then zero
    else
      let (w,r) := w0_mul_add_n1 12 wx wy w_0 in
      if w0_eq0 w then N12 r
      else Nn 0 (WW (extend11 w0 (WW w_0 w)) r)
  | N12 wx, N1 wy =>
    let (w,r) := w1_mul_add_n1 11 wx wy W0 in
    if w1_eq0 w then N12 r
    else Nn 0 (WW (extend11 w0 w) r)
  | N12 wx, N2 wy =>
    let (w,r) := w2_mul_add_n1 10 wx wy W0 in
    if w2_eq0 w then N12 r
    else Nn 0 (WW (extend10 w1 w) r)
  | N12 wx, N3 wy =>
    let (w,r) := w3_mul_add_n1 9 wx wy W0 in
    if w3_eq0 w then N12 r
    else Nn 0 (WW (extend9 w2 w) r)
  | N12 wx, N4 wy =>
    let (w,r) := w4_mul_add_n1 8 wx wy W0 in
    if w4_eq0 w then N12 r
    else Nn 0 (WW (extend8 w3 w) r)
  | N12 wx, N5 wy =>
    let (w,r) := w5_mul_add_n1 7 wx wy W0 in
    if w5_eq0 w then N12 r
    else Nn 0 (WW (extend7 w4 w) r)
  | N12 wx, N6 wy =>
    let (w,r) := w6_mul_add_n1 6 wx wy W0 in
    if w6_eq0 w then N12 r
    else Nn 0 (WW (extend6 w5 w) r)
  | N12 wx, N7 wy =>
    let (w,r) := w7_mul_add_n1 5 wx wy W0 in
    if w7_eq0 w then N12 r
    else Nn 0 (WW (extend5 w6 w) r)
  | N12 wx, N8 wy =>
    let (w,r) := w8_mul_add_n1 4 wx wy W0 in
    if w8_eq0 w then N12 r
    else Nn 0 (WW (extend4 w7 w) r)
  | N12 wx, N9 wy =>
    let (w,r) := w9_mul_add_n1 3 wx wy W0 in
    if w9_eq0 w then N12 r
    else Nn 0 (WW (extend3 w8 w) r)
  | N12 wx, N10 wy =>
    let (w,r) := w10_mul_add_n1 2 wx wy W0 in
    if w10_eq0 w then N12 r
    else Nn 0 (WW (extend2 w9 w) r)
  | N12 wx, N11 wy =>
    let (w,r) := w11_mul_add_n1 1 wx wy W0 in
    if w11_eq0 w then N12 r
    else Nn 0 (WW (extend1 w10 w) r)
  | N12 wx, N12 wy =>
    Nn 0 (w12_mul_c wx wy)
  | N12 wx, Nn n wy =>
    let (w,r) := w12_mul_add_n1 (S n) wy wx W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N0 wy =>
    if w0_eq0 wy then zero
    else
    let (w,r) := 
      gen_mul_add_mn1 w_0 (fun r => extend11 w0 (WW w_0 r))
      w12_op.(znz_0W) w12_op.(znz_WW)
      (w0_mul_add_n1 12) (S n) wx wy w_0 in
    if w0_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (extend12 w0 (WW w_0 w))) r)
  | Nn n wx, N1 wy =>   
    let (w,r) := 
      gen_mul_add_mn1 W0 (fun r => extend11 w0 r)
      w12_op.(znz_0W) w12_op.(znz_WW)
      (w1_mul_add_n1 11) (S n) wx wy W0 in
    if w1_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (extend12 w0 w)) r)
  | Nn n wx, N2 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx (extend10 w1 wy) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N3 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx (extend9 w2 wy) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N4 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx (extend8 w3 wy) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N5 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx (extend7 w4 wy) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N6 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx (extend6 w5 wy) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N7 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx (extend5 w6 wy) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N8 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx (extend4 w7 wy) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N9 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx (extend3 w8 wy) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N10 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx (extend2 w9 wy) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N11 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx (extend1 w10 wy) W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, N12 wy =>
    let (w,r) := w12_mul_add_n1 (S n) wx wy W0 in
    if w12_eq0 w then Nn n r
    else Nn (S n) (WW (extend n w12 (WW W0 w)) r)
  | Nn n wx, Nn m wy =>
    match extend_to_max w12 n m wx wy with
    | inl wx' =>
      let op := make_op m in
      reduce_n (S m) (op.(znz_mul_c) wx' wy)
    | inr wy' =>
      let op := make_op n in
      reduce_n (S n) (op.(znz_mul_c) wx wy')
    end
  end.

 Definition w0_square_c := w0_op.(znz_square_c).
 Definition w1_square_c := w1_op.(znz_square_c).
 Definition w2_square_c := w2_op.(znz_square_c).
 Definition w3_square_c := w3_op.(znz_square_c).
 Definition w4_square_c := w4_op.(znz_square_c).
 Definition w5_square_c := w5_op.(znz_square_c).
 Definition w6_square_c := w6_op.(znz_square_c).
 Definition w7_square_c := w7_op.(znz_square_c).
 Definition w8_square_c := w8_op.(znz_square_c).
 Definition w9_square_c := w9_op.(znz_square_c).
 Definition w10_square_c := w10_op.(znz_square_c).
 Definition w11_square_c := w11_op.(znz_square_c).
 Definition w12_square_c := w12_op.(znz_square_c).

 Definition square x :=
  match x with
  | N0 wx => reduce_1 (w0_square_c wx)
  | N1 wx => N2 (w1_square_c wx)
  | N2 wx => N3 (w2_square_c wx)
  | N3 wx => N4 (w3_square_c wx)
  | N4 wx => N5 (w4_square_c wx)
  | N5 wx => N6 (w5_square_c wx)
  | N6 wx => N7 (w6_square_c wx)
  | N7 wx => N8 (w7_square_c wx)
  | N8 wx => N9 (w8_square_c wx)
  | N9 wx => N10 (w9_square_c wx)
  | N10 wx => N11 (w10_square_c wx)
  | N11 wx => N12 (w11_square_c wx)
  | N12 wx => Nn 0 (w12_square_c wx)
  | Nn n wx =>
    let op := make_op n in
    Nn (S n) (op.(znz_square_c) wx)
  end.

 Fixpoint power_pos (x:t) (p:positive) {struct p} : t :=
  match p with
  | xH => x
  | xO p => square (power_pos x p)
  | xI p => mul (square (power_pos x p)) x
  end.

 Definition w0_sqrt := w0_op.(znz_sqrt).
 Definition w1_sqrt := w1_op.(znz_sqrt).
 Definition w2_sqrt := w2_op.(znz_sqrt).
 Definition w3_sqrt := w3_op.(znz_sqrt).
 Definition w4_sqrt := w4_op.(znz_sqrt).
 Definition w5_sqrt := w5_op.(znz_sqrt).
 Definition w6_sqrt := w6_op.(znz_sqrt).
 Definition w7_sqrt := w7_op.(znz_sqrt).
 Definition w8_sqrt := w8_op.(znz_sqrt).
 Definition w9_sqrt := w9_op.(znz_sqrt).
 Definition w10_sqrt := w10_op.(znz_sqrt).
 Definition w11_sqrt := w11_op.(znz_sqrt).
 Definition w12_sqrt := w12_op.(znz_sqrt).

 Definition sqrt x :=
  match x with
  | N0 wx => reduce_0 (w0_sqrt wx)
  | N1 wx => reduce_1 (w1_sqrt wx)
  | N2 wx => reduce_2 (w2_sqrt wx)
  | N3 wx => reduce_3 (w3_sqrt wx)
  | N4 wx => reduce_4 (w4_sqrt wx)
  | N5 wx => reduce_5 (w5_sqrt wx)
  | N6 wx => reduce_6 (w6_sqrt wx)
  | N7 wx => reduce_7 (w7_sqrt wx)
  | N8 wx => reduce_8 (w8_sqrt wx)
  | N9 wx => reduce_9 (w9_sqrt wx)
  | N10 wx => reduce_10 (w10_sqrt wx)
  | N11 wx => reduce_11 (w11_sqrt wx)
  | N12 wx => reduce_12 (w12_sqrt wx)
  | Nn n wx =>
    let op := make_op n in
    reduce_n n (op.(znz_sqrt) wx)
  end.

 Definition w0_div_gt := w0_op.(znz_div_gt).
 Definition w1_div_gt := w1_op.(znz_div_gt).
 Definition w2_div_gt := w2_op.(znz_div_gt).
 Definition w3_div_gt := w3_op.(znz_div_gt).
 Definition w4_div_gt := w4_op.(znz_div_gt).
 Definition w5_div_gt := w5_op.(znz_div_gt).
 Definition w6_div_gt := w6_op.(znz_div_gt).
 Definition w7_div_gt := w7_op.(znz_div_gt).
 Definition w8_div_gt := w8_op.(znz_div_gt).
 Definition w9_div_gt := w9_op.(znz_div_gt).
 Definition w10_div_gt := w10_op.(znz_div_gt).
 Definition w11_div_gt := w11_op.(znz_div_gt).
 Definition w12_div_gt := w12_op.(znz_div_gt).

 Definition w0_divn1 :=
  gen_divn1 w0_op.(znz_zdigits) w0_op.(znz_0)
    w0_op.(znz_WW) w0_op.(znz_head0)
    w0_op.(znz_add_mul_div) w0_op.(znz_div21)
    w0_op.(znz_compare) w0_op.(znz_sub).
 Definition w1_divn1 :=
  gen_divn1 w1_op.(znz_zdigits) w1_op.(znz_0)
    w1_op.(znz_WW) w1_op.(znz_head0)
    w1_op.(znz_add_mul_div) w1_op.(znz_div21)
    w1_op.(znz_compare) w1_op.(znz_sub).
 Definition w2_divn1 :=
  gen_divn1 w2_op.(znz_zdigits) w2_op.(znz_0)
    w2_op.(znz_WW) w2_op.(znz_head0)
    w2_op.(znz_add_mul_div) w2_op.(znz_div21)
    w2_op.(znz_compare) w2_op.(znz_sub).
 Definition w3_divn1 :=
  gen_divn1 w3_op.(znz_zdigits) w3_op.(znz_0)
    w3_op.(znz_WW) w3_op.(znz_head0)
    w3_op.(znz_add_mul_div) w3_op.(znz_div21)
    w3_op.(znz_compare) w3_op.(znz_sub).
 Definition w4_divn1 :=
  gen_divn1 w4_op.(znz_zdigits) w4_op.(znz_0)
    w4_op.(znz_WW) w4_op.(znz_head0)
    w4_op.(znz_add_mul_div) w4_op.(znz_div21)
    w4_op.(znz_compare) w4_op.(znz_sub).
 Definition w5_divn1 :=
  gen_divn1 w5_op.(znz_zdigits) w5_op.(znz_0)
    w5_op.(znz_WW) w5_op.(znz_head0)
    w5_op.(znz_add_mul_div) w5_op.(znz_div21)
    w5_op.(znz_compare) w5_op.(znz_sub).
 Definition w6_divn1 :=
  gen_divn1 w6_op.(znz_zdigits) w6_op.(znz_0)
    w6_op.(znz_WW) w6_op.(znz_head0)
    w6_op.(znz_add_mul_div) w6_op.(znz_div21)
    w6_op.(znz_compare) w6_op.(znz_sub).
 Definition w7_divn1 :=
  gen_divn1 w7_op.(znz_zdigits) w7_op.(znz_0)
    w7_op.(znz_WW) w7_op.(znz_head0)
    w7_op.(znz_add_mul_div) w7_op.(znz_div21)
    w7_op.(znz_compare) w7_op.(znz_sub).
 Definition w8_divn1 :=
  gen_divn1 w8_op.(znz_zdigits) w8_op.(znz_0)
    w8_op.(znz_WW) w8_op.(znz_head0)
    w8_op.(znz_add_mul_div) w8_op.(znz_div21)
    w8_op.(znz_compare) w8_op.(znz_sub).
 Definition w9_divn1 :=
  gen_divn1 w9_op.(znz_zdigits) w9_op.(znz_0)
    w9_op.(znz_WW) w9_op.(znz_head0)
    w9_op.(znz_add_mul_div) w9_op.(znz_div21)
    w9_op.(znz_compare) w9_op.(znz_sub).
 Definition w10_divn1 :=
  gen_divn1 w10_op.(znz_zdigits) w10_op.(znz_0)
    w10_op.(znz_WW) w10_op.(znz_head0)
    w10_op.(znz_add_mul_div) w10_op.(znz_div21)
    w10_op.(znz_compare) w10_op.(znz_sub).
 Definition w11_divn1 :=
  gen_divn1 w11_op.(znz_zdigits) w11_op.(znz_0)
    w11_op.(znz_WW) w11_op.(znz_head0)
    w11_op.(znz_add_mul_div) w11_op.(znz_div21)
    w11_op.(znz_compare) w11_op.(znz_sub).
 Definition w12_divn1 :=
  gen_divn1 w12_op.(znz_zdigits) w12_op.(znz_0)
    w12_op.(znz_WW) w12_op.(znz_head0)
    w12_op.(znz_add_mul_div) w12_op.(znz_div21)
    w12_op.(znz_compare) w12_op.(znz_sub).

 Definition div_gt x y :=
  match x, y with
  | N0 wx, N0 wy => let (q, r):= w0_div_gt wx wy in (reduce_0 q, reduce_0 r)
  | N0 wx, N1 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 0 wx in
    let (q, r):= w1_div_gt wx' wy in
    (reduce_1 q, reduce_1 r)
  | N0 wx, N2 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 1 wx in
    let (q, r):= w2_div_gt wx' wy in
    (reduce_2 q, reduce_2 r)
  | N0 wx, N3 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 2 wx in
    let (q, r):= w3_div_gt wx' wy in
    (reduce_3 q, reduce_3 r)
  | N0 wx, N4 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 3 wx in
    let (q, r):= w4_div_gt wx' wy in
    (reduce_4 q, reduce_4 r)
  | N0 wx, N5 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 4 wx in
    let (q, r):= w5_div_gt wx' wy in
    (reduce_5 q, reduce_5 r)
  | N0 wx, N6 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 5 wx in
    let (q, r):= w6_div_gt wx' wy in
    (reduce_6 q, reduce_6 r)
  | N0 wx, N7 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 6 wx in
    let (q, r):= w7_div_gt wx' wy in
    (reduce_7 q, reduce_7 r)
  | N0 wx, N8 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 7 wx in
    let (q, r):= w8_div_gt wx' wy in
    (reduce_8 q, reduce_8 r)
  | N0 wx, N9 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 8 wx in
    let (q, r):= w9_div_gt wx' wy in
    (reduce_9 q, reduce_9 r)
  | N0 wx, N10 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 9 wx in
    let (q, r):= w10_div_gt wx' wy in
    (reduce_10 q, reduce_10 r)
  | N0 wx, N11 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 10 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N0 wx, N12 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 11 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N0 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w0_op.(znz_0W) 12 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N1 wx, N0 wy => let (q, r):= w0_divn1 1 wx wy in (reduce_1 q, reduce_0 r)
  | N1 wx, N1 wy => let (q, r):= w1_div_gt wx wy in (reduce_1 q, reduce_1 r)
  | N1 wx, N2 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 0 wx in
    let (q, r):= w2_div_gt wx' wy in
    (reduce_2 q, reduce_2 r)
  | N1 wx, N3 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 1 wx in
    let (q, r):= w3_div_gt wx' wy in
    (reduce_3 q, reduce_3 r)
  | N1 wx, N4 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 2 wx in
    let (q, r):= w4_div_gt wx' wy in
    (reduce_4 q, reduce_4 r)
  | N1 wx, N5 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 3 wx in
    let (q, r):= w5_div_gt wx' wy in
    (reduce_5 q, reduce_5 r)
  | N1 wx, N6 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 4 wx in
    let (q, r):= w6_div_gt wx' wy in
    (reduce_6 q, reduce_6 r)
  | N1 wx, N7 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 5 wx in
    let (q, r):= w7_div_gt wx' wy in
    (reduce_7 q, reduce_7 r)
  | N1 wx, N8 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 6 wx in
    let (q, r):= w8_div_gt wx' wy in
    (reduce_8 q, reduce_8 r)
  | N1 wx, N9 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 7 wx in
    let (q, r):= w9_div_gt wx' wy in
    (reduce_9 q, reduce_9 r)
  | N1 wx, N10 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 8 wx in
    let (q, r):= w10_div_gt wx' wy in
    (reduce_10 q, reduce_10 r)
  | N1 wx, N11 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 9 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N1 wx, N12 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 10 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N1 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w1_op.(znz_0W) 11 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N2 wx, N0 wy => let (q, r):= w0_divn1 2 wx wy in (reduce_2 q, reduce_0 r)
  | N2 wx, N1 wy => let (q, r):= w1_divn1 1 wx wy in (reduce_2 q, reduce_1 r)
  | N2 wx, N2 wy => let (q, r):= w2_div_gt wx wy in (reduce_2 q, reduce_2 r)
  | N2 wx, N3 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 0 wx in
    let (q, r):= w3_div_gt wx' wy in
    (reduce_3 q, reduce_3 r)
  | N2 wx, N4 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 1 wx in
    let (q, r):= w4_div_gt wx' wy in
    (reduce_4 q, reduce_4 r)
  | N2 wx, N5 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 2 wx in
    let (q, r):= w5_div_gt wx' wy in
    (reduce_5 q, reduce_5 r)
  | N2 wx, N6 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 3 wx in
    let (q, r):= w6_div_gt wx' wy in
    (reduce_6 q, reduce_6 r)
  | N2 wx, N7 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 4 wx in
    let (q, r):= w7_div_gt wx' wy in
    (reduce_7 q, reduce_7 r)
  | N2 wx, N8 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 5 wx in
    let (q, r):= w8_div_gt wx' wy in
    (reduce_8 q, reduce_8 r)
  | N2 wx, N9 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 6 wx in
    let (q, r):= w9_div_gt wx' wy in
    (reduce_9 q, reduce_9 r)
  | N2 wx, N10 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 7 wx in
    let (q, r):= w10_div_gt wx' wy in
    (reduce_10 q, reduce_10 r)
  | N2 wx, N11 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 8 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N2 wx, N12 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 9 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N2 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w2_op.(znz_0W) 10 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N3 wx, N0 wy => let (q, r):= w0_divn1 3 wx wy in (reduce_3 q, reduce_0 r)
  | N3 wx, N1 wy => let (q, r):= w1_divn1 2 wx wy in (reduce_3 q, reduce_1 r)
  | N3 wx, N2 wy => let (q, r):= w2_divn1 1 wx wy in (reduce_3 q, reduce_2 r)
  | N3 wx, N3 wy => let (q, r):= w3_div_gt wx wy in (reduce_3 q, reduce_3 r)
  | N3 wx, N4 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 0 wx in
    let (q, r):= w4_div_gt wx' wy in
    (reduce_4 q, reduce_4 r)
  | N3 wx, N5 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 1 wx in
    let (q, r):= w5_div_gt wx' wy in
    (reduce_5 q, reduce_5 r)
  | N3 wx, N6 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 2 wx in
    let (q, r):= w6_div_gt wx' wy in
    (reduce_6 q, reduce_6 r)
  | N3 wx, N7 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 3 wx in
    let (q, r):= w7_div_gt wx' wy in
    (reduce_7 q, reduce_7 r)
  | N3 wx, N8 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 4 wx in
    let (q, r):= w8_div_gt wx' wy in
    (reduce_8 q, reduce_8 r)
  | N3 wx, N9 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 5 wx in
    let (q, r):= w9_div_gt wx' wy in
    (reduce_9 q, reduce_9 r)
  | N3 wx, N10 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 6 wx in
    let (q, r):= w10_div_gt wx' wy in
    (reduce_10 q, reduce_10 r)
  | N3 wx, N11 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 7 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N3 wx, N12 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 8 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N3 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w3_op.(znz_0W) 9 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N4 wx, N0 wy => let (q, r):= w0_divn1 4 wx wy in (reduce_4 q, reduce_0 r)
  | N4 wx, N1 wy => let (q, r):= w1_divn1 3 wx wy in (reduce_4 q, reduce_1 r)
  | N4 wx, N2 wy => let (q, r):= w2_divn1 2 wx wy in (reduce_4 q, reduce_2 r)
  | N4 wx, N3 wy => let (q, r):= w3_divn1 1 wx wy in (reduce_4 q, reduce_3 r)
  | N4 wx, N4 wy => let (q, r):= w4_div_gt wx wy in (reduce_4 q, reduce_4 r)
  | N4 wx, N5 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 0 wx in
    let (q, r):= w5_div_gt wx' wy in
    (reduce_5 q, reduce_5 r)
  | N4 wx, N6 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 1 wx in
    let (q, r):= w6_div_gt wx' wy in
    (reduce_6 q, reduce_6 r)
  | N4 wx, N7 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 2 wx in
    let (q, r):= w7_div_gt wx' wy in
    (reduce_7 q, reduce_7 r)
  | N4 wx, N8 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 3 wx in
    let (q, r):= w8_div_gt wx' wy in
    (reduce_8 q, reduce_8 r)
  | N4 wx, N9 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 4 wx in
    let (q, r):= w9_div_gt wx' wy in
    (reduce_9 q, reduce_9 r)
  | N4 wx, N10 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 5 wx in
    let (q, r):= w10_div_gt wx' wy in
    (reduce_10 q, reduce_10 r)
  | N4 wx, N11 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 6 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N4 wx, N12 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 7 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N4 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w4_op.(znz_0W) 8 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N5 wx, N0 wy => let (q, r):= w0_divn1 5 wx wy in (reduce_5 q, reduce_0 r)
  | N5 wx, N1 wy => let (q, r):= w1_divn1 4 wx wy in (reduce_5 q, reduce_1 r)
  | N5 wx, N2 wy => let (q, r):= w2_divn1 3 wx wy in (reduce_5 q, reduce_2 r)
  | N5 wx, N3 wy => let (q, r):= w3_divn1 2 wx wy in (reduce_5 q, reduce_3 r)
  | N5 wx, N4 wy => let (q, r):= w4_divn1 1 wx wy in (reduce_5 q, reduce_4 r)
  | N5 wx, N5 wy => let (q, r):= w5_div_gt wx wy in (reduce_5 q, reduce_5 r)
  | N5 wx, N6 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 0 wx in
    let (q, r):= w6_div_gt wx' wy in
    (reduce_6 q, reduce_6 r)
  | N5 wx, N7 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 1 wx in
    let (q, r):= w7_div_gt wx' wy in
    (reduce_7 q, reduce_7 r)
  | N5 wx, N8 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 2 wx in
    let (q, r):= w8_div_gt wx' wy in
    (reduce_8 q, reduce_8 r)
  | N5 wx, N9 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 3 wx in
    let (q, r):= w9_div_gt wx' wy in
    (reduce_9 q, reduce_9 r)
  | N5 wx, N10 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 4 wx in
    let (q, r):= w10_div_gt wx' wy in
    (reduce_10 q, reduce_10 r)
  | N5 wx, N11 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 5 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N5 wx, N12 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 6 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N5 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w5_op.(znz_0W) 7 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N6 wx, N0 wy => let (q, r):= w0_divn1 6 wx wy in (reduce_6 q, reduce_0 r)
  | N6 wx, N1 wy => let (q, r):= w1_divn1 5 wx wy in (reduce_6 q, reduce_1 r)
  | N6 wx, N2 wy => let (q, r):= w2_divn1 4 wx wy in (reduce_6 q, reduce_2 r)
  | N6 wx, N3 wy => let (q, r):= w3_divn1 3 wx wy in (reduce_6 q, reduce_3 r)
  | N6 wx, N4 wy => let (q, r):= w4_divn1 2 wx wy in (reduce_6 q, reduce_4 r)
  | N6 wx, N5 wy => let (q, r):= w5_divn1 1 wx wy in (reduce_6 q, reduce_5 r)
  | N6 wx, N6 wy => let (q, r):= w6_div_gt wx wy in (reduce_6 q, reduce_6 r)
  | N6 wx, N7 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 0 wx in
    let (q, r):= w7_div_gt wx' wy in
    (reduce_7 q, reduce_7 r)
  | N6 wx, N8 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 1 wx in
    let (q, r):= w8_div_gt wx' wy in
    (reduce_8 q, reduce_8 r)
  | N6 wx, N9 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 2 wx in
    let (q, r):= w9_div_gt wx' wy in
    (reduce_9 q, reduce_9 r)
  | N6 wx, N10 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 3 wx in
    let (q, r):= w10_div_gt wx' wy in
    (reduce_10 q, reduce_10 r)
  | N6 wx, N11 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 4 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N6 wx, N12 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 5 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N6 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w6_op.(znz_0W) 6 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N7 wx, N0 wy => let (q, r):= w0_divn1 7 wx wy in (reduce_7 q, reduce_0 r)
  | N7 wx, N1 wy => let (q, r):= w1_divn1 6 wx wy in (reduce_7 q, reduce_1 r)
  | N7 wx, N2 wy => let (q, r):= w2_divn1 5 wx wy in (reduce_7 q, reduce_2 r)
  | N7 wx, N3 wy => let (q, r):= w3_divn1 4 wx wy in (reduce_7 q, reduce_3 r)
  | N7 wx, N4 wy => let (q, r):= w4_divn1 3 wx wy in (reduce_7 q, reduce_4 r)
  | N7 wx, N5 wy => let (q, r):= w5_divn1 2 wx wy in (reduce_7 q, reduce_5 r)
  | N7 wx, N6 wy => let (q, r):= w6_divn1 1 wx wy in (reduce_7 q, reduce_6 r)
  | N7 wx, N7 wy => let (q, r):= w7_div_gt wx wy in (reduce_7 q, reduce_7 r)
  | N7 wx, N8 wy =>
    let wx':= GenBase.extend w7_op.(znz_0W) 0 wx in
    let (q, r):= w8_div_gt wx' wy in
    (reduce_8 q, reduce_8 r)
  | N7 wx, N9 wy =>
    let wx':= GenBase.extend w7_op.(znz_0W) 1 wx in
    let (q, r):= w9_div_gt wx' wy in
    (reduce_9 q, reduce_9 r)
  | N7 wx, N10 wy =>
    let wx':= GenBase.extend w7_op.(znz_0W) 2 wx in
    let (q, r):= w10_div_gt wx' wy in
    (reduce_10 q, reduce_10 r)
  | N7 wx, N11 wy =>
    let wx':= GenBase.extend w7_op.(znz_0W) 3 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N7 wx, N12 wy =>
    let wx':= GenBase.extend w7_op.(znz_0W) 4 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N7 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w7_op.(znz_0W) 5 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N8 wx, N0 wy => let (q, r):= w0_divn1 8 wx wy in (reduce_8 q, reduce_0 r)
  | N8 wx, N1 wy => let (q, r):= w1_divn1 7 wx wy in (reduce_8 q, reduce_1 r)
  | N8 wx, N2 wy => let (q, r):= w2_divn1 6 wx wy in (reduce_8 q, reduce_2 r)
  | N8 wx, N3 wy => let (q, r):= w3_divn1 5 wx wy in (reduce_8 q, reduce_3 r)
  | N8 wx, N4 wy => let (q, r):= w4_divn1 4 wx wy in (reduce_8 q, reduce_4 r)
  | N8 wx, N5 wy => let (q, r):= w5_divn1 3 wx wy in (reduce_8 q, reduce_5 r)
  | N8 wx, N6 wy => let (q, r):= w6_divn1 2 wx wy in (reduce_8 q, reduce_6 r)
  | N8 wx, N7 wy => let (q, r):= w7_divn1 1 wx wy in (reduce_8 q, reduce_7 r)
  | N8 wx, N8 wy => let (q, r):= w8_div_gt wx wy in (reduce_8 q, reduce_8 r)
  | N8 wx, N9 wy =>
    let wx':= GenBase.extend w8_op.(znz_0W) 0 wx in
    let (q, r):= w9_div_gt wx' wy in
    (reduce_9 q, reduce_9 r)
  | N8 wx, N10 wy =>
    let wx':= GenBase.extend w8_op.(znz_0W) 1 wx in
    let (q, r):= w10_div_gt wx' wy in
    (reduce_10 q, reduce_10 r)
  | N8 wx, N11 wy =>
    let wx':= GenBase.extend w8_op.(znz_0W) 2 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N8 wx, N12 wy =>
    let wx':= GenBase.extend w8_op.(znz_0W) 3 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N8 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w8_op.(znz_0W) 4 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N9 wx, N0 wy => let (q, r):= w0_divn1 9 wx wy in (reduce_9 q, reduce_0 r)
  | N9 wx, N1 wy => let (q, r):= w1_divn1 8 wx wy in (reduce_9 q, reduce_1 r)
  | N9 wx, N2 wy => let (q, r):= w2_divn1 7 wx wy in (reduce_9 q, reduce_2 r)
  | N9 wx, N3 wy => let (q, r):= w3_divn1 6 wx wy in (reduce_9 q, reduce_3 r)
  | N9 wx, N4 wy => let (q, r):= w4_divn1 5 wx wy in (reduce_9 q, reduce_4 r)
  | N9 wx, N5 wy => let (q, r):= w5_divn1 4 wx wy in (reduce_9 q, reduce_5 r)
  | N9 wx, N6 wy => let (q, r):= w6_divn1 3 wx wy in (reduce_9 q, reduce_6 r)
  | N9 wx, N7 wy => let (q, r):= w7_divn1 2 wx wy in (reduce_9 q, reduce_7 r)
  | N9 wx, N8 wy => let (q, r):= w8_divn1 1 wx wy in (reduce_9 q, reduce_8 r)
  | N9 wx, N9 wy => let (q, r):= w9_div_gt wx wy in (reduce_9 q, reduce_9 r)
  | N9 wx, N10 wy =>
    let wx':= GenBase.extend w9_op.(znz_0W) 0 wx in
    let (q, r):= w10_div_gt wx' wy in
    (reduce_10 q, reduce_10 r)
  | N9 wx, N11 wy =>
    let wx':= GenBase.extend w9_op.(znz_0W) 1 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N9 wx, N12 wy =>
    let wx':= GenBase.extend w9_op.(znz_0W) 2 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N9 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w9_op.(znz_0W) 3 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N10 wx, N0 wy => let (q, r):= w0_divn1 10 wx wy in (reduce_10 q, reduce_0 r)
  | N10 wx, N1 wy => let (q, r):= w1_divn1 9 wx wy in (reduce_10 q, reduce_1 r)
  | N10 wx, N2 wy => let (q, r):= w2_divn1 8 wx wy in (reduce_10 q, reduce_2 r)
  | N10 wx, N3 wy => let (q, r):= w3_divn1 7 wx wy in (reduce_10 q, reduce_3 r)
  | N10 wx, N4 wy => let (q, r):= w4_divn1 6 wx wy in (reduce_10 q, reduce_4 r)
  | N10 wx, N5 wy => let (q, r):= w5_divn1 5 wx wy in (reduce_10 q, reduce_5 r)
  | N10 wx, N6 wy => let (q, r):= w6_divn1 4 wx wy in (reduce_10 q, reduce_6 r)
  | N10 wx, N7 wy => let (q, r):= w7_divn1 3 wx wy in (reduce_10 q, reduce_7 r)
  | N10 wx, N8 wy => let (q, r):= w8_divn1 2 wx wy in (reduce_10 q, reduce_8 r)
  | N10 wx, N9 wy => let (q, r):= w9_divn1 1 wx wy in (reduce_10 q, reduce_9 r)
  | N10 wx, N10 wy => let (q, r):= w10_div_gt wx wy in (reduce_10 q, reduce_10 r)
  | N10 wx, N11 wy =>
    let wx':= GenBase.extend w10_op.(znz_0W) 0 wx in
    let (q, r):= w11_div_gt wx' wy in
    (reduce_11 q, reduce_11 r)
  | N10 wx, N12 wy =>
    let wx':= GenBase.extend w10_op.(znz_0W) 1 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N10 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w10_op.(znz_0W) 2 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N11 wx, N0 wy => let (q, r):= w0_divn1 11 wx wy in (reduce_11 q, reduce_0 r)
  | N11 wx, N1 wy => let (q, r):= w1_divn1 10 wx wy in (reduce_11 q, reduce_1 r)
  | N11 wx, N2 wy => let (q, r):= w2_divn1 9 wx wy in (reduce_11 q, reduce_2 r)
  | N11 wx, N3 wy => let (q, r):= w3_divn1 8 wx wy in (reduce_11 q, reduce_3 r)
  | N11 wx, N4 wy => let (q, r):= w4_divn1 7 wx wy in (reduce_11 q, reduce_4 r)
  | N11 wx, N5 wy => let (q, r):= w5_divn1 6 wx wy in (reduce_11 q, reduce_5 r)
  | N11 wx, N6 wy => let (q, r):= w6_divn1 5 wx wy in (reduce_11 q, reduce_6 r)
  | N11 wx, N7 wy => let (q, r):= w7_divn1 4 wx wy in (reduce_11 q, reduce_7 r)
  | N11 wx, N8 wy => let (q, r):= w8_divn1 3 wx wy in (reduce_11 q, reduce_8 r)
  | N11 wx, N9 wy => let (q, r):= w9_divn1 2 wx wy in (reduce_11 q, reduce_9 r)
  | N11 wx, N10 wy => let (q, r):= w10_divn1 1 wx wy in (reduce_11 q, reduce_10 r)
  | N11 wx, N11 wy => let (q, r):= w11_div_gt wx wy in (reduce_11 q, reduce_11 r)
  | N11 wx, N12 wy =>
    let wx':= GenBase.extend w11_op.(znz_0W) 0 wx in
    let (q, r):= w12_div_gt wx' wy in
    (reduce_12 q, reduce_12 r)
  | N11 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w11_op.(znz_0W) 1 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | N12 wx, N0 wy => let (q, r):= w0_divn1 12 wx wy in (reduce_12 q, reduce_0 r)
  | N12 wx, N1 wy => let (q, r):= w1_divn1 11 wx wy in (reduce_12 q, reduce_1 r)
  | N12 wx, N2 wy => let (q, r):= w2_divn1 10 wx wy in (reduce_12 q, reduce_2 r)
  | N12 wx, N3 wy => let (q, r):= w3_divn1 9 wx wy in (reduce_12 q, reduce_3 r)
  | N12 wx, N4 wy => let (q, r):= w4_divn1 8 wx wy in (reduce_12 q, reduce_4 r)
  | N12 wx, N5 wy => let (q, r):= w5_divn1 7 wx wy in (reduce_12 q, reduce_5 r)
  | N12 wx, N6 wy => let (q, r):= w6_divn1 6 wx wy in (reduce_12 q, reduce_6 r)
  | N12 wx, N7 wy => let (q, r):= w7_divn1 5 wx wy in (reduce_12 q, reduce_7 r)
  | N12 wx, N8 wy => let (q, r):= w8_divn1 4 wx wy in (reduce_12 q, reduce_8 r)
  | N12 wx, N9 wy => let (q, r):= w9_divn1 3 wx wy in (reduce_12 q, reduce_9 r)
  | N12 wx, N10 wy => let (q, r):= w10_divn1 2 wx wy in (reduce_12 q, reduce_10 r)
  | N12 wx, N11 wy => let (q, r):= w11_divn1 1 wx wy in (reduce_12 q, reduce_11 r)
  | N12 wx, N12 wy => let (q, r):= w12_div_gt wx wy in (reduce_12 q, reduce_12 r)
  | N12 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w12_op.(znz_0W) 0 wx) in
    let (q, r):= (make_op n).(znz_div_gt) wx' wy in
    (reduce_n n q, reduce_n n r)
  | Nn n wx, N0 wy =>
    let wy':= GenBase.extend w0_op.(znz_0W) 11 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N1 wy =>
    let wy':= GenBase.extend w1_op.(znz_0W) 10 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N2 wy =>
    let wy':= GenBase.extend w2_op.(znz_0W) 9 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N3 wy =>
    let wy':= GenBase.extend w3_op.(znz_0W) 8 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N4 wy =>
    let wy':= GenBase.extend w4_op.(znz_0W) 7 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N5 wy =>
    let wy':= GenBase.extend w5_op.(znz_0W) 6 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N6 wy =>
    let wy':= GenBase.extend w6_op.(znz_0W) 5 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N7 wy =>
    let wy':= GenBase.extend w7_op.(znz_0W) 4 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N8 wy =>
    let wy':= GenBase.extend w8_op.(znz_0W) 3 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N9 wy =>
    let wy':= GenBase.extend w9_op.(znz_0W) 2 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N10 wy =>
    let wy':= GenBase.extend w10_op.(znz_0W) 1 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N11 wy =>
    let wy':= GenBase.extend w11_op.(znz_0W) 0 wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, N12 wy =>
    let wy':= wy in
    let (q, r):= w12_divn1 (S n) wx wy' in
    (reduce_n n q, reduce_12 r)
  | Nn n wx, Nn m wy =>
    match extend_to_max w12 n m wx wy with
    | inl wx' =>
      let (q, r):= (make_op m).(znz_div) wx' wy in
      (reduce_n m q, reduce_n m r)
    | inr wy' =>
      let (q, r):= (make_op n).(znz_div) wx wy' in
      (reduce_n n q, reduce_n n r)
    end
  end.

 Definition div_eucl x y :=
  match compare x y with
  | Eq => (one, zero)
  | Lt => (zero, x)
  | Gt => div_gt x y
  end.

 Definition div x y := fst (div_eucl x y).

 Definition w0_mod_gt := w0_op.(znz_mod_gt).
 Definition w1_mod_gt := w1_op.(znz_mod_gt).
 Definition w2_mod_gt := w2_op.(znz_mod_gt).
 Definition w3_mod_gt := w3_op.(znz_mod_gt).
 Definition w4_mod_gt := w4_op.(znz_mod_gt).
 Definition w5_mod_gt := w5_op.(znz_mod_gt).
 Definition w6_mod_gt := w6_op.(znz_mod_gt).
 Definition w7_mod_gt := w7_op.(znz_mod_gt).
 Definition w8_mod_gt := w8_op.(znz_mod_gt).
 Definition w9_mod_gt := w9_op.(znz_mod_gt).
 Definition w10_mod_gt := w10_op.(znz_mod_gt).
 Definition w11_mod_gt := w11_op.(znz_mod_gt).
 Definition w12_mod_gt := w12_op.(znz_mod_gt).

 Definition w0_modn1 :=
  gen_modn1 w0_op.(znz_zdigits) w0_op.(znz_0)
    w0_op.(znz_head0) w0_op.(znz_add_mul_div) w0_op.(znz_div21)
    w0_op.(znz_compare) w0_op.(znz_sub).
 Definition w1_modn1 :=
  gen_modn1 w1_op.(znz_zdigits) w1_op.(znz_0)
    w1_op.(znz_head0) w1_op.(znz_add_mul_div) w1_op.(znz_div21)
    w1_op.(znz_compare) w1_op.(znz_sub).
 Definition w2_modn1 :=
  gen_modn1 w2_op.(znz_zdigits) w2_op.(znz_0)
    w2_op.(znz_head0) w2_op.(znz_add_mul_div) w2_op.(znz_div21)
    w2_op.(znz_compare) w2_op.(znz_sub).
 Definition w3_modn1 :=
  gen_modn1 w3_op.(znz_zdigits) w3_op.(znz_0)
    w3_op.(znz_head0) w3_op.(znz_add_mul_div) w3_op.(znz_div21)
    w3_op.(znz_compare) w3_op.(znz_sub).
 Definition w4_modn1 :=
  gen_modn1 w4_op.(znz_zdigits) w4_op.(znz_0)
    w4_op.(znz_head0) w4_op.(znz_add_mul_div) w4_op.(znz_div21)
    w4_op.(znz_compare) w4_op.(znz_sub).
 Definition w5_modn1 :=
  gen_modn1 w5_op.(znz_zdigits) w5_op.(znz_0)
    w5_op.(znz_head0) w5_op.(znz_add_mul_div) w5_op.(znz_div21)
    w5_op.(znz_compare) w5_op.(znz_sub).
 Definition w6_modn1 :=
  gen_modn1 w6_op.(znz_zdigits) w6_op.(znz_0)
    w6_op.(znz_head0) w6_op.(znz_add_mul_div) w6_op.(znz_div21)
    w6_op.(znz_compare) w6_op.(znz_sub).
 Definition w7_modn1 :=
  gen_modn1 w7_op.(znz_zdigits) w7_op.(znz_0)
    w7_op.(znz_head0) w7_op.(znz_add_mul_div) w7_op.(znz_div21)
    w7_op.(znz_compare) w7_op.(znz_sub).
 Definition w8_modn1 :=
  gen_modn1 w8_op.(znz_zdigits) w8_op.(znz_0)
    w8_op.(znz_head0) w8_op.(znz_add_mul_div) w8_op.(znz_div21)
    w8_op.(znz_compare) w8_op.(znz_sub).
 Definition w9_modn1 :=
  gen_modn1 w9_op.(znz_zdigits) w9_op.(znz_0)
    w9_op.(znz_head0) w9_op.(znz_add_mul_div) w9_op.(znz_div21)
    w9_op.(znz_compare) w9_op.(znz_sub).
 Definition w10_modn1 :=
  gen_modn1 w10_op.(znz_zdigits) w10_op.(znz_0)
    w10_op.(znz_head0) w10_op.(znz_add_mul_div) w10_op.(znz_div21)
    w10_op.(znz_compare) w10_op.(znz_sub).
 Definition w11_modn1 :=
  gen_modn1 w11_op.(znz_zdigits) w11_op.(znz_0)
    w11_op.(znz_head0) w11_op.(znz_add_mul_div) w11_op.(znz_div21)
    w11_op.(znz_compare) w11_op.(znz_sub).
 Definition w12_modn1 :=
  gen_modn1 w12_op.(znz_zdigits) w12_op.(znz_0)
    w12_op.(znz_head0) w12_op.(znz_add_mul_div) w12_op.(znz_div21)
    w12_op.(znz_compare) w12_op.(znz_sub).

 Definition mod_gt x y :=
  match x, y with
  | N0 wx, N0 wy => reduce_0 (w0_mod_gt wx wy)
  | N0 wx, N1 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 0 wx in
    reduce_1 (w1_mod_gt wx' wy)
  | N0 wx, N2 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 1 wx in
    reduce_2 (w2_mod_gt wx' wy)
  | N0 wx, N3 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 2 wx in
    reduce_3 (w3_mod_gt wx' wy)
  | N0 wx, N4 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 3 wx in
    reduce_4 (w4_mod_gt wx' wy)
  | N0 wx, N5 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 4 wx in
    reduce_5 (w5_mod_gt wx' wy)
  | N0 wx, N6 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 5 wx in
    reduce_6 (w6_mod_gt wx' wy)
  | N0 wx, N7 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 6 wx in
    reduce_7 (w7_mod_gt wx' wy)
  | N0 wx, N8 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 7 wx in
    reduce_8 (w8_mod_gt wx' wy)
  | N0 wx, N9 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 8 wx in
    reduce_9 (w9_mod_gt wx' wy)
  | N0 wx, N10 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 9 wx in
    reduce_10 (w10_mod_gt wx' wy)
  | N0 wx, N11 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 10 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N0 wx, N12 wy =>
    let wx':= GenBase.extend w0_op.(znz_0W) 11 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N0 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w0_op.(znz_0W) 12 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N1 wx, N0 wy => reduce_0 (w0_modn1 1 wx wy)
  | N1 wx, N1 wy => reduce_1 (w1_mod_gt wx wy)
  | N1 wx, N2 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 0 wx in
    reduce_2 (w2_mod_gt wx' wy)
  | N1 wx, N3 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 1 wx in
    reduce_3 (w3_mod_gt wx' wy)
  | N1 wx, N4 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 2 wx in
    reduce_4 (w4_mod_gt wx' wy)
  | N1 wx, N5 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 3 wx in
    reduce_5 (w5_mod_gt wx' wy)
  | N1 wx, N6 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 4 wx in
    reduce_6 (w6_mod_gt wx' wy)
  | N1 wx, N7 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 5 wx in
    reduce_7 (w7_mod_gt wx' wy)
  | N1 wx, N8 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 6 wx in
    reduce_8 (w8_mod_gt wx' wy)
  | N1 wx, N9 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 7 wx in
    reduce_9 (w9_mod_gt wx' wy)
  | N1 wx, N10 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 8 wx in
    reduce_10 (w10_mod_gt wx' wy)
  | N1 wx, N11 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 9 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N1 wx, N12 wy =>
    let wx':= GenBase.extend w1_op.(znz_0W) 10 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N1 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w1_op.(znz_0W) 11 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N2 wx, N0 wy => reduce_0 (w0_modn1 2 wx wy)
  | N2 wx, N1 wy => reduce_1 (w1_modn1 1 wx wy)
  | N2 wx, N2 wy => reduce_2 (w2_mod_gt wx wy)
  | N2 wx, N3 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 0 wx in
    reduce_3 (w3_mod_gt wx' wy)
  | N2 wx, N4 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 1 wx in
    reduce_4 (w4_mod_gt wx' wy)
  | N2 wx, N5 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 2 wx in
    reduce_5 (w5_mod_gt wx' wy)
  | N2 wx, N6 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 3 wx in
    reduce_6 (w6_mod_gt wx' wy)
  | N2 wx, N7 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 4 wx in
    reduce_7 (w7_mod_gt wx' wy)
  | N2 wx, N8 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 5 wx in
    reduce_8 (w8_mod_gt wx' wy)
  | N2 wx, N9 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 6 wx in
    reduce_9 (w9_mod_gt wx' wy)
  | N2 wx, N10 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 7 wx in
    reduce_10 (w10_mod_gt wx' wy)
  | N2 wx, N11 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 8 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N2 wx, N12 wy =>
    let wx':= GenBase.extend w2_op.(znz_0W) 9 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N2 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w2_op.(znz_0W) 10 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N3 wx, N0 wy => reduce_0 (w0_modn1 3 wx wy)
  | N3 wx, N1 wy => reduce_1 (w1_modn1 2 wx wy)
  | N3 wx, N2 wy => reduce_2 (w2_modn1 1 wx wy)
  | N3 wx, N3 wy => reduce_3 (w3_mod_gt wx wy)
  | N3 wx, N4 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 0 wx in
    reduce_4 (w4_mod_gt wx' wy)
  | N3 wx, N5 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 1 wx in
    reduce_5 (w5_mod_gt wx' wy)
  | N3 wx, N6 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 2 wx in
    reduce_6 (w6_mod_gt wx' wy)
  | N3 wx, N7 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 3 wx in
    reduce_7 (w7_mod_gt wx' wy)
  | N3 wx, N8 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 4 wx in
    reduce_8 (w8_mod_gt wx' wy)
  | N3 wx, N9 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 5 wx in
    reduce_9 (w9_mod_gt wx' wy)
  | N3 wx, N10 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 6 wx in
    reduce_10 (w10_mod_gt wx' wy)
  | N3 wx, N11 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 7 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N3 wx, N12 wy =>
    let wx':= GenBase.extend w3_op.(znz_0W) 8 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N3 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w3_op.(znz_0W) 9 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N4 wx, N0 wy => reduce_0 (w0_modn1 4 wx wy)
  | N4 wx, N1 wy => reduce_1 (w1_modn1 3 wx wy)
  | N4 wx, N2 wy => reduce_2 (w2_modn1 2 wx wy)
  | N4 wx, N3 wy => reduce_3 (w3_modn1 1 wx wy)
  | N4 wx, N4 wy => reduce_4 (w4_mod_gt wx wy)
  | N4 wx, N5 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 0 wx in
    reduce_5 (w5_mod_gt wx' wy)
  | N4 wx, N6 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 1 wx in
    reduce_6 (w6_mod_gt wx' wy)
  | N4 wx, N7 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 2 wx in
    reduce_7 (w7_mod_gt wx' wy)
  | N4 wx, N8 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 3 wx in
    reduce_8 (w8_mod_gt wx' wy)
  | N4 wx, N9 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 4 wx in
    reduce_9 (w9_mod_gt wx' wy)
  | N4 wx, N10 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 5 wx in
    reduce_10 (w10_mod_gt wx' wy)
  | N4 wx, N11 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 6 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N4 wx, N12 wy =>
    let wx':= GenBase.extend w4_op.(znz_0W) 7 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N4 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w4_op.(znz_0W) 8 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N5 wx, N0 wy => reduce_0 (w0_modn1 5 wx wy)
  | N5 wx, N1 wy => reduce_1 (w1_modn1 4 wx wy)
  | N5 wx, N2 wy => reduce_2 (w2_modn1 3 wx wy)
  | N5 wx, N3 wy => reduce_3 (w3_modn1 2 wx wy)
  | N5 wx, N4 wy => reduce_4 (w4_modn1 1 wx wy)
  | N5 wx, N5 wy => reduce_5 (w5_mod_gt wx wy)
  | N5 wx, N6 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 0 wx in
    reduce_6 (w6_mod_gt wx' wy)
  | N5 wx, N7 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 1 wx in
    reduce_7 (w7_mod_gt wx' wy)
  | N5 wx, N8 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 2 wx in
    reduce_8 (w8_mod_gt wx' wy)
  | N5 wx, N9 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 3 wx in
    reduce_9 (w9_mod_gt wx' wy)
  | N5 wx, N10 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 4 wx in
    reduce_10 (w10_mod_gt wx' wy)
  | N5 wx, N11 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 5 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N5 wx, N12 wy =>
    let wx':= GenBase.extend w5_op.(znz_0W) 6 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N5 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w5_op.(znz_0W) 7 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N6 wx, N0 wy => reduce_0 (w0_modn1 6 wx wy)
  | N6 wx, N1 wy => reduce_1 (w1_modn1 5 wx wy)
  | N6 wx, N2 wy => reduce_2 (w2_modn1 4 wx wy)
  | N6 wx, N3 wy => reduce_3 (w3_modn1 3 wx wy)
  | N6 wx, N4 wy => reduce_4 (w4_modn1 2 wx wy)
  | N6 wx, N5 wy => reduce_5 (w5_modn1 1 wx wy)
  | N6 wx, N6 wy => reduce_6 (w6_mod_gt wx wy)
  | N6 wx, N7 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 0 wx in
    reduce_7 (w7_mod_gt wx' wy)
  | N6 wx, N8 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 1 wx in
    reduce_8 (w8_mod_gt wx' wy)
  | N6 wx, N9 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 2 wx in
    reduce_9 (w9_mod_gt wx' wy)
  | N6 wx, N10 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 3 wx in
    reduce_10 (w10_mod_gt wx' wy)
  | N6 wx, N11 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 4 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N6 wx, N12 wy =>
    let wx':= GenBase.extend w6_op.(znz_0W) 5 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N6 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w6_op.(znz_0W) 6 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N7 wx, N0 wy => reduce_0 (w0_modn1 7 wx wy)
  | N7 wx, N1 wy => reduce_1 (w1_modn1 6 wx wy)
  | N7 wx, N2 wy => reduce_2 (w2_modn1 5 wx wy)
  | N7 wx, N3 wy => reduce_3 (w3_modn1 4 wx wy)
  | N7 wx, N4 wy => reduce_4 (w4_modn1 3 wx wy)
  | N7 wx, N5 wy => reduce_5 (w5_modn1 2 wx wy)
  | N7 wx, N6 wy => reduce_6 (w6_modn1 1 wx wy)
  | N7 wx, N7 wy => reduce_7 (w7_mod_gt wx wy)
  | N7 wx, N8 wy =>
    let wx':= GenBase.extend w7_op.(znz_0W) 0 wx in
    reduce_8 (w8_mod_gt wx' wy)
  | N7 wx, N9 wy =>
    let wx':= GenBase.extend w7_op.(znz_0W) 1 wx in
    reduce_9 (w9_mod_gt wx' wy)
  | N7 wx, N10 wy =>
    let wx':= GenBase.extend w7_op.(znz_0W) 2 wx in
    reduce_10 (w10_mod_gt wx' wy)
  | N7 wx, N11 wy =>
    let wx':= GenBase.extend w7_op.(znz_0W) 3 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N7 wx, N12 wy =>
    let wx':= GenBase.extend w7_op.(znz_0W) 4 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N7 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w7_op.(znz_0W) 5 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N8 wx, N0 wy => reduce_0 (w0_modn1 8 wx wy)
  | N8 wx, N1 wy => reduce_1 (w1_modn1 7 wx wy)
  | N8 wx, N2 wy => reduce_2 (w2_modn1 6 wx wy)
  | N8 wx, N3 wy => reduce_3 (w3_modn1 5 wx wy)
  | N8 wx, N4 wy => reduce_4 (w4_modn1 4 wx wy)
  | N8 wx, N5 wy => reduce_5 (w5_modn1 3 wx wy)
  | N8 wx, N6 wy => reduce_6 (w6_modn1 2 wx wy)
  | N8 wx, N7 wy => reduce_7 (w7_modn1 1 wx wy)
  | N8 wx, N8 wy => reduce_8 (w8_mod_gt wx wy)
  | N8 wx, N9 wy =>
    let wx':= GenBase.extend w8_op.(znz_0W) 0 wx in
    reduce_9 (w9_mod_gt wx' wy)
  | N8 wx, N10 wy =>
    let wx':= GenBase.extend w8_op.(znz_0W) 1 wx in
    reduce_10 (w10_mod_gt wx' wy)
  | N8 wx, N11 wy =>
    let wx':= GenBase.extend w8_op.(znz_0W) 2 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N8 wx, N12 wy =>
    let wx':= GenBase.extend w8_op.(znz_0W) 3 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N8 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w8_op.(znz_0W) 4 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N9 wx, N0 wy => reduce_0 (w0_modn1 9 wx wy)
  | N9 wx, N1 wy => reduce_1 (w1_modn1 8 wx wy)
  | N9 wx, N2 wy => reduce_2 (w2_modn1 7 wx wy)
  | N9 wx, N3 wy => reduce_3 (w3_modn1 6 wx wy)
  | N9 wx, N4 wy => reduce_4 (w4_modn1 5 wx wy)
  | N9 wx, N5 wy => reduce_5 (w5_modn1 4 wx wy)
  | N9 wx, N6 wy => reduce_6 (w6_modn1 3 wx wy)
  | N9 wx, N7 wy => reduce_7 (w7_modn1 2 wx wy)
  | N9 wx, N8 wy => reduce_8 (w8_modn1 1 wx wy)
  | N9 wx, N9 wy => reduce_9 (w9_mod_gt wx wy)
  | N9 wx, N10 wy =>
    let wx':= GenBase.extend w9_op.(znz_0W) 0 wx in
    reduce_10 (w10_mod_gt wx' wy)
  | N9 wx, N11 wy =>
    let wx':= GenBase.extend w9_op.(znz_0W) 1 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N9 wx, N12 wy =>
    let wx':= GenBase.extend w9_op.(znz_0W) 2 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N9 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w9_op.(znz_0W) 3 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N10 wx, N0 wy => reduce_0 (w0_modn1 10 wx wy)
  | N10 wx, N1 wy => reduce_1 (w1_modn1 9 wx wy)
  | N10 wx, N2 wy => reduce_2 (w2_modn1 8 wx wy)
  | N10 wx, N3 wy => reduce_3 (w3_modn1 7 wx wy)
  | N10 wx, N4 wy => reduce_4 (w4_modn1 6 wx wy)
  | N10 wx, N5 wy => reduce_5 (w5_modn1 5 wx wy)
  | N10 wx, N6 wy => reduce_6 (w6_modn1 4 wx wy)
  | N10 wx, N7 wy => reduce_7 (w7_modn1 3 wx wy)
  | N10 wx, N8 wy => reduce_8 (w8_modn1 2 wx wy)
  | N10 wx, N9 wy => reduce_9 (w9_modn1 1 wx wy)
  | N10 wx, N10 wy => reduce_10 (w10_mod_gt wx wy)
  | N10 wx, N11 wy =>
    let wx':= GenBase.extend w10_op.(znz_0W) 0 wx in
    reduce_11 (w11_mod_gt wx' wy)
  | N10 wx, N12 wy =>
    let wx':= GenBase.extend w10_op.(znz_0W) 1 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N10 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w10_op.(znz_0W) 2 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N11 wx, N0 wy => reduce_0 (w0_modn1 11 wx wy)
  | N11 wx, N1 wy => reduce_1 (w1_modn1 10 wx wy)
  | N11 wx, N2 wy => reduce_2 (w2_modn1 9 wx wy)
  | N11 wx, N3 wy => reduce_3 (w3_modn1 8 wx wy)
  | N11 wx, N4 wy => reduce_4 (w4_modn1 7 wx wy)
  | N11 wx, N5 wy => reduce_5 (w5_modn1 6 wx wy)
  | N11 wx, N6 wy => reduce_6 (w6_modn1 5 wx wy)
  | N11 wx, N7 wy => reduce_7 (w7_modn1 4 wx wy)
  | N11 wx, N8 wy => reduce_8 (w8_modn1 3 wx wy)
  | N11 wx, N9 wy => reduce_9 (w9_modn1 2 wx wy)
  | N11 wx, N10 wy => reduce_10 (w10_modn1 1 wx wy)
  | N11 wx, N11 wy => reduce_11 (w11_mod_gt wx wy)
  | N11 wx, N12 wy =>
    let wx':= GenBase.extend w11_op.(znz_0W) 0 wx in
    reduce_12 (w12_mod_gt wx' wy)
  | N11 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w11_op.(znz_0W) 1 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | N12 wx, N0 wy => reduce_0 (w0_modn1 12 wx wy)
  | N12 wx, N1 wy => reduce_1 (w1_modn1 11 wx wy)
  | N12 wx, N2 wy => reduce_2 (w2_modn1 10 wx wy)
  | N12 wx, N3 wy => reduce_3 (w3_modn1 9 wx wy)
  | N12 wx, N4 wy => reduce_4 (w4_modn1 8 wx wy)
  | N12 wx, N5 wy => reduce_5 (w5_modn1 7 wx wy)
  | N12 wx, N6 wy => reduce_6 (w6_modn1 6 wx wy)
  | N12 wx, N7 wy => reduce_7 (w7_modn1 5 wx wy)
  | N12 wx, N8 wy => reduce_8 (w8_modn1 4 wx wy)
  | N12 wx, N9 wy => reduce_9 (w9_modn1 3 wx wy)
  | N12 wx, N10 wy => reduce_10 (w10_modn1 2 wx wy)
  | N12 wx, N11 wy => reduce_11 (w11_modn1 1 wx wy)
  | N12 wx, N12 wy => reduce_12 (w12_mod_gt wx wy)
  | N12 wx, Nn n wy =>
    let wx':= extend n w12 (GenBase.extend w12_op.(znz_0W) 0 wx) in
    reduce_n n ((make_op n).(znz_mod_gt) wx' wy)
  | Nn n wx, N0 wy =>
    let wy':= GenBase.extend w0_op.(znz_0W) 11 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N1 wy =>
    let wy':= GenBase.extend w1_op.(znz_0W) 10 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N2 wy =>
    let wy':= GenBase.extend w2_op.(znz_0W) 9 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N3 wy =>
    let wy':= GenBase.extend w3_op.(znz_0W) 8 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N4 wy =>
    let wy':= GenBase.extend w4_op.(znz_0W) 7 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N5 wy =>
    let wy':= GenBase.extend w5_op.(znz_0W) 6 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N6 wy =>
    let wy':= GenBase.extend w6_op.(znz_0W) 5 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N7 wy =>
    let wy':= GenBase.extend w7_op.(znz_0W) 4 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N8 wy =>
    let wy':= GenBase.extend w8_op.(znz_0W) 3 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N9 wy =>
    let wy':= GenBase.extend w9_op.(znz_0W) 2 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N10 wy =>
    let wy':= GenBase.extend w10_op.(znz_0W) 1 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N11 wy =>
    let wy':= GenBase.extend w11_op.(znz_0W) 0 wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, N12 wy =>
    let wy':= wy in
    reduce_12 (w12_modn1 (S n) wx wy')
  | Nn n wx, Nn m wy =>
    match extend_to_max w12 n m wx wy with
    | inl wx' =>
      reduce_n m ((make_op m).(znz_mod_gt) wx' wy)
    | inr wy' =>
      reduce_n n ((make_op n).(znz_mod_gt) wx wy')
    end
  end.

 Definition modulo x y := 
  match compare x y with
  | Eq => zero
  | Lt => x
  | Gt => mod_gt x y
  end.

 Definition digits x :=
  match x with
  | N0 _ => w0_op.(znz_digits)
  | N1 _ => w1_op.(znz_digits)
  | N2 _ => w2_op.(znz_digits)
  | N3 _ => w3_op.(znz_digits)
  | N4 _ => w4_op.(znz_digits)
  | N5 _ => w5_op.(znz_digits)
  | N6 _ => w6_op.(znz_digits)
  | N7 _ => w7_op.(znz_digits)
  | N8 _ => w8_op.(znz_digits)
  | N9 _ => w9_op.(znz_digits)
  | N10 _ => w10_op.(znz_digits)
  | N11 _ => w11_op.(znz_digits)
  | N12 _ => w12_op.(znz_digits)
  | Nn n _ => (make_op n).(znz_digits)
  end.

 Definition gcd_gt_body a b cont :=
  match compare b zero with
  | Gt =>
    let r := mod_gt a b in
    match compare r zero with
    | Gt => cont r (mod_gt b r)
    | _ => b
    end
  | _ => a
  end.

 Fixpoint gcd_gt (p:positive) (cont:t->t->t) (a b:t) {struct p} : t :=
  gcd_gt_body a b
    (fun a b =>
       match p with
       | xH => cont a b
       | xO p => gcd_gt p (gcd_gt p cont) a b
       | xI p => gcd_gt p (gcd_gt p cont) a b
       end).

 Definition gcd_cont a b :=
  match compare one b with
  | Eq => one
  | _ => a
  end.

 Definition gcd a b :=
  match compare a b with
  | Eq => a
  | Lt => gcd_gt (digits b) gcd_cont b a
  | Gt => gcd_gt (digits a) gcd_cont a b
  end.

 Definition of_pos x :=
  let h := nat_of_P (pheight x) in
  match h with
  | O => reduce_0 (snd (w0_op.(znz_of_pos) x))
  | (S O) => reduce_1 (snd (w1_op.(znz_of_pos) x))
  | (S (S O)) => reduce_2 (snd (w2_op.(znz_of_pos) x))
  | (S (S (S O))) => reduce_3 (snd (w3_op.(znz_of_pos) x))
  | (S (S (S (S O)))) => reduce_4 (snd (w4_op.(znz_of_pos) x))
  | (S (S (S (S (S O))))) => reduce_5 (snd (w5_op.(znz_of_pos) x))
  | (S (S (S (S (S (S O)))))) => reduce_6 (snd (w6_op.(znz_of_pos) x))
  | (S (S (S (S (S (S (S O))))))) => reduce_7 (snd (w7_op.(znz_of_pos) x))
  | (S (S (S (S (S (S (S (S O)))))))) => reduce_8 (snd (w8_op.(znz_of_pos) x))
  | (S (S (S (S (S (S (S (S (S O))))))))) => reduce_9 (snd (w9_op.(znz_of_pos) x))
  | (S (S (S (S (S (S (S (S (S (S O)))))))))) => reduce_10 (snd (w10_op.(znz_of_pos) x))
  | (S (S (S (S (S (S (S (S (S (S (S O))))))))))) => reduce_11 (snd (w11_op.(znz_of_pos) x))
  | (S (S (S (S (S (S (S (S (S (S (S (S O)))))))))))) => reduce_12 (snd (w12_op.(znz_of_pos) x))
  | _ =>
    let n := minus h 13 in
    reduce_n n (snd ((make_op n).(znz_of_pos) x))
  end.

 Definition of_N x :=
  match x with
  | BinNat.N0 => zero
  | Npos p => of_pos p
  end.

 Definition to_Z x :=
  match x with
  | N0 wx => w0_op.(znz_to_Z) wx
  | N1 wx => w1_op.(znz_to_Z) wx
  | N2 wx => w2_op.(znz_to_Z) wx
  | N3 wx => w3_op.(znz_to_Z) wx
  | N4 wx => w4_op.(znz_to_Z) wx
  | N5 wx => w5_op.(znz_to_Z) wx
  | N6 wx => w6_op.(znz_to_Z) wx
  | N7 wx => w7_op.(znz_to_Z) wx
  | N8 wx => w8_op.(znz_to_Z) wx
  | N9 wx => w9_op.(znz_to_Z) wx
  | N10 wx => w10_op.(znz_to_Z) wx
  | N11 wx => w11_op.(znz_to_Z) wx
  | N12 wx => w12_op.(znz_to_Z) wx
  | Nn n wx => (make_op n).(znz_to_Z) wx
  end.

End Make.