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
|
\input texinfo
@c TODO: setting for configuring proof hidden regions.
@c
@c $Id$
@c
@c NB: the first line of this file uses a non-standard TeXinfo
@c hack to print in Serifa fonts. It has no effect if you don't have
@c my hacked version of TeXinfo - da.
@c
@c
@setfilename PG-adapting.info
@settitle Adapting Proof General
@setchapternewpage odd
@paragraphindent 0
@iftex
@afourpaper
@end iftex
@c
@c Some URLs.
@c FIXME: unfortunately, broken in buggy pdftexinfo.
@c so removed for now.
@set URLisamode http://homepages.inf.ed.ac.uk/da/isamode
@set URLpghome https://proofgeneral.github.io
@set URLpglatestrpm http://proofgeneral.inf.ed.ac.uk/releases/ProofGeneral-latest.noarch.rpm
@set URLpglatesttar http://proofgeneral.inf.ed.ac.uk/releases/ProofGeneral-latest.tar.gz
@set URLpglatestdev http://proofgeneral.inf.ed.ac.uk/releases/ProofGeneral-devel-latest.tar.gz
@c
@c
@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 GNU Emacs at the time of writing).
@c
@c
@c reminder about 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.
@set version 4.5-git
@set emacsversion 24.3
@set last-update September 2016
@set rcsid $Id$
@dircategory Theorem proving
@direntry
* Adapting PG: (PG-adapting). Adapt Proof General to new provers
END-INFO-DIR-ENTRY
@end direntry
@c
@c MACROS
@c
@c define one here for a command with a key-binding?
@c
@c I like the idea, but it's maybe against the TeXinfo
@c style to fix together a command and its key-binding.
@c
@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 Adapting Proof General
@subtitle Proof General --- Organize your proofs!
@sp 1
@subtitle Adapting Proof General @value{version} to new provers
@subtitle @value{last-update}
@subtitle @b{proofgeneral.github.io}
@iftex
@vskip 1cm
@image{ProofGeneral-image}
@end iftex
@author David Aspinall with T. Kleymann
@page
@vskip 0pt plus 1filll
This manual and the program Proof General are
Copyright @copyright{} 2000-2011 by members
of the 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
GNU Emacs @value{emacsversion} or (as far as possible) later versions.
Proof General is distributed under the terms of the GNU General Public
License (GPL); please check the accompanying file @file{COPYING} for
more details.
@sp 1
Visit Proof General on the web at @code{https://proofgeneral.github.io}
@c (commented; dates from CVS) Version control: @code{@value{rcsid}}
@end titlepage
@page
@ifinfo
@node Top
@top Proof General
This file documents configuration mechanisms for version @value{version}
of @b{Proof General}, a generic Emacs interface for proof assistants.
Proof General @value{version} has been tested with GNU Emacs
@value{emacsversion}. It is supplied ready customized for the proof
assistants Coq, Lego, Isabelle, and HOL.
This manual contains information for customizing to new proof
assistants; see the user manual for details about how to use
Proof General.
@menu
* Introduction::
* Beginning with a New Prover::
* Menus and Toolbar and User-level Commands::
* Proof Script Settings::
* Proof Shell Settings::
* Goals Buffer Settings::
* Splash Screen Settings::
* Global Constants::
* Handling Multiple Files::
* Configuring Editing Syntax::
* Configuring Font Lock::
* Configuring Tokens::
* Configuring Proof-Tree Visualization::
* Writing More Lisp Code::
* Internals of Proof General::
* Plans and Ideas::
* Demonstration Instantiations::
* Function Index::
* Variable Index::
* Concept Index::
@end menu
@end ifinfo
@node Introduction
@unnumbered Introduction
Welcome to Proof General!
Proof General a generic Emacs-based interface for proof assistants.
This manual contains information for adapting Proof General to new proof
assistants, and some sketches of the internal implementation. It is not
intended for most ordinary users of the system.
For full details about how to use Proof General, and information on its
availability and installation, please see the main Proof General manual
which should accompany this one.
We positively encourage the support of new systems. Proof General has
grown more flexible and useful as it has been adapted to more proof
assistants.
Typically, adding support for a new prover improves support for others,
both because the code becomes more robust, and because new ideas are
brought into the generic setting. Notice that the Proof General
framework has been built as a "product line architecture": generality
has been introduced step-by-step in a demand-driven way, rather than at
the outset as a grand design. Despite this strategy, the interface has
a surprisingly clean structure. The approach means that we fully expect
hiccups when adding support for new assistants, so the generic core may
need extension or modification. To support this we have an open
development method: if you require changes in the generic support,
please contact us (or make adjustments yourself and send them to us).
Proof General has a home page at
@uref{https://proofgeneral.github.io}. Visit this page
for the latest version of the manuals, other documentation, system
downloads, etc.
@menu
* Future::
* Credits::
@end menu
@node Future
@unnumberedsec Future
@cindex Proof General Kit
@cindex Future
The aim of the Proof General project is to provide a powerful and
configurable interfaces which help user-interaction with interactive
proof assistants.
The strategy Proof General uses is to targets power users rather than
novices; other interfaces have often neglected this class of users. But
we do include general user interface niceties, such as toolbar and
menus, which make use easier for all.
Proof General has been Emacs based so far, but plans are afoot to
liberate it from the points and parentheses of Emacs Lisp. The
successor project Proof General Kit proposes that proof assistants use a
@i{standard} XML-based protocol for interactive proof, dubbed @b{PGIP}.
PGIP enables middleware for interactive proof tools and interface
components. Rather than configuring Proof General for your proof
assistant, you will need to configure your proof assistant to understand
PGIP. There is a similarity however; the design of PGIP was based
heavily on the Emacs Proof General framework. This means that effort on
customizing Emacs Proof General to a new proof assistant is worthwhile
even in the light of PGIP: it will help you to understand Proof
General's model of interaction, and moreover, we hope to use the Emacs
customizations to provide experimental filters which allow supported
provers to communicate using PGIP.
At the time of writing, these ideas are in early stages. For latest
details, or to become involved, see
@uref{http://proofgeneral.inf.ed.ac.uk/kit, the Proof General Kit
webpage}.
@node Credits
@unnumberedsec Credits
David Aspinall put together and wrote most of this manual. Thomas
Kleymann wrote some of the text in Chapter 8. Much of the content is
generated automatically from Emacs docstrings, some of which have been
written by other Proof General developers.
@node Beginning with a New Prover
@chapter Beginning with a New Prover
Proof General has about 100 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 fraction of the variables to get the basic
features of script management working. The bare minimum for a working
prototype is about 25 simple settings.
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{Tips, ,Elisp}.
The configuration variables are declared in the file
@file{generic/proof-config.el}. The details in the central part of this
manual are based on the contents of that file, beginning in @ref{Menus and Toolbar
and User-level Commands}, and continuing until @ref{Global Constants}.
Other chapters cover the details of configuring for multiple files and
for supporting the other Emacs packages mentioned in the user manual
(@i{Support for other Packages}). If you write additional Elisp code
interfacing to Proof General, you can find out about some useful functions
by reading @ref{Writing More Lisp Code}. The last chapter of this
manual describes some of the internals of Proof General, in case you are
interested, maybe because you need to extend the generic core to do
something new.
In the rest of this chapter we describe the general mechanisms for
instantiating Proof General. We assume some knowledge of the content
of the main Proof General manual.
@menu
* Overview of adding a new prover::
* Demonstration instance and easy configuration::
* Major modes used by Proof General::
@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.
@enumerate
@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 Proof 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 Proof General modes in @file{myassistant.el},
by setting configuration variables to customize the
behaviour of the generic modes.
@end enumerate
@c You could begin by setting a minimum number of the variables, then
@c adjust the settings via the customize menus, under Proof-General ->
@c Internals.
@c TEXI DOCSTRING MAGIC: proof-assistant-table
@defopt proof-assistant-table
Proof General's table of supported proof assistants.@*
This is copied from @samp{@code{proof-assistant-table-default}} at load time,
removing any entries that do not have a corresponding directory
under @samp{@code{proof-home-directory}}.
Each entry is a list of the form
@lisp
(@var{symbol} @var{name} @var{file-extension} [AUTOMODE-REGEXP] [IGNORED-EXTENSIONS-LIST])
@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}
(or with extension @var{file-extension}) are visited. If present,
@var{ignored-extensions-list} is a list of file-name extensions to be
ignored when doing file-name completion (@var{ignored-extensions-list}
is added to @samp{@code{completion-ignored-extensions}}).
@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 @var{proof-home-directory} is the value of the
variable @samp{@code{proof-home-directory}}.
The default value is @code{((isar "Isabelle" "thy") (coq "Coq" "v" nil (".vo" ".glob")) (easycrypt "EasyCrypt" "ec" "\\.eca?\\'") (phox "PhoX" "phx" nil (".phi" ".pho")) (pgshell "PG-Shell" "pgsh") (pgocaml "PG-OCaml" "pgml") (pghaskell "PG-Haskell" "pghci"))}.
@end defopt
The final step of the description above is where the work lies. There
are two basic methods. You can write some Emacs lisp functions and
define the modes using the macro @code{define-derived-mode}. Or you can
use the new easy configuration mechanism of Proof General 3.0 described
in the next section, which calls @code{define-derived-mode} for you.
You still need to know which configuration variables should be set, and
how to set them.
The documentation below (and inside Emacs) should help with that, but
the best way to begin might be to use an existing Proof General instance
as an example.
@node Demonstration instance and easy configuration
@section Demonstration instance and easy configuration
Proof General is supplied with a demonstration instance for Isabelle
which configures the basic features. This is a whittled down version of
Isabelle Proof General, which you can use as a template to get support
for a new assistant going. Check the directory @file{demoisa} for the
two files @file{demoisa.el} and @file{demoisa-easy.el}.
The file @file{demoisa.el} follows the scheme described in @ref{Major
modes used by Proof General}. It uses the Emacs Lisp macro
@code{define-derived-mode} to define the four modes for a Proof General
instance, by inheriting from the generic code. Settings which configure
Proof General are made by functions called from within each mode, as
appropriate.
The file @file{demoisa-easy.el} uses a new simplified mechanism to
achieve (virtually) the same result. It uses the macro
@code{proof-easy-config} defined in @file{proof-easy-configl.el} to make
all of the settings for the Proof General instance in one go, defining
the derived modes automatically using a regular naming scheme. No lisp
code is used in this file except the call to this macro. The minor
difference in the end result is that all the variables are set at once,
rather than inside each mode. But since the configuration variables are
all global variables anyway, this makes no real difference.
The macro @code{proof-easy-config} is called like this:
@lisp
(proof-easy-config @var{myprover} "@var{MyProver}"
@var{config_1} @var{val_1}
...
@var{config_n} @var{val_n})
@end lisp
The main body of the macro call is like the body of a @code{setq}. It
contains pairs of variables and value settings. The first argument to
the macro is a symbol defining the mode root, the second argument is a
string defining the mode name. These should be the same as the first
part of the entry in @code{proof-assistant-table} for your prover.
@xref{Overview of adding a new prover}. After the call to
@code{proof-easy-config}, the new modes @code{@var{myprover}-mode},
@code{@var{myprover}-shell-mode}, @code{@var{myprover}-response-mode},
and @code{@var{myprover}-goals-mode} will be defined. The configuration
variables in the body will be set immediately.
This mechanism is in fact recommended for new instantiations of
Proof General since it follows a regular pattern, and we can more
easily adapt it in the future to new versions of Proof General.
Even Emacs Lisp experts should prefer the simplified mechanism. If you
want to set some buffer-local variables in your Proof General modes, or
invoke supporting lisp code, this can easily be done by adding functions
to the appropriate mode hooks after the @code{proof-easy-config} call.
For example, to add extra settings for the shell mode for
@code{demoisa}, we could do this:
@lisp
(defun demoisa-shell-extra-config ()
@var{extra configuration ...}
)
(add-hook 'demoisa-shell-mode-hook 'demoisa-shell-extra-config)
@end lisp
The function to do extra configuration @code{demoisa-shell-extra-config}
is then called as the final step when @code{demoisa-shell-mode} is
entered (be wary, this will be after the generic
@code{proof-shell-config-done} is called, so it will be too late to set
normal configuration variables which may be examined by
@code{proof-shell-config-done}).
@node Major modes used by Proof General
@section Major modes used by Proof General
There are four major modes used by Proof General, one for each type of
buffer it handles. The buffer types are: script, shell, response and
goals. Each of these has a generic mode, respectively:
@code{proof-mode}, @code{proof-shell-mode}, @code{proof-response-mode},
and @code{proof-goals-mode}.
The pattern for defining the major mode for an instance of Proof General
is to use @code{define-derived-mode} to define a specific mode to inherit from
each 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 each of your modes 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 it has set its configuration variables. These functions
finalize the configuration of the mode.
The modes must be named standardly, replacing @code{proof-} with the
prover's symbol name, @code{@var{PA}-}. In other words, you must define
@code{@var{PA}-mode}, @code{@var{PA}-shell-mode}, etc.
See the file @file{demoisa.el} for an example of the four calls to
@code{define-derived-mode}.
Aside: notice that the modes are selected using stub functions
inside @code{proof-site.el}, which set the variables
@code{proof-mode-for-script}, @code{proof-mode-for-shell}, etc,
that actually select the right mode. These variables
are declared in @code{pg-vars.el}.
@node Menus and Toolbar and User-level Commands
@chapter Menus, toolbar, and user-level commands
The variables described in this chapter configure the menus, toolbar,
and user-level commands. They should be set in the script mode
before @code{proof-config-done} is called. (Toolbar configuration must
be made before @file{proof-toolbar.el} is loaded, which usually is
triggered automatically by an attempt to display the toolbar).
@menu
* Settings for generic user-level commands::
* Menu configuration::
* Toolbar configuration::
@end menu
@node Settings for generic user-level commands
@section Settings for generic user-level commands
@c TEXI DOCSTRING MAGIC: proof-assistant-home-page
@defvar proof-assistant-home-page
Web address for information on proof assistant.@*
Used for Proof General's help menu.
@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.@*
String or fn. If a string, the command to use.
If a function, it should return the command string to insert.
@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 term. String or fn.@*
If a string, the format character @samp{%s} will be replaced by the term.
If a function, it should return the command string to send.
@end defvar
@node Menu configuration
@section Menu configuration
As well as the generic Proof General menu, each proof assistant is
provided with a specific menu which can have prover-specific commands.
Proof General puts some default things on this menu, including the
commands to start/stop the prover, and the user-extensible "Favourites"
menu.
@c TEXI DOCSTRING MAGIC: PA-menu-entries
@defvar PA-menu-entries
Extra entries for proof assistant specific menu.@*
A list of menu items [@var{name} @var{callback} @var{enabler} ...]. See the documentation
of @samp{@code{easy-menu-define}} for more details.
@end defvar
@c TEXI DOCSTRING MAGIC: PA-help-menu-entries
@defvar PA-help-menu-entries
Extra entries for help submenu for proof assistant specific help menu.@*
A list of menu items [@var{name} @var{callback} @var{enabler} ...]. See the documentation
of @samp{@code{easy-menu-define}} for more details.
@end defvar
@node Toolbar configuration
@section Toolbar configuration
Unlike the menus, Proof General has only one toolbar. For the "generic"
aspect of Proof General to work well, we shouldn't change (the meaning
of) the existing toolbar buttons too far. This would discourage people
from experimenting with different proof assistants when they don't
really know them, which is one of the advantages that Proof General
brings.
But in case it is hard to map some of the generic buttons
onto functions in particular provers, and to allow extra
buttons, there is a mechanism for adjustment.
I used The Gimp to create the buttons for Proof General. The
development distribution includes a button blank and some notes in
@file{etc/notes.txt} about making new buttons.
@c TEXI DOCSTRING MAGIC: proof-toolbar-entries-default
@defvar proof-toolbar-entries-default
Example value for proof-toolbar-entries. Also used to define scripting menu.@*
This gives a bare toolbar that works for any prover, providing the
appropriate configuration variables are set.
To add/remove prover specific buttons, adjust the @samp{<PA>-toolbar-entries}
variable, and follow the pattern in @samp{proof-toolbar.el} for
defining functions, images.
@end defvar
@c TEXI DOCSTRING MAGIC: PA-toolbar-entries
@defvar PA-toolbar-entries
List of entries for Proof General toolbar and Scripting menu.@*
Format of each entry is (@var{token} @var{menuname} @var{tooltip} @var{toolbar-p} [VISIBLE-P]).
For each @var{token}, we expect an icon with base filename @var{token},
a function proof-toolbar-<TOKEN>, and (optionally) a dynamic enabler
proof-toolbar-<TOKEN>-enable-p.
If @var{visible-p} is absent, or evaluates to non-nil, the item will
appear on the toolbar or menu. If it evaluates to nil, the item
is not shown.
If @var{menuname} is nil, item will not appear on the scripting menu.
If @var{toolbar-p} is nil, item will not appear on the toolbar.
The default value is @samp{@code{proof-toolbar-entries-default}} which contains
the standard Proof General buttons.
@end defvar
Here's an example of how to remove a button, from @file{af2.el}:
@lisp
(setq af2-toolbar-entries
(assq-delete-all 'state af2-toolbar-entries))
@end lisp
@c defgroup proof-script
@node Proof Script Settings
@chapter Proof Script Settings
The variables described in this chapter should be set in the script mode
before @code{proof-config-done} is called. These variables configure
recognition of commands in the proof script, and also control some of
the behaviour of script management.
@menu
* Recognizing commands and comments::
* Recognizing proofs::
* Recognizing other elements::
* Configuring undo behaviour::
* Nested proofs::
* Safe (state-preserving) commands::
* Activate scripting hook::
* Automatic multiple files::
* Completely asserted buffers::
* Completions::
@end menu
@node Recognizing commands and comments
@section Recognizing commands and comments
The first four settings configure the generic parsing strategy for
commands in the proof script. Usually only one of these three needs to
be set. If the generic parsing functions are not flexible for your
needs, you can supply a value for @code{proof-script-parse-function}.
Note that for the generic functions to work properly, it is
@strong{essential} that you set the syntax table for your mode properly,
so that comments and strings are recognized. See the Emacs
documentation to discover how to do this (particularly for the function
@code{modify-syntax-entry}, (@inforef{Syntax Tables, ,Elisp}).
@xref{Proof script mode}, for more details of the parsing
functions.
@c TEXI DOCSTRING MAGIC: proof-terminal-string
@defvar proof-terminal-string
String that terminates commands sent to prover; nil if none.
To configure command recognition properly, you must set at least one
of these: @samp{@code{proof-script-sexp-commands}}, @samp{@code{proof-script-command-end-regexp}},
@samp{@code{proof-script-command-start-regexp}}, @samp{@code{proof-terminal-string}},
or @samp{@code{proof-script-parse-function}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-electric-terminator-noterminator
@defvar proof-electric-terminator-noterminator
If non-nil, electric terminator does not actually insert a terminator.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-script-sexp-commands
@defvar proof-script-sexp-commands
Non-nil if script has Lisp-like syntax: commands are @code{top-level} sexps.@*
You should set this variable in script mode configuration.
To configure command recognition properly, you must set at least one
of these: @samp{@code{proof-script-sexp-commands}}, @samp{@code{proof-script-command-end-regexp}},
@samp{@code{proof-script-command-start-regexp}}, @samp{@code{proof-terminal-string}},
or @samp{@code{proof-script-parse-function}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-script-command-start-regexp
@defvar proof-script-command-start-regexp
Regular expression which matches start of commands in proof script.@*
You should set this variable in script mode configuration.
To configure command recognition properly, you must set at least one
of these: @samp{@code{proof-script-sexp-commands}}, @samp{@code{proof-script-command-end-regexp}},
@samp{@code{proof-script-command-start-regexp}}, @samp{@code{proof-terminal-string}},
or @samp{@code{proof-script-parse-function}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-script-command-end-regexp
@defvar proof-script-command-end-regexp
Regular expression which matches end of commands in proof script.@*
You should set this variable in script mode configuration.
The end of the command is considered to be the end of the match
of this regexp. The regexp may include a nested group, which
can be used to recognize the start of the following command
(or white space). If there is a nested group, the end of the
command is considered to be the start of the nested group,
i.e. (@code{match-beginning} 1), rather than (@code{match-end} 0).
To configure command recognition properly, you must set at least one
of these: @samp{@code{proof-script-sexp-commands}}, @samp{@code{proof-script-command-end-regexp}},
@samp{@code{proof-script-command-start-regexp}}, @samp{@code{proof-terminal-string}},
or @samp{@code{proof-script-parse-function}}.
@end defvar
The next four settings configure the comment syntax. Notice that to get
reliable behaviour of the parsing functions, you may need to modify the
syntax table for your prover's mode.
Read the Elisp manual (@inforef{Syntax Tables, ,Elisp}) for details about that.
@c TEXI DOCSTRING MAGIC: proof-script-comment-start
@defvar proof-script-comment-start
String which starts a comment in the proof assistant command language.@*
The script buffer's @samp{@code{comment-start}} is set to this string plus a space.
Moreover, comments are usually ignored during script management, and not
sent to the proof process.
You should set this variable for reliable working of Proof General,
as well as @samp{@code{proof-script-comment-end}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-script-comment-start-regexp
@defvar proof-script-comment-start-regexp
Regexp which matches a comment start in the proof command language.
The default value for this is set as (@code{regexp-quote} @samp{@code{proof-script-comment-start}})
but you can set this variable to something else more precise if necessary.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-script-comment-end
@defvar proof-script-comment-end
String which ends a comment in the proof assistant command language.@*
Should be an empty string if comments are terminated by @samp{@code{end-of-line}}
The script buffer's @samp{@code{comment-end}} is set to a space plus this string,
if it is non-empty.
See also @samp{@code{proof-script-comment-start}}.
You should set this variable for reliable working of Proof General.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-script-comment-end-regexp
@defvar proof-script-comment-end-regexp
Regexp which matches a comment end in the proof command language.
The default value for this is set as (@code{regexp-quote} @samp{@code{proof-script-comment-end}})
but you can set this variable to something else more precise if necessary.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-case-fold-search
@defvar proof-case-fold-search
Value for @samp{@code{case-fold-search}} when recognizing portions of proof scripts.@*
Also used for completion, via @samp{@code{proof-script-complete}}.
The default value is nil. If your prover has a case @strong{insensitive}
input syntax, @samp{@code{proof-case-fold-search}} should be set to t instead.
NB: This setting is not used for matching output from the prover.
@end defvar
Finally, the function @code{proof-looking-at-syntactic-context} is used
internally to help determine the syntactic structure of the buffer.
You can test it to check the settings above. If necessary, you can
override this with a system-specific function.
@c TEXI DOCSTRING MAGIC: proof-looking-at-syntactic-context
@defun proof-looking-at-syntactic-context
Determine if current point is at beginning or within comment/string context.@*
If so, return a symbol indicating this ('comment or @code{'string}).
This function invokes <PA-syntactic-context> if that is defined, otherwise
it calls @samp{@code{proof-looking-at-syntactic-context}}.
@end defun
@node Recognizing proofs
@section Recognizing proofs
Several settings each may be supplied for recognizing goal-like and
save-like commands. The @code{-with-hole-} settings are used to make a
record of the name of the theorem proved.
The @code{-p} subsidiary predicates were added to allow more
discriminating behaviour for particular proof assistants. (This is a
typical example of where the core framework needs some additional
generalization, to simplify matters, and allow for a smooth handling of
nested proofs; the present state is only part of the way there).
@c TEXI DOCSTRING MAGIC: proof-goal-command-regexp
@defvar proof-goal-command-regexp
Matches a goal command in the proof script.@*
This is used to make the default value for @samp{@code{proof-goal-command-p}},
used as an important part of script management to find the start
of an atomic undo block.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-goal-command-p
@defvar proof-goal-command-p
A function to test: is this really a goal command span?
This is added as a more refined addition to @samp{@code{proof-goal-command-regexp}},
to solve the problem that Coq and some other provers can have goals which
look like definitions, etc. (In the future we may generalize
@samp{@code{proof-goal-command-regexp}} instead).
@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.@*
The name of the theorem is built from the variable
@samp{@code{proof-goal-with-hole-result}} using the same convention as
for @samp{@code{query-replace-regexp}}.
Used for setting names of goal..save regions and for default
configuration of other modes (function menu, imenu).
It's safe to leave this setting as nil.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-goal-with-hole-result
@defvar proof-goal-with-hole-result
How to get theorem name after @samp{@code{proof-goal-with-hole-regexp}} match.@*
String or Int.
If an int N, use @samp{@code{match-string}} to get the value of the Nth parenthesis matched.
If a string, use @samp{@code{replace-match}}. In this case, @samp{@code{proof-goal-with-hole-regexp}}
should match the entire command.
@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.@*
The name of the theorem is built from the variable
@samp{@code{proof-save-with-hole-result}} using the same convention as
@samp{@code{query-replace-regexp}}.
Used for setting names of goal..save and proof regions.
It's safe to leave this setting as nil.
@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 "save" command appears --- or it may not appear at all. Unless
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.
NB: @code{'extend} behaviour is not currently compatible with appearance of
save commands, so don't use that if your prover has save commands.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-really-save-command-p
@defvar proof-really-save-command-p
Is this really a save command?
This is a more refined addition to @samp{@code{proof-save-command-regexp}}.
It should be a function taking a span and command as argument,
and can be used to track nested proofs.
@end defvar
@node Recognizing other elements
@section Recognizing other elements
@vindex proof-goal-with-hole-regexp
@vindex proof-goal-with-hole-result
To configure @i{Imenu} (which in turn configures @i{Speedbar}),
you may use the following setting. If this is unset, a generic
setting based on @code{proof-goal-with-hole-regexp} is configured.
@c TEXI DOCSTRING MAGIC: proof-script-imenu-generic-expression
@defvar proof-script-imenu-generic-expression
Regular expressions to help find definitions and proofs in a script.@*
Value for @samp{@code{imenu-generic-expression}}, see documentation of Imenu
and that variable for details.
@end defvar
@c This is _not_ docstring magic, but docstring-by-hand from
@c imenu.el in XEmacs 21.4.12
@defvar imenu-generic-expression
The regex pattern to use for creating a buffer index.
If non-nil this pattern is passed to @samp{imenu--generic-function}
to create a buffer index.
The value should be an alist with elements that look like this:
@lisp
(@var{menu-title} @var{regexp} @var{index})
@end lisp
or like this:
@lisp
(@var{menu-title} @var{regexp} @var{index} @var{function} ARGUMENTS...)
@end lisp
with zero or more ARGUMENTS. The former format creates a simple element in
the index alist when it matches; the latter creates a special element
of the form (@var{name} @var{function} @var{position-marker} ARGUMENTS...)
with @var{function} and @var{arguments} beiong copied from @samp{imenu-generic-expression}.
@var{menu-title} is a string used as the title for the submenu or nil if the
entries are not nested.
@var{regexp} is a regexp that should match a construct in the buffer that is
to be displayed in the menu; i.e., function or variable definitions,
etc. It contains a substring which is the name to appear in the
menu. See the info section on Regexps for more information.
@var{index} points to the substring in @var{regexp} that contains the name (of the
function, variable or type) that is to appear in the menu.
The variable is buffer-local.
The variable @samp{imenu-case-fold-search} determines whether or not the
regexp matches are case sensitive. and @samp{imenu-syntax-alist} can be
used to alter the syntax table for the search.
For example, see the value of @samp{lisp-imenu-generic-expression} used by
@samp{lisp-mode} and @samp{emacs-lisp-mode} with @samp{imenu-syntax-alist} set
locally to give the characters which normally have \"punctuation\"
syntax \"word\" syntax during matching."
@end defvar
@node Configuring undo behaviour
@section Configuring undo behaviour
The settings here are used to configure the way "undo" commands are
calculated.
@c TEXI DOCSTRING MAGIC: proof-non-undoables-regexp
@defvar proof-non-undoables-regexp
Regular expression matching commands which are @strong{not} undoable.@*
These are commands which should not appear in proof scripts,
for example, undo commands themselves (if the proof assistant
cannot "redo" an "undo").
Used in default functions @samp{@code{proof-generic-state-preserving-p}}
and @samp{@code{proof-generic-count-undos}}. If you don't use those,
may be left as nil.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-undo-n-times-cmd
@defvar proof-undo-n-times-cmd
Command to undo n steps of the currently open goal.@*
String or function.
If this is set to a string, @samp{%s} will be replaced by the number of
undo steps to issue.
If this is set to a function, it should return a list of
the appropriate commands (given the number of undo steps).
This setting is used for the default @samp{@code{proof-generic-count-undos}}.
If you set @samp{@code{proof-count-undos-fn}} to some other function, there is no
need to set this variable.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-ignore-for-undo-count
@defvar proof-ignore-for-undo-count
Matcher for script commands to be ignored in undo count.@*
May be left as nil, in which case it will be set to
@samp{@code{proof-non-undoables-regexp}}.
Used in default function @samp{@code{proof-generic-count-undos}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-count-undos-fn
@defvar proof-count-undos-fn
Function to calculate a list of commands to undo to reach a target span.@*
The function takes a span as an argument, and should return a string
which is the command to undo to the target span. The target is
guaranteed to be within the current (open) proof.
This is an important function for script management.
The default setting @samp{@code{proof-generic-count-undos}} is based on the
settings @samp{@code{proof-non-undoables-regexp}} and
@samp{@code{proof-non-undoables-regexp}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-generic-count-undos
@defun proof-generic-count-undos span
Count number of undos in @var{span}, return commands needed to undo that far.@*
Command is set using @samp{@code{proof-undo-n-times-cmd}}.
A default value for @samp{@code{proof-count-undos-fn}}.
For this function to work properly, you must configure
@samp{@code{proof-undo-n-times-cmd}} and @samp{@code{proof-ignore-for-undo-count}}.
@end defun
@c TEXI DOCSTRING MAGIC: proof-find-and-forget-fn
@defvar proof-find-and-forget-fn
Function to return list of commands to forget 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 (@code{proof-unprocessed-begin}). This may involve forgetting a number
of definitions, declarations, or whatever.
If return value is nil, it 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,
or leave it set to the default function @samp{@code{proof-generic-find-and-forget}}
(which see).
@end defvar
@c TEXI DOCSTRING MAGIC: proof-generic-find-and-forget
@defun proof-generic-find-and-forget span
Calculate a forget/undo command to forget back to @var{span}.@*
This is a long-range forget: we know that there is no
open goal at the moment, so forgetting involves unbinding
declarations, etc, rather than undoing proof steps.
This generic implementation assumes it is enough to find the
nearest following span with a @samp{name} property, and retract
that using @samp{@code{proof-forget-id-command}} with the given name.
If this behaviour is not correct, you must customize the function
with something different.
@end defun
@c TEXI DOCSTRING MAGIC: proof-forget-id-command
@defvar proof-forget-id-command
Command to forget back to a given named span.@*
A string; @samp{%s} will be replaced by the name of the span.
This is only used in the implementation of @samp{@code{proof-generic-find-and-forget}},
you only need to set if you use that function (by not customizing
@samp{@code{proof-find-and-forget-fn}}.
@end defvar
@c TEXI DOCSTRING MAGIC: pg-topterm-goalhyplit-fn
@defvar pg-topterm-goalhyplit-fn
Function to return cons if point is at a goal/hypothesis/literal.@*
This is used to parse the proofstate output to mark it up for
proof-by-pointing or literal command insertion. It should return a cons or nil.
First element of the cons is a symbol, @code{'goal'}, @code{'hyp'} or @code{'lit'}.
The second element is a string: the goal, hypothesis, or literal command itself.
If you leave this variable unset, no proof-by-pointing markup
will be attempted.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-kill-goal-command
@defvar proof-kill-goal-command
Command to kill the currently open goal.
If this is set to nil, PG will expect @samp{@code{proof-find-and-forget-fn}}
to do all the work of retracting to an arbitrary point in a file.
Otherwise, the generic split-phase mechanism will be used:
1. If inside an unclosed proof, use @samp{proof-count-undos}.
2. If retracting to before an unclosed proof, use
@samp{@code{proof-kill-goal-command}}, followed by @samp{@code{proof-find-and-forget-fn}}
if necessary.
@end defvar
@node Nested proofs
@section Nested proofs
Proof General allows configuration for provers which have particular
notions of nested proofs. The right thing may happen automatically,
or you may need to adjust some of the following settings.
First, you should alter the next setting if the prover retains history
for nested proofs.
@c TEXI DOCSTRING MAGIC: proof-nested-goals-history-p
@defvar proof-nested-goals-history-p
Whether the prover supports recovery of history for nested proofs.@*
If it does (non-nil), Proof General will retain history inside
nested proofs.
If it does not, Proof General will amalgamate nested proofs into single
steps within the outer proof.
@end defvar
Second, it may happen (i.e. it does for Coq) that the prover has a
history mechanism which necessitates keeping track of the number of
nested "undoable" commands, even if the history of the proof itself is
lost.
@c TEXI DOCSTRING MAGIC: proof-nested-undo-regexp
@defvar proof-nested-undo-regexp
Regexp for commands that must be counted in nested goal-save regions.
Used for provers which allow nested atomic goal-saves, but with some
nested history that must be undone specially.
At the moment, the behaviour is that a goal-save span has a @code{'nestedundos}
property which is set to the number of commands within it which match
this regexp. The idea is that the prover-specific code can create a
customized undo command to retract the goal-save region, based on the
@code{'nestedundos} setting. Coq uses this to forget declarations, since
declarations in Coq reside in a separate context with its own (flat)
history.
@end defvar
@node Safe (state-preserving) commands
@section Safe (state-preserving) commands
A proof command is "safe" if it can be issued away from the proof
script. For this to work it should be state-preserving in the proof
assistant (with respect to an on-going proof).
@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.@*
This is a safety-test used by @samp{@code{proof-minibuffer-cmd}} to filter out scripting
commands which should be entered directly into the script itself.
The default setting for this function, @samp{@code{proof-generic-state-preserving-p}}
tests by negating the match on @samp{@code{proof-non-undoables-regexp}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-generic-state-preserving-p
@defun proof-generic-state-preserving-p cmd
Is @var{cmd} state preserving? Match on @samp{@code{proof-non-undoables-regexp}}.
@end defun
@node Activate scripting hook
@section Activate scripting hook
@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
@samp{@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
@node Automatic multiple files
@section Automatic multiple files
@xref{Handling Multiple Files}, for more details about this
setting.
@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 dependencies rather than using this setting.
@end defvar
@node Completely asserted buffers
@section Completely asserted buffers
When switching scripting from buffer A to buffer B Proof General
normally offers the choice of either completely retracting or
completely asserting buffer A. The option to completely assert
buffer A is offered, because the material in B may depend on A.
Even if B does not depend on A, it does no harm if one keeps the
development of A loaded in the proof assistant. This observation
is true for many proof assistants.
One exception is Coq. Assume file B depends on file A. When Coq
processes B it does not read the sources of A. Instead it loads a
compiled object representation of A. Therefore, when switching
from A to B, it does make no sense to keep the material of A
loaded in the proof assistant. For Coq, the material of A may
even provoke errors on correct input. Therefore, for coq, the
right behaviour is to completely retract buffer A before
switching to B.
@c TEXI DOCSTRING MAGIC: proof-no-fully-processed-buffer
@defvar proof-no-fully-processed-buffer
Set to t if buffers should always retract before scripting elsewhere.@*
Leave at nil if fully processed buffers make sense for the current
proof assistant. If nil the user can choose to fully assert a
buffer when starting scripting in a different buffer. If t there
is only the choice to fully retract the active buffer before
starting scripting in a different buffer. This last behavior is
needed for Coq.
@end defvar
@node Completions
@section Completions
Proof General allows provers to create a @i{completion table} to help
writing keywords and identifiers in proof scripts. This is documented
in the main @i{Proof General} user manual but summarized here for (a
different kind of) completion.
Completions are filled in according to what has been recently typed,
from a database of symbols. The database is automatically saved at the
end of a session. Completion is usually a hand-wavy thing, so we don't
make any attempt to maintain a precise completion table or anything.
The completion table maintained by @file{complete.el} is initialized
from @code{PA-completion-table} when @file{proof-script.el} is loaded.
This is done with the function @code{proof-add-completions} which
you may want to call at other times.
@c TEXI DOCSTRING MAGIC: PA-completion-table
@defvar PA-completion-table
List of identifiers to use for completion for this proof assistant.@*
Completion is activated with M-x complete.
If this table is empty or needs adjusting, please make changes using
@samp{@code{customize-variable}} and post suggestions at
https://github.com/ProofGeneral/PG/issues
@end defvar
@c TEXI DOCSTRING MAGIC: proof-add-completions
@deffn Command proof-add-completions
Add completions from <PA>-completion-table to completion database.@*
Uses @samp{@code{add-completion}} with a negative number of uses and ancient
last use time, to discourage saving these into the users database.
@end deffn
@node Proof Shell Settings
@chapter Proof Shell Settings
The variables in this chapter concern the proof shell mode, and are the
largest group. They are split into several subgroups. The first
subgroup are commands invoked at various points. The second subgroup of
variables are concerned with matching the output from the proof
assistant. The final subgroup contains various hooks which you can set
to add lisp customization to Proof General in various points (some of
them are also used internally for behaviour you may wish to adjust).
Variables for configuring the proof shell 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 way the proof assistant runs inside Emacs, 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, including the @code{proof-shell-mode} and
all specific shell modes derived from it.
@menu
* Proof shell commands::
* Script input to the shell::
* Settings for matching various output from proof process::
* Settings for matching urgent messages from proof process::
* Hooks and other settings::
@end menu
@node Proof shell commands
@section Commands
Settings in this section configure Proof General with commands
to send to the prover to activate certain actions.
@c TEXI DOCSTRING MAGIC: proof-prog-name
@defvar proof-prog-name
System command to run the proof assistant in the proof shell.@*
May contain arguments separated by spaces, but see also the
prover specific settings @samp{<PA>-prog-args} and @samp{<PA>-prog-env}.
Remark: if @samp{<PA>-prog-args} is non-nil, then @samp{@code{proof-prog-name}} is considered
strictly: it must contain @strong{only} the program name with no option, spaces
are interpreted literally as part of the program name.
@end defvar
@c TEXI DOCSTRING MAGIC: PA-prog-args
@defvar PA-prog-args
Arguments to be passed to @samp{@code{proof-prog-name}} to run the proof assistant.@*
If non-nil, will be treated as a list of arguments for @samp{@code{proof-prog-name}}.
Otherwise @samp{@code{proof-prog-name}} will be split on spaces to form arguments.
Remark: Arguments are interpreted strictly: each one must contain only one
word, with no space (unless it is the same word). For example if the
arguments are -x foo -y bar, then the list should be '("-x" "foo"
"-y" "bar"), notice that '("-x foo" "-y bar") is @strong{wrong}.
@end defvar
@c TEXI DOCSTRING MAGIC: PA-prog-env
@defvar PA-prog-env
Modifications to @samp{@code{process-environment}} made before running @samp{@code{proof-prog-name}}.@*
Each element should be a string of the form ENVVARNAME=@var{value}. They will be
added to the environment before launching the prover (but not pervasively).
For example for coq on Windows you might need something like:
(setq @code{coq-prog-env} '("HOME=C:\Program Files\Coq\"))
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-auto-terminate-commands
@defvar proof-shell-auto-terminate-commands
Non-nil if Proof General should try to add terminator to every command.@*
If non-nil, whenever a command is sent to the prover using
@samp{@code{proof-shell-invisible-command}}, Proof General will check to see if it
ends with @samp{@code{proof-terminal-string}}, and add it if not.
If @samp{@code{proof-terminal-string}} is nil, this has no effect.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-pre-sync-init-cmd
@defvar proof-shell-pre-sync-init-cmd
The command for configuring the proof process to gain synchronization.@*
This command is sent before Proof General's synchronization
mechanism is engaged, to allow customization inside the process
to help gain syncrhonization (e.g. engaging special markup).
It is better to configure the proof assistant for this purpose
via command line options if possible, in which case this variable
does not need to be set.
See also @samp{@code{proof-shell-init-cmd}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-init-cmd
@defvar proof-shell-init-cmd
The command(s) for initially configuring the proof process.@*
This command is sent to the process as soon as synchronization is gained
(when an annotated prompt is first recognized). It can be used to configure
the proof assistant in some way, or print a welcome message
(since output before the first prompt is discarded).
See also @samp{@code{proof-shell-pre-sync-init-cmd}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-restart-cmd
@defvar proof-shell-restart-cmd
A command for re-initialising the proof process.
@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.
@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 @samp{%s} is replaced with the directory, and
the escape sequences in @samp{@code{proof-shell-filename-escapes}} are
applied to the filename.
This setting is used to define the function @samp{@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, @samp{@code{proof-cd}} is called from @samp{@code{proof-activate-scripting-hook}},
so that the prover switches to the directory of a proof
script every time scripting begins.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-start-silent-cmd
@defvar proof-shell-start-silent-cmd
Command to turn prover goals output off when sending many script commands.@*
If non-nil, Proof General will automatically issue this command
to help speed up processing of long proof scripts.
See also @samp{@code{proof-shell-stop-silent-cmd}}.
NB: terminator not added to command.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-stop-silent-cmd
@defvar proof-shell-stop-silent-cmd
Command to turn prover output on.@*
If non-nil, Proof General will automatically issue this command
to help speed up processing of long proof scripts.
See also @samp{@code{proof-shell-start-silent-cmd}}.
NB: Terminator not added to command.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-silent-threshold
@defvar proof-shell-silent-threshold
Number of waiting commands in the proof queue needed to trigger silent mode.@*
Default is 2, but you can raise this in case switching silent mode
on or off is particularly expensive (or make it ridiculously large
to disable silent mode altogether).
@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 @samp{%s} is replaced by a complete filename for a
script file which has been fully processed interactively with
Proof General. See @samp{@code{proof-format-filename}} for other possibilities
to process the filename.
This setting 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: @samp{@code{proof-shell-inform-file-retracted-cmd}},
@samp{@code{proof-shell-process-file}}, @samp{@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 @samp{%s} is replaced by a complete filename for a
script file which Proof General wants the prover to consider as not
completely processed. See @samp{@code{proof-format-filename}} for other
possibilities to process the filename.
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.
It is also possible to set this value to a function which will
be invoked on the name of the retracted file, and should remove
the ancestor files from @samp{@code{proof-included-files-list}} by some
other calculation.
See also: @samp{@code{proof-shell-inform-file-processed-cmd}},
@samp{@code{proof-shell-process-file}}, @samp{@code{proof-shell-compute-new-files-list}}.
@end defvar
@node Script input to the shell
@section Script input to the shell
Generally, commands from the proof script are sent verbatim to the proof
process running in the proof shell. For historical reasons, carriage
returns are stripped by default. You can set
@code{proof-shell-strip-crs-from-input} to adjust that. For more
sophisticated pre-processing of the sent string, you may like to set
@code{proof-shell-insert-hook}.
@c TEXI DOCSTRING MAGIC: proof-shell-strip-crs-from-input
@defvar proof-shell-strip-crs-from-input
If non-nil, replace carriage returns in every input with spaces.@*
This is enabled by default: it is appropriate for many systems
based on human input, because several CR's can result in several
prompts, which may mess up the display (or even worse, the
synchronization).
If the prover can be set to output only one prompt for every chunk of
input, then newlines can be retained in the input.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-insert-hook
@defvar proof-shell-insert-hook
Hooks run by @samp{@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 @samp{@code{save-excursion}} with the @samp{@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 @samp{@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, the first two
are normally the ones of interest:
@lisp
@code{'proof-done-advancing} A "forward" scripting command
@code{'proof-done-retracting} A "backward" scripting command
@code{'proof-done-invisible} A non-scripting command
@code{'proof-shell-set-silent} Indicates prover output has been surpressed
@code{'proof-shell-clear-silent} Indicates prover output has been restored
@code{'init-cmd} Early initialization command sent to prover
@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}.
See also @samp{@code{proof-script-preprocess}} which can munge text when
it is added to the queue of commands.
@end defvar
@node Settings for matching various output from proof process
@section Settings for matching various output from proof process
These settings control the way Proof General reacts to process output.
The single most important setting is
@code{proof-shell-annotated-prompt-regexp}, which @b{must} be set as
part of the prover configuraton. This is used to configure the
communication with the prover process.
@c TEXI DOCSTRING MAGIC: pg-subterm-first-special-char
@defvar pg-subterm-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.
Leave unset if no special characters are being used.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-annotated-prompt-regexp
@defvar proof-shell-annotated-prompt-regexp
Regexp matching a (possibly annotated) prompt pattern.
@var{this} IS THE @var{most} @var{important} @var{setting} TO @var{configure}!!
Output is grabbed between pairs of lines matching this regexp,
and the appearance of this regexp is used by Proof General to
recognize when the prover has finished processing a command.
To help speed up matching you may be able to annotate the
proof assistant prompt with a special character not appearing
in ordinary output, which should appear in this regexp.
@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 @strong{not} be matched as an
eager annotation (see @samp{@code{proof-shell-eager-annotation-start}}) otherwise it
will be lost.
Error messages are considered to begin from @samp{@code{proof-shell-error-regexp}}
and continue until the next prompt. The variable
@samp{@code{proof-shell-truncate-before-error}} controls whether text before the
error message is displayed.
The engine matches interrupts before errors, see @samp{@code{proof-shell-interrupt-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 @samp{@code{proof-shell-eager-annotation-start}}) otherwise it
will be lost.
The engine matches interrupts before errors, see @samp{@code{proof-shell-error-regexp}}.
It is safe to leave this variable unset (as nil).
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-truncate-before-error
@defvar proof-shell-truncate-before-error
Non-nil means truncate output that appears before error messages.@*
If nil, the whole output that the prover generated before the last
error message will be shown.
NB: the default setting for this is t to be compatible with
behaviour in Proof General before version 3.4. The more obvious
setting for new instances is probably nil.
Interrupt messages are treated in the same way.
See @samp{@code{proof-shell-error-regexp}} and @samp{@code{proof-shell-interrupt-regexp}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-proof-completed-regexp
@defvar proof-shell-proof-completed-regexp
Regexp matching output indicating a finished proof.
When output which matches this regexp is seen, we clear the goals
buffer in case this is not also marked up as a @samp{goals} type of
message.
We also enable the QED function (save a proof) and we may automatically
close off the proof region if another goal appears before a save
command, depending on whether the prover supports nested proofs or not.
@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.
If it is left as nil, the goals buffer will not be used.
The goals display starts at the beginning of the match on this
regexp, unless it has a match group, in which case it starts
at (@code{match-end} 1).
@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, or nil.@*
This allows a shorter form of the proof state output to be displayed,
in case several messages are combined in a command output.
The portion treated as the goals output will be that between the
match on @samp{@code{proof-shell-start-goals-regexp}} (which see) and the
start of the match on @samp{@code{proof-shell-end-goals-regexp}}.
If nil, use the whole of the output from the match on
@samp{@code{proof-shell-start-goals-regexp}} up to the next prompt.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-assumption-regexp
@defvar proof-shell-assumption-regexp
A regular expression matching the name of assumptions.
At the moment, this setting is not used in the generic Proof General.
Future use may provide a generic implementation for @samp{@code{pg-topterm-goalhyplit-fn}},
used to help parse the goals buffer to annotate it for proof by pointing.
@end defvar
@node Settings for matching urgent messages from proof process
@section Settings for matching urgent messages from proof process
Among the various dialogue messages that the proof assistant outputs
during proof, Proof General can consider certain messages to be
"urgent". When processing many lines of a proof, Proof General will
normally supress the output, waiting until the final message appears
before displaying anything to the user. Urgent messages escape this:
typically they include messages that the prover wants the user to
notice, for example, perhaps, file loading messages, timing
statistics or dedicated tracing messages which can be sent to the
@code{*trace*} buffer.
So that Proof General notices, these urgent messages should be marked-up
with "eager" annotations.
@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 Proof General that some following output
should be displayed (or processed) immediately and not accumulated for
parsing later. Note that this affects processing of output which is
ordinarily accumulated: output which appears before the eager annotation
start will be discarded.
The start/end annotations can be used to hilight the output, but
are stripped from display of the message in the minibuffer.
It is useful to recognize (starts of) warnings or file-reading messages
with this regexp. You must also recognize any special messages
from the prover to PG with this regexp (e.g. @samp{@code{proof-shell-clear-goals-regexp}},
@samp{@code{proof-shell-retract-files-regexp}}, etc.)
See also @samp{@code{proof-shell-eager-annotation-start-length}},
@samp{@code{proof-shell-eager-annotation-end}}.
Set to nil to disable this feature.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-eager-annotation-start-length
@defvar proof-shell-eager-annotation-start-length
Maximum length of an eager annotation start.@*
Must be set to the maximum length of the text that may match
@samp{@code{proof-shell-eager-annotation-start}} (at least 1).
If this value is too low, eager annotations may be lost!
This value is used internally by Proof General to optimize the process
filter to avoid unnecessary searching.
@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 or processed immediately.
See also @samp{@code{proof-shell-eager-annotation-start}}.
It is nice to recognize (ends of) warnings or file-reading messages
with this regexp. You must also recognize (ends of) any special messages
from the prover to PG with this regexp (e.g. @samp{@code{proof-shell-clear-goals-regexp}},
@samp{@code{proof-shell-retract-files-regexp}}, etc.)
The default value is "\n" to match up to the end of the line.
@end defvar
The default action for urgent messages is to display them in the
response buffer, highlighted. But we also allow for some control
messages, issued from the proof assistant to Proof General and not
intended for the user to see. These are recognized in the same way as
urgent messages (marked with eager annotations), so they will
be acted on as soon as they are issued by the prover.
@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.
More precisely, this should match a string which is bounded by
matches on @samp{@code{proof-shell-eager-annotation-start}} and
@samp{@code{proof-shell-eager-annotation-end}}.
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-clear-goals-regexp
@defvar proof-shell-clear-goals-regexp
Regexp matching output telling Proof General to clear the goals buffer.
More precisely, this should match a string which is bounded by
matches on @samp{@code{proof-shell-eager-annotation-start}} and
@samp{@code{proof-shell-eager-annotation-end}}.
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-interactive-prompt-regexp
@defvar proof-shell-interactive-prompt-regexp
Matches output from the prover which indicates an interactive prompt.@*
If we match this, we suppose that the prover has switched to an
interactive diagnostic mode which requires direct interaction
with the shell rather than via script management. In this case,
the shell buffer will be displayed and the user left to their own
devices.
Note: this should match a string which is bounded by matches
on @samp{@code{proof-shell-eager-annotation-start}} and
@samp{@code{proof-shell-eager-annotation-end}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-trace-output-regexp
@defvar proof-shell-trace-output-regexp
Matches tracing output which should be displayed in trace buffer.@*
Each line which matches this regexp but would otherwise be treated
as an ordinary response, is sent to the trace buffer instead of the
response buffer.
This is intended for unusual debugging output from
the prover, rather than ordinary output from final proofs.
This should match a string which is bounded by matches
on @samp{@code{proof-shell-eager-annotation-start}} and
@samp{@code{proof-shell-eager-annotation-end}}.
Set to nil to disable.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-set-elisp-variable-regexp
@defvar proof-shell-set-elisp-variable-regexp
Matches output telling Proof General to set some variable.@*
This allows the proof assistant to configure Proof General directly
and dynamically. (It's also a fantastic backdoor security risk).
More precisely, this should match a string which is bounded by
matches on @samp{@code{proof-shell-eager-annotation-start}} and
@samp{@code{proof-shell-eager-annotation-end}}.
If the regexp matches output from the proof assistant, there should be
two match strings: (@code{match-string} 1) should be the name of the elisp
variable to be set, and (@code{match-string} 2) should be the value of the
variable (which will be evaluated as a Lisp expression).
A good markup for the second string is to delimit with #'s, since
these are not valid syntax for elisp evaluation.
Elisp errors will be trapped when evaluating; set
@samp{@code{proof-general-debug}} to be informed when this happens.
Example uses are to adjust PG's internal copies of proof assistant's
settings, or to make automatic dynamic syntax adjustments in Emacs to
match changes in theory, etc.
If you pick a dummy variable name (e.g. @samp{proof-dummy-setting}) you
can just evaluation arbitrary elisp expressions for their side
effects, to adjust menu entries, or even launch auxiliary programs.
But use with care -- there is no protection against catastrophic elisp!
This setting could also be used to move some configuration settings
from PG to the prover, but this is not really supported (most settings
must be made before this mechanism will work). In future, the PG
standard protocol, @var{pgip}, will use this mechanism for making all
settings.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-theorem-dependency-list-regexp
@defvar proof-shell-theorem-dependency-list-regexp
Matches output telling Proof General about dependencies.@*
This is to allow navigation and display of dependency information.
The output from the prover should be a message with the form
@lisp
@var{dependencies} OF X Y Z ARE A B C
@end lisp
with X Y Z, A B C separated by whitespace or somehow else (see
@samp{@code{proof-shell-theorem-dependency-list-split}}. This variable should
be set to a regexp to match the overall message (which should
be an urgent message), with two sub-matches for X Y Z and A B C.
This is an experimental feature, currently work-in-progress.
@end defvar
Two important control messages are recognized by
@code{proof-shell-process-file} and
@code{proof-shell-retract-files-regexp}, used for synchronizing Proof
General with a file loading mechanism built into the proof assistant.
@xref{Handling Multiple Files}, for more details about how to use the
final four settings described here.
@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.
It must return the name of a script file (with complete path)
that 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.
More precisely, @var{regexp} should match a string which is bounded by
matches on @samp{@code{proof-shell-eager-annotation-start}} and
@samp{@code{proof-shell-eager-annotation-end}}.
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.
More precisely, this should match a string which is bounded by
matches on @samp{@code{proof-shell-eager-annotation-start}} and
@samp{@code{proof-shell-eager-annotation-end}}.
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. The
result will be stored in @samp{@code{proof-included-files-list}}.
This function is called when @samp{@code{proof-shell-retract-files-regexp}}
has been matched in the prover output.
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
@c TEXI DOCSTRING MAGIC: proof-cannot-reopen-processed-files
@defvar proof-cannot-reopen-processed-files
Non-nil if the prover allows re-opening of already processed files.
If the user has used Proof General to process a file incrementally,
then PG will retain the spans recording undo history in the buffer
corresponding to that file (provided it remains visited in Emacs).
If the prover allows, it will be possible to undo to a position within
this file. If the prover does @strong{not} allow this, this variable should
be set non-nil, so that when a completed file is activated for
scripting (to do undo operations), the whole history is discarded.
@end defvar
@node Hooks and other settings
@section Hooks and other settings
@c TEXI DOCSTRING MAGIC: proof-shell-filename-escapes
@defvar proof-shell-filename-escapes
A list of escapes that are applied to %s for filenames.@*
A list of cons cells, car of which is string to be replaced
by the cdr.
For example, when directories are sent to Isabelle, HOL, and Coq,
they appear inside ML strings and the backslash character and
quote characters must be escaped. The setting
@lisp
'(("@var{\\\\}" . "@var{\\\\}")
("\"" . "\\\""))
@end lisp
achieves this. This does not apply to @var{lego}, which does not
need backslash escapes and does not allow filenames with
quote characters.
This setting is used inside the function @samp{@code{proof-format-filename}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-process-connection-type
@defvar proof-shell-process-connection-type
The value of @samp{@code{process-connection-type}} for the proof shell.@*
Set non-nil for ptys, nil for pipes.
@var{note}: In Emacs >= 24 (checked for 24 and 25.0.50.1), t is not a
good choice: input is cut after @var{4095} chars, which hangs pg.
@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-last-output-kind}} to
determine whether the cause was an error or interrupt. Possible
values for this hook include:
@lisp
@samp{@code{proof-goto-end-of-locked-on-error-if-pos-not-visible-in-window}}
@samp{@code{proof-goto-end-of-locked-if-pos-not-visible-in-window}}
@end lisp
which move the cursor in the scripting buffer on an error or
error/interrupt.
Remark: This hook is called from shell buffer. If you want to do
something in scripting buffer, @samp{@code{save-excursion}} and/or @samp{@code{set-buffer}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-pre-interrupt-hook
@defvar proof-shell-pre-interrupt-hook
Run immediately after @samp{@code{comint-interrupt-subjob}} is called.@*
This hook is added to allow customization for systems that query the user
before returning to the top level.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-handle-output-system-specific
@defvar proof-shell-handle-output-system-specific
Set this variable to handle system specific output.@*
Errors and interrupts are recognised in the function
@samp{@code{proof-shell-handle-immediate-output}}. Later output is
handled by @samp{@code{proof-shell-handle-delayed-output}}, which
displays messages to the user in @strong{goals} and @strong{response}
buffers.
This hook can run between the two stages to take some effect.
It should be a function which is passed (cmd string) as
arguments, where @samp{cmd} is a string containing the currently
processed command and @samp{string} is the response from the proof
system. If action is taken and goals/response display should
be prevented, the function should update the variable
@samp{@code{proof-shell-last-output-kind}} to some non-nil symbol.
The symbol will be compared against standard ones, see documentation
of @samp{@code{proof-shell-last-output-kind}}. A suggested canonical non-standard
symbol is @code{'systemspecific}.
@end defvar
@node Goals Buffer Settings
@chapter Goals Buffer Settings
The goals buffer settings allow configuration of Proof General for proof
by pointing or similar features.
See the Proof General @uref{https://proofgeneral.github.io/doc, documentation web page}
for a link to the technical report ECS-LFCS-97-368 which hints
at how to use these settings.
@c At the moment these settings are disabled.
@c TEXI DOCSTRING MAGIC: pg-goals-change-goal
@defvar pg-goals-change-goal
Command to change to the goal @samp{%s}.
@end defvar
@c TEXI FIX DOCSTRING MAGIC: pbp-goal-command
@defvar pbp-goal-command
Command sent when @samp{pg-goals-button-action} is requested on a goal.
@end defvar
@c TEXI FIX DOCSTRING MAGIC: pbp-hyp-command
@defvar pbp-hyp-command
Command sent when @samp{pg-goals-button-action} is requested on an assumption.
@end defvar
@c TEXI DOCSTRING MAGIC: pg-goals-error-regexp
@defvar pg-goals-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: pg-subterm-start-char
@defvar pg-subterm-start-char
Opening special character for subterm markup.@*
Subsequent special characters with values @strong{below}
@samp{@code{pg-subterm-first-special-char}} are assumed to be subterm position
indicators. Annotations should be finished with @samp{@code{pg-subterm-sep-char}};
the end of the concrete syntax is indicated by @samp{@code{pg-subterm-end-char}}.
If @samp{@code{pg-subterm-start-char}} is nil, subterm markup is disabled.
@end defvar
@c TEXI DOCSTRING MAGIC: pg-subterm-sep-char
@defvar pg-subterm-sep-char
Finishing special for a subterm markup.@*
See doc of @samp{@code{pg-subterm-start-char}}.
@end defvar
@c TEXI DOCSTRING MAGIC: pg-topterm-regexp
@defvar pg-topterm-regexp
Annotation regexp that indicates the beginning of a "top" element.@*
A "top" element may be a sub-goal to be proved or a named hypothesis,
for example. It could also be a literal command to insert and
send back to the prover.
The function @samp{@code{pg-topterm-goalhyplit-fn}} examines text following this
special character, to determine what kind of top element it is.
This setting is also used to see if proof-by-pointing features
are configured. If it is unset, some of the code
for parsing the prover output is disabled.
@end defvar
@c TEXI DOCSTRING MAGIC: pg-subterm-end-char
@defvar pg-subterm-end-char
Closing special character for subterm markup.@*
See @samp{@code{pg-subterm-start-char}}.
@end defvar
@node Splash Screen Settings
@chapter 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 wee while 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
@node Global Constants
@chapter 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{"https://proofgeneral.github.io"}.
@end defopt
@c TEXI DOCSTRING MAGIC: proof-universal-keys
@defvar proof-universal-keys
List of key bindings made for all proof general buffers.@*
Elements of the list are tuples @samp{(k . f)}
where @samp{k} is a key binding (vector) and @samp{f} the designated function.
@end defvar
@node Handling Multiple Files
@chapter 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 is considered in the user manual.
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 @samp{@code{proof-shell-process-file}} configuration settings.
When the prover retracts a file, this list is resynchronised via the
@samp{@code{proof-shell-retract-files-regexp}} and @samp{@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. Ideally you should not set this
variable directly, but instead use (some of) the various
configuration settings that enable functionality inside Proof
General for managing @code{proof-included-files-list} (see below
if the configuration setting do not suffice).
@vindex proof-shell-process-file
@vindex proof-shell-retract-files-regexp
@vindex proof-shell-compute-new-files-list
@vindex proof-cannot-reopen-processed-files
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, the file 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} should be set to calculate the
new value for @code{proof-included-files-list} after a retract message
has been seen).
@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, retracting,
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}.
The special case for retracting is the primary file the user wishes to
edit: this is automatically removed from
@code{proof-included-files-list}, but it depends on the proof assistant
whether or not it is possible to revert to a partially processed version
of the file (or "undo into" it). This is the reason for the setting
@code{proof-cannot-reopen-processed-files}. If this is non-nil, any
attempt to undo a fully processed file will unlock the entire file
(whether or not Proof General itself has history information for the
file).
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 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{Settings for matching
urgent messages from proof process}. 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}.
If your prover does not allow re-opening of closed
files, set @code{proof-cannot-reopen-processed-files} to @code{t}.
Finally, set the flag @code{proof-auto-multiple-files}
for a automatic approximation to multiple file handling.
@xref{Proof Script Settings}.
Internally Proof General uses
@code{proof-register-possibly-new-processed-file} to add a file
to @code{proof-included-files-list} and to possibly inform the
prover about this fact, @xref{Proof script mode}. The function
@code{proof-shell-process-urgent-message-retract} is responsible
for taking (possibly several) files off
@code{proof-included-files-list}. It relies on
@code{proof-shell-compute-new-files-list} (@pxref{Settings for
matching urgent messages from proof process}) to compute the new
value of @code{proof-included-files-list} and then calls
@code{proof-restart-buffers} on all those buffers that have been
taken off from @code{proof-included-files-list}, @xref{Proof
script mode}.
@node Configuring Editing Syntax
@chapter Configuring Editing Syntax
@cindex syntax table
Emacs has some standard settings which configure the syntax of major
modes. The main setting is the @i{syntax table}, which determines the
syntax of programming elements such as strings, comments, and
parentheses. To configure the syntax table, you can either write calls
to @code{modify-syntax-entry} in your mode functions, or set the
following variables to contain the tables for each mode. (The main mode
to be concerned about is of course the proof script, where user editing
takes place).
@c TEXI DOCSTRING MAGIC: proof-script-syntax-table-entries
@defvar proof-script-syntax-table-entries
List of syntax table entries for proof script mode.@*
A flat list of the form
@lisp
(@var{char} @var{syncode} @var{char} @var{syncode} ...)
@end lisp
See doc of @samp{@code{modify-syntax-entry}} for details of characters
and syntax codes.
At present this is used only by the @samp{@code{proof-easy-config}} macro.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-syntax-table-entries
@defvar proof-shell-syntax-table-entries
List of syntax table entries for proof script mode.@*
A flat list of the form
@lisp
(@var{char} @var{syncode} @var{char} @var{syncode} ...)
@end lisp
See doc of @samp{@code{modify-syntax-entry}} for details of characters
and syntax codes.
At present this is used only by the @samp{@code{proof-easy-config}} macro.
@end defvar
Some additional useful settings are:
@c magic by hand: comment-quote-nested
@defvar comment-quote-nested
Non-nil if nested comments should be quoted.
This should be locally set by each major mode if needed. The
default setting is non-nil: modes which allow nested comments may set
this to nil.
@end defvar
@defvar outline-regexp
Regular expression to match the beginning of a heading.
Any line whose beginning matches this regexp is considered to start a heading.
@end defvar
@defvar outline-heading-end-regexp
Regular expression to match the beginning of a heading.
Any line whose beginning matches this regexp is considered to start a heading.
@end defvar
@node Configuring Font Lock
@chapter Configuring Font Lock
@cindex font lock
Support for Font Lock in Proof General is described in the user manual
(see the @i{Syntax highlighting} section). To configure Font Lock for a
new proof assistant, you need to set the variable
@code{font-lock-keywords} in each of the mode functions you want
highlighting for. Proof General will automatically install these
settings, and use font lock minor mode (for syntax highlighting as you
type) in script buffers.
@c nope: too big. TEXI DOCSTRING MAGIC: font-lock-keywords
To understand its format, check the documentation of
@code{font-lock-keywords} inside Emacs.
Instead of setting @code{font-lock-keywords} in each mode function, you
can use the following four variables to make the settings in place.
This is particularly useful if use the easy configuration mechanism for
Proof General, @pxref{Demonstration instance and easy configuration}.
@c TEXI DOCSTRING MAGIC: proof-script-font-lock-keywords
@defvar proof-script-font-lock-keywords
Value of @samp{@code{font-lock-keywords}} used to fontify proof scripts.@*
The proof script mode should set this before calling @samp{@code{proof-config-done}}.
Used also by @samp{@code{proof-easy-config}} mechanism.
See also @samp{@code{proof-goals-font-lock-keywords}} and @samp{@code{proof-response-font-lock-keywords}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-goals-font-lock-keywords
@defvar proof-goals-font-lock-keywords
Value of @samp{@code{font-lock-keywords}} used to fontify the goals output.@*
The goals shell mode should set this before calling @samp{@code{proof-goals-config-done}}.
Used also by @samp{@code{proof-easy-config}} mechanism.
See also @samp{@code{proof-script-font-lock-keywords}} and @samp{@code{proof-response-font-lock-keywords}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-response-font-lock-keywords
@defvar proof-response-font-lock-keywords
Value of @samp{@code{font-lock-keywords}} used to fontify the response output.@*
The response mode should set this before calling @samp{@code{proof-response-config-done}}.
Used also by @samp{@code{proof-easy-config}} mechanism.
See also @samp{@code{proof-script-font-lock-keywords}} and @samp{@code{proof-goals-font-lock-keywords}}.
@end defvar
Proof General provides a special function, @code{proof-zap-commas}, for
tweaking the font lock behaviour of provers which have declarations of
the form @code{x,y,z:Ty}. This function removes highlighting on the
commas, and can be added as the last element of
@code{font-lock-keywords}. Further manipulation of font lock behaviour
can be achieved via two hook functions which are run before and after
fontifying the output buffers.
@c TEXI DOCSTRING MAGIC: proof-zap-commas
@defun proof-zap-commas limit
Remove the face of all @samp{,} from point to @var{limit}.@*
Meant to be used from @samp{@code{font-lock-keywords}} as a way
to unfontify commas in declarations and definitions.
Useful for provers which have declarations of the form x,y,z:Ty
All that can be said for it is that the previous ways of doing
this were even more bogus....
@end defun
@c TEXI DOCSTRING MAGIC: pg-before-fontify-output-hook
@defvar pg-before-fontify-output-hook
This hook is called before fontifying a region in an output buffer.@*
A function on this hook can alter the region of the buffer within
the current restriction, and must return the final value of (@code{point-max}).
[This hook is presently only used by phox-sym-lock].
@end defvar
@c TEXI DOCSTRING MAGIC: pg-after-fontify-output-hook
@defvar pg-after-fontify-output-hook
This hook is called before fonfitying a region in an output buffer.@*
[This hook is presently only used by Isabelle].
@end defvar
@node Configuring Tokens
@chapter Configuring Tokens
@cindex Unicode Tokens
@cindex Tokens
Unicode Tokens is basically an overly complicated way of configuring
font-lock, along with some helpful menus. The font lock configuration
makes use of recent Emacs features, particularly including
@code{compose-region} which allows the presentation of the buffer be
different from the underlying buffer contents. Compared with the
X-Symbol package used previously by Proof General, this has the huge
advantage of not requiring the underlying text to be changed to display
symbols.
Usage of the Unicode Tokens package is described in the Proof General
user manual, @inforef{Unicode support, ,ProofGeneral}.
@c FIXME TODO: add documentation here to explain config of Unicode Tokens
@c TEXI DOCSTRING MAGIC: proof-tokens-activate-command
@defvar proof-tokens-activate-command
Command to activate token input/output for prover.@*
If non-nil, this command is sent to the proof assistant when
Unicode Tokens support is activated.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-tokens-deactivate-command
@defvar proof-tokens-deactivate-command
Command to deactivate token input/output for prover.@*
If non-nil, this command is sent to the proof assistant when
Unicode Tokens support is deactivated.
@end defvar
We expect tokens to be used uniformly, so that along with each script
mode buffer, the response buffer and goals buffer also invoke Tokens
to display special characters in the same token language. This happens
automatically. If you want additional modes to use Tokens with the
token language for your proof assistant, you can set
@code{proof-tokens-extra-modes}.
@c TEXI DOCSTRING MAGIC: proof-tokens-extra-modes
@defvar proof-tokens-extra-modes
List of additional mode names to use with Proof General tokens.@*
These modes will have Tokens 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 Configuring Proof-Tree Visualization
@chapter Configuring Proof-Tree Visualization
The proof-tree visualization feature was written with the idea of
supporting Coq as well as other proof assistants. Nevertheless,
supporting proof-tree visualization for a second proof assistant
will almost certainly require changes in the generic Elisp code
in @code{generic/proof-tree.el} as well as in the
Prooftree program.
@menu
* A layered set of proof trees::
* Prerequisites::
* Proof-Tree Display Internals::
* Configuring Prooftree for a New Proof Assistant::
@end menu
@node A layered set of proof trees
@section A layered set of proof trees
Prooftree can actually display more than one proof tree per
proof. This is necessary to support the
@code{Grab Existential Variables} command in Coq. When the main
goal has been proved, this command turns all open existential
variables into new proof obligations. All these new proof
obligations become root nodes for their own proof trees. When
they all have been proved one can again grab the open existential
variables...
For each proof, Prooftree can therefore display several layers,
where each layer can contain several (graphically) independent
proof trees. The first layer contains one tree for the original
proof goal. The second layer contains proof trees for goals that
have been added to the proof after the first proof tree was
completed. And so on.
To organize the layers, Prooftree must identify those proof
commands that add new goals to a proof.
@c TEXI DOCSTRING MAGIC: proof-tree-new-layer-command-regexp
@defvar proof-tree-new-layer-command-regexp
Regexp to match proof commands that add new goals to a proof.@*
This regexp must match the command that turns the proof assistant
into prover mode, which adds the initial goal to the proof. It
must further match commands that add additional goals after all
previous goals have been proved.
@end defvar
@node Prerequisites
@section Prerequisites
Proof-tree visualization requires certain support from the proof
assistant. Patching the proof assistant is therefore the first
step of adding support for proof-tree visualization. The
following features are needed.
@table @asis
@item Unique goal identification
The proof assistant must assign and output a unique string for
each goal. For Coq the internal @code{evar} index number is used,
which is printed for each goal in the form @code{(ID XXX)} when
Coq is started with the option @code{-emacs}.
The unique goal identification is needed to distinguish newly
spawned subgoals from older open subgoals and to mark the current
goal in the proof-tree display.
@item Indication of newly generated subgoals
A proof command that spawns additional subgoals must somehow
indicate the goal ID's of these new subgoals. Otherwise the
proof-tree display will not be able to reconstruct the proof-tree
structure.
For Coq the newly spawned subgoals appear always in the list of
additional subgoals below the current goal. Note, that it is not
required to mark the newly spawned subgoals. They may appear in a
mixed list with older open subgoals. Note further, that it is not
required that always the complete set of all open subgoals is
printed (which is indeed not the case after of @code{Focus}
command in Coq). It is only required that the goal ID's of all
newly spawned subgoals is somehow printed.
@item State number for undo
There must be a state number that is strictly increasing when
asserting proof commands and that is reset to the appropriate
number after retracting some proof commands.
For Coq the state number in the extended prompt (visible only
with option @code{-emacs}) is used.
@item Information about existential variables
Existential variables are placeholders that might or must be
instantiated later in the proof. Prooftree supports
existential variables with three features. Firstly, it can update
goals when existential variables get instantiated. Secondly, it
can mark the proof commands that introduced or instantiated
existential variables and, thirdly, it can display and track
dependencies between existential variables.
For the first feature, the proof assistant must list the currently
instantiated existential variables for every goal. For the second
feature it must additionally list the not instantiated
existential variables. Finally, for the third feature, it must
display the dependencies for instantiated existential variables.
For Coq, all necessary information is provided in the existential
evar line, that is printed with the @code{-emacs} switch.
@end table
@node Proof-Tree Display Internals
@section Proof-Tree Display Internals
This section gives some information about the inner structure of
the code that realizes the proof-tree display. The idea here is
that this section provides the background information to make the
documentation of the customizable variables of the proof-tree
Elisp code easy to understand.
@menu
* Organization of the Code::
* Communication::
* Guards::
* Urgent and Delayed Actions::
* Full Annotation::
@end menu
@node Organization of the Code
@subsection Organization of the Code
The proof-tree display is realized by Proof General in
cooperation with the external Prooftree program. The
latter is a GTK application in OCaml. Both, the Elisp code in
Proof General and the Prooftree OCaml code is divided into
a generic and a proof assistant specific part.
The generic Elisp code lives in @code{generic/proof-tree.el}. As
usual in Proof General, it contains various customizable
variables, which the proof assistant specific code must set. Most
of these variables contain regular expressions, but there are also
some that hold functions. The Coq specific code for the
proof-tree display is distributed in a few chunks over
@code{coq/coq.el}.
The main task of the Elisp code is to extract goals, undo events
and information about existential variables from the
proof-assistant output and to send all this data to Prooftree.
The Elisp code does also determine if additional output must be
requested from the proof assistant. In that case it adds
appropriate commands to @code{proof-action-list}, @pxref{Proof
script mode}. These additional commands are flagged with
@code{proof-tree-show-subgoal}, @code{no-goals-display} and
@code{no-response-display}. The flag
@code{proof-tree-show-subgoal} ensures that a number of internal
functions ignore these additional commands. The other two flags
ensure that their output is neither displayed in the goals nor
the response buffer.
For the decision about which goals must be sent to Prooftree, the
Elisp code maintains the following two state variables.
@c TEXI DOCSTRING MAGIC: proof-tree-sequent-hash
@defvar proof-tree-sequent-hash
Hash table to remember sequent ID's.@*
Needed because some proof assistants do not distinguish between
new subgoals, which have been created by the last proof command,
and older, currently unfocussed subgoals. If Proof General meets
a goal, it is treated as new subgoal if it is not in this hash yet.
The hash is mostly used as a set of sequent ID's. However, for
undo operations it is necessary to delete all those sequents from
the hash that have been created in a state later than the undo
state. For this purpose this hash maps sequent ID's to the state
number in which the sequent has been created.
The hash table is initialized in @samp{@code{proof-tree-start-process}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-tree-existentials-alist
@defvar proof-tree-existentials-alist
Alist mapping existential variables to sequent ID's.@*
Used to remember which goals need a refresh when an existential
variable gets instantiated. To support undo commands the old
contents of this list must be stored in
@samp{@code{proof-tree-existentials-alist-history}}. To ensure undo is
properly working, this variable should only be changed by using
@samp{@code{proof-tree-delete-existential-assoc}},
@samp{@code{proof-tree-add-existential-assoc}} or
@samp{@code{proof-tree-clear-existentials}}.
@end defvar
When retracting these two variables must be set to their previous
state. For @code{proof-tree-sequent-hash} this is done with the
state numbers that are stored in the hash. For
@code{proof-tree-existentials-alist} a separate alist stores
previous states.
@c TEXI DOCSTRING MAGIC: proof-tree-existentials-alist-history
@defvar proof-tree-existentials-alist-history
Alist mapping state numbers to old values of @samp{@code{proof-tree-existentials-alist}}.@*
Needed for undo.
@end defvar
In Prooftree the separation between generic and proof-assistant
specific code is less obvious. The Coq specific code is in the
file @code{coq.ml}. All the remaining code is generic.
Prooftree opens for each proof a separate window. It reconstructs
the proof tree and orders the existential variables in a
dependency hierarchy. It stores a complete history of previous
states to support arbitrary undo operations. Under normal
circumstances one starts just one Prooftree process that keeps
running for the remainder of the Proof General session,
regardless of how many proof-tree windows are displayed.
A fair amount of the Prooftree code is documented with
@code{ocamldoc} documentation comments. With @code{make doc} they
can be converted into a set of html pages in the @code{doc}
subdirectory.
@node Communication
@subsection Communication
Prooftree is a standard Emacs subprocess that reads goals and
other proof status messages from its standard input. The
communication between Proof General and Prooftree is almost one
way only. Proof General sends proof status messages to Prooftree,
from which Prooftree reconstructs the current proof status and
the complete proof tree. Prooftree never requests additional
information from Proof General.
There are only a few messages that Prooftree sends to Proof
General. These messages communicate user requests to Proof
General, for instance, when the user selects the undo menu item,
or when he closes the Prooftree window.
The communication protocol is completely described in the
@code{ocamldoc} documentation of @code{input.ml} in the Prooftree
sources. All messages consist of UTF-8 encoded human-readable
strings. The strings have either a fixed length or their byte-length
is encoded in the message before the string itself.
For debugging purposes Prooftree can save all input in a file.
This feature can be turned on in the @code{Debug} tab of the
Prooftree configuration dialog or with option @code{-tee}. The
text that Prooftree sends to Proof General can be found in buffer
@code{*proof-tree*}.
@node Guards
@subsection Guards
The proof-tree display code inside Proof General uses two guard
variables.
@c TEXI DOCSTRING MAGIC: proof-tree-configured
@defvar proof-tree-configured
Whether external proof-tree display is configured.@*
This boolean enables the proof-tree menu entry and the function
that starts external proof-tree display.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-tree-external-display
@defvar proof-tree-external-display
Display proof trees in external prooftree windows if t.@*
Actually, if this variable is t then the user requested an
external proof-tree display. If there was no unfinished proof
when proof-tree display was requested and if no proof has been
started since then, then there is obviously no proof-tree
display. In this case, this variable stays t and the proof-tree
display will be started for the next proof.
Controlled by @samp{@code{proof-tree-external-display-toggle}}.
@end defvar
In Proof General, the code for the external proof-tree display is
called from the proof-shell filter function in
@code{proof-shell-exec-loop} and
@code{proof-shell-filter-manage-output}, @pxref{Proof shell
mode}. The variable @code{proof-tree-external-display} is a guard
for these calls, to ensure that the proof-tree specific code is
only called if the user requested a proof-tree display.
The whole proof-tree package contains only one function that can
be called interactively:
@code{proof-tree-external-display-toggle}, which switches
@code{proof-tree-external-display} on and off. When
@code{proof-tree-configured} is @code{nil},
@code{proof-tree-external-display-toggle} aborts with an error
message.
@c TEXI DOCSTRING MAGIC: proof-tree-external-display-toggle
@deffn Command proof-tree-external-display-toggle
Toggle the external proof-tree display.@*
When called outside a proof the external proof-tree display will
be enabled for the next proof. When called inside a proof the
proof display will be created for the current proof. If the
external proof-tree display is currently on, then this toggle
will switch it off. At the end of the proof the proof-tree
display is switched off.
@end deffn
@node Urgent and Delayed Actions
@subsection Urgent and Delayed Actions
The proof-shell filter functions contains two calls to proof-tree
specific code. One for urgent actions and one for all remaining
actions, that can be delayed.
Urgent actions are those that must be executed before
@code{proof-shell-exec-loop} sends the next item from
@code{proof-action-list} to the proof assistant. For execution
speed, the amount of urgent code should be kept small.
@c TEXI DOCSTRING MAGIC: proof-tree-urgent-action
@defun proof-tree-urgent-action flags
Handle urgent points before the next item is sent to the proof assistant.@*
Schedule goal updates when existential variables have changed and
call @samp{@code{proof-tree-urgent-action-hook}}. All this is only done if
the current output does not come from a command (with the
@code{'proof-tree-show-subgoal} flag) that this package inserted itself.
Urgent actions are only needed if the external proof display is
currently running. Therefore this function should not be called
when @samp{@code{proof-tree-external-display}} is nil.
This function assumes that the prover output is not suppressed.
Therefore, @samp{@code{proof-tree-external-display}} being t is actually a
necessary precondition.
The not yet delayed output is in the region
[@code{proof-shell-delayed-output-start}, @code{proof-shell-delayed-output-end}].
@end defun
The function @code{proof-tree-urgent-action} is called at a point
where it is save to manipulate @code{proof-action-list}. This is
essential, because @code{proof-tree-urgent-action} inserts goal
display commands into @code{proof-action-list} when existential
variables got instantiated and when the sequent text from newly
created subgoals is missing.
Most of the proof-tree specific code runs when the proof
assistant is already busy with the next item from
@code{proof-action-list}.
@c TEXI DOCSTRING MAGIC: proof-tree-handle-delayed-output
@defun proof-tree-handle-delayed-output old-proof-marker cmd flags span
Process delayed output for prooftree.@*
This function is the main entry point of the Proof General
prooftree support. It examines the delayed output in order to
take appropriate actions and maintains the internal state.
The delayed output to handle is in the region
[@code{proof-shell-delayed-output-start}, @code{proof-shell-delayed-output-end}].
Urgent messages might be before that, following @var{old-proof-marker},
which contains the position of @samp{@code{proof-marker}}, before the next
command was sent to the proof assistant.
All other arguments are (former) fields of the @samp{@code{proof-action-list}}
entry that is now finally retired. @var{cmd} is the command, @var{flags} are
the flags and @var{span} is the span.
@end defun
The function @code{proof-tree-handle-delayed-output} does all the
communication with Prooftree.
@node Full Annotation
@subsection Full Annotation
In the default configuration Proof General switches the proof
assistant into quiet mode if there are more than
@code{proof-shell-silent-threshold} items in
@code{proof-action-list}, see Section @i{Document centred
working} (in Chapter @i{Advanced Script Management and Editing})
in the @i{Proof General} users manual. The proof-tree display
needs of course the full output from the proof assistant.
Therefore @code{proof-shell-should-be-silent} keeps the proof
assistant noisy when the proof-tree display is switched on.
@node Configuring Prooftree for a New Proof Assistant
@section Configuring Prooftree for a New Proof Assistant
To get the proof-tree display running for a new proof assistant
one has to configure the proof-tree Elisp code and adapt the
Prooftree program.
@menu
* Proof Tree Elisp configuration::
* Prooftree Adaption::
@end menu
@node Proof Tree Elisp configuration
@subsection Proof Tree Elisp configuration
All variables that need to be configured are in the customization
group @code{proof-tree-internals}. Most of these variables are
regular expressions for extracting various parts from the proof
assistant output. However, some are functions that need to be
implemented as prover specific part of the proof display code.
The variables @code{proof-tree-configured},
@code{proof-tree-get-proof-info} and
@code{proof-tree-find-begin-of-unfinished-proof} might be used
before the proof assistant is running inside a proof shell. They
must therefore be configured as part of the proof assistant
editing mode.
The other variables are only used when the proof shell is
running. They can therefore be configured with the
proof assistant proof-shell mode.
@node Prooftree Adaption
@subsection Prooftree Adaption
To make the new proof assistant known to Prooftree, the match in
function @code{configure_prooftree} in @code{input.ml} must be
extended. If the new proof assistant does not support existential
variables adding a line
@example
| "new-pa-name" -> ()
@end example
suffices.
If the new prover supports existential variables, Prooftree must
be extended with a parser for the existential variable
information printout of the proof assistant. The parser for Coq
is contained in the file @code{coq.ml}. Then the function
@code{configure_prooftree} must assign this new parser to the
reference @code{parse_existential_info}.
@node Writing More Lisp Code
@chapter Writing More Lisp Code
You may want to add some extra features to your instance of Proof
General which are not supported in the generic core. To do this, you
can use the settings described above, plus a small number of fundamental
functions in Proof General which you can consider as exported in the
generic interface. Be careful using more functions than are mentioned
here because the internals of Proof General may change between versions.
@menu
* Default values for generic settings::
* Adding prover-specific configurations::
* Useful variables::
* Useful functions and macros::
@end menu
@node Default values for generic settings
@section Default values for generic settings
Several generic settings are defined using @code{defpgcustom} in
@file{proof-config.el}. This introduces settings of the form
@code{<PA>-name} for each proof assistant @var{PA}.
To set the default value for these settings in prover-specific cases,
you should use the special @code{defpgdefault} macro:
@c TEXI DOCSTRING MAGIC: defpgdefault
@deffn Macro defpgdefault
Set default for the proof assistant specific variable <PA>@var{-sym} to @var{value}.@*
This should be used in prover-specific code to alter the default values
for prover specific settings.
Usage: (defpgdefault SYM @var{value})
@end deffn
In your prover-specific code you can simply use the setting
@code{<PA>-sym} directly, i.e., write @code{myprover-home-page}.
In the generic code, you can use a macro, writing @code{(proof-ass
home-page)} to refer to the @code{<PA>-home-page} setting for the
currently running instance of Proof General.
@xref{Configuration variable mechanisms}, for more details on this
mechanism.
@node Adding prover-specific configurations
@section Adding prover-specific configurations
Apart from the generic settings, your prover instance will probably need
some specific customizable settings.
Defining new prover-specific settings using customize is pretty easy.
You should do it at least for your prover-specific user options.
The code in @file{proof-site.el} provides each prover with two
customization groups automatically (based on the name of the assistant):
@code{<PA>} for user options for prover @var{PA}
and
@code{<PA>-config} for configuration of prover @var{PA}.
Typically @code{<PA>-config} holds settings which are
constants but which may be nice to tweak.
The first group appears in the menu
@lisp
ProofGeneral -> Advanced -> Customize -> <PA>
@end lisp
The second group appears in the menu:
@lisp
ProofGeneral -> Internals -> <PA> config
@end lisp
A typical use of @code{defcustom} looks like this:
@lisp
(defcustom myprover-search-page
"http://findtheorem.myprover.org"
"URL of search web page for myprover."
:type 'string
:group 'myprover-config)
@end lisp
This introduces a new customizable setting, which you might use to make
a menu entry, for example. The default value is the string
@code{"http://findtheorem.myprover.org"}.
@node Useful variables
@section Useful variables
In @file{proof-site}, some architecture flags are defined. These
can be used to write conditional pieces of code for different Emacs
and operating systems. They are referred to mainly in
@file{proof-compat} (which helps to keep the architecture and version
dependent code in one place).
@node Useful functions and macros
@section Useful functions and macros
The recommended functions you may invoke are these:
@itemize @bullet
@item Any of the interactive commands (i.e. anything you
can invoke with @kbd{M-x}, including all key-bindings)
@item Any of the internal functions and macros mentioned below
@end itemize
To insert text into the current (usually script) buffer, the function
@code{proof-insert} is useful. There's also a handy macro
@code{proof-defshortcut} for defining shortcut functions using it.
@c TEXI DOCSTRING MAGIC: proof-insert
@defun proof-insert text
Insert @var{text} into the current buffer.@*
@var{text} may include these special characters:
@lisp
%p - place the point here after input
@end lisp
Any other %-prefixed character inserts itself.
@end defun
@c TEXI DOCSTRING MAGIC: proof-defshortcut
@deffn Macro proof-defshortcut
Define shortcut function FN to insert @var{string}, optional keydef KEY.@*
This is intended for defining proof assistant specific functions.
@var{string} is inserted using @samp{@code{proof-insert}}, which see.
KEY is added onto proof assistant map.
@end deffn
The function @code{proof-shell-invisible-command} is a useful utility
for sending a single command to the process. You should use this to
implement user-level or internal functions rather than attempting to
directly manipulate the proof action list, or insert into the shell
buffer.
@c TEXI DOCSTRING MAGIC: proof-shell-invisible-command
@defun proof-shell-invisible-command cmd &optional wait invisiblecallback &rest flags
Send @var{cmd} to the proof process.@*
The @var{cmd} is @samp{invisible} in the sense that it is not recorded in buffer.
@var{cmd} may be a string or a string-yielding expression.
Automatically add @samp{@code{proof-terminal-string}} if necessary, examining
@samp{proof-shell-no-auto-terminate-commands}.
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.
In case @var{cmd} is (or yields) nil, do nothing.
@var{invisiblecallback} will be invoked after the command has finished,
if it is set. It should probably run the hook variables
@samp{@code{proof-state-change-hook}}.
@var{flags} are additional flags to put onto the @samp{@code{proof-action-list}}.
The flag @code{'invisible} is always added to @var{flags}.
@end defun
There are several handy macros to help you define functions
which invoke @code{proof-shell-invisible-command}.
@c TEXI DOCSTRING MAGIC: proof-definvisible
@deffn Macro proof-definvisible
Define function FN to send @var{string} to proof assistant, optional keydef KEY.@*
This is intended for defining proof assistant specific functions.
@var{string} is sent using @samp{@code{proof-shell-invisible-command}}, which see.
@var{string} may be a string or a function which returns a string.
KEY is added onto proof assistant map.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-define-assistant-command
@deffn Macro proof-define-assistant-command
Define FN (docstring DOC): check if @var{cmdvar} is set, then send @var{body} to prover.@*
@var{body} defaults to @var{cmdvar}, a variable.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-define-assistant-command-witharg
@deffn Macro proof-define-assistant-command-witharg
Define FN (arg) with DOC: check @var{cmdvar} is set, @var{prompt} a string and eval @var{body}.@*
The @var{body} can contain occurrences of arg.
@var{cmdvar} is a variable holding a function or string. Automatically has history.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-format-filename
@defun proof-format-filename string filename
Format @var{string} by replacing quoted chars by escaped version of @var{filename}.
%e uses the canonicalized expanded version of filename (including
directory, using @samp{@code{default-directory}} -- see @samp{@code{expand-file-name}}).
%r uses the unadjusted (possibly relative) version of @var{filename}.
%m ('module') uses the basename of the file, without directory
or extension.
%s means the same as %e.
Using %e can avoid problems with dumb proof assistants who don't
understand ~, for example.
For all these cases, the escapes in @samp{@code{proof-shell-filename-escapes}}
are processed.
If @var{string} is in fact a function, instead invoke it on @var{filename} and
return the resulting (string) value.
@end defun
@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::
* Proof General site configuration::
* Configuration variable mechanisms::
* Global variables::
* Proof script mode::
* Proof shell mode::
* Debugging::
@end menu
@c
@c SECTION: Global variables
@c
@node Spans
@section Spans
@cindex spans
@cindex extents
@cindex overlays
@dfn{Spans} are an abstraction of Emacs @dfn{overlays} originally used
to help bridge the gulf between GNU Emacs and XEmacs. See the file
@file{lib/span.el}. XEmacs calls these @dfn{extents} which is a name
still used in some parts of the code.
@c
@c SECTION: Proof General site configuration
@c
@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.@*
Based on where the file @samp{proof-site.el} was loaded from.
Falls back to consulting the environment variable @samp{PROOFGENERAL_HOME} if
proof-site.el couldn't know where it was executed from.
@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{'isar} @code{'coq} @code{'easycrypt} @code{'phox} @code{'pgshell} @code{'pgocaml} @code{'pghaskell}.
If nil, the default will be ALL available proof assistants.
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{nil}.
@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
@c
@c SECTION: Configuration variable mechanisms
@c
@node Configuration variable mechanisms
@section Configuration variable mechanisms
@cindex conventions
@cindex user options
@cindex configuration
@cindex settings
The file @file{proof-config.el} defines the configuration variables for
Proof General, including instantiation parameters and user options. See
previous chapters for details of its contents. Here we mention some
conventions for declaring user options.
Global user options and instantiation parameters are declared using
@code{defcustom} as usual. User options should have `@code{*}' as the
first character of their docstrings (standard Emacs convention) and live
in the customize group @code{proof-user-options}. See
@file{proof-config.el} for the groups for instantiation parameters.
User options which are generic (having separate instances for each
prover) and instantiation parameters (by definition generic) can be
declared using the special macro @code{defpgcustom}. It is used in the
same way as @code{defcustom}, except that the symbol declared will
automatically be prefixed by the current proof assistant symbol.
@c TEXI DOCSTRING MAGIC: defpgcustom
@deffn Macro defpgcustom
Define a new customization variable <PA>@var{-sym} for the current proof assistant.@*
This is intended for defining settings which are useful for any prover,
but which the user may require different values of across provers.
The function proof-assistant-<SYM> is also defined, which can be used in the
generic portion of Proof General to access the value for the current prover.
Arguments @var{args} are as for @samp{defcustom}, which see. If a :group argument is
not supplied, the setting will be added to the internal settings for the
current prover (named <PA>-config).
@end deffn
In specific instances of Proof General, the macro @code{defpgdefault}
can be used to give a default value for a generic setting.
@c TEXI DOCSTRING MAGIC: defpgdefault
@deffn Macro defpgdefault
Set default for the proof assistant specific variable <PA>@var{-sym} to @var{value}.@*
This should be used in prover-specific code to alter the default values
for prover specific settings.
Usage: (defpgdefault SYM @var{value})
@end deffn
All new instantiation variables are best declared using the
@code{defpgcustom} mechanism (old code may be converted gradually).
Customizations which are liable to be different for different instances
of Proof General are also best declared in this way. An example is the
use of X Symbol, controlled by @code{@emph{PA}-x-symbol-enable}, since
it works poorly or not at all with some provers.
To access the generic settings, the following four functions and
macros are useful.
@c TEXI DOCSTRING MAGIC: proof-ass
@deffn Macro proof-ass
Return the value for SYM for the current prover.@*
This macro should only be invoked once a specific prover is engaged.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-ass-sym
@deffn Macro proof-ass-sym
Return the symbol for SYM for the current prover. SYM not evaluated.@*
This macro should only be called once a specific prover is known.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-ass-symv
@deffn Macro proof-ass-symv
Return the symbol for SYM for the current prover. SYM evaluated.@*
This macro should only be invoked once a specific prover is engaged.
@end deffn
If changing a user option setting amounts to more than just setting a
variable (it may have some dynamic effect), we can set the
@code{custom-set} property for the variable to the function
@code{proof-set-value} which does an ordinary @code{set-default} to set
the variable, and then calls a function with the same name as the
variable, to do whatever is necessary according to the new value for the
variable.
There are several settings which can be switched on or off by the user,
which use this @code{proof-set-value} mechanism. They are controlled by
boolean variables with names like @code{proof-@var{foo}-enable}, 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}.
In @code{proof-utils.el} there is a handy macro,
@code{proof-deftoggle}, 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 boolean user options, as well as
interfacing properly with the @code{customize} mechanism.
@c TEXI DOCSTRING MAGIC: proof-set-value
@defun proof-set-value sym value
Set a customize variable using @samp{@code{set-default}} and a function.@*
We first call @samp{@code{set-default}} to set @var{sym} to @var{value}.
Then if there is a function @var{sym} (i.e. with the same name as the
variable @var{sym}), it is called to take some dynamic action for the new
setting.
If there is no function @var{sym}, we try stripping
@samp{@code{proof-assistant-symbol}} and adding "proof-" instead to get
a function name. This extends @code{proof-set-value} to work with
generic individual settings.
The dynamic action call only happens when values @strong{change}: as an
approximation we test whether proof-config is fully-loaded yet.
@end defun
@c TEXI DOCSTRING MAGIC: proof-deftoggle
@deffn Macro proof-deftoggle
Define a function VAR-toggle for toggling a boolean customize setting VAR.@*
The toggle function uses @samp{@code{customize-set-variable}} to change the variable.
@var{othername} gives an alternative name than the default <VAR>-toggle.
The name of the defined function is returned.
@end deffn
@c
@c SECTION: Global variables
@c
@node Global variables
@section Global variables
@cindex 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-response-buffer
@defvar proof-response-buffer
The response buffer.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-goals-buffer
@defvar proof-goals-buffer
The goals buffer.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-buffer-type
@defvar proof-buffer-type
Symbol for the type of this buffer: @code{'script}, @code{'shell}, @code{'goals}, or @code{'response}.
@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 @samp{@code{proof-shell-process-file}} configuration settings.
When the prover retracts a file, this list is resynchronised via the
@samp{@code{proof-shell-retract-files-regexp}} and @samp{@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
@c
@c SECTION: Proof script mode
@c
@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, key-bindings, 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.@*
Each script buffer has its own queue span, although only the active
scripting buffer may have an active queue span.
@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.
Also clear list of script portions.
@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
Ensure @var{buffer} marked completely processed, completing with a single step.
If buffer already contains a locked region, only the remainder of the
buffer is closed off atomically (although undo for the initial portion
is unlikely to work, the decoration may be worth retaining).
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 noquestions
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).
In this case, the user will be queried to save some buffers, unless
@var{noquestions} is non-nil.
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 has a modified buffer visiting the file.
@end defun
(Unlocking is done by
@code{proof-shell-process-urgent-message-retract} together with
@code{proof-restart-buffers}.)
An important pair of functions activate and deactivate scripting for the
current buffer. A change in the state of active scripting 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 is 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.
If the hooks issue commands to the proof assistant (via
@samp{@code{proof-shell-invisible-command}}) which result in an error, the
activation is considered to have failed and an error is given.
@end deffn
@c TEXI DOCSTRING MAGIC: proof-deactivate-scripting
@deffn Command proof-deactivate-scripting &optional forcedaction
Try to deactivate scripting for the active scripting buffer.
Aims to set @samp{@code{proof-script-buffer}} to nil and turn off the
modeline indicator. No action is required there is no active
scripting buffer.
We make sure that the active scripting buffer either has no locked
region or a full locked region (everything in it has been processed).
If this is not already the case, we question the user whether to
retract or assert, or automatically take the action indicated in the
user option @samp{@code{proof-auto-action-when-deactivating-scripting}}.
If @samp{@code{proof-no-fully-processed-buffer}} is t there is only the choice
to fully retract the active scripting buffer. In this case the
active scripting buffer is retracted even if it was fully processed.
Setting @samp{@code{proof-auto-action-when-deactivating-scripting}} to @code{'process}
is ignored in this case.
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, we make sure that it is @strong{not} registered. This is to be
certain 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 @samp{@code{proof-script-buffer}} is 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 @samp{@code{kill-buffer-hook}} for scripting buffers, so that when
a scripting buffer is killed it is always retracted.
@end deffn
The function @code{proof-segment-up-to} is the main one used for parsing
the proof script buffer. There are several variants of this function
available corresponding to different parsing strategies; the appropriate
one is aliased to @code{proof-segment-up-to} according to which
configuration variables have been set.
@itemize @bullet
@item If @code{proof-script-sexp-commands} is set, the choice is
@code{proof-script-generic-parse-sexp}.
@ item If only @code{proof-script-command-end-regexp} or @code{proof-terminal-string} are set,
then the default is @code{proof-script-generic-parse-cmdend}.
@item If @code{proof-script-command-start-regexp} is set, the choice is
@code{proof-script-generic-parse-cmdstart}.
@end itemize
The function @code{proof-semis-to-vanillas} uses
@code{proof-segment-up-to} 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-script-generic-parse-cmdend
@defun proof-script-generic-parse-cmdend
For @samp{@code{proof-script-parse-function}} if @samp{@code{proof-script-command-end-regexp}} set.
@end defun
@c TEXI DOCSTRING MAGIC: proof-script-generic-parse-cmdstart
@defun proof-script-generic-parse-cmdstart
For @samp{@code{proof-script-parse-function}} if @samp{@code{proof-script-command-start-regexp}} is set.
@end defun
@c TEXI DOCSTRING MAGIC: proof-script-generic-parse-sexp
@defun proof-script-generic-parse-sexp
Used for @samp{@code{proof-script-parse-function}} if @samp{@code{proof-script-sexp-commands}} is set.
@end defun
@c TEXI DOCSTRING MAGIC: proof-semis-to-vanillas
@defun proof-semis-to-vanillas semis &optional queueflags
Create vanilla spans for @var{semis} and a list for the queue.@*
Proof terminator positions @var{semis} has the form returned by
the function @samp{proof-segment-up-to}. The argument list is destroyed.
The callback in each queue element is @samp{@code{proof-done-advancing}}.
If the variable @samp{@code{proof-script-preprocess}} is set (to the name of
a function), call that function to construct the first element of
each queue item.
The optional @var{queueflags} are added to each queue item.
@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 displayflags
Process the region from the end of the locked-region until point.
@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 undo-action displayflags
Set up the proof process for retracting until point.@*
This calculates the commands to undo to the current point within
the locked region. If invoked outside the locked region, undo
the last successfully processed command. See @samp{@code{proof-retract-target}}.
After retraction has succeeded in the prover, the filter will call
@samp{@code{proof-done-retracting}}. If @var{undo-action} is non-nil, it will
then be invoked on the region in the proof script corresponding to
the proof command sequence.
@var{displayflags} control output shown to user, see @samp{@code{proof-action-list}}.
Before the retraction is calculated, we enforce the file-level
protocol with @samp{@code{proof-activate-scripting}}. This has a couple
of effects:
1. If the file is completely processed, we have to re-open it
for scripting again which may involve retracting
other (dependent) files.
2. We may query the user whether to save some buffers.
Step 2 may seem odd -- we're undoing (in) the buffer, after all
-- but what may happen is that when scripting starts going
forward again, we hit a command that loads other files, but the
user hasn't saved the latest edits. Therefore it is right to
query saves here.
@end defun
To clean up when scripting is stopped, a script buffer is killed,
a file is retract (and thus must be unlocked), or the
proof assistant exits, we use the functions
@code{proof-restart-buffers} and
@code{proof-script-remove-all-spans-and-deactivate}.
@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}}.@*
The high-level effect is that all members of @var{buffers} are
completely unlocked, including all the necessary cleanup. No
effect on a buffer which is nil or killed. If one of the buffers
is the current scripting buffer, then @samp{@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 @samp{@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
@cindex scomint-mode
The proof shell mode code is in the file @file{proof-shell.el}. Proof
shell mode is defined to inherit from @code{scomint-mode} using
@code{define-derived-mode} near the end of the file. The
@file{scomint.el} package stands for ``simplified comint'', where
@code{comint-mode} is the standard Emacs mode for running an
embedded command interpreter. In @code{scomint}, many of the
interactive commands have been removed to speed up the process
handling, because it isn't intended that the user interacts
directly with the shell in Proof General.
The bulk of the code in the @code{proof-shell} package is concerned with
sending code to and from the shell, and processing output for the
associated buffers (goals and response).
Good 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.
The lock notes that we are processing a queue of commands being
sent to the prover, and indicates whether the commands correspond
to script management from a buffer (rather than being ad-hoc
query commands to the prover).
When processing commands from a buffer for script management,
this will be set to the queue mode @code{'advancing} or @code{'retracting} to
indicate the direction of movement.
When this is non-nil, @samp{@code{proof-shell-ready-prover}} will give
an error if called with a different requested queue mode.
See also functions @samp{@code{proof-activate-scripting}} and
@samp{@code{proof-shell-available-p}}.
@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
The main queue of things to do: spans, commands and actions.@*
The value is a list of lists of the form
@lisp
(@var{span} @var{commands} @var{action} [DISPLAYFLAGS])
@end lisp
which is the queue of things to do.
@var{span} is a region in the sources, where @var{commands} come from. Often,
additional properties are recorded as properties of @var{span}.
@var{commands} is a list of strings, holding the text to be send to the
prover. It might be the empty list if nothing needs to be sent to
the prover, such as, for comments. Usually @var{commands}
contains just 1 string, but it might also contains more elements.
The text should be obtained with
@samp{(mapconcat }identity @var{commands} " ")', where the last argument
is a space.
@var{action} is the callback to be invoked when this item has been
processed by the prover. For normal scripting items it is
@samp{@code{proof-done-advancing}}, for retract items
@samp{@code{proof-done-retracting}}, but there are more possibilities (e.g.
@samp{@code{proof-done-invisible}}, @samp{@code{proof-shell-set-silent}},
@samp{@code{proof-shell-clear-silent}} and @samp{@code{proof-tree-show-goal-callback}}).
The @var{displayflags} are set
for non-scripting commands or for when scripting should not
bother the user. They may include
@lisp
@code{'invisible} non-script command (@samp{@code{proof-shell-invisible-command}})
@code{'no-response-display} do not display messages in @strong{response} buffer
@code{'no-error-display} do not display errors/take error action
@code{'no-goals-display} do not goals in @strong{goals} buffer
@code{'proof-tree-show-subgoal} item inserted by the proof-tree package
@end lisp
Note that @code{'invisible} does not imply any of the others. If flags
are non-empty, interactive cues will be surpressed. (E.g.,
printing hints).
See the functions @samp{@code{proof-start-queue}} and @samp{@code{proof-shell-exec-loop}}.
@end defvar
In Proof General 4.2 and earlier it was always the case that all
items from the queue region were present in
@code{proof-action-list}. Because of the new parallel background
compilation for Coq, this is no longer the case. Prover specific
code may now store items from the queue region somewhere else. To
notify generic Proof General about this, it must set
@code{proof-second-action-list-active} for the time where some
queue items are missing from @code{proof-action-list}. In this
case Proof General keeps the proof shell lock and the queue span
even in case @code{proof-action-list} gets empty. Coq uses this
feature to hold back Require commands and the following text
until the asynchronous background compilation finishes.
@c TEXI DOCSTRING MAGIC: proof-second-action-list-active
@defvar proof-second-action-list-active
Signals that some items are waiting outside of @samp{@code{proof-action-list}}.@*
If this is t it means that some items from the queue region are
waiting for being processed in a place different from
@samp{@code{proof-action-list}}. In this case Proof General must behave as if
@samp{@code{proof-action-list}} would be non-empty, when it is, in fact, empty.
This is used, for instance, for parallel background compilation
for Coq: The Require command and the following items are not put
into @samp{@code{proof-action-list}} and are stored somewhere else until the
background compilation finishes. Then those items are put into
@samp{@code{proof-action-list}} for getting processed.
@end defvar
@c TEXI DOCSTRING MAGIC: pg-subterm-anns-use-stack
@defvar pg-subterm-anns-use-stack
Choice of syntax tree encoding for terms.
If nil, prover is expected to make no optimisations.
If non-nil, the pretty printer of the prover only reports local changes.
For @var{lego} 1.3.1 use nil, for Coq 6.2, use 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.@*
Does nothing if proof assistant is already running.
Also generates goal and response buffers.
If @samp{@code{proof-prog-name-ask}} is set, query the user for the
process command.
@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.@*
Try to shut down the proof process nicely and clear locked
regions and state variables. Value for @samp{@code{kill-buffer-hook}} in
shell buffer, called by @samp{@code{proof-shell-bail-out}} if process exits.
@end defun
@c TEXI DOCSTRING MAGIC: proof-shell-exit
@deffn Command proof-shell-exit &optional dont-ask
Query the user and exit the proof process.
This simply kills the @samp{@code{proof-shell-buffer}} relying on the hook function
@samp{@code{proof-shell-kill-function}} to do the hard work. If optional
argument @var{dont-ask} is non-nil, the proof process is terminated
without confirmation.
The kill function uses @samp{<PA>-quit-timeout} as a timeout to wait
after sending @samp{@code{proof-shell-quit-cmd}} before rudely killing the process.
This function should not be called if
@samp{@code{proof-shell-exit-in-progress}} is t, because a recursive call of
@samp{@code{proof-shell-kill-function}} will give strange errors.
@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 @var{process}.@*
If the proof assistant dies, run @samp{@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.
@var{event} is the string describing the change.
@end defun
@c TEXI DOCSTRING MAGIC: proof-shell-restart
@deffn Command proof-shell-restart
Clear script buffers and send @samp{@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
@samp{@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-extend-queue} and @code{proof-shell-exec-loop}.
@c TEXI DOCSTRING MAGIC: proof-extend-queue
@defun proof-extend-queue end queueitems
Extend the current queue with @var{queueitems}, queue end @var{end}.@*
To make sense, the commands should correspond to processing actions
for processing a region from (buffer-queue-or-locked-end) to @var{end}.
The queue mode is set to @code{'advancing}
@end defun
@c TEXI DOCSTRING MAGIC: proof-extend-queue
@defun proof-extend-queue end queueitems
Extend the current queue with @var{queueitems}, queue end @var{end}.@*
To make sense, the commands should correspond to processing actions
for processing a region from (buffer-queue-or-locked-end) to @var{end}.
The queue mode is set to @code{'advancing}
@end defun
@vindex proof-action-list
@c TEXI DOCSTRING MAGIC: proof-shell-exec-loop
@defun proof-shell-exec-loop
Main loop processing the @samp{@code{proof-action-list}}, called from shell filter.
@samp{@code{proof-action-list}} contains a list of (@var{span} @var{command} @var{action} [FLAGS]) lists.
If this function is called with a non-empty @samp{@code{proof-action-list}}, the
head of the list is the previously executed command which succeeded.
We execute the callback (@var{action} @var{span}) on the first item,
then (@var{action} @var{span}) on any following items which have null 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 or
contains only invisible elements for Prooftree synchronization.
@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 strings action &optional scriptspan
Insert @var{strings} at the end of the proof shell, call @samp{@code{scomint-send-input}}.
@var{strings} is a list of strings (which will be concatenated), or a
single string.
The @var{action} argument is a symbol which is typically the name of a
callback for when each string has been processed.
This calls @samp{@code{proof-shell-insert-hook}}. The arguments @var{action} and
@var{scriptspan} may be examined by the hook to determine how to modify
the string variable (exploiting dynamic scoping) which will be
the command actually sent to the shell.
Note that the hook is not called for the empty (null) string
or a carriage return.
We strip the string of carriage returns before inserting it
and updating @samp{@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 @samp{@code{proof-add-to-queue}} when we start processing a queue, and in
@samp{@code{proof-shell-exec-loop}}, to process the next item.
@end defun
When Proof General is processing a queue of commands, the lock
is managed using a couple of utility functions. You should
not need to use these directly.
@c TEXI DOCSTRING MAGIC: proof-grab-lock
@defun proof-grab-lock &optional queuemode
Grab the proof shell lock, starting the proof assistant if need be.@*
Runs @samp{@code{proof-state-change-hook}} to notify state change.
If @var{queuemode} is supplied, set the lock to that value.
@end defun
@c TEXI DOCSTRING MAGIC: proof-release-lock
@defun proof-release-lock
Release the proof shell lock. Clear @samp{@code{proof-shell-busy}}.
@end defun
@c
@c OUTPUT
@c
@subsection Output from the shell
Two main functions deal with output, @code{proof-shell-classify-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
internal variable @code{proof-shell-urgent-message-marker} tracks the
last urgent message seen.
When output is grabbed from the prover process, the first action
is to strip spurious carriage return characters from the end of
lines, if @code{proof-shell-strip-crs-from-output} requires it.
Then the output is stored into
@code{proof-shell-last-output}, and its type is stored in
@code{proof-shell-last-output-kind}. Output which is deferred or
possibly discarded until the queue is empty is copied into
@code{proof-shell-delayed-output}, with type
@code{proof-shell-delayed-output-kind}. A record of the last prompt
seen from the prover process is also kept, in
@code{proof-shell-last-prompt}.
@c TEXI DOCSTRING MAGIC: proof-shell-strip-crs-from-output
@defvar proof-shell-strip-crs-from-output
If non-nil, remove carriage returns (^M) at the end of lines from output.@*
This is enabled for cygwin32 systems by default. You should turn it off
if you don't need it (slight speed penalty).
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-last-prompt
@defvar proof-shell-last-prompt
A raw record of the last prompt seen from the proof system.@*
This is the string matched by @samp{@code{proof-shell-annotated-prompt-regexp}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-last-output
@defvar proof-shell-last-output
A record of the last string seen from the proof system.@*
This is raw string, for internal use only.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-last-output-kind
@defvar proof-shell-last-output-kind
A symbol denoting the type of the last output string from the proof system.@*
Specifically:
@lisp
@code{'interrupt} An interrupt message
@code{'error} An error message
@code{'loopback} A command sent from the PA to be inserted into the script
@code{'response} A response message
@code{'goals} A goals (proof state) display
@code{'systemspecific} Something specific to a particular system,
-- see @samp{@code{proof-shell-handle-output-system-specific}}
@end lisp
The output corresponding to this will be in @samp{@code{proof-shell-last-output}}.
See also @samp{@code{proof-shell-proof-completed}} for further information about
the proof process output, when ends of proofs are spotted.
This variable can be used for instance specific functions which want
to examine @samp{@code{proof-shell-last-output}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-last-output-kind
@defvar proof-shell-last-output-kind
A symbol denoting the type of the last output string from the proof system.@*
Specifically:
@lisp
@code{'interrupt} An interrupt message
@code{'error} An error message
@code{'loopback} A command sent from the PA to be inserted into the script
@code{'response} A response message
@code{'goals} A goals (proof state) display
@code{'systemspecific} Something specific to a particular system,
-- see @samp{@code{proof-shell-handle-output-system-specific}}
@end lisp
The output corresponding to this will be in @samp{@code{proof-shell-last-output}}.
See also @samp{@code{proof-shell-proof-completed}} for further information about
the proof process output, when ends of proofs are spotted.
This variable can be used for instance specific functions which want
to examine @samp{@code{proof-shell-last-output}}.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-delayed-output-start
@defvar proof-shell-delayed-output-start
A record of the start of the previous output in the shell buffer.@*
The previous output is held back for processing at end of queue.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-delayed-output-end
@defvar proof-shell-delayed-output-end
A record of the start of the previous output in the shell buffer.@*
The previous output is held back for processing at end of queue.
@end defvar
@c TEXI DOCSTRING MAGIC: proof-shell-delayed-output-flags
@defvar proof-shell-delayed-output-flags
A copy of the @samp{@code{proof-action-list}} flags for @samp{proof-shell-delayed-output}.
@end defvar
@vindex proof-action-list
@c TEXI DOCSTRING MAGIC: proof-shell-handle-immediate-output
@defun proof-shell-handle-immediate-output cmd start end flags
See if the output between @var{start} and @var{end} must be dealt with immediately.@*
To speed up processing, PG tries to avoid displaying output that
the user will not have a chance to see. Some output must be
handled immediately, however: these are errors, interrupts,
goals and loopbacks (proof step hints/proof by pointing results).
In this function we check, in turn:
@lisp
@samp{@code{proof-shell-interrupt-regexp}}
@samp{@code{proof-shell-error-regexp}}
@samp{@code{proof-shell-proof-completed-regexp}}
@samp{@code{proof-shell-result-start}}
@end lisp
Other kinds of output are essentially display only, so only
dealt with if necessary.
To extend this, set @samp{@code{proof-shell-handle-output-system-specific}},
which is a hook to take particular additional actions.
This function sets variables: @samp{@code{proof-shell-last-output-kind}},
and the counter @samp{@code{proof-shell-proof-completed}} which counts commands
after a completed proof.
@end defun
@c TEXI DOCSTRING MAGIC: proof-shell-handle-delayed-output
@defun proof-shell-handle-delayed-output
Display delayed goals/responses, when queue is stopped or completed.@*
This function handles the cases of @samp{proof-shell-output-kind} which
are not dealt with eagerly during script processing, namely
@code{'response} and @code{'goals} types.
This is useful even with empty delayed output as it will empty
the buffers.
The delayed output is in the region
[@code{proof-shell-delayed-output-start},@code{proof-shell-delayed-output-end}].
If no goals classified output is found, the whole output is
displayed in the response buffer.
If goals output is found, the last matching instance, possibly
bounded by @samp{@code{proof-shell-end-goals-regexp}}, will be displayed
in the goals buffer (and may be further analysed by Proof General).
Any output that appears @strong{before} the last goals output (but
after messages classified as urgent, see @samp{@code{proof-shell-filter}})
will also be displayed in the response buffer.
For example, if @var{output} has this form:
@lisp
@var{messsage-1}
@var{goals-1}
@var{message-2}
@var{goals-2}
@var{junk}
@end lisp
then @var{goals-2} will be displayed in the goals buffer, and @var{message-2}
in the response buffer. @var{junk} will be ignored.
Notice that the above alternation (and separation of @var{junk}) can
only be distinguished if both @samp{@code{proof-shell-start-goals-regexp}}
and @samp{@code{proof-shell-end-goals-regexp}} are set. With just the start
goals regexp set, @var{goals-2} @var{junk} will appear in the goals buffer
and no response output would occur.
@lisp
@end lisp
The goals and response outputs are copied into
@samp{@code{proof-shell-last-goals-output}} and
@samp{@code{proof-shell-last-response-output}} respectively.
The value returned is the value for @samp{@code{proof-shell-last-output-kind}},
i.e., @code{'goals} or @code{'response}.
@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 start end
Analyse urgent message between @var{start} and @var{end} for various cases.
Cases are: @strong{trace} output, included/retracted files, cleared
goals/response buffer, variable setting, xml-encoded @var{pgip} response,
theorem dependency message or interactive output indicator.
If none of these apply, display the text between @var{start} and @var{end}.
The text between @var{start} and @var{end} should be a string that starts with
text matching @samp{@code{proof-shell-eager-annotation-start}} and
ends with text matching @samp{@code{proof-shell-eager-annotation-end}}.
@end defun
The main processing point which triggers other actions is
@code{proof-shell-filter}. It is called from
@code{proof-shell-filter-wrapper}, which itself is called from an
ordinary Emacs process filter inside the simplified @code{comint}
library that is distributed with Proof General (in
@code{lib/scomint.el}).
@c TEXI DOCSTRING MAGIC: proof-shell-filter
@defun proof-shell-filter
Master filter for the proof assistant shell-process.@*
A function for @samp{@code{scomint-output-filter-functions}}.
Deal with output and issue new input from the queue. This is an
important internal function. The output must be collected from
@samp{@code{proof-shell-buffer}} for the following reason. This function
might block inside @samp{@code{process-send-string}} when sending input to
the proof assistant or to prooftree. In this case Emacs might
call the process filter again while the previous instance is
still running. @samp{@code{proof-shell-filter-wrapper}} detects and delays
such calls but does not buffer the output.
Handle urgent messages first. As many as possible are processed,
using the function @samp{@code{proof-shell-process-urgent-messages}}.
If a prompt is seen, run @samp{@code{proof-shell-filter-manage-output}} on the
output between the new prompt and the last input (position of
@samp{@code{proof-marker}}) or the last urgent message (position of
@samp{@code{proof-shell-urgent-message-marker}}), whichever is later. For
example, in this case:
@lisp
PROMPT> @var{input}
@var{output-1}
@var{urgent-message-1}
@var{output-2}
@var{urgent-message-2}
@var{output-3}
PROMPT>
@end lisp
@samp{@code{proof-marker}} points after @var{input}.
@samp{@code{proof-shell-urgent-message-marker}} points after @var{urgent-message-2},
after both urgent messages have been processed by
@samp{@code{proof-shell-process-urgent-messages}}. Urgent messages always
processed; they are intended to correspond to informational
notes that the prover makes to inform the user or interface on
progress.
In this case, the ordinary outputs @var{output-1} and @var{output-2} are
ignored; only @var{output-3} will be processed by
@samp{@code{proof-shell-filter-manage-output}}.
Error or interrupt messages are expected to terminate an
interactive output and appear last before a prompt and will
always be processed. Error messages and interrupt messages are
therefore @strong{not} considered as urgent messages.
The first time that a prompt is seen, @samp{@code{proof-marker}} is
initialised to the end of the prompt. This should correspond
with initializing the process. After that, @samp{@code{proof-marker}}
is only changed when input is sent in @samp{@code{proof-shell-insert}}.
@end defun
@c TEXI DOCSTRING MAGIC: proof-shell-filter-manage-output
@defun proof-shell-filter-manage-output start end
Subroutine of @samp{@code{proof-shell-filter}} for output between @var{start} and @var{end}.
First, we invoke @samp{@code{proof-shell-handle-immediate-output}} which classifies
and handles output that must be dealt with immediately.
Other output (user display) is only displayed when the proof
action list becomes empty, to avoid a confusing rapidly changing
output that slows down processing.
After processing the current output, the last step undertaken
by the filter is to send the next command from the queue.
@end defun
@c TEXI DOCSTRING MAGIC: proof-shell-filter-wrapper
@defun proof-shell-filter-wrapper str-do-not-use
Wrapper for @samp{@code{proof-shell-filter}}, protecting against parallel calls.@*
In Emacs a process filter function can be called while the same
filter is currently running for the same process, for instance,
when the filter bocks on I/O. This wrapper protects the main
entry point, @samp{@code{proof-shell-filter}} against such parallel,
overlapping calls.
The argument @var{str-do-not-use} contains the most recent output, but
is discarded. @samp{@code{proof-shell-filter}} collects the output from
@samp{@code{proof-shell-buffer}} (where it is inserted by
@samp{@code{scomint-output-filter}}), relieving this function from the task
to buffer the output that arrives during parallel, overlapping
calls.
@end defun
@c
@c SECTION: Debugging
@c
@node Debugging
@section Debugging
@cindex debugging
@c FIXME: better to have general hints on Elisp earlier, plus some
@c links to helpful docs.
To debug Proof General, it may be helpful to set the
configuration variable @code{proof-general-debug}.
@c TEXI DOCSTRING MAGIC: proof-general-debug
@defopt proof-general-debug
Non-nil to run Proof General in debug mode.@*
This changes some behaviour (e.g. markup stripping) and displays
debugging messages in the response buffer. To avoid erasing
messages shortly after they're printed, set @samp{@code{proof-tidy-response}} to nil.
This is only useful for PG developers.
The default value is @code{nil}.
@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: Plans and Ideas
@c
@c
@node Plans and Ideas
@appendix Plans and Ideas
This appendix contains some tentative plans and ideas for improving
Proof General.
This appendix is no longer extended: instead we keep a list of Proof
General projects on the web, and forthcoming plans and ideas in the
@file{TODO} and @file{todo} files included in the ordinary and
developers PG distributions, respectively. Once the items mentioned
below are implemented, they will be removed from here.
Please send us contributions to our wish lists, or better still, an
offer to implement something from them!
@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.
Proof General already supports proof by pointing, and experimental
support is provided in LEGO. We would like to extend this support to
other proof assistants. Unfortunately, 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 is usually specific to a
particular logic in use, if we hope to generate a good 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.
Implementors of new proof assistants should be encouraged to consider
supporting term-structure mark up from the start. Command generation
should be something that the logic-implementor can specify in some way.
Of the supported provers, we can certainly hope for proof-by-pointing
support from Coq, since the CtCoq proof-by-pointing code has been moved
into the Coq kernel lately. I hope the Coq community can encourage
somebody to do this.
@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 (see @i{Goal-save
sequences} in the user manual), particularly to make retraction more flexible.
The blue 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 (see @i{Goal-save sequences} in
the user manual), 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.
@c
@c
@c APPENDIX: Demonstration instantiation for Isabelle
@c
@c
@node Demonstration Instantiations
@appendix Demonstration Instantiations
This appendix contains the code for the two demonstration
instantiations of Proof General, for Isabelle.
These instantiations make an almost-bare minimum of settings to get
things working. To add embellishments, you should refer to
the instantiations for other systems distributed with
Proof General.
@menu
* demoisa-easy.el::
* demoisa.el::
@end menu
@node demoisa-easy.el
@section demoisa-easy.el
@lisp
@c FIXME: MAGIC NEEDED TO INCLUDE FILE VERBATIM
@c @includeverbatim ../demoisa/demoisa-easy.el
;; demoisa-easy.el Example Proof General instance for Isabelle
;;
;; Copyright (C) 1999 LFCS Edinburgh.
;;
;; Author: David Aspinall <David.Aspinall@@ed.ac.uk>
;;
;; $Id$
;;
;; This is an alternative version of demoisa.el which uses the
;; proof-easy-config macro to do the work of declaring derived modes,
;; etc.
;;
;; See demoisa.el and the Proof General manual for more documentation.
;;
;; To test this file you must rename it demoisa.el.
;;
(require 'proof-easy-config) ; easy configure mechanism
(proof-easy-config
'demoisa "Isabelle Demo"
proof-prog-name "isabelle"
proof-terminal-string ";"
proof-script-comment-start "(*"
proof-script-comment-end "*)"
proof-goal-command-regexp "^Goal"
proof-save-command-regexp "^qed"
proof-goal-with-hole-regexp "qed_goal \"\\(\\(.*\\)\\)\""
proof-save-with-hole-regexp "qed \"\\(\\(.*\\)\\)\""
proof-non-undoables-regexp "undo\\|back"
proof-goal-command "Goal \"%s\";"
proof-save-command "qed \"%s\";"
proof-kill-goal-command "Goal \"PROP no_goal_set\";"
proof-showproof-command "pr()"
proof-undo-n-times-cmd "pg_repeat undo %s;"
proof-auto-multiple-files t
proof-shell-cd-cmd "cd \"%s\""
proof-shell-interrupt-regexp "Interrupt"
proof-shell-start-goals-regexp "Level [0-9]"
proof-shell-end-goals-regexp "val it"
proof-shell-quit-cmd "quit();"
proof-assistant-home-page
"http://www.cl.cam.ac.uk/Research/HVG/Isabelle/"
proof-shell-annotated-prompt-regexp
"^\\(val it = () : unit\n\\)?ML>? "
proof-shell-error-regexp
"\\*\\*\\*\\|^.*Error:\\|^uncaught exception \\|^Exception- "
proof-shell-init-cmd
"fun pg_repeat f 0 = () | pg_repeat f n = (f(); pg_repeat f (n-1));"
proof-shell-proof-completed-regexp "^No subgoals!"
proof-shell-eager-annotation-start
"^\\[opening \\|^###\\|^Reading")
(provide 'demoisa)
@end lisp
@node demoisa.el
@section demoisa.el
@lisp
@c FIXME: MAGIC NEEDED TO INCLUDE FILE VERBATIM
@c @includeverbatim ../demoisa/demoisa.el
;; demoisa.el Example Proof General instance for Isabelle
;;
;; Copyright (C) 1999 LFCS Edinburgh.
;;
;; Author: David Aspinall <David.Aspinall@@ed.ac.uk>
;;
;; $Id$
;;
;; =================================================================
;;
;; See README in this directory for an introduction.
;;
;; Basic configuration is controlled by one line in `proof-site.el'.
;; It has this line in proof-assistant-table:
;;
;; (demoisa "Isabelle Demo" "\\.ML$")
;;
;; From this it loads this file "demoisa/demoisa.el" whenever
;; a .ML file is visited, and sets the mode to `demoisa-mode'
;; (defined below).
;;
;; I've called this instance "Isabelle Demo Proof General" just to
;; avoid confusion with the real "Isabelle Proof General" in case the
;; demo gets loaded by accident.
;;
;; To make the line above take precedence over the real Isabelle mode
;; later in the table, set PROOFGENERAL_ASSISTANTS=demoisa in the
;; shell before starting Emacs (or customize proof-assistants).
;;
(require 'proof) ; load generic parts
;; ======== User settings for Isabelle ========
;;
;; Defining variables using customize is pretty easy.
;; You should do it at least for your prover-specific user options.
;;
;; proof-site provides us with two customization groups
;; automatically: (based on the name of the assistant)
;;
;; 'isabelledemo - User options for Isabelle Demo Proof General
;; 'isabelledemo-config - Configuration of Isabelle Proof General
;; (constants, but may be nice to tweak)
;;
;; The first group appears in the menu
;; ProofGeneral -> Advanced -> Customize -> Isabelledemo
;; The second group appears in the menu:
;; ProofGeneral -> Internals -> Isabelledemo config
;;
(defcustom isabelledemo-prog-name "isabelle"
"*Name of program to run Isabelle."
:type 'file
:group 'isabelledemo)
(defcustom isabelledemo-web-page
"http://www.cl.cam.ac.uk/Research/HVG/isabelle.html"
"URL of web page for Isabelle."
:type 'string
:group 'isabelledemo-config)
;;
;; ======== Configuration of generic modes ========
;;
(defun demoisa-config ()
"Configure Proof General scripting for Isabelle."
(setq
proof-terminal-string ";"
proof-script-comment-start "(*"
proof-script-comment-end "*)"
proof-goal-command-regexp "^Goal"
proof-save-command-regexp "^qed"
proof-goal-with-hole-regexp "qed_goal \"\\(\\(.*\\)\\)\""
proof-save-with-hole-regexp "qed \"\\(\\(.*\\)\\)\""
proof-non-undoables-regexp "undo\\|back"
proof-undo-n-times-cmd "pg_repeat undo %s;"
proof-showproof-command "pr()"
proof-goal-command "Goal \"%s\";"
proof-save-command "qed \"%s\";"
proof-kill-goal-command "Goal \"PROP no_goal_set\";"
proof-assistant-home-page isabelledemo-web-page
proof-auto-multiple-files t))
(defun demoisa-shell-config ()
"Configure Proof General shell for Isabelle."
(setq
proof-shell-annotated-prompt-regexp "^\\(val it = () : unit\n\\)?ML>? "
proof-shell-cd-cmd "cd \"%s\""
proof-shell-interrupt-regexp "Interrupt"
proof-shell-error-regexp "\\*\\*\\*\\|^.*Error:\\|^uncaught exception \\|^Exception- "
proof-shell-start-goals-regexp "Level [0-9]"
proof-shell-end-goals-regexp "val it"
proof-shell-proof-completed-regexp "^No subgoals!"
proof-shell-eager-annotation-start "^\\[opening \\|^###\\|^Reading"
proof-shell-init-cmd ; define a utility function, in a lib somewhere?
"fun pg_repeat f 0 = ()
| pg_repeat f n = (f(); pg_repeat f (n-1));"
proof-shell-quit-cmd "quit();"))
;;
;; ======== Defining the derived modes ========
;;
;; The name of the script mode is always <proofsym>-script,
;; but the others can be whatever you like.
;;
;; The derived modes set the variables, then call the
;; <mode>-config-done function to complete configuration.
(define-derived-mode demoisa-mode proof-mode
"Isabelle Demo script" nil
(demoisa-config)
(proof-config-done))
(define-derived-mode demoisa-shell-mode proof-shell-mode
"Isabelle Demo shell" nil
(demoisa-shell-config)
(proof-shell-config-done))
(define-derived-mode demoisa-response-mode proof-response-mode
"Isabelle Demo response" nil
(proof-response-config-done))
(define-derived-mode demoisa-goals-mode proof-goals-mode
"Isabelle Demo goals" nil
(proof-goals-config-done))
;; The response buffer and goals buffer modes defined above are
;; trivial. In fact, we don't need to define them at all -- they
;; would simply default to "proof-response-mode" and "pg-goals-mode".
;; A more sophisticated instantiation might set font-lock-keywords to
;; add highlighting, or some of the proof by pointing markup
;; configuration for the goals buffer.
(provide 'demoisa)
@end lisp
@node Function Index
@unnumbered Function and Command Index
@printindex fn
@node Variable Index
@unnumbered Variable and User Option Index
@printindex vr
@c Nothing in this one!
@c @node Keystroke Index
@c @unnumbered Keystroke Index
@c @printindex ky
@node Concept Index
@unnumbered Concept Index
@printindex cp
@page
@contents
@bye
|