forked from ProofGeneral/PG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPG-adapting.texi
4843 lines (3919 loc) · 193 KB
/
PG-adapting.texi
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
\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.6-git
@set emacsversion 25.2
@set last-update July 2022
@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), version 3 or later;
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, EasyCrypt, qrhl-tool, and PhoX.
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, @pxref{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
@defvar 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}}.
@end defvar
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::
* Omitting proofs for speed::
* 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}, (@pxref{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 (@pxref{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