added Isar-syntax for define_shortcut*

This commit is contained in:
Burkhart Wolff 2020-12-22 08:07:19 +01:00
parent 0e64608a58
commit de5c0fc6e2
7 changed files with 51 additions and 62 deletions

View File

@ -19,13 +19,11 @@ begin
open_monitor*[this::article]
declare[[strict_monitor_checking=false]]
setup \<open> DOF_lib.define_shortcut \<^binding>\<open>isadof\<close> "\\isadof"
#> DOF_lib.define_shortcut \<^binding>\<open>LaTeX\<close> "\\LaTeX{}"
#> DOF_lib.define_shortcut \<^binding>\<open>Protege\<close> "Prot{\\'e}g{\\'e}"
#> DOF_lib.define_shortcut \<^binding>\<open>dots\<close> "\\ldots"
#> DOF_lib.define_shortcut \<^binding>\<open>isabelle\<close> "Isabelle/HOL"
\<close>
define_shortcut* isadof \<rightleftharpoons> \<open>\isadof\<close>
LaTeX \<rightleftharpoons> \<open>\LaTeX{}\<close>
dots \<rightleftharpoons> \<open>\ldots\<close>
isabelle \<rightleftharpoons> \<open>Isabelle/HOL\<close>
Protege \<rightleftharpoons> \<open>Prot{\'e}g{\'e}\<close>
(* slanted text in contrast to italics *)
setup\<open> DOF_lib.define_macro \<^binding>\<open>slanted_text\<close> "\\textsl{" "}" (K(K()))\<close>

View File

@ -12,17 +12,17 @@ declare[[ Definition_default_class="definition"]]
declare[[ Lemma_default_class="lemma"]]
declare[[ Theorem_default_class="theorem"]]
setup \<open> DOF_lib.define_shortcut \<^binding>\<open>csp\<close> "CSP"
#> DOF_lib.define_shortcut \<^binding>\<open>isabelle\<close> "Isabelle/HOL"\<close>
define_shortcut* csp \<rightleftharpoons> \<open>CSP\<close>
isabelle \<rightleftharpoons> \<open>Isabelle/HOL\<close>
(*>*)
title*[tit::title]\<open>Philosophers may Dine - Definitively!\<close>
author*[safouan,email="\<open>safouan.taha@lri.fr\<close>",affiliation="\<open>LRI, CentraleSupelec\<close>"]\<open>Safouan Taha\<close>
author*[bu,email= "\<open>wolff@lri.fr\<close>",affiliation = "\<open>LRI, Université Paris-Saclay\<close>"]\<open>Burkhart Wolff\<close>
author*[lina,email="\<open>lina.ye@lri.fr\<close>",affiliation="\<open>LRI, Inria, LSV, CentraleSupelec\<close>"]\<open>Lina Ye\<close>
abstract*[abs, keywordlist="[\<open>Shallow Embedding\<close>,\<open>Process-Algebra\<close>,
\<open>Concurrency\<close>,\<open>Computational Models\<close>]"]
\<open> The theory of Communicating Sequential Processes going back to Hoare and Roscoe is still today

View File

@ -16,20 +16,21 @@ theory "00_Frontmatter"
imports "Isabelle_DOF.technical_report"
begin
text\<open> \<open> \<tau>\<close>\<close>
section\<open>Document Local Setup.\<close>
text\<open>Some internal setup, introducing document specific abbreviations and macros.\<close>
setup \<open>DOF_lib.define_shortcut \<^binding>\<open>dof\<close> "\\dof"\<close>
setup \<open>DOF_lib.define_shortcut \<^binding>\<open>isadof\<close> "\\isadof"\<close>
setup \<open> DOF_lib.define_shortcut \<^binding>\<open>TeXLive\<close>"\\TeXLive"
#> DOF_lib.define_shortcut \<^binding>\<open>BibTeX\<close> "\\BibTeX{}"
#> DOF_lib.define_shortcut \<^binding>\<open>LaTeX\<close> "\\LaTeX{}"
#> DOF_lib.define_shortcut \<^binding>\<open>TeX\<close> "\\TeX{}"
#> DOF_lib.define_shortcut \<^binding>\<open>pdf\<close> "PDF"
#> DOF_lib.define_shortcut \<^binding>\<open>pdftex\<close> "\\pdftex{}"
\<close>
define_shortcut* dof \<rightleftharpoons> \<open>\dof\<close>
isadof \<rightleftharpoons> \<open>\isadof\<close>
define_shortcut* TeXLive \<rightleftharpoons> \<open>\TeXLive\<close>
BibTeX \<rightleftharpoons> \<open>\BibTeX{}\<close>
LaTeX \<rightleftharpoons> \<open>\LaTeX{}\<close>
TeX \<rightleftharpoons> \<open>\TeX{}\<close>
pdf \<rightleftharpoons> \<open>PDF\<close>
pdftex \<rightleftharpoons> \<open>\pdftex{}\<close>
text\<open>Note that these setups assume that the associated \<^LaTeX> macros are defined, \<^eg>,
in the document prelude. \<close>

View File

@ -14,9 +14,10 @@
(*<*)
theory TR_MyCommentedIsabelle
imports "Isabelle_DOF.technical_report"
begin
setup \<open> DOF_lib.define_shortcut \<^binding>\<open>isabelle\<close> "Isabelle/HOL"\<close>
define_shortcut* isabelle \<rightleftharpoons> \<open>Isabelle/HOL\<close>
open_monitor*[this::report]
(*>*)
@ -2311,6 +2312,7 @@ for Unicode Character Denotations as well as many local hints for improvements.\
section*[bib::bibliography]\<open>Bibliography\<close>
close_monitor*[this]
check_doc_global

View File

@ -29,6 +29,7 @@ theory Isa_COL
and "figure*" "side_by_side_figure*" :: document_body
and "assert*" :: thy_decl
and "define_shortcut*" :: thy_decl
begin
@ -413,6 +414,17 @@ fun enclose_env verbatim ctxt block_env body =
end
\<close>
ML\<open>
local
val parse_define_shortcut = Parse.binding --
((\<^keyword>\<open>\<rightleftharpoons>\<close> || \<^keyword>\<open>==\<close>) |-- (Parse.alt_string || Parse.cartouche))
val define_shortcuts = fold(uncurry DOF_lib.define_shortcut)
in
val _ =
Outer_Syntax.command \<^command_keyword>\<open>define_shortcut*\<close> "define LaTeX shortcut"
(Scan.repeat1 parse_define_shortcut >> (Toplevel.theory o define_shortcuts));
end
\<close>
section\<open>Tables\<close>
(* TODO ! ! ! *)
@ -426,5 +438,4 @@ ML\<open>@{term "side_by_side_figure"};
@{typ "doc_class rexp"};
DOF_core.SPY;\<close>
end

View File

@ -62,7 +62,7 @@ doc_class F =
doc_class G = C +
g :: "thm" <= "@{thm ''HOL.refl''}"
g :: "thm" <= "@{thm \<open>HOL.refl\<close>}"
doc_class M =
trace :: "(A + C + D + F) list"
@ -79,8 +79,8 @@ ML\<open> Thy_Header.get_keywords @{theory};(* this looks to be really theory gl
section*[test::A]\<open>Test and Validation\<close>
text\<open>Defining some document elements to be referenced in later on in another theory: \<close>
text*[sdf]\<open> Lorem ipsum @{thm refl}\<close>
text*[ sdfg] \<open> Lorem ipsum @{thm refl}\<close>
text*[ xxxy ] \<open> Lorem ipsum @{docitem \<open>sdfg\<close>} rate @{thm refl}\<close>
text*[ sdfg :: F] \<open> Lorem ipsum @{thm refl}\<close>
text*[ xxxy ] \<open> Lorem ipsum @{F \<open>sdfg\<close>} rate @{thm refl}\<close>
end

View File

@ -470,46 +470,23 @@ setup\<open> let val cidS = ["scholarly_paper.introduction","scholarly_paper.tec
in DOF_core.update_class_invariant "scholarly_paper.article" body end\<close>
(* some test code *)
ML\<open>
(*
val trace = AttributeAccess.compute_trace_ML (Context.Proof @{context}) "this" @{here} @{here}
val groups = partition ( @{context}) cidS trace
val _::_::_::_:: _ ::_ ::_ ::a::_ = groups;
check;
fun get_level_raw oid = AttributeAccess.compute_attr_access (Context.Proof @{context}) "level" oid @{here} @{here};
fun get_level oid = dest_option (snd o HOLogic.dest_number) (get_level_raw (oid));
fun check_level_hd a = case (get_level (snd a)) of
NONE => error("Invariant violation: leading section" ^ snd a ^
" must have lowest level")
| SOME X => X
fun check_group_elem level_hd a = case (get_level (snd a)) of
NONE => true
| SOME y => if y > level_hd then true
else error("Invariant violation: subsequent section " ^ snd a ^
" must have higher level.");
fun check_group a = map (check_group_elem (check_level_hd (hd a))) (tl a) ;
*)
\<close>
section\<open>Miscelleous\<close>
subsection\<open>Layout Trimming Commands\<close>
setup\<open> DOF_lib.define_macro \<^binding>\<open>hs\<close> "\\hspace{" "}" (K(K())) \<close>
setup\<open> DOF_lib.define_macro \<^binding>\<open>vs\<close> "\\vspace{" "}" (K(K())) \<close>
setup\<open> DOF_lib.define_shortcut \<^binding>\<open>clearpage\<close> "\\clearpage{}" \<close>
subsection\<open>Common Abbreviations\<close>
setup \<open> DOF_lib.define_shortcut \<^binding>\<open>eg\<close> "\\eg"
(* Latin: „exempli gratia“ meaning „for example“. *)
#> DOF_lib.define_shortcut \<^binding>\<open>ie\<close> "\\ie"
(* Latin: „id est“ meaning „that is to say“. *)
#> DOF_lib.define_shortcut \<^binding>\<open>etc\<close> "\\etc"\<close>
(* this is an alternative style for macro definitions equivalent to setup ... setup ...*)
define_shortcut* eg \<rightleftharpoons> \<open>\eg\<close> (* Latin: „exempli gratia“ meaning „for example“. *)
ie \<rightleftharpoons> \<open>\ie\<close> (* Latin: „id est“ meaning „that is to say“. *)
etc \<rightleftharpoons> \<open>\etc\<close> (* Latin : et cetera *)
subsection\<open>Layout Trimming Commands\<close>
setup\<open> DOF_lib.define_macro \<^binding>\<open>hs\<close> "\\hspace{" "}" (K(K())) \<close>
setup\<open> DOF_lib.define_macro \<^binding>\<open>vs\<close> "\\vspace{" "}" (K(K())) \<close>
define_shortcut* clearpage \<rightleftharpoons> \<open>\clearpage{}\<close>
end