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
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
|
\input texinfo @c -*-texinfo-*-
@c
@c $Id$
@c
@c %**start of header
@setfilename ProofGeneral.info
@settitle Proof General
@setchapternewpage odd
@paragraphindent 0
@c A flag for whether to include the front image in the
@c DVI file. You can download the front image from
@c http://www.dcs.ed.ac.uk/~proofgen/ProofGeneral.eps.gz
@c then put it into this directory and 'make dvi'
@c will set the flag below automatically.
@set haveeps
@c
@iftex
@afourpaper
@end iftex
@c %**end of header
@c
@c TODO, priority order
@c . polish mark-up
@c . add more index entries
@c . screenshots might be nice (one day)
@c . follow conventions:
@c key-binding or key binding ?
@c references:
@c @xref{node} blah start of sentence: See [ref]
@c blah (@pxref{node}) blah bla (see [ref]), best at end of sentence
@c @ref{node} without "see". Careful for info.
@c
@c IMPORTANT NOTE ABOUT THIS TEXINFO FILE:
@c I've tried keep full node lines *out* of this file because Emacs makes a
@c mess of updating them and they are a nuisance to do by hand.
@c Instead, rely on makeinfo and friends to do the equivalent job.
@c For this to work, we must follow each node
@c immediately with a section command, i.e.:
@c
@c @node node-name
@c <section-command>
@c
@c And each section with lower levels must have a menu command in
@c it. Menu updating with Emacs is a bit better than node updating,
@c but tends to delete the first section of the file in XEmacs!
@c (it's better in FSF Emacs at the time of writing).
@c
@set version 3.0
@set xemacsversion 21.1
@set fsfversion 20.4
@set last-update November 1999
@set rcsid $Id$
@ifinfo
@format
START-INFO-DIR-ENTRY
* Proof General: (ProofGeneral). Organize your proofs with Emacs!
END-INFO-DIR-ENTRY
@end format
@end ifinfo
@c
@c MACROS
@c
@c define one here for a command with a keybinding?
@c
@c I like the idea, but it's maybe against the texinfo
@c style to fix together a command and its keybinding.
@c merge functions and variables into concept index.
@c @syncodeindex fn cp
@c @syncodeindex vr cp
@c merge functions into variables index
@c @syncodeindex fn vr
@finalout
@titlepage
@title Proof General
@subtitle Organise your proofs with Emacs!
@subtitle Proof General @value{version}
@subtitle @value{last-update}
@ifset haveeps
@iftex
@c @vskip 1cm
@c The .eps file takes 8.4M! A pity texi can't seem
@c to deal with gzipped files? (goes down to 1.7M).
@c But this still seems too much to put into the
@c PG distribution just for an image on the manual page,
@c so we take it out for now.
@c Ideally would like some way of generating eps from
@c the .jpg file.
@image{ProofGeneral}
@c FIXME: for html, just do @c image ProofGeneral, it
@c gets confused by the braces.
@c FIXME: doesn't work for PDF image at the moment.
@end iftex
@end ifset
@author David Aspinall with H. Goguen, T. Kleymann and D. Sequeira
@page
@vskip 0pt plus 1filll
This manual and the program Proof General are
Copyright @copyright{} 1998 Proof General team, LFCS Edinburgh.
@c
@c COPYING NOTICE
@c
@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries copying permission notice
identical to this one except for the removal of this paragraph (this
paragraph not being relevant to the printed manual).
@end ignore
@sp 2
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
@sp 2
This manual documents Proof General, Version @value{version}, for use
with XEmacs @value{xemacsversion} and FSF GNU Emacs @value{fsfversion}
or later versions.
Version control stamp: @code{@value{rcsid}}
@end titlepage
@page
@ifinfo
@node Top
@top Proof General
This file documents version @value{version} of @b{Proof General}, a
generic Emacs interface for proof assistants.
Proof General @value{version} has been tested with XEmacs
@value{xemacsversion} and FSF GNU Emacs @value{fsfversion}. It is
supplied ready customized for the proof assistants Coq, Lego, and
Isabelle.
@menu
* Preface::
* Introducing Proof General::
* Basic Script Management::
* Advanced Script Management::
* Support for other Packages::
* Customizing Proof General::
* LEGO Proof General::
* Coq Proof General::
* Isabelle Proof General::
* Adapting Proof General to Other Provers::
* Internals of Proof General::
* Obtaining and Installing::
* Known bugs and workarounds::
* Plans and ideas::
* References::
* Function Index::
* Variable Index::
* Keystroke Index::
* Concept Index::
@end menu
@end ifinfo
@node Preface
@unnumbered Preface
@menu
* Credits::
* History::
* Latest news::
@end menu
@node Credits
@unnumberedsec Credits
@cindex @code{lego-mode}
@cindex maintenance
The main developers of Proof General are
@itemize @bullet
@item @b{David Aspinall},
@item @b{Healfdene Goguen},
@item @b{Thomas Kleymann} and
@item @b{Dilip Sequeira}.
@end itemize
LEGO Proof General (the successor of @code{lego-mode}) was crafted by
Thomas Kleymann and Dilip Sequeira.
@c
It is presently maintained by
Paul Callaghan @i{<P.C.Callaghan@@durham.ac.uk>}.
@c
Coq Proof General was crafted by Healfdene Goguen, with
later contributions from Patrick Loiseleur.
It is now maintained by Pierre Courtieu <courtieu@@lri.fr>
@c
Isabelle Proof General was crafted and is being maintained by David
Aspinall @i{<isabelle@@dcs.ed.ac.uk>}. It has benefited greatly
from code and suggestions by Markus Wenzel, who crafted and maintains
Isabelle/Isar Proof General. David von Oheimb supplied patches
for x-symbol support.
The generic base for Proof General was developed by Kleymann, Sequeira,
Goguen and Aspinall (in order of appearance). It follows some of the
ideas used in Project @uref{http://www.inria.fr/croap/,CROAP}. The Proof
General project was initiated in 1994 and coordinated until October 1998
by Thomas Kleymann. Since October 1998, David Aspinall is in charge of
Proof General.
An early version of this manual was prepared by Dilip. The present
version was written by David and Thomas, and Healf supplied some text
for the section on Coq Proof General.
The project has benefited from funding by EPSRC (Applications of a Type
Theory Based Proof Assistant) and the EC (Types for Proofs and Programs).
During the development of Proof General, the following people helped
by providing feedback, testing, or code:
Pascal Brisset,
Rod Burstall,
Paul Callaghan,
Martin Hofmann,
James McKinna,
David von Oheimb,
and Markus Wenzel. Thanks to all of you!
@node Latest news
@unnumberedsec Latest news
@cindex news
Proof General 3.0 offers many enhancements over 2.x releases.
First, there are usability improvements. The toolbar has twice as many
buttons, and now includes all of the useful functions used during proof
which were previously hidden on the menu, or even only available as key
presses. The menu has been redesigned and coordinated with the toolbar.
User options have been re-organized.
Second, there are improvements, extensions, and bug fixes in the core
code. Proofs which are unfinished and not explicitly closed by a
``save'' type command are supported by the core, if they are allowed by
the prover. The design of switching the active scripting buffer has
been streamlined. The proof shell filter has been optimized to give
hungry proof assistants a better share of CPU cycles. Proof General is
easier to adapt to new provers --- it fails more gracefully (or not at
all!) when particular configuration variables are unset.
This manual has been updated accordingly. It also has a better
description of how to add support for a new prover.
See the @code{CHANGES} file in the distribution for more information.
Developers should check the @code{ChangeLog} in the developer's release
for detailed comments on internal changes.
Most of the work has been done by David Aspinall, with help from Markus
Wenzel for Isabelle support and Patrick Loiseleur for Coq support.
Markus has also provided support for his Isar language, a new proof
language for Isabelle. David von Oheimb helped to develop and debug the
generic version of his X-Symbol patch originally for Isabelle.
A new instantiation of Proof General is being worked on for
@emph{Plastic}, a proof assistant being developed at the University of
Durham.
Proof General has a @uref{http://zermelo.dcs.ed.ac.uk/home/proofgen,home
page} hosted at Edinburgh. Visit this page for more news!
@node History
@unnumberedsec History
@cindex @code{lego-mode}
@cindex history
It all started some time in 1994. There was no Emacs interface for LEGO.
Back then, Emacs militants worked directly with the Emacs shell to
interact with the LEGO system.
David Aspinall convinced Thomas Kleymann that programming in
Emacs Lisp wasn't so difficult after all. In fact, Aspinall had already
implemented an Emacs interface for Isabelle with bells and whistles,
called @uref{http://www.dcs.ed.ac.uk/home/da/Isamode,Isamode}. Soon
after, the package @code{lego-mode} was born. Users were able to develop
proof scripts in one buffer. Support was provided to automatically send
parts of the script to the proof process. The last official version with
the name @code{lego-mode} (1.9) was released in May 1995.
@cindex proof by pointing
@cindex CtCoq
@cindex Centaur
The interface project really took off the ground in November 1996. Yves
Bertot had been working on a sophisticated user interface for the Coq
system (CtCoq) based on the generic environment Centaur. He visited the
Edinburgh LEGO group for a week to transfer proof-by-pointing
technology. Even though proof-by-pointing is an inherently
structure-conscious algorithm, within a week, Yves Bertot, Dilip Sequeira
and Thomas Kleymann managed to implement a first prototype of
proof-by-pointing in the Emacs interface for LEGO [BKS97].
@cindex structure editor
@cindex script management
Perhaps we could reuse even more of the CtCoq system. It being a
structure editor did no longer seem to be such an obstacle. Moreover,
to conveniently use proof-by-pointing in actual developments, one would
need better support for script management.
@cindex generic
In 1997, Dilip Sequeira implemented script management in our Emacs
interface for LEGO following the recipe in
[BT98]. Inspired by the project CROAP, the
implementation made some effort to be generic. A working prototype was
demonstrated at UITP'97.
In October 1997, Healfdene Goguen ported @code{lego-mode} to Coq. Part
of the generic code in the @code{lego} package was outsourced (and made
more generic) in a new generic package called @code{proof}. Dilip
Sequeira provided some LEGO-specific support for handling multiple files
and wrote a few manual pages. The system was reasonably robust and we
shipped out the package to friends.
In June 1998, David Aspinall reentered the picture by providing an
instantiation for Isabelle. Actually, our previous version wasn't quite
as generic as we had hoped. Whereas LEGO and Coq are similar systems in
many ways, Isabelle was really a different beast. Fierce reengineering
and various usability improvements were provided by David Aspinall and
Thomas Kleymann to make it easier to instantiate to new proof
systems. The major technical improvement was a truly generic extension
of script management to work across multiple files.
It was time to come up with a better name than just @code{proof}
mode. David Aspinall suggested @emph{Proof General} and set about
reorganizing the file structure to disentangle the Proof General project
from LEGO at last. He cooked up some images and bolted on a toolbar, so
a naive user can replay proofs without knowing a proof assistant
language or even Emacs hot-keys. He also designed some web pages, and
wrote most of this new manual.
Proof General 2.0 was the first official release of the improved
program.
Why not adapt Proof General to your favourite proof assitant?
@c
@c CHAPTER: Introduction
@c
@node Introducing Proof General
@chapter Introducing Proof General
@cindex proof assistant
@cindex Proof General
@c would like the logo on the title page really but
@c it doesn't seem to work there for html.
@ifhtml
<IMG SRC="ProofGeneral.jpg" ALT="[ Proof General logo ]" >
@end ifhtml
@dfn{Proof General} is a generic Emacs interface for interactive proof
assistants,@footnote{A @dfn{proof assistant} is a computerized helper for
developing mathematical proofs. For short, we sometimes call it a
@dfn{prover}, although we always have in mind an interactive system
rather than a fully automated theorem prover.} developed at the LFCS in
the University of Edinburgh. It works best under XEmacs, but can also
be used with FSF GNU Emacs.
You do not have to be an Emacs militant to use Proof General!
The interface is designed to be very easy to use. You develop your
proof script@footnote{A @dfn{proof script} is a sequence of commands
which constructs a proof, usually stored in a file.}
in-place rather than line-by-line and later reassembling the pieces.
Proof General keeps track of which proof steps have been processed by
the prover, and prevents you editing them accidently. You can undo
steps as usual.
The main aim of Proof General is to provide a powerful and configurable
Emacs mode to help user-interaction with numerous interactive proof
assistants. Please help us with this aim! Configure Proof General for
your own proof assistant, by adding features at the generic level of
Proof General wherever possible. See @ref{Adapting Proof General to Other
Provers} for more details, and send ideas, comments, patches, and code
to @code{proofgen@@dcs.ed.ac.uk}.
@menu
* Quick start guide::
* Features of Proof General::
* Supported proof assistants::
* Prerequisites for this manual::
@end menu
@node Quick start guide
@section Quick start guide
Proof General may have been installed for you already. If so, when you
visit a proof script file for your proof assistant, the corresponding
Proof General mode will be invoked automatically:
@multitable @columnfractions .3 .3 .4
@item @b{Prover} @tab @b{Extensions} @tab @b{Modes}
@item LEGO @tab @file{.l} @tab @code{lego-mode}
@item Coq @tab @file{.v} @tab @code{coq-mode}
@item Isabelle @tab @file{.thy},@file{.ML} @tab @code{isa-mode}
@end multitable
You can also invoke the mode command directly, e.g., type
@kbd{M-x lego-mode}, to turn a buffer into a lego script buffer.
You'll find commands to process the proof script are available from the
toolbar, menus, and keyboard. Type @kbd{C-h m} to get a list of the
keyboard shortcuts for the current mode. The commands available should
be easy to understand, but the rest of this manual describes them in
some detail.
The proof assistant itself is started automatically inside Emacs as an
"inferior" process when you ask for some of the proof script to be
processed. You can also start the proof assistant directly from the
menu command "Start proof assistant".
To follow an example use of Proof General on a LEGO proof, see
@ref{Walkthrough example in LEGO}. If you know the syntax for proof
scripts in another theorem prover, you can easily adapt the details
given there.
If Proof General has not already been installed, you should insert the
line:
@lisp
(load "@var{proof-general-home}/generic/proof-site.el")
@end lisp
into your @file{~/.emacs} file, where @var{proof-general-home} is the
top-level directory that was created when Proof General was unpacked.
@xref{Obtaining and Installing}, if you need more
information.
@node Features of Proof General
@section Features of Proof General
@cindex Features
@cindex Why use Proof General?
Why would you want to use Proof General?
Here is an outline of its main features.
@itemize @bullet
@item @i{Simplified communication}@*
The proof assistant's shell is normally hidden from the user.
Communication takes place via two or three buffers. The @dfn{script
buffer} holds input, the commands to construct a proof. The @dfn{goals
buffer} displays the current list of subgoals to be solved. The
@dfn{response buffer} displays other output from the proof assistant.
This means that the user normally only sees the output from the most recent proof
step, rather than a screen full of output from the proof assistant.
However, the user can still access the proof assistant shell to examine
it and run commands.
@c Optionally, the goals buffer and script buffer can be identified.
For more details, see @ref{Basic Script Management}, @ref{Script
buffers} and @ref{Summary of Proof General buffers}.
@item @i{Script management}@*
Proof General colours proof script regions blue when they have already
been processed by the prover, and colours regions red when the prover is
currently processing them. The appearance of Emacs buffers always
matches the proof assistant's state. Coloured parts of the buffer cannot
be edited. Proof General has functions for @emph{asserting} or
@emph{retracting} parts of a proof script, which alters the coloured
regions.
For more details, see @ref{Basic Script Management},
@ref{Script processing commands}.
and @ref{Advanced Script Management}.
@item @i{Script editing mode}@*
Proof General provides useful facilities for editing proof scripts,
including syntax hilighting and a menu to jump to particular goals,
definitions, or declarations.
Special editing functions send lines of proof script to the proof
assistant, or undo previous proof steps.
For more details, see @ref{Script editing commands}
and @ref{Script processing commands}.
@item @i{Toolbar and menus}@*
A script buffer has a toolbar with navigation buttons for processing
parts of the proof script. A menu provides further functions for
operations in the proof assistant, as well as customization of Proof
General.
For more details, see @ref{Toolbar commands}, @ref{Proof assistant
commands}, and @ref{Customizing Proof General}.
@c not yet
@c @item @i{Proof by pointing}
@end itemize
@node Supported proof assistants
@section Supported proof assistants
Proof General comes ready-customised for these proof assistants:
@c FLAG VERSIONS HERE
@itemize @bullet
@item
@b{LEGO Proof General} for LEGO Version 1.3.1@*
@c written by Thomas Kleymann and Dilip Sequeira.
@c
All features of Proof General are supported.
For more details @xref{LEGO Proof General}.
@item
@b{Coq Proof General} for Coq Version 6.3@*
@c written by Healfdene Goguen.
@c
All features of Proof General are supported except multiple files.
For more details @xref{Coq Proof General}.
@item
@b{Isabelle Proof General} for Isabelle 99@*
@c written by David Aspinall.
All features of Proof General are supported, except for an external tags
program. Isabelle Proof General handles theory files as well as ML
(proof script files), and has an extensive theory file editing mode
taken from @uref{http://www.dcs.ed.ac.uk/home/da/Isamode,Isamode}.
For more details @xref{Isabelle Proof General}.
@end itemize
Proof General is designed to be generic, so if you know a little bit of
Emacs Lisp, you can make
@itemize @bullet
@item
@b{Your Proof General} for your favourite proof assistant.@*
For more details of how to make Proof General work
with another proof assistant,
@xref{Adapting Proof General to Other Provers}.
@end itemize
@node Prerequisites for this manual
@section Prerequisites for this manual
This manual assumes that you understand a little about using Emacs, for
example, switching between buffers using @kbd{C-x b} and understanding
that key sequences like @kbd{C-x b} mean "control-x followed by b".
The manual also assumes you have a basic understanding of your proof
assistant and the language and files it uses for proof scripts. But
even without this, Proof General is not useless: you can use the
interface to @emph{replay} proof scripts for any proof assistant without
knowing how to start it up or issue commands, etc. This is the beauty
of a common interface mechanism.
To get more from Proof General and adapt it to your liking, it helps to
know a little bit about how Emacs lisp packages can be customized via
the Customization mechanism. It's really easy to use. For details,
@xref{How to customize}, and @inforef{Easy customization, ,(xemacs)}.
To get the absolute most from Proof General, to improve it or to adapt
it for new provers, you'll need to know a little bit of Emacs lisp.
Emacs is self-documenting, so you can begin from @kbd{C-h} and find out
everything! Here are some useful commands:
@table @asis
@item @kbd{C-h i}
@code{info}
@item @kbd{C-h m}
@code{describe-mode}
@item @kbd{C-h b}
@code{describe-bindings}
@item @kbd{C-h f}
@code{describe-function}
@item @kbd{C-h v}
@code{describe-variable}
@end table
Most of this manual covers the user-level view and customization of
Proof General. Towards the end we consider adapting Proof General to
new proof assistants, and document some of the internals of Proof
General. The manual concludes with some credits and references.
See the table of contents for details.
@c
@c CHAPTER: Basic Script Management
@c
@node Basic Script Management
@chapter Basic Script Management
This chapter is an introduction to using the script management
facilities of Proof General. We begin with a quick walkthrough example,
then describe the concepts and functions in more detail.
@menu
* Walkthrough example in LEGO::
* Proof scripts::
* Script buffers::
* Summary of Proof General buffers::
* Script editing commands::
* Script processing commands::
* Toolbar commands::
* Proof assistant commands::
@end menu
@node Walkthrough example in LEGO
@section Walkthrough example in LEGO
Here's a short example in LEGO to see how script management is used.
The file you are asked to type below is included in the distribution as
@file{lego/example.l}. If you're not using LEGO, substitute some lines
from a simple proof for your proof assistant, or consult the example
file provided with Proof General.
First, find a new file by doing @kbd{C-x C-f} and typing as the filename
@file{example.l}. This should load LEGO Proof General and the
toolbar and Proof General menus will appear. This walkthrough is
keyboard based, although you could easily use the toolbar and menu
functions instead.
Now turn on @dfn{electric terminator minor mode} by typing @kbd{C-c ;} and
enter:
@lisp
Module example Import lib_logic;
@end lisp
electric terminator minor mode sends commands to the proof assistant as
you type them. The command should now be lit in pink (or inverse video
if you don't have a colour display). As LEGO imports each module, a
line will appear in the minibuffer showing the creation of context
marks. Eventually the command should turn blue, indicating that LEGO has
successfully processed it. Then type (on a separate line if you like):
@lisp
Goal bland_commutes: @{A,B:Prop@} (and A B) -> (and B A);
@end lisp
The goal should be echoed in the goals buffer.
@lisp
Intros;
@end lisp
Whoops! That was the wrong command. Press @kbd{C-c C-u} to pretend that didn't happen.
@lisp
intros; andI;
@end lisp
A proof summary will appear in the goals buffer.
@c We could solve the goal by pointing now, but we'll stay with the keyboard.
@lisp
Refine H; intros; Immed; Refine H; intros; Immed;
@end lisp
finishes the Goal.
@lisp
Save bland_commutes;
@end lisp
Moving the mouse pointer over the locked region now reveals that the
entire proof has been aggregated into a single segment. Suppose we
decide to call the goal something more sensible. Moving the cursor up
into the locked region, somewhere between @samp{Goal} and @samp{Save},
we enter @kbd{C-c C-RET}. The segment is transferred back into the
editing region. Now we correct the goal name, move the cursor to the end
of the buffer, and type @kbd{C-c C-RET}. Proof mode queues the commands
for processing and executes them.
@node Proof scripts
@section Proof scripts
@cindex proof script
@cindex scripting
A @dfn{proof script} is a sequence of commands which constructs
definitions, declarations and proofs in a proof assistant. Proof General
is designed to work with text-based @i{interactive} proof assistants,
where the mode of working is usually a dialogue between the human and
the proof assistant.
Primitive interfaces for proof assistants simply present a shell-like
view of this dialogue: the human repeatedly types commands to the shell
until the proof is completed. The system responds at each step, perhaps
with a new list of subgoals to be solved, or perhaps with a failure
report. Proof General manages the dialogue to only show the human the
information which is relevant at each step.
Often we want to keep a record of the proof commands used to prove a
theorem, to build up a library of proved results. An easy way to store
a proof is to keep a text file which contains a proof script; the proof
assistant usually provides facilities to read a proof script from a file
instead of the terminal. Using the file, we can @dfn{replay} the proof
script to prove the theorem again.
@c Re-playing a proof script is a non-interactive procedure,
@c since it is supposed to succeed.
Using only a primitive shell interface, it can be tedious to construct
proof scripts with cut-and-paste. Proof General helps out by issuing
commands directly from a proof script file, while it is being written
and edited. Proof General can also be used conveniently to replay a
proof step-by-step, to see the progress at each stage.
@c developing them in proof script files.
@dfn{Scripting} is the process of building up a proof script file or
replaying a proof. When scripting, Proof General sends proof commands
to the proof assistant one at a time, and prevents you from editing
commands which have been successfully completed by the proof assistant.
Regions of the proof script are analysed based on syntax and the
behaviour of the proof assistant after each proof command.
@node Script buffers
@section Script buffers
@cindex script buffer
@cindex proof script mode
A @dfn{script buffer} is a buffer displaying a proof script. Its Emacs
mode is particular to the proof assistant you are using (but it inherits
from @dfn{proof-mode}).
A script buffer is divided into three regions: @emph{locked},
@emph{queue} and @emph{editing}. The proof commands
in the script buffer can include a number of
@emph{Goal-save sequences}.
@menu
* Locked queue and editing regions::
* Goal-save sequences::
* Active scripting buffer::
@end menu
@node Locked queue and editing regions
@subsection Locked, queue, and editing regions
@cindex Locked region
@cindex Queue region
@cindex Editing region
@cindex blue text
@cindex pink text
The three regions that a script buffer can be divided into are: @c
@itemize @bullet
@item The @emph{locked} region, which appears in blue (underlined on monochrome
displays) and contains commands which have been sent to the proof
process and verified. The commands in the locked region cannot be
edited.
@item The @emph{queue} region, which appears in pink (inverse video) and contains
commands waiting to be sent to the proof process. Like those in the
locked region, these commands can't be edited.
@item The @emph{editing} region, which contains the commands the user is working
on, and can be edited as normal Emacs text.
@end itemize
These three regions appear in the buffer in the order above; that is,
the locked region is always at the start of the buffer, and the editing
region always at the end. The queue region only exists if there is input
waiting to be processed by the proof process.
Proof mode has two fundamental operations which transfer commands
between these regions: @emph{assertion} (or processing) and
@emph{retraction} (or undoing).
@cindex Assertion
@strong{Assertion} causes commands from the editing region to be
transferred to the queue region and sent one by one to the proof
process. If the command is accepted, it is transferred to the locked
region, but if an error occurs it is signalled to the user, and the
offending command is transferred back to the editing region together
with any remaining commands in the queue.
Assertion corresponds to processing proof commands, and makes the locked
region grow.
@cindex Retraction
@strong{Retraction} causes commands to be transferred from the locked
region to the editing region (again via the queue region) and the
appropriate 'undo' commands to be sent to the proof process.
Retraction corresponds to undoing commands, and makes the locked region
shrink. For details of the commands
available for doing assertion and retraction,
@xref{Script processing commands}.
@node Goal-save sequences
@subsection Goal-save sequences
@cindex goal
@cindex save
@cindex goal-save sequences
A proof script contains a sequence of commands used to prove one or more
theorems.
As commands in a proof script are transferred to the locked region, they
are aggregated into segments which constitute the smallest units which
can be undone. Typically a segment consists of a declaration or
definition, or all the text from a @dfn{goal} command to the
corresponding @dfn{save} command, or the individual commands in the
proof of an unfinished goal. As the mouse moves over the the region,
the segment containing the pointer will be highlighted.
Proof General therefore assumes that the proof script has a series of
proofs which look something like this:
@lisp
goal @var{mythm} is @var{G}
@dots{}
save theorem @var{mythm}
@end lisp
interspersed with comments, definitions, and the like. Of course, the
exact syntax and terminology will depend on the proof assistant you use.
The name @var{mythm} can appear in the menu for the proof script to help
quickly find a proof (@pxref{Support for function menus}).
@c Proof General recognizes the goal-save sequences in proof scripts.
@c once a goal-save region has been fully processed by the proof assistant,
@c it is treated as atomic when undoing proof steps. This reflects the
@c fact that most proof assistants discard the history of a proof once a it
@c is completed or once a new proof is begun.
@node Active scripting buffer
@subsection Active scripting buffer
@cindex active scripting buffer
You can edit as many script buffers as you want simultaneously, but only
one buffer at a time can be used to process a proof script
incrementally: this is the @dfn{active scripting buffer}.
The active scripting buffer has a special indicator: the word
@code{Scripting} appears in its mode line.
When you use a scripting command, it will automatically turn a buffer
into the active scripting mode. You can also do this by hand, via the
menu command 'Toggle Scripting' or the key @kbd{C-c C-s}.
@table @asis
@item @kbd{C-c C-s}
@code{proof-toggle-active-scripting}
@end table
When active scripting mode is turned on, several things may happen to
get ready for scripting (exactly what happens depends on which proof
assistant you are using and some user settings). First, the proof
assistant is started if it is not already running. Second, a command is
sent to the proof assistant to change directory to the directory of the
current buffer. If the current buffer corresponds to a file, this is
the directory the file lives in. This is in case any scripting commands
refer to files in the same directory as the script. The third thing
that may happen is that you are prompted to save some unsaved buffers.
This is in case any scripting commands may read in files which you are
editing. Finally, some proof assistants may automatically read in
files which the current file depends on implicitly. In Isabelle, for
example, there is an implicit dependency between a @code{.ML} script
file and a @code{.thy} theory file which defines its theory.
If you have a partly processed scripting buffer and use @kbd{C-c C-s},
or you attempt to use script processing in a new buffer, Proof General
will ask you if you want to retract what has been proved so far,
@code{Scripting incomplete in buffer myproof.l, retract?}
or if you want to process the remainder of the active buffer,
@code{Completely process buffer myproof.l instead?}
before you can start scripting in a new buffer. If you refuse to do
either, Proof General will give an error message:
@code{Cannot have more than one active scripting buffer!}.
To turn off active scripting, the buffer must be completely processed
(all blue), or completely unprocessed. There are two reasons for this.
First, it would be confusing if it were possible to split parts of a
proof arbitrarily between different buffers; the dependency between the
commands would be lost and it would be tricky to replay the proof.
Second, we want to interface with file management in the proof
assistant. Proof General assumes that a proof assistant may have a
notion of which files have been processed, but that the assistant will
only record files that have been @i{completely} processed. For more
explanation of the handling of multiple files, @xref{Switching between
proof scripts}.
@c TEXI DOCSTRING MAGIC: proof-toggle-active-scripting
@deffn Command proof-toggle-active-scripting &optional arg
Toggle active scripting mode in the current buffer.@*
With @var{arg}, turn on scripting iff @var{arg} is positive.
@end deffn
@node Summary of Proof General buffers
@section Summary of Proof General buffers
@cindex shell buffer
@cindex goals buffer
@cindex response buffer
@cindex proof by pointing
Proof General manages several kinds of buffers in Emacs. Here is a
summary of the different kinds of buffers you will use when developing
proofs.
@itemize @bullet
@item The @dfn{proof shell buffer} is an Emacs shell buffer
used to run your proof assistant. Usually it is hidden from view
(but see @ref{Escaping script management}).
Communication with the proof shell takes place via two or three
intermediate buffers.
@item A @dfn{script buffer}, as we have explained, is a buffer for editing a
proof script. The @dfn{active scripting buffer} is the script buffer
which is currently being used to send commands to the proof shell.
@item The @dfn{goals buffer} displays the list of subgoals to be
solved for a proof in progress. During a proof it is usually
displayed together with the script buffer.
@c FIXME: change when pbp is added back!
The goals buffer has facility for @dfn{proof-by-pointing}, although
this is disabled in Proof General @value{version}.
@item The @dfn{response buffer} displays other output from the proof
assistant, for example error messages or informative messages.
The response buffer is displayed whenever Proof General puts
a new message in it.
@end itemize
Normally Proof General will automatically reveal and hide the goals and
response buffers as necessary during scripting. However there are ways
to customize the way the buffers are displayed (@pxref{Display
customization}).
The menu @code{Proof General -> Buffers} provides a convenient way to
display or switch to one of the four buffers: active scripting, goals,
response, or shell.
@c When
@c Proof General sees an error in the shell buffer, it will highlight the
@c error and display the buffer automatically.
@c This facility was not added:
@c
@c Optionally, the goals buffer and script buffer can be identified
@c @pxref{Identify goals and response}. The disadvantage of this is that
@c the goals display can be replaced by other messages, so you must ask for
@c it to be refreshed. The advantage is that it is simpler to deal with
@c fewer Emacs buffers.
@node Script editing commands
@section Script editing commands
Proof General provides a few functions for editing proof scripts.
Specific proof assistant code may elaborate on these basics.
@findex indent-for-tab-command
@vindex proof-script-indent
Indentation is controlled by the user option @code{proof-script-indent}
(@pxref{User options}). When indentation is enabled, Proof General
will indent lines of proof script with the usual Emacs functions,
particularly @kbd{TAB}, @code{indent-for-tab-command}.
@c FIXME: remove when indentation is fixed.
Unfortunately, indentation in Proof General @value{version} is somewhat
slow. Therefore with large proof scripts, we recommend
@code{proof-script-indent} is turned off.
Here are the commands for moving around in a proof script,
with their default key bindings:
@kindex C-c C-a
@kindex C-c C-e
@kindex C-c C-.
@table @kbd
@item C-c C-a
@code{proof-goto-command-start}
@item C-c C-e
@code{proof-goto-command-end}
@item C-c C-.
@code{proof-goto-end-of-locked}
@end table
@c TEXI DOCSTRING MAGIC: proof-goto-command-start
@deffn Command proof-goto-command-start
Move point to start of current (or final) command of the script.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-goto-command-end
@deffn Command proof-find-next-terminator
Set point after next @samp{@code{proof-terminal-char}}.
@end deffn
@vindex proof-terminal-char
The variable @code{proof-terminal-char} is a prover-specific character to
terminate proof commands. LEGO and Isabelle use @samp{;}. Coq employs
@samp{.}.
@c TEXI DOCSTRING MAGIC: proof-goto-end-of-locked
@deffn Command proof-goto-end-of-locked &optional switch
Jump to the end of the locked region, maybe switching to script buffer.@*
If interactive or @var{switch} is non-nil, switch to script buffer first.
@end deffn
@node Script processing commands
@section Script processing commands
@kindex C-c C-n
@kindex C-c C-u
@kindex C-c C-b
@kindex C-c C-r
@kindex C-c C-RET
Here are the commands for asserting and retracting portions of the proof
script, together with their default key bindings. Sometimes assertion
and retraction commands can only be issued when the queue is empty. You
will get an error message @code{Proof Process Busy!} if you try to
assert or retract when the queue is being processed.@footnote{In fact,
this is an unnecessary restriction imposed by the original design of
Proof General. There is nothing to stop future versions of Proof
General allowing the queue region to be extended or shrunk, whilst the
prover is processing it. Proof General 3.0 already relaxes the original
design, by allowing successive assertion commands without complaining.}
@table @kbd
@item C-c C-n
@code{proof-assert-next-command-interactive}
@item C-c C-u
@code{proof-undo-last-successful-command}
@item C-c C-RET
@code{proof-goto-point}
@item C-c C-b
@code{proof-process-buffer}
@item C-c C-r
@code{proof-retract-buffer}
@item C-c @var{terminator-character}
@code{proof-electric-terminator-toggle}
@end table
The last command, @code{proof-electric-terminator-toggle}, is triggered
using the character which terminates proof commands for your proof
assistant's script language. For LEGO and Isabelle, use @kbd{C-c ;},
for Coq, use @kbd{C-c .}. This not really a script processing
command. Instead, if enabled, it causes subsequent key presses of
@kbd{;} or @kbd{.} to automatically activate
@code{proof-assert-next-command-interactive} for convenience.
Rather than use a file command inside the proof assistant to read a
proof script, a good reason to use @kbd{C-c C-b}
(@code{proof-process-buffer}) is that with a faulty proof script (e.g.,
a script you are adapting to prove a different theorem), Proof General
will stop exactly where the proof script fails, showing you the error
message and the last processed command. So you can easily continue
development from exactly the right place in the script.
Here is the full set of script processing commands.
@c TEXI DOCSTRING MAGIC: proof-assert-next-command-interactive
@deffn Command proof-assert-next-command-interactive
Process until the end of the next unprocessed command after point.@*
If inside a comment, just process until the start of the comment.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-undo-last-successful-command
@deffn Command proof-undo-last-successful-command
Undo last successful command at end of locked region.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-goto-point
@deffn Command proof-goto-point
Assert or retract to the command at current position.@*
Calls @code{proof-assert-until-point} or @code{proof-retract-until-point} as
appropriate.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-process-buffer
@deffn Command proof-process-buffer
Process the current buffer, and maybe move point to the end.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-retract-buffer
@deffn Command proof-retract-buffer
Retract the current buffer, and maybe move point to the start.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-electric-terminator-toggle
@deffn Command proof-electric-terminator-toggle arg
Toggle @code{proof-electric-terminator-enable}. With @var{arg}, turn on iff ARG>0.@*
This function simply uses @code{customize-set-variable} to set the variable.
It was constructed with the macro @code{proof-customize-toggle}.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-assert-until-point-interactive
@deffn Command proof-assert-until-point-interactive
Process the region from the end of the locked-region until point.@*
Default action if inside a comment is just process as far as the start of
the comment.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-retract-until-point-interactive
@deffn Command proof-retract-until-point-interactive &optional delete-region
Tell the proof process to retract until point.@*
If invoked outside a locked region, undo the last successfully processed
command. If called with a prefix argument (@var{delete-region} non-nil), also
delete the retracted region from the proof-script.
@end deffn
@node Proof assistant commands
@section Proof assistant commands
@kindex C-c C-p
@kindex C-c C-h
@kindex C-c C-c
@kindex C-c C-v
@kindex C-c C-f
@kindex C-c C-t
There are several commands for interacting with the proof assistant away
from a proof script. Here are the keybindings and functions.
@table @kbd
@item C-c C-p
@code{proof-prf}
@item C-c C-t
@code{proof-ctxt}
@item C-c C-h
@code{proof-help}
@item C-c C-f
@code{proof-find-theorems}
@item C-c C-c
@code{proof-interrupt-process}
@item C-c C-v
@code{proof-minibuffer-cmd}
@end table
@c TEXI DOCSTRING MAGIC: proof-prf
@deffn Command proof-prf
Show the current proof state.@*
Issues a command to the assistant based on @code{proof-showproof-command}.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-ctxt
@deffn Command proof-ctxt
Show the current context.@*
Issues a command to the assistant based on @code{proof-context-command}.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-help
@deffn Command proof-help
Show a help or information message from the proof assistant.@*
Typically, a list of syntax of commands available.
Issues a command to the assistant based on @code{proof-info-command}.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-find-theorems
@deffn Command proof-find-theorems arg
Search for items containing given constants.@*
Issues a command based on @var{arg} to the assistant, using @code{proof-find-theorems-command}.
The user is prompted for an argument.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-interrupt-process
@deffn Command proof-interrupt-process
Interrupt the proof assistant. Warning! This may confuse Proof General.@*
This sends an interrupt signal to the proof assistant, if Proof General
thinks it is busy.
This command is risky because when an interrupt is trapped in the
proof assistant, we don't know whether the last command succeeeded or
not. The assumption is that it didn't, which should be true most of
the time, and all of the time if the proof assistant has a careful
handling of interrupt signals.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-minibuffer-cmd
@deffn Command proof-minibuffer-cmd cmd
Prompt for a command in the minibuffer and send it to proof assistant.@*
The command isn't added to the locked region.
If @samp{@code{proof-state-preserving-p}} is configured, it is used as a check
that the command will be safe to execute, in other words, that
it won't ruin synchronization. If applied to the command it
returns false, then an error message is given.
This command risks spoiling synchronization if the test
@samp{@code{proof-state-preserving-p}} is not configured, or if it is
only an approximate test.
@end deffn
As if the last two commands weren't risky enough, there's also a command
which explicitly adjusts the end of the locked region, to be used in
extreme circumstances only. @xref{Escaping script management}.
There are a few commands for stopping, starting, and restarting the
proof assistant process which have menu entries but no key bindings.
As with any Emacs command, you can invoke these with @kbd{M-x}.
Here's a tip: if you accidently kill one of the Proof General special
buffers (goals or response), exiting the proof assistant and restarting
it will solve the problem.
@c TEXI DOCSTRING MAGIC: proof-shell-start
@deffn Command proof-shell-start
Initialise a shell-like buffer for a proof assistant.
Also generates goal and response buffers.
Does nothing if proof assistant is already running.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-shell-restart
@deffn Command proof-shell-restart
Clear script buffers and send @code{proof-shell-restart-cmd}.@*
All locked regions are cleared and the active scripting buffer
deactivated.
If the proof shell is busy, an interrupt is sent with
@code{proof-interrupt-process} and we wait until the process is ready.
The restart command should re-synchronize Proof General with the proof
assistant, without actually exiting and restarting the proof assistant
process.
It is up to the proof assistant how much context is cleared: for
example, theories already loaded may be "cached" in some way,
so that loading them the next time round only performs a re-linking
operation, not full re-processing. (One way of caching is via
object files, used by Lego and Coq).
@end deffn
@c TEXI DOCSTRING MAGIC: proof-shell-exit
@deffn Command proof-shell-exit
Query the user and exit the proof process.
This simply kills the @code{proof-shell-buffer} relying on the hook function
@code{proof-shell-kill-function} to do the hard work.
@end deffn
@node Toolbar commands
@section Toolbar commands
The toolbar provides a selection of functions for asserting and
retracting portions of the script, issuing non-scripting commands, and
inserting "goal" and "save" type commands. The latter functions are not
available on keys, but are available from the from the menu, or via
@kbd{M-x}, as well as the toolbar.
@c TEXI DOCSTRING MAGIC: proof-issue-goal
@deffn Command proof-issue-goal arg
Write a goal command in the script, prompting for the goal.@*
Issues a command based on @var{arg} to the assistant, using @code{proof-goal-command}.
The user is prompted for an argument.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-issue-save
@deffn Command proof-issue-save arg
Write a save/qed command in the script, prompting for the theorem name.@*
Issues a command based on @var{arg} to the assistant, using @code{proof-save-command}.
The user is prompted for an argument.
@end deffn
@c
@c CHAPTER: Advanced Script Management
@c
@node Advanced Script Management
@chapter Advanced Script Management
@cindex Multiple Files
By @emph{advanced} we mean script management for large proof
developments. These are typically spread across various files which
depend on each other in some way. Proof General knows enough about the
dependencies to allow script management across multiple files.
With large developments particularly, users may occasionally need to
escape from script management, in case Proof General loses
syncrhonization with the proof assistant. Proof General provides
you with several escape mechanisms if you want to do this.
@menu
* Switching between proof scripts::
* View of processed files ::
* Retracting across files::
* Asserting across files::
* Escaping script management::
@end menu
@node Switching between proof scripts
@section Switching between proof scripts
@cindex Switching between proof scripts
Basic modularity in large proof developments can be achieved by
splitting proof scripts across various files. Let's assume that you are
in the middle of a proof development. You are working on a soundness
proof of Hoare Logic in a file called@footnote{The suffix may depend of
the specific proof assistant you are using e.g, LEGO's proof script
files have to end with @file{.l}.} @file{HSound.l}. It
depends on a number of other files which develop underlying
concepts e.g. syntax and semantics of expressions, assertions,
imperative programs. You notice that the current lemma is too difficult
to prove because you have forgotten to prove some more basic properties
about determinism of the programming language. Or perhaps a previous
definition is too cumbersome or even wrong.
At this stage, you would like to visit the appropriate file, say
@file{sos.l} and retract to where changes are required. Then, using
script management, you want to develop some more basic theory in
@file{sos.l}. Once this task has been completed (possibly involving
retraction across even earlier files) and the new development has been
asserted, you want to switch back to @file{HSound.l} and replay to the
point you got stuck previously.
Some hours (or days) later you have completed the soundness proof and
are ready to tackle new challenges. Perhaps, you want to prove a
property that builds on soundness or you want to prove an orthogonal
property such as completeness.
Proof General lets you do all of this while maintaining the consistency
between proof script buffers and the state of the proof assistant.
However, you cannot have more than one buffer where only a fraction of
the proof script contains a locked region. Before you can employ script
management in another proof script buffer, you must either fully assert
or retract the current script buffer.
@node View of processed files
@section View of processed files
Proof General tries to be aware of all files that the proof assistant
has processed or is currently processing. In fact, it relies on the
proof assistant explicitly telling it whenever it processes a new file
which corresponds@footnote{For example, LEGO generates additional
compiled (optimised) proof script files for efficiency.} to a file
containing a proof script. For further technical details, see
@ref{Handling multiple files}.
If the current proof script buffer depends on background material from
other files, proof assistants typically process these files
automatically. If you visit such a file, the whole file is locked as
having been processed in a single step. From the user's point of view,
you can only retract but not assert in this buffer. Furthermore,
retraction is only possible to the @emph{beginning} of the buffer.
To be more precise, buffers are locked as soon the proof assistant
notifies Proof General of processing a file different from the
current proof script. Thus, if you visit the file while the proof
assistant is still processing the file, it is already completely locked.
If the proof assistant is not happy with the script and
complains with an error message, the buffer will still be marked as
having been completely processed. Sorry. You need to visit the
troublesome file, retract (which will always retract to the beginning of
the file) and debug the problem e.g., by asserting all of the buffer
under the supervision of Proof General, see @ref{Script processing
commands}.
In case you wondered, inconsistencies may arise when you have unsaved
changes in a proof script buffer and the proof assistant suddenly
decides to automatically process the corresponding file. The good news
is that Proof General detects this problem and flashes up a warning in
the response buffer. You might then want to visit the modified buffer,
save it and retract to the beginning. Then you are back on track.
@node Retracting across files
@section Retracting across files
@cindex Retraction
Make sure that the current script buffer has either been completely
asserted or retracted. Then you can retract proof scripts in a different
file. Simply visit a file that has been processed earlier and retract in
it, using the retraction commands from @ref{Script processing commands}. Apart from removing parts of the locked region in this
buffer, all files which depend on it will be retracted (and thus
unlocked) automatically. Proof General reminds you that now is a good
time to save any unmodified buffers.
@node Asserting across files
@section Asserting across files
@cindex Assertion
Make sure that the current script buffer has either been completely
asserted or retracted. Then you can assert proof scripts in a different
file. Simply visit a file that contains no locked region and assert some
command with the usual assertion commands, see @ref{Script processing
commands}. Proof General reminds you that now is a good time to save any
unmodified buffers. This is particularly useful as assertion may cause
the proof assistant to automatically process other files.
@node Escaping script management
@section Escaping script management
@cindex Shell
Occasionally you may want to review the dialogue of the entire session
with the proof assistant, or check that it hasn't done something
unexpected. Experienced users may also want to directly communicate
with the proof assistant rather than sending commands via the
minibuffer, see @ref{Proof assistant commands}.
Although the proof shell is usually hidden from view, it is run in a
buffer which provides the usual full editing and history facilities of
Emacs shells (see the package @file{comint.el} distributed with your
version of Emacs). You can switch to it using the menu:
@lisp
Proof-General -> Buffers -> Shell
@end lisp
@b{Warning:} you can probably cause confusion by typing in the shell
buffer! Proof General may lose track of the state of the proof
assistant. Output from the assistant is only fully monitored when Proof
General is in control of the shell.
When in control, Proof General watches the output from the proof
assistant to guess when a file is loaded or when a proof step is taken
or undone. What happens when you type in the shell buffer directly
depends on how complete the communication is between Proof General and
the prover (which depends on the particular instantiation of Proof
General).
If synchronization is lost, you have two options to resynchronize. If
you are lucky, it might suffice to use the key:
@table @kbd
@item C-c C-z
@code{proof-frob-locked-end}
@end table
This command is disabled by default, to protect novices using it
accidently.
If @code{proof-frob-locked-end} does not work, you will need to restart
script management altogether (@pxref{Proof assistant commands}).
@c TEXI DOCSTRING MAGIC: proof-frob-locked-end
@deffn Command proof-frob-locked-end
Move the end of the locked region backwards to regain synchronization.@*
Only for use by consenting adults.
This command can be used to repair synchronization in case something
goes wrong and you want to tell Proof General that the proof assistant
has processed less of your script than Proof General thinks.
You should only use it to move the locked region to the end of
a proof command.
@end deffn
@node Support for other Packages
@chapter Support for other Packages
Proof General makes some configuration for other Emacs packages which
provide various useful facilities. Sometimes this configuration is at
the proof assistant specific level, but we suggest that it should be
made for all proof assistants, as a convention.
The packages currently supported are @code{font-lock} @code{func-menu},
@code{outline-mode} and @code{etags}.
@menu
* Syntax Highlighting::
* Support for function menus::
* Support for outline mode::
* Support for tags::
@end menu
@node Syntax Highlighting
@section Syntax Highlighting
@vindex lego-mode-hooks
@vindex coq-mode-hooks
@vindex isa-mode-hooks
@cindex font-lock
@cindex colour
In XEmacs, proof script buffers are coloured (fontified as they say) by
default. To automatically switch on fontification in FSF GNU Emacs 20.4,
you may need to engage @code{M-x global-font-lock-mode}.
The old mechanism of adding hooks to the mode functions is no longer
recommended; it should not be needed in latest Emacs versions which have
more flexible customization.
@node Support for function menus
@section Support for function menus
@vindex proof-goal-with-hole-regexp
@cindex func-menu
@cindex fume-func
The Emacs package @code{func-menu} (formerly called @code{fume-func}) is
a handy facility to make a menu from the names of entities declared in a
buffer. Proof General configures @code{func-menu} so that you can
quickly jump to particular proofs in a script buffer. (This is done
with the configuration variables @code{proof-goal-with-hole-regexp} and
@code{proof-save-with-hole-regexp}.)
@c , @pxref{Proof script mode} for further details.
If you want to use function menu, you can simply type
@lisp
M-x function-menu
@end lisp
to display a menu. This works for the current version of XEmacs, 21.1.
Although the package is distributed with XEmacs, it is not enabled by
default every time you visit a buffer. To enable it by default
(i.e. avoid typing @code{M-x function-menu}), you should find the file
@file{func-menu.el} and follow the instructions there. At the time of
writing, the current version of XEmacs is 21.1, supplied with function
menu version 2.63, which suggests the following code for your
@file{.emacs} file:
@lisp
(require 'func-menu)
(define-key global-map 'f8 'function-menu)
(add-hook 'find-file-hooks 'fume-add-menubar-entry t)
(define-key global-map "\C-cl" 'fume-list-functions)
(define-key global-map "\C-cg" 'fume-prompt-function-goto)
(define-key global-map '(shift button3) 'mouse-function-menu)
(define-key global-map '(meta button1) 'fume-mouse-function-goto)
@end lisp
(we have found that the extra @code{t} argument to @code{add-hook}
may be important although it isn't suggested in @file{func-menu.el}).
If you have another version of Emacs, you should check the
@file{func-menu.el} (or @file{fume-func.el}) file supplied with it.
@node Support for outline mode
@section Support for outline mode
@cindex outline mode
Proof General configures Emacs variables (@code{outline-regexp} and
@code{outline-heading-end-regexp}) so that outline minor mode can be
used on proof script files. The headings taken for outlining are the
"goal" statements at the start of goal-save sequences,
see @ref{Goal-save sequences}. If you want to use @code{outline} to hide
parts of the proof script in the @emph{locked} region, you need to disable
@code{proof-strict-read-only}.
Use @kbd{M-x outline-minor-mode} to turn on outline minor mode.
Functions for navigating, hiding, and revealing the proof script are
available in menus.
See @inforef{Outline Mode, ,(xemacs)} for more information about
outline mode.
@node Support for tags
@section Support for tags
@cindex tags
An Emacs "tags table" is a description of how a multi-file system is
broken up into files. It lists the names of the component files and the
names and positions of the functions (or other named subunits) in each
file. Grouping the related files makes it possible to search or replace
through all the files with one command. Recording the function names
and positions makes possible the @kbd{M-.} command which finds the
definition of a function by looking up which of the files it is in.
Some instantiations of Proof General (currently LEGO and Coq) are
supplied with external programs (@file{legotags} and @file{coqtags}) for
making tags tables. For example, invoking @samp{coqtags *.v} produces a file
@file{TAGS} for all files @samp{*.v} in the current directory. Invoking @samp{coqtags `find . -name \*.v`} produces a file
@file{TAGS} for all files ending in @samp{.v} in the current directory
structure. Once a tag
table has been made for your proof developments, you can use the Emacs
tags mechanisms to find tags, and complete symbols from tags table.
One useful key binding you might want to make is to set the usual
completion key @kbd{M-tab} to run @code{tag-complete-symbol} to use
completion from names in the tag table. To set this binding in Proof
General script buffers, put this code in your @file{.emacs} file:
@lisp
(add-hook 'proof-mode-hook
(lambda () (local-set-key '(meta tab) 'tag-complete-symbol)))
@end lisp
Since this key binding interferes with a default binding that users may
already have customized, Proof General doesn't do this automatically.
For more information on how to use tags, @inforef{Tags, ,(xemacs)}.
@node Customizing Proof General
@chapter Customizing Proof General
@cindex Customization
There are two kinds of customization for Proof General: it can be
customized for a user's preferences using a particular proof assistant,
or it can be customized by an Emacs expert to add a new proof assistant.
Here we cover the user-level customization for Proof General,
see @ref{Adapting Proof General to Other Provers} for how to configure
for a new proof assistant.
We only consider settings for Proof General itself. The support for a
particular proof assistant can provide extra customization settings.
See the chapters covering each assistant for details.
@menu
* How to customize::
* Display customization::
* User options::
* Changing faces::
* Tweaking configuration settings::
@end menu
@node How to customize
@section How to customize
@cindex Using Customize
@cindex Emacs customization library
Proof General uses the Emacs customization library to provide a friendly
interface.
Visit a proof script file for some prover. Now you can access the
customization settings for Proof General via the menu:
@lisp
Proof-General -> Customize
@end lisp
Using the customize facility is straightforward. You can select the
setting to customize via the menus, or with @code{M-x
customize-variable}. When you have selected a setting, you are shown a
buffer with its current value, and facility to edit it. Once you have
edited it, you can use the special buttons @var{set}, @var{save} and
@var{done}. You must use one of @var{set} or @var{save} to get any
effect. The @var{save} button stores the setting in your @file{.emacs}
file. In XEmacs, the menu item @code{Options -> Save Options} saves all
settings you have edited.
A technical note. In the customize menus, the variable names mentioned
later in this chapter may be abbreviated --- the "@code{proof}-" or
similar prefixes are omitted. Also, some of the option settings may
have more descriptive names (for example, @var{on} and @var{off}) than
the low-level lisp values (non-@code{nil}, @code{nil}) which are
mentioned in this chapter. These features make customize rather more
friendly than raw lisp.
You can also access the customize settings for Proof General from
other (non-script) buffers. In XEmacs, the menu path is:
@lisp
Options -> Customize -> Emacs -> External -> Proof General
@end lisp
in XEmacs. In FSF GNU Emacs, use the menu:
@lisp
Help -> Customize -> Top-level Customization Group
@end lisp
and select the @code{External} and then @code{Proof-General} groups.
The complete set of customization settings will only be available after
Proof General has been fully loaded. Proof General is fully loaded when
you visit a script file for the first time, or if you type @kbd{M-x
load-library RET proof RET}.
For more help with customize, see @inforef{Easy Customization, ,xemacs}.
@node Display customization
@section Display customization
@cindex display customization
@cindex multiple windows
@cindex buffer display customization
@cindex frames
@cindex multiple frames
@cindex three-buffer interaction
By default, Proof General displays two buffers during scripting, in a
split window on the display. One buffer is the script buffer. The
other buffer is either the goals buffer (e.g. @code{*isabelle-goals*})
or the response buffer (@code{*isabelle-response*}). Proof General
switches between these last two automatically.
Proof General allows several ways to customize this default display
model.
If your screen is large enough, you may prefer to display all three of
the interaction buffers at once. This is useful, for example, to see
output from the @code{proof-find-theorems} command at the same time as
the subgoal list. Set the user option @code{proof-window-dedicated} to
make Proof General keep both the goals and response buffer displayed.
@c TEXI DOCSTRING MAGIC: proof-window-dedicated
@defopt proof-window-dedicated
Whether response and goals buffers have dedicated windows.@*
If non-nil, Emacs windows displaying messages from the prover will not
be switchable to display other windows.
This option can help manage your display.
Setting this option triggers a three-buffer mode of interaction where
the goals buffer and response buffer are both displayed, rather than
the two-buffer mode where they are switched between. It also prevents
Emacs automatically resizing windows between proof steps.
If you use several frames (X windows), you can force a frame to stick
to showing the goals or response buffer.
For single frame use this option may be inconvenient for
experienced Emacs users.
The default value is @code{nil}.
@end defopt
Sometimes during script management, there is no response from the proof
assistant to some command. In this case you might like the empty
response window to be hidden so you have more room to see the proof
script. The setting @code{proof-auto-delete-windows} helps you do this.
@c TEXI DOCSTRING MAGIC: proof-auto-delete-windows
@defopt proof-auto-delete-windows
If non-nil, automatically remove windows when they are cleaned.@*
For example, at the end of a proof the goals buffer window will
be cleared; if this flag is set it will automatically be removed.
If you want to fix the sizes of your windows you may want to set this
variable to @code{'nil'} to avoid windows being deleted automatically.
If you use multiple frames, only the windows in the currently
selected frame will be automatically deleted.
The default value is @code{nil}.
@end defopt
If you are working on a workstation with a window system, you can use
Emacs to manage several @i{frames} on the display, to keep the goals
buffer displayed in a fixed place on your screen and in a certain font,
for example. A convenient way to do this is via
@code{special-display-regexps}, for example:
@lisp
(setq special-display-regexps
(cons "\\*isabelle-\\(goals\\|response\\)\\*"
special-display-regexps))
@end lisp
This setting makes the @code{*isabelle-goals*} and
@code{*isabelle-response*} buffers automatically create their own
frames.
Multiple frames work best when @code{proof-auto-delete-windows} is
@code{nil} and @code{proof-window-dedicated} is @code{t}.
@node User options
@section User options
@c Index entries for each option 'concept'
@cindex User options
@cindex Strict read-only
@cindex Query program name
@cindex Dedicated windows
@cindex Remote host
@cindex Toolbar follow mode
@cindex Toolbar disabling
@cindex Toolbar button enablers
@cindex Proof script indentation
@cindex Indentation
@cindex Remote shell
@cindex Running proof assistant remotely
@c @cindex formatting proof script
Here is the complete set of user options for Proof General, apart from
the two display options mentioned above.
User options can be set via the customization system already mentioned,
via the old-fashioned @code{M-x edit-options} mechanism, or simply by
adding @code{setq}'s to your @file{.emacs} file. The first approach is
strongly recommended.
Unless mentioned, all of these settings can be changed dynamically,
without needing to restart Emacs to see the effect. But you must use
customize to be sure that Proof General reconfigures itself properly.
@c TEXI DOCSTRING MAGIC: proof-splash-enable
@defopt proof-splash-enable
If non-nil, display a splash screen when Proof General is loaded.
The default value is @code{t}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-electric-terminator-enable
@defopt proof-electric-terminator-enable
If non-nil, use electric terminator mode on start-up.@*
If electric terminator mode is enabled, pressing a terminator will
automatically issue @samp{@code{proof-assert-next-command}} for convenience,
to send the command straight to the proof process. Electric!
The default value is @code{nil}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-toolbar-enable
@defopt proof-toolbar-enable
If non-nil, display Proof General toolbar for script buffers.@*
NB: the toolbar is only available with XEmacs.
The default value is @code{t}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-x-symbol-enable
@defopt proof-x-symbol-enable
Whether to use x-symbol in Proof General buffers.@*
If you activate this variable, whether or not you get x-symbol support
depends on if your proof assistant supports it and it is enabled
inside your Emacs.
The default value is @code{nil}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-output-fontify-enable
@defopt proof-output-fontify-enable
Whether to fontify output from the proof assistant.@*
If non-nil, output from the proof assistant will be highlighted
in the goals and response buffers.
(This is providing @code{font-lock-keywords} have been set for the
buffer modes).
The default value is @code{t}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-strict-read-only
@defopt proof-strict-read-only
Whether Proof General is strict about the read-only region in buffers.@*
If non-nil, an error is given when an attempt is made to edit the
read-only region. If nil, Proof General is more relaxed (but may give
you a reprimand!).
If you change @code{proof-strict-read-only} during a session, you must use
@lisp
"Restart" (@code{proof-shell-restart})
@end lisp
The default value for @code{proof-strict-read-only} depends on which
version of Emacs you are using. In FSF Emacs, strict read only is buggy
when it used in conjunction with font-lock, so it is disabled by default.
The default value is @code{strict}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-toolbar-use-button-enablers
@defopt proof-toolbar-use-button-enablers
If non-nil, toolbars buttons may be enabled/disabled automatically.@*
Toolbar buttons can be automatically enabled/disabled according to
the context. Set this variable to nil if you don't like this feature
or if you find it unreliable.
Notes:
* Toolbar enablers are only available with XEmacs 21 and later.
* With this variable nil, buttons do nothing when they would
otherwise be disabled.
* If you change this variable it will only be noticed when you
next start Proof General.
The default value is @code{t}.
@end defopt
@c This one removed: proof-auto-retract
@c TEXI DOCSTRING MAGIC: proof-query-file-save-when-activating-scripting
@defopt proof-query-file-save-when-activating-scripting
If non-nil, query user to save files when activating scripting.
Often, activating scripting or executing the first scripting command
of a proof script will cause the proof assistant to load some files
needed by the current proof script. If this option is non-nil, the
user will be prompted to save some unsaved buffers in case any of
them corresponds to a file which may be loaded by the proof assistant.
You can turn this option off if the save queries are annoying, but
be warned that with some proof assistants this may risk processing
files which are out of date with respect to the lodead buffers!
The default value is @code{t}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-script-indent
@defopt proof-script-indent
If non-nil, enable indentation code for proof scripts.@*
Currently the indentation code can be rather slow for large scripts,
and is critical on the setting of regular expressions for particular
provers. Enable it if it works for you.
The default value is @code{nil}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-one-command-per-line
@defopt proof-one-command-per-line
If non-nil, format for newlines after each proof command in a script.@*
This option is not fully-functional at the moment.
The default value is @code{nil}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-prog-name-ask
@defopt proof-prog-name-ask
If non-nil, query user which program to run for the inferior process.
The default value is @code{nil}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-prog-name-guess
@defopt proof-prog-name-guess
If non-nil, use @samp{@code{proof-guess-command-line}} to guess @code{proof-prog-name}.@*
This option is compatible with @code{proof-prog-name-ask}.
No effect if @code{proof-guess-command-line} is nil.
The default value is @code{nil}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-tidy-response
@defopt proof-tidy-response
Non-nil indicates that the response buffer should be cleared often.@*
The response buffer can be set either to accumulate output, or to
clear frequently.
With this variable non-nil, the response buffer is kept tidy by
clearing it often, typically between successive commands (just like the
goals buffer).
Otherwise the response buffer will accumulate output from the prover.
The default value is @code{t}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-show-debug-messages
@defopt proof-show-debug-messages
Whether to display debugging messages in the response buffer.@*
If non-nil, debugging messages are displayed in the response giving
information about what Proof General is doing.
To avoid erasing the messages shortly after they're printed,
you should set @samp{@code{proof-tidy-response}} to nil.
The default value is @code{t}.
@end defopt
@c ******* NON-BOOLEANS *******
@c TEXI DOCSTRING MAGIC: proof-follow-mode
@defopt proof-follow-mode
Choice of how point moves with script processing commands.@*
One of the symbols: @code{'locked}, @code{'follow}, @code{'ignore}.
If @code{'locked}, point sticks to the end of the locked region.
If @code{'follow}, point moves just when needed to display the locked region end.
If @code{'ignore}, point is never moved after movement commands.
The default value is @code{locked}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-auto-action-when-deactivating-scripting
@defopt proof-auto-action-when-deactivating-scripting
If @code{'retract} or @code{'process}, do that when deactivating scripting.
With this option set to @code{'retract} or @code{'process}, when scripting
is turned off in a partly processed buffer, the buffer will be
retracted or processed automatically.
With this option unset (nil), the user is questioned instead.
Proof General insists that only one script buffer can be partly
processed: all others have to be completely processed or completely
unprocessed. This is to make sure that handling of multiple files
makes sense within the proof assistant.
NB: A buffer is completely processed when all non-whitespace is
locked (coloured blue); a buffer is completely unprocessed when there
is no locked region.
The default value is @code{nil}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-script-command-separator
@defopt proof-script-command-separator
String separating commands in proof scripts.@*
For example, if a proof assistant prefers one command per line, then
this string should be set to a newline. Otherwise it should be
set to a space.
The default value is @code{" "}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-rsh-command
@defopt proof-rsh-command
Shell command prefix to run a command on a remote host. @*
For example,
@lisp
ssh bigjobs
@end lisp
Would cause Proof General to issue the command @samp{ssh bigjobs isabelle}
to start Isabelle remotely on our large compute server called @samp{bigjobs}.
The protocol used should be configured so that no user interaction
(passwords, or whatever) is required to get going.
The default value is @code{""}.
@end defopt
@node Changing faces
@section Changing faces
The fonts and colours that Proof General uses are configurable. If you
alter these through the customize menus, only the particular kind of
display in use (colour window system, monochrome window system, console,
@dots{}) will be affected.
@c TEXI DOCSTRING MAGIC: proof-queue-face
@deffn Face proof-queue-face
Face for commands in proof script waiting to be processed.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-locked-face
@deffn Face proof-locked-face
Face for locked region of proof script (processed commands).
@end deffn
@c TEXI DOCSTRING MAGIC: proof-declaration-name-face
@deffn Face proof-declaration-name-face
Face for declaration names in proof scripts.@*
Exactly what uses this face depends on the proof assistant.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-tacticals-name-face
@deffn Face proof-tacticals-name-face
Face for names of tacticals in proof scripts.@*
Exactly what uses this face depends on the proof assistant.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-error-face
@deffn Face proof-error-face
Face for error messages from proof assistant.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-warning-face
@deffn Face proof-warning-face
Face for warning messages.@*
Warning messages can come from proof assistant or from Proof General itself.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-debug-message-face
@deffn Face proof-debug-message-face
Face for debugging messages from Proof General.
@end deffn
@c Maybe this detail of explanation belongs in the internals,
@c with just a hint here.
The slightly bizarre name of the next face comes from the idea that
while large amounts of output are being sent from the prover, some
messages should be displayed to the user while the bulk of the output is
hidden. The messages which are displayed may have a special annotation
to help Proof General recognize them, and this is an "eager" annotation
in the sense that it should be processed as soon as it is observed
by Proof General.
@c TEXI DOCSTRING MAGIC: proof-eager-annotation-face
@deffn Face proof-eager-annotation-face
Face for important messages from proof assistant.
@end deffn
@node Tweaking configuration settings
@section Tweaking configuration settings
This section is a note for advanced users.
Configuration settings are the per-prover customizations of Proof
General. These are not intended to be adjusted by the user. But
occasionally you may like to test changes to these settings to improve
the way Proof General works. You may want to do this when a proof
assistant has a flexible proof script language in which one can define
new tactics or even operations, and you want Proof General to recognize
some of these which the default settings don't mention. So please feel
free to try adjusting the configuration settings and report to us if you
find better default values than the ones we have provided.
The configuration settings appear in the customization group
@code{prover-config}, or via the menu
@lisp
Proof-General -> Internals -> Prover Config
@end lisp
One basic example of a setting you may like to tweak is:
@c TEXI DOCSTRING MAGIC: proof-assistant-home-page
@defvar proof-assistant-home-page
Web address for information on proof assistant
@end defvar
Most of the others are more complicated. For more details of the settings,
see @ref{Adapting Proof General to Other Provers}. To browse
them, you can look through the customization groups
@code{prover-config}, @code{proof-script} and @code{proof-shell}. The
group @code{proof-script} contains the configuration variables for
scripting, and the group @code{proof-shell} contains those for
interacting with the proof assistant.
Unfortunately, although you can use the customization mechanism to set
and save these variables, saving them may have no effect because the
default settings are often hard-wired into the proof assistant code.
Ones we expect may need changing appear as proof assistant specific
configurations. For example, @code{proof-assistant-home-page} is set in
the LEGO code from the value of the customization setting
@code{lego-www-home-page}. At present there is no easy way to save
changes to other configuration variables across sessions, other than by
editing the source code. Please contact us if this proves to be a
problem for any variable.
@c
@c CHAPTER: LEGO Proof General
@c
@node LEGO Proof General
@chapter LEGO Proof General
@cindex LEGO Proof General
LEGO proof script mode is a mode derived from proof script mode for
editing LEGO scripts. An important convention is that proof script
buffers @emph{must} start with a module declaration. If the proof script
buffer's file name is @file{fermat.l}, then it must commence with a
declaration of the form
@lisp
Module fermat;
@end lisp
If, in the development of the module @samp{fermat}, you require material
from other module e.g., @samp{lib_nat} and @samp{galois}, you need to
specify this dependency as part of the module declaration:
@lisp
Module fermat Import lib_nat galois;
@end lisp
No need to worry too much about efficiency. When you retract back to a
module declaration to add a new import item, LEGO does not actually
retract the previously imported modules. Therefore, reasserting the
extended module declaration really only processes the newly imported
modules.
Using the LEGO Proof General, you never ever need to use administrative
LEGO commands such as @samp{Forget}, @samp{ForgetMark}, @samp{KillRef},
@samp{Load}, @samp{Make}, @samp{Reload} and @samp{Undo} again
@footnote{And please, don't even think of including those in your LEGO
proof script!}. You can concentrate on your actual proof developments.
Script management in Proof General will invoke the appropriate commands
for you. Proving with LEGO has never been easier.
@menu
* LEGO specific commands::
* LEGO tags::
* LEGO customizations::
@end menu
@node LEGO specific commands
@section LEGO specific commands
In addition to the commands provided by the generic Proof General (as
discussed in the previous sections) the LEGO Proof General provides a
few extensions. In proof scripts, there are some abbreviations for
common commands:
@kindex C-c i
@kindex C-c I
@kindex C-c R
@table @kbd
@item C-c i
intros
@item C-c I
Intros
@item C-c R
Refine
@end table
@node LEGO tags
@section LEGO tags
You
might want to ask your local system administrator to tag the directories
@file{lib_Prop}, @file{lib_Type} and @file{lib_TYPE} of the LEGO
library. See @ref{Support for tags} for further details on tags.
@node LEGO customizations
@section LEGO customizations
We refer to chapter @ref{Customizing Proof General} for an introduction
to the customisation mechanism. In addition to customizations at the
generic level, for LEGO you can also customize:
@c TEXI DOCSTRING MAGIC: lego-tags
@defopt lego-tags
The directory of the @var{tags} table for the @var{lego} library
The default value is @code{"/usr/lib/lego/lib_Type/"}.
@end defopt
@c TEXI DOCSTRING MAGIC: lego-www-home-page
@defvar lego-www-home-page
Lego home page URL.
@end defvar
@c TEXI DOCSTRING MAGIC: lego-help-menu-list
@defvar lego-help-menu-list
List of menu itemsfor @var{lego} specific help.
See the documentation of @samp{@code{easy-menu-define}}
@end defvar
@c We don't worry about the following for now. These are too obscure.
@c lego-indent
@c lego-test-all-name
@c We also don't document any of the internal variables which have been
@c set to configure the generic Proof General and which the user should
@c not tamper with
@node Coq Proof General
@chapter Coq Proof General
Coq Proof General is an instantiation of Proof General for the Coq proof
assistant. It adds several features over the generic parts of Proof
General.
@menu
* Coq-specific commands::
* Editing multiple proofs::
* User-loaded tactics::
* Suggested Coq abbreviations::
@end menu
@node Coq-specific commands
@section Coq-specific commands
@kindex C-c I
@kindex C-c a
@kindex C-c s
@kindex C-c e
Coq Proof General supplies the following key-bindings:
@table @kbd
@item C-c I
Inserts ``Intros '' into proof buffer.
@item C-c a
Inserts ``Apply '' into proof buffer.
@item C-c s
Inserts ``Section '' into proof buffer
@item C-c e
Closes the current section by inserting ``End <section-name>.''. (this
should work well with nested sections).
@end table
@node Editing multiple proofs
@section Editing multiple proofs
Coq allows the user to enter top-level commands while editing a proof
script. For example, if the user realizes that the current proof will
fail without an additional axiom, he or she can add that axiom to the
system while in the middle of the proof. Similarly, the user can
nest lemmas, beginning a new lemma while in the middle of an earlier
one, and as the lemmas are proved or their proofs aborted they are
popped off a stack.
Coq Proof General supports this feature of Coq. Top-level commands
entered while in a proof are promoted immediately above the outermost
active proof. If new lemmas are started, Coq Proof General lets the user
work on the proof of the new lemma, and when the lemma is finished the
full proof of that lemma is promoted. This is supported to any nesting
depth that Coq allows.
@b{Special note:} this feature is disabled in version 3.0 because the
implementation was unreliable.
@node User-loaded tactics
@section User-loaded tactics
Another feature that Coq allows is the extension of the grammar of the
proof assistant by new tactic commands. This feature interacts with the
proof script management of Proof General, because Proof General needs to
know when a tactic is called that alters the proof state.
Unfortunately, Coq Proof General does not currently support tactic
extension in Coq. When the user tries to retract across an extended
tactic in a script, the algorithm for calculating how far to undo does
not recognize the extension, and so the proof buffer and Coq are not
synchronized.
Until this feature is incorporated into Coq Proof General, the user can
use C-c C-v to resynchronize. For example, if the user does C-c C-u to
move the point back past one extended tactic, he or she can type C-c C-v
``Undo 1.'' This then undoes the tactic that the proof mode failed to
recognize.
@node Suggested Coq abbreviations
@section Suggested Coq abbreviations
@c FIXME: could make this generic
Coq has many command strings that are long, such as ``Reflexivity,''
``Inductive,'' ``Definition'' and ``Discriminate.'' Although it is
not a feature particular to Coq, it can be very useful to add
abbreviations and enable Abbrev mode in Coq Proof General.
Here is a suggested list of abbreviations for Coq:
@lisp
"assn" 0 "Assumption"
"ax" 0 "Axiom"
"coern" 0 "Coercion"
"cofixpt" 0 "CoFixpt"
"coindv" 0 "CoInductive"
"constr" 0 "Constructor"
"contradn" 0 "Contradiction"
"defn" 0 "Definition"
"discr" 0 "Discriminate"
"extrn" 0 "Extraction"
"fixpt" 0 "Fixpoint"
"genz" 0 "Generalize"
"hypo" 0 "Hypothesis"
"immed" 0 "Immediate"
"indn" 0 "Induction"
"indv" 0 "Inductive"
"injn" 0 "Injection"
"intn" 0 "Intuition"
"invn" 0 "Inversion"
"pmtr" 0 "Parameter"
"refly" 0 "Reflexivity"
"rmk" 0 "Remark"
"specz" 0 "Specialize"
"symy" 0 "Symmetry"
"thm" 0 "Theorem"
"transpt" 0 "Transparent"
"transy" 0 "Transitivity"
"trivial" 0 "Trivial"
"varl" 0 "Variable"
@end lisp
You need to read the Emacs manual to find out how to configure these
abbreviations. It is possible to copy the text above into a file that
Emacs reads.
@c How?
@c Sorry, there is currently very little specific documentation written for
@c Coq Proof General. If any Coq user would like to contribute, please send
@c a message to @code{proofgen@@dcs.ed.ac.uk}.
@c Type @kbd{C-h C-m} to get a list of all Coq specific commands and
@c browse the customize menus to find out what customization
@c options there are for Coq.
@c
@c CHAPTER: Isabelle Proof General
@c
@node Isabelle Proof General
@chapter Isabelle Proof General
@cindex Isabelle Proof General
Isabelle Proof General includes a mode for editing theory files taken
from David Aspinall's Isamode interface,
@uref{http://www.dcs.ed.ac.uk/home/da/Isamode}. Detailed documentation
for the theory file mode is included with @code{Isamode}, there are some
notes on the special functions available and customization settings
below.
@menu
* Theory files::
* Isabelle specific commands::
* Isabelle customizations::
@end menu
@node Theory files
@section Theory files
@cindex Theory files (in Isabelle)
@cindex ML files (in Isabelle)
Isabelle Proof General attempts to lock theory files as well as ML files
when they are loaded. Theory files are always completely locked or
completely unlocked, because they are processed atomically.
Proof General attempts to load the theory file for a @file{.ML} file
automatically before you start scripting. This relies on new support
built especially for Proof General into Isabelle 99's theory loader.
However, because scripting cannot begin until the theory is loaded, and
it should not begin if an error occurs during loading the theory, Proof
General blocks waiting for the theory loader to finish. This means that
if you have a theory file which takes a long time to load, you might
want to use it directly:
@c FIXME: should say something about this:
@c This can cause confusion in the theory loader later,
@c especially with @code{update()}. To be safe, try to use just the Proof
@c General interface, and report any repeatable problems to
@c @code{isabelle@dcs.ed.ac.uk}.
@c Compared to Isamode's theory editing mode, some of the functions and key
@c bindings for interacting with Isabelle have been removed, and two new
@c functions are available.
The key @kbd{C-c C-b} (@code{isa-process-thy-file}) will cause Isabelle
to read the theory file being edited. This causes the file and all its
children (both theory and ML files) to be read. Any top-level ML file
associated with this theory file is also read.
The key @kbd{C-c C-u} (@code{isa-retract-thy-file}) will retract
(unlock) the theory file being edited. This unlocks the file and all
its children (theory and ML files); no changes occur in Isabelle itself.
@c TEXI DOCSTRING MAGIC: isa-process-thy-file
@deffn Command isa-process-thy-file file
Process the theory file @var{file}. If interactive, use @code{buffer-file-name}.
@end deffn
@c TEXI DOCSTRING MAGIC: isa-retract-thy-file
@deffn Command isa-retract-thy-file file
Retract the theory file @var{file}. If interactive, use @code{buffer-file-name}.@*
To prevent inconsistencies, scripting is deactivated before doing this.
So if scripting is active in an ML file which is not completely processed,
you will be asked to retract the file or process the remainder of it.
(If you process the rest of it it may subsequently be unlocked anyway).
@end deffn
@node Isabelle specific commands
@section Isabelle specific commands
@unnumberedsubsec Switching to theory files
@cindex Switching to theory files
@kindex C-c C-o
In Isabelle proof script mode, @kbd{C-c C-o} (@code{thy-find-other-file})
finds and switches to the associated theory file, that is, the file with
the same base name but extension @file{.thy} swapped for @file{.ML}.
The same function (and keybinding) switches back to an ML file from the
theory file.
@c TEXI DOCSTRING MAGIC: thy-find-other-file
@deffn Command thy-find-other-file &optional samewindow
Find associated .ML or .thy file.@*
Finds and switch to the associated ML file (when editing a theory file)
or theory file (when editing an ML file).
If @var{samewindow} is non-nil (interactively, with an optional argument)
the other file replaces the one in the current window.
@end deffn
@node Isabelle customizations
@section Isabelle customizations
Here are some of the user options specific to Isabelle. You can set
these as usual with the customization mechanism.
@c TEXI DOCSTRING MAGIC: isabelle-web-page
@defvar isabelle-web-page
URL of web page for Isabelle.
@end defvar
@c @unnumberedsubsec Theory file editing customization
@c TEXI DOCSTRING MAGIC: thy-use-sml-mode
@defopt thy-use-sml-mode
If non-nil, invoke @code{sml-mode} inside "ML" section of theory files.@*
This option is left-over from Isamode. Really, it would be more
useful if the script editing mode of Proof General itself could be based
on @code{sml-mode}, but at the moment there is no way to do this.
The default value is @code{nil}.
@end defopt
@c TEXI DOCSTRING MAGIC: thy-indent-level
@defvar thy-indent-level
Indentation level for Isabelle theory files. An integer.
@end defvar
@defopt thy-indent-level
Indentation level for Isabelle theory files. An integer.
@end defopt
@c TEXI DOCSTRING MAGIC: thy-sections
@defvar thy-sections
Names of theory file sections and their templates.@*
Each item in the list is a pair of a section name and a template.
A template is either a string to insert or a function. Useful functions are:
@lisp
@code{thy-insert-header}, @code{thy-insert-class}, @code{thy-insert-default-sort},
@code{thy-insert-const}, @code{thy-insert-rule}.
@end lisp
The nil template does nothing.
You can add extra sections to theory files by extending this variable.
@end defvar
@c TEXI DOCSTRING MAGIC: thy-template
@defvar thy-template
Template for theory files.@*
Contains a default selection of sections in a traditional order.
You can use the following format characters:
@samp{%t} --- replaced by theory name.
@samp{%p} --- replaced by names of parents, separated by @samp{+} characters.
@end defvar
@c ideal for above:
@c @defopt thy-template
@c Template for theory files.
@c Contains a default selection of sections in a traditional order.
@c You can use the following format characters:
@c @code{%t} -- replaced by theory name
@c @code{%p} -- replaced by names of parents, separated by @code{+}'s
@c @end defopt
@node Adapting Proof General to Other Provers
@chapter Adapting Proof General to Other Provers
Proof General has about 60 configuration variables which are set on a
per-prover basis to configure the various features. It may sound like a
lot but don't worry! Many of the variables occur in pairs (typically
regular expressions matching the start and end of some text), and you
can begin by setting just a few variables to get the basic features of
script management working.
For more advanced features you may need (or want) to write some Emacs
Lisp. If you're adding new functionality please consider making it
generic for different proof assistants, if appropriate. When writing
your modes, please follow the Emacs Lisp conventions @inforef{Style
Tips, ,(lispref)}.
The configuration variables are declared in the file
@file{generic/proof-config.el}. The documentation below is based on the
contents of that file.
@menu
* Overview of adding a new prover::
* Major modes used by Proof General::
* Menus and user-level commands::
* Proof script settings::
* Proof shell settings::
* Splash screen settings::
* Goals buffer settings::
* Global constants::
* Handling multiple files::
* Configuring X-Symbol::
@end menu
@node Overview of adding a new prover
@section Overview of adding a new prover
Each proof assistant supported has its own subdirectory under
@code{proof-home-directory}, used to store a root elisp file and any
other files needed to adapt the proof assistant for Proof General.
@c Here we show how a minimal configuration of Proof General works for
@c Isabelle, without any special changes to Isabelle.
Here is how to go about adding support for a new prover.
@itemize @bullet
@item Make a directory called @file{myassistant/} under the Proof General home
directory @code{proof-home-directory}, to put the specific customization
and associated files in.
@item Add a file @file{myassistant.el} to the new directory.
@item Edit @file{proof-site.el} to add a new entry to the
@code{proof-assistants-table} variable. The new entry should look
like this:
@lisp
(myassistant "My New Assistant" "\\.myasst$")
@end lisp
The first item is used to form the name of the internal variables for
the new mode as well as the directory and file where it loads from. The
second is a string, naming the proof assistant. The third item is a
regular expression to match names of proof script files for this
assistant. See the documentation of @code{proof-assistant-table} for
more details.
@item Define the new modes in @file{myassistant.el}, by looking at
the files for the currently supported assistants for example
Basically you need to define some modes using @code{define-derived-mode}
and set configuration variables.
@xref{Major modes used by Proof General}.
@end itemize
You could begin by setting a minimum number of the variables, then
adjust the settings via the customize menus, under Proof-General ->
Internals.
@c TEXI DOCSTRING MAGIC: proof-assistant-table
@defopt proof-assistant-table
Proof General's table of supported proof assistants.@*
Extend this table to add a new proof assistant.
Each entry is a list of the form
@lisp
(@var{symbol} @var{name} @var{automode-regexp})
@end lisp
The @var{name} is a string, naming the proof assistant.
The @var{symbol} is used to form the name of the mode for the
assistant, @samp{SYMBOL-mode}, run when files with @var{automode-regexp}
are visited. @var{symbol} is also used to form the name of the
directory and elisp file for the mode, which will be
@lisp
@var{proof-home-directory}/@var{symbol}/@var{symbol}.el
@end lisp
where @samp{PROOF-HOME-DIRECTORY} is the value of the
variable @code{proof-home-directory}.
The default value is @code{((demoisa "Isabelle Demo" "\\.ML$") (isar "Isabelle/Isar" "\\.thy$") (isa "Isabelle" "\\.ML$\\|\\.thy$") (lego "LEGO" "\\.l$") (coq "Coq" "\\.v$") (plastic "Plastic" "\\.lf$"))}.
@end defopt
@node Major modes used by Proof General
@section Major modes used by Proof General
There are four major modes used by Proof General for each type of buffer
it handles. The buffer types are: script, shell, response and goals.
Each of these has a generic mode, respecitvely: @code{proof-mode},
@code{proof-shell-mode}, @code{proof-response-mode}, and
@code{proof-pbp-mode}.
The pattern for defining the major mode for an instance of Proof General
is to use @code{define-derived-mode} to define each mode to inherit from
the corresponding generic one, like this:
@lisp
(define-derived-mode myass-shell-mode proof-shell-mode
"MyAss shell" nil
(myass-shell-config)
(proof-shell-config-done)
@end lisp
Where @code{myass-shell-config} is a function which sets the
configuration variables for the shell @pxref{Proof shell settings}.
It's important that your mode invokes one of the functions
@code{proof-config-done},
@code{proof-shell-config-done},
@code{proof-response-config-done}, or
@code{proof-goals-config-done}
once they've set their configuration variables. These functions
finialize the configuration of the mode.
For each mode, there is a configuration variable which names it so that
Proof General can set buffers to the proper mode, or find buffers in
that mode. These are shown below, and set like this:
@lisp
(setq proof-mode-for-script 'myass-mode)
@end lisp
where @code{myass-mode} is your major mode for scripts, derived from
@code{proof-mode}.
@c TEXI DOCSTRING MAGIC: proof-mode-for-script
@defvar proof-mode-for-script
Mode for proof script buffers.@*
This is used by Proof General to find out which buffers
contain proof scripts.
Suggestion: this can be set in the script mode configuration.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-mode-for-shell
@defvar proof-mode-for-shell
Mode for proof shell buffers.@*
Usually customised for specific prover.
Suggestion: this can be set in the shell mode configuration.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-mode-for-response
@defvar proof-mode-for-response
Mode for proof response buffer.@*
Usually customised for specific prover.
Suggestion: this can be set in the shell mode configuration.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-mode-for-pbp
@defvar proof-mode-for-pbp
Mode for proof state display buffers.@*
Usually customised for specific prover.
Suggestion: this can be set in the shell mode configuration.
@end defvar
@node Menus and user-level commands
@section Menus and user-level commands
The following variables should be set in the script mode before
@code{proof-config-done} is called. These make some settings for the
commands and menus available in Proof General.
@c TEXI DOCSTRING MAGIC: proof-assistant-home-page
@defvar proof-assistant-home-page
Web address for information on proof assistant
@end defvar
@c TEXI DOCSTRING MAGIC: proof-context-command
@defvar proof-context-command
Command to display the context in proof assistant.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-info-command
@defvar proof-info-command
Command to ask for help or information in the proof assistant.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-showproof-command
@defvar proof-showproof-command
Command to display proof state in proof assistant.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-goal-command
@defvar proof-goal-command
Command to set a goal in the proof assistant. String or fn.@*
If a string, the format character @samp{%s} will be replaced by the
goal string.
If a function, it should return the command string to insert.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-save-command
@defvar proof-save-command
Command to save a proved theorem in the proof assistant. String or fn.@*
If a string, the format character @samp{%s} will be replaced by the
theorem name.
If a function, it should return the command string to insert.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-find-theorems-command
@defvar proof-find-theorems-command
Command to search for a theorem containing a given constant. String or fn.@*
If a string, the format character @samp{%s} will be replaced by the
constant name.
If a function, it should return the command string to insert.
@end defvar
@c defgroup proof-script
@node Proof script settings
@section Proof script settings
The following variables should be set in the script mode before
@code{proof-config-done} is called. These configure the mode for the
script buffer.
@c TEXI DOCSTRING MAGIC: proof-terminal-char
@defvar proof-terminal-char
Character which terminates a command in a script buffer.@*
You must set this variable in script mode configuration.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-comment-start
@defvar proof-comment-start
String which starts a comment in the proof assistant command language.@*
The script buffer's @code{comment-start} is set to this string plus a space.
Moreover, comments are ignored during script management, and not
sent to the proof process.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-comment-end
@defvar proof-comment-end
String which ends a comment in the proof assistant command language.@*
The script buffer's @code{comment-end} is set to this string plus a space.
See also @samp{@code{proof-comment-start}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-case-fold-search
@defvar proof-case-fold-search
Value for @code{case-fold-search} when recognizing portions of proof scripts.@*
The default value is @code{'nil'}. If your prover has a case @strong{insensitive}
input syntax, @code{proof-case-fold-search} should be set to @code{'t'} instead.
NB: This setting is not used for matching output from the prover.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-save-command-regexp
@defvar proof-save-command-regexp
Matches a save command
@end defvar
@c TEXI DOCSTRING MAGIC: proof-save-with-hole-regexp
@defvar proof-save-with-hole-regexp
Regexp which matches a command to save a named theorem.@*
Match number 2 should be the name of the theorem saved.
Used for setting names of goal..save regions and for default
@code{function-menu} configuration in @code{proof-script-find-next-entity}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-goal-command-regexp
@defvar proof-goal-command-regexp
Matches a goal command.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-goal-with-hole-regexp
@defvar proof-goal-with-hole-regexp
Regexp which matches a command used to issue and name a goal.@*
Match number 2 should be the name of the goal issued.
Used for setting names of goal..save regions and for default
@code{function-menu} configuration in @code{proof-script-find-next-entity}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-script-next-entity-regexps
@defvar proof-script-next-entity-regexps
Regular expressions to help find definitions and proofs in a script.@*
This is the list of the form
@lisp
(@var{anyentity-regexp}
@var{discriminator-regexp} ... @var{discriminator-regexp})
@end lisp
The idea is that @var{anyentity-regexp} matches any named entity in the
proof script, on a line where the name appears. This is assumed to be
the start or the end of the entity. The discriminators then test
which kind of entity has been found, to get its name. A
@var{discriminator-regexp} has one of the forms
@lisp
(@var{regexp} @var{matchno})
(@var{regexp} @var{matchno} @code{'backward} @var{backregexp})
(@var{regexp} @var{matchno} @code{'forward} @var{forwardregexp})
@end lisp
If @var{regexp} matches the string captured by @var{anyentity-regexp}, then
@var{matchno} is the match number for the substring which names the entity.
If @code{'backward} @var{backregexp} is present, then the start of the entity
is found by searching backwards for @var{backregexp}.
Conversely, if @code{'forward} @var{forwardregexp} is found, then the end of
the entity is found by searching forwards for @var{forwardregexp}.
Otherwise, the start and end of the entity will be the region matched
by @var{anyentity-regexp}.
This mechanism allows fairly complex parsing of the buffer, in
particular, it allows for goal..save regions which are named
only at the end. However, it does not parse strings,
comments, or parentheses.
This variable may not need to be set: a default value which should
work for goal..saves is calculated from @code{proof-goal-with-hole-regexp},
@code{proof-goal-command-regexp}, and @code{proof-save-with-hole-regexp}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-script-find-next-entity-fn
@defvar proof-script-find-next-entity-fn
Name of function to find next interesting entity in a script buffer.@*
This is used to configure @code{func-menu}. The default value is
@code{proof-script-find-next-entity}, which searches for the next entity
based on @code{fume-function-name-regexp} which by default is set from
@code{proof-script-next-entity-regexps}.
The function should move point forward in a buffer, and return a cons
cell of the name and the beginning of the entity's region.
Note that @code{proof-script-next-entity-regexps} is set to a default value
from @code{proof-goal-with-hole-regexp} and @code{proof-save-with-hole-regexp} in
the function @code{proof-config-done}, so you may not need to worry about any
of this. See whether function menu does something sensible by
default.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-goal-command-p
@defvar proof-goal-command-p
Is this really a goal command?
@end defvar
@c TEXI DOCSTRING MAGIC: proof-completed-proof-behaviour
@defvar proof-completed-proof-behaviour
Indicates how Proof General treats commands beyond the end of a proof.@*
Normally goal...save regions are "closed", i.e. made atomic for undo.
But once a proof has been completed, there may be a delay before the
@lisp
"save" command appears --- or it may not appear at all. Unless
@end lisp
nested proofs are supported, this can spoil the undo-behaviour in
script management since once a new goal arrives the old undo history
may be lost in the prover. So we allow Proof General to close
off the goal..[save] region in more flexible ways.
The possibilities are:
@lisp
nil - nothing special; close only when a save arrives
@code{'closeany} - close as soon as the next command arrives, save or not
@code{'closegoal} - close when the next "goal" command arrives
@code{'extend} - keep extending the closed region until a save or goal.
@end lisp
If your proof assistant allows nested goals, it will be wrong to close
off the portion of proof so far, so this variable should be set to nil.
There is no built-in understanding of the undo behaviour of nested
proofs; instead there is some support for un-nesting nested proofs in
the @code{proof-lift-global} mechanism. Of course, this is risky because of
nested contexts!
@end defvar
@c TEXI DOCSTRING MAGIC: proof-lift-global
@defvar proof-lift-global
Function which lifts local lemmas from inside goals out to top level.@*
This function takes the local goalsave span as an argument. Leave this
set this at @samp{nil} if the proof assistant does not support nested goals,
or if you don't want to write a function to do move them around.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-count-undos-fn
@defvar proof-count-undos-fn
Function to compute number of undos in a target segment.@*
This is an important function for script management.
Study one of the existing instantiations for examples of how to write it.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-find-and-forget-fn
@defvar proof-find-and-forget-fn
Function that returns a command to forget back to before its argument span.@*
This setting is used to for retraction (undoing) in proof scripts.
It should undo the effect of all settings between its target span
up to (proof-unlocked-begin). This may involve forgetting a number
of definitions, declarations, or whatever.
The special string @code{proof-no-command} means there is nothing to do.
This is an important function for script management.
Study one of the existing instantiations for examples of how to write it.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-goal-hyp-fn
@defvar proof-goal-hyp-fn
Function which returns cons cell if point is at a goal/hypothesis.@*
First element of cell is a symbol, @code{'goal'} or @code{'hyp'}. The second
element is a string: the goal or hypothesis itself. This is used
when parsing the proofstate output.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-kill-goal-command
@defvar proof-kill-goal-command
Command to kill the currently open goal.@*
You must set this (perhaps to a no-op) for script management to work.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-global-p
@defvar proof-global-p
Whether a command is a global declaration. Predicate on strings or nil.@*
This is used to handle nested goals allowed by some provers.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-state-preserving-p
@defvar proof-state-preserving-p
A predicate, non-nil if its argument (a command) preserves the proof state.@*
If set, used by @code{proof-minibuffer-cmd} to filter out scripting
commands which should be entered directly into the script itself.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-activate-scripting-hook
@defvar proof-activate-scripting-hook
Hook run when a buffer is switched into scripting mode.@*
The current buffer will be the newly active scripting buffer.
This hook may be useful for synchronizing with the proof
assistant, for example, to switch to a new theory
(in case that isn't already done by commands in the proof
script).
When functions in this hook are called, the variable
@samp{activated-interactively} will be non-nil if
@code{proof-activate-scripting} was called interactively
(rather than as a side-effect of some other action).
If a hook function sends commands to the proof process,
it should wait for them to complete (so the queue is cleared
for scripting commands), unless activated-interactively is set.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-stack-to-indent
@defvar proof-stack-to-indent
Prover-specific code for indentation.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-parse-indent
@defvar proof-parse-indent
Proof-assistant specific function for parsing.@*
Invoked in @samp{proof-parse-to-point}. Must be a
function taking two arguments, a character (the current character)
and a stack reflecting indentation, and must return a stack. The
stack is a list of the form (c . p) where @samp{c} is a character
representing the type of indentation and @samp{p} records the column for
indentation. The generic @samp{proof-parse-to-point} function supports
parentheses and commands. It represents these with the characters
@samp{?(}, @samp{?[} and @samp{@code{proof-terminal-char}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-font-lock-zap-commas
@defvar proof-font-lock-zap-commas
If non-nil, enable a font-lock hack which unfontifies commas.@*
If you fontify variables inside lists like [a,b,c] by matching
on the brackets @samp{[} and '[', you may take objection to the commas
being coloured as well. In that case, enable this hack which
will magically restore the commas to the default font for you.
The hack is rather painful and forces immediate fontification of
files on loading (no lazy, caching locking). It is unreliable
under FSF Emacs, to boot.
@end defvar
@xref{Handling multiple files}, for more details about the final
setting in this group.
@c TEXI DOCSTRING MAGIC: proof-auto-multiple-files
@defvar proof-auto-multiple-files
Whether to use automatic multiple file management.@*
If non-nil, Proof General will automatically retract a script file
whenever another one is retracted which it depends on. It assumes
a simple linear dependency between files in the order which
they were processed.
If your proof assistant has no management of file dependencies, or one
which depends on a simple linear context, you may be able to use this
setting to good effect. If the proof assistant has more complex
file dependencies then you should configure it to communicate with
Proof General about the dependcies rather than using this setting.
@end defvar
@node Proof shell settings
@section Proof shell settings
The variables in this section are the largest group. They concern the
proof shell mode. The first group of variables are hooks invoked at
various points. The second group of variables are concerned with
matching the output from the proof assistant.
Variables here are put into the customize group @code{proof-shell}.
These should be set in the shell mode configuration, before
@code{proof-shell-config-done} is called.
To understand the customizations for the proof shell, you may want to
refer to the @code{comint.el} (Command interpreter) package distributed
with Emacs. This package controls several shell-like modes available in
Emacs.
@menu
* Proof shell commands::
* Settings for matching output from proof process::
* Hooks and function variables::
@end menu
@node Proof shell commands
@subsection Commands
@c TEXI DOCSTRING MAGIC: proof-prog-name
@defvar proof-prog-name
System command to run the proof assistant in the proof shell.@*
Suggestion: this can be set in @code{proof-pre-shell-start-hook} from
a variable which is in the proof assistant's customization
group. This allows different proof assistants to coexist
(albeit in separate Emacs sessions).
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-init-cmd
@defvar proof-shell-init-cmd
The command for initially configuring the proof process.@*
This command is sent to the process as soon as it starts up,
perhaps in order to configure it for Proof General or to
print a welcome message.
Note that it is sent before Proof General's synchronization
mechanism is engaged (in case the command engages it). It
is better to configure the proof assistant via command
line options if possible.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-restart-cmd
@defvar proof-shell-restart-cmd
A command for re-initialising the proof process.@*
The @code{proof-terminal-char} is added on to the end.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-quit-cmd
@defvar proof-shell-quit-cmd
A command to quit the proof process. If nil, send EOF instead.@*
The @code{proof-terminal-char} is added on to the end.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-cd-cmd
@defvar proof-shell-cd-cmd
Command to the proof assistant to change the working directory.@*
The format character %s is replaced with the directory, and the
@code{proof-terminal-char} is added on to the end.
This is used to define the function @code{proof-cd} which
changes to the value of (@code{default-directory}) for script buffers.
For files, the value of (@code{default-directory}) is simply the
directory the file resides in.
NB: By default, @code{proof-cd} is called from @code{proof-activate-scripting-hook},
so that the prover switches to the directory of a proof
script every time scripting begins.
@end defvar
@xref{Handling multiple files},
for more details about the final two settings in this group,
@c TEXI DOCSTRING MAGIC: proof-shell-inform-file-processed-cmd
@defvar proof-shell-inform-file-processed-cmd
Command to the proof assistant to tell it that a file has been processed.@*
The format character %s is replaced by a complete filename for a
script file which has been fully processed interactively with
Proof General.
This is used to interface with the proof assistant's internal
management of multiple files, so the proof assistant is kept aware of
which files have been processed. Specifically, when scripting
is deactivated in a completed buffer, it is added to Proof General's
list of processed files, and the prover is told about it by
issuing this command.
If this is set to nil, no command is issued.
See also: @code{proof-shell-inform-file-retracted-cmd},
@code{proof-shell-process-file}, @code{proof-shell-compute-new-files-list}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-inform-file-retracted-cmd
@defvar proof-shell-inform-file-retracted-cmd
Command to the proof assistant to tell it that a file has been retracted.@*
The format character %s is replaced by a complete filename for a
script file which Proof General wants the prover to consider
as not completely processed.
This is used to interface with the proof assistant's internal
management of multiple files, so the proof assistant is kept aware of
which files have been processed. Specifically, when scripting
is activated, the file is removed from Proof General's list of
processed files, and the prover is told about it by issuing this
command. The action may cause the prover in turn to suggest to
Proof General that files depending on this one are
also unlocked.
If this is set to nil, no command is issued.
See also: @code{proof-shell-inform-file-processed-cmd},
@code{proof-shell-process-file}, @code{proof-shell-compute-new-files-list}.
@end defvar
@node Settings for matching output from proof process
@subsection Settings for matching output from proof process
@c TEXI DOCSTRING MAGIC: proof-shell-wakeup-char
@defvar proof-shell-wakeup-char
A special character which terminates an annotated prompt.@*
Set to nil if proof assistant does not support annotated prompts.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-first-special-char
@defvar proof-shell-first-special-char
First special character.@*
Codes above this character can have special meaning to Proof General,
and are stripped from the prover's output strings.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-prompt-pattern
@defvar proof-shell-prompt-pattern
Proof shell's value for comint-prompt-pattern, which see.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-annotated-prompt-regexp
@defvar proof-shell-annotated-prompt-regexp
Regexp matching a (possibly annotated) prompt pattern.@*
Output is grabbed between pairs of lines matching this regexp.
To help matching you may be able to annotate the proof assistant
prompt with a special character not appearing in ordinary output.
The special character should appear in this regexp, and should
be the value of @code{proof-shell-wakeup-char}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-abort-goal-regexp
@defvar proof-shell-abort-goal-regexp
Regexp matching output from an aborted proof.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-error-regexp
@defvar proof-shell-error-regexp
Regexp matching an error report from the proof assistant.
We assume that an error message corresponds to a failure in the last
proof command executed. So don't match mere warning messages with
this regexp. Moreover, an error message should not be matched as an
eager annotation (see @code{proof-shell-eager-annotation-start}) otherwise it
will be lost.
Error messages are considered to begin from @code{proof-shell-error-regexp}
and continue until the next prompt.
The engine matches interrupts before errors, see proof-shell-interupt-regexp.
It is safe to leave this variable unset (as nil).
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-interrupt-regexp
@defvar proof-shell-interrupt-regexp
Regexp matching output indicating the assistant was interrupted.@*
We assume that an interrupt message corresponds to a failure in the last
proof command executed. So don't match mere warning messages with
this regexp. Moreover, an interrupt message should not be matched as an
eager annotation (see @code{proof-shell-eager-annotation-start}) otherwise it
will be lost.
The engine matches interrupts before errors, see @code{proof-shell-error-regexp}.
It is safe to leave this variable unset (as nil).
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-proof-completed-regexp
@defvar proof-shell-proof-completed-regexp
Regexp matching output indicating a finished proof.@*
Match number 1 should be the response text.
This is used to enable the QED function (save a proof) and
to control what output appears in the response buffer at the
end of a proof.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-clear-response-regexp
@defvar proof-shell-clear-response-regexp
Regexp matching output telling Proof General to clear the response buffer.@*
This feature is useful to give the prover more control over what output
is shown to the user. Set to nil to disable.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-start-goals-regexp
@defvar proof-shell-start-goals-regexp
Regexp matching the start of the proof state output.@*
This is an important setting. Output between @samp{@code{proof-shell-start-goals-regexp}}
and @samp{@code{proof-shell-end-goals-regexp}} will be pasted into the goals buffer
and possibly analysed further for proof-by-pointing markup.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-end-goals-regexp
@defvar proof-shell-end-goals-regexp
Regexp matching the end of the proof state output.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-eager-annotation-start
@defvar proof-shell-eager-annotation-start
Eager annotation field start. A regular expression or nil.@*
An eager annotation indicates to Emacs that some following output
should be displayed immediately and not accumulated for parsing.
Set to nil to disable this feature.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-eager-annotation-end
@defvar proof-shell-eager-annotation-end
Eager annotation field end. A regular expression or nil.@*
An eager annotation indicates to Emacs that some following output
should be displayed immediately and not accumulated for parsing.
The default value is "\n" to match up to the end of the line.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-assumption-regexp
@defvar proof-shell-assumption-regexp
A regular expression matching the name of assumptions.
@end defvar
@node Hooks and function variables
@subsection Hooks and function variables
@c TEXI DOCSTRING MAGIC: proof-shell-insert-hook
@defvar proof-shell-insert-hook
Hooks run by @code{proof-shell-insert} before inserting a command.@*
Can be used to configure the proof assistant to the interface in
various ways -- for example, to observe or alter the commands sent to
the prover, or to sneak in extra commands to configure the prover.
This hook is called inside a @code{save-excursion} with the @code{proof-shell-buffer}
current, just before inserting and sending the text in the
variable @samp{string}. The hook can massage @samp{string} or insert additional
text directly into the @code{proof-shell-buffer}.
Before sending @samp{string}, it will be stripped of carriage returns.
Additionally, the hook can examine the variable @samp{action}. It will be
a symbol, set to the callback command which is executed in the proof
shell filter once @samp{string} has been processed. The @samp{action} variable
suggests what class of command is about to be inserted:
@lisp
@code{'proof-shell-done-invisible} A non-scripting command
@code{'proof-done-advancing} A "forward" scripting command
@code{'proof-done-retracting} A "backward" scripting command
@end lisp
Caveats: You should be very careful about setting this hook. Proof
General relies on a careful synchronization with the process between
inputs and outputs. It expects to see a prompt for each input it
sends from the queue. If you add extra input here and it causes more
prompts than expected, things will break! Extending the variable
@samp{string} may be safer than inserting text directly, since it is
stripped of carriage returns before being sent.
Example uses:
@var{lego} uses this hook for setting the pretty printer width if
the window width has changed;
Plastic uses it to remove literate-style markup from @samp{string}.
The x-symbol support uses this hook to convert special characters
into tokens for the proof assistant.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-pre-shell-start-hook
@defvar proof-pre-shell-start-hook
Hooks run before proof shell is started.@*
Suggestion: set this to a function which configures just these proof
shell variables:
@lisp
@code{proof-prog-name}
@code{proof-mode-for-shell}
@code{proof-mode-for-response}
@code{proof-mode-for-pbp}
@end lisp
This is the bare minimum needed to get a shell buffer and
its friends configured in the function @code{proof-shell-start}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-handle-error-or-interrupt-hook
@defvar proof-shell-handle-error-or-interrupt-hook
Run after an error or interrupt has been reported in the response buffer.@*
Hook functions may inspect @samp{@code{proof-shell-error-or-interrupt-seen}} to
determine whether the cause was an error or interrupt.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-process-output-system-specific
@defvar proof-shell-process-output-system-specific
Set this variable to handle system specific output.@*
Errors, start of proofs, abortions of proofs and completions of
proofs are recognised in the function @samp{@code{proof-shell-process-output}}.
All other output from the proof engine is simply reported to the
user in the @var{response} buffer.
To catch further special cases, set this variable to a pair of
functions '(condf . actf). Both are given (cmd string) as arguments.
@samp{cmd} is a string containing the currently processed command.
@samp{string} is the response from the proof system. To change the
behaviour of @samp{@code{proof-shell-process-output}}, (condf cmd string) must
return a non-nil value. Then (actf cmd string) is invoked. See the
documentation of @samp{@code{proof-shell-process-output}} for the required
output format.
@end defvar
@xref{Handling multiple files}, for more details about the final three
settings in this section.
@vindex proof-included-files-list
@c TEXI DOCSTRING MAGIC: proof-shell-process-file
@defvar proof-shell-process-file
A pair (@var{regexp} . @var{function}) to match a processed file name.
If @var{regexp} matches output, then the function @var{function} is invoked on the
output string chunk. It must return a script file name (with complete
path) the system has successfully processed. In practice, @var{function} is
likely to inspect the match data. If it returns the empty string,
the file name of the scripting buffer is used instead. If it
returns nil, no action is taken.
Care has to be taken in case the prover only reports on compiled
versions of files it is processing. In this case, @var{function} needs to
reconstruct the corresponding script file name. The new (true) file
name is added to the front of @samp{@code{proof-included-files-list}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-retract-files-regexp
@defvar proof-shell-retract-files-regexp
Matches a message that the prover has retracted a file.
At this stage, Proof General's view of the processed files is out of
date and needs to be updated with the help of the function
@samp{@code{proof-shell-compute-new-files-list}}.
@end defvar
@vindex proof-included-files-list
@c TEXI DOCSTRING MAGIC: proof-shell-compute-new-files-list
@defvar proof-shell-compute-new-files-list
Function to update @samp{proof-included-files list}.
It needs to return an up to date list of all processed files. Its
output is stored in @samp{@code{proof-included-files-list}}. Its input is the
string of which @samp{@code{proof-shell-retract-files-regexp}} matched a
substring. In practice, this function is likely to inspect the
previous (global) variable @samp{@code{proof-included-files-list}} and the match
data triggered by @samp{@code{proof-shell-retract-files-regexp}}.
@end defvar
@node Splash screen settings
@section Splash screen settings
The splash screen can be configured, in a rather limited way.
@c TEXI DOCSTRING MAGIC: proof-splash-time
@defvar proof-splash-time
Minimum number of seconds to display splash screen for.@*
The splash screen may be displayed for a couple of seconds longer than
this, depending on how long it takes the machine to initialise
Proof General.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-splash-contents
@defvar proof-splash-contents
Evaluated to configure splash screen displayed when entering Proof General.@*
A list of the screen contents. If an element is a string or an image
specifier, it is displayed centred on the window on its own line.
If it is nil, a new line is inserted.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-splash-extensions
@defvar proof-splash-extensions
Prover specific extensions of splash screen.@*
These are evaluated and appended to @samp{@code{proof-splash-contents}}.
@end defvar
@node Goals buffer settings
@section Goals buffer settings
The goals buffer settings allow configuration of Proof General for proof
by pointing or similar features.
@c At the moment these settings are disabled.
@c TEXI DOCSTRING MAGIC: pbp-change-goal
@defvar pbp-change-goal
Command to change to the goal @samp{%s}
@end defvar
@c TEXI DOCSTRING MAGIC: pbp-goal-command
@defvar pbp-goal-command
Command informing the prover that @samp{@code{pbp-button-action}} has been@*
requested on a goal.
@end defvar
@c TEXI DOCSTRING MAGIC: pbp-hyp-command
@defvar pbp-hyp-command
Command informing the prover that @samp{@code{pbp-button-action}} has been@*
requested on an assumption.
@end defvar
@c TEXI DOCSTRING MAGIC: pbp-error-regexp
@defvar pbp-error-regexp
Regexp indicating that the proof process has identified an error.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-result-start
@defvar proof-shell-result-start
Regexp matching start of an output from the prover after pbp commands.@*
In particular, after a @samp{@code{pbp-goal-command}} or a @samp{@code{pbp-hyp-command}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-result-end
@defvar proof-shell-result-end
Regexp matching end of output from the prover after pbp commands.@*
In particular, after a @samp{@code{pbp-goal-command}} or a @samp{@code{pbp-hyp-command}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-start-char
@defvar proof-shell-start-char
Starting special for a subterm markup.@*
Subsequent characters with values @strong{below} @code{proof-shell-first-special-char}
are assumed to be subterm position indicators. Subterm markups should
be finished with @code{proof-shell-end-char}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-end-char
@defvar proof-shell-end-char
Finishing special for a subterm markup.@*
See documentation of @code{proof-shell-start-char}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-goal-char
@defvar proof-shell-goal-char
goal mark
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-field-char
@defvar proof-shell-field-char
annotated field end
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-start-char
@defvar proof-shell-start-char
Starting special for a subterm markup.@*
Subsequent characters with values @strong{below} @code{proof-shell-first-special-char}
are assumed to be subterm position indicators. Subterm markups should
be finished with @code{proof-shell-end-char}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-end-char
@defvar proof-shell-end-char
Finishing special for a subterm markup.@*
See documentation of @code{proof-shell-start-char}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-goal-char
@defvar proof-shell-goal-char
goal mark
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-field-char
@defvar proof-shell-field-char
annotated field end
@end defvar
The final setting just configures where the ``proof completed''
message appears.
@c TEXI DOCSTRING MAGIC: proof-goals-display-qed-message
@defvar proof-goals-display-qed-message
If non-nil, display the proof-completed message in the goals buffer.@*
For some proof assistants (e.g. Isabelle) it seems aesthetic to
display the QED message in the goals buffer, even though it doesn't
contain any goals and shouldn't be marked up for proof-by-pointing.
If this setting is non-nil, QED messages appear in the goals
buffer. Otherwise they appear in the response buffer.
@end defvar
@node Global constants
@section Global constants
The settings here are internal constants used by Proof General.
You don't need to configure these for your proof assistant
unless you want to modify or extend the defaults.
@c TEXI DOCSTRING MAGIC: proof-general-name
@defvar proof-general-name
Proof General name used internally and in menu titles.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-general-home-page
@defopt proof-general-home-page
Web address for Proof General
The default value is @code{"http://www.dcs.ed.ac.uk/home/proofgen"}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-universal-keys
@defvar proof-universal-keys
List of keybindings made for the script, goals and response buffer. @*
Elements of the list are tuples @samp{(k . f)}
where @samp{k} is a keybinding (vector) and @samp{f} the designated function.
@end defvar
@node Handling multiple files
@section Handling multiple files
@cindex Multiple files
Large proof developments are typically spread across multiple files.
Many provers support such developments by keeping track of dependencies
and automatically processing scripts. Proof General supports this
mechanism. The user's point of view was considered in @ref{Advanced
Script Management}. Here, we describe the more technical nitty
gritty. This is what you need to know when you customise another proof
assistant to work with Proof General.
Documentation for the configuration settings mentioned here appears in
the previous sections, this section is intended to help explain the use
of those settings.
Proof General maintains a list @code{proof-included-files-list} of files
which it thinks have been processed by the proof assistant. When a file
which is on this list is visited in Emacs, it will be coloured entirely
blue to indicate that it has been processed. No editing of the file
will be allowed (unless @code{proof-strict-read-only} allows it).
@c TEXI DOCSTRING MAGIC: proof-included-files-list
@defvar proof-included-files-list
List of files currently included in proof process.@*
This list contains files in canonical truename format
(see @samp{@code{file-truename}}).
Whenever a new file is being processed, it gets added to this list
via the @code{proof-shell-process-file} configuration settings.
When the prover retracts a file, this list is resynchronised via the
@code{proof-shell-retract-files-regexp} and @code{proof-shell-compute-new-files-list}
configuration settings.
Only files which have been @strong{fully} processed should be included here.
Proof General itself will automatically add the filenames of a script
buffer which has been completely read when scripting is deactivated.
It will automatically remove the filename of a script buffer which
is completely unread when scripting is deactivated.
NB: Currently there is no generic provision for removing files which
are only partly read-in due to an error, so ideally the proof assistant
should only output a processed message when a file has been successfully
read.
@end defvar
The way that @code{proof-included-files-list} is maintained is the key
to multiple file management. (But you should not set this variable
directly, it is managed via the configuration setttings).
@vindex proof-shell-process-file
@vindex proof-shell-retract-files-regexp
@vindex proof-shell-compute-new-files-list
There is a range of strategies for managing multiple files. Ideally,
file dependencies should be managed by the proof assistant. Proof
General will use the prover's low-level commands to process a whole file
and its requirements non-interactively, without going through script
management. So that the user knows which files have been processed, the
proof assistant should issue messages which Proof General can recognize
(``file @code{foo} has been processed'') --- see
@code{proof-shell-process-file}. When the user wants to edit a file
which has been processed, it must be retracted (unlocked). The proof
assistant should provide a command corresponding to this action, which
undoes a given file and all its dependencies. As each file is undone, a
message should be issued which Proof General can recognize (``file
@code{foo} has been undone'') -- see
@code{proof-shell-retract-files-regexp}. (The function
@code{proof-shell-compute-new-files-list} can be set to calculate the
new value for @code{proof-included-files-list}).
@c The key idea is that we leave it to the specific proof assistant to
@c worry about managing multiple files, as far as possible. Whenever the
@c proof assistant processes or retracts a file it must clearly say so, so
@c that Proof General can register this.
As well as this communication from the assistant to Proof General about
processed or retracted files, Proof General can communicate the other
way: it will tell the proof assistant when it has processed or retracted
a file via script management. This is because during script management,
the proof assistant may not be aware that it is actually dealing with a
file of proof commands (rather than just terminal input).
Proof General will provide this information in two special instances.
First, when scripting is turned off in a file that has been completely
processed, Proof General will tell the proof assistant using
@code{proof-shell-inform-file-processed-cmd}. Second, when scripting is
turned on in a file which is completely processed, Proof General will
tell the proof assistant to reconsider: the file should not be
considered completely processed yet. This uses the setting
@code{proof-shell-inform-file-retracted-cmd}. This second case might
lead to a series of messages from the prover telling Proof General to
unlock files which depend on the present one, again via
@code{proof-shell-retract-files-regexp}.
What we have described so far is the ideal case, but it may require some
support from the proof assistant to set up (for example, if file-level
undo is not normally supported, or the messages during file processing
are not suitable). Moreover, some proof assistants may not have file
handling with dependencies, or may have a particularly simple case of a
linear context: each file depends on all the ones processed before it.
Proof General allows you a shortcut to get automatic management of
multiple files in these cases by setting the flag
@code{proof-auto-multiple-files}. This setting is probably an
approximation to the right thing for any proof assistant. More files
than necessary will be retracted if the prover has a tree-like file
dependency rather than a linear one.
@vindex proof-shell-eager-annotation-start
@vindex proof-shell-eager-annotation-end
Finally, we should mention how Proof General recognizes file processing
messages from the proof assistant. Proof General considers @var{output}
delimited by the the two regular expressions
@code{proof-shell-eager-annotation-start} and
@code{proof-shell-eager-annotation-end} as being important. It displays
the @var{output} in the Response buffer and analyses the contents
further. Among possibly other important messages characterised by these
regular expressions (warnings, errors, or information), the prover can
tell the interface whenever it processes or retracts a file.
To summarize, the settings for multiple file management that may be
customized are as follows. To recognize file-processing,
@code{proof-shell-process-file}. To recognize messages about file
undoing, @code{proof-shell-retract-files-regexp} and
@code{proof-shell-compute-new-files-list}. @xref{Hooks and function
variables}. To tell the prover about files handled with
script management, use
@code{proof-shell-inform-file-processed-cmd} and
@code{proof-shell-inform-file-retracted-cmd}. @xref{Proof shell
commands}. Finally, set the flag @code{proof-auto-multiple-files}
for a automatic approximation to multiple file handling.
@xref{Proof script settings}.
@node Configuring X-Symbol
@section Configuring X-Symbol
@cindex X-Symbol
The X-Symbol package (by Christoph Wedler) displays characters from a
variety of fonts in Emacs buffers, automatically converting between
codes for special characters and @i{tokens} which are character
sequences stored in files.
Proof General can use X-Symbol to allow interaction between the user and
the proof assistant to use tokens, yet appear to be using special
characters. So proof scripts and proofs themselves can be processed
with non-ascii characters for mathematical symbols.
To configure X-Symbol for Proof General, you must understand a little
bit of how X-Symbol works: read the documentation that is supplied with
it. The basic task is to set up a @i{token language} for your proof
assistant. If your assistant is stored in the subdirectory
@var{myprover}, the token language will be called @var{myprover} and be
defined in a file @file{x-symbol-@var{myprover}.el} which is
automatically loaded by X-Symbol. The name of the token language mode
will be @code{@var{myprover}sym}.
In the usual configuration file @file{@var{myprover}.el}, you must set
several variables that Proof General uses to configure X-Symbol with.
@c FIXME: more here!! unfinished!!
@code{@var{myprover}sym-font-lock-keywords}
@c TEXI DOCSTRING MAGIC: proof-xsym-activate-command
@defvar proof-xsym-activate-command
Command to activate token input/output for X-Symbol.@*
If non-nil, this command is sent to the proof assistant when
X-Symbol support is activated.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-xsym-deactivate-command
@defvar proof-xsym-deactivate-command
Command to deactivate token input/output for X-Symbol.@*
If non-nil, this command is sent to the proof assistant when
X-Symbol support is deactivated.
@end defvar
We expect tokens to be used uniformly, so that along with each script
mode buffer, the response buffer, goals buffer, and shell buffer are all
kept in X-Symbol minor mode to display special characters. This happens
automatically. If you want additional modes, you can set
@code{proof-xsym-extra-modes}.
@c TEXI DOCSTRING MAGIC: proof-xsym-extra-modes
@defvar proof-xsym-extra-modes
List of additional mode names to use X-Symbol with Proof General tokens.@*
These modes will have X-Symbol enabled for the proof assistant token language,
in addition to the four modes for Proof General (script, shell, response, pbp).
Set this variable if you want additional modes to also display
tokens (for example, editing documentation or source code files).
@end defvar
@node Internals of Proof General
@chapter Internals of Proof General
This chapter sketches some of the internal functions and variables of
Proof General, to help developers who wish to understand or modify the
code.
Most of the documentation below is generated automatically from the
comments in the code. Because Emacs lisp is interpreted and
self-documenting, the best way to find your way around the source is
inside Emacs once Proof General is loaded. Read the source files, and
use functions such as @kbd{C-h v} and @kbd{C-h f}.
The code is split into files. The following sections document the
important files, kept in the @file{generic/} subdirectory.
@menu
* Spans::
* User option conventions::
* Proof General site configuration::
* Global variables::
* Proof script mode::
* Proof shell mode::
* Debugging::
@end menu
@node Spans
@section Spans
@cindex spans
@cindex extents
@cindex overlays
@dfn{Spans} are an abstraction of XEmacs @dfn{extents} used to help
bridge the gulf between FSF GNU Emacs and XEmacs. In FSF GNU Emacs, spans are
implemented using @dfn{overlays}.
See the files @file{span-extent.el} and @file{span-overlay.el} for the
implementation of the common interface in each case.
@node Proof General site configuration
@section Proof General site configuration
@cindex installation directories
@cindex site configuration
The file @file{proof-site.el} contains the initial configuration for
Proof General for the site (or user) and the choice of provers.
The first part of the configuration is to set
@code{proof-home-directory} to the directory that @file{proof-site.el}
is located in, or to the variable of the environment variable
@code{PROOFGENERAL_HOME} if that is set.
@c TEXI DOCSTRING MAGIC: proof-home-directory
@defvar proof-home-directory
Directory where Proof General is installed. Ends with slash.@*
Default value taken from environment variable @samp{PROOFGENERAL_HOME} if set,
otherwise based on where the file @samp{proof-site.el} was loaded from.
You can use customize to set this variable.
@end defvar
@c They're no longer options.
@c The default value for @code{proof-home-directory} mentioned above is the
@c one for the author's system, it won't be the same for you!
Further directory variables allow the files of Proof General to be split
up and installed across a system if need be, rather than under the
@code{proof-home-directory} root.
@c TEXI DOCSTRING MAGIC: proof-images-directory
@defvar proof-images-directory
Where Proof General image files are installed. Ends with slash.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-info-directory
@defvar proof-info-directory
Where Proof General Info files are installed. Ends with slash.
@end defvar
@cindex mode stub
After defining these settings, we define a @dfn{mode stub} for each
proof assistant enabled. The mode stub will autoload Proof General for
the right proof assistant when a file is visited with the corresponding
extension. The proof assistants enabled are the ones listed
in the @code{proof-assistants} setting.
@c TEXI DOCSTRING MAGIC: proof-assistants
@defopt proof-assistants
Choice of proof assistants to use with Proof General.@*
A list of symbols chosen from: @code{'demoisa} @code{'isar} @code{'isa} @code{'lego} @code{'coq} @code{'plastic}.
Each proof assistant defines its own instance of Proof General,
providing session control, script management, etc. Proof General
will be started automatically for the assistants chosen here.
To avoid accidently invoking a proof assistant you don't have,
only select the proof assistants you (or your site) may need.
You can select which proof assistants you want by setting this
variable before @samp{proof-site.el} is loaded, or by setting
the environment variable @samp{PROOFGENERAL_ASSISTANTS} to the
symbols you want, for example "lego isa". Or you can
edit the file @samp{proof-site.el} itself.
Note: to change proof assistant, you must start a new Emacs session.
The default value is @code{(demoisa isar isa lego coq plastic)}.
@end defopt
The file @file{proof-site.el} also defines a version variable.
@c TEXI DOCSTRING MAGIC: proof-general-version
@defvar proof-general-version
Version string identifying Proof General release.
@end defvar
@node User option conventions
@section User option conventions
@cindex conventions
@cindex user options
There are several settings which can be switched on or off by the user.
These are controlled by boolean variables with names like
@code{proof-@var{foo}-enable}. These are defined with @code{defcustom}
and appear at the start of the customize group
@code{proof-user-options}. They should be edited by the user through
the customization mechanism, and set in the code using
@code{customize-set-variable}.
If changing the setting amounts to more than just setting a variable (it
may have some dynamic effect), we set the @code{custom-set} property for
the variable to the function @code{proof-set-bool} which does an
ordinary @code{set-default} to set the variable, and then calls the
@i{function} with the same name as the variable,
@code{proof-@var{foo}-enable}, to do whatever is necessary according to
the new value for the variable.
In @code{proof.el} there is a handy macro,
@code{proof-customize-toggle}, which constructs an interactive function
for toggling boolean customize settings. We can use this to make an
interactive function @code{proof-@var{foo}-toggle} to put on a menu or
bind to a key, for example.
This general scheme is followed as far as possible, to give uniform
behaviour and appearance for these cases, as well as interfacing
properly with the @code{customize} mechanism.
@node Global variables
@section Global variables
Global variables are defined in @file{proof.el}. The same file defines
a few utility functions and some triggers to load in the other files.
@c TEXI DOCSTRING MAGIC: proof-script-buffer
@defvar proof-script-buffer
The currently active scripting buffer or nil if none.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-buffer
@defvar proof-shell-buffer
Process buffer where the proof assistant is run.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-goals-buffer
@defvar proof-goals-buffer
The goals buffer (also known as the pbp buffer).
@end defvar
@c TEXI DOCSTRING MAGIC: proof-buffer-type
@defvar proof-buffer-type
Symbol indicating the type of this buffer: @code{'script}, @code{'shell}, or @code{'pbp}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-included-files-list
@defvar proof-included-files-list
List of files currently included in proof process.@*
This list contains files in canonical truename format
(see @samp{@code{file-truename}}).
Whenever a new file is being processed, it gets added to this list
via the @code{proof-shell-process-file} configuration settings.
When the prover retracts a file, this list is resynchronised via the
@code{proof-shell-retract-files-regexp} and @code{proof-shell-compute-new-files-list}
configuration settings.
Only files which have been @strong{fully} processed should be included here.
Proof General itself will automatically add the filenames of a script
buffer which has been completely read when scripting is deactivated.
It will automatically remove the filename of a script buffer which
is completely unread when scripting is deactivated.
NB: Currently there is no generic provision for removing files which
are only partly read-in due to an error, so ideally the proof assistant
should only output a processed message when a file has been successfully
read.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-proof-completed
@defvar proof-shell-proof-completed
Flag indicating that a completed proof has just been observed.@*
If non-nil, the value counts the commands from the last command
of the proof (starting from 1).
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-error-or-interrupt-seen
@defvar proof-shell-error-or-interrupt-seen
Flag indicating that an error or interrupt has just occurred.@*
Set to @code{'error} or @code{'interrupt} if one was observed from the proof
assistant during the last group of commands.
@end defvar
The @file{proof.el} also loads @file{proof-config.el} which declares the
proof assistant configuration variables for Proof General.
For details, @xref{Adapting Proof General to Other Provers}.
@node Proof script mode
@section Proof script mode
The file @file{proof-script.el} contains the main code for proof script
mode, as well as definitions of menus, keybindings, and user-level
functions.
Proof scripts have two important variables for the locked and queue
regions. These variables are local to each script buffer (although we
only really need one queue span in total rather than one per buffer).
@c TEXI DOCSTRING MAGIC: proof-locked-span
@defvar proof-locked-span
The locked span of the buffer.@*
Each script buffer has its own locked span, which may be detached
from the buffer.
Proof General allows buffers in other modes also to be locked;
these also have a non-nil value for this variable.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-queue-span
@defvar proof-queue-span
The queue span of the buffer. May be detached if inactive or empty.
@end defvar
Various utility functions manipulate and examine the spans. An
important one is @code{proof-init-segmentation}.
@c TEXI DOCSTRING MAGIC: proof-init-segmentation
@defun proof-init-segmentation
Initialise the queue and locked spans in a proof script buffer.@*
Allocate spans if need be. The spans are detached from the
buffer, so the regions are made empty by this function.
@end defun
For locking files loaded by a proof assistant, we use the next function.
@c TEXI DOCSTRING MAGIC: proof-complete-buffer-atomic
@defun proof-complete-buffer-atomic buffer
Make sure @var{buffer} is marked as completely processed, completing with a single step.
If buffer already contains a locked region, only the remainder of the
buffer is closed off atomically.
This works for buffers which are not in proof scripting mode too,
to allow other files loaded by proof assistants to be marked read-only.
@end defun
Atomic locking is instigated by the next function, which uses the
variables @code{proof-included-files-list} documented earlier
(@pxref{Handling multiple files} and @pxref{Global variables}).
@c TEXI DOCSTRING MAGIC: proof-register-possibly-new-processed-file
@defun proof-register-possibly-new-processed-file file &optional informprover
Register a possibly new @var{file} as having been processed by the prover.@*
If @var{informprover} is non-nil, the proof assistant will be told about this,
to co-ordinate with its internal file-management. (Otherwise we assume
that it is a message from the proof assistant which triggers this call).
No action is taken if the file is already registered.
A warning message is issued if the register request came from the
proof assistant and Emacs is has a modified buffer visiting the file.
@end defun
An important pair of functions activate and deactivate scripting for the
current buffer. This can trigger various actions, such as starting
up the proof assistant, or altering @code{proof-included-files-list}.
@c TEXI DOCSTRING MAGIC: proof-activate-scripting
@deffn Command proof-activate-scripting &optional nosaves queuemode
Ready prover and activate scripting for the current script buffer.
The current buffer is prepared for scripting. No changes are
necessary if it is already in Scripting minor mode. Otherwise, it
will become the new active scripting buffer, provided scripting
can be switched off in the previous active scripting buffer
with @samp{@code{proof-deactivate-scripting}}.
Activating a new script buffer may be a good time to ask if the
user wants to save some buffers; this is done if the user
option @samp{@code{proof-query-file-save-when-activating-scripting}} is set
and provided the optional argument @var{nosaves} is non-nil.
The optional argument @var{queuemode} relaxes the test for a
busy proof shell to allow one which has mode @var{queuemode}.
In all other cases, a proof shell busy error is given.
Finally, the hooks @samp{@code{proof-activate-scripting-hook}} are run.
This can be a useful place to configure the proof assistant for
scripting in a particular file, for example, loading the
correct theory, or whatever.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-deactivate-scripting
@deffn Command proof-deactivate-scripting &optional forcedaction
Deactivate scripting for the active scripting buffer.
Set @code{proof-script-buffer} to nil and turn off the modeline indicator.
No action if there is no active scripting buffer.
We make sure that the active scripting buffer either has no locked
region or everything in it has been processed. This is done by
prompting the user or by automatically taking the action indicated in
the user option @samp{@code{proof-auto-action-when-deactivating-scripting}.}
If the scripting buffer is (or has become) fully processed, and
it is associated with a file, it is registered on
@samp{@code{proof-included-files-list}}. Conversely, if it is (or has become)
empty, make sure that it is @strong{not} registered. This is to
make sure that the included files list behaves as we might expect
with respect to the active scripting buffer, in an attempt to
harmonize mixed scripting and file reading in the prover.
This function either succeeds, fails because the user
refused to process or retract a partly finished buffer,
or gives an error message because retraction or processing failed.
If this function succeeds, then proof-script-buffer=nil afterwards.
The optional argument @var{forcedaction} overrides the user option
@samp{@code{proof-auto-action-when-deactivating-scripting}} and prevents
questioning the user. It is used to make a value for
the @code{kill-buffer-hook} for scripting buffers, so that when
a scripting buffer is killed it is always retracted.
@end deffn
The next function is the main one used for parsing the proof script
buffer.
@c TEXI DOCSTRING MAGIC: proof-segment-up-to
@defun proof-segment-up-to pos &optional next-command-end
Create a list of (type,int,string) tuples from end of queue/locked region to @var{pos}.@*
Each tuple denotes the command and the position of its terminator,
type is one of @code{'comment}, or @code{'cmd}. @code{'unclosed-comment} may be consed onto
the start if the segment finishes with an unclosed comment.
If optional @var{next-command-end} is non-nil, we contine past @var{pos} until
the next command end.
@end defun
The function @code{proof-semis-to-vanillas} is used to convert
a parsed region of the script into a series of commands to
be sent to the proof assistant.
@c TEXI DOCSTRING MAGIC: proof-semis-to-vanillas
@defun proof-semis-to-vanillas semis &optional callback-fn
Convert a sequence of terminator positions to a set of vanilla extents.@*
Proof terminator positions @var{semis} has the form returned by
the function @code{proof-segment-up-to}.
@end defun
The function @code{proof-assert-until-point} is the main one used to
process commands in the script buffer. It's actually used to implement
the assert-until-point, electric terminator keypress, and
find-next-terminator behaviours. In different cases we want different
things, but usually the information (i.e. are we inside a comment) isn't
available until we've actually run @code{proof-segment-up-to (point)},
hence all the different options when we've done so.
@c TEXI DOCSTRING MAGIC: proof-assert-until-point
@defun proof-assert-until-point &optional unclosed-comment-fun ignore-proof-process-p
Process the region from the end of the locked-region until point.@*
Default action if inside a comment is just process as far as the start of
the comment.
If you want something different, put it inside
@var{unclosed-comment-fun}. If @var{ignore-proof-process-p} is set, no commands
will be added to the queue and the buffer will not be activated for
scripting.
@end defun
@code{proof-assert-next-command} is a variant of this function.
@c TEXI DOCSTRING MAGIC: proof-assert-next-command
@defun proof-assert-next-command &optional unclosed-comment-fun ignore-proof-process-p dont-move-forward for-new-command
Process until the end of the next unprocessed command after point.@*
If inside a comment, just process until the start of the comment.
If you want something different, put it inside @var{unclosed-comment-fun}.
If @var{ignore-proof-process-p} is set, no commands will be added to the queue.
Afterwards, move forward to near the next command afterwards, unless
@var{dont-move-forward} is non-nil. If @var{for-new-command} is non-nil,
a space or newline will be inserted automatically.
@end defun
The main command for retracting parts of a script is
@code{proof-retract-until-point}.
@c TEXI DOCSTRING MAGIC: proof-retract-until-point
@defun proof-retract-until-point &optional delete-region
Set up the proof process for retracting until point.@*
In particular, set a flag for the filter process to call
@samp{@code{proof-done-retracting}} after the proof process has successfully
reset its state.
If @var{delete-region} is non-nil, delete the region in the proof script
corresponding to the proof command sequence.
If invoked outside a locked region, undo the last successfully processed
command.
@end defun
To clean up when scripting is stopped, a script buffer is killed, or the
proof assistant exits, we use the functions
@code{proof-deactivate-scripting}, @code{proof-restart-buffers}, and
@code{proof-script-remove-all-spans-and-deactivate}.
@c TEXI DOCSTRING MAGIC: proof-deactivate-scripting
@deffn Command proof-deactivate-scripting &optional forcedaction
Deactivate scripting for the active scripting buffer.
Set @code{proof-script-buffer} to nil and turn off the modeline indicator.
No action if there is no active scripting buffer.
We make sure that the active scripting buffer either has no locked
region or everything in it has been processed. This is done by
prompting the user or by automatically taking the action indicated in
the user option @samp{@code{proof-auto-action-when-deactivating-scripting}.}
If the scripting buffer is (or has become) fully processed, and
it is associated with a file, it is registered on
@samp{@code{proof-included-files-list}}. Conversely, if it is (or has become)
empty, make sure that it is @strong{not} registered. This is to
make sure that the included files list behaves as we might expect
with respect to the active scripting buffer, in an attempt to
harmonize mixed scripting and file reading in the prover.
This function either succeeds, fails because the user
refused to process or retract a partly finished buffer,
or gives an error message because retraction or processing failed.
If this function succeeds, then proof-script-buffer=nil afterwards.
The optional argument @var{forcedaction} overrides the user option
@samp{@code{proof-auto-action-when-deactivating-scripting}} and prevents
questioning the user. It is used to make a value for
the @code{kill-buffer-hook} for scripting buffers, so that when
a scripting buffer is killed it is always retracted.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-restart-buffers
@defun proof-restart-buffers buffers
Remove all extents in @var{buffers} and maybe reset @samp{@code{proof-script-buffer}}.@*
No effect on a buffer which is nil or killed. If one of the buffers
is the current scripting buffer, then @code{proof-script-buffer}
will deactivated.
@end defun
@c TEXI DOCSTRING MAGIC: proof-script-remove-all-spans-and-deactivate
@defun proof-script-remove-all-spans-and-deactivate
Remove all spans from scripting buffers via @code{proof-restart-buffers}.
@end defun
@c
@c SECTION: Proof Shell Mode
@c
@node Proof shell mode
@section Proof shell mode
@cindex proof shell mode
@cindex comint-mode
The proof shell mode code is in the file @file{proof-shell.el}. Proof
shell mode is defined to inherit from @code{comint-mode} using
@code{define-derived-mode} near the end of the file. The bulk of the
code in the file is concerned with sending code to and from the shell,
and processing output for the associated buffers (goals and response).
Clever process handling is a tricky issue. Proof General attempts to
manage the process strictly, by maintaining a queue of commands to send to
the process. Once a command has been processed, another one is popped
off the queue and sent.
There are several important internal variables which control
interaction with the process.
@c TEXI DOCSTRING MAGIC: proof-shell-busy
@defvar proof-shell-busy
A lock indicating that the proof shell is processing.@*
When this is non-nil, @code{proof-shell-ready-prover} will give
an error.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-marker
@defvar proof-marker
Marker in proof shell buffer pointing to previous command input.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-action-list
@defvar proof-action-list
A list of@*
@lisp
(@var{span} @var{command} @var{action})
@end lisp
triples, which is a queue of things to do.
See the functions @samp{@code{proof-start-queue}} and @samp{proof-exec-loop}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-analyse-using-stack
@defvar proof-analyse-using-stack
Choice of syntax tree encoding for terms.
If @samp{nil}, prover is expected to make no optimisations.
If non-@samp{nil}, the pretty printer of the prover only reports local changes.
For @var{lego} 1.3.1 use @samp{nil}, for Coq 6.2, use @samp{t}.
@end defvar
The function @code{proof-shell-start} is used to initialise a shell
buffer and the associated buffers.
@c TEXI DOCSTRING MAGIC: proof-shell-start
@deffn Command proof-shell-start
Initialise a shell-like buffer for a proof assistant.
Also generates goal and response buffers.
Does nothing if proof assistant is already running.
@end deffn
The function @code{proof-shell-kill-function} performs the converse
function of shutting things down; it is used as a hook function for
@code{kill-buffer-hook}. Then no harm occurs if the user kills the
shell directly, or if it is done more cautiously via
@code{proof-shell-exit}. The function @code{proof-shell-restart} allows
a less drastic way of restarting scripting, other than killing and
restarting the process.
@c TEXI DOCSTRING MAGIC: proof-shell-kill-function
@defun proof-shell-kill-function
Function run when a proof-shell buffer is killed.@*
Attempt to shut down the proof process nicely and
clear up all the locked regions and state variables.
Value for @code{kill-buffer-hook} in shell buffer.
Also called by @code{proof-shell-bail-out} if the process is
exited by hand (or exits by itself).
@end defun
@c TEXI DOCSTRING MAGIC: proof-shell-exit
@deffn Command proof-shell-exit
Query the user and exit the proof process.
This simply kills the @code{proof-shell-buffer} relying on the hook function
@code{proof-shell-kill-function} to do the hard work.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-shell-bail-out
@defun proof-shell-bail-out process event
Value for the process sentinel for the proof assistant process.@*
If the proof assistant dies, run @code{proof-shell-kill-function} to
cleanup and remove the associated buffers. The shell buffer is
left around so the user may discover what killed the process.
@end defun
@c TEXI DOCSTRING MAGIC: proof-shell-restart
@deffn Command proof-shell-restart
Clear script buffers and send @code{proof-shell-restart-cmd}.@*
All locked regions are cleared and the active scripting buffer
deactivated.
If the proof shell is busy, an interrupt is sent with
@code{proof-interrupt-process} and we wait until the process is ready.
The restart command should re-synchronize Proof General with the proof
assistant, without actually exiting and restarting the proof assistant
process.
It is up to the proof assistant how much context is cleared: for
example, theories already loaded may be "cached" in some way,
so that loading them the next time round only performs a re-linking
operation, not full re-processing. (One way of caching is via
object files, used by Lego and Coq).
@end deffn
@c
@c INPUT
@c
@subsection Input to the shell
Input to the proof shell via the queue region is managed by the
functions @code{proof-start-queue} and @code{proof-shell-exec-loop}.
@c TEXI DOCSTRING MAGIC: proof-start-queue
@defun proof-start-queue start end alist
Begin processing a queue of commands in @var{alist}.@*
If @var{start} is non-nil, @var{start} and @var{end} are buffer positions in the
active scripting buffer for the queue region.
@end defun
@vindex proof-action-list
@c TEXI DOCSTRING MAGIC: proof-shell-exec-loop
@defun proof-shell-exec-loop
Process the @code{proof-action-list}.
@samp{@code{proof-action-list}} contains a list of (@var{span} @var{command} @var{action}) triples.
If this function is called with a non-empty @code{proof-action-list}, the
head of the list is the previously executed command which succeeded.
We execute (@var{action} @var{span}) on the first item, then (@var{action} @var{span}) on any
following items which have @code{proof-no-command} as their cmd components.
If a there is a next command after that, send it to the process. If
the action list becomes empty, unlock the process and remove the queue
region.
The return value is non-nil if the action list is now empty.
@end defun
A useful utility function for sending a single command to the process is
@code{proof-shell-invisible-command}. This should be used to implement
user-level functions rather than attempting to manipulate the proof
action list directly.
@c TEXI DOCSTRING MAGIC: proof-shell-invisible-command
@defun proof-shell-invisible-command cmd &optional wait
Send @var{cmd} to the proof process. Add terminal string if necessary.@*
By default, let the command be processed asynchronously.
But if optional @var{wait} command is non-nil, wait for processing to finish
before and after sending the command.
If @var{wait} is an integer, wait for that many seconds afterwards.
@end defun
Input is actually inserted into the shell buffer and sent to the process
by the low-level function @code{proof-shell-insert}.
@c TEXI DOCSTRING MAGIC: proof-shell-insert
@defun proof-shell-insert string action
Insert @var{string} at the end of the proof shell, call @code{comint-send-input}.
First call @code{proof-shell-insert-hook}. The argument @var{action} may be
examined by the hook to determine how to process the @var{string} variable.
Then strip @var{string} of carriage returns before inserting it and updating
@code{proof-marker} to point to the end of the newly inserted text.
Do not use this function directly, or output will be lost. It is only
used in @code{proof-append-alist} when we start processing a queue, and in
@code{proof-shell-exec-loop}, to process the next item.
@end defun
@c
@c OUTPUT
@c
@subsection Output from the shell
Two main functions deal with output, @code{proof-shell-process-output}
and @code{proof-shell-process-urgent-message}. In effect we consider
the output to be two streams intermingled: the "urgent" messages which
have "eager" annotations, as well as the ordinary ruminations from the
prover.
The idea is to conceal as much irrelevant information from the user as
possible; only the remaining output between prompts and after the last
urgent message will be a candidate for the goal or response buffer.
The variable @code{proof-shell-urgent-message-marker} tracks
the last urgent message seen.
@vindex proof-action-list
@c TEXI DOCSTRING MAGIC: proof-shell-process-output
@defun proof-shell-process-output cmd string
Process shell output (resulting from @var{cmd}) by matching on @var{string}.@*
@var{cmd} is the first part of the @code{proof-action-list} that lead to this
output. The result of this function is a pair (@var{symbol} @var{newstring}).
Here is where we recognizes interrupts, abortions of proofs, errors,
completions of proofs, and proof step hints (proof by pointing results).
They are checked for in this order, using
@lisp
@code{proof-shell-interrupt-regexp}
@code{proof-shell-error-regexp}
@code{proof-shell-abort-goal-regexp}
@code{proof-shell-proof-completed-regexp}
@code{proof-shell-result-start}
@end lisp
All other output from the proof engine will be reported to the user in
the response buffer by setting @code{proof-shell-delayed-output} to a cons
cell of ('insert . @var{text}) where @var{text} is the text string to be inserted.
Order of testing is: interrupt, abort, error, completion.
To extend this function, set @code{proof-shell-process-output-system-specific}.
The "aborted" case is intended for killing off an open proof during
retraction. Typically it the error message caused by a
@code{proof-kill-goal-command}. It simply inserts the word "Aborted" into
the response buffer. So it is expected to be the result of a
retraction, rather than the indication that one should be made.
This function can return one of 4 things as the symbol: @code{'error},
@code{'interrupt}, @code{'loopback}, or nil. @code{'loopback} means this was output from
pbp, and should be inserted into the script buffer and sent back to
the proof assistant.
@end defun
@c TEXI DOCSTRING MAGIC: proof-shell-urgent-message-marker
@defvar proof-shell-urgent-message-marker
Marker in proof shell buffer pointing to end of last urgent message.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-process-urgent-message
@defun proof-shell-process-urgent-message message
Analyse urgent @var{message} for various cases.@*
Cases are: included file, retracted file, cleared response buffer, or
if none of these apply, display it.
@var{message} should be a string annotated with
@code{proof-shell-eager-annotation-start}, @code{proof-shell-eager-annotation-end}.
@end defun
The main processing point which triggers other actions is
@code{proof-shell-filter}.
@c TEXI DOCSTRING MAGIC: proof-shell-filter
@defun proof-shell-filter str
Filter for the proof assistant shell-process.@*
A function for @code{comint-output-filter-functions}.
Deal with output and issue new input from the queue.
Handle urgent messages first. As many as possible are processed,
using the function @samp{@code{proof-shell-process-urgent-messages}}.
Otherwise wait until an annotated prompt appears in the input.
If @code{proof-shell-wakeup-char} is set, wait until we see that in the
output chunk @var{str}. This optimizes the filter a little bit.
If a prompt is seen, run @code{proof-shell-process-output} on the output
between the new prompt and the last input (position of @code{proof-marker})
or the last urgent message (position of
@code{proof-shell-urgent-message-marker}), whichever is later.
For example, in this case:
@lisp
PROMPT> @var{input}
@var{output-1}
@var{urgent-message}
@var{output-2}
PROMPT>
@end lisp
@code{proof-marker} is set after @var{input} by @code{proof-shell-insert} and
@code{proof-shell-urgent-message-marker} is set after @var{urgent-message}.
Only @var{output-2} will be processed. For this reason, error
messages and interrupt messages should @strong{not} be considered
urgent messages.
Output is processed using @code{proof-shell-filter-process-output}.
The first time that a prompt is seen, @code{proof-marker} is
initialised to the end of the prompt. This should
correspond with initializing the process. The
ordinary output before the first prompt is ignored (urgent messages,
however, are always processed; hence their name).
@end defun
@c TEXI DOCSTRING MAGIC: proof-shell-filter-process-output
@defun proof-shell-filter-process-output string
Subroutine of @code{proof-shell-filter} to process output @var{string}.
Appropriate action is taken depending on the what
@code{proof-shell-process-output} returns: maybe handle an interrupt, an
error, or deal with ordinary output which is a candidate for the goal
or response buffer. Ordinary output is only displayed when the proof
action list becomes empty, to avoid a confusing rapidly changing
output.
After processing the current output, the last step undertaken
by the filter is to send the next command from the queue.
@end defun
@c
@c SECTION: Debugging
@c
@node Debugging
@section Debugging
@cindex debugging
To debug Proof General, it may be helpful to set the
configuration variable @code{proof-show-debug-messages}.
@c TEXI DOCSTRING MAGIC: proof-show-debug-messages
@defopt proof-show-debug-messages
Whether to display debugging messages in the response buffer.@*
If non-nil, debugging messages are displayed in the response giving
information about what Proof General is doing.
To avoid erasing the messages shortly after they're printed,
you should set @samp{@code{proof-tidy-response}} to nil.
The default value is @code{t}.
@end defopt
For more information about debugging Emacs lisp, consult the Emacs Lisp
Reference Manual. I recommend using the source-level debugger
@code{edebug}.
@c
@c
@c APPENDIX: Obtaining and Installing
@c
@c
@node Obtaining and Installing
@appendix Obtaining and Installing
Proof General has its own
@uref{http://www.dcs.ed.ac.uk/home/proofgen,home page} hosted at
Edinburgh. Visit this page for the latest news!
STOP PRESS: the Proof General web pages are temporarily
being hosted at @uref{zermelo.dcs.ed.ac.uk}. Where you see
@code{www.dcs} below, replace with @code{zermelo.dcs}.
@menu
* Obtaining Proof General::
* Installing Proof General from tarball::
* Installing Proof General from RPM package::
* Setting the names of binaries::
* Notes for syssies::
@end menu
@node Obtaining Proof General
@section Obtaining Proof General
You can obtain Proof General from the URL
@example
@uref{http://www.dcs.ed.ac.uk/home/proofgen/download.html}.
@end example
The distribution is available in three forms
@itemize @bullet
@item A source tarball, @*
@uref{http://www.dcs.ed.ac.uk/home/proofgen/ProofGeneral-latest.tar.gz}
@item A Linux RPM package (for any architecture), @*
@uref{http://www.dcs.ed.ac.uk/home/proofgen/ProofGeneral-latest.noarch.rpm}
@item A developer's tarball, @*
@uref{http://www.dcs.ed.ac.uk/home/proofgen/ProofGeneral-devel-latest.tar.gz}
@end itemize
Both the source tarball and the RPM package include the generic elisp
code, code for LEGO, Coq, and Isabelle, installation instructions
(reproduced below) and this documentation.
The developer's tarball contains our full source tree, including all of
the elisp and documentation, along with our low-level list of things to
do, sources for the images, some make files used to generate the release
itself from our CVS repository, and some test files. Developers
interested in accessing our CVS repository directly should contact
@code{proofgen@@dcs.ed.ac.uk}.
@c was Installing Proof General from @file{.tar.gz}
@node Installing Proof General from tarball
@section Installing Proof General from tarball
Copy the distribution to some directory @var{mydir}.
Unpack it there. For example:
@example
# cd @var{mydir}
# gunzip ProofGeneral-@var{version}.tar.gz
# tar -xpf ProofGeneral-@var{version}.tar
@end example
If you downloaded the version called @var{latest}, you'll find it
unpacks to a numeric version number.
Proof General will now be in some subdirectory of @var{mydir}. The name
of the subdirectory will depend on the version number of Proof General.
For example, it might be @file{ProofGeneral-2.0}. It's convenient to
link it to a fixed name:
@example
# ln -sf ProofGeneral-2.0 ProofGeneral
@end example
Now put this line in your @file{.emacs} file:
@lisp
(load-file "@var{mydir}/ProofGeneral/generic/proof-site.el")
@end lisp
@node Installing Proof General from RPM package
@section Installing Proof General from RPM package
To install an RPM package you need to be root. Then type
@example
# rpm -Uvh ProofGeneral-latest.noarch.rpm
@end example
Now add the line:
@lisp
(load-file "/usr/share/emacs/ProofGeneral/generic/proof-site.el")
@end lisp
to your @file{.emacs} or the site-wide initialisation file
@file{site-start.el}.
@node Setting the names of binaries
@section Setting the names of binaries
The @code{load-file} command you have added will load @file{proof-site}
which sets the Emacs load path for Proof General and add auto-loads and
modes for the supported assistants.
The default names for proof assistant binaries may work on your system.
If not, you will need to set the appropriate variables. The easiest way
to do this (and most other customization of Proof General) is via the
Customize mechanism, see the menu item:
@example
Proof-General -> Customize -> @var{Name of Assistant} -> Prog Name
@end example
The Proof-General menu is available from script buffers after Proof
General is loaded. To load it manually, type
@lisp
M-x load-library RET proof RET
@end lisp
Notice that the customization mechanism is only available in Emacs 20.x
and XEmacs. If you cannot use customize, simply add a line like this:
@lisp
(setq isabelle-prog-name "/usr/bin/isabelle FOL")
@end lisp
to your @file{.emacs} file.
@node Notes for syssies
@section Notes for syssies
Here are some more notes for installing Proof General in more complex
ways. Only attempt things in this section if you really understand what
you're doing.
@unnumberedsubsec Byte compilation
Compilation of the Emacs lisp files improves efficiency but can
sometimes cause compatibility problems, especially if you use more than
one version of Emacs at the same time. Furthermore, we develop Proof
General with source files so may miss problems with the byte compiled
versions. If you discover problems using the byte-compiled @code{.elc}
files which aren't present using the source @code{.el} files, please
report them to us.
You can compile Proof General by typing @code{make} in the directory
where you installed it.
@unnumberedsubsec Site-wide installation
If you are installing Proof General site-wide, you can put the
components in the standard directories of the filesystem if you prefer,
providing the variables in @file{proof-site.el} are adjusted
accordingly, see @ref{Proof General site configuration}. Make sure that
the @file{generic/} and assistant-specific elisp files are kept in
subdirectories (@file{coq/}, @file{isa.}, @file{lego.}) of
@code{proof-home-directory} so that the autoload directory calculations
are correct.
To prevent every user needing to edit their own @file{.emacs} files, you
can put the @code{load-file} command to load @file{proof-site.el} into
@file{site-start.el} or similar. Consult the Emacs documentation for more
details if you don't know where to find this file.
@unnumberedsubsec Removing support for unwanted provers
You cannot run more than one instance of Proof General at a time: so if
you're using Coq, visiting an @file{.ML} file will not load Isabelle
Proof General, and the buffer remains in fundamental mode. If there are
some assistants supported that you never want to use, you can adjust the
variable @code{proof-assistants} in @file{proof-site.el} to remove the
extra autoloads. This is advisable in case the extensions clash with
other Emacs modes, for example @code{sml-mode} for @file{.ML} files, or
Verilog mode for @file{.v} files.
See @ref{Proof General site configuration} to find out how to disable
support for provers you don't use.
@c Via the Customize mechanism, see the menu:
@c @example
@c Options -> Customize -> Emacs -> External -> Proof General
@c @end example
@c or, after loading Proof General, in a proof script buffer
@c @example
@c Proof-General -> Customize
@c @end example
@c
@c
@c APPENDIX: Known bugs and workarounds
@c
@c
@node Known bugs and workarounds
@appendix Known bugs and workarounds
We mention some of the known problems with Proof General here. The list
was written for Proof General 2.0. It is not a description of all bugs
and may be out of date. @* Please consult the file
@uref{http://www.dcs.ed.ac.uk/home/proofgen/ProofGeneral/BUGS,@file{BUGS}}
in the distribution for more detailed and up-to-date information. @*
If you discover a problem which isn't mentioned in @file{BUGS}, please
let us know by sending a note to @code{proofgen@@dcs.ed.ac.uk}.
@menu
* Bugs at the generic level::
* Bugs specific to LEGO Proof General::
* Bugs specific to Coq Proof General::
* Bugs specific to Isabelle Proof General::
@end menu
@node Bugs at the generic level
@section Bugs at the generic level
@subsection Undo in XEmacs
When @code{proof-strict-read-only} is non-nil, ordinary undo in the
script buffer can edit the "uneditable region" in XEmacs. This doesn't
happen in FSF GNU Emacs. Test case: Insert some nonsense text after the
locked region. Kill the line. Process to the next command. Press
@kbd{C-x u}, nonsense text appears in locked region.
@strong{Workaround:} be careful with undo.
@subsection Font locking and read-only in FSF GNU Emacs
When @code{proof-strict-read-only} is set and font lock is switched on,
spurious "Region read only" errors are given which break font lock.
@strong{Workaround:} turn off @code{proof-strict-read-only}, font lock,
or for the best of all possible worlds, switch to XEmacs.
@subsection Pressing keyboard quit @kbd{C-g}
Using @kbd{C-g} can leave script management in a mess. The code is not
properly protected from Emacs interrupts.
@strong{Workaround:} Don't type @kbd{C-g} while script management is
processing. If you do, use @code{proof-shell-restart} to restart
the system.
@c da: Removed 11.12.98: since PG handles this gracefully now,
@c I no longer consider it a bug really.
@c @subsection One prover at a time
@c You can't use more than one proof assistant at a time in the same Emacs
@c session. Attempting to load Proof General for a second prover will
@c fail, leaving a buffer in fundamental mode instead of the Proof General
@c mode for proof scripts.
@c @strong{Workaround:} stick to one prover per Emacs session, make sure
@c that the @code{proof-assistants} variable only enables Proof General
@c for the provers you need.
@node Bugs specific to LEGO Proof General
@section Bugs specific to LEGO Proof General
@menu
* Retraction and Discharge::
* Retraction and proving::
* Non writable directories::
@end menu
@node Retraction and Discharge
@subsection Retraction and Discharge
After a @code{Discharge}, retraction ought to only be possible back to
the first declaration/definition which is discharged. However, LEGO
Proof General does not know that @code{Discharge} has such a non-local
effect. See @ref{Granularity of atomic command sequences} for a proposal
on how to fix this bug.
@strong{Workaround:} retract back to the first declaration/definition
which is discharged.
@node Retraction and proving
@subsection Retraction and proving
@cindex Retraction
Getting retraction right is tricky when working on proofs.
@subsubsection Definitions in a proof state
A thorny issue are local definitions in a proof state. LEGO cannot undo
them explicitly.
@strong{Workaround:} retract back to a command before a definition.
@subsubsection Normalisation in proofs
Normalisation commands such as @samp{Dnf}, @samp{Hnf} @samp{Normal}
cannot be undone in a proof state by Proof General.
@strong{Workaround:} retract back to the start of the proof.
@c @subsubsection Not saving proofs.
@c After LEGO has issued a @samp{*** QED ***} you may undo steps in the
@c proof as long as you don't issue a @samp{Save} command or start a new
@c proof. LEGO Proof General assumes that all proofs are terminated with a
@c proper @samp{Save} command.
@strong{Workaround:} Always issue a @samp{Save} command after completing
a proof. If you forget one, you should retract to a point before the
offending proof development.
@node Non writable directories
@subsection Non-writable directories
If LEGO 1.3.1 attempts to write a (object) file in a non-writable
directory, it forgets the protocol mechanism on how to interact with
Proof General and gets stuck.
@strong{Workaround:} Directly enter @kbd{Configure AnnotateOn;} in the
Proof Shell to recover.
@node Bugs specific to Coq Proof General
@section Bugs specific to Coq Proof General
@subsection Hard-wired tactics
The collection of tactics which Proof General is aware of is hard-wired.
Thus, user-defined tactics cannot be retracted.
@strong{Workaround:} You may need to retract to the start of the proof.
@subsection Sections
Coq Proof General does not know about Coq's Section mechanism.
@c
@c Isabelle Bugs
@c
@node Bugs specific to Isabelle Proof General
@section Bugs specific to Isabelle Proof General
Here are some bugs and problems specific to Isabelle Proof General.
@subsection Clash with @code{sml-mode}
Since Isabelle proof scripts are not differentiated from @file{.ML}
files, Proof General may compete with @code{sml-mode} (if you use it)
for controlling these buffers. To ensure Proof General wins, load it
last.
@strong{Workaround:} use another extension for real ML files, e.g.
@code{.sml}, and disable @code{.ML} from entering @code{sml-mode}.
@subsection Indentation
Isabelle Proof General doesn't support Proof General's indentation
code to indent proof scripts. In any case, Proof General's
indentation code is somewhat broken.
@strong{Workaround:} indent your script by hand.
@subsection Scripting language limitations
Since Isabelle uses ML as a top-level language for writing
proof-scripts, Proof General may have difficulty understanding scripts
which stray too far away from the standard functions, tactics, and
tacticals, or include nested structure with semicolons within a
top-level phrase. You will usually notice when a function, or whatever,
doesn't get highlighted as you might expect, or when only part of a
top-level phrase gets parsed as a command and Proof General gets
``stuck''. Sometimes you will be able to fix things by changing the
script. Generally this probably has no detrimental impact on the
interface unless you use your own variants of the @code{goal} or
@code{qed} forms.
@strong{Workaround:} Restrict yourself to standard proof script
functions, or customize some of the variables from @file{isa.el} and
@file{isa-syntax.el} appropriately.
@subsection Interaction with theory database
Isabelle Proof General uses some support from Isabelle to remove and
reload theories from the theory database. To maintain consistency,
Isabelle is rather conservative. So re-asserting a retracted file will
always re-load it, even if it has not changed. (This is because the
file may have implicit dependencies on things in the global ML
environment not made apparent by the theory structure).
This may lead to seemingly unnecessary repetition of time-consuming
proofs, so be careful not to retract more than you need!
@node Plans and ideas
@appendix Plans and ideas
This section contains some tentative plans and ideas for improving Proof
General. Please send us contributions to this wish list, or better
still, offers to implement something from it!
@menu
* Proof by pointing and similar features::
* Granularity of atomic command sequences::
* Browser mode for script files and theories::
@end menu
@node Proof by pointing and similar features
@section Proof by pointing and similar features
@cindex proof by pointing
This is a note by David Aspinall about proof by pointing and similar
features.
In fact, Proof General already contains code for proof by pointing, for
a reference see @ref{History}. However, it is slightly
LEGO specific and not robust enough.
Proof-by-pointing requires rather heavy support from the proof
assistant. There are two aspects to the support:
@itemize @bullet
@item term structure mark-up
@item proof by pointing command generation
@end itemize
Term structure mark-up is useful in itself: it allows the user to
explore the structure of a term using the mouse (the smallest
subexpression that the mouse is over is highlighted), and easily copy
subterms from the output to a proof script.
Command generation for proof by pointing might be specific to a
particular logic in use, if we hope to generate a proof command
unambiguously for any particular click. However, Proof General could
easily be generalised to offer the user a context-sensitive choice of
next commands to apply, which may be more useful in practice, and a
worthy addition to Proof General.
@node Granularity of atomic command sequences
@section Granularity of atomic command sequences
@c @cindex Granularity of Atomic Sequences
@c @cindex Retraction
@c @cindex Goal
@cindex ACS (Atomic Command Sequence)
This is a proposal by Thomas Kleymann for generalising the way Proof
General handles sequences of proof commands (@pxref{Goal-save
sequences}), particularly to make retraction more flexible.
The locked region of a script buffer contains the initial segment of
the proof script which has been processed successfully. It consists of
atomic sequences of commands (ACS). Retraction is supported to the
beginning of every ACS. By default, every command is an ACS. But the
granularity of atomicity should be able to be adjusted.
This is essential when arbitrary retraction is not supported. Usually,
after a theorem has been proved, one may only retract to the start of
the goal. One needs to mark the proof of the theorem as an ACS. At present, support for goal-save sequences @ref{Goal-save
sequences} has been hard wired. No other ACS are currently supported. We
propose the following to overcome this deficiency:
@vtable @code
@item proof-atomic-sequents-list
is a list of instructions for setting up ACSs. Each instruction is a
list of the form @code{(@var{end} @var{start} &optional
@var{forget-command})}. @var{end} is a regular expression to recognise
the last command in an ACS. @var{start} is a function. Its input is the
last command of an ACS. Its output is a regular expression to recognise
the first command of the ACS. It is evaluated once and, starting with the
command matched by @var{end}, the output is
successively matched against previously processed commands until a match
occurs (or the beginning of the current buffer is reached). The region
determined by (@var{start},@var{end}) is locked as an ACS. Optionally,
the ACS is annotated with the actual command to retract the ACS. This is
computed by applying @var{forget-command} to the first and last command
of the ACS.
For convenience one might also want to allow @var{start} to be the
symbol @samp{t} as a convenient short-hand for @code{'(lambda (str)
".")} which always matches.
@end vtable
@node Browser mode for script files and theories
@section Browser mode for script files and theories
This is a proposal by David Aspinall for a browser window.
A browser window should provide support for browsing script files and
theories. We should be able to inspect data in varying levels of
detail, perhaps using outlining mechanisms. For theories, it would be
nice to query the running proof assistant. This may require support
from the assistant in the form of output which has been specially
marked-up with an SGML like syntax, for example.
A browser would be useful to:
@itemize @bullet
@item Provide impoverished proof assistants with a browser
@item Extend the uniform interface of Proof General to theory browsing
@item Interact closely with proof script writing
@end itemize
The last point is the most important. We should be able to integrate a
search mechanism for proofs of similar theorems, theorems containing
particular constants, etc.
@node References
@unnumbered References
Script management as used in Proof General is described in the paper:
@itemize @bullet
@item @b{[BT98]}
Yves Bertot and Laurent Th@'ery. @i{A generic approach to building
user interfaces for theorem provers}. Journal of
Symbolic Computation, 25(7), pp. 161-194, February 1998.
@end itemize
Proof General has the beginnings of support for proof by pointing,
as described in the document:
@itemize @bullet
@item @b{[BKS97]}
Yves Bertot, Thomas Kleymann-Schreiber and Dilip Sequeira. @i{Implementing
Proof by Pointing without a
Structure Editor}. LFCS Technical Report ECS-LFCS-97-368. Also published as Rapport de recherche de
l'INRIA Sophia Antipolis RR-3286
@end itemize
@node Function Index
@unnumbered Function and Command Index
@printindex fn
@node Variable Index
@unnumbered Variable and User Option Index
@printindex vr
@node Keystroke Index
@unnumbered Keystroke Index
@printindex ky
@node Concept Index
@unnumbered Concept Index
@printindex cp
@page
@contents
@bye
|