doc-src/LaTeXsugar/Sugar/Sugar.thy
changeset 16076 03e8a88c0b54
parent 16075 8852058ecf8d
child 16153 999ca183b4c7
equal deleted inserted replaced
16075:8852058ecf8d 16076:03e8a88c0b54
   292     \verb!@!\verb!{thm_style stylename thm}!\\
   292     \verb!@!\verb!{thm_style stylename thm}!\\
   293     \verb!@!\verb!{term_style stylename term}!
   293     \verb!@!\verb!{term_style stylename term}!
   294     \end{quote}
   294     \end{quote}
   295 
   295 
   296   A ``style'' is a transformation of propositions. There are predefined
   296   A ``style'' is a transformation of propositions. There are predefined
   297   styles, namly \verb!lhs!, \verb!rhs! and \verb!conclusion!, with obvious
   297   styles, namly \verb!lhs!, \verb!rhs! and \verb!conclusion!. For example, 
   298   meanings. For example, the output
   298   the output
   299   \begin{center}
   299   \begin{center}
   300   \begin{tabular}{l@ {~~@{text "="}~~}l}
   300   \begin{tabular}{l@ {~~@{text "="}~~}l}
   301   @{thm_style lhs foldl_Nil} & @{thm_style rhs foldl_Nil}\\
   301   @{thm_style lhs foldl_Nil} & @{thm_style rhs foldl_Nil}\\
   302   @{thm_style lhs foldl_Cons} & @{thm_style rhs foldl_Cons}
   302   @{thm_style lhs foldl_Cons} & @{thm_style rhs foldl_Cons}
   303   \end{tabular}
   303   \end{tabular}
   311     \verb!\end{tabular}!\\
   311     \verb!\end{tabular}!\\
   312     \verb!\end{center}!
   312     \verb!\end{center}!
   313   \end{quote}
   313   \end{quote}
   314   Note the space between \verb!@! and \verb!{! in the tabular argument.
   314   Note the space between \verb!@! and \verb!{! in the tabular argument.
   315   It prevents Isabelle from interpreting \verb!@ {~~...~~}! 
   315   It prevents Isabelle from interpreting \verb!@ {~~...~~}! 
   316   as an antiquotation. Both styles \verb!lhs! and \verb!rhs!
   316   as an antiquotation. The styles \verb!lhs! and \verb!rhs!
   317   extract the left hand side (or right hand side respectivly) from the
   317   extract the left hand side (or right hand side respectivly) from the
   318   conclusion of propositions, consisting of a binary operator
   318   conclusion of propositions consisting of a binary operator
   319   (e.~g.~@{text "="}, @{text "\<equiv>"}, @{text "<"}).
   319   (e.~g.~@{text "="}, @{text "\<equiv>"}, @{text "<"}).
   320 
   320 
   321   Likewise \verb!conclusion! may be used as style to show just the conclusion
   321   Likewise, \verb!conclusion! may be used as a style to show just the
   322   of a proposition. For example, take
   322   conclusion of a proposition. For example, take \verb!hd_Cons_tl!:
   323   \begin{center}
   323   \begin{center}
   324     @{thm hd_Cons_tl}
   324     @{thm hd_Cons_tl}
   325   \end{center}
   325   \end{center}
   326   produced by
       
   327   \begin{quote}
       
   328     \verb!\begin{center}!\\
       
   329     \verb!@!\verb!{thm hd_Cons_tl}!\\
       
   330     \verb!\end{center}!
       
   331   \end{quote}
       
   332   To print just the conclusion,
   326   To print just the conclusion,
   333   \begin{center}
   327   \begin{center}
   334     @{thm_style conclusion hd_Cons_tl}
   328     @{thm_style conclusion hd_Cons_tl}
   335   \end{center}
   329   \end{center}
   336   type
   330   type
   363     \verb!  in [TermStyle.add_style "my_concl" my_concl]!\\
   357     \verb!  in [TermStyle.add_style "my_concl" my_concl]!\\
   364     \verb!end;!\\
   358     \verb!end;!\\
   365     \verb!*!\verb!}!\\
   359     \verb!*!\verb!}!\\
   366   \end{quote}
   360   \end{quote}
   367 
   361 
   368   This example indeed shows how the \verb!conclusion! style could is implemented;
   362   \noindent
   369   note that the real implementation is more sophisticated.
   363   This example shows how the \verb!conclusion! style could have been implemented
   370 
   364   and may be used as as a ``copy-and-paste'' pattern to write your own styles.
   371   This code should go into your theory file, not as part of your
   365   (The real implementation of \verb!conclusion! is a bit more sophisticated).
   372   \LaTeX\ text but as a separate command in front of it.
   366 
       
   367   The code should go into your theory file, separate from the \LaTeX\ text.
   373   The \verb!let! expression avoids polluting the
   368   The \verb!let! expression avoids polluting the
   374   ML global namespace. Each style receives the current proof context
   369   ML global namespace. Each style receives the current proof context
   375   as first argument; this is helpful in situations where the current proof
   370   as first argument; this is helpful in situations where the
   376   context has an impact on the style (which is the case e.~g.~when the
   371   style has some object-logic specific behaviour for example.
   377   style has some object-logic specific behaviour).
       
   378 
   372 
   379   The mapping from identifier name to the style function
   373   The mapping from identifier name to the style function
   380   is done by the @{ML_idf TermStyle.add_style} expression which expects the desired
   374   is done by the @{ML_idf TermStyle.add_style} expression which expects the desired
   381   style name and the style function as arguments.
   375   style name and the style function as arguments.
   382   
   376   
   383   After this \verb!setup!,
   377   After this \verb!setup!,
   384   there will be a new style available named \verb!my_concl!, thus allowing
   378   there will be a new style available named \verb!my_concl!, thus allowing
   385   antiquoations like \verb!@!\verb!{thm_style my_concl hd_Cons_tl}!
   379   antiquoations like \verb!@!\verb!{thm_style my_concl hd_Cons_tl}!
   386   yielding @{thm_style my_concl hd_Cons_tl}.
   380   yielding @{thm_style my_concl hd_Cons_tl}.
   387 
   381 
   388   The example above may be used as as a ``copy-and-paste'' pattern to write
       
   389   your own styles.
       
   390 
       
   391 *}
   382 *}
   392 
   383 
   393 (*<*)
   384 (*<*)
   394 end
   385 end
   395 (*>*)
   386 (*>*)