368 \item [$\isarkeyword{ML_setup}~text$] executes ML commands from $text$. The |
368 \item [$\isarkeyword{ML_setup}~text$] executes ML commands from $text$. The |
369 theory context is passed down to the ML session, and fetched back |
369 theory context is passed down to the ML session, and fetched back |
370 afterwards. Thus $text$ may actually change the theory as a side effect. |
370 afterwards. Thus $text$ may actually change the theory as a side effect. |
371 |
371 |
372 \item [$\isarkeyword{setup}~text$] changes the current theory context by |
372 \item [$\isarkeyword{setup}~text$] changes the current theory context by |
373 applying $text$, which refers to an ML expression of type $(theory \to |
373 applying $text$, which refers to an ML expression of type |
374 theory)~list$. The $\isarkeyword{setup}$ command is the canonical way to |
374 \texttt{(theory~->~theory)~list}. The $\isarkeyword{setup}$ command is the |
375 initialize object-logic specific tools and packages written in ML. |
375 canonical way to initialize object-logic specific tools and packages written |
|
376 in ML. |
376 \end{descr} |
377 \end{descr} |
377 |
378 |
378 |
379 |
379 \subsection{Syntax translation functions} |
380 \subsection{Syntax translation functions} |
380 |
381 |
391 \end{matharray} |
392 \end{matharray} |
392 |
393 |
393 Syntax translation functions written in ML admit almost arbitrary |
394 Syntax translation functions written in ML admit almost arbitrary |
394 manipulations of Isabelle's inner syntax. Any of the above commands have a |
395 manipulations of Isabelle's inner syntax. Any of the above commands have a |
395 single \railqtoken{text} argument that refers to an ML expression of |
396 single \railqtoken{text} argument that refers to an ML expression of |
396 appropriate type. See \cite[\S8]{isabelle-ref} for more information on syntax |
397 appropriate type. |
397 transformations. |
398 |
|
399 \begin{ttbox} |
|
400 val parse_ast_translation : (string * (ast list -> ast)) list |
|
401 val parse_translation : (string * (term list -> term)) list |
|
402 val print_translation : (string * (term list -> term)) list |
|
403 val typed_print_translation : |
|
404 (string * (bool -> typ -> term list -> term)) list |
|
405 val print_ast_translation : (string * (ast list -> ast)) list |
|
406 val token_translation : |
|
407 (string * string * (string -> string * real)) list |
|
408 \end{ttbox} |
|
409 See \cite[\S8]{isabelle-ref} for more information on syntax transformations. |
398 |
410 |
399 |
411 |
400 \subsection{Oracles} |
412 \subsection{Oracles} |
401 |
413 |
402 \indexisarcmd{oracle} |
414 \indexisarcmd{oracle} |
467 |
479 |
468 |
480 |
469 \subsection{Proof context}\label{sec:proof-context} |
481 \subsection{Proof context}\label{sec:proof-context} |
470 |
482 |
471 \indexisarcmd{fix}\indexisarcmd{assume}\indexisarcmd{presume}\indexisarcmd{def} |
483 \indexisarcmd{fix}\indexisarcmd{assume}\indexisarcmd{presume}\indexisarcmd{def} |
|
484 \indexisarcmd{case} |
472 \begin{matharray}{rcl} |
485 \begin{matharray}{rcl} |
473 \isarcmd{fix} & : & \isartrans{proof(state)}{proof(state)} \\ |
486 \isarcmd{fix} & : & \isartrans{proof(state)}{proof(state)} \\ |
474 \isarcmd{assume} & : & \isartrans{proof(state)}{proof(state)} \\ |
487 \isarcmd{assume} & : & \isartrans{proof(state)}{proof(state)} \\ |
475 \isarcmd{presume} & : & \isartrans{proof(state)}{proof(state)} \\ |
488 \isarcmd{presume} & : & \isartrans{proof(state)}{proof(state)} \\ |
476 \isarcmd{def} & : & \isartrans{proof(state)}{proof(state)} \\ |
489 \isarcmd{def} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
490 \isarcmd{case} & : & \isartrans{proof(state)}{proof(state)} \\ |
477 \end{matharray} |
491 \end{matharray} |
478 |
492 |
479 The logical proof context consists of fixed variables and assumptions. The |
493 The logical proof context consists of fixed variables and assumptions. The |
480 former closely correspond to Skolem constants, or meta-level universal |
494 former closely correspond to Skolem constants, or meta-level universal |
481 quantification as provided by the Isabelle/Pure logical framework. |
495 quantification as provided by the Isabelle/Pure logical framework. |
499 Local definitions, introduced by $\DEF{}{x \equiv t}$, are achieved by |
513 Local definitions, introduced by $\DEF{}{x \equiv t}$, are achieved by |
500 combining $\FIX x$ with another version of assumption that causes any |
514 combining $\FIX x$ with another version of assumption that causes any |
501 hypothetical equation $x \equiv t$ to be eliminated by the reflexivity rule. |
515 hypothetical equation $x \equiv t$ to be eliminated by the reflexivity rule. |
502 Thus, exporting some result $x \equiv t \drv \phi[x]$ yields $\edrv \phi[t]$. |
516 Thus, exporting some result $x \equiv t \drv \phi[x]$ yields $\edrv \phi[t]$. |
503 |
517 |
|
518 \medskip Basically, Isar proof contexts have to be built up explicitly using |
|
519 any of the above commands. In typical verification tasks this can become hard |
|
520 to manage, though, with a large number of local contexts emerging from case |
|
521 analysis or induction, for example. The $\CASENAME$ command provides a |
|
522 shorthand to refer to certain parts of logical context symbolically. Proof |
|
523 methods may provide an environment of named ``cases'' of the form $c\colon |
|
524 \vec x, \vec \chi$. Then the effect of $\CASE{c}$ is exactly the same as |
|
525 $\FIX{\vec x}~\ASSUME{c}{\vec\chi}$. |
|
526 |
|
527 It is important to note that $\CASENAME$ does \emph{not} provide means to peek |
|
528 at the current goal state, which is considered strictly non-observable in |
|
529 Isar. Instead, the cases considered here typically emerge in a canonical way |
|
530 from certain pieces of specification that appears in the theory somewhere, |
|
531 such as an inductive definition, or recursive function. See \S\ref{sec:FIXME} |
|
532 for more details of how this works in HOL. |
|
533 |
504 \begin{rail} |
534 \begin{rail} |
505 'fix' (vars + 'and') comment? |
535 'fix' (vars + 'and') comment? |
506 ; |
536 ; |
507 ('assume' | 'presume') (assm comment? + 'and') |
537 ('assume' | 'presume') (assm comment? + 'and') |
508 ; |
538 ; |
509 'def' thmdecl? \\ var '==' term termpat? comment? |
539 'def' thmdecl? \\ var '==' term termpat? comment? |
|
540 ; |
|
541 'case' name |
510 ; |
542 ; |
511 |
543 |
512 var: name ('::' type)? |
544 var: name ('::' type)? |
513 ; |
545 ; |
514 vars: (name+) ('::' type)? |
546 vars: (name+) ('::' type)? |
532 In results exported from the context, $x$ is replaced by $t$. Basically, |
564 In results exported from the context, $x$ is replaced by $t$. Basically, |
533 $\DEF{}{x \equiv t}$ abbreviates $\FIX{x}~\ASSUME{}{x \equiv t}$, with the |
565 $\DEF{}{x \equiv t}$ abbreviates $\FIX{x}~\ASSUME{}{x \equiv t}$, with the |
534 resulting hypothetical equation solved by reflexivity. |
566 resulting hypothetical equation solved by reflexivity. |
535 |
567 |
536 The default name for the definitional equation is $x_def$. |
568 The default name for the definitional equation is $x_def$. |
|
569 \item [$\CASE{c}$] invokes local context $c\colon \vec x, \vec \chi$, as |
|
570 provided by an appropriate proof method. This abbreviates $\FIX{\vec |
|
571 x}~\ASSUME{c}{\vec\chi}$. |
537 \end{descr} |
572 \end{descr} |
538 |
573 |
539 The special name $prems$\indexisarthm{prems} refers to all assumptions of the |
574 The special name $prems$\indexisarthm{prems} refers to all assumptions of the |
540 current context as a list of theorems. |
575 current context as a list of theorems. |
541 |
576 |
716 sufficient to see what is going wrong. |
751 sufficient to see what is going wrong. |
717 \item [``$\DDOT$''] is a \emph{default proof}\index{proof!default}; it |
752 \item [``$\DDOT$''] is a \emph{default proof}\index{proof!default}; it |
718 abbreviates $\BY{default}$. |
753 abbreviates $\BY{default}$. |
719 \item [``$\DOT$''] is a \emph{trivial proof}\index{proof!trivial}; it |
754 \item [``$\DOT$''] is a \emph{trivial proof}\index{proof!trivial}; it |
720 abbreviates $\BY{this}$. |
755 abbreviates $\BY{this}$. |
721 \item [$\isarkeyword{sorry}$] is a \emph{fake proof}\index{proof!fake}; |
756 \item [$\SORRY$] is a \emph{fake proof}\index{proof!fake}; provided that the |
722 provided that the \texttt{quick_and_dirty} flag is enabled, |
757 \texttt{quick_and_dirty} flag is enabled, $\SORRY$ pretends to solve the |
723 $\isarkeyword{sorry}$ pretends to solve the goal without further ado. Of |
758 goal without further ado. Of course, the result is a fake theorem only, |
724 course, the result is a fake theorem only, involving some oracle in its |
759 involving some oracle in its internal derivation object (this is indicated |
725 internal derivation object (this is indicated as ``$[!]$'' in the printed |
760 as ``$[!]$'' in the printed result). The main application of $\SORRY$ is to |
726 result). The main application of $\isarkeyword{sorry}$ is to support |
761 support experimentation and top-down proof development. |
727 experimentation and top-down proof development. |
|
728 \end{descr} |
|
729 |
|
730 |
|
731 \subsection{Improper proof steps} |
|
732 |
|
733 The following commands emulate unstructured tactic scripts to some extent. |
|
734 While these are anathema for writing proper Isar proof documents, they might |
|
735 come in handy for interactive exploration and debugging. |
|
736 |
|
737 \indexisarcmd{apply}\indexisarcmd{then-apply}\indexisarcmd{back} |
|
738 \begin{matharray}{rcl} |
|
739 \isarcmd{apply}^* & : & \isartrans{proof(prove)}{proof(prove)} \\ |
|
740 \isarcmd{then_apply}^* & : & \isartrans{proof(prove)}{proof(prove)} \\ |
|
741 \isarcmd{back}^* & : & \isartrans{proof}{proof} \\ |
|
742 \end{matharray} |
|
743 |
|
744 \railalias{thenapply}{then\_apply} |
|
745 \railterm{thenapply} |
|
746 |
|
747 \begin{rail} |
|
748 'apply' method |
|
749 ; |
|
750 thenapply method |
|
751 ; |
|
752 'back' |
|
753 ; |
|
754 \end{rail} |
|
755 |
|
756 \begin{descr} |
|
757 \item [$\isarkeyword{apply}~(m)$] applies proof method $m$ in the plain old |
|
758 tactic sense. Facts for forward chaining are reset. |
|
759 \item [$\isarkeyword{then_apply}~(m)$] is similar to $\isarkeyword{apply}$, |
|
760 but keeps the goal's facts. |
|
761 \item [$\isarkeyword{back}$] does back-tracking over the result sequence of |
|
762 the latest proof command.\footnote{Unlike the ML function \texttt{back} |
|
763 \cite{isabelle-ref}, the Isar command does not search upwards for further |
|
764 branch points.} Basically, any proof command may return multiple results. |
|
765 \end{descr} |
762 \end{descr} |
766 |
763 |
767 |
764 |
768 \subsection{Term abbreviations}\label{sec:term-abbrev} |
765 \subsection{Term abbreviations}\label{sec:term-abbrev} |
769 |
766 |
859 \section{Other commands} |
856 \section{Other commands} |
860 |
857 |
861 \subsection{Diagnostics} |
858 \subsection{Diagnostics} |
862 |
859 |
863 \indexisarcmd{thm}\indexisarcmd{term}\indexisarcmd{prop}\indexisarcmd{typ} |
860 \indexisarcmd{thm}\indexisarcmd{term}\indexisarcmd{prop}\indexisarcmd{typ} |
|
861 \indexisarcmd{print-facts}\indexisarcmd{print-binds}\indexisarcmd{print-cases} |
864 \begin{matharray}{rcl} |
862 \begin{matharray}{rcl} |
865 \isarcmd{thm} & : & \isarkeep{theory~|~proof} \\ |
863 \isarcmd{thm} & : & \isarkeep{theory~|~proof} \\ |
866 \isarcmd{term} & : & \isarkeep{theory~|~proof} \\ |
864 \isarcmd{term} & : & \isarkeep{theory~|~proof} \\ |
867 \isarcmd{prop} & : & \isarkeep{theory~|~proof} \\ |
865 \isarcmd{prop} & : & \isarkeep{theory~|~proof} \\ |
868 \isarcmd{typ} & : & \isarkeep{theory~|~proof} \\ |
866 \isarcmd{typ} & : & \isarkeep{theory~|~proof} \\ |
|
867 \isarcmd{print_facts} & : & \isarkeep{proof} \\ |
|
868 \isarcmd{print_binds} & : & \isarkeep{proof} \\ |
|
869 \isarcmd{print_cases} & : & \isarkeep{proof} \\ |
869 \end{matharray} |
870 \end{matharray} |
870 |
871 |
871 These commands are not part of the actual Isabelle/Isar syntax, but assist |
872 These commands are not part of the actual Isabelle/Isar syntax, but assist |
872 interactive development. Also note that $undo$ does not apply here, since the |
873 interactive development. Also note that $undo$ does not apply here, since the |
873 theory or proof configuration is not changed. |
874 theory or proof configuration is not changed. |
894 context; the inferred type of $t$ is output as well. Note that these |
895 context; the inferred type of $t$ is output as well. Note that these |
895 commands are also useful in inspecting the current environment of term |
896 commands are also useful in inspecting the current environment of term |
896 abbreviations. |
897 abbreviations. |
897 \item [$\isarkeyword{typ}~\tau$] reads and prints types of the meta-logic |
898 \item [$\isarkeyword{typ}~\tau$] reads and prints types of the meta-logic |
898 according to the current theory or proof context. |
899 according to the current theory or proof context. |
899 \end{descr} |
900 \item [$\isarkeyword{print_facts}$] prints any named facts of the current |
|
901 context, including assumptions and local results. |
|
902 \item [$\isarkeyword{print_binds}$] prints all term abbreviations present in |
|
903 the context. |
|
904 \item [$\isarkeyword{print_cases}$] prints all local contexts (also known as |
|
905 ``cases'') of the current goal context. |
|
906 \end{descr} |
|
907 |
|
908 |
|
909 \subsection{Meta-linguistic features} |
|
910 |
|
911 \indexisarcmd{oops} |
|
912 \begin{matharray}{rcl} |
|
913 \isarcmd{oops}^* & : & \isartrans{proof}{theory} \\ |
|
914 \end{matharray} |
|
915 |
|
916 The $\OOPS$ command discontinues the current proof attempt, while considering |
|
917 the partial proof text as properly processed. This is conceptually quite |
|
918 different from ``faking'' actual proofs via $\SORRY$ (see |
|
919 \S\ref{sec:proof-steps}): $\OOPS$ does not observe the proof structure at all, |
|
920 but goes back right to the theory level. Furthermore, $\OOPS$ does not |
|
921 produce any result theorem --- there is no claim to be able to complete the |
|
922 proof anyhow. |
|
923 |
|
924 A typical application of $\OOPS$ is to explain Isar proofs \emph{within} the |
|
925 system itself, in conjunction with the document preparation tools of Isabelle |
|
926 described in \cite{isabelle-sys}. Thus partial or even wrong proof attempts |
|
927 can be discussed in a logically sound manner. Note that the Isabelle {\LaTeX} |
|
928 macros can be easily adapted to print something like ``$\dots$'' instead of an |
|
929 ``$\OOPS$'' keyword. |
900 |
930 |
901 |
931 |
902 \subsection{System operations} |
932 \subsection{System operations} |
903 |
933 |
904 \indexisarcmd{cd}\indexisarcmd{pwd}\indexisarcmd{use-thy}\indexisarcmd{use-thy-only} |
934 \indexisarcmd{cd}\indexisarcmd{pwd}\indexisarcmd{use-thy}\indexisarcmd{use-thy-only} |
926 \end{descr} |
956 \end{descr} |
927 |
957 |
928 These system commands are scarcely used when working with the Proof~General |
958 These system commands are scarcely used when working with the Proof~General |
929 interface, since loading of theories is done fully transparently. |
959 interface, since loading of theories is done fully transparently. |
930 |
960 |
|
961 |
|
962 \subsection{Emulating tactic scripts} |
|
963 |
|
964 The following elements emulate unstructured tactic scripts to some extent. |
|
965 While these are anathema for writing proper Isar proof documents, they might |
|
966 come in handy for interactive exploration and debugging. |
|
967 |
|
968 \indexisarcmd{apply}\indexisarcmd{apply-end}\indexisarcmd{back}\indexisarmeth{tactic} |
|
969 \begin{matharray}{rcl} |
|
970 \isarcmd{apply} & : & \isartrans{proof(prove)}{proof(prove)} \\ |
|
971 \isarcmd{apply_end}^* & : & \isartrans{proof(state)}{proof(state)} \\ |
|
972 tactic & : & \isarmeth \\ |
|
973 \isarcmd{back}^* & : & \isartrans{proof}{proof} \\ |
|
974 \end{matharray} |
|
975 |
|
976 \railalias{applyend}{apply\_end} |
|
977 \railterm{applyend} |
|
978 |
|
979 \begin{rail} |
|
980 'apply' method |
|
981 ; |
|
982 applyend method |
|
983 ; |
|
984 'tactic' text |
|
985 ; |
|
986 'back' |
|
987 ; |
|
988 \end{rail} |
|
989 |
|
990 \begin{descr} |
|
991 \item [$\isarkeyword{apply}~(m)$] applies proof method $m$ in an initial |
|
992 position, but retains ``$prove$'' mode (unlike $\PROOFNAME$). Thus |
|
993 consecutive method applications may be given just as in tactic scripts. In |
|
994 order to complete the proof properly, any of the actual structured proof |
|
995 commands (e.g.\ ``$\DOT$'') has to be given eventually. |
|
996 |
|
997 Facts are passed to $m$ as indicated by the goal's forward-chain mode. |
|
998 Common use of $\isarkeyword{apply}$ would be in a purely backward manner, |
|
999 though. |
|
1000 \item [$\isarkeyword{apply_end}~(m)$] applies proof method $m$ as if in |
|
1001 terminal position. Basically, this simulates a multi-step tactic script for |
|
1002 $\QEDNAME$, but may be given anywhere within the proof body. |
|
1003 |
|
1004 No facts are passed to $m$. Furthermore, the static context is that of the |
|
1005 enclosing goal (as for actual $\QEDNAME$). Thus the proof method may not |
|
1006 refer to any assumptions introduced in the current body, for example. |
|
1007 \item [$tactic~text$] produces a proof method from any ML text of type |
|
1008 \texttt{tactic}. Apart from the usual ML environment, and the current |
|
1009 implicit theory context, the ML code may refer to the following locally |
|
1010 bound values: |
|
1011 \begin{ttbox} |
|
1012 val ctxt : Proof.context |
|
1013 val facts : thm list |
|
1014 val thm : string -> thm |
|
1015 val thms : string -> thm list |
|
1016 \end{ttbox} |
|
1017 Here \texttt{ctxt} refers to the current proof context, \texttt{facts} |
|
1018 indicates any current facts for forward-chaining, and |
|
1019 \texttt{thm}~/~\texttt{thms} retrieve named facts (including global |
|
1020 theorems) from the context. |
|
1021 \item [$\isarkeyword{back}$] does back-tracking over the result sequence of |
|
1022 the latest proof command.\footnote{Unlike the ML function \texttt{back} |
|
1023 \cite{isabelle-ref}, the Isar command does not search upwards for further |
|
1024 branch points.} Basically, any proof command may return multiple results. |
|
1025 \end{descr} |
|
1026 |
|
1027 |
931 %%% Local Variables: |
1028 %%% Local Variables: |
932 %%% mode: latex |
1029 %%% mode: latex |
933 %%% TeX-master: "isar-ref" |
1030 %%% TeX-master: "isar-ref" |
934 %%% End: |
1031 %%% End: |