388 \begin{isamarkuptext}% |
388 \begin{isamarkuptext}% |
389 If for some reason you want or need to present theorems your |
389 If for some reason you want or need to present theorems your |
390 own way, you can extract the premises and the conclusion explicitly |
390 own way, you can extract the premises and the conclusion explicitly |
391 and combine them as you like: |
391 and combine them as you like: |
392 \begin{itemize} |
392 \begin{itemize} |
393 \item \verb!@!\verb!{thm_style prem1! $thm$\verb!}! |
393 \item \verb!@!\verb!{thm (prem 1)! $thm$\verb!}! |
394 prints premise 1 of $thm$ (and similarly up to \texttt{prem9}). |
394 prints premise 1 of $thm$. |
395 \item \verb!@!\verb!{thm_style concl! $thm$\verb!}! |
395 \item \verb!@!\verb!{thm (concl)! $thm$\verb!}! |
396 prints the conclusion of $thm$. |
396 prints the conclusion of $thm$. |
397 \end{itemize} |
397 \end{itemize} |
398 For example, ``from \isa{Q} and |
398 For example, ``from \isa{Q} and |
399 \isa{P} we conclude \isa{P\ {\isasymand}\ Q}'' |
399 \isa{P} we conclude \isa{P\ {\isasymand}\ Q}'' |
400 is produced by |
400 is produced by |
401 \begin{quote} |
401 \begin{quote} |
402 \verb!from !\verb!@!\verb!{thm_style prem2 conjI}! \verb!and !\verb!@!\verb!{thm_style prem1 conjI}!\\ |
402 \verb!from !\verb!@!\verb!{thm (prem 2) conjI}! \verb!and !\verb!@!\verb!{thm (prem 1) conjI}!\\ |
403 \verb!we conclude !\verb!@!\verb!{thm_style concl conjI}! |
403 \verb!we conclude !\verb!@!\verb!{thm (concl) conjI}! |
404 \end{quote} |
404 \end{quote} |
405 Thus you can rearrange or hide premises and typeset the theorem as you like. |
405 Thus you can rearrange or hide premises and typeset the theorem as you like. |
406 The \verb!thm_style! antiquotation is a general mechanism explained |
406 Styles like !(prem 1)! are a general mechanism explained |
407 in \S\ref{sec:styles}.% |
407 in \S\ref{sec:styles}.% |
408 \end{isamarkuptext}% |
408 \end{isamarkuptext}% |
409 \isamarkuptrue% |
409 \isamarkuptrue% |
410 % |
410 % |
411 \isamarkupsubsection{Patterns% |
411 \isamarkupsubsection{Patterns% |
514 To deal with such cases where it is desirable to dive into the structure |
514 To deal with such cases where it is desirable to dive into the structure |
515 of terms and theorems, Isabelle offers antiquotations featuring |
515 of terms and theorems, Isabelle offers antiquotations featuring |
516 ``styles'': |
516 ``styles'': |
517 |
517 |
518 \begin{quote} |
518 \begin{quote} |
519 \verb!@!\verb!{thm_style stylename thm}!\\ |
519 \verb!@!\verb!{thm (style) thm}!\\ |
520 \verb!@!\verb!{term_style stylename term}! |
520 \verb!@!\verb!{prop (style) thm}!\\ |
|
521 \verb!@!\verb!{term (style) term}! |
521 \end{quote} |
522 \end{quote} |
522 |
523 |
523 A ``style'' is a transformation of propositions. There are predefined |
524 A ``style'' is a transformation of propositions. There are predefined |
524 styles, namely \verb!lhs! and \verb!rhs!, \verb!prem1! up to \verb!prem9!, and \verb!concl!. |
525 styles, namely \verb!lhs! and \verb!rhs!, \verb!prem! with one argument, and \verb!concl!. |
525 For example, |
526 For example, |
526 the output |
527 the output |
527 \begin{center} |
528 \begin{center} |
528 \begin{tabular}{l@ {~~\isa{{\isacharequal}}~~}l} |
529 \begin{tabular}{l@ {~~\isa{{\isacharequal}}~~}l} |
529 \isa{foldl\ f\ a\ {\isacharbrackleft}{\isacharbrackright}} & \isa{a}\\ |
530 \isa{foldl\ f\ a\ {\isacharbrackleft}{\isacharbrackright}} & \isa{a}\\ |
532 \end{center} |
533 \end{center} |
533 is produced by the following code: |
534 is produced by the following code: |
534 \begin{quote} |
535 \begin{quote} |
535 \verb!\begin{center}!\\ |
536 \verb!\begin{center}!\\ |
536 \verb!\begin{tabular}{l@ {~~!\verb!@!\verb!{text "="}~~}l}!\\ |
537 \verb!\begin{tabular}{l@ {~~!\verb!@!\verb!{text "="}~~}l}!\\ |
537 \verb!@!\verb!{thm_style lhs foldl_Nil} & @!\verb!{thm_style rhs foldl_Nil}!\\ |
538 \verb!@!\verb!{thm (lhs) foldl_Nil} & @!\verb!{thm (rhs) foldl_Nil}!\\ |
538 \verb!@!\verb!{thm_style lhs foldl_Cons} & @!\verb!{thm_style rhs foldl_Cons}!\\ |
539 \verb!@!\verb!{thm (lhs) foldl_Cons} & @!\verb!{thm (rhs) foldl_Cons}!\\ |
539 \verb!\end{tabular}!\\ |
540 \verb!\end{tabular}!\\ |
540 \verb!\end{center}! |
541 \verb!\end{center}! |
541 \end{quote} |
542 \end{quote} |
542 Note the space between \verb!@! and \verb!{! in the tabular argument. |
543 Note the space between \verb!@! and \verb!{! in the tabular argument. |
543 It prevents Isabelle from interpreting \verb!@ {~~...~~}! |
544 It prevents Isabelle from interpreting \verb!@ {~~...~~}! |
556 \isa{hd\ {\isacharparenleft}xs\ {\isasymColon}\ {\isacharprime}a\ list{\isacharparenright}{\isasymcdot}tl\ xs\ {\isacharequal}\ xs} |
557 \isa{hd\ {\isacharparenleft}xs\ {\isasymColon}\ {\isacharprime}a\ list{\isacharparenright}{\isasymcdot}tl\ xs\ {\isacharequal}\ xs} |
557 \end{center} |
558 \end{center} |
558 type |
559 type |
559 \begin{quote} |
560 \begin{quote} |
560 \verb!\begin{center}!\\ |
561 \verb!\begin{center}!\\ |
561 \verb!@!\verb!{thm_style [show_types] concl hd_Cons_tl}!\\ |
562 \verb!@!\verb!{thm [show_types] (concl) hd_Cons_tl}!\\ |
562 \verb!\end{center}! |
563 \verb!\end{center}! |
563 \end{quote} |
564 \end{quote} |
564 Beware that any options must be placed \emph{before} |
565 Beware that any options must be placed \emph{before} |
565 the name of the style, as in this example. |
566 the name of the style, as in this example. |
566 |
567 |
567 Further use cases can be found in \S\ref{sec:yourself}. |
568 Further use cases can be found in \S\ref{sec:yourself}. |
568 |
569 |
569 If you are not afraid of ML, you may also define your own styles. |
570 If you are not afraid of ML, you may also define your own styles. |
570 A style is implemented by an ML function of type |
571 Have a look at module \verb|Term_Style|.% |
571 \verb!Proof.context -> term -> term!. |
|
572 Have a look at the following example:% |
|
573 \end{isamarkuptext}% |
|
574 \isamarkuptrue% |
|
575 % |
|
576 \isadelimML |
|
577 % |
|
578 \endisadelimML |
|
579 % |
|
580 \isatagML |
|
581 % |
|
582 \endisatagML |
|
583 {\isafoldML}% |
|
584 % |
|
585 \isadelimML |
|
586 % |
|
587 \endisadelimML |
|
588 % |
|
589 \begin{isamarkuptext}% |
|
590 \begin{quote} |
|
591 \verb!setup {!\verb!*!\\ |
|
592 \verb!let!\\ |
|
593 \verb! fun my_concl ctxt = Logic.strip_imp_concl!\\ |
|
594 \verb! in TermStyle.add_style "my_concl" my_concl!\\ |
|
595 \verb!end;!\\ |
|
596 \verb!*!\verb!}!\\ |
|
597 \end{quote} |
|
598 |
|
599 \noindent |
|
600 This example shows how the \verb!concl! style is implemented |
|
601 and may be used as as a ``copy-and-paste'' pattern to write your own styles. |
|
602 |
|
603 The code should go into your theory file, separate from the \LaTeX\ text. |
|
604 The \verb!let! expression avoids polluting the |
|
605 ML global namespace. Each style receives the current proof context |
|
606 as first argument; this is helpful in situations where the |
|
607 style has some object-logic specific behaviour for example. |
|
608 |
|
609 The mapping from identifier name to the style function |
|
610 is done by the \verb|TermStyle.add_style| expression which expects the desired |
|
611 style name and the style function as arguments. |
|
612 |
|
613 After this \verb!setup!, |
|
614 there will be a new style available named \verb!my_concl!, thus allowing |
|
615 antiquoations like \verb!@!\verb!{thm_style my_concl hd_Cons_tl}! |
|
616 yielding \isa{hd\ xs{\isasymcdot}tl\ xs\ {\isacharequal}\ xs}.% |
|
617 \end{isamarkuptext}% |
572 \end{isamarkuptext}% |
618 \isamarkuptrue% |
573 \isamarkuptrue% |
619 % |
574 % |
620 \isadelimtheory |
575 \isadelimtheory |
621 % |
576 % |