; isar.el Major mode for Isabelle/Isar proof assistant ;; Copyright (C) 1994-2004 LFCS Edinburgh. ;; ;; License: GPL (GNU GENERAL PUBLIC LICENSE) ;; ;; Maintainers: David Aspinall, Stefan Berghofer ;; ;; Authors: David Aspinall ;; Markus Wenzel ;; ;; Contributors: David von Oheimb, Sebastian Skalberg ;; ;; ;; $Id$ ;; (require 'proof) ;; System code (require 'isabelle-system) ;; "Find Theorems" search form (require 'isar-find-theorems) ;; ;; Load syntax ;; (defcustom isar-keywords-name nil "Specifies a theory-specific keywords setting to use with Isar. See -k option for Isabelle interface script." :type 'string :group 'isabelle-isar) (or (featurep 'isar-keywords) ;; Pickup isar-keywords file from somewhere appropriate, ;; giving user chance to set name of file, or based on ;; name of logic. (isabelle-load-isar-keywords (or isar-keywords-name isabelle-chosen-logic))) (require 'isar-syntax) ;; Completion table for Isabelle/Isar identifiers (defpgdefault completion-table isar-keywords-major) (defcustom isar-web-page "http://isabelle.in.tum.de/Isar/" "URL of web page for Isabelle/Isar." :type 'string :group 'isabelle-isar) ;; Adjust toolbar entries (must be done before proof-toolbar is loaded). (if proof-running-on-XEmacs (setq isar-toolbar-entries (remassoc 'qed (remassoc 'goal isar-toolbar-entries)))) (defun isar-strip-terminators () "Remove explicit Isabelle/Isar command terminators `;' from the buffer." (interactive) (save-excursion (goto-char (point-min)) (while (proof-search-forward ";" (point-max) t) (if (not (proof-buffer-syntactic-context)) (progn (delete-backward-char 1) (or (proof-looking-at ";\\|\\s-\\|$") (insert " "))))))) (defun isar-markup-ml (string) "Return marked up version of ML command STRING for Isar." (format "ML_command {* %s *};" string)) (defun isar-mode-config-set-variables () "Configure generic proof scripting mode variables for Isabelle/Isar." (setq proof-assistant-home-page isar-web-page proof-mode-for-script 'isar-mode ;; proof script syntax proof-terminal-char ?\; ; forcibly ends a command proof-script-command-start-regexp (proof-regexp-alt ;; FIXME: this gets { and } wrong: they must _not_ appear as {* *} ;; because that's lexically a kind of comment. isar-any-command-regexp (regexp-quote ";")) proof-script-integral-proofs t ;; FIXME: use old parser for now to avoid { } problem proof-script-use-old-parser t proof-script-comment-start isar-comment-start proof-script-comment-end isar-comment-end proof-script-comment-start-regexp isar-comment-start-regexp proof-script-comment-end-regexp isar-comment-end-regexp proof-string-start-regexp isar-string-start-regexp proof-string-end-regexp isar-string-end-regexp ;; Next few used for func-menu and recognizing goal..save regions in ;; script buffer. proof-save-command-regexp isar-save-command-regexp proof-goal-command-regexp isar-goal-command-regexp proof-goal-with-hole-regexp isar-named-entity-regexp proof-goal-with-hole-result 2 proof-save-with-hole-regexp nil proof-script-next-entity-regexps isar-next-entity-regexps proof-script-imenu-generic-expression isar-generic-expression imenu-syntax-alist isar-script-syntax-table-alist proof-indent-enclose-offset (- proof-indent) proof-indent-open-offset 0 proof-indent-close-offset 0 proof-indent-any-regexp isar-indent-any-regexp ; proof-indent-inner-regexp isar-indent-inner-regexp proof-indent-enclose-regexp isar-indent-enclose-regexp proof-indent-open-regexp isar-indent-open-regexp proof-indent-close-regexp isar-indent-close-regexp ;; proof engine commands proof-showproof-command "pr" proof-goal-command "lemma \"%s\"" proof-save-command "qed" proof-context-command "print_context" proof-info-command "welcome" proof-kill-goal-command "ProofGeneral.kill_proof" ; proof-find-theorems-command "find_theorems %s" ;; minibuffer proof-find-theorems-command 'isar-find-theorems-minibuffer ;; equivalent ; proof-find-theorems-command 'isar-find-theorems-form ;; search form proof-shell-start-silent-cmd "disable_pr" proof-shell-stop-silent-cmd "enable_pr" ;; command hooks proof-goal-command-p 'isar-goal-command-p proof-really-save-command-p 'isar-global-save-command-p proof-count-undos-fn 'isar-count-undos proof-find-and-forget-fn 'isar-find-and-forget proof-state-preserving-p 'isar-state-preserving-p proof-shell-compute-new-files-list 'isar-shell-compute-new-files-list ;; span menu proof-script-span-context-menu-extensions 'isabelle-create-span-menu)) (defun isar-shell-mode-config-set-variables () "Configure generic proof shell mode variables for Isabelle/Isar." (setq pg-topterm-regexp "\376\\|\^AW" pg-topterm-goalhyplit-fn 'isar-goalhyplit-test proof-shell-wakeup-char nil proof-shell-annotated-prompt-regexp "^\\w*[>#] \372\\|^\\w*[>#] \^AS" ;; This pattern is just for comint. proof-shell-prompt-pattern "^\\w*[>#] " ;; for issuing command, not used to track cwd in any way. proof-shell-cd-cmd (isar-markup-ml "ThyLoad.add_path \"%s\"") ;; Escapes for filenames inside ML strings. ;; We also make a hack for a bug in Isabelle, by switching from ;; backslashes to forward slashes if it looks like we're running ;; on Windows. proof-shell-filename-escapes (if (fboundp 'win32-long-filename) ; rough test for XEmacs on win32 ;; Patterns to unixfy names. ;; Jacques Fleuriot's patch in ML does this too: ("^[a-zA-Z]:" . "") ;; But I'll risk leaving drive names in, not sure how to replace them. '(("\\\\" . "/") ("\"" . "\\\"")) ;; Normal case: quotation for backslash, quote mark. '(("\\\\" . "\\\\") ("\"" . "\\\""))) proof-shell-proof-completed-regexp nil ; n.a. proof-shell-interrupt-regexp "\364\\*\\*\\* Interrupt\\|\^AM\\*\\*\\* Interrupt" proof-shell-error-regexp "\364\\*\\*\\*\\|\^AM\\*\\*\\*" proof-shell-abort-goal-regexp nil ; n.a. pg-next-error-regexp "\\((line \\([0-9]+\\) of \"[^\"]+\")\\)" pg-next-error-filename-regexp "\\((line [0-9]+ of \"\\([^\"]+\\)\")\\)" ;; matches names of assumptions proof-shell-assumption-regexp isar-id proof-shell-start-goals-regexp "\366\n\\|\^AO\n" proof-shell-end-goals-regexp "\367\\|\^AP" proof-shell-init-cmd nil proof-shell-restart-cmd "ProofGeneral.restart" proof-shell-eager-annotation-start-length 1 proof-shell-eager-annotation-start "\360\\|\362\\|\^AI\\|\^AK" proof-shell-eager-annotation-end "\361\\|\363\\|\^AJ\\|\^AL" ;; see isar-pre-shell-start for proof-shell-trace-output-regexp ;; Isabelle is learning to talk PGIP... proof-shell-match-pgip-cmd "