added wrapper to achims listings environments.

This commit is contained in:
Burkhart Wolff 2020-08-28 12:42:20 +02:00
parent d206bf9f7c
commit 094281cf89
6 changed files with 118 additions and 36 deletions

View File

@ -46,11 +46,41 @@ fun boxed_text_antiquotation name (* redefined in these more abstract terms *) =
(fn ctxt => DOF_lib.string_2_text_antiquotation ctxt (fn ctxt => DOF_lib.string_2_text_antiquotation ctxt
#> DOF_lib.enclose_env ctxt "isarbox") #> DOF_lib.enclose_env ctxt "isarbox")
val neant = K(Latex.text("",\<^here>))
fun boxed_theory_text_antiquotation name (* redefined in these more abstract terms *) = fun boxed_theory_text_antiquotation name (* redefined in these more abstract terms *) =
DOF_lib.gen_text_antiquotation name DOF_lib.report_theory_text DOF_lib.gen_text_antiquotation name DOF_lib.report_theory_text
(fn ctxt => DOF_lib.string_2_theory_text_antiquotation ctxt (fn ctxt => DOF_lib.string_2_theory_text_antiquotation ctxt
#> DOF_lib.enclose_env ctxt "isarbox") #> DOF_lib.enclose_env ctxt "isarbox"
(* #> neant *)) (*debugging *)
fun boxed_sml_text_antiquotation name =
DOF_lib.gen_text_antiquotation name (K(K()))
(fn ctxt => Input.source_content
#> Latex.text
#> DOF_lib.enclose_env ctxt "sml")
(* the simplest conversion possible *)
fun boxed_pdf_antiquotation name =
DOF_lib.gen_text_antiquotation name (K(K()))
(fn ctxt => Input.source_content
#> Latex.text
#> DOF_lib.enclose_env ctxt "out")
(* the simplest conversion possible *)
fun boxed_latex_antiquotation name =
DOF_lib.gen_text_antiquotation name (K(K()))
(fn ctxt => Input.source_content
#> Latex.text
#> DOF_lib.enclose_env ctxt "ltx")
(* the simplest conversion possible *)
fun boxed_bash_antiquotation name =
DOF_lib.gen_text_antiquotation name (K(K()))
(fn ctxt => Input.source_content
#> Latex.text
#> DOF_lib.enclose_env ctxt "bash")
(* the simplest conversion possible *)
\<close> \<close>
@ -59,7 +89,12 @@ setup\<open>(* std_text_antiquotation \<^binding>\<open>my_text\<close> #
(* std_text_antiquotation \<^binding>\<open>my_cartouche\<close> #> *) (* std_text_antiquotation \<^binding>\<open>my_cartouche\<close> #> *)
boxed_text_antiquotation \<^binding>\<open>boxed_cartouche\<close> #> boxed_text_antiquotation \<^binding>\<open>boxed_cartouche\<close> #>
(* std_theory_text_antiquotation \<^binding>\<open>my_theory_text\<close>#> *) (* std_theory_text_antiquotation \<^binding>\<open>my_theory_text\<close>#> *)
boxed_theory_text_antiquotation \<^binding>\<open>boxed_theory_text\<close>\<close> boxed_theory_text_antiquotation \<^binding>\<open>boxed_theory_text\<close> #>
boxed_sml_text_antiquotation \<^binding>\<open>boxed_sml\<close> #>
boxed_pdf_antiquotation \<^binding>\<open>boxed_pdf\<close> #>
boxed_latex_antiquotation \<^binding>\<open>boxed_latex\<close>#>
boxed_bash_antiquotation \<^binding>\<open>boxed_bash\<close>\<close>
@ -85,7 +120,7 @@ text*[abs::abstract,
\<open> \<^isadof> provides an implementation of \<^dof> on top of Isabelle/HOL. \<open> \<^isadof> provides an implementation of \<^dof> on top of Isabelle/HOL.
\<^dof> itself is a novel framework for \<^emph>\<open>defining\<close> ontologies \<^dof> itself is a novel framework for \<^emph>\<open>defining\<close> ontologies
and \<^emph>\<open>enforcing\<close> them during document development and document and \<^emph>\<open>enforcing\<close> them during document development and document
evolution. \<^isadof> targets use-cases such as mathematical texts referring evolution. \<^isadof> targets use-cases such as mathematical texts referring
to a theory development or technical reports requiring a particular structure. to a theory development or technical reports requiring a particular structure.
A major application of \<^dof> is the integrated development of A major application of \<^dof> is the integrated development of
formal certification documents (\<^eg>, for Common Criteria or CENELEC formal certification documents (\<^eg>, for Common Criteria or CENELEC

View File

@ -90,26 +90,34 @@ text\<open>
lemma refl: "x = x" lemma refl: "x = x"
by simp by simp
\end{isar} \end{isar}
% @ {boxed_isar [display]
% \<open>lemma refl: "x = x"
% by simp\<close>}
@{boxed_theory_text [display]
\<open>lemma refl: "x = x"
by simp\<close>}
\<^item> a green background for examples of generated document fragments (\<^ie>, PDF output): \<^item> a green background for examples of generated document fragments (\<^ie>, PDF output):
\begin{out} @{boxed_pdf [display] \<open>The axiom refl\<close>}
The axiom refl
\end{out}
\<^item> a red background for For (S)ML-code: \<^item> a red background for For (S)ML-code:
\begin{sml} @{boxed_sml [display] \<open>fun id x = x\<close>}
fun id x = x
\end{sml}
\<^item> a yellow background for \LaTeX-code: \<^item> a yellow background for \LaTeX-code:
@{boxed_latex [display] \<open>\newcommand{\refl}{$x = x$}\<close>}
\begin{ltx} \begin{ltx}
\newcommand{\refl}{$x = x$} \newcommand{\refl}{$x = x$}
\end{ltx} \end{ltx}
\<^item> a grey background for shell scripts and interactive shell sessions: \<^item> a grey background for shell scripts and interactive shell sessions:
@{boxed_bash [display]
\<open>ë\prompt{}ë ls
CHANGELOG.md CITATION examples install LICENSE README.md ROOTS src\<close>}
\begin{bash} \begin{bash}
ë\prompt{}ë ls ë\prompt{}ë ls
CHANGELOG.md CITATION examples install LICENSE README.md ROOTS src CHANGELOG.md CITATION examples install LICENSE README.md ROOTS src
\end{bash} \end{bash}
\<close> \<close>
subsubsection\<open>How to Cite \isadof\<close> subsubsection\<open>How to Cite \<^isadof>\<close>
text\<open> text\<open>
If you use or extend \<^isadof> in your publications, please use If you use or extend \<^isadof> in your publications, please use
\<^item> for the \<^isadof> system~@{cite "brucker.ea:isabelle-ontologies:2018"}: \<^item> for the \<^isadof> system~@{cite "brucker.ea:isabelle-ontologies:2018"}:
@ -120,8 +128,8 @@ text\<open>
Heidelberg, 2018. \href{https://doi.org/10.1007/978-3-319-96812-4\_3} Heidelberg, 2018. \href{https://doi.org/10.1007/978-3-319-96812-4\_3}
{10.1007/978-3-319-96812-4\_3}. {10.1007/978-3-319-96812-4\_3}.
\end{quote} \end{quote}
A \BibTeX-entry is available at: A \<^BibTeX>-entry is available at:
\url{https://www.brucker.ch/bibliography/abstract/brucker.ea-isabelle-ontologies-2018}. \<^url>\<open>https://www.brucker.ch/bibliography/abstract/brucker.ea-isabelle-ontologies-2018\<close>.
\<^item> for the implementation of \<^isadof>~@{cite "brucker.ea:isabelledof:2019"}: \<^item> for the implementation of \<^isadof>~@{cite "brucker.ea:isabelledof:2019"}:
\begin{quote}\small \begin{quote}\small
A.~D. Brucker and B.~Wolff. \<^isadof>: Design and implementation. In P.C.~{\"O}lveczky and A.~D. Brucker and B.~Wolff. \<^isadof>: Design and implementation. In P.C.~{\"O}lveczky and
@ -130,8 +138,8 @@ text\<open>
\href{https://doi.org/10.1007/978-3-030-30446-1_15}{10.1007/978-3-030-30446-1\_15}. \href{https://doi.org/10.1007/978-3-030-30446-1_15}{10.1007/978-3-030-30446-1\_15}.
\end{quote} \end{quote}
A \BibTeX-entry is available at: A \<^BibTeX>-entry is available at:
\url{https://www.brucker.ch/bibliography/abstract/brucker.ea-isabelledof-2019}. \<^url>\<open>https://www.brucker.ch/bibliography/abstract/brucker.ea-isabelledof-2019\<close>.
\<close> \<close>
subsubsection\<open>Availability\<close> subsubsection\<open>Availability\<close>
text\<open> text\<open>

View File

@ -89,38 +89,67 @@ text\<open>
\inlineisar{Main} refers to an imported theory (recall that the import \inlineisar{Main} refers to an imported theory (recall that the import
relation must be acyclic) and \inlineisar{keywords} are used to relation must be acyclic) and \inlineisar{keywords} are used to
separate commands from each other. separate commands from each other.
\<close>
(* experiment starts here *)
(* somewhere we destroyed the standard antiquotation thm ...
text\<open> \<^emph>\<open>blabla\<close> @{thm \<open>refl\<close>}\<close>
text\<open> According to the \<^emph>\<open>reflexivity\<close> axiom @{thm refl}, we obtain in \<Gamma>
for @{term "fac 5"} the result @{value "fac 5"}.\<close>
*)
text\<open> \<^theory_text>\<open>text\<open> According to the *\<open>reflexivity\<close> axiom @{thm refl}, we obtain in \<Gamma>
for @{term "fac 5"} the result @{value "fac 5"}.\<close>\<close>\<close>
text\<open>
We distinguish fundamentally two different syntactic levels: We distinguish fundamentally two different syntactic levels:
\<^item> the \<^emph>\<open>outer-syntax\<close>\<^bindex>\<open>syntax!outer\<close>\<^index>\<open>outer syntax|see {syntax, outer}\<close> (\<^ie>, the \<^item> the \<^emph>\<open>outer-syntax\<close>\<^bindex>\<open>syntax!outer\<close>\<^index>\<open>outer syntax|see {syntax, outer}\<close> (\<^ie>, the
syntax for commands) is processed by a lexer-library and parser combinators built on top, and syntax for commands) is processed by a lexer-library and parser combinators built on top, and
\<^item> the \<^emph>\<open>inner-syntax\<close>\<^bindex>\<open>syntax!inner\<close>\<^index>\<open>inner syntax|see {syntax, inner}\<close> (\<^ie>, the \<^item> the \<^emph>\<open>inner-syntax\<close>\<^bindex>\<open>syntax!inner\<close>\<^index>\<open>inner syntax|see {syntax, inner}\<close> (\<^ie>, the
syntax for \inlineisar|\<lambda>|-terms in HOL) with its own parametric polymorphism type syntax for \<open>\<lambda>\<close>-terms in HOL) with its own parametric polymorphism type checking.
checking.
On the semantic level, we assume a validation process for an integrated document, where the On the semantic level, we assume a validation process for an integrated document, where the
semantics of a command is a transformation \inlineisar+\<theta> \<rightarrow> \<theta>+ for some system state semantics of a command is a transformation \<open>\<theta> \<rightarrow> \<theta>\<close> for some system state \<open>\<theta>\<close>.
\inlineisar+\<theta>+. This document model can be instantiated with outer-syntax commands for common This document model can be instantiated with outer-syntax commands for common
text elements, \<^eg>, \inlineisar+section\<Open>...\<Close>+ or \inlineisar+text\<Open>...\<Close>+. text elements, \<^eg>, \<^theory_text>\<open>section\<open>...\<close>\<close> or \<^theory_text>\<open>text\<open>...\<close>\<close>.
Thus, users can add informal text to a sub-document using a text command: Thus, users can add informal text to a sub-document using a text command:
@{boxed_theory_text [display] \<open>text\<open>This is a description.\<close>\<close> }
\begin{isar} \begin{isar}
text\<Open>This is a description.\<Close> text\<Open>This is a description.\<Close>
\end{isar} \end{isar}
This will type-set the corresponding text in, for example, a PDF document. However, this This will type-set the corresponding text in, for example, a PDF document. However, this
translation is not necessarily one-to-one: text elements can be enriched by formal, \<^ie>, translation is not necessarily one-to-one: text elements can be enriched by formal, \<^ie>,
machine-checked content via *\<open>semantic macros\<close>, called antiquotations\<^bindex>\<open>antiquotation\<close>: machine-checked content via *\<open>semantic macros\<close>, called antiquotations\<^bindex>\<open>antiquotation\<close>:
@{boxed_theory_text [display]
\<open>text\<open> According to the *\<open>reflexivity\<close> axiom @{thm refl}, we obtain in \<Gamma>
for @{term "fac 5"} the result @{value "fac 5"}.\<close>\<close>
}
\begin{isar} \begin{isar}
text\<Open>According to the *\<Open>reflexivity\<Close> axiom <@>{thm refl}, we obtain in \<Gamma> text\<Open>According to the *\<Open>reflexivity\<Close> axiom <@>{thm refl}, we obtain in \<Gamma>
for <@>{term "fac 5"} the result <@>{value "fac 5"}.\<Close> for <@>{term "fac 5"} the result <@>{value "fac 5"}.\<Close>
\end{isar} \end{isar}
which is represented in the final document (\<^eg>, a PDF) by: which is represented in the final document (\<^eg>, a PDF) by:
\begin{out} \begin{out}
According to the \emph{reflexivity} axiom $\mathrm{x = x}$, we obtain in $\Gamma$ for $\operatorname{fac} \text{\textrm{5}}$ the result $\text{\textrm{120}}$. According to the \emph{reflexivity} axiom $\mathrm{x = x}$, we obtain in $\Gamma$
for $\operatorname{fac} \text{\textrm{5}}$ the result $\text{\textrm{120}}$.
\end{out} \end{out}
Semantic macros are partial functions of type \inlineisar+\<theta> \<rightarrow> text+; since they can use the
@{boxed_pdf [display]
\<open>According to the \emph{reflexivity} axiom $\mathrm{x = x}$, we obtain in $\Gamma$
for $\operatorname{fac} \text{\textrm{5}}$ the result $\text{\textrm{120}}$.\<close>
}
Semantic macros are partial functions of type \<open>\<theta> \<rightarrow> text\<close>; since they can use the
system state, they can perform all sorts of specific checks or evaluations (type-checks, system state, they can perform all sorts of specific checks or evaluations (type-checks,
executions of code-elements, references to text-elements or proven theorems such as executions of code-elements, references to text-elements or proven theorems such as
\inlineisar+refl+, which is the reference to the axiom of reflexivity). \<open>refl\<close>, which is the reference to the axiom of reflexivity).
Semantic macros establish \<^emph>\<open>formal content\<close> inside informal content; they can be Semantic macros establish \<^emph>\<open>formal content\<close> inside informal content; they can be
type-checked before being displayed and can be used for calculations before being type-checked before being displayed and can be used for calculations before being
@ -133,17 +162,15 @@ figure*["fig:dependency"::figure,relative_width="70",src="''figures/document-hie
section*[bgrnd21::introduction]\<open>Implementability of the Required Document Model.\<close> section*[bgrnd21::introduction]\<open>Implementability of the Required Document Model.\<close>
text\<open> text\<open>
Batch-mode checkers for \<^dof> can be implemented in all systems of the LCF-style prover family, Batch-mode checkers for \<^dof> can be implemented in all systems of the LCF-style prover family,
\<^ie>, systems with a type-checked \inlinesml{term}, and abstract \inlinesml{thm}-type for \<^ie>, systems with a type-checked \<open>term\<close>, and abstract \<open>thm\<close>-type for theorems
theorems (protected by a kernel). This includes, \<^eg>, ProofPower, HOL4, HOL-light, Isabelle, or (protected by a kernel). This includes, \<^eg>, ProofPower, HOL4, HOL-light, Isabelle, or Coq
Coq and its derivatives. \<^dof> is, however, designed for fast interaction in an IDE. If a user wants and its derivatives. \<^dof> is, however, designed for fast interaction in an IDE. If a user wants
to benefit from this experience, only Isabelle and Coq have the necessary infrastructure of to benefit from this experience, only Isabelle and Coq have the necessary infrastructure of
asynchronous proof-processing and support by a PIDE~@{cite "wenzel:asynchronous:2014" and asynchronous proof-processing and support by a PIDE~@{cite "wenzel:asynchronous:2014" and
"wenzel:system:2014" and "barras.ea:pervasive:2013" "wenzel:system:2014" and "barras.ea:pervasive:2013" and "faithfull.ea:coqoon:2018"} which
and "faithfull.ea:coqoon:2018"} which in many features over-accomplishes the required in many features over-accomplishes the required features of \<^dof>. For example, current Isabelle
features of \<^dof>. For example, current Isabelle versions offer cascade-syntaxes (different versions offer cascade-syntaxes (different syntaxes and even parser-technologies which can be
syntaxes and even parser-technologies which can be nested along the nested along the \<open>\<open>...\<close>\<close> barriers, while \<^dof> actually only requires a two-level syntax model.
\inlineisar+\<Open> ... \<Close> + barriers, while \<^dof> actually only requires a two-level
syntax model.
\<close> \<close>
figure*["fig:dof-ide"::figure,relative_width="95",src="''figures/cicm2018-combined''"]\<open> figure*["fig:dof-ide"::figure,relative_width="95",src="''figures/cicm2018-combined''"]\<open>
@ -168,6 +195,8 @@ text\<open>
\<^ie>, sub-graphs of the document-structure that can be ``pre-compiled'' and loaded \<^ie>, sub-graphs of the document-structure that can be ``pre-compiled'' and loaded
instantaneously, \<^ie>, without re-processing. \<close> instantaneously, \<^ie>, without re-processing. \<close>
(* end experiment *)
(*<*) (*<*)
end end
(*>*) (*>*)

View File

@ -118,6 +118,16 @@ France, and therefore granted with public funds of the Program ``Investissements
\AtBeginDocument{\isabellestyle{literal}\newcommand{\lstnumberautorefname}{Line}} \AtBeginDocument{\isabellestyle{literal}\newcommand{\lstnumberautorefname}{Line}}
\renewcommand{\isacommand}[1]{\textcolor{OliveGreen!60}{\ttfamily\bfseries #1}} \renewcommand{\isacommand}[1]{\textcolor{OliveGreen!60}{\ttfamily\bfseries #1}}
%\newtcolorbox{mybox}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1},
%\newenvironment{isarbox}
%{\begin{mybox}}
%{\end{mybox}}
%\newenvironment{isarbox}
%{\begin{isar}}
%{\end{isar}}
\newenvironment{isarbox} \newenvironment{isarbox}
{AAA - bu isarbox} {AAA - bu isarbox}
{ZZZ - bu isarbox} {ZZZ - bu isarbox}

View File

@ -375,7 +375,7 @@ fun theory_text_antiquotation name =
fun enclose_env ctxt block_env body = fun enclose_env ctxt block_env body =
if Config.get ctxt Document_Antiquotation.thy_output_display if Config.get ctxt Document_Antiquotation.thy_output_display
then Latex.environment_block block_env [body] then Latex.environment_block block_env [body]
else body; else Latex.block ([Latex.string (block_env ^"inline{")] @ [body] @ [ Latex.string ("}")]);
end end
\<close> \<close>

View File

@ -316,8 +316,8 @@ val _ = Theory.setup
\<close> \<close>
textN\<open> textN\<open>
@{boxed_cartouche [display] \<open>definition dfg = \<lambda>x. x\<close>} @{boxed_cartouche [display] \<open>definition dfg = \<lambda>x. x\<close>}
@{boxed_theory_text [display] \<open>doc_class dfg = ...\<close>} \<close> @{boxed_theory_text [display] \<open>doc_class dfg = \<lambda>x... \<Gamma>\<close>} \<close>
end end
(*>*) (*>*)