diff options
author | Karl Berry <karl@freefriends.org> | 2009-09-20 23:33:29 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-09-20 23:33:29 +0000 |
commit | 44bb8968da104e49b3765b18aa54f62870f88c39 (patch) | |
tree | 01f02e9f18b677e666821adaa29621489e2d14a5 | |
parent | 2c20e449c234f30eb26e3cbbd9cd48b281842a37 (diff) |
new mpost package drv 0.93 (20sep09)
git-svn-id: svn://tug.org/texlive/trunk@15388 c570f23f-e606-0410-a88d-b1316a301751
28 files changed, 13333 insertions, 8 deletions
diff --git a/Master/texmf-dist/doc/metapost/drv/README b/Master/texmf-dist/doc/metapost/drv/README new file mode 100644 index 00000000000..e5d287c876f --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/README @@ -0,0 +1,21 @@ +drv.mp - derivation trees with MetaPost +version 0.93 + +Licence +lppl + +Description +drv.mp is a set of MetaPost macros for typesetting derivation trees (such as +used in sequent calculus, type inference, programming language semantics...) +NO MetaPost knowledge is needed to use these macros. + +Contents +drv.mp the main file +drv-guide.pdf a user guide attempt +doc/ the sources for drv-guide.pdf +sample/ an example of use in conjunction with the beamer class +template/ a basic set of files for your own tries +README this file + +Any feedback is welcome. +laurent.mehats@gmail.com diff --git a/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp new file mode 100644 index 00000000000..ab6b41675e2 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp @@ -0,0 +1,1727 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Structure of a MetaPost file using drv.mp +% 1. Preamble +% input drv; +% verbatimtex %&latex +% <LaTeX preamble> +% \begin{document} +% etex; +% 2. Figures +% <optional drv tunings> +% beginfig(<index>) +% <judgment & inference declarations> +% draw drv_tree; +% <optional extra MetaPost code> +% endfig; +% 3. Postamble +% end +% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% 1. Preamble +% + +input drv; + +verbatimtex %&latex + +% Any piece of code related to font selection in the preamble of +% `drv-guide.tex' (document class, font package, font selection commands ...) +% should be reported here. + +\documentclass[twoside,11pt]{article} +\usepackage[T1]{fontenc} +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage{stmaryrd} + +% Choose your favourite fonts combination (if available). +% See "http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey". +% +%\usepackage{cmbright} % CM text & CM Bright math +%\usepackage{ccfonts,eulervm} % Concrete text & Euler math +%\usepackage{ccfonts} % Concrete text & math +%\usepackage[math]{iwona} % Iwona text & math +%\usepackage[math]{kurier} % Kurier text & math +%\usepackage[math]{anttor} % Antykwa Torunska text & math +%\usepackage{kmath,kerkis} % Kerkis text & math +%\usepackage{fouriernc} % New Century Schoolbook & Fourier math +%\usepackage{pxfonts} % Palatino & pxfonts math +%\usepackage{mathpazo} % Palatino & Pazo math +%\usepackage{mathpple} % Palatino & Euler math +\usepackage[varg]{txfonts} % Times & txfonts math +%\usepackage{mathtime} % Times & Belleek math +%\usepackage{mathptmx} % Times & Symbol math +%\usepackage{mbtimes} % Omega Serif text & Omega math +%\usepackage{arev} % Arev Sans text with Arev math +%\usepackage[charter]{mathdesign} % Bitstream Charter & Math Design math +%\usepackage{comicsans} % Comic Sans text & math +%\usepackage[garamond]{mathdesign} % Garamond & Math Design math +%\usepackage{fourier} % Utopia & Fourier math +%\usepackage[utopia]{mathdesign} % Utopia & Math Design math + +\begin{document} +etex; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% 2. Figures +% + +% +% title page +% + +beginfig(100) +jgm 0 "\Gamma, \Delta, \Theta, \Pi, \Upsilon\vdash F"; + jgm 1 "\Pi\vdash (A\to D)\to E"; + jgm 2 "\Gamma, \Delta, \Theta, (A\to D)\to E, \Upsilon\vdash F"; + jgm 3 "\Gamma, \Delta, \Theta\vdash A\to D"; + jgm 4 "A, \Gamma, \Delta, \Theta\vdash D"; + jgm 5 "A, \Gamma, \Delta\vdash B\wedge C"; + jgm 6 "A, \Gamma\vdash B"; + jgm 7 "\Delta\vdash C"; + jgm 8 "B\wedge C, \Theta\vdash D"; + jgm 9 "E, \Upsilon\vdash F"; +nfr 0 (1, 2) ("\text{cut}", 1); + nfr 1 () ("\pi", 4); + nfr 2 (3, 9) ("\to_L", 1); + nfr 3 (4) ("\to_R", 1); + nfr 4 (5, 8) ("\text{cut}", 1); + nfr 5 (6, 7) ("\wedge_R", 1); + nfr 6 () ("\gamma", 2); + nfr 7 () ("\delta", 1); + nfr 8 () ("\theta", 3); + nfr 9 () ("\upsilon", 2); +draw drv_tree; +endfig; + +% +% first example +% + +beginfig(110) +jgm 0 "A\vdash B"; +jgm 1 "B\vdash C"; +jgm 2 "A\vdash C"; +nfr 0 () ("f", 1); +nfr 1 () ("g", 1); +nfr 2 (0, 1) ("\circ", 1); +draw drv_tree; +endfig; + +% +% sub-judgments +% + +beginfig(111) +jgm 0 "A", "\vdash", "B"; +nfr 0 () ("f", 1); +draw drv_tree; +endfig; + + +% +% inference line styles +% + +beginfig(120) +jgm 0 "\text{none}"; +jgm 1 "\text{simple}"; +jgm 2 "\text{double}"; +jgm 3 "\text{dotted}"; +jgm 4 "\text{dashed}"; +jgm 5 "\text{waved}"; +jgm 6 "\text{\TeX-dotted}"; +jgm 7 "\text{default}"; +nfr 0 ( ) ("\leftarrow 0", 0); +nfr 1 (0) ("\leftarrow 1", 1); +nfr 2 (1) ("\leftarrow 2", 2); +nfr 3 (2) ("\leftarrow 3", 3); +nfr 4 (3) ("\leftarrow 4", 4); +nfr 5 (4) ("\leftarrow 5", 5); +nfr 6 (5) ("\leftarrow 6", 6); +nfr 7 (6) ("\leftarrow\_", _); +draw drv_tree; +endfig; + +% +% declarations order +% + +beginfig(130) +% preorder declarations +jgm 0 "0"; + jgm 1 "00"; + jgm 2 "000"; + jgm 3 "001"; + jgm 4 "002"; + jgm 5 "01"; + jgm 6 "010"; + jgm 7 "011"; + jgm 8 "012"; + jgm 9 "02"; + jgm 10 "020"; + jgm 11 "021"; + jgm 12 "022"; +nfr 0 (1, 5, 9) ("a", _); + nfr 1 (2, 3, 4) ("b", _); + nfr 2 () ("c", _); + nfr 3 () ("d", _); + nfr 4 () ("e", _); + nfr 5 (6, 7, 8) ("f", _); + nfr 6 () ("g", _); + nfr 7 () ("h", _); + nfr 8 () ("i", _); + nfr 9 (10, 11, 12) ("j", _); + nfr 10 () ("k", _); + nfr 11 () ("l", _); + nfr 12 () ("m", _); +draw drv_tree; +endfig; + +beginfig(131) +% postorder declarations + jgm 0 "000"; + jgm 1 "001"; + jgm 2 "002"; + jgm 3 "00"; + jgm 4 "010"; + jgm 5 "011"; + jgm 6 "012"; + jgm 7 "01"; + jgm 8 "020"; + jgm 9 "021"; + jgm 10 "022"; + jgm 11 "02"; +jgm 12 "0"; + nfr 0 () ("a", _); + nfr 1 () ("b", _); + nfr 2 () ("c", _); + nfr 3 (0, 1, 2) ("d", _); + nfr 4 () ("e", _); + nfr 5 () ("f", _); + nfr 6 () ("g", _); + nfr 7 (4, 5, 6) ("h", _); + nfr 8 () ("i", _); + nfr 9 () ("j", _); + nfr 10 () ("k", _); + nfr 11 (8, 9, 10) ("l", _); +nfr 12 (3, 7, 11) ("m", _); +draw drv_tree; +endfig; + +% +% dcl +% + +beginfig(140) +dcl 0 () ("f", 1) "A\vdash B"; +dcl 1 () ("g", 1) "B\vdash C"; +dcl 2 (0, 1) ("\circ", 1) "A\vdash C"; +draw drv_tree; +endfig; + +beginfig(141) +dcl 0 () ("f", 1) "A", "\vdash", "B"; +draw drv_tree; +endfig; + +beginfig(150) +dcl 0 (1, 5, 9) ("a", _) "0"; + dcl 1 (2, 3, 4) ("b", _) "00"; + dcl 2 () ("c", _) "000"; + dcl 3 () ("d", _) "001"; + dcl 4 () ("e", _) "002"; + dcl 5 (6, 7, 8) ("f", _) "01"; + dcl 6 () ("g", _) "010"; + dcl 7 () ("h", _) "011"; + dcl 8 () ("i", _) "012"; + dcl 9 (10, 11, 12) ("j", _) "02"; + dcl 10 () ("k", _) "020"; + dcl 11 () ("l", _) "021"; + dcl 12 () ("m", _) "022"; +draw drv_tree; +endfig; + +% +% bxd +% + +beginfig(160) +dcl 0 (1, 4) ("", _) "a"; + dcl 1 (2) ("", _) "a"; + dcl 2 (3) ("", _) "a"; + dcl 3 () ("", _) "aaaaaaa"; + dcl 4 () ("", _) "aaaaa"; +draw drv_tree; +endfig; + +beginfig(161) +dcl 0 (bxd 1, 4) ("", _) "a"; + dcl 1 (2) ("", _) "a"; + dcl 2 (3) ("", _) "a"; + dcl 3 () ("", _) "aaaaaaa"; + dcl 4 () ("", _) "aaaaa"; +draw drv_tree; +endfig; + +vardef auxbox[]= + ((smin_x[@], ypart iln[ccl[@]].c+iln[ccl[@]].hg)-- + (smin_x[@], smax_y[@])-- + (smax_x[@], smax_y[@])-- + (smax_x[@], ypart iln[ccl[@]].c+iln[ccl[@]].hg)-- + cycle) shifted (0, min_clr_scl*min_clr[drv_sty]/2) +enddef; + +beginfig(162) +dcl 0 (bxd 1, 4) ("", _) "a"; + dcl 1 (2) ("", _) "a"; + dcl 2 (3) ("", _) "a"; + dcl 3 () ("", _) "aaaaaaa"; + dcl 4 () ("", _) "aaaaa"; +draw drv_tree; +draw auxbox[1] withcolor (1, 0, 0); +endfig; + +% +% mvd +% + +beginfig(170) +jgm 1 "aaa"; +jgm 2 "bbb"; +jgm 3 "ccc"; +jgm 4 "d"; +nfr 1 () ("", _); +nfr 2 () ("", _); +nfr 3 () ("", _); +nfr 4 (mvd 1 (2, 3), 2, 3) ("", _); +draw drv_tree; +endfig; + +beginfig(171) +jgm 1 "aaa"; +jgm 2 "bbb"; +jgm 3 "ccc"; +jgm 4 "d"; +nfr 1 () ("", _); +nfr 2 () ("", _); +nfr 3 () ("", _); +nfr 4 (1, mvd 2 (2, 4), 3) ("", _); +draw drv_tree; +endfig; + +beginfig(172) +jgm 1 "aaa"; +jgm 2 "bbb"; +jgm 3 "ccc"; +jgm 4 "d"; +nfr 1 () ("", _); +nfr 2 () ("", _); +nfr 3 () ("", _); +nfr 4 (1, 2, mvd 3 (2, 6)) ("", _); +draw drv_tree; +endfig; + +beginfig(180) +jgm 0 "\textsc{Size matters -- Part 1}"; +jgm 1 "\text{Here is a rather long judgment"& % string concatenation + " that I don't want to shorten.}"; +jgm 2 "\text{Will the derivation tree fit on the page?}"; +jgm 3 "\text{It does.}"; +nfr 0 () ("", 0); +nfr 1 (0) ("", 1); +nfr 2 () ("", 1); +nfr 3 (mvd 1 (2, 3), 2) ("", 1); +draw drv_tree; +endfig; + +% +% Nfr +% + +beginfig(190) +jgm 0 "a"; +jgm 1 "b"; +jgm 2 "c"; +jgm 3 "d"; +Nfr 0 () ("0", "", "", _); +Nfr 1 () ("1", "", "", _); +Nfr 2 (0, 1) ("2", "E", "", _); +Nfr 3 (2) ("3", "", "F", _); +draw drv_tree; +endfig; + +% +% Dcl +% + +beginfig(200) +Dcl 0 () ("", "", "", _) "a"; +Dcl 1 (0) ("", "", "B", _) "c"; +Dcl 2 () ("", "", "", _) "d"; +Dcl 3 (1, 2) ("", "E", "", _) "f"; +draw drv_tree; +endfig; + +% +% Mvd +% + +beginfig(210) +jgm 1 "aaa"; +jgm 2 "bbb"; +jgm 3 "ccc"; +nfr 1 () ("", _); +nfr 2 () ("", _); +nfr 3 (Mvd 1 (2, "d", "", 3), 2) ("", _); +draw drv_tree; +endfig; + +% +% drv_font_size +% + +drv_font_size "\tiny"; + +beginfig(220) +jgm 1 "a"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +Nfr 3 (1, 2) ("3", "4", "", 1); +draw drv_tree; +endfig; + +drv_font_size "\small"; + +beginfig(221) +jgm 1 "a"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +Nfr 3 (1, 2) ("3", "4", "", 1); +draw drv_tree; +endfig; + +drv_font_size "\Large"; + +beginfig(222) +jgm 1 "a"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +Nfr 3 (1, 2) ("3", "4", "", 1); +draw drv_tree; +endfig; + +drv_font_size "\normalsize"; + +% +% drv_math_style (drv, ); +% + +beginfig(230) +jgm 1 "a"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +Nfr 3 (1, 2) ("3", "4", "", 1); +draw drv_tree; +endfig; + +drv_math_style (drv, "\textstyle"); + +beginfig(231) +jgm 1 "a"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +Nfr 3 (1, 2) ("3", "4", "", 1); +draw drv_tree; +endfig; + +drv_math_style (drv, "\scriptstyle"); + +beginfig(232) +jgm 1 "a"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +Nfr 3 (1, 2) ("3", "4", "", 1); +draw drv_tree; +endfig; + +drv_math_style (drv, "\displaystyle"); + +% +% drv_math_style (jdg, ); +% + +drv_math_style (jdg, "\displaystyle"); + +beginfig(240) +jgm 1 "\bigwedge_{i\in I} A_i"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +Nfr 3 (1, 2) ("3", "4", "", 1); +draw drv_tree; +endfig; + +drv_math_style (jdg, "\textstyle"); + +beginfig(241) +jgm 1 "\bigwedge_{i\in I} A_i"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +Nfr 3 (1, 2) ("3", "4", "", 1); +draw drv_tree; +endfig; + +drv_math_style (jdg, "\scriptstyle"); + +beginfig(242) +jgm 1 "\bigwedge_{i\in I} A_i"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +Nfr 3 (1, 2) ("3", "4", "", 1); +draw drv_tree; +endfig; + +drv_math_style (jdg, "\textstyle"); + +% +% drv_math_style (ilb, ); +% + +drv_math_style (ilb, "\textstyle"); + +beginfig(250) +jgm 1 "a"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +nfr 3 (1, 2) ("3", 1); +draw drv_tree; +endfig; + +drv_math_style (ilb, "\scriptstyle"); + +beginfig(251) +jgm 1 "a"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +nfr 3 (1, 2) ("3", 1); +draw drv_tree; +endfig; + +drv_math_style (ilb, "\scriptscriptstyle"); + +beginfig(252) +jgm 1 "a"; +jgm 2 "b"; +jgm 3 "c"; +nfr 1 () ("1", 1); +nfr 2 () ("2", 1); +nfr 3 (1, 2) ("3", 1); +draw drv_tree; +endfig; + +drv_math_style (ilb, "\scriptstyle"); + +% +% drv_scale (clr, ); +% + +drv_scale (clr, 0); + +beginfig(260) +dcl 1 () ("", 1) "\Bigl(a\Bigr)"; +dcl 2 (1) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (clr, 1); + +beginfig(261) +dcl 1 () ("", 1) "\Bigl(a\Bigr)"; +dcl 2 (1) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (clr, 2.5); + +beginfig(262) +dcl 1 () ("", 1) "\Bigl(a\Bigr)"; +dcl 2 (1) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (clr, 4); + +beginfig(263) +dcl 1 () ("", 1) "\Bigl(a\Bigr)"; +dcl 2 (1) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (clr, 1); + +% +% drv_scale (prm, ); +% + +drv_scale (prm, 0); + +beginfig(270) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (prm, 1); + +beginfig(271) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (prm, 2.5); + +beginfig(272) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (prm, 4); + +beginfig(273) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (prm, 1); + +% +% drv_scale (jgm, ); +% + +drv_scale (jgm, 0); + +beginfig(280) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (jgm, 1); + +beginfig(281) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (jgm, 2.5); + +beginfig(282) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (jgm, 4); + +beginfig(283) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (jgm, 1); + +% +% drv_scale (ilb, ); +% + +drv_scale (ilb, 0); + +beginfig(290) +dcl 1 () ("b", 1) "a"; +dcl 2 () ("b", 1) "a"; +dcl 3 (1, 2) ("b", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (ilb, 1); + +beginfig(291) +dcl 1 () ("b", 1) "a"; +dcl 2 () ("b", 1) "a"; +dcl 3 (1, 2) ("b", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (ilb, 2.5); + +beginfig(292) +dcl 1 () ("b", 1) "a"; +dcl 2 () ("b", 1) "a"; +dcl 3 (1, 2) ("b", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (ilb, 4); + +beginfig(293) +dcl 1 () ("b", 1) "a"; +dcl 2 () ("b", 1) "a"; +dcl 3 (1, 2) ("b", 1) "a"; +draw drv_tree; +endfig; + +drv_scale (ilb, 1); + +% +% drv_junction_style +% + +path azerty[]; + +drv_junction_style 0; + +beginfig(300) +dcl 1 () ("", 1) "aaaaaaaaaaaa"; +dcl 2 (1) ("", 1) "a"; +dcl 3 (2) ("", 1) "a"; +dcl 4 (3) ("", 1) "a"; +dcl 5 (4) ("", 1) "aaaaaa"; +dcl 6 () ("", 1) "aaaaaa"; +dcl 7 (6) ("", 1) "a"; +dcl 8 (7) ("", 1) "a"; +dcl 9 (5, 8) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_junction_style 1; + +beginfig(301) +dcl 1 () ("", 1) "aaaaaaaaaaaa"; +dcl 2 (1) ("", 1) "a"; +dcl 3 (2) ("", 1) "a"; +dcl 4 (3) ("", 1) "a"; +dcl 5 (4) ("", 1) "aaaaaa"; +dcl 6 () ("", 1) "aaaaaa"; +dcl 7 (6) ("", 1) "a"; +dcl 8 (7) ("", 1) "a"; +dcl 9 (5, 8) ("", 1) "a"; +draw drv_tree; +draw auxbox[8] withcolor .9(1, 1, 1); +endfig; + +drv_junction_style 2; + +beginfig(302) +dcl 1 () ("", 1) "aaaaaaaaaaaa"; +dcl 2 (1) ("", 1) "a"; +dcl 3 (2) ("", 1) "a"; +dcl 4 (3) ("", 1) "a"; +dcl 5 (4) ("", 1) "aaaaaa"; +dcl 6 () ("", 1) "aaaaaa"; +dcl 7 (6) ("", 1) "a"; +dcl 8 (7) ("", 1) "a"; +dcl 9 (5, 8) ("", 1) "a"; +draw drv_tree; +draw auxbox[5] withcolor .9(1, 1, 1); +draw auxbox[8] withcolor .9(1, 1, 1); +endfig; + +drv_junction_style 1; + +% +% drv_alignment_style +% + +drv_alignment_style l; + +beginfig(310) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +dcl 4 () ("", 1) "a"; +dcl 5 () ("", 1) "a"; +dcl 6 (4, 5) ("", 1) "a"; +dcl 7 (3, 6) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_alignment_style c; + +beginfig(311) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +dcl 4 () ("", 1) "a"; +dcl 5 () ("", 1) "a"; +dcl 6 (4, 5) ("", 1) "a"; +dcl 7 (3, 6) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_alignment_style r; + +beginfig(312) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +dcl 4 () ("", 1) "a"; +dcl 5 () ("", 1) "a"; +dcl 6 (4, 5) ("", 1) "a"; +dcl 7 (3, 6) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_alignment_style c; + +% +% drv_labels_position +% + +drv_labels_position l; + +beginfig(320) +dcl 1 () ("b", 1) "a"; +dcl 2 () ("b", 1) "a"; +dcl 3 (1, 2) ("b", 1) "a"; +draw drv_tree; +endfig; + +drv_labels_position r; + +beginfig(321) +dcl 1 () ("b", 1) "a"; +dcl 2 () ("b", 1) "a"; +dcl 3 (1, 2) ("b", 1) "a"; +draw drv_tree; +endfig; + +% +% drv_roots_position +% + +drv_roots_position t; + +beginfig(330) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +dcl 4 () ("", 1) "a"; +dcl 5 () ("", 1) "a"; +dcl 6 (4, 5) ("", 1) "a"; +dcl 7 (3, 6) ("", 1) "a"; +draw drv_tree; +drv_axis (iln, 3); +endfig; + +drv_roots_position b; + +beginfig(331) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +dcl 4 () ("", 1) "a"; +dcl 5 () ("", 1) "a"; +dcl 6 (4, 5) ("", 1) "a"; +dcl 7 (3, 6) ("", 1) "a"; +draw drv_tree; +endfig; + +% +% drv_axis_reference +% + +beginfig(340) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_axis_reference jdg; + +beginfig(341) +dcl 1 () ("", 1) "a"; +dcl 2 () ("", 1) "a"; +dcl 3 (1, 2) ("", 1) "a"; +draw drv_tree; +endfig; + +drv_axis_reference iln; + +% +% drv_left_delimiter +% + +drv_left_delimiter "("; + +beginfig(350) +dcl 1 () ("", 1) "a"; +Dcl 2 (1) ("", "", "B", 1) "c"; +dcl 3 () ("", 1) "d"; +Dcl 4 (2, 3) ("", "E", "", 1) "f"; +draw drv_tree; +endfig; + +drv_left_delimiter "\lfloor"; + +beginfig(351) +dcl 1 () ("", 1) "a"; +Dcl 2 (1) ("", "", "B", 1) "c"; +dcl 3 () ("", 1) "d"; +Dcl 4 (2, 3) ("", "E", "", 1) "f"; +draw drv_tree; +endfig; + +drv_left_delimiter "."; + +beginfig(352) +dcl 1 () ("", 1) "a"; +Dcl 2 (1) ("", "", "B", 1) "c"; +dcl 3 () ("", 1) "d"; +Dcl 4 (2, 3) ("", "E", "", 1) "f"; +draw drv_tree; +endfig; + +drv_left_delimiter "\lbrace"; + +% +% drv_right_delimiter +% + +drv_right_delimiter "\rangle"; + +beginfig(360) +dcl 1 () ("", 1) "a"; +Dcl 2 (1) ("", "", "B", 1) "c"; +dcl 3 () ("", 1) "d"; +Dcl 4 (2, 3) ("", "E", "", 1) "f"; +draw drv_tree; +endfig; + +drv_right_delimiter "\uparrow"; + +beginfig(361) +dcl 1 () ("", 1) "a"; +Dcl 2 (1) ("", "", "B", 1) "c"; +dcl 3 () ("", 1) "d"; +Dcl 4 (2, 3) ("", "E", "", 1) "f"; +draw drv_tree; +endfig; + +drv_right_delimiter "."; + +beginfig(362) +dcl 1 () ("", 1) "a"; +Dcl 2 (1) ("", "", "B", 1) "c"; +dcl 3 () ("", 1) "d"; +Dcl 4 (2, 3) ("", "E", "", 1) "f"; +draw drv_tree; +endfig; + +drv_right_delimiter "\rbrace"; + +% +% drv_box_mode +% + +drv_box_mode on; + +beginfig(370) +dcl 0 () ("", 1) "aaaaa"; +dcl 1 () ("", 1) "aaaaaaa"; +dcl 2 (1) ("", 1) "a"; +dcl 3 (2) ("", 1) "a"; +dcl 4 (0, 3) ("", 1) "a"; +draw drv_tree; +endfig; + +beginfig(371) +dcl 0 () ("", 1) "aaaaa"; +dcl 1 () ("", 1) "aaaaaaa"; +dcl 2 (1) ("", 1) "a"; +dcl 3 (2) ("", 1) "a"; +dcl 4 (0, 3) ("", 1) "a"; +draw drv_tree; +for idx=0, 1, 2, 3: + draw auxbox[idx] withcolor (1, 0, 0); +endfor +endfig; + +drv_box_mode off; + +beginfig(372) +dcl 0 () ("", 1) "aaaaa"; +dcl 1 () ("", 1) "aaaaaaa"; +dcl 2 (1) ("", 1) "a"; +dcl 3 (2) ("", 1) "a"; +dcl 4 (0, 3) ("", 1) "a"; +draw drv_tree; +endfig; + +% +% drv_fraction_mode +% + +beginfig(380) +jgm 0 "\overbrace{A, \Gamma\vdash B}"; +jgm 1 "B, \Delta\vdash C"; +jgm 2 "A, \Gamma, \Delta\vdash C"; +jgm 3 "\Gamma, \Delta\vdash A\to C"; +nfr 0 () ("", 0); +nfr 1 () ("", 1); +nfr 2 (0, 1) ("\text{cut}", 1); +nfr 3 (2) ("\to_R", 1); +draw drv_tree; +endfig; + +drv_fraction_mode off; + +beginfig(381) +jgm 0 "\overbrace{A, \Gamma\vdash B}"; +jgm 1 "B, \Delta\vdash C"; +jgm 2 "A, \Gamma, \Delta\vdash C"; +jgm 3 "\Gamma, \Delta\vdash A\to C"; +nfr 0 () ("", 0); +nfr 1 () ("", 1); +nfr 2 (0, 1) ("\text{cut}", 1); +nfr 3 (2) ("\to_R", 1); +draw drv_tree; +endfig; + +drv_fraction_mode on; + +beginfig(382) +jgm 0 "\overbrace{A, \Gamma\vdash B}"; +jgm 1 "B, \Delta\vdash C"; +jgm 2 "A, \Gamma, \Delta\vdash C"; +jgm 3 "\Gamma, \Delta\vdash A\to C"; +nfr 0 () ("", 1); +nfr 1 () ("", 1); +nfr 2 (0, 1) ("\text{cut}", 1); +nfr 3 (2) ("\to_R", 1); +draw drv_tree; +unfill bbox iln[0]; +draw iln[0] withcolor (1, 0, 0); +endfig; + +% +% drv_proof_mode +% + +drv_proof_mode on; + +beginfig(390) +jgm 0 "A", "\vdash", "A"; +jgm 1 "B", "\vdash", "B"; +jgm 2 "A", ",", "A", "\multimap", "B", "\vdash", "B"; +jgm 3 "A", "\multimap", "B", "\vdash", "A", "\multimap", "B"; +nfr 0 () ("1", 1); +nfr 1 () ("1", 1); +nfr 2 (0, 1) ("\multimap_{L}", 1); +nfr 3 (2) ("\multimap_{R}", 1); +draw drv_tree; +endfig; + +drv_proof_mode off; + +beginfig(391) +jgm 0 "A", "\vdash", "A"; +jgm 1 "B", "\vdash", "B"; +jgm 2 "A", ",", "A", "\multimap", "B", "\vdash", "B"; +jgm 3 "A", "\multimap", "B", "\vdash", "A", "\multimap", "B"; +nfr 0 () ("1", 1); +nfr 1 () ("1", 1); +nfr 2 (0, 1) ("\multimap_{L}", 1); +nfr 3 (2) ("\multimap_{R}", 1); +draw drv_tree; +endfig; + +% +% a fraction +% + +drv_math_style (drv, "\textstyle"); +drv_scale (jgm, 0); + +beginfig(400) +dcl 0 ( ) ("", 0) "\gamma"; +dcl 1 (0) ("", 1) "\delta"; +draw drv_tree; +endfig; + +drv_math_style (drv, "\displaystyle"); +drv_scale (jgm, 1); + +% +% drv_bbox +% + +beginfig(410) +dcl 0 (1, 5) ("", _) "a"; + dcl 1 (2, 3, 4) ("", _) "b"; + dcl 2 () ("", _) "c"; + dcl 3 () ("", _) "d"; + dcl 4 () ("", _) "e"; + dcl 5 () ("", _) "f"; +fill drv_bbox 1 withcolor (255, 230, 205)/255; % rgb color +draw drv_tree; +endfig; + +beginfig(411) +dcl 0 (bxd 1, 5) ("", _) "a"; + dcl 1 (2, 3, 4) ("", _) "b"; + dcl 2 () ("", _) "c"; + dcl 3 () ("", _) "d"; + dcl 4 () ("", _) "e"; + dcl 5 () ("", _) "f"; +fill drv_bbox 1 withcolor (255, 230, 205)/255; % rgb color +draw drv_tree; +endfig; + +% +% drv_axis +% + +beginfig(420) +Dcl 0 ( ) ("", "", "", _) "a"; +Dcl 1 (0) ("", "{}", "", _) "b"; +draw drv_tree; +drv_axis (iln, 0); +endfig; + +beginfig(421) +Dcl 0 ( ) ("", "", "", _) "a"; +Dcl 1 (0) ("", "{}", "", _) "b"; +draw drv_tree; +drv_axis (jdg, 1); +endfig; + +beginfig(422) +Dcl 0 ( ) ("", "", "", _) "a"; +Dcl 1 (0) ("", "{}", "", _) "b"; +draw drv_tree; +drv_axis (dlm, 1); +endfig; + +% +% NFR +% + +beginfig(430) +jgm 0 "a"; +NFR 0 () ("1", "2", "3", "4", _, _, _); +draw drv_tree; +endfig; + +% +% DCL +% + +beginfig(440) +DCL 0 () ("1", "", "", "", _, _, _) "a"; +DCL 1 () ("", "2", "", "", _, _, _) "b"; +DCL 2 (0, 1) ("", "", "3", "", _, _, _) "c"; +DCL 3 (2) ("", "", "", "4", _, _, _) "d"; +draw drv_tree; +endfig; + +% +% MVD +% + +beginfig(450) +jgm 0 "aaaaaa"; +jgm 1 "aaa"; +jgm 2 "a"; +jgm 3 "aaaaaaaaa"; +jgm 4 "a"; +nfr 0 () ("", _); +NFR 1 () ("", "", "", "", _, _, _); +nfr 2 (MVD 0 (2, "A", "", l, 3), 1) ("", _); +nfr 3 () ("", _); +nfr 4 (2, MVD 3 (5, "", "A", r, 4)) ("", _); +draw drv_tree; +endfig; + +beginfig(460) +jgm 0 "\textsc{Size matters -- Part 2}"; +jgm 1 "\text{Here is an even longer judgment"& + " that I don't want to shorten either.}"; +jgm 2 "\text{This time I'm pretty sure that the"& + " derivation tree won't fit on the page.}"; +jgm 3 "\text{It does! Amazing.}"; +nfr 0 () ("", 0); +nfr 1 (0) ("", 1); +nfr 2 () ("", 1); +nfr 3 (MVD 1 (2, "", "", l, 3), 2) ("", 1); +draw drv_tree; +endfig; + +% +% Components and central points +% + +drv_font_size "\large"; + +beginfig(470) % components +DCL 6 () ("", "", "", "", _, _, 0) "0"; +DCL 7 (6) ("(1)", "(2)", "(3)", "(4)", _, _, 1) "A", "B"; +drv_freeze; % usually called by drv_tree +draw jdg[6]; % judgment 0 +draw sbj[7][0] withcolor (0, 0, 1); % sub-judgment A +draw sbj[7][1] withcolor (0, 1, 0); % sub-judgment B +draw l_ilb[7] withcolor (0, 1, 1); % left inference label (1) +draw r_ilb[7] withcolor (1, 0, 0); % right inference label (2) +draw l_dlb[7] withcolor (1, 0, 1); % left delimiter label (3) +draw r_dlb[7] withcolor (1, 1, 0); % right delimiter label (4) +draw l_dlm[7]; % left delimiter +draw iln[7]; % inference line +draw r_dlm[7]; % right delimiter +endfig; + +beginfig(471) % central points +DCL 6 () ("", "", "", "", _, _, 0) "0"; +DCL 7 (6) ("(1)", "(2)", "(3)", "(4)", _, _, 1) "A", "B"; +pickup pencircle scaled 2.5; +draw drv_tree withcolor .75(1, 1, 1); +draw jdg[6].c; % judgment 0 +draw sbj[7][0].c withcolor (0, 0, 1); % sub-judgment A +draw sbj[7][1].c withcolor (0, 1, 0); % sub-judgment B +draw l_ilb[7].c withcolor (0, 1, 1); % left inference label (1) +draw r_ilb[7].c withcolor (1, 0, 0); % right inference label (2) +draw l_dlb[7].c withcolor (1, 0, 1); % left delimiter label (3) +draw r_dlb[7].c withcolor (1, 1, 0); % right delimiter label (4) +draw l_dlm[7].c; % left delimiter +draw iln[7].c; % inference line +draw r_dlm[7].c; % right delimiter +endfig; + +drv_font_size "\normalsize"; + +% +% Dimensions +% + +vardef aux_drawdblarrow expr pth= +save ah; +path ah; +ah:=ahlength*(dir (180-ahangle/2))--(0, 0)-- + ahlength*(dir (180+ahangle/2)); +if direction infinity of pth<>(0, 0): + draw pth; + draw ah rotated (angle (direction infinity of pth)) + shifted (point infinity of pth); + draw ah rotated (180+angle (direction -infinity of pth)) + shifted (point -infinity of pth); +fi +enddef; + +drv_box + "jdg_ma[]", + "jdg_cp[]", + "jdg_hg[]", + "jdg_dp[]", + "iln_cp[]", + "n_hg", + "d_dp"; +for idx=0, 1: + box_init jdg_ma[idx](mth_tex[1]"\textit{math axis}"); + box_init jdg_cp[idx](mth_tex[2]"\texttt{jdg["&decimal idx&"].c}"); + box_init jdg_hg[idx](mth_tex[1]"\texttt{jdg["&decimal idx&"].hg}"); + box_init jdg_dp[idx](mth_tex[1]"\texttt{jdg["&decimal idx&"].dp}"); + box_init iln_cp[idx](mth_tex[2]"\texttt{iln["&decimal idx&"].c}"); +endfor +box_init n_hg(mth_tex[1]"\texttt{num\_hg}"); +box_init d_dp(mth_tex[1]"\texttt{den\_dp}"); + +drv_font_size "\fontsize{95}{0}"; + +beginfig(480) +dcl 0 () ("", 0) "\gamma"; +dcl 1 (0) ("", 1) "\delta"; +draw drv_tree withcolor .75*background; +interim linejoin:=beveled; +interim ahangle:=60; +lref[0]:=xpart iln[1].l-20pt; +lref[1]:=xpart iln[1].l-10pt; +lref[2]:=xpart iln[1].l-25pt; +rref[0]:=xpart iln[1].r+20pt; +rref[1]:=xpart iln[1].r+10pt; +rref[2]:=xpart iln[1].r+25pt; +for idx=0, 1: + forsuffixes sfx=l, c ,r: + draw jdg[idx].sfx withpen pencircle scaled 2.5; + endfor + lx[idx]:=xpart jdg[idx].l; + rx[idx]:=xpart jdg[idx].r; + ty[idx]:=ypart jdg[idx].c+jdg[idx].hg; + cy[idx]:=ypart jdg[idx].c; + by[idx]:=ypart jdg[idx].c+jdg[idx].dp; + for pth= + (lx[idx], ty[idx])--(rref[0], ty[idx]), + (lref[0], cy[idx])--(rref[0], cy[idx]), + (lx[idx], by[idx])--(rref[0], by[idx]), + (lx[idx], ty[idx])--(lx[idx], by[idx]), + (rx[idx], ty[idx])--(rx[idx], by[idx]): + draw pth dashed evenly scaled .5; + endfor + for pth= + (rref[1], ty[idx])--(rref[1], cy[idx]), + (rref[1], cy[idx])--(rref[1], by[idx]): + aux_drawdblarrow pth; + endfor + jdg_ma[idx].r=(lref[2], cy[idx]); + jdg_cp[idx].c=jdg[idx].c shifted (0, -7.5pt); + jdg_hg[idx].l=(rref[2], (ty[idx]+cy[idx])/2); + jdg_dp[idx].l=(rref[2], (cy[idx]+by[idx])/2); + forsuffixes sfx=jdg_ma, jdg_cp, jdg_hg, jdg_dp: + box_freeze sfx[idx]; + draw sfx[idx]; + endfor +endfor +draw iln[1].c withpen pencircle scaled 2.5; +iln_cp[1].c=iln[1].c shifted (0, -7.5pt); +box_freeze iln_cp[1]; +draw iln_cp[1]; +iln_y:=ypart iln[1].c; +draw (lref[0], iln_y)--(rref[0], iln_y) dashed evenly scaled .5; +aux_drawdblarrow (lref[1], cy[0])--(lref[1], iln_y); +aux_drawdblarrow (lref[1], iln_y)--(lref[1], cy[1]); +n_hg.r=(lref[2], (cy[0]+iln_y)/2); +d_dp.r=(lref[2], (iln_y+cy[1])/2); +forsuffixes sfx=n_hg, d_dp: + box_freeze sfx; + draw sfx; +endfor +endfig; + +drv_font_size "\normalsize"; + +% +% drv_styled +% + +beginfig(490) +jgm 4 "A", "\vdash", "A"; +jgm 5 "B", "\vdash", "B"; +jgm 6 "A", ",", "A", "\multimap", "B", "\vdash", "B"; +jgm 7 "A", "\multimap", "B", "\vdash", "A", "\multimap", "B"; +nfr 4 () ("1", _); +nfr 5 () ("1", _); +nfr 6 (4, 5) ("\multimap_{L}", _); +nfr 7 (6) ("\multimap_{R}", _); +drv_freeze; +draw (sbj[7][2].c shifted (0, -num_hg) .. + sbj[7][2].c {up} .. + sbj[6][4].c .. + sbj[5][0].c .. tension 1.05 .. + sbj[5][2].c .. + sbj[6][6].c .. + sbj[7][6].c {down} .. + sbj[7][6].c shifted (0, -num_hg)) +drv_styled 2 withcolor (1, 0, 0); +draw drv_tree; +endfig; + +% +% ``User specified'' junction style +% + +beginfig(500) +jgm 0 "{\cdot}"; +jgm 1 "{\cdot}"; +jgm 2 "\text{You may check that the distance"& + " between the two dots above is 5 cm.}"; +NFR 0 () ("", "", "", "", _, _, _); +NFR 1 () ("", "", "", "", _, _, _); +NFR 2 (0, 1) ("", "", "", "", 3, _, _); % caution: 3 +xpart jdg[1].c=xpart jdg[0].c+5cm; +draw drv_tree; +endfig; + +% +% ``User specified'' alignment style +% + +beginfig(510) % "\vdash": +jgm 0 "B, A, \Gamma", "\vdash", "C"; % sbj[0][1] +jgm 1 "A, \Gamma", "\vdash", "B\multimap C"; % sbj[1][1] +jgm 2 "\Gamma", "\vdash", "A\multimap(B\multimap C)"; % sbj[2][1] +NFR_opt 0 () () () (_, _, 0); +NFR_opt 1 (0) ("\multimap_R") () (_, u, 1); % caution: u +NFR_opt 2 (1) ("\multimap_R") () (_, u, 1); % caution: u +xpart sbj[1][1].c=xpart sbj[0][1].c; +xpart sbj[2][1].c=xpart sbj[1][1].c; +draw drv_tree; +endfig; + +beginfig(511) % "\vdash": +jgm 0 "B, A, \Gamma", "\vdash", "C"; % sbj[0][1] +jgm 1 "A, \Gamma", "\vdash", "B\multimap C"; % sbj[1][1] +jgm 2 "\Gamma", "\vdash", "A\multimap(B\multimap C)"; % sbj[2][1] +NFR_opt 0 () () () (_, _, 0); +NFR_opt 1 (0) ("\multimap_R") () (_, u, 1); % caution: u +NFR_opt 2 (1) ("\multimap_R") () (_, u, 1); % caution: u +xpart sbj[1][1].l=xpart sbj[0][1].r; +xpart sbj[2][1].l=xpart sbj[1][1].r; +draw drv_tree; +endfig; + +% +% debugging +% + +beginfig(520) +jgm 0 "A\vdash B"; +jgm 1 "B\vdash C"; +jgm 2 "A\vdash C"; +jgm 3 "C\vdash D"; +jgm 4 "A\vdash D"; +nfr 0 () ("f", _); +nfr 1 () ("g", _); +nfr 2 (0, 1) ("\circ", _); +nfr 3 () ("h", _); +nfr 4 (2, 3) ("\circ", _); +draw drv_tree; +endfig; + +% +% example - Restall +% + +string Lor, Ror[], Land[], Rand; +Lor:="\vee L"; +Ror1:="\vee R_1"; +Ror2:="\vee R_2"; +Land1:="\wedge L_1"; +Land2:="\wedge L_2"; +Rand:="\wedge R"; + +beginfig(530) +jgm 0 "p\wedge(q\vee(r_1\wedge r_2))\vdash p\wedge(q\vee(r_1\wedge r_2))"; + jgm 1 "p\wedge(q\vee(r_1\wedge r_2))\vdash p"; + jgm 2 "p\vdash p"; + jgm 3 "p\wedge(q\vee(r_1\wedge r_2))\vdash q\vee(r_1\wedge r_2)"; + jgm 4 "q\vee(r_1\wedge r_2)\vdash q\vee(r_1\wedge r_2)"; + jgm 5 "q\vdash q\vee(r_1\wedge r_2)"; + jgm 6 "q\vdash q"; + jgm 7 "r_1\wedge r_2\vdash q\vee(r_1\wedge r_2)"; + jgm 8 "r_1\wedge r_2\vdash r_1\wedge r_2"; + jgm 9 "r_1\wedge r_2\vdash r_1"; + jgm 10 "r_1\vdash r_1"; + jgm 11 "r_1\wedge r_2\vdash r_2"; + jgm 12 "r_2\vdash r_2"; +nfr 0 (1, 3) (Rand, 1); + nfr 1 (2) (Land1, 1); + nfr 2 () ("", 0); + nfr 3 (bxd 4) (Land2, 1); % fig. 531 -> nfr 3 (mvd 4 (1, 3)) + nfr 4 (5, 7) (Lor, 1); % fig. 531 -> Nfr + nfr 5 (6) (Ror1, 1); + nfr 6 () ("", 0); + nfr 7 (bxd 8) (Ror2, 1); % fig. 531 -> nfr 7 (mvd 8 (1, 3)) + nfr 8 (9, 11) (Rand, 1); % fig. 531 -> Nfr + nfr 9 (10) (Land1, 1); + nfr 10 () ("", 0); + nfr 11 (12) (Land2, 1); + nfr 12 () ("", 0); +fill drv_bbox 4 withcolor (255, 230, 205)/255; +fill drv_bbox 8 withcolor (236, 211, 185)/255; +draw drv_tree; +endfig; + +beginfig(531) +jgm 0 "p\wedge(q\vee(r_1\wedge r_2))\vdash p\wedge(q\vee(r_1\wedge r_2))"; + jgm 1 "p\wedge(q\vee(r_1\wedge r_2))\vdash p"; + jgm 2 "p\vdash p"; + jgm 3 "p\wedge(q\vee(r_1\wedge r_2))\vdash q\vee(r_1\wedge r_2)"; + jgm 4 "q\vee(r_1\wedge r_2)\vdash q\vee(r_1\wedge r_2)"; + jgm 5 "q\vdash q\vee(r_1\wedge r_2)"; + jgm 6 "q\vdash q"; + jgm 7 "r_1\wedge r_2\vdash q\vee(r_1\wedge r_2)"; + jgm 8 "r_1\wedge r_2\vdash r_1\wedge r_2"; + jgm 9 "r_1\wedge r_2\vdash r_1"; + jgm 10 "r_1\vdash r_1"; + jgm 11 "r_1\wedge r_2\vdash r_2"; + jgm 12 "r_2\vdash r_2"; +nfr 0 (1, 3) (Rand, 1); + nfr 1 (2) (Land1, 1); + nfr 2 () ("", 0); + nfr 3 (mvd 4 (1, 3)) (Land2, 1); + Nfr 4 (5, 7) (Lor, "\text{Id\,}_{q\vee(r_1\wedge r_2)}", "", 1); + nfr 5 (6) (Ror1, 1); + nfr 6 () ("", 0); + nfr 7 (mvd 8 (1, 3)) (Ror2, 1); + Nfr 8 (9, 11) (Rand, "\text{Id\,}_{r_1\wedge r_2}", "", 1); + nfr 9 (10) (Land1, 1); + nfr 10 () ("", 0); + nfr 11 (12) (Land2, 1); + nfr 12 () ("", 0); +fill drv_bbox 4 withcolor (255, 230, 205)/255; +fill drv_bbox 8 withcolor (236, 211, 185)/255; +draw drv_tree; +endfig; + +% +% example - Roegel +% + +drv_junction_style 0; +drv_scale (jdg, 0.85); +drv_scale (prm, 0.85); + +vardef mix[]= + "\textit{mix}("&(decimal @)&")" +enddef; + +beginfig(540) +jgm 0 "\Gamma_A, \Gamma'\vdash\Delta, \Delta'_A"; + jgm 1 "\Gamma_A, \Gamma', \Gamma_A, \Gamma', \Gamma_A, \Gamma'\vdash"& + "\Delta, \Delta'_A, \Delta, \Delta'_A, \Delta, \Delta'_A"; + jgm 2 "\Gamma_A, \Gamma', \Gamma_A\vdash"& % a space character is + " C, \Delta, \Delta'_A, \Delta, \Delta'_A"; % needed before 'C'! + jgm 3 "\Gamma_A, \Gamma'\vdash B, C, \Delta, \Delta'_A"; + jgm 4 "\Gamma, B\vee C\vdash \Delta"; + jgm 5 "\Gamma, B\vdash \Delta"; + jgm 6 "\Pi_1"; + jgm 7 "\Gamma, C\vdash \Delta"; + jgm 8 "\Pi_2"; + jgm 9 "\Gamma'\vdash B, C, \Delta'"; + jgm 10 "\Pi_3"; + jgm 11 "\Gamma_A, \Gamma', B\vdash\Delta, \Delta'_A"; + jgm 12 "\Gamma, B\vdash \Delta"; + jgm 13 "\Pi_1"; + jgm 14 "\Gamma'\vdash B\vee C, \Delta'"; + jgm 15 "\Gamma'\vdash B, C, \Delta'"; + jgm 16 "\Pi_3"; + jgm 17 "\Gamma_A, \Gamma', C\vdash\Delta, \Delta'_A"; + jgm 18 "\Gamma, C\vdash \Delta"; + jgm 19 "\Pi_2"; + jgm 20 "\Gamma'\vdash B\vee C, \Delta'"; + jgm 21 "\Gamma'\vdash B, C, \Delta'"; + jgm 22 "\Pi_3"; +nfr 0 (1) ("\text{contr$_g$, contr$_d$}", 1); + nfr 1 (2, 17) (mix5, 1); + nfr 2 (mvd 3 (5, 6), 11) (mix3 , 1); + nfr 3 (4, 9) (mix1, 1); + nfr 4 (5, 7) ("\vee_g", 1); + nfr 5 (mvd 6 (1, 6)) ("", 0); + nfr 6 () ("", 0); + nfr 7 (mvd 8 (1, 6)) ("", 0); + nfr 8 () ("", 0); + nfr 9 (mvd 10 (1, 6)) ("", 0); + nfr 10 () ("", 0); + nfr 11 (12, 14) ("", 1); + nfr 12 (mvd 13 (1, 6)) ("", 0); + nfr 13 () ("", 0); + nfr 14 (15) ("", 1); + nfr 15 (mvd 16 (1, 6)) ("", 0); + nfr 16 () ("", 0); + nfr 17 (18, 20) (mix4, 1); + nfr 18 (mvd 19 (1, 6)) ("", 0); + nfr 19 () ("", 0); + nfr 20 (21) ("\vee_d", 1); + nfr 21 (mvd 22 (1, 6)) ("", 0); + nfr 22 () ("", 0); +draw drv_tree; +endfig; + +drv_junction_style 1; +drv_scale (jdg, 1); +drv_scale (prm, 1); + +% +% example - Lutz +% + +drv_math_style (ilb, "\textstyle"); +drv_labels_position (ilb, l); +drv_scale (clr, 1.5); + +string neg, par, otm; +neg:="^\bot"; +par:="\mathbin{\bindnasrepma}"; % from stmaryrd.sty +otm:="\otimes"; + +beginfig(550) + % 0 1 2 3 4 5 6 7 8 9 +jgm 0 "a", neg, par, "a"; +jgm 1 "a", neg, par, "(", "a", otm, "(", "a", par, "a", neg, ")", ")"; +jgm 2 "a", neg, par, "(", "a", otm, "a", ")", par, "a", neg; +jgm 3 "a", neg, par, "(", "a", otm, "a", ")", par, "(", + "(", "a", par, "a", neg, ")", otm, "a", neg, ")"; +jgm 4 "a", neg, par, "(", "a", otm, "a", ")", par, "a", + par, "(", "a", neg, otm, "a", neg, ")"; +nfr 0 ( ) ("\textsf{id}", 1); +nfr 1 (0) ("\textsf{id}", 1); +nfr 2 (1) ("\textsf{s}", 1); +nfr 3 (2) ("\textsf{id}", 1); +nfr 4 (3) ("\textsf{s}", 1); +drv_freeze; +drawoptions (withpen drv_pen scaled 2 withcolor (255, 94, 94)/255); +draw + sbj[4][12].c shifted (0, -num_hg) .. {up} + sbj[4][12].c .. + sbj[3][13].c .. tension .9 .. + sbj[3][11].c .. + sbj[4][9].c {down} .. + sbj[4][9].c shifted (0, -num_hg); +draw + sbj[4][15].c shifted (0, -num_hg) .. {up} + sbj[4][15].c .. + sbj[3][17].c .. tension 1.2 .. + sbj[2][9].c .. + sbj[1][9].c {up} .. tension 1.5.. {down} + sbj[1][7].c .. + sbj[2][6].c .. tension 1.2 .. + sbj[3][6].c .. + sbj[4][6].c {down} .. + sbj[4][6].c shifted (0, -num_hg); +draw + sbj[4][0].c shifted (0, -num_hg) .. {up} + sbj[4][0].c .. + sbj[3][0].c .. tension 1.2 .. + sbj[2][0].c .. + sbj[1][0].c .. tension 1.2 .. + sbj[0][0].c {up} .. tension 1.8.. {down} + sbj[0][3].c .. tension 1.2 .. + sbj[1][4].c .. + sbj[2][4].c .. tension 1.2 .. + sbj[3][4].c .. + sbj[4][4].c {down} .. + sbj[4][4].c shifted (0, -num_hg); +drawoptions (); +draw drv_tree; % fig. 551 -> draw jdg[4]; +endfig; + +beginfig(551) + % 0 1 2 3 4 5 6 7 8 9 +jgm 0 "a", neg, par, "a"; +jgm 1 "a", neg, par, "(", "a", otm, "(", "a", par, "a", neg, ")", ")"; +jgm 2 "a", neg, par, "(", "a", otm, "a", ")", par, "a", neg; +jgm 3 "a", neg, par, "(", "a", otm, "a", ")", par, "(", + "(", "a", par, "a", neg, ")", otm, "a", neg, ")"; +jgm 4 "a", neg, par, "(", "a", otm, "a", ")", par, "a", + par, "(", "a", neg, otm, "a", neg, ")"; +nfr 0 ( ) ("\textsf{id}", 1); +nfr 1 (0) ("\textsf{id}", 1); +nfr 2 (1) ("\textsf{s}", 1); +nfr 3 (2) ("\textsf{id}", 1); +nfr 4 (3) ("\textsf{s}", 1); +drv_freeze; +drawoptions (withpen drv_pen scaled 2 withcolor (255, 94, 94)/255); +draw + sbj[4][12].c shifted (0, -num_hg) .. {up} + sbj[4][12].c .. + sbj[3][13].c .. tension .9 .. + sbj[3][11].c .. + sbj[4][9].c {down} .. + sbj[4][9].c shifted (0, -num_hg); +draw + sbj[4][15].c shifted (0, -num_hg) .. {up} + sbj[4][15].c .. + sbj[3][17].c .. tension 1.2 .. + sbj[2][9].c .. + sbj[1][9].c {up} .. tension 1.5.. {down} + sbj[1][7].c .. + sbj[2][6].c .. tension 1.2 .. + sbj[3][6].c .. + sbj[4][6].c {down} .. + sbj[4][6].c shifted (0, -num_hg); +draw + sbj[4][0].c shifted (0, -num_hg) .. {up} + sbj[4][0].c .. + sbj[3][0].c .. tension 1.2 .. + sbj[2][0].c .. + sbj[1][0].c .. tension 1.2 .. + sbj[0][0].c {up} .. tension 1.8.. {down} + sbj[0][3].c .. tension 1.2 .. + sbj[1][4].c .. + sbj[2][4].c .. tension 1.2 .. + sbj[3][4].c .. + sbj[4][4].c {down} .. + sbj[4][4].c shifted (0, -num_hg); +drawoptions (); +draw jdg[4]; % fig. 550 -> draw drv_tree; +endfig; + +drv_math_style (ilb, "\scriptstyle"); +drv_labels_position (ilb, r); +drv_scale (clr, 1); + +% +% a continued fraction +% + +drv_math_style (ilb, "\textstyle"); +drv_scale (jdg, 0); +drv_scale (ilb, 0); +drv_labels_position (ilb, l); +drv_roots_position t; +drv_box_mode on; + +drv_font_size "\normalsize"; + +beginfig(560) +dcl 0 (1) ("1+", 1) "a"; +dcl 1 (2) ("2+", 1) "b"; +dcl 2 (3) ("3+", 1) "c"; +dcl 3 (4) ("4+", 1) "d"; +dcl 4 ( ) ("", 0) "\cdots"; +draw drv_tree; +endfig; + +drv_math_style (ilb, "\scriptstyle"); +drv_scale (jdg, 1); +drv_scale (ilb, 1); +drv_labels_position (ilb, r); +drv_roots_position b; +drv_box_mode off; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% 3. Postamble +% + +end diff --git a/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex new file mode 100644 index 00000000000..48a7644a517 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex @@ -0,0 +1,1864 @@ +% Any piece of code related to font selection in the following preamble +% (document class, font package, font selection commands ...) should be +% reported in `drv-guide.mp'. + +\documentclass[twoside,11pt]{article} +\usepackage[T1]{fontenc} +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage{stmaryrd} + +% Choose your favourite fonts combination (if available). +% See "http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey". +% +%\usepackage{cmbright} % CM text & CM Bright math +%\usepackage{ccfonts,eulervm} % Concrete text & Euler math +%\usepackage{ccfonts} % Concrete text & math +%\usepackage[math]{iwona} % Iwona text & math +%\usepackage[math]{kurier} % Kurier text & math +%\usepackage[math]{anttor} % Antykwa Torunska text & math +%\usepackage{kmath,kerkis} % Kerkis text & math +%\usepackage{fouriernc} % New Century Schoolbook & Fourier math +%\usepackage{pxfonts} % Palatino & pxfonts math +%\usepackage{mathpazo} % Palatino & Pazo math +%\usepackage{mathpple} % Palatino & Euler math +\usepackage[varg]{txfonts} % Times & txfonts math +%\usepackage{mathtime} % Times & Belleek math +%\usepackage{mathptmx} % Times & Symbol math +%\usepackage{mbtimes} % Omega Serif text & Omega math +%\usepackage{arev} % Arev Sans text with Arev math +%\usepackage[charter]{mathdesign} % Bitstream Charter & Math Design math +%\usepackage{comicsans} % Comic Sans text & math +%\usepackage[garamond]{mathdesign} % Garamond & Math Design math +%\usepackage{fourier} % Utopia & Fourier math +%\usepackage[utopia]{mathdesign} % Utopia & Math Design math + +\usepackage{mflogo} +\usepackage{array} +\usepackage{multicol} +\raggedcolumns +\usepackage{fancyvrb} +\fvset{fontsize=\small} +\usepackage{color} +\definecolor{myblue}{rgb}{0,0,.5} + +\usepackage{hyperref} +\hypersetup{colorlinks=true} +\hypersetup{citecolor=myblue} +\hypersetup{linkcolor=myblue} +\hypersetup{urlcolor=myblue} +\hypersetup{pdftitle={drv.mp - derivation trees with MetaPost}} +\hypersetup{pdfauthor={Laurent M\'ehats}} + +% Picture inclusion macro: \drv +% +% \drv includes a picture file in such a way that the baseline of the included +% picture coincides with the baseline of the inclusion point. The code for \drv +% was suggested by Josselin Noirel on the fr.comp.text.tex usenet group. + +\usepackage{graphicx} +\makeatletter +\def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}} +\newsavebox{\graphicsbox} +\newcommand*{\drv}[1]{% +\sbox{\graphicsbox}{\includegraphics{#1}}% +\raisebox{\Gin@lly bp}% +{\usebox{\graphicsbox}}} +\makeatother + +\newcommand{\param}[1]{\textrm{\textit{$\langle$#1\/$\rangle$}}} +\newcommand{\default}[1][]{\emph{$*$ default#1 $*$}} +\newcommand{\tbs}{\textbackslash} +\newcommand{\resplap}{\llap{\textrm{\emph{resp. }}}} + +\title{\texttt{drv.mp}\\ +derivation trees with \MP% +\thanks{You don't need to know \MP\ to use this package.}\\ +{\small almost a user's guide% +\thanks{Feel free to improve! (E.g. by correcting the poor English.) +Last update: \today.}}} +\author{Laurent \textsc{M\'ehats}\\ +{\small\href{mailto:laurent.mehats@gmail.com} +{\texttt{laurent.mehats@gmail.com}}}} +\date{documented version: 0.93} + +\pagestyle{myheadings} +\renewcommand{\sectionmark}[1]{% +\markboth{\upshape\sc#1}{}} +\renewcommand{\subsectionmark}[1]{% +\markright{\upshape\thesubsection\quad#1}} + +\begin{document} +\maketitle +% +% +\begin{gather*} +\drv{drv-guide.100} +\end{gather*} +% +% +\tableofcontents +% +% +\section{Usage\label{sec-usage}} +% +% +\subsection{Structure of a \MP\ file using \texttt{drv.mp}% +\label{sec-structure}} +% +% +\begin{description} +\item[Preamble]\ + \begin{Verbatim}[commandchars=\\\{\}] + input drv; + verbatimtex %&latex + \param{\LaTeX\ preamble} + \texttt{\tbs{}begin\{document\}} + etex; + \end{Verbatim} +\item[Figures]\ + \begin{Verbatim}[commandchars=\\\{\}] + \param{optional \texttt{drv} tunings} + beginfig(\param{index}) + \param{judgment \& inference declarations} + draw drv_tree; + \param{optional extra \MP\ code} + endfig; + \end{Verbatim} +\item[Postamble]\ + \begin{Verbatim} + end + \end{Verbatim} +\end{description} +For each ``\texttt{beginfig(\param{index})}, \texttt{endfig;}'' pair in a file +\texttt{\param{jobname}.mp}, \MP\ generates an Encapsulated PostScript file +\texttt{\param{jobname}.\param{index}}. +% +% +\subsection{Running \MP\label{sec-running}} +% +% +You have to run \emph{at least twice} +\begin{center} +\texttt{mpost \param{jobname}.mp} +\end{center} +(once more if you use sub-tree delimiters, see~\S~\ref{sec-sub-tree}). On the +first run \MP\ collects the \LaTeX\ code generated by \texttt{drv.mp} +declaration macros and writes it to the file +\texttt{\param{jobname}-delayed.mp}. On the second run \MP\ preprocesses the +\LaTeX\ code in \texttt{\param{jobname}-delayed.mp} and then typesets the +derivation trees. + +If you get an error on the first run then it comes from the +\texttt{drv.mp}/\MP\ code. If you get an error on the second run then it comes +from the \LaTeX\ code. In both cases, correct the error (see +Appendix~\ref{sec-debugging}), delete \texttt{\param{jobname}-delayed.mp} and +run ``\texttt{mpost \param{jobname}.mp}'' twice again (a \texttt{makefile} can +do that for you). +% +% +\subsection{\LaTeX\ inclusion commands\label{sec-inclusion}} +% +% +Encapsulated PostScript files \texttt{\param{jobname}.\param{index}} generated +by \MP\ can be included in \LaTeX\ documents using the +\texttt{\tbs{}includegraphics\{\param{jobname}.\param{index}\}} +command from the \texttt{graphicx.sty} (or \texttt{graphics.sty}) package% +\footnote{You may get standalone picture files (e.g. transparent \textsc{png} +for inclusion in a webpage) from each \texttt{\param{jobname}.\param{index}} +file as described in Appendix~\ref{sec-standalone}.}. + +However \texttt{drv.mp} provides ways to set the baseline of +derivation tree pictures (see~\S~\ref{sec-axis-reference} + and~\S~\ref{sec-axis}). Then I suggest using the following +\texttt{\tbs{}drv\{\param{jobname}.\param{index}\}} command which is +such that the baseline of the included picture coincides with the baseline of +the inclusion point. +\begin{Verbatim} +\usepackage{graphicx} +\makeatletter +\def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}} +\newsavebox{\graphicsbox} +\newcommand*{\drv}[1]{% +\sbox{\graphicsbox}{\includegraphics{#1}}% +\raisebox{\Gin@lly bp}% +{\usebox{\graphicsbox}}} +\makeatother +\end{Verbatim} +The code for \texttt{\tbs{}drv} was suggested by Josselin +\textsc{Noirel} on the \texttt{fr.comp.text.tex} Usenet group. +% +% +\section{Judgment \& inference declarations\label{sec-declarations}} +% +% +\subsection{\texttt{jgm} \& \texttt{nfr}\label{sec-jgm-nfr}} +% +% +\texttt{jgm \param{nat} \param{str list}}\\ +\begin{tabular}{ll} +\param{nat}& judgment index\\ +\param{str list}& sub-judgments \emph{math-mode} \LaTeX\ code +\end{tabular}\\[1ex] +\texttt{nfr \param{nat} (\param{nat list}) (\param{str}, \param{id})}\\ +\begin{tabular}{ll} +\param{nat}& inference index\\ +\param{nat list}& list of premise indices\\ +\param{str}& inference label \emph{math-mode} \LaTeX\ code\\ +\param{id}& inference line style identifier ({\tt0}, {\tt1}, + {\tt2}, {\tt3}, {\tt4}, {\tt5}, {\tt6} or {\tt\_}) +\end{tabular}\\[1ex] +``\texttt{jgm} \param{nat}'' declares a judgment which index is +\param{nat} while ``\texttt{nfr} \param{nat}'' declares an inference which +conclusion is the index \param{nat} judgment (a judgment may be declared before +or after the corresponding inference, no matter). + +A premise index \param{nat} refers to the sub-tree ending with the index +\param{nat} judgment. A list of premise indices may be arbitrary long. +% +% +\begin{multicols}{2} +\paragraph{First example} +% +% +%\begin{multicols}{2} +\begin{Verbatim} +beginfig(110) +jgm 0 "A\vdash B"; +jgm 1 "B\vdash C"; +jgm 2 "A\vdash C"; +nfr 0 () ("f", 1); +nfr 1 () ("g", 1); +nfr 2 (0, 1) ("\circ", 1); +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak + +\begin{gather*} +\drv{drv-guide.110} +\end{gather*} +\end{multicols} +% +% +\paragraph{Sub-judgments} +% +% +\begin{multicols}{2} +\begin{Verbatim} +beginfig(111) +jgm 0 "A", "\vdash", "B"; +nfr 0 () ("f", 1); +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak + +\begin{gather*} +\drv{drv-guide.111} +\end{gather*} +\end{multicols} +\noindent +The outputs induced by +\begin{center} +\texttt{jgm 0 "A\tbs{}vdash B";}\qquad and\qquad +\texttt{jgm 0 "A", "\tbs{}vdash", "B";} +\end{center} +are the same. Using the latter declaration, you can manipulate sub-judgments +independently from each-other (see \S~\ref{sec-components}). +% +% +\paragraph{Inference line styles} +% +% +\begin{multicols}{2} +\begin{Verbatim} +beginfig(120) +jgm 0 "\text{none}"; +jgm 1 "\text{simple}"; +jgm 2 "\text{double}"; +jgm 3 "\text{dotted}"; +jgm 4 "\text{dashed}"; +jgm 5 "\text{waved}"; +jgm 6 "\text{\TeX-dotted}"; +jgm 7 "\text{default}"; +nfr 0 ( ) ("\leftarrow 0", 0); +nfr 1 (0) ("\leftarrow 1", 1); +nfr 2 (1) ("\leftarrow 2", 2); +nfr 3 (2) ("\leftarrow 3", 3); +nfr 4 (3) ("\leftarrow 4", 4); +nfr 5 (4) ("\leftarrow 5", 5); +nfr 6 (5) ("\leftarrow 6", 6); +nfr 7 (6) ("\leftarrow\_", _); +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak + +\begin{gather*} +\drv{drv-guide.120} +\end{gather*} +\end{multicols} +\noindent +The default inference line style is set by the \texttt{drv\_path\_style} macro +(see \S~\ref{sec-path-style}). +% +% +\paragraph{Declarations order} +% +% +Declarations may occur in any order. +\begin{multicols}{2} +\begin{Verbatim} +beginfig(130) +% preorder declarations +jgm 0 "0"; + jgm 1 "00"; + jgm 2 "000"; + jgm 3 "001"; + jgm 4 "002"; + jgm 5 "01"; + jgm 6 "010"; + jgm 7 "011"; + jgm 8 "012"; + jgm 9 "02"; + jgm 10 "020"; + jgm 11 "021"; + jgm 12 "022"; +nfr 0 (1, 5, 9) ("a", _); + nfr 1 (2, 3, 4) ("b", _); + nfr 2 () ("c", _); + nfr 3 () ("d", _); + nfr 4 () ("e", _); + nfr 5 (6, 7, 8) ("f", _); + nfr 6 () ("g", _); + nfr 7 () ("h", _); + nfr 8 () ("i", _); + nfr 9 (10, 11, 12) ("j", _); + nfr 10 () ("k", _); + nfr 11 () ("l", _); + nfr 12 () ("m", _); +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak +\begin{Verbatim} +beginfig(131) +% postorder declarations + jgm 0 "000"; + jgm 1 "001"; + jgm 2 "002"; + jgm 3 "00"; + jgm 4 "010"; + jgm 5 "011"; + jgm 6 "012"; + jgm 7 "01"; + jgm 8 "020"; + jgm 9 "021"; + jgm 10 "022"; + jgm 11 "02"; +jgm 12 "0"; + nfr 0 () ("a", _); + nfr 1 () ("b", _); + nfr 2 () ("c", _); + nfr 3 (0, 1, 2) ("d", _); + nfr 4 () ("e", _); + nfr 5 () ("f", _); + nfr 6 () ("g", _); + nfr 7 (4, 5, 6) ("h", _); + nfr 8 () ("i", _); + nfr 9 () ("j", _); + nfr 10 () ("k", _); + nfr 11 (8, 9, 10) ("l", _); +nfr 12 (3, 7, 11) ("m", _); +draw drv_tree; +endfig; +\end{Verbatim} +\end{multicols} +\begin{gather*} +\drv{drv-guide.130}\tag{130}\\[1ex] +\drv{drv-guide.131}\tag{131} +\end{gather*} +% +% +\paragraph{Code for the title page derivation tree} +% +% +\begin{Verbatim} +beginfig(100) +jgm 0 "\Gamma, \Delta, \Theta, \Pi, \Upsilon\vdash F"; + jgm 1 "\Pi\vdash (A\to D)\to E"; + jgm 2 "\Gamma, \Delta, \Theta, (A\to D)\to E, \Upsilon\vdash F"; + jgm 3 "\Gamma, \Delta, \Theta\vdash A\to D"; + jgm 4 "A, \Gamma, \Delta, \Theta\vdash D"; + jgm 5 "A, \Gamma, \Delta\vdash B\wedge C"; + jgm 6 "A, \Gamma\vdash B"; + jgm 7 "\Delta\vdash C"; + jgm 8 "B\wedge C, \Theta\vdash D"; + jgm 9 "E, \Upsilon\vdash F"; +nfr 0 (1, 2) ("\text{cut}", 1); + nfr 1 () ("\pi", 4); + nfr 2 (3, 9) ("\to_L", 1); + nfr 3 (4) ("\to_R", 1); + nfr 4 (5, 8) ("\text{cut}", 1); + nfr 5 (6, 7) ("\wedge_R", 1); + nfr 6 () ("\gamma", 2); + nfr 7 () ("\delta", 1); + nfr 8 () ("\theta", 3); + nfr 9 () ("\upsilon", 2); +draw drv_tree; +endfig; +\end{Verbatim} +% +% +\subsection{\texttt{dcl}\label{sec-dcl}} +% +% +\texttt{dcl} enables the simultaneous declarations of a judgment and of the +corresponding inference: +%\begin{center} +``\texttt{dcl \param{nat} (\param{nat list}) +(\param{str}, \param{id}) \param{str list}}'' +%\end{center} +is a shorthand for +``\texttt{jgm \param{nat} \param{str list}; nfr \param{nat} (\param{nat list}) +(\param{str}, \param{id})}''. +\begin{multicols}{2} +\begin{Verbatim} +beginfig(140) +dcl 0 () ("f", 1) "A\vdash B"; +dcl 1 () ("g", 1) "B\vdash C"; +dcl 2 (0, 1) ("\circ", 1) "A\vdash C"; +draw drv_tree; +endfig; + +beginfig(141) +dcl 0 () ("f", 1) "A", "\vdash", "B"; +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak + +\begin{gather*} +\drv{drv-guide.140} +\end{gather*} +\vfill +\begin{gather*} +\drv{drv-guide.141} +\end{gather*} +\end{multicols} +\begin{Verbatim} +beginfig(150) +dcl 0 (1, 5, 9) ("a", _) "0"; + dcl 1 (2, 3, 4) ("b", _) "00"; + dcl 2 () ("c", _) "000"; + dcl 3 () ("d", _) "001"; + dcl 4 () ("e", _) "002"; + dcl 5 (6, 7, 8) ("f", _) "01"; + dcl 6 () ("g", _) "010"; + dcl 7 () ("h", _) "011"; + dcl 8 () ("i", _) "012"; + dcl 9 (10, 11, 12) ("j", _) "02"; + dcl 10 () ("k", _) "020"; + dcl 11 () ("l", _) "021"; + dcl 12 () ("m", _) "022"; +draw drv_tree; +endfig; +\end{Verbatim} +\begin{gather*} +\drv{drv-guide.150} +\end{gather*} +% +% +\subsection{\texttt{bxd} \& \texttt{mvd}\label{sec-bxd-mvd}} +% +% +\paragraph{\texttt{bxd}} +% +% +A premise index \param{nat} can be replaced with ``\texttt{bxd \param{nat}}'' +so that the whole sub-tree ending with the index \param{nat} judgment behaves +as if it was enclosed within a box. +\begin{Verbatim}[commandchars=\\\{\}] +beginfig(160) +dcl 0 (1, 4) ("", _) "a"; +\resplap{}dcl 0 (bxd 1, 4) ("", _) "a"; + dcl 1 (2) ("", _) "a"; + dcl 2 (3) ("", _) "a"; + dcl 3 () ("", _) "aaaaaaa"; + dcl 4 () ("", _) "aaaaa"; +draw drv_tree; +endfig; +\end{Verbatim} +\begin{gather*} +\drv{drv-guide.160}\quad\text{resp.}\quad +\drv{drv-guide.161}\quad\text{typeset as}\quad +\drv{drv-guide.162} +\end{gather*} +% +% +\paragraph{\texttt{mvd}} +% +% +A premise index \param{nat 1} in an inference declaration can be replaced with +``\texttt{mvd \param{nat 1} (\param{nat 2}, \param{id})}'' so as to declare +\param{nat 2} ``phantom'' inference steps starting from the index \param{nat 1} +judgment. The ``phantom'' inference steps are intended to be drawn as +a path using the path-style \param{id}.\\[1ex] +\texttt{mvd \param{nat 1} (\param{nat 2}, \param{id})}\\ +\begin{tabular}{ll} +\param{nat 1}& index of the origin judgment\\ +\param{nat 2}& number of phantom steps\\ +\param{id}& phantom steps path-style identifier ({\tt0}, {\tt1}, {\tt2}, + {\tt3}, {\tt4}, {\tt5}, {\tt6} or {\tt\_}) +\end{tabular} +\begin{multicols}{2} +\begin{Verbatim}[commandchars=\\\{\}] +beginfig(170) +jgm 1 "aaa"; +jgm 2 "bbb"; +jgm 3 "ccc"; +jgm 4 "d"; +nfr 1 () ("", _); +nfr 2 () ("", _); +nfr 3 () ("", _); +nfr 4 (mvd 1 (2, 3), 2, 3) ("", _); +\resplap{}nfr 4 (1, mvd 2 (2, 4), 3) ("", _); +\resplap{}nfr 4 (1, 2, mvd 3 (2, 6)) ("", _); +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak +\begin{gather*} +\drv{drv-guide.170}\\[1ex] +\drv{drv-guide.171}\\[1ex] +\drv{drv-guide.172} +\end{gather*} +\end{multicols} +\begin{Verbatim}[commandchars=\\\{\}] +beginfig(180) +jgm 0 "\tbs{}textsc\{Size matters -- Part 1\}"; +jgm 1 "\tbs{}text\{Here is a rather long judgment"&\textrm{\emph{ + % string concatenation}} + " that I don't want to shorten.\}"; +jgm 2 "\tbs{}text\{Will the derivation tree fit on the page?\}"; +jgm 3 "\tbs{}text\{It does.\}"; +nfr 0 () ("", 0); +nfr 1 (0) ("", 1); +nfr 2 () ("", 1); +nfr 3 (mvd 1 (2, 3), 2) ("", 1); +draw drv_tree; +endfig; +\end{Verbatim} +\begin{gather*} +\drv{drv-guide.180} +\end{gather*} +%The default phantom steps path-style ``''is set by the +%\texttt{drv\_path\_style} macro (see~\S~\ref{sec-path-style}). +% +% +\subsection{Sub-tree delimiters \& labels\label{sec-sub-tree}} +% +% +\paragraph{\texttt{Nfr}} +% +% +The \texttt{Nfr} declaration macro is an alternative for \texttt{nfr} that +enables the typesetting of delimiters.\\[1ex] +\texttt{Nfr \param{nat} (\param{nat list}) +(\param{str 1}, \param{str 2}, \param{str 3}, \param{id})}\\ +\begin{tabular}{ll} +\param{nat}& inference index\\ +\param{nat list}& list of premise indices\\ +\param{str 1}& inference label \emph{math-mode} \LaTeX\ code\\ +\param{str 2}& left delimiter label \emph{math-mode} \LaTeX\ code\\ +\param{str 3}& right delimiter label \emph{math-mode} \LaTeX\ code\\ +\param{id}& inference line style identifier ({\tt0}, {\tt1}, + {\tt2}, {\tt3}, {\tt4}, {\tt5}, {\tt6} or {\tt\_}) +\end{tabular}\\[1ex] +If both \param{str 2} and \param{str 3} are the empty string +\texttt{""} then \texttt{Nfr} behaves exactly like \texttt{nfr}. However, if +\param{str 2} is a non-empty string then a delimiter is placed to the left of +the sub-tree ending with the index \param{nat} judgment and \param{str 2} is +attached to it as a label. The same way, if \param{str 3} is a non-empty +string then a delimiter is placed to the right of the sub-tree ending with the +index \param{nat} judgment and \param{str 3} is attached to it as a label. Both +\param{str 2} and \param{str 3} may be non-empty strings. You may use +\texttt{"\{\}"} as a string argument to get a delimiter without a label. +\begin{multicols}{2} +\begin{Verbatim} +beginfig(190) +jgm 0 "a"; +jgm 1 "b"; +jgm 2 "c"; +jgm 3 "d"; +Nfr 0 () ("0", "", "", _); +Nfr 1 () ("1", "", "", _); +Nfr 2 (0, 1) ("2", "E", "", _); +Nfr 3 (2) ("3", "", "F", _); +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak + +\begin{gather*} +\drv{drv-guide.190} +\end{gather*} +\end{multicols} +% +% +\paragraph{\texttt{Dcl}} +% +% +The \texttt{Dcl} declaration macro is a shorthand for \texttt{jgm} and +\texttt{Nfr} in the same way as \texttt{dcl} is a shorthand for \texttt{jgm} +and \texttt{nfr}. +\begin{multicols}{2} +\begin{Verbatim} +beginfig(200) +Dcl 0 () ("", "", "", _) "a"; +Dcl 1 (0) ("", "", "B", _) "c"; +Dcl 2 () ("", "", "", _) "d"; +Dcl 3 (1, 2) ("", "E", "", _) "f"; +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak + +\begin{gather*} +\drv{drv-guide.200} +\end{gather*} +\end{multicols} +% +% +\paragraph{\texttt{Mvd}} +% +% +The \texttt{Mvd} macro is an alternative for \texttt{mvd} that enables the +attachment of labels to phantom steps paths.\\[1ex] +\texttt{Mvd \param{nat 1} +(\param{nat 2}, \param{str 1}, \param{str 2}, \param{id})}\\ +\begin{tabular}{ll} +\param{nat 1}& index of the origin judgment\\ +\param{nat 2}& number of phantom steps\\ +\param{str 1}& left label \emph{math-mode} \LaTeX\ code\\ +\param{str 2}& right label \emph{math-mode} \LaTeX\ code\\ +\param{id}& phantom steps path-style identifier ({\tt0}, {\tt1}, {\tt2}, + {\tt3}, {\tt4}, {\tt5}, {\tt6} or {\tt\_}) +\end{tabular}\\[1ex] +If \param{str 1} is a non-empty string then it is attached as a label to the +left of the phantom steps path. The same way, if \param{str 2} is a non-empty +string then it is attached as a label to the right of the phantom steps path. +Both \param{str 1} and \param{str 2} may be non-empty strings. +\begin{multicols}{2} +\begin{Verbatim} +beginfig(210) +jgm 1 "aaa"; +jgm 2 "bbb"; +jgm 3 "ccc"; +nfr 1 () ("", _); +nfr 2 () ("", _); +nfr 3 (Mvd 1 (2, "d", "", 3), 2) ("", _); +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak + +\begin{gather*} +\drv{drv-guide.210} +\end{gather*} +\end{multicols} +% +% +\section{\texttt{drv} tunings\label{sec-tunings}} +% +% +\texttt{drv} tuning macros set the parameters according to which derivation +trees are typeset. All these macros have to be called outside figure +environments (delimited by ``\texttt{beginfig(\param{index})}, +\texttt{endfig;}'' pairs). +% +% +\begin{multicols}{2} +\subsection{\texttt{drv\_font\_size}\label{sec-font-size}} +% +% +\texttt{drv\_font\_size \param{str}}\\ +\begin{tabular}{ll} +\param{str}& \LaTeX\ font-size command\\ +& \begin{tabular}{l} + \texttt{"\tbs{}tiny"}\\ + \texttt{"\tbs{}scriptsize"}\\ + \texttt{"\tbs{}footnotesize"}\\ + \texttt{"\tbs{}small"}\\ + \texttt{"\tbs{}normalsize"}\rlap{\quad\default}\\ + \texttt{"\tbs{}large"}\\ + \texttt{"\tbs{}Large"}\\ + etc. + \end{tabular} +\end{tabular} +\columnbreak +\begin{gather*} +\texttt{"\tbs{}tiny"}\\ +\drv{drv-guide.220}\\ +\texttt{"\tbs{}small"}\\ +\drv{drv-guide.221}\\ +\texttt{"\tbs{}Large"}\\ +\drv{drv-guide.222} +\end{gather*} +\end{multicols} +% +% +\subsection{\texttt{drv\_math\_style}\label{sec-math-style}} +% +% +\texttt{drv\_math\_style (\param{id}, \param{str})}\\ +\begin{tabular}{ll} +\param{id}& component identifier ({\tt drv}, {\tt jdg}, {\tt ilb}, + {\tt dlb} or {\tt plb})\\ +& \begin{tabular}{lll} + {\tt drv}& derivation trees& + \default[ style: \texttt{"\tbs{}displaystyle"}]\\ + {\tt jdg}& judgments& + \default[ style: \texttt{"\tbs{}textstyle"}]\\ + {\tt ilb}& inference labels& + \default[ style: \texttt{"\tbs{}scriptstyle"}]\\ + {\tt dlb}& delimiter labels& + \default[ style: \texttt{"\tbs{}textstyle"}]\\ + {\tt plb}& phantom steps labels& + \default[ style: \texttt{"\tbs{}textstyle"}] + \end{tabular}\\ +\param{str}& \LaTeX\ math-style command +\end{tabular}\\[1ex] +% +% +``\texttt{drv\_math\_style (drv, {\rm ---});}'' +\begin{gather*} +\begin{array}{*{3}{@{}>{\centering}p{.33\textwidth}}@{}l@{}} +\texttt{"\tbs{}displaystyle"}& +\texttt{"\tbs{}textstyle"}& +\texttt{"\tbs{}scriptstyle"}&\\[1ex] +\drv{drv-guide.230}& +\drv{drv-guide.231}& +\drv{drv-guide.232}& +\end{array} +\end{gather*} +% +% +``\texttt{drv\_math\_style (jdg, {\rm ---});}'' +\begin{gather*} +\begin{array}{*{3}{@{}>{\centering}p{.33\textwidth}}@{}l@{}} +\texttt{"\tbs{}displaystyle"}& +\texttt{"\tbs{}textstyle"}& +\texttt{"\tbs{}scriptstyle"}&\\[1ex] +\drv{drv-guide.240}& +\drv{drv-guide.241}& +\drv{drv-guide.242}& +\end{array} +\end{gather*} +% +% +``\texttt{drv\_math\_style (ilb, {\rm ---});}'' +\begin{gather*} +\begin{array}{*{3}{@{}>{\centering}p{.33\textwidth}}@{}l@{}} +\texttt{"\tbs{}textstyle"}& +\texttt{"\tbs{}scriptstyle"}& +\texttt{"\tbs{}scriptscriptstyle"}&\\[1ex] +\drv{drv-guide.250}& +\drv{drv-guide.251}& +\drv{drv-guide.252}& +\end{array} +\end{gather*} +Notice that the math-style of derivation trees determines the math-style of +judgments (and of labels) in the same way as the math-style of fractions +determines the math-style of numerators and denominators. +% +% +\subsection{\texttt{drv\_scale}\label{sec-scale}} +% +% +\texttt{drv\_scale (\param{id}, \param{float})}\\ +\begin{tabular}{ll} +\param{id}& scale identifier ({\tt clr}, {\tt prm}, {\tt jdg} or + {\tt ilb})\\ +& \begin{tabular}{lll} + {\tt clr}&nice explanation soon + (see examples)&\default[ scale: 1]\\ + {\tt prm}&nice explanation soon + (see examples)&\default[ scale: 1]\\ + {\tt jdg}&nice explanation soon + (see examples)&\default[ scale: 1]\\ + {\tt ilb}&nice explanation soon + (see examples)&\default[ scale: 1] + \end{tabular}\\ +\param{float}&scale value +\end{tabular}\\[1ex] +% +% +``\texttt{drv\_scale (clr, {\rm ---});}'' +\begin{gather*} +\begin{array}{*{4}{@{}>{\centering}p{.25\textwidth}}@{}l@{}} +\texttt{0}& +\texttt{1}& +\texttt{2.5}& +\texttt{4}&\\[1ex] +\drv{drv-guide.260}& +\drv{drv-guide.261}& +\drv{drv-guide.262}& +\drv{drv-guide.263}& +\end{array} +\end{gather*} +% +% +``\texttt{drv\_scale (prm, {\rm ---});}'' +\begin{gather*} +\begin{array}{*{4}{@{}>{\centering}p{.25\textwidth}}@{}l@{}} +\texttt{0}& +\texttt{1}& +\texttt{2.5}& +\texttt{4}&\\[1ex] +\drv{drv-guide.270}& +\drv{drv-guide.271}& +\drv{drv-guide.272}& +\drv{drv-guide.273}& +\end{array} +\end{gather*} +% +% +``\texttt{drv\_scale (jgm, {\rm ---});}'' +\begin{gather*} +\begin{array}{*{4}{@{}>{\centering}p{.25\textwidth}}@{}l@{}} +\texttt{0}& +\texttt{1}& +\texttt{2.5}& +\texttt{4}&\\[1ex] +\drv{drv-guide.280}& +\drv{drv-guide.281}& +\drv{drv-guide.282}& +\drv{drv-guide.283}& +\end{array} +\end{gather*} +% +% +``\texttt{drv\_scale (ilb, {\rm ---});}'' +\begin{gather*} +\begin{array}{*{4}{@{}>{\centering}p{.25\textwidth}}@{}l@{}} +\texttt{0}& +\texttt{1}& +\texttt{2.5}& +\texttt{4}&\\[1ex] +\drv{drv-guide.290}& +\drv{drv-guide.291}& +\drv{drv-guide.292}& +\drv{drv-guide.293}& +\end{array} +\end{gather*} +% +% +\subsection{\texttt{drv\_junction\_style}\label{sec-junction-style}} +% +% +This macro sets the default way the premises of an inference have to be +horizontally joined.\\[1ex] +\texttt{drv\_junction\_style \param{id}}\\ +\begin{tabular}{ll} +\param{id}&junction style identifier ({\tt 0}, {\tt 1} or {\tt 2})\\ +& \begin{tabular}{ll} + {\tt 0}&``fully-interlacing''\\ + {\tt 1}&``semi-interlacing''\quad\default\\ + {\tt 2}&``non-interlacing'' + \end{tabular} +\end{tabular} +\begin{gather*} +\begin{array}{*{3}{@{}>{\centering}p{.33\textwidth}}@{}l@{}} +\texttt{0}& +\texttt{1}& +\texttt{2}&\\[1ex] +\drv{drv-guide.300}& +\drv{drv-guide.301}& +\drv{drv-guide.302}& +\end{array} +\end{gather*} +% +% +\subsection{\texttt{drv\_alignment\_style}\label{sec-alignment-style}} +% +% +This macro sets the default way a judgment has to be horizontally aligned +relatively to its premises.\\[1ex] +\texttt{drv\_alignment\_style \param{id}}\\ +\begin{tabular}{ll} +\param{id}& alignment style identifier ({\tt l}, {\tt c} or {\tt r})\\ +& \begin{tabular}{ll} + {\tt l}&left\\ + {\tt c}¢ered\quad\default\\ + {\tt r}&right + \end{tabular} +\end{tabular} +\begin{gather*} +\begin{array}{*{3}{@{}>{\centering}p{.33\textwidth}}@{}l@{}} +\texttt{l}& +\texttt{c}& +\texttt{r}&\\[1ex] +\drv{drv-guide.310}& +\drv{drv-guide.311}& +\drv{drv-guide.312}& +\end{array} +\end{gather*} +% +% +\subsection{\texttt{drv\_path\_style}\label{sec-path-style}} +% +% +\texttt{drv\_path\_style (\param{id 1}, \param{id 2})}\\ +\begin{tabular}{ll} +\param{id 1}& path-type identifier ({\tt iln} or {\tt phm})\\ +& \begin{tabular}{lll} + {\tt iln} &inference lines&\default[ style: {\tt1}]\\ + {\tt phm} &phantom steps paths&\default[ style: {\tt3}] + \end{tabular}\\ +\param{id 2}& path-style identifier ({\tt0}, {\tt1}, {\tt2}, {\tt3}, {\tt4}, + {\tt5} or {\tt6}) +\end{tabular} +% +% +\subsection{\texttt{drv\_labels\_position}\label{sec-labels-position}} +% +% +\texttt{drv\_labels\_position (\param{id 1}, \param{id 2})}\\ +\begin{tabular}{ll} +\param{id 1}& label-type identifier ({\tt ilb}, {\tt plb} or {\tt dlb})\\ +& \begin{tabular}{lll} + {\tt ilb} &inference labels& + \default[ position: {\tt r}]\\ + {\tt dlb} &delimiter labels& + \default[ position: {\tt l}]\\ + {\tt plb} &phantom steps labels& + \default[ position: {\tt l}] + \end{tabular}\\ +\param{id 2}& position identifier ({\tt l} or {\tt r})\\ +& \begin{tabular}{ll} + {\tt l}&left\\ + {\tt r}&right + \end{tabular} +\end{tabular}\\[1ex] +``\texttt{drv\_labels\_position (ilb, {\rm ---});}'' +\begin{gather*} +\begin{array}{*{2}{@{}>{\centering}p{.24\textwidth}}@{}l@{}} +{\tt l}&{\tt r}&\\[1ex] +\drv{drv-guide.320}& +\drv{drv-guide.321}& +\end{array} +\end{gather*} +\enlargethispage{.25\baselineskip}% +Setting a default position for delimiter labels (thus for delimiters) and for +phantom steps labels may be useful in conjunction with declaration macros +taking optional label arguments (see~\S~\ref{sec-labels}). +% +% +\begin{multicols}{2} +\subsection{\texttt{drv\_roots\_position}\label{sec-roots-position}} +% +% +%\begin{multicols}{2} +\texttt{drv\_roots\_position \param{id}}\\ +\begin{tabular}{ll} +\param{id}& position identifier ({\tt t} or {\tt b})\\ +& \begin{tabular}{ll} + {\tt t}&top\\ + {\tt b}&bottom\quad\default + \end{tabular} +\end{tabular} +\columnbreak + +\begin{gather*} +\begin{array}{*{2}{@{}>{\centering}p{.24\textwidth}}@{}l@{}} +\drv{drv-guide.330}& +\drv{drv-guide.331}& +\end{array} +\end{gather*} +\end{multicols} +% +% +\subsection{\texttt{drv\_axis\_reference}\label{sec-axis-reference}} +% +% +The baseline of derivation tree pictures is set in such a way that their +math-axis coincides either with the axis of their root inference line or with +the math-axis of their root judgment according to the default behaviour set by +\texttt{drv\_axis\_reference}.\\[1ex] +\texttt{drv\_axis\_reference \param{id}}\\ +\begin{tabular}{ll} +\param{id}& reference identifier ({\tt iln} or {\tt jdg})\\ +& \begin{tabular}{lll} + {\tt iln}&root inference line axis&\default\\ + {\tt jdg}&root judgment math-axis + \end{tabular} +\end{tabular} +\begin{gather*} +\frac{\qquad}{}\textit{math axis}\frac{\qquad}{} +\drv{drv-guide.340}\frac{\qquad}{} +\drv{drv-guide.341}\frac{\qquad}{} +\end{gather*} +Notice that \texttt{drv\_axis\_reference} is irrelevant if you don't use the +\texttt{\tbs{}drv} inclusion command (see \S~\ref{sec-inclusion}). +% +% +\subsection{\texttt{drv\_left\_delimiter} \& \texttt{drv\_right\_delimiter}% +\label{sec-delimiters}} +% +% +\texttt{drv\_left\_delimiter \param{str}}\\ +\begin{tabular}{ll} +\param{str}& left delimiter math-mode \LaTeX\ code\\ +& \begin{tabular}{llll} + \texttt{"("}& $($\\ + \texttt{"["}& $[$\\ + \texttt{"\tbs{}lbrace"}& $\lbrace$&\default\\ + \texttt{"\tbs{}langle"}& $\langle$\\ + etc. + \end{tabular} +\end{tabular}\\[1ex] +\texttt{drv\_right\_delimiter \param{str}}\\ +\begin{tabular}{ll} +\param{str}& right delimiter math-mode \LaTeX\ code\\ +& \begin{tabular}{llll} + \texttt{")"}& $)$\\ + \texttt{"]"}& $]$\\ + \texttt{"\tbs{}rbrace"}& $\rbrace$&\default\\ + \texttt{"\tbs{}rangle"}& $\rangle$\\ + etc. + \end{tabular} +\end{tabular}\\[1ex] +``\texttt{drv\_left\_delimiter {\rm ---};}'' +\begin{gather*} +\begin{array}{*{3}{@{}>{\centering}p{.33\textwidth}}@{}l@{}} +\texttt{"("}& +\texttt{"\tbs{}lfloor"}& +\texttt{"."}&\\[1ex] +\drv{drv-guide.350}& +\drv{drv-guide.351}& +\drv{drv-guide.352}& +\end{array} +\end{gather*} +``\texttt{drv\_right\_delimiter {\rm ---};}'' +\begin{gather*} +\begin{array}{*{3}{@{}>{\centering}p{.33\textwidth}}@{}l@{}} +\texttt{"\tbs{}rangle"}& +\texttt{"\tbs{}uparrow"}& +\texttt{"."}&\\[1ex] +\drv{drv-guide.360}& +\drv{drv-guide.361}& +\drv{drv-guide.362}& +\end{array} +\end{gather*} +% +% +\subsection{\texttt{drv\_box\_mode}\label{sec-box-mode}} +% +% +When in ``box mode'', derivation trees are typeset in such a way that all +sub-trees behave as if they were enclosed within boxes (that is as if all +premise indices were prefixed with \texttt{bxd}, +see~\S~\ref{sec-bxd-mvd}).\\[1ex] +% +% +\texttt{drv\_box\_mode \param{id}}\\ +\begin{tabular}{ll} +\param{id}& status identifier ({\tt on} or {\tt off})\\ +& \begin{tabular}{ll} + {\tt on}\\ + {\tt off}&\default + \end{tabular} +\end{tabular} +\begin{gather*} +\begin{array}{*{3}{@{}>{\centering}p{.33\textwidth}}@{}l@{}} +\texttt{on}& +typeset as& +\texttt{off}&\\[1ex] +\drv{drv-guide.370}& +\drv{drv-guide.371}& +\drv{drv-guide.372}& +\end{array} +\end{gather*} +% +% +\subsection{\texttt{drv\_fraction\_mode}\label{sec-fraction-mode}} +% +% +\nopagebreak\parbox{\textwidth}{\texttt{drv.mp} typesets derivation trees in +such a way that: the distance from the axis of an inference line to the +math-axis of a judgment above it is always the same (\texttt{num\_hg}, +see~\S~\ref{sec-components}); the distance from the axis of an inference line +to the math-axis of a judgment below it is always the same (\texttt{den\_dp}, +see~\S~\ref{sec-components}). When in ``fraction mode'', if roots are at bottom +then the height of leaf judgments above which there is no inference line is +ignored (the depth of root judgments is always ignored); if roots are at top +then the depth of leaf judgments below which there is no inference line is +ignored (the height of root judgments is always ignored). This mode may cause +overlaps when used in conjunction with +interlacing junction-styles (\texttt{0} and \texttt{1}).}\\[1ex] +\texttt{drv\_fraction\_mode \param{id}}\\ +\begin{tabular}{ll} +\param{id}& status identifier ({\tt on} or {\tt off})\\ +& \begin{tabular}{ll} + {\tt on}&\default\\ + {\tt off} + \end{tabular} +\end{tabular} +\begin{gather*} +\begin{array}{*{3}{@{}>{\centering}p{.33\textwidth}}@{}l@{}} +\texttt{on}& +\texttt{off}& +typeset as&\\[1ex] +\drv{drv-guide.380}& +\drv{drv-guide.381}& +\drv{drv-guide.382}& +\end{array} +\end{gather*} +% +% +\subsection{\texttt{drv\_proof\_mode}\label{sec-proof-mode}} +% +% +\texttt{drv\_proof\_mode \param{id}}\\ +\begin{tabular}{ll} +\param{id}& status identifier ({\tt on} or {\tt off})\\ +& \begin{tabular}{ll} + {\tt on}\\ + {\tt off}&\default + \end{tabular} +\end{tabular} +\begin{gather*} +\begin{array}{*{2}{@{}>{\centering}p{.5\textwidth}}@{}l@{}} +\texttt{on}& +\texttt{off}&\\[1ex] +\drv{drv-guide.390}& +\drv{drv-guide.391}& +\end{array}\\[1ex] +\end{gather*} +Red numbers (resp. dots) refer to judgment indices (resp. central points, +see~\S~\ref{sec-components}) while blue numbers (resp. dots) refer to +sub-judgment indices (resp. central points, see~\S~\ref{sec-components}). +% +% +\section{Pictures, bounding boxes and math-axis\label{sec-pictures}} +% +% +\subsection{\texttt{drv\_freeze} \& \texttt{drv\_tree}} +% +% +\texttt{drv.mp} composes derivation trees with respect to judgment and +inference declarations only once the \texttt{drv\_freeze} macro is called. +This is usually done by \texttt{drv\_tree} which is actually a macro that +returns a picture. You may however call \texttt{drv\_freeze} yourself if you +have no need for the whole derivation tree picture that \texttt{drv\_tree} +would otherwise return (Section~\ref{sec-components} illustrates such a +situation). + +\texttt{drv.mp} composes derivation trees essentially according to the +algorithm for composing fractions described in Appendix~G of the {\TeX}book +(see~\cite{jackowski06,knuth84}). In particular, \texttt{drv.mp} uses +``\texttt{\tbs{}fontdimen}'' parameters so that the derivation tree pictures +it generates should integrate smoothly within any document, whatever the fonts +you use. As an example (when using the ``\texttt{drv\_scale (jgm, 0);}'' +tuning) \drv{drv-guide.400} should look the same as +$\frac{\gamma}{\delta}$. The first fraction is composed by \texttt{drv.mp} +while the second one is composed by the standard \texttt{\tbs{}frac} +command. +% +% +\subsection{\texttt{drv\_bbox}\label{sec-bbox}} +% +% +\texttt{drv\_bbox \param{nat}}\\ +\begin{tabular}{ll} +\param{nat}& sub-tree root index +\end{tabular}\\[1ex] +``\texttt{drv\_bbox \param{nat}}'' returns a \MP\ path expression representing +the bounding box of the sub-tree ending with the index \param{nat} judgment. +\texttt{drv\_bbox} calls \texttt{drv\_freeze} if necessary. +\begin{Verbatim}[commandchars=\\\{\}] +beginfig(410) +dcl 0 (1, 5) ("", _) "a"; +\resplap{}dcl 0 (bxd 1, 5) ("", _) "a"; + dcl 1 (2, 3, 4) ("", _) "b"; + dcl 2 () ("", _) "c"; + dcl 3 () ("", _) "d"; + dcl 4 () ("", _) "e"; + dcl 5 () ("", _) "f"; +fill drv_bbox 1 withcolor (255, 230, 205)/255; % rgb color +draw drv_tree; +endfig; +\end{Verbatim} +\begin{gather*} +\drv{drv-guide.410}\quad\text{resp.}\quad\drv{drv-guide.411} +\end{gather*} +% +% +\subsection{\texttt{drv\_axis}\label{sec-axis}} +% +% +\texttt{drv\_axis} allows you set the math-axis of a derivation tree with +respect to a particular inference, judgment or sub-tree.\\[1ex] +\texttt{drv\_axis (\param{id}, \param{nat})}\\ +\begin{tabular}{ll} +\param{id}& reference type identifier ({\tt iln}, {\tt jdg} or {\tt dlm})\\ +& \begin{tabular}{ll} + {\tt iln}&inference line axis\\ + {\tt jdg}&judgment math-axis\\ + {\tt dlm}&delimiter axis + \end{tabular}\\ +\param{nat}& reference index +\end{tabular} +\begin{Verbatim}[commandchars=\\\{\}] +beginfig(420) +Dcl 0 ( ) ("", "", "", _) "a"; +Dcl 1 (0) ("", "{}", "", _) "b"; +draw drv_tree; +drv_axis (iln, 0); +\resplap{}drv_axis (jdg, 1); +\resplap{}drv_axis (dlm, 1); +endfig; +\end{Verbatim} +\begin{gather*} +\drv{drv-guide.420}\frac{\qquad}{}\text{ resp. }\frac{\qquad}{} +\drv{drv-guide.421}\frac{\qquad}{}\text{ resp. }\frac{\qquad}{} +\drv{drv-guide.422} +\end{gather*} +Notice that \texttt{drv\_axis} is irrelevant if you don't use the +\texttt{\tbs{}drv} inclusion command.% (see \S~\ref{sec-inclusion}). +% +% +\section{Low level inference declaration macros\label{sec-low-level}} +% +% +\subsection{\texttt{NFR}, \texttt{DCL} \& \texttt{MVD}\label{sec-NFR-DCL-MVD}} +% +% +\paragraph{\texttt{NFR}} +% +% +\enlargethispage{.05\baselineskip}% +The \texttt{NFR} declaration macro is the lowest level one. It allows you to +specify all the labels and styles of an inference.\\[1ex] +\texttt{NFR +\param{nat} +(\param{nat\;list}) +(\param{str~1},\;\param{str~2},\;\param{str~3},\;\param{str~4}) +(\param{id~1},\;\param{id~2},\;\param{id~3})} +\begin{tabular}{ll} +\param{nat}& inference index\\ +\param{nat list}& list of premise indices\\ +\param{str 1}& left inference label \emph{math-mode} \LaTeX\ code\\ +\param{str 2}& right inference label \emph{math-mode} \LaTeX\ code\\ +\param{str 3}& left delimiter label \emph{math-mode} \LaTeX\ code\\ +\param{str 4}& right delimiter label \emph{math-mode} \LaTeX\ code\\ +\param{id 1}& junction style identifier ({\tt0}, {\tt1}, {\tt2}, + {\tt3} or {\tt\_})\\ +& \begin{tabular}{ll} + {\tt0}&fully-interlacing\\ + {\tt1}&semi-interlacing\\ + {\tt2}&non-interlacing\\ + {\tt3}&user specified (tricky, + see~\S~\ref{sec-user-specified})\\ + {\tt\_}&default (set by \texttt{drv\_junction\_style}, + see~\S~\ref{sec-junction-style}) + \end{tabular}\\ +\param{id 2}& alignment style identifier ({\tt l}, {\tt c}, {\tt r}, + {\tt u} or {\tt\_})\\ +& \begin{tabular}{ll} + {\tt l}&left\\ + {\tt c}¢ered\\ + {\tt r}&right\\ + {\tt u}&user specified (tricky, + see~\S~\ref{sec-user-specified})\\ + {\tt\_}&default (set by \texttt{drv\_alignment\_style}, + see~\S~\ref{sec-alignment-style}) + \end{tabular}\\ +\param{id 3}& inference line style identifier ({\tt0}, {\tt1}, + {\tt2}, {\tt3}, {\tt4}, {\tt5}, {\tt6} or {\tt\_}) +\end{tabular} +\begin{multicols}{3} +\begin{Verbatim} +beginfig(430) +jgm 0 "a"; +NFR 0 () ("1", "2", "3", "4", _, _, _); +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak\ \columnbreak + +\begin{gather*} +\drv{drv-guide.430} +\end{gather*} +\end{multicols} +% +% +\paragraph{\texttt{DCL}} +% +% +The \texttt{DCL} declaration macro is a shorthand for \texttt{jgm} and +\texttt{NFR} in the same way as \texttt{dcl} is a shorthand for \texttt{jgm} +and \texttt{nfr}. +\begin{multicols}{3} +\begin{Verbatim} +beginfig(440) +DCL 0 () ("1", "", "", "", _, _, _) "a"; +DCL 1 () ("", "2", "", "", _, _, _) "b"; +DCL 2 (0, 1) ("", "", "3", "", _, _, _) "c"; +DCL 3 (2) ("", "", "", "4", _, _, _) "d"; +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak\ \columnbreak + +\begin{gather*} +\drv{drv-guide.440} +\end{gather*} +\end{multicols} +% +% +\paragraph{\texttt{MVD}} +% +% +The \texttt{MVD} macro is a generalization of \texttt{Mvd} that allows you to +specify the alignment style of phantom inferences.\\[1ex] +\texttt{MVD \param{nat 1} +(\param{nat 2}, \param{str 1}, \param{str 2}, \param{id 1} \param{id 2})}\\ +\begin{tabular}{ll} +\param{nat 1}& index of the origin judgment\\ +\param{nat 2}& number of phantom steps\\ +\param{str 1}& left label \emph{math-mode} \LaTeX\ code\\ +\param{str 2}& right label \emph{math-mode} \LaTeX\ code\\ +\param{id 1}& alignment style identifier ({\tt l}, {\tt c}, {\tt r}, {\tt u} + or {\tt\_})\\ +\param{id 2}& phantom steps path-style identifier ({\tt0}, {\tt1}, {\tt2}, + {\tt3}, {\tt4}, {\tt5}, {\tt6} or {\tt\_}) +\end{tabular} +\begin{multicols}{3} +\begin{Verbatim} +beginfig(450) +jgm 0 "aaaaaa"; +jgm 1 "aaa"; +jgm 2 "a"; +jgm 3 "aaaaaaaaa"; +jgm 4 "a"; +nfr 0 () ("", _); +NFR 1 () ("", "", "", "", _, _, _); +nfr 2 (MVD 0 (2, "A", "", l, 3), 1) ("", _); +nfr 3 () ("", _); +nfr 4 (2, MVD 3 (5, "", "A", r, 4)) ("", _); +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak\ \columnbreak + +\begin{gather*} +\drv{drv-guide.450} +\end{gather*} +\end{multicols} +\pagebreak +\begin{Verbatim} +beginfig(460) +jgm 0 "\textsc{Size matters -- Part 2}"; +jgm 1 "\text{Here is an even longer judgment"& + " that I don't want to shorten either.}"; +jgm 2 "\text{This time I'm pretty sure that the"& + " derivation tree won't fit on the page.}"; +jgm 3 "\text{It does! Amazing.}"; +nfr 0 () ("", 0); +nfr 1 (0) ("", 1); +nfr 2 () ("", 1); +nfr 3 (MVD 1 (2, "", "", l, 3), 2) ("", 1); +draw drv_tree; +endfig; +\end{Verbatim} +\begin{gather*} +\drv{drv-guide.460} +\end{gather*} +% +% +\subsection{Optional labels\label{sec-labels}} +% +% +\paragraph{\texttt{NFR\_opt}} +% +% +The \texttt{NFR\_opt} declaration macro is an alternative for \texttt{NFR} +that lets you specify labels at your option.\\[1ex] +\texttt{NFR\_opt +\param{nat} +(\param{nat list}) +(\param{str list 1}) +(\param{str list 2}) +(\param{id 1}, \param{id 2}, \param{id 3})} +\begin{tabular}{ll} +\param{nat}& inference index\\ +\param{nat list}& list of premise indices\\ +\param{str list 1}& list of inference labels \emph{math-mode} + \LaTeX\ code\\ +\param{str list 2}& list of delimiter labels \emph{math-mode} + \LaTeX\ code\\ +\param{id 1}& junction style identifier ({\tt0}, {\tt1}, {\tt2}, + {\tt3} or {\tt\_})\\ +\param{id 2}& alignment style identifier ({\tt l}, {\tt c}, {\tt r}, + {\tt u} or {\tt\_})\\ +\param{id 3}& inference line style identifier ({\tt0}, {\tt1}, + {\tt2}, {\tt3}, {\tt4}, {\tt5}, {\tt6} or {\tt\_}) +\end{tabular}\\[1ex] +% +% +The list \param{str list 1} may contain zero, one or two +strings specifying inference labels. If no label is specified then no label +is attached to the inference line. If two labels are specified then the first +one is attached to the left and the second one to the right. Finally, if one +label only is specified then it is attached either to the left or to the right +of the inference line depending on the default inference labels position set by +\texttt{drv\_labels\_position} (see~\S~\ref{sec-labels-position}). + +The same way, \param{str list 2} may contain zero, one or two strings +specifying delimiter labels. If one label only is specified then it is attached +to a delimiter placed either to the left or to the right of the sub-tree ending +with the index \param{nat} judgment depending on the default delimiter labels +position set by \texttt{drv\_labels\_position}. + +As an example, ``\texttt{nfr \param{nat} (\param{nat list}) +(\param{str}, \param{id})}'' behaves exactly the same way as +``\texttt{NFR\_opt \param{nat} (\param{nat list}) (\param{str}) () +(\_, \_, \param{id})}''. +% +% +\paragraph{\texttt{DCL\_opt}} +% +% +The \texttt{DCL\_opt} declaration macro is a shorthand for \texttt{jgm} and +\texttt{NFR\_opt} in the same way as \texttt{DCL} is a shorthand for +\texttt{jgm} and \texttt{NFR}. +% +% +\paragraph{\texttt{MVD\_opt}} +% +% +The \texttt{MVD\_opt} macro is an alternative for \texttt{MVD} that lets you +specify labels at your option.\\[1ex] +\texttt{MVD\_opt \param{nat 1} (\param{nat 2}) +(\param{str list}) (\param{id 1} \param{id 2})}\\ +\begin{tabular}{ll} +\param{nat 1}& index of the origin judgment\\ +\param{nat 2}& number of phantom steps\\ +\param{str list}& list of labels \emph{math-mode} \LaTeX\ code\\ +\param{id 1}& alignment style identifier ({\tt l}, {\tt c}, {\tt r} + or {\tt u})\\ +\param{id 2}& phantom steps path-style identifier ({\tt0}, {\tt1}, + {\tt2}, {\tt3}, {\tt4}, {\tt5}, {\tt6} or {\tt\_}) +\end{tabular}\\[1ex] +The list \param{str list} may contain zero, one or two +strings specifying labels. If one label only is specified then it is attached +either to the left or to the right of the phantom steps path depending on the +default phantom steps labels position set by +\texttt{drv\_labels\_position} (see~\S~\ref{sec-labels-position}). +% +% +\subsection{User defined declaration macros (tricky)\label{sec-user-defined}} +% +% +Here are the \MP\ headers for \texttt{NFR}, \texttt{MVD}, \texttt{NFR\_opt} and +\texttt{MVD\_opt}. +\begin{Verbatim}[commandchars=\\\{\}] +NFR[](text PRM)(expr lilb, \!rilb, \!ldlb, \!rdlb)(suffix jsty, \!asty, \!isty) +MVD[](expr num, lplb, rplb)(suffix asty, psty) +NFR_opt[](text PRM)(text ILB)(text DLB)(suffix jsty, asty, isty) +MVD_opt[](expr num)(text PLB)(suffix asty, psty) +\end{Verbatim} +``\texttt{[]}'' in the header of a macro indicates that this macro expects a +numeric argument referred to as ``\texttt{@}'' in its body. +``\texttt{text}'', ``\texttt{expr}'' and ``\texttt{suffix}'' specify argument +types (see~\cite[Section 10]{hobby09}). You may use \texttt{NFR}, \texttt{MVD}, +\texttt{NFR\_opt} and \texttt{MVD\_opt} to define your own declaration macros. +Here are possible definitions for \texttt{Nfr} and \texttt{Mvd}. +\begin{Verbatim} +vardef Nfr[](text PRM)(expr ilb, ldlb, rdlb)(suffix isty)= + NFR_opt[@](PRM)(ilb)(ldlb, rdlb)(_, _, isty); +enddef; +\end{Verbatim} +\begin{Verbatim} +vardef Mvd[](expr num, lplb, rplb)(suffix psty)= + MVD[@](num, lplb, rplb, _, psty) % Mvd returns an index, no `;'! +enddef; +\end{Verbatim} +% +% +\section{Inside derivation trees\label{sec-inside}} +% +% +\subsection{Components, distinguished points and +dimensions\label{sec-components}} +% +% +\paragraph{Components} +% +% +Once \texttt{drv\_freeze} has been called, all the components of a derivation +tree are accessible independently from each-other. +% +% +\begin{Verbatim} +beginfig(470) % components +DCL 6 () ("", "", "", "", _, _, 0) "0"; +DCL 7 (6) ("(1)", "(2)", "(3)", "(4)", _, _, 1) "A", "B"; +drv_freeze; % usually called by drv_tree +draw jdg[6]; % judgment 0 +draw sbj[7][0] withcolor (0, 0, 1); % sub-judgment A +draw sbj[7][1] withcolor (0, 1, 0); % sub-judgment B +draw l_ilb[7] withcolor (0, 1, 1); % left inference label (1) +draw r_ilb[7] withcolor (1, 0, 0); % right inference label (2) +draw l_dlb[7] withcolor (1, 0, 1); % left delimiter label (3) +draw r_dlb[7] withcolor (1, 1, 0); % right delimiter label (4) +draw l_dlm[7]; % left delimiter +draw iln[7]; % inference line +draw r_dlm[7]; % right delimiter +endfig; +\end{Verbatim} +%\begin{gather*} +%\drv{drv-guide.470}\qquad\drv{drv-guide.471} +%\end{gather*} +% +% +\paragraph{Distinguished points} +% +% +Three distinguished points are associated with each component \param{cpn}, +namely \texttt{\param{cpn}.l}, \texttt{\param{cpn}.c} and +\texttt{\param{cpn}.r} that lie respectively to the left, at the center and to +the right of the component math-axis. +\begin{gather*} +\begin{array}{cc} +\text{components}&\text{central points}\\[1ex] +\drv{drv-guide.470}&\drv{drv-guide.471} +\end{array} +\end{gather*} +% +% +\paragraph{Dimensions} +% +% +Two dimensions are associated with each component \param{cpn}, a depth +\texttt{\param{cpn}.dp} and a height \texttt{\param{cpn}.hg} that both are +relative to the component math-axis. Two overall dimensions are associated with +each derivation tree, \texttt{den\_dp} and \texttt{num\_hg}. The former +refers to the depth of a judgment math-axis relatively to the axis of an +inference line above it while the latter refers to the height of a judgment +math-axis relatively to the axis of an inference line below it. Depths are +negative while heights are positive. +\begin{Verbatim} +beginfig(470) +dcl 0 () ("", 0) "\gamma"; +dcl 1 (0) ("", 1) "\delta"; +draw drv_tree; +endfig; +\end{Verbatim} +(The picture below may look weird if you don't use scalable fonts.) +\begin{gather*} +\drv{drv-guide.480} +\end{gather*} +% +% +\subsection{\texttt{drv\_styled}\label{sec-styled}} +% +% +\texttt{drv\_styled} allows you to draw \MP\ paths using \texttt{drv.mp} +path-styles.\\[1ex] +\texttt{\param{path} drv\_styled \param{id}}\\ +\begin{tabular}{ll} +\param{path}& \MP\ path expression\\ +\param{id}& path style identifier ({\tt0}, {\tt1}, {\tt2}, {\tt3}, + {\tt4}, {\tt5} or {\tt6}) +\end{tabular} +\begin{Verbatim} +beginfig(490) +jgm 4 "A", "\vdash", "A"; +jgm 5 "B", "\vdash", "B"; +jgm 6 "A", ",", "A", "\multimap", "B", "\vdash", "B"; +jgm 7 "A", "\multimap", "B", "\vdash", "A", "\multimap", "B"; +nfr 4 () ("1", _); +nfr 5 () ("1", _); +nfr 6 (4, 5) ("\multimap_{L}", _); +nfr 7 (6) ("\multimap_{R}", _); +drv_freeze; +draw (sbj[7][2].c shifted (0, -num_hg) .. + sbj[7][2].c {up} .. + sbj[6][4].c .. + sbj[5][0].c .. tension 1.05 .. + sbj[5][2].c .. + sbj[6][6].c .. + sbj[7][6].c {down} .. + sbj[7][6].c shifted (0, -num_hg)) +drv_styled 2 withcolor (1, 0, 0); +draw drv_tree; +endfig; +\end{Verbatim} +\begin{gather*} +\drv{drv-guide.490} +\end{gather*} +% +% +\subsection{User specified junction \& alignment styles +(tricky)\label{sec-user-specified}} +% +% +\texttt{drp.mp} composes derivation trees by stating geometrical constraints to +be solved by \MP. These constraints express how the components of a derivation +tree must be arranged with respect to each-other. In the example about +dimensions (see above), such a constraint could be that the vertical +distance from +\texttt{iln[1].c} to \texttt{jdg[0].c} has to be \texttt{num\_hg}, which could +be \emph{stated} in the \MP\ syntax as +``\texttt{ypart jdg[0].c=ypart iln[1].c+num\_hg}'' (this is \emph{not} an +affectation). + +You can prevent \texttt{drp.mp} from stating \emph{horizontal} +constraints about premises junction or judgments alignment by using the +junction style~\texttt{3} or the alignment style~\texttt{u} of the \texttt{NFR} +and \texttt{NFR\_opt} macros +(see~\S~\ref{sec-NFR-DCL-MVD},~\ref{sec-labels}). In such cases, you have +to state your own constraints. All the constraints related to a derivation tree +must be stated \emph{before} \texttt{drv\_freeze} is called. \MP\ will complain +if the constraints you state are insufficient, redundant or inconsistent. +% +% +\paragraph{User specified junction style} +% +% +The \emph{horizontal} constraints you state should express how the premises +of the inference have to be joined. +\begin{Verbatim} +beginfig(500) +jgm 0 "{\cdot}"; +jgm 1 "{\cdot}"; +jgm 2 "\text{You may check that the distance"& + " between the two dots above is 5 cm.}"; +NFR 0 () ("", "", "", "", _, _, _); +NFR 1 () ("", "", "", "", _, _, _); +NFR 2 (0, 1) ("", "", "", "", 3, _, _); % caution: 3 +xpart jdg[1].c=xpart jdg[0].c+5cm; +draw drv_tree; +endfig; +\end{Verbatim} +\begin{gather*} +\drv{drv-guide.500} +\end{gather*} +% +% +\paragraph{User specified alignment style} +The \emph{horizontal} constraints you state should express how the inferred +judgment has to be aligned with respect to its premises. +% +% +\begin{Verbatim}[commandchars=\\\{\}] +beginfig(510) % "\tbs{}vdash": +jgm 0 "B, A, \tbs{}Gamma", "\tbs{ +}vdash", "C"; % sbj[0][1] +jgm 1 "A, \tbs{}Gamma", "\tbs{ +}vdash", "B\tbs{}multimap C"; % sbj[1][1] +jgm 2 "\tbs{}Gamma", "\tbs{ +}vdash", "A\tbs{}multimap(B\tbs{}multimap C)"; % sbj[2][1] +NFR_opt 0 () () () (_, _, 0); +NFR_opt 1 (0) ("\tbs{}multimap_{R}") () (_, u, 1); % caution: u +NFR_opt 2 (1) ("\tbs{}multimap_{R}") () (_, u, 1); % caution: u +xpart sbj[1][1].c=xpart sbj[0][1].c; +\resplap{}xpart sbj[1][1].l=xpart sbj[0][1].r; +xpart sbj[2][1].c=xpart sbj[1][1].c; +\resplap{}xpart sbj[2][1].l=xpart sbj[1][1].r; +draw drv_tree; +endfig; +\end{Verbatim} +\begin{gather*} +\drv{drv-guide.510}\quad\text{resp.}\quad\drv{drv-guide.511} +\end{gather*} +% +% +\addcontentsline{toc}{section}{References} +% +% +\begin{thebibliography}{1} +\bibitem{hobby09} +John~D. \textsc{Hobby}. +\href{http://tug.org/docs/metapost/mpman.pdf} +{\emph{A User's Manual for \MP}}, 2009 +\bibitem{jackowski06} +Bogus{\l}aw \textsc{Jackowski}. +\href{http://tug.org/TUGboat/Articles/tb27-1/tb86jackowski.pdf} +{\emph{Appendix G illuminated}}. \emph{TUGboat}, 27(1):83--90, 2006. +\bibitem{knuth84} +Donald~E. \textsc{Knuth}. +\emph{The {\TeX}book}. +Addison-Wesley, 1984. +\bibitem{restall06} +Greg \textsc{Restall}. +\href{http://consequently.org/papers/ptp.pdf} +{\emph{Proof Theory and Philosophy}}. Book in progress, 2006. +\bibitem{roegel02} +Denis \textsc{Roegel}. +\href{http://www.ctan.org/get/graphics/metapost/contrib/macros/% +metaobj/doc/momanual.pdf}{\emph{The MetaObj tutorial and reference manual}}, +2002. +\bibitem{lutz06} +Lutz \textsc{Stra\ss{}burger}. +\href{http://www.lix.polytechnique.fr/~lutz/papers/RR-6013.pdf} +{\emph{Proof Nets and the Identity of Proofs}}. \textsc{Inria}, 2006. +\end{thebibliography} +% +% +\appendix +\section{Debugging\label{sec-debugging}} +% +% +Recall that you have to run ``\texttt{mpost \param{jobname}.mp}'' \emph{at +least twice} (once more if you use sub-tree delimiters). If you get an error on +the first run then it comes from the \texttt{drv.mp}/\MP\ code. If you get an +error on the second run then it comes from the \LaTeX\ code. +% +% +\paragraph{Error on the first run} +\MP\ behaves essentially as \TeX/\LaTeX\ when it finds and error +(see~\cite[Debugging]{hobby09}). It stops, ``explains'' the error in some way +(look for the line starting with an exclamation mark \texttt{!}), shows some +lines of context, and asks you what to do next (answer \texttt{h} to get some +help or \texttt{x} to terminate the run). If you're lucky, the error comes from +an inconsistency that \texttt{drv.mp} can detect. In such a case the +explanation should be quite understandable. +\begin{multicols}{2} +\begin{Verbatim}[numbers=left,firstnumber=46] +beginfig(520) +jgm 0 "A\vdash B"; +jgm 1 "B\vdash C"; +jgm 2 "A\vdash C"; +jgm 3 "C\vdash D"; +jgm 4 "A\vdash D"; +nfr 0 () ("f", _); +nfr 1 () ("g", _); +nfr 2 (0, 1) ("\circ", _); +nfr 3 () ("h", _); +nfr 4 (0, 3) ("\circ", _); +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak +\MP\ error message. +\begin{Verbatim}[commandchars=\\\{\}] +! drv (fig. 520): 0 has been used +already as a premise index for +inference declaration 2. +\param{error context} +l.56 nfr 4 (0, 3) ("{\tbs}circ", 1) + ; +? +\end{Verbatim} +\end{multicols} +% +% +\paragraph{Error on the second run} +\MP\ fails to preprocess the \LaTeX\ code in +\texttt{\param{jobname}-delayed.mp} and suggests that you ``\texttt{see +mpxerr.log}'' which is a regular \LaTeX\ log-file. This file shows you which +part of the \LaTeX\ code is faulty but unfortunately not where to find it in +\texttt{\param{jobname}.mp}. +% +% +\section{Gallery\label{sec-gallery}} +% +% +Here are the \texttt{drv.mp} version of a derivation tree found +in~\cite[p.~57]{restall06} and an alternative for it (figures~530,~531). +% +% +\begin{gather*} +\drv{drv-guide.530} +\end{gather*} +\begin{gather*} +\drv{drv-guide.531} +\end{gather*} +% +% +Here is the \texttt{drv.mp} version of a derivation tree found +in~\cite[p.~86]{roegel02} (figure~540). +\begin{gather*} +\drv{drv-guide.540} +\end{gather*} +% +% +Here are the \texttt{drv.mp} versions of derivations trees found +in~\cite[p.~50]{lutz06} (figures~550,~551). +\begin{gather*} +\drv{drv-guide.550}\quad\to\quad\drv{drv-guide.551} +\end{gather*} +% +% +Here is a continued fraction composed by \texttt{drv.mp} (figure~560). +\begin{gather*} +\drv{drv-guide.560} +\end{gather*} +% +% +\section{Standalone picture files\label{sec-standalone}} +% +% +Given a PostScript file \texttt{\param{jobname}.\param{index}} generated by +\MP, you may get a standalone \textsc{pdf} file (with embedded fonts) +\texttt{\param{jobname}-\param{index}.pdf} by running +\begin{center} +\texttt{mptopdf \param{jobname}.\param{index}} +\end{center} +(\texttt{mptopdf} should be part of your \TeX\ distribution). Next you may +get a standalone \textsc{ps} file \texttt{\param{jobname}-\param{index}.ps} by +running +\begin{center} +\texttt{pdftops \param{jobname}-\param{index}.pdf} +\end{center} +(\texttt{pdftops} is part of the Xpdf software package). Finally you may get a +standalone \emph{transparent} \textsc{png} file +\texttt{\param{jobname}-\param{index}.png} by running +\begin{center} +\texttt{convert \param{jobname}-\param{index}.ps +\param{jobname}-\param{index}.png} +\end{center} +(\texttt{convert} is part of the ImageMagick software package). Notice that you +can run \texttt{convert} on \texttt{\param{jobname}-\param{index}.pdf} but then +the \textsc{png} file you get is not transparent. +% +% +\section{Related packages\label{sec-related}} +% +% +\begin{itemize} +\item +\href{http://math.ucsd.edu/~sbuss/ResearchWeb/bussproofs/} +{\texttt{bussproofs.sty}} +(Samuel R. \textsc{Buss}); +\item +\href{http://research.nii.ac.jp/~tatsuta/proof-sty.html} +{\texttt{proof.sty}} +(Makoto \textsc{Tatsuta}); +\item +\href{http://www.paultaylor.eu/proofs/index.html} +{\texttt{prooftree.sty}} +(Paul \textsc{Taylor}); +\item +the \texttt{Ptree} constructor from +\href{http://tug.ctan.org/tex-archive/graphics/% +metapost/contrib/macros/metaobj/}{\texttt{metaobj.mp}} +(Denis \textsc{Roegel}, see~\cite{roegel02}); +\item +\href{http://tug.ctan.org/tex-archive/macros/latex/contrib/semantic/} +{\texttt{semantic.sty}} +(Peter M\o ller \textsc{Neergaard} \& Arne John \textsc{Glenstrup}); +\item +\href{http://alessio.guglielmi.name/res/vl/} +{\texttt{virginialake.sty}} +(Alessio \textsc{Guglielmi}). +\end{itemize} +Some of these are described on Peter \textsc{Smith}'s +``\href{http://www.phil.cam.ac.uk/teaching_staff/Smith/logicmatters/% +latexforlogician.html}{\LaTeX\ for Logicians}'' webpage. +\end{document} diff --git a/Master/texmf-dist/doc/metapost/drv/doc/drv.mp b/Master/texmf-dist/doc/metapost/drv/doc/drv.mp new file mode 100644 index 00000000000..5eb38396144 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/doc/drv.mp @@ -0,0 +1,2245 @@ +%% drv.mp 0.93 +%% Copyright 2009 Laurent M\'ehats +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Laurent M\'ehats. +% <laurent.mehats@gmail.com> +% +% This work consists of the file drv.mp + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% User's macros summary +% +% +% * Judgment & inference declarations +% =================================== +% +% jgm <nat> <str list> +% <nat> judgment index +% <str list> sub-judgments math-mode LaTeX code +% +% nfr <nat> (<nat list>) (<str>, <id>) +% <nat> inference index +% <nat list> list of premise indices +% <str> inference label math-mode LaTeX code +% <id> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% 0 none +% 1 simple +% 2 double +% 3 dotted +% 4 dashed +% 5 waved +% 6 TeX-dotted +% _ default (set by drv_path_style) +% +% mvd <nat 1> (<nat 2>, <id>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <id> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% Nfr <nat> (<nat list>) (<str 1>, <str 2>, <str 3>, <id>) +% <nat> inference index +% <nat list> list of premise indices +% <str 1> inference label math-mode LaTeX code +% <str 2> left delimiter label math-mode LaTeX code +% <str 3> right delimiter label math-mode LaTeX code +% <id> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% Mvd <nat 1> (<nat 2>, <str 1>, <str 2>, <id>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str 1> left label math-mode LaTeX code +% <str 2> right label math-mode LaTeX code +% <id> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% NFR <nat> (<nat list>) (<str 1>, <str 2>, <str 3>, <str 4>) +% (<id 1>, <id 2>, <id 3>) +% <nat> inference index +% <nat list> list of premise indices +% <str 1> left inference label math-mode LaTeX code +% <str 2> right inference label math-mode LaTeX code +% <str 3> left delimiter label math-mode LaTeX code +% <str 4> right delimiter label math-mode LaTeX code +% <id 1> junction style identifier (0, 1, 2, 3 or _) +% 0 fully-interlacing +% 1 semi-interlacing +% 2 non-interlacing +% 3 user specified (tricky) +% _ default (set by drv_junction_style) +% <id 2> alignment style identifier (l, c, r, u or _) +% l left +% c centered +% r right +% u user specified (tricky) +% _ default (set by drv_alignment_style) +% <id 3> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% MVD <nat 1> (<nat 2>, <str 1>, <str 2>, <id 1> <id 2>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str 1> left label math-mode LaTeX code +% <str 2> right label math-mode LaTeX code +% <id 1> alignment style identifier (l, c, r, u or _) +% <id 2> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% NFR_opt <nat> (<nat list>) (<str list 1>) (<str list 2>) +% (<id 1>, <id 2>, <id 3>) +% <nat> inference index +% <nat list> list of premise indices +% <str list 1> list of inference labels math-mode LaTeX code +% <str list 2> list of delimiter labels math-mode LaTeX code +% <id 1> junction style identifier (0, 1, 2, 3 or _) +% <id 2> alignment style identifier (l, c, r, u or _) +% <id 3> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% MVD_opt <nat 1> (<nat 2>) (<str list>) (<id 1> <id 2>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str list> list of labels math-mode LaTeX code +% <id 1> alignment style identifier (l, c, r or u) +% <id 2> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% * Tunings +% ========= +% +% drv_font_size <str> +% <str> LaTeX font-size command +% "\tiny" +% "\scriptsize" +% "\footnotesize" +% "\small" +% "\normalsize" +% "\large" +% "\Large" +% etc. +% +% drv_math_style (<id>, <str>) +% <id> component identifier (drv, jdg, ilb, dlb or plb) +% drv derivation trees +% jdg judgments +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <str> LaTeX math-style command +% +% drv_scale (<id>, <float>) +% <id> scale identifier (clr, prm, jdg or ilb) +% clr nice explanation soon (see examples) +% prm nice explanation soon (see examples) +% jdg nice explanation soon (see examples) +% ilb nice explanation soon (see examples) +% <float> scale value +% +% drv_junction_style <id> +% <id> junction style identifier (0, 1 or 2) +% 0 ``fully-interlacing'' +% 1 ``semi-interlacing'' +% 2 ``non-interlacing'' +% +% drv_alignment_style <id> +% <id> alignment style identifier (l, c or r) +% l left +% c centered +% r right +% +% drv_path_style (<id 1>, <id 2>) +% <id 1> path-type identifier (iln or phm) +% iln inference lines +% phm phantom steps paths +% <id 2> path-style identifier (0, 1, 2, 3, 4, 5 or 6) +% +% drv_labels_position (<id 1>, <id 2>) +% <id 1> label-type identifier (ilb, plb or dlb) +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <id 2> position identifier (l or r) +% l left +% r right +% +% drv_roots_position <id> +% <id> position identifier (t or b) +% t top +% b bottom +% +% drv_axis_reference <id> +% <id> reference identifier (iln or jdg) +% iln root inference line axis +% jdg root judgment math-axis +% +% drv_left_delimiter <str> +% <str> left delimiter math-mode LaTeX code +% "(" $($ +% "[" $[$ +% "\lbrace" $\lbrace$ +% "\langle" $\langle$ +% etc. +% +% drv_right_delimiter <str> +% <str> right delimiter math-mode LaTeX code +% ")" +% "]" +% "\rbrace" +% "\rangle" +% etc. +% +% drv_box_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_fraction_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_proof_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% * Derivation tree pictures +% ========================== +% +% drv_bbox <nat> +% <nat> sub-tree root index +% +% drv_axis (<id>, <nat>) +% <id> reference type identifier (iln, jdg or dlm) +% iln inference line axis +% jdg judgment math-axis +% dlm delimiter axis +% <nat> reference index +% +% <path> drv_styled <id> +% <path> MetaPost path expression +% <id> path style identifier (0, 1, 2, 3, 4, 5 or 6) +% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MetaPost messages formatting +% + +% drv_format prevents messages from being automatically cut into lines every +% 79 characters: if possible, a word which would otherwise be cut is 'pushed' +% to the following line by inserting space characters before it. + +vardef drv_format (expr str, fst_len, nxt_len, dbl_pcs)= + % str: the message to be formatted + % fst_len: first line length + % nxt_len: following lines length + % dbl_pcs (boolean): occurrences of the percent character must be doubled + save str_len, sub_len, aux_len, chr_rnk, occ_num; + numeric str_len, sub_len, aux_len, chr_rnk, occ_num; + save aux_str, chr; + string aux_str, chr; + str_len:=length str; + sub_len:=0; + chr_rnk:=0; + occ_num:=0; + aux_len:=0; + aux_str:=""; + forever: + exitif (chr_rnk=fst_len) or (chr_rnk=str_len); + chr:=substring (chr_rnk, chr_rnk+1) of str; + aux_str:=aux_str&chr; + if chr=" ": + sub_len:=chr_rnk+1; + aux_len:=sub_len+occ_num; + elseif (chr="%") and dbl_pcs: + aux_str:=aux_str&"%"; + occ_num:=occ_num+1; + fi + chr_rnk:=chr_rnk+1; + endfor + if chr_rnk=fst_len: + begingroup + if sub_len=0: + sub_len:=fst_len; + aux_len:=sub_len+occ_num; + fi + substring (0, aux_len) of aux_str& + for idx=sub_len+1 upto fst_len: + " "& + endfor + drv_format (substring (sub_len, str_len) of str, + nxt_len, nxt_len, dbl_pcs) + endgroup + else: + aux_str + fi +enddef; + +boolean drv_inside_fig; +drv_inside_fig:=false; + +vardef drv_context= + "drv"&if drv_inside_fig: " (fig. "&decimal charcode&")"&fi ": " +enddef; + +vardef drv_message expr str= + message drv_format (drv_context&str, 79, 79, false); +enddef; + +vardef drv_errhelp expr str= + % Occurrences of the percent character must be doubled: errhelp makes single + % single occurrences behave as newline characters (this is inherited from + % MetaFont). + errhelp drv_format (str, 79, 79, true); +enddef; + +vardef drv_errmessage expr str= + % errmessage inserts the 2-characters string "! " before its argument. + % Hence 77 as a first line length argument. + errmessage drv_format (drv_context&str, 77, 79, false); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Delayed LaTeX processing +% + +picture tex_pct[]; +string delayed_tex_file; +delayed_tex_file:=jobname&"-delayed.mp"; + +% +% reading LaTeX picture definitions +% + +boolean drv_nullpicture; +drv_nullpicture:=true; + +string readfrom_str; +readfrom_str:=readfrom delayed_tex_file; +if readfrom_str<>EOF: + closefrom delayed_tex_file; + drv_message ("reading `"&delayed_tex_file&"' LateX picture definitions."); + batchmode; + scantokens ("input "&delayed_tex_file); + errorstopmode; + drv_message "done."; + drv_nullpicture:=false; +fi + +% +% copying LaTeX preamble +% + +vardef drv_read (expr search_str) (suffix accum_str)= + save readfrom_str, readfrom_substr; + string readfrom_str, readfrom_substr; + accum_str:=""; + forever: + readfrom_str:=readfrom jobname; + readfrom_substr:=substring (0, length search_str) of readfrom_str; + exitif (readfrom_substr=search_str) or (readfrom_str=EOF); + accum_str:=accum_str&readfrom_str&char(10); + endfor + if readfrom_str=EOF: + closefrom jobname; + drv_errhelp ("`"&jobname&".mp' should contain a line starting with "& + ditto&search_str&ditto&"."); + drv_errmessage (ditto&search_str&ditto&" is missing"); + fi +enddef; + +string tex_preamble_str[]; +% tex_preamble_str[0] from "verbatimtex %&latex" to "\begin{document}" +% tex_preamble_str[1] from "\begin{document}" to "etex;" + +drv_message ("reading `"&jobname&".mp' LateX preamble."); + drv_read ("verbatimtex %&latex", tex_preamble_str[0]); + drv_read ("\begin{document}", tex_preamble_str[0]); + drv_read ("etex;", tex_preamble_str[1]); + closefrom jobname; + write + "%"&char(10)& + "% AUTOMATICALLY GENERATED BY DRV.MP - DO NOT MODIFY."&char(10)& + "%"&char(10)&char(10)& + "verbatimtex %&latex"&char(10)& + tex_preamble_str[0]& + "\begin{document}"&char(10)& + tex_preamble_str[1]& + "etex;" + to delayed_tex_file; +drv_message "done."; + +% +% writing LaTeX picture definitions +% + +numeric tex_pct_idx; +tex_pct_idx:=0; + +% Math style indices: 0, 1, 2, 3 +string mth_sty_str[]; +mth_sty_str[0]:="\displaystyle"; +mth_sty_str[1]:="\textstyle"; +mth_sty_str[2]:="\scriptstyle"; +mth_sty_str[3]:="\scriptscriptstyle"; + +string drv_fontsize; + +vardef drv_tex[] expr tex_str= + % @: math style index + % tex_str: math mode LaTeX code + save def_str, pct; + string def_str; + picture pct; + def_str:="btex{"&drv_fontsize&"$"&mth_sty_str[@]&"{}"&tex_str&"{}$}etex;"; + write "tex_pct["&(decimal tex_pct_idx)&"]:="&def_str to delayed_tex_file; + pct:= + if known tex_pct[tex_pct_idx]: + tex_pct[tex_pct_idx] + else: + nullpicture + fi; + tex_pct_idx:=tex_pct_idx+1; + pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MetaPost shorthands +% + +vardef depth expr pct= + ypart llcorner pct +enddef; + +vardef height expr pct= + ypart urcorner pct +enddef; + +vardef width expr pct= + xpart urcorner pct-xpart llcorner pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Font-specific parameters +% + +% +% em[s] width of an m (s: mathstyle index) +% ex[s] height of an x +% axis_hg[s] height of the mathematical axis +% num_bl_hg[s] height of a numerator baseline w.r.t. the fraction bar axis +% den_bl_dp[s] depth of a denominator baseline w.r.t. the fraction bar axis +% rul_thk[s] default rule thickness +% + +numeric em[], ex[], axis_hg[], num_bl_hg[], den_bl_dp[], rul_thk[]; + +% +% thn_sp[s] thin space, usually 1em/6 +% med_sp[s] medium space, usually 2em/9 +% thk_sp[s] thick space, usually 5em/18 +% + +numeric thn_sp[], med_sp[], thk_sp[]; + +% +% pdt_hg[s] height of a punctuation ldot +% pdt_wd[s] width of a punctuation ldot +% + +numeric pdt_hg[], pdt_wd[]; + +% +% tt_dgt[s][i] typewriter typeface digits (i ranges from 0 to 9) +% + +picture tt_dgt[][]; + +% +% min_clr[s] minimal clearance between a numerator +% or a denominator and the fraction bar +% prm_skp[s] <nice explanation> +% jdg_skp[s] <nice explanation> +% ilb_skp[s] <nice explanation> +% plb_skp[s] <nice explanation> +% + +numeric min_clr[], prm_skp[], jdg_skp[], ilb_skp[], plb_skp[]; + +vardef drv_fontdimen[] expr font= + save dim_pct; + picture dim_pct; + dim_pct:=drv_tex[0] ("\rule{\the\fontdimen"&(decimal @)&font&"}{0bp}"); + width dim_pct +enddef; + +vardef drv_font_size expr size_str= + save pdt_pct, sp_pct; + picture pdt_pct, sp_pct; + drv_fontsize:=size_str; + write char(10)&"% font-specific parameters ("&drv_fontsize&")"&char(10) + to delayed_tex_file; + ex[0]:=drv_fontdimen[5] "\textfont2"; + ex[1]:=drv_fontdimen[5] "\textfont2"; + ex[2]:=drv_fontdimen[5] "\scriptfont2"; + ex[3]:=drv_fontdimen[5] "\scriptscriptfont2"; + em[0]:=drv_fontdimen[6] "\textfont2"; + em[1]:=drv_fontdimen[6] "\textfont2"; + em[2]:=drv_fontdimen[6] "\scriptfont2"; + em[3]:=drv_fontdimen[6] "\scriptscriptfont2"; + rul_thk[0]:=drv_fontdimen[8] "\textfont3"; + rul_thk[1]:=drv_fontdimen[8] "\textfont3"; + rul_thk[2]:=drv_fontdimen[8] "\scriptfont3"; + rul_thk[3]:=drv_fontdimen[8] "\scriptscriptfont3"; + axis_hg[0]:=drv_fontdimen[22] "\textfont2"; + axis_hg[1]:=drv_fontdimen[22] "\textfont2"; + axis_hg[2]:=drv_fontdimen[22] "\scriptfont2"; + axis_hg[3]:=drv_fontdimen[22] "\scriptscriptfont2"; + num_bl_hg[0]:=(drv_fontdimen[8] "\textfont2")-axis_hg[0]; + num_bl_hg[1]:=(drv_fontdimen[9] "\textfont2")-axis_hg[1]; + num_bl_hg[2]:=(drv_fontdimen[9] "\scriptfont2")-axis_hg[2]; + num_bl_hg[3]:=(drv_fontdimen[9] "\scriptscriptfont2")-axis_hg[3]; + den_bl_dp[0]:=-(drv_fontdimen[11] "\textfont2")-axis_hg[0]; + den_bl_dp[1]:=-(drv_fontdimen[12] "\textfont2")-axis_hg[1]; + den_bl_dp[2]:=-(drv_fontdimen[12] "\scriptfont2")-axis_hg[2]; + den_bl_dp[3]:=-(drv_fontdimen[12] "\scriptscriptfont2")-axis_hg[3]; + min_clr[0]:=3*rul_thk[0]; % The TEXbook, + min_clr[1]:=1*rul_thk[1]; % Appendix G, + min_clr[2]:=1*rul_thk[2]; % Rule 15d. + min_clr[3]:=1*rul_thk[3]; % + for mth_sty:=0 upto 3: + sp_pct:=drv_tex[mth_sty] "\,"; + thn_sp[mth_sty]:=width sp_pct; + sp_pct:=drv_tex[mth_sty] "\>"; + med_sp[mth_sty]:=width sp_pct; + sp_pct:=drv_tex[mth_sty] "\;"; + thk_sp[mth_sty]:=width sp_pct; + pdt_pct:=drv_tex[mth_sty] "\ldotp"; + pdt_hg[mth_sty]:=height pdt_pct; + pdt_wd[mth_sty]:=width pdt_pct; + for dgt=0 upto 9: + tt_dgt[mth_sty][dgt]:=drv_tex[mth_sty] "\texttt{"&(decimal dgt)&"}"; + endfor + prm_skp[mth_sty]:=3*med_sp[mth_sty]; % arbitrary + jdg_skp[mth_sty]:=thn_sp[mth_sty]; % arbitrary + ilb_skp[mth_sty]:=thn_sp[mth_sty]; % arbitrary + plb_skp[mth_sty]:=thk_sp[mth_sty]; % arbitrary + endfor +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Math-related parameters & macros +% + +% +% Math styles +% drv_sty derivation trees +% jdg_sty[drv_sty] judgments +% ilb_sty[drv_sty] inference labels +% dlb_sty[drv_sty] delimiter labels +% plb_sty[drv_sty] phantom steps labels +% + +numeric drv_sty, jdg_sty[], ilb_sty[], dlb_sty[], plb_sty[]; + +% +% Math-axis centered LaTeX pictures +% + +vardef mth_tex[] expr tex_str= + (drv_tex[@] tex_str) shifted (0, -axis_hg[@]) +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% drv-boxes +% + +vardef drv_box text STR= + for str=STR: + expandafter picture scantokens str; + expandafter pair scantokens str.l; + expandafter pair scantokens str.c; + expandafter pair scantokens str.r; + expandafter numeric scantokens str.hg; + expandafter numeric scantokens str.dp; + endfor +enddef; + +vardef box_init @# (expr pct)= + @#:=pct; + @#.r-@#.l=(width pct, 0); + @#.c=(@#.l+@#.r)/2; + @#.hg:=height pct; + @#.dp:=depth pct; +enddef; + +vardef box_freeze @#= + @#:=@# shifted @#.l; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% beginfig & endfig +% + +% +% drv_beginfig: figure initialization +% + +pen drv_pen; + +vardef drv_beginfig= + % + % Judgments + % + % jdg[i] judgment drv-box + % sbj_num[i] number of sub-judgments + % sbj[i][j] sub-judgment drv-box (j ranges from 0 to sbj_num[i]-1) + % + drv_box "jdg[]"; + numeric sbj_num[]; + drv_box "sbj[][]"; + % + % Inferences + % + % prm_num[i] number of premises + % prm[i][j] premise index (j ranges from 0 to prm_num[i]-1) + % ccl[i] conclusion index + % jct_sty[i] junction style + % alg_sty[i] alignment style + % iln_sty[i] inference line style + % l_prm[i] leftmost `graphical' premise index + % r_prm[i] rightmost `graphical' premise index + % + numeric prm_num[], prm[][], ccl[]; + numeric jct_sty[]; + string alg_sty[]; + numeric iln_sty[]; + numeric l_prm[], r_prm[]; + % + % imin_x[i] inference minimal x + % l_dlb[i] left delimiter label drv-box + % l_dlm[i] left delimiter drv-box + % l_ilb[i] left label drv-box + % iln[i] inference line drv-box + % r_ilb[i] right label drv-box + % r_dlm[i] right delimiter drv-box + % r_dlb[i] right delimiter label drv-box + % imax_x[i] inference maximal x + % + numeric imin_x[]; + drv_box "l_dlb[]", "l_dlm[]", "l_ilb[]"; + drv_box "iln[]"; + drv_box "r_ilb[]", "r_dlm[]", "r_dlb[]"; + numeric imax_x[]; + % + % Sub-trees + % + % smin_x[i] sub-tree minimal x + % smax_x[i] sub-tree maximal x + % smin_y[i] sub-tree minimal y + % smax_y[i] sub-tree maximal y + % boxed[i] boolean + % + numeric smin_x[], smax_x[], smin_y[], smax_y[]; + boolean boxed[]; + % + % Pen initialization + % + drv_pen:=pencircle scaled rul_thk[drv_sty]; + % + % num_hg height of a numerator axis w.r.t. the fraction bar axis + % den_dp depth of a denominator axis w.r.t. the fraction bar axis + % iln_hg[s] height of a style s inference line + % iln_dp[s] depth of a style s inference line + % + numeric num_hg, den_dp, iln_hg[], iln_dp[]; + num_hg:=num_bl_hg[drv_sty]+axis_hg[jdg_sty[drv_sty]]; + den_dp:=den_bl_dp[drv_sty]+axis_hg[jdg_sty[drv_sty]]; + picture iln_pct; + for sty=0 upto 6: + iln_pct:=((0, 0)--(10, 0)) drv_styled sty; + iln_hg[sty]:=height iln_pct; + iln_dp[sty]:=depth iln_pct; + endfor + % + % Derivation trees + % + % root_num number of roots + % root[i] root index (i ranges from 0 to root_num-1) + % drv_built boolean + % drv_frozen boolean + % + numeric root_num, root[]; + boolean drv_checked, drv_built, drv_frozen; + root_num:=0; + drv_checked:=false; + drv_built:=false; + drv_frozen:=false; + % + % Phantom steps + % + % phm_idx phantom inferences index + % src[i] base phantom judgment index (in case of an origin judgment) + % tgt[i] origin judgment index (in case of a base phantom judgment) + % phm_sty[i] phantom steps style + % l_plb[i] left phantom steps label drv-box (in case of a base + % phantom judgment) + % phm[i] phantom steps drv-box (in case of a base phantom + % judgment) + % r_plb[i] right phantom steps label drv-box (in case of a base + % phantom judgment) + % + numeric phm_idx, src[], tgt[], phm_sty[]; + phm_idx:=0; + drv_box "l_plb[]", "phm[]", "r_plb[]"; + % + % Proof pictures + % + % jdg_prf[i] judgment index drv-box + % sbj_prf[i][j] sub-judgment index drv-box (j ranges from 0 to + % sbj_num[i]-1) + % + drv_box "jdg_prf[]", "sbj_prf[][]"; + % + % Info + % + write char(10)&"% fig. "&(decimal charcode)&char(10) to delayed_tex_file; + drv_inside_fig:=true; % context: inside a figure +enddef; + +extra_beginfig:=extra_beginfig&"drv_beginfig;"; + +% +% drv_endfig: proof-file generation +% + +string proof_file; +proof_file:=jobname&"-proof.tex"; + +% TODO: taking outputtemplate into account. +vardef output_file[]= + jobname&"."&(decimal @) +enddef; + +string buf_str; +buf_str:= + "%"&char(10)& + "% AUTOMATICALLY GENERATED BY DRV.MP."&char(10)& + "%"&char(10)&char(10)& + tex_preamble_str[0]& + "\usepackage{graphicx}"&char(10)& + "\makeatletter"&char(10)& + "\def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}}"&char(10)& + "\newsavebox{\graphicsbox}"&char(10)& + "\newcommand*{\drv}[1]{%"&char(10)& + "\sbox{\graphicsbox}{\includegraphics{#1}}%"&char(10)& + "\raisebox{\Gin@lly bp}%"&char(10)& + "{\usebox{\graphicsbox}}}"&char(10)& + "\makeatother"&char(10)&char(10)& + "\newcount\h"&char(10)& + "\newcount\m"&char(10)& + "\h=\time"&char(10)& + "\divide\h 60"&char(10)& + "\m=-\h"&char(10)& + "\multiply\m 60"&char(10)& + "\advance\m\time"&char(10)& + "\def\hm{\number\h:\ifnum\m<10{}0\fi\number\m}"&char(10)&char(10)& + "\newcommand{\mathaxis}{\frac{\quad}{}}"&char(10)&char(10)& + "\begin{document}"&char(10)& + tex_preamble_str[1]& + "\noindent\today\ at \hm\medskip"&char(10)&char(10)&"\noindent"; + +vardef drv_endfig= + drv_inside_fig:=false; % context: outside a figure + buf_str:=buf_str&char(10)& + "\texttt{"&output_file[charcode]&"}"&char(10)& + " (\verb+"&drv_fontsize&"+, \verb+"&(mth_sty_str[drv_sty])&"+)"&char(10)& + " {"&drv_fontsize&char(10)& + " \["&(mth_sty_str[drv_sty])&char(10)& + " \mathaxis\drv{"&output_file[charcode]&"}\mathaxis"&char(10)& + " \]}\\"; + write EOF to proof_file; % erases the previous content + write buf_str&char(10)&"\end{document}" to proof_file; + write EOF to proof_file; + if drv_nullpicture: + draw btex{\tt drv}: run {\tt mpost} again.etex withcolor (1, 0, 0); + fi +enddef; + +extra_endfig:="drv_endfig;"&extra_endfig; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Judgment declarations +% + +vardef jgm[] text SUB= + % @: judgment index + % SUB: list of `sub-judgments' (pictures or strings) + if @<0: + drv_errhelp "An judgment index can not be negative."; + drv_errmessage (decimal @)&" is negative"; + elseif known jdg[@]: + drv_errhelp "An index can be used only once to declare a judgment."; + drv_errmessage (decimal @)&" has been used already as a judgment index"; + else: + save jdg_pct, sbj_pct, jdg_wd, sbj_rnk; + picture jdg_pct, sbj_pct; + numeric jdg_wd, sbj_rnk; + jdg_pct:=nullpicture; + jdg_wd:=0; + sbj_rnk:=0; + for sub=SUB: + sbj_pct:= + if picture sub: + sub + elseif sub<>"": + mth_tex[jdg_sty[drv_sty]] sub + else: + nullpicture + fi; + box_init sbj[@][sbj_rnk] (sbj_pct); + if sbj_rnk>0: + sbj[@][sbj_rnk-1].r=sbj[@][sbj_rnk].l; + fi + addto jdg_pct also sbj_pct shifted (jdg_wd, 0); + jdg_wd:=width jdg_pct; + sbj_rnk:=sbj_rnk+1; + endfor + sbj_num[@]:=sbj_rnk; + box_init jdg[@] (jdg_pct); + if sbj_num[@]>0: + jdg[@].l=sbj[@][0].l; + jdg[@].r=sbj[@][sbj_num[@]-1].r; + fi + fi +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Inference declarations +% + +vardef check_junction_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="0") + or (sty_str="1") + or (sty_str="2") + or (sty_str="3"): + sty_sfx + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " 0 (fully-interlacing),"& + " 1 (semi-interlacing),"& + " 2 (non-interlacing),"& + " 3 (user specified) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid junction style identifier"; + default + endgroup + fi +enddef; + +vardef check_alignment_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="l") + or (sty_str="c") + or (sty_str="r") + or (sty_str="u"): + sty_str + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " l (none),"& + " c (simple),"& + " r (double),"& + " u (dotted) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid alignment style identifier"; + default + endgroup + fi +enddef; + +vardef check_path_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="0") + or (sty_str="1") + or (sty_str="2") + or (sty_str="3") + or (sty_str="4") + or (sty_str="5") + or (sty_str="6"): + sty_sfx + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " 0 (none),"& + " 1 (simple),"& + " 2 (double),"& + " 3 (dotted),"& + " 4 (dashed),"& + " 5 (waved),"& + " 6 (TeX-dotted) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid path style identifier"; + default + endgroup + fi +enddef; + +vardef opt_init[] @# expr arg= + if picture arg: + if arg<>nullpicture: + box_init @# (arg); + fi + elseif arg<>"": + box_init @# (mth_tex[@] arg); + fi +enddef; + +vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) + (suffix j_sty, a_sty, i_sty)= + % + % @: inference index + % + if known prm_num[@]: + drv_errhelp "An index can be used only once to declare an inference."; + drv_errmessage (decimal @)&" has been used already as an inference index"; + else: + % + % PRM: list of premise indices + % + save prm_rnk; + numeric prm_rnk; + prm_rnk:=0; + for prm_idx=PRM: + if prm_idx=@: + drv_errhelp "An inference index can not be used"& + " as one of its own premise indices."; + drv_errmessage "the inference index "&(decimal prm_idx)& + " is used as one of its own premise indices"; + elseif known ccl[prm_idx]: + drv_errhelp "An index can be used only once as a premise index."; + drv_errmessage (decimal prm_idx)&" has been used already as a"& + " premise index for inference declaration "&(decimal ccl[prm_idx]); + else: + if known prm_num[prm_idx]: + % + % roots list update + % + save root_idx; + numeric root_idx; + root_idx:=0; + forever: + exitif root[root_idx]=prm_idx; + root_idx:=root_idx+1; + endfor + forever: + exitif root_idx=root_num-1; + root[root_idx]:=root[root_idx+1]; + root_idx:=root_idx+1; + endfor + root_num:=root_num-1; + fi + ccl[prm_idx]:=@; + prm[@][prm_rnk]:=prm_idx; + prm_rnk:=prm_rnk+1; + fi + endfor + prm_num[@]:=prm_rnk; + if known ccl[@]: + % + % cycle detection + % + save ccl_idx, ccl_str; + numeric ccl_idx; + string ccl_str; + ccl_idx:=@; + ccl_str:=decimal ccl_idx; + forever: + ccl_idx:=ccl[ccl_idx]; + if ccl_idx>=0: + ccl_str:=(decimal ccl_idx)&", "&ccl_str; + fi + exitif (unknown ccl[ccl_idx]) or (ccl_idx=@); + endfor + if ccl_idx=@: + drv_errhelp "Inferences declarations can not be cyclic."; + drv_errmessage "inference declaration "&(decimal @)&" creates a"& + " cycle of inferences (indices "&ccl_str&" from conclusions to"& + " premises)"; + fi + else: + root[root_num]:=@; + root_num:=root_num+1; + fi + % + % lilb, rilb: inference labels + % + opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; + opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + % + % ldlb, rdlb: delimiter labels + % + opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; + opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + % + % j_sty, a_sty and i_sty: junction, alignment and inference styles + % + jct_sty[@]:=check_junction_style (j_sty, drv_jct_sty); + alg_sty[@]:=check_alignment_style (a_sty, drv_alg_sty); + iln_sty[@]:=check_path_style (i_sty, drv_iln_sty); + if drv_boxmode_on: + boxed[@]:=true; + fi + fi +enddef; + +vardef DCL[] (text PRM) (expr lilb, rilb, ldlb, rdlb) + (suffix j_sty, a_sty, i_sty) text SUB= + NFR[@] (PRM) (lilb, rilb, ldlb, rdlb, j_sty, a_sty, i_sty); + jgm[@] SUB; +enddef; + +vardef MVD[] (expr inf_num, lplb, rplb) (suffix a_sty, p_sty)= + if inf_num<1: + drv_errhelp "The minimal value is 1."; + drv_errmessage (decimal inf_num)&" is not a valid number of inference"& + " steps"; + else: + save aux_idx, aux_sty, phm_jdg; + numeric aux_idx, aux_sty; + picture phm_jdg; + aux_sty:=check_path_style (p_sty, drv_phm_sty); + phm_jdg:=nullpicture; + setbounds phm_jdg to (0, 0)--(iln_hg[aux_sty]-iln_dp[aux_sty], 0)--cycle; + aux_idx:=@; + for i=1 upto inf_num: + phm_idx:=phm_idx-1; + box_init jdg[phm_idx] (phm_jdg); + sbj_num[phm_idx]:=0; + NFR[phm_idx] (aux_idx) ("", "", "", "", 0, a_sty, 0); + aux_idx:=phm_idx; + endfor + src[@]:=phm_idx; + tgt[phm_idx]:=@; + phm_sty[phm_idx]:=aux_sty; + % + % lplb, rplb: phantom steps labels + % + opt_init[plb_sty[drv_sty]] l_plb[phm_idx] lplb; + opt_init[plb_sty[drv_sty]] r_plb[phm_idx] rplb; + phm_idx + fi +enddef; + +vardef bxd[]= + boxed[@]:=true; + @ +enddef; + +% +% Optional labels & shorthands +% + +numeric drv_jct_sty; % default junction style +string drv_alg_sty; % default junction style +numeric drv_iln_sty; % default inference line path-style +numeric drv_phm_sty; % default phantom steps path-style + +boolean drv_left_ilb; % inference labels on the left +boolean drv_left_dlb; % delimiter labels (hence delimiters) on the left +boolean drv_left_plb; % phantom steps labels on the left + +vardef arg_type expr arg= + if picture arg: + "picture" + else: + "string" + fi +enddef; + +vardef opt_lbls @# (text LBL) expr left_lbls= + save lbl_num, fst_lbl, snd_lbl; + numeric lbl_num; + lbl_num:=0; + for lbl=LBL: + if lbl_num=0: + scantokens (arg_type lbl) fst_lbl; + fst_lbl:=lbl; + elseif lbl_num=1: + scantokens (arg_type lbl) snd_lbl; + snd_lbl:=lbl; + else: + drv_errhelp "At most two labels can be specified:"& + " a left one and a right one."; + drv_errmessage "more than two labels have been specified"; + fi + lbl_num:=lbl_num+1; + endfor + if lbl_num=0: + string @#.l; + string @#.r; + @#.l:=""; + @#.r:=""; + elseif lbl_num=1: + if left_lbls: + scantokens (arg_type fst_lbl) @#.l; + string @#.r; + @#.l:=fst_lbl; + @#.r:=""; + else: + string @#.l; + scantokens (arg_type fst_lbl) @#.r; + @#.l:=""; + @#.r:=fst_lbl; + fi + else: + scantokens (arg_type fst_lbl) @#.l; + scantokens (arg_type snd_lbl) @#.r; + @#.l:=fst_lbl; + @#.r:=snd_lbl; + fi +enddef; + +vardef NFR_opt[] (text PRM) (text ILB) (text DLB) + (suffix j_sty, a_sty, i_sty)= + opt_lbls ilb (ILB) drv_left_ilb; + opt_lbls dlb (DLB) drv_left_dlb; + NFR[@] (PRM) (ilb.l, ilb.r, dlb.l, dlb.r, j_sty, a_sty, i_sty); +enddef; + +vardef DCL_opt[] (text PRM) (text ILB) (text DLB) + (suffix j_sty, a_sty, i_sty) text SUB= + NFR_opt[@] (PRM) (ILB) (DLB) (j_sty, a_sty, i_sty); + jgm[@] SUB; +enddef; + +vardef MVD_opt[] (expr inf_num) (text PLB) (suffix a_sty, p_sty)= + opt_lbls plb (PLB) drv_left_plb; + MVD[@] (inf_num, plb.l, plb.r, a_sty, p_sty) +enddef; + +% Nfr, Dcl & Mvd + +vardef Nfr[] (text PRM) (expr ilb, ldlb, rdlb) (suffix i_sty)= + NFR_opt[@] (PRM) (ilb) (ldlb, rdlb) (_, _, i_sty); +enddef; + +vardef Dcl[] (text PRM) (expr ilb, ldlb, rdlb) (suffix i_sty) text SUB= + Nfr[@] (PRM) (ilb, ldlb, rdlb, i_sty); + jgm[@] SUB; +enddef; + +vardef Mvd[] (expr inf_num, lplb, rplb) (suffix p_sty)= + MVD[@] (inf_num, lplb, rplb, _, p_sty) +enddef; + +% nfr, dcl & mvd + +vardef nfr[] (text PRM) (expr ilb) (suffix i_sty)= + NFR_opt[@] (PRM) (ilb) () (_, _, i_sty); +enddef; + +vardef dcl[] (text PRM) (expr ilb) (suffix i_sty) text SUB= + nfr[@] (PRM) (ilb, i_sty); + jgm[@] SUB; +enddef; + +vardef mvd[] (expr inf_num) (suffix p_sty)= + MVD_opt[@] (inf_num) () (_, p_sty) +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Pictured paths +% + +vardef dotted_aux (expr pth, dot_wd, dots_dist)= + save pth_len, pct; + numeric pth_len; + picture pct; + pth_len:=arclength pth; + pct:=nullpicture; + if dots_dist>0: + stp_num:=round ((pth_len-dot_wd)/dots_dist); + if stp_num>0: + stp_len:=(pth_len-dot_wd)/stp_num; + addto pct doublepath pth dashed dashpattern (on 0 off stp_len) + shifted (dot_wd/2, 0) withpen pencircle scaled dot_wd; + fi + fi + pct +enddef; + +primarydef pth dotted wd_dist= + dotted_aux(pth, xpart wd_dist, ypart wd_dist) +enddef; + +vardef expanded_aux (expr pth, scl, dir, stp_len)= + save pth_len, aux_len; + numeric pth_len, aux_len; + pth_len:=arclength pth; + if (stp_len>0) and (pth_len>stp_len): + aux_len:=pth_len/(pth_len div stp_len); + point arctime 0 of pth of pth shifted + (unitvector direction arctime 0 of pth of pth + rotated dir scaled scl).. + {direction arctime 0 of pth of pth} + for i=aux_len step aux_len until pth_len-aux_len: + point arctime i of pth of pth shifted + (unitvector direction arctime i of pth of pth + rotated dir scaled scl) + {direction arctime i of pth of pth}.. + endfor + point arctime pth_len of pth of pth shifted + (unitvector direction arctime pth_len of pth of pth + rotated dir scaled scl) + {direction arctime pth_len of pth of pth} + else: + pth + fi +enddef; + +primarydef pth expanded scl_dir_len= + expanded_aux (pth, + redpart scl_dir_len, greenpart scl_dir_len, bluepart scl_dir_len) +enddef; + +vardef waved_aux (expr pth, amp)= + save pth_len, mid; + numeric pth_len, mid; + pth_len:=arclength pth; + if (amp>0) and (pth_len>2(1+sqrt 5)*amp): + mid:=pth_len/(2(pth_len div (2(1+sqrt 5)*amp))); + point arctime 0 of pth of pth shifted + (unitvector direction arctime 0 of pth of pth + rotated -90 scaled amp) + {direction arctime 0 of pth of pth} + for i=mid step 2mid until pth_len: + ..point arctime i of pth of pth shifted + (unitvector direction arctime i of pth of pth + rotated 90 scaled amp) + {direction arctime i of pth of pth} + ..point arctime i+mid of pth of pth shifted + (unitvector direction arctime i+mid of pth of pth + rotated -90 scaled amp) + {direction arctime i+mid of pth of pth} + endfor + else: + pth + fi +enddef; + +primarydef pth waved amp= + waved_aux(pth, amp) +enddef; + +vardef drv_styled_aux[] expr pth= + save sty_idx, pth_len, pct; + numeric sty_idx, pth_len; + picture pct; + sty_idx:=check_path_style (@, 1); + pth_len:=arclength pth; + pct:=nullpicture; + if sty_idx=1: + interim linecap:=butt; + addto pct doublepath pth withpen drv_pen; + elseif sty_idx=2: + interim linecap:=butt; + addto pct doublepath pth + expanded (1.25rul_thk[drv_sty], 90, rul_thk[drv_sty]) + withpen drv_pen; + addto pct doublepath pth + expanded (1.25rul_thk[drv_sty], -90, rul_thk[drv_sty]) + withpen drv_pen; + elseif sty_idx=3: + addto pct also pth dotted (rul_thk[drv_sty], 2rul_thk[drv_sty]); + elseif sty_idx=4: + if rul_thk[drv_sty]>0: + interim linecap:=butt; + save dsh_num, dsh_len; + numeric dsh_num, dsh_len; + dsh_num:=round(pth_len/(3rul_thk[drv_sty])); + dsh_len:= + if odd dsh_num: + pth_len/dsh_num + else: + pth_len/(dsh_num+1) + fi; + addto pct doublepath pth dashed dashpattern(on dsh_len off dsh_len) + withpen drv_pen; + fi + elseif sty_idx=5: + interim linecap:=butt; + addto pct doublepath pth + waved 1.25rul_thk[drv_sty] withpen drv_pen; + elseif (sty_idx=6) and (pth_len>0): + addto pct also pth dotted (pdt_hg[drv_sty], pdt_wd[drv_sty]); + fi + pct +enddef; + +primarydef pth drv_styled sty= + drv_styled_aux[sty] pth +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Delimiters +% + +% +% 1. Global parameters +% + +string drv_l_dlm; % left delimiter LaTeX code +string drv_r_dlm; % right delimiter LaTeX code + +% +% 2. Macros +% + +vardef minmax_y[]=( + if drv_bot_roots: + if known ccl[@]: + ypart jdg[@].c-num_hg+iln_hg[(iln_sty[ccl[@]])] + +min_clr_scl*min_clr[drv_sty]/2 + else: + smin_y[@]-min_clr_scl*min_clr[drv_sty] + fi, + smax_y[@]+min_clr_scl*min_clr[drv_sty] + else: + smin_y[@]-min_clr_scl*min_clr[drv_sty], + if known ccl[@]: + ypart jdg[@].c-den_dp-iln_hg[(iln_sty[ccl[@]])] + -min_clr_scl*min_clr[drv_sty]/2 + else: + smax_y[@]+min_clr_scl*min_clr[drv_sty] + fi + fi) +enddef; + +vardef delim @# expr dlm_len= + save rule_str, dlm_str, dlm_pct, dlm_dp; + string rule_str, dlm_str; + picture dlm_pct; + numeric dlm_dp; + rule_str:="\rule{0bp}{"&(decimal(dlm_len/2+axis_hg[drv_sty]))&"bp}"; + dlm_str:= + if str @#="l": + "\left"&drv_l_dlm&rule_str&"\right." + else: + "\left."&rule_str&"\right"&drv_r_dlm + fi; + dlm_pct:=mth_tex[drv_sty] dlm_str; + dlm_dp:=depth dlm_pct; + if dlm_dp=0: + nullpicture + else: + begingroup + setbounds dlm_pct to + (xpart llcorner dlm_pct, dlm_dp) + --(xpart ulcorner dlm_pct, -dlm_dp) + --(xpart urcorner dlm_pct, -dlm_dp) + --(xpart lrcorner dlm_pct, dlm_dp) + --cycle; + dlm_pct yscaled (dlm_len/(2*height dlm_pct)) + endgroup + fi +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Checking, building, freezing (very inefficient, to be improved) +% + +% +% 1. Global parameters +% + +numeric min_clr_scl; % +numeric prm_skp_scl; % +numeric jdg_skp_scl; % +numeric ilb_skp_scl; % +numeric plb_skp_scl; % + +boolean drv_bot_roots; % +boolean drv_boxmode_on; % +boolean drv_fractionmode_on; % +string drv_axis_ref; % + +% +% 2. Macros +% + +% +% Checking +% + +vardef fraction_inference[]= + (prm_num[@]=0) + and (iln_sty[@]=0) + and (unknown l_ilb[@]) + and (unknown r_ilb[@]) + and drv_fractionmode_on +enddef; + +vardef drv_check_root[]= + if unknown jdg[@]: + drv_errhelp "An index must be used to declare a both a judgment and an"& + " inference."; + drv_errmessage (decimal @)&" has been used as an inference index but not"& + " as a judgment index"; + elseif unknown prm_num[@]: + drv_errhelp "An index must be used to declare a both a judgment and an"& + " inference."; + drv_errmessage (decimal @)&" has been used as a judgment index but not"& + " as an inference index"; + else: + save i_sty, prm_idx; + numeric i_sty, prm_idx; + i_sty:=iln_sty[@]; + for prm_rnk=0 upto prm_num[@]-1: + prm_idx:=prm[@][prm_rnk]; + drv_check_root[prm_idx]; + % + % numerators and denominators clearances + % The TEXbook, Appendix G, Rule 15d. + % + if drv_bot_roots: + num_hg:=max(num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].dp); + else: + den_dp:=min(den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].hg); + fi + endfor + if not fraction_inference[@]: + if drv_bot_roots: + den_dp:=min(den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[@].hg); + else: + num_hg:=max(num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[@].dp); + fi + fi + if unknown boxed[@]: + boxed[@]:=false; + fi + fi +enddef; + +vardef drv_check= + if root_num=0: + drv_errhelp "Well ..."; + drv_errmessage "no inference has been declared"; + else: + save root_idx; + numeric root_idx; + root_idx:=root[0]; + drv_check_root[root_idx]; + if root_num>1: + save root_str; + string root_str; + root_str:=decimal root_idx; + for idx=1 upto root_num-1: + root_idx:=root[idx]; + drv_check_root[root_idx]; + root_str:=root_str&", "&(decimal root_idx); + endfor + drv_message "warning, multiple root indices ("&root_str&")."; + fi + fi + drv_checked:=true; +enddef; + +% +% Building +% + +vardef drv_build_root[]= + % + % premises junction (from left to right) + % + for prm_rnk=0 upto prm_num[@]-1: + drv_build_root[prm[@][prm_rnk]]; + if prm_rnk>0: + save ll_idx, lr_idx, rl_idx, rr_idx; + save lmax_x, rmin_x, min_skp; + numeric ll_idx, lr_idx, rl_idx, rr_idx; + numeric lmax_x, rmin_x, min_skp; + ypart jdg[prm[@][prm_rnk-1]].c=ypart jdg[prm[@][prm_rnk]].c; + ll_idx:=prm[@][0]; + lr_idx:=prm[@][prm_rnk-1]; + rl_idx:=prm[@][prm_rnk]; + rr_idx:=prm[@][prm_rnk]; + lmax_x:=imax_x[lr_idx]; + rmin_x:=imin_x[rl_idx]; + min_skp[0]:=rmin_x-lmax_x; + forever: + exitif (unknown r_prm[lr_idx]) or (unknown l_prm[rl_idx]); + ll_idx:=l_prm[ll_idx]; + lr_idx:=r_prm[lr_idx]; + rl_idx:=l_prm[rl_idx]; + rr_idx:=r_prm[rr_idx]; + lmax_x:=max(lmax_x, imax_x[lr_idx]); + rmin_x:=min(rmin_x, imin_x[rl_idx]); + min_skp[0]:=min(min_skp[0], imin_x[rl_idx]-imax_x[lr_idx]); + endfor + min_skp[1]:=rmin_x-lmax_x; + if known r_prm[lr_idx]: + r_prm[rr_idx]:= r_prm[lr_idx]; + lmax_x:=smax_x[lr_idx]; + elseif known l_prm[rl_idx]: + l_prm[ll_idx]:=l_prm[rl_idx]; + rmin_x:=smin_x[rl_idx]; + fi + min_skp[2]:=rmin_x-lmax_x; + if jct_sty[@]<3: + min_skp[jct_sty[@]]=prm_skp_scl*prm_skp[drv_sty]; + fi + fi + endfor + if prm_num[@]>0: + l_prm[@]:=prm[@][0]; + r_prm[@]:=prm[@][prm_num[@]-1]; + fi + % + % judgment alignment + % + if prm_num[@]=0: + imin_x[@]:=xpart jdg[@].l-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + imax_x[@]:=xpart jdg[@].r+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + else: + save l_xref, r_xref; + l_xref= + if boxed[prm[@][0]]: + smin_x[prm[@][0]] + else: + xpart jdg[prm[@][0]].l + fi; + r_xref= + if boxed[prm[@][prm_num[@]-1]]: + smax_x[prm[@][prm_num[@]-1]] + else: + xpart jdg[prm[@][prm_num[@]-1]].r + fi; + if alg_sty[@]="l": + xpart jdg[@].l=l_xref; + elseif alg_sty[@]="c": + xpart jdg[@].c=(l_xref+r_xref)/2; + elseif alg_sty[@]="r": + xpart jdg[@].r=r_xref; + fi + imin_x[@]:=min(xpart jdg[@].l, l_xref) + -jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + imax_x[@]:=max(xpart jdg[@].r, r_xref) + +jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + fi + % + % inference line + % + save iln_wd, iln_pct; + numeric iln_wd; + picture iln_pct; + iln_wd:=imax_x[@]-imin_x[@]; + iln_pct:=((0, 0)--(iln_wd, 0)) drv_styled iln_sty[@]; + setbounds iln_pct to + (0, ypart llcorner iln_pct) + --(0, ypart ulcorner iln_pct) + --(iln_wd, ypart ulcorner iln_pct) + --(iln_wd, ypart llcorner iln_pct) + --cycle; % ! `linecap:=butt' and `linecap:=squared' -> same bounding box ! + box_init iln[@] (iln_pct); + xpart iln[@].c=(imin_x[@]+imax_x[@])/2; + % + % orientation, smin_y & smax_y + % + if drv_bot_roots: + ypart iln[@].c=ypart jdg[@].c-den_dp; + smin_y[@]:=ypart jdg[@].c+jdg[@].dp; + smax_y[@]:= + if iln_sty[@]=0: + ypart jdg[@].c+jdg[@].hg + else: + ypart iln[@].c+iln[@].hg + fi; + if prm_num[@]>0: + ypart iln[@].c=ypart jdg[prm[@][0]].c-num_hg; + for prm_rnk=0 upto prm_num[@]-1: + smax_y[@]:=max(smax_y[@], smax_y[prm[@][prm_rnk]]); + endfor; + fi + else: + ypart iln[@].c=ypart jdg[@].c-num_hg; + smin_y[@]:= + if iln_sty[@]=0: + ypart jdg[@].c+jdg[@].dp + else: + ypart iln[@].c+iln[@].dp + fi; + smax_y[@]:=ypart jdg[@].c+jdg[@].hg; + if prm_num[@]>0: + ypart iln[@].c=ypart jdg[prm[@][0]].c-den_dp; + for prm_rnk=0 upto prm_num[@]-1: + smin_y[@]:=min(smin_y[@], smin_y[prm[@][prm_rnk]]); + endfor; + fi + fi + % + % inference labels + % + if known l_ilb[@]: + l_ilb[@].r=iln[@].l shifted (-ilb_skp_scl*ilb_skp[drv_sty], 0); + imin_x[@]:=xpart l_ilb[@].l; + smin_y[@]:=min(smin_y[@], ypart l_ilb[@].c+l_ilb[@].dp); + smax_y[@]:=max(smax_y[@], ypart l_ilb[@].c+l_ilb[@].hg); + fi + if known r_ilb[@]: + r_ilb[@].l=iln[@].r shifted (ilb_skp_scl*ilb_skp[drv_sty], 0); + imax_x[@]:=xpart r_ilb[@].r; + smin_y[@]:=min(smin_y[@], ypart r_ilb[@].c+r_ilb[@].dp); + smax_y[@]:=max(smax_y[@], ypart r_ilb[@].c+r_ilb[@].hg); + fi + % + % phantom steps + % + if known tgt[@]: + save phm_pth, phm_pct; + path phm_pth; + picture phm_pct; + save top_y, mid_y, bot_y; + numeric top_y, bot_y; + if drv_bot_roots: + bot_y:=xpart minmax_y[@]+min_clr_scl*min_clr[drv_sty]/2; + top_y:=xpart minmax_y[tgt[@]]; + else: + bot_y:=ypart minmax_y[tgt[@]]; + top_y:=ypart minmax_y[@]-min_clr_scl*min_clr[drv_sty]/2; + fi + mid_y:=(top_y+bot_y)/2; + phm_pth:=(0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2); + phm_pct:=phm_pth drv_styled phm_sty[@]; + box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); + phm[@].c=(xpart jdg[@].c, mid_y); + imin_x[@]:=min(imin_x[@], xpart phm[@].l); + imax_x[@]:=max(imax_x[@], xpart phm[@].r); + % + % phantom steps labels + % + if known l_plb[@]: + l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); + imin_x[@]:=min(imin_x[@], xpart l_plb[@].l); + fi + if known r_plb[@]: + r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); + imax_x[@]:=max(imax_x[@], xpart r_plb[@].r); + fi + fi + % + % smin_x & smax_x + % + smin_x[@]:=imin_x[@]; + smax_x[@]:=imax_x[@]; + for prm_rnk=0 upto prm_num[@]-1: + smin_x[@]:=min(smin_x[@], smin_x[prm[@][prm_rnk]]); + smax_x[@]:=max(smax_x[@], smax_x[prm[@][prm_rnk]]); + endfor + % + % delimiters + % + if known l_dlb[@] or known r_dlb[@]: + save idx, mmy, min_y, max_y; + numeric idx, min_y, max_y; + pair mmy; + mmy:=minmax_y[@]; + min_y:=xpart mmy; + max_y:=ypart mmy; + if known l_dlb[@]: + box_init l_dlm[@] (delim l (max_y-min_y)); + l_dlm[@].r=(smin_x[@], (max_y+min_y)/2); + l_dlb[@].r=l_dlm[@].l; + smin_x[@]:=xpart l_dlb[@].l; + fi + if known r_dlb[@]: + box_init r_dlm[@] (delim r (max_y-min_y)); + r_dlm[@].l=(smax_x[@], (max_y+min_y)/2); + r_dlb[@].l=r_dlm[@].r; + smax_x[@]:=xpart r_dlb[@].r; + fi + fi + if (known l_dlb[@]) or boxed[@]: + idx:=@; + forever: + imin_x[idx]:=smin_x[@]; + exitif unknown l_prm[idx]; + idx:=l_prm[idx]; + endfor + fi + if (known r_dlb[@]) or boxed[@]: + idx:=@; + forever: + imax_x[idx]:=smax_x[@]; + exitif unknown r_prm[idx]; + idx:=r_prm[idx]; + endfor + fi +enddef; + +vardef drv_build= + if not drv_checked: + drv_check; + fi + for idx=0 upto root_num-1: + drv_build_root[root[idx]]; + endfor + drv_built:=true; +enddef; + +% +% Freezing +% + +vardef drv_freeze_root[]= + for prm_rnk=0 upto prm_num[@]-1: + drv_freeze_root[prm[@][prm_rnk]]; + endfor + for sbj_rnk=0 upto sbj_num[@]-1: + box_freeze sbj[@][sbj_rnk]; + endfor + forsuffixes sfx= + iln, jdg, phm, + l_dlb, l_dlm, l_ilb, l_plb, + r_dlb, r_dlm, r_ilb, r_plb: + if known sfx[@]: + box_freeze sfx[@]; + fi + endfor +enddef; + +vardef drv_freeze= + if not drv_built: + drv_build; + fi + save root_idx; + numeric root_idx; + root_idx:=root[0]; + if unknown iln[root_idx].c: + % + % default math axis + % + if drv_axis_ref="iln": + iln[root_idx].c=(0, axis_hg[drv_sty]); + else: % drv_axis_ref="jdg" + jdg[root_idx].c=(0, axis_hg[drv_sty]); + fi + drv_freeze_root[root_idx]; + fi + for idx=1 upto root_num-1: + root_idx:=root[idx]; + if unknown iln[root_idx].c: + smin_x[root_idx]=smax_x[root[idx-1]]+prm_skp_scl*prm_skp[drv_sty]; + ypart iln[root_idx].c=ypart iln[root[idx-1]].c; + fi + drv_freeze_root[root_idx]; + endfor + drv_frozen:=true; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Derivation tree pictures +% + +% +% 1. Global parameters +% + +boolean drv_proofmode_on; % +color prf_clr; % +color jdg_clr; % +color sbj_clr; % + +prf_clr:=.75background; % arbitrary +jdg_clr:=red; % arbitrary +sbj_clr:=blue; % arbitrary + +% +% 2. Macros +% + +vardef drv_tree_addto @# (expr idx) text draw_options= + for prm_rnk=0 upto prm_num[idx]-1: + drv_tree_addto @# (prm[idx][prm_rnk]) draw_options; + endfor + forsuffixes sfx= + jdg, phm, + l_dlb, l_dlm, l_ilb, l_plb, + r_dlb, r_dlm, r_ilb, r_plb: + if known sfx[idx]: + addto @# also sfx[idx] draw_options; + fi + endfor + if iln_sty[idx]>0: + addto @# also iln[idx] draw_options; + fi +enddef; + +vardef tt_nat[] expr nat= % typewriter typeface naturals + save nat_aux, nat_pct_wd, dgt_num, nat_pct; + numeric nat_aux, nat_pct_wd, dgt_num; + picture nat_pct; + nat_aux:=abs nat; + nat_pct:=nullpicture; + nat_pct_wd:=0; + dgt_num:=1; + forever: + exitif nat_aux div (10**dgt_num)=0; + dgt_num:=dgt_num+1; + endfor + for rnk:=1 upto dgt_num: + addto nat_pct also tt_dgt[@][nat_aux div (10**(dgt_num-rnk))] + shifted (nat_pct_wd, 0); + nat_pct_wd:=width nat_pct; + nat_aux:=nat_aux mod (10**(dgt_num-rnk)); + endfor + nat_pct shifted (0, -axis_hg[@]) +enddef; + +vardef prf_tree_addto @# expr idx= + for prm_rnk=0 upto prm_num[idx]-1: + prf_tree_addto @# (prm[idx][prm_rnk]); + endfor + if idx>=0: + box_init jdg_prf[idx] (tt_nat[2] idx); + jdg_prf[idx].r=jdg[idx].l; + box_freeze jdg_prf[idx]; + addto @# also jdg_prf[idx] withcolor jdg_clr; + addto @# doublepath jdg[idx].c withcolor jdg_clr + withpen pencircle scaled (2*pdt_hg[drv_sty]); + fi + for sbj_rnk=0 upto sbj_num[idx]-1: + box_init sbj_prf[idx][sbj_rnk] (tt_nat[3] sbj_rnk); + if odd sbj_rnk: + sbj_prf[idx][sbj_rnk].c shifted (0, sbj_prf[idx][sbj_rnk].hg)= + sbj[idx][sbj_rnk].c + shifted (0, -den_dp-min_clr_scl*min_clr[drv_sty]/2); + else: + sbj_prf[idx][sbj_rnk].c shifted (0, sbj_prf[idx][sbj_rnk].dp)= + sbj[idx][sbj_rnk].c + shifted (0, -num_hg+min_clr_scl*min_clr[drv_sty]/2); + fi + box_freeze sbj_prf[idx][sbj_rnk]; + addto @# also sbj_prf[idx][sbj_rnk] withcolor sbj_clr; + addto @# doublepath sbj[idx][sbj_rnk].c withcolor sbj_clr + withpen pencircle scaled pdt_hg[drv_sty]; + endfor +enddef; + +vardef drv_tree= + save pct; + picture pct; + pct:=nullpicture; + if not drv_frozen: + drv_freeze; + fi + for root_idx=0 upto root_num-1: + if drv_proofmode_on: + drv_tree_addto pct (root[root_idx]) withcolor prf_clr; + prf_tree_addto pct (root[root_idx]); + else: + drv_tree_addto pct (root[root_idx]); + fi + endfor + pct +enddef; + +vardef drv_bbox[]= + save min_x, max_x, mmy, min_y, max_y; + pair mmy; + numeric min_x, max_x, max_y, min_y; + if not drv_frozen: + drv_freeze; + fi + min_x:= + if known l_dlm[@].r: + xpart l_dlm[@].r + else: + smin_x[@] + fi-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + max_x:= + if known r_dlm[@].l: + xpart l_dlm[@].l + else: + smax_x[@] + fi+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + mmy:=minmax_y[@]; + min_y:=xpart mmy; + max_y:=ypart mmy; + (min_x, min_y)-- + (min_x, max_y)-- + (max_x, max_y)-- + (max_x, min_y)-- + cycle +enddef; + +vardef mth_axis @# (suffix ref_sfx) (expr idx)= + if not drv_frozen: + drv_freeze; + fi + if unknown prm_num[idx]: + drv_errhelp "An index must be used to declare an inference before it is"& + " used to set the math axis of a picture."; + drv_errmessage "no inference has been declared using index "&(decimal idx); + else: + save ref_str, yref; + string ref_str; + numeric yref; + ref_str:=str ref_sfx; + if ref_str="iln": + yref:=ypart iln[idx].c; + elseif ref_str="jdg": + yref:=ypart jdg[idx].c; + elseif ref_str="dlm": + if known l_dlm[idx]: + yref:=ypart l_dlm[idx].c; + elseif known r_dlm[idx]: + yref:=ypart r_dlm[idx].c; + else: + drv_errhelp "Well ..."; + drv_errmessage "no delimiter is attached to inference "&(decimal idx); + fi + else: + drv_errhelp "Valid identifiers are"& + " iln (inference line axis),"& + " jdg (judgment math-axis) and"& + " dlm (delimiter axis)."; + drv_errmessage (ref_str&" is not a valid reference type identifier"); + fi + if known yref: + @#:=@# shifted (0, axis_hg[drv_sty]-yref); + fi + fi +enddef; + +vardef drv_axis (suffix ref) (expr idx)= + mth_axis currentpicture (ref, idx); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Tunings +% + +vardef check_math_style (expr sty_str, default)= + if sty_str="\displaystyle": + 0 + elseif sty_str="\textstyle": + 1 + elseif sty_str="\scriptstyle": + 2 + elseif sty_str="\scriptscriptstyle": + 3 + else: + begingroup + drv_errhelp "Valid commands are"& + " \displaystyle,"& + " \textstyle,"& + " \scriptstyle and"& + " \scriptscriptstyle."; + drv_errmessage (sty_str&" is not a valid math-style command"); + default + endgroup + fi +enddef; + +vardef check_position_left (suffix pos_sfx) (expr default)= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if (pos_str="l"): + true + elseif (pos_str="r"): + false + else: + begingroup + drv_errhelp "Valid identifiers are l (left) and r (right)."; + drv_errmessage (pos_str&" is not a valid label position identifier"); + default + endgroup + fi +enddef; + +vardef check_mode_on (suffix status_sfx) (expr default)= + save status_str; + string status_str; + status_str:=str status_sfx; + if status_str="on": + true + elseif status_str="off": + false + else: + begingroup + drv_errhelp "Possible identifiers are on and off"; + drv_errmessage (status_str&" is not a valid status identifier"); + default + endgroup + fi +enddef; + +vardef drv_math_style (suffix typ_sfx) (expr sty_str)= + save typ_str, sty_idx; + string typ_str; + numeric sty_idx; + typ_str:=str typ_sfx; + if (typ_str<>"drv") + and (typ_str<>"jdg") + and (typ_str<>"ilb") + and (typ_str<>"dlb") + and (typ_str<>"plb"): + drv_errhelp "Valid identifiers are"& + " drv (derivation tree),"& + " jdg (judgment),"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (sty_str&" is not a valid component identifier"); + else: + sty_idx:=check_math_style (sty_str, 0); + if typ_str="drv": + drv_sty:=sty_idx; + else: + forsuffixes sfx=scantokens (typ_str&"_sty"): + for idx=0 upto 3: + sfx[idx]:=min(idx+sty_idx, 3); + endfor + endfor + fi + fi +enddef; + +vardef drv_scale (suffix scl_sfx) (expr scl)= + save scl_str; + string scl_str; + scl_str:=str scl_sfx; + if scl_str="clr": + min_clr_scl:=scl; + elseif scl_str="prm": + prm_skp_scl:=scl; + elseif (scl_str="jdg") or (scl_str="jgm"): % "jgm" is deprecated + jdg_skp_scl:=scl; + elseif (scl_str="ilb") or (scl_str="lbl"): % "lbl" is deprecated + ilb_skp_scl:=scl; + else: + drv_errhelp "Valid identifiers are"& + " clr,"& + " prm,"& + " jdg and"& + " ilb."; + drv_errmessage (scl_str&" is not a valid scale identifier"); + fi +enddef; + +vardef drv_junction_style suffix sty_sfx= + drv_jct_sty:=check_junction_style (sty_sfx, drv_jct_sty); +enddef; + +vardef drv_alignment_style suffix sty_sfx= + drv_alg_sty:=check_alignment_style (sty_sfx, drv_alg_sty); +enddef; + +vardef drv_path_style (suffix typ_sfx, sty_sfx)= + save typ_str; + string typ_str; + typ_str:=str typ_sfx; + if typ_str="iln": + drv_iln_sty:=check_path_style (sty_sfx, drv_iln_sty); + elseif typ_str="phm": + drv_phm_sty:=check_path_style (sty_sfx, drv_phm_sty); + else: + drv_errhelp "Valid identifiers are"& + " iln (inference line) and"& + " phm (phantom steps path)."; + drv_errmessage (typ_str&" is not a valid path-type identifier"); + fi +enddef; + +vardef drv_labels_position_aux (suffix typ_sfx, pos_sfx)= + save typ_str, idt_str, pos_str; + string typ_str, idt_str, pos_str; + typ_str:=str typ_sfx; + if typ_str="ilb": + drv_left_ilb:=check_position_left (pos_sfx, drv_left_ilb); + elseif typ_str="dlb": + drv_left_dlb:=check_position_left (pos_sfx, drv_left_dlb); + elseif typ_str="plb": + drv_left_plb:=check_position_left (pos_sfx, drv_left_plb); + else: + drv_errhelp "Valid identifiers are"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (typ_str&" is not a valid label-type identifier"); + fi +enddef; + +vardef drv_labels_position text ARG= + drv_labels_position_aux if pair ARG: ARG else: (ilb, ARG) fi; +enddef; + +vardef drv_roots_position suffix pos_sfx= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if pos_str="t": + drv_bot_roots:=false; + elseif pos_str="b": + drv_bot_roots:=true; + else: + drv_errhelp "Valid identifiers are"& + " t (top) and"& + " b (bottom)."; + drv_errmessage (pos_str&" is not a valid root position identifier"); + fi +enddef; + +vardef drv_axis_reference suffix ref_sfx= + save ref_str; + string ref_str; + ref_str:=str ref_sfx; + if (ref_str<>"iln") and (ref_str<>"jdg"): + drv_errhelp "Valid identifiers are iln (inference line axis) and"& + " jdg (judgment math-axis)."; + drv_errmessage (ref_str&" is not a valid reference identifier"); + else: + drv_axis_ref:=ref_str; + fi +enddef; + +vardef drv_delimiter (suffix pos_sfx) (expr dlm_str)= + if check_position_left (pos_sfx, true): + drv_l_dlm:=dlm_str; + else: + drv_r_dlm:=dlm_str; + fi +enddef; + +vardef drv_left_delimiter expr dlm_str= + drv_delimiter (l, dlm_str); +enddef; + +vardef drv_right_delimiter expr dlm_str= + drv_delimiter (r, dlm_str); +enddef; + +vardef drv_box_mode suffix status_sfx= + drv_boxmode_on:=check_mode_on (status_sfx, drv_boxmode_on); +enddef; + +vardef drv_fraction_mode suffix status_sfx= + drv_fractionmode_on:=check_mode_on (status_sfx, drv_fractionmode_on); +enddef; + +vardef drv_proof_mode suffix status_sfx= + drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Default settings +% + +drv_font_size "\normalsize"; +drv_math_style (drv, "\displaystyle"); +drv_math_style (jdg, "\textstyle"); +drv_math_style (ilb, "\scriptstyle"); +drv_math_style (dlb, "\textstyle"); +drv_math_style (plb, "\textstyle"); +drv_scale (clr, 1); +drv_scale (prm, 1); +drv_scale (jdg, 1); +drv_scale (ilb, 1); +drv_junction_style 1; +drv_alignment_style c; +drv_path_style (iln, 1); +drv_path_style (phm, 3); +drv_labels_position (ilb, r); +drv_labels_position (dlb, l); +drv_labels_position (plb, l); +drv_roots_position b; +drv_axis_reference iln; +drv_left_delimiter "\lbrace"; +drv_right_delimiter "\rbrace"; +drv_box_mode off; +drv_fraction_mode on; +drv_proof_mode off; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% LaTeX inclusion macro +% +% \drv includes a picture file in such a way that the baseline of the included +% picture coincides with the baseline of the inclusion point. The code for \drv +% was suggested by Josselin Noirel on the fr.comp.text.tex usenet group. +% +% \usepackage{graphicx} +% \makeatletter +% \def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}} +% \newsavebox{\graphicsbox} +% \newcommand*{\drv}[1]{% +% \sbox{\graphicsbox}{\includegraphics{#1}}% +% \raisebox{\Gin@lly bp}% +% {\usebox{\graphicsbox}}} +% \makeatother diff --git a/Master/texmf-dist/doc/metapost/drv/doc/makefile b/Master/texmf-dist/doc/metapost/drv/doc/makefile new file mode 100644 index 00000000000..ce2f2b8c6cf --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/doc/makefile @@ -0,0 +1,46 @@ +MAIN= drv-guide + +$(MAIN).pdf: $(MAIN).ps + ps2pdf $(MAIN).ps + +$(MAIN).ps: $(MAIN).tex $(MAIN)-delayed.mp + latex $(MAIN) + latex $(MAIN) + latex $(MAIN) + dvips $(MAIN) -o + +$(MAIN)-proof.pdf: $(MAIN)-proof.ps + ps2pdf $(MAIN)-proof.ps + +$(MAIN)-proof.ps: $(MAIN)-delayed.mp + latex $(MAIN)-proof + dvips $(MAIN)-proof -o + +$(MAIN)-delayed.mp: $(MAIN).mp + $(RM) $(MAIN)-delayed.mp + mpost $(MAIN) + mpost $(MAIN) + mpost $(MAIN) + +.SILENT clean: + $(RM) drv.mpx + $(RM) $(MAIN).[0-9]* + $(RM) $(MAIN).aux + $(RM) $(MAIN).dvi + $(RM) $(MAIN).log + $(RM) $(MAIN).nav + $(RM) $(MAIN).out + $(RM) $(MAIN).toc + $(RM) $(MAIN)-delayed.mp + $(RM) $(MAIN)-delayed.mpx + $(RM) $(MAIN)-proof.aux + $(RM) $(MAIN)-proof.dvi + $(RM) $(MAIN)-proof.log + $(RM) $(MAIN)-proof.tex + $(RM) $(MAIN)-proof.toc + +cleanall: clean + $(RM) $(MAIN).pdf + $(RM) $(MAIN).ps + $(RM) $(MAIN)-proof.pdf + $(RM) $(MAIN)-proof.ps diff --git a/Master/texmf-dist/doc/metapost/drv/doc/readme.txt b/Master/texmf-dist/doc/metapost/drv/doc/readme.txt new file mode 100644 index 00000000000..66f2719391a --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/doc/readme.txt @@ -0,0 +1,17 @@ +# In order to compile the sources and to get a pdf file, use `make' or: + +# 1. run metapost THREE TIMES: +mpost drv-guide.mp +mpost drv-guide.mp +mpost drv-guide.mp + +# 2. run latex (three times): +latex drv-guide.tex +latex drv-guide.tex +latex drv-guide.tex + +# 3. run dvips (once): +dvips drv-guide.dvi -o + +# 4. run ps2pdf (once): +ps2pdf drv-guide.ps diff --git a/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf b/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf Binary files differnew file mode 100644 index 00000000000..ab7d917ba9e --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf diff --git a/Master/texmf-dist/doc/metapost/drv/sample/coq-sample.mp b/Master/texmf-dist/doc/metapost/drv/sample/coq-sample.mp new file mode 100644 index 00000000000..c10dc3972c4 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/sample/coq-sample.mp @@ -0,0 +1,101 @@ +input drv; + +verbatimtex %&latex + +% Any piece of code related to font selection in the preambule of +% `coq-sample.tex' (document class, font package, font selection commands ...) +% should be reported here. + +\documentclass[8pt]{beamer} +\usepackage[T1]{fontenc} +\usepackage{amsmath} +\usepackage[varg]{txfonts} +\newcommand{\var}{\text{Var}} +\newcommand{\app}{\text{App}} +\newcommand{\lam}{\text{Lam}} +\begin{document} +etex; + +drv_font_size "\small"; +drv_labels_position l; + +for index=0 upto 6: + beginfig(index) + jgm 0 "\vdash", "(P\to(Q\to R))\to(Q\to(P\to R))"; + jgm 1 "P\to(Q\to R)\vdash", "Q\to(P\to R)"; + jgm 2 "P\to(Q\to R), Q\vdash", "P\to R"; + jgm 3 "P\to(Q\to R), Q, P\vdash", "R"; + jgm 4 "P\to(Q\to R), Q, P\vdash", "Q\to R"; + jgm 5 "P\to(Q\to R), Q, P\vdash", "P\to(Q\to R)"; + jgm 6 "P\to(Q\to R), Q, P\vdash", "P"; + jgm 7 "P\to(Q\to R), Q, P\vdash", "Q"; + nfr 0 (1) ("\lam", 1); + nfr 1 (2) ("\lam", 1); + nfr 2 (3) ("\lam", 1); + nfr 3 (4, 7) ("\app", 1); + nfr 4 (5, 6) ("\app", 1); + nfr 5 () ("\var", 1); + nfr 6 () ("\var", 1); + nfr 7 () ("\var", 1); + setbounds currentpicture to drv_bbox 0; + % All the pictures will have the same bounding box + % as the complete derivation tree. + draw sbj[0][0]; + if index=0: + draw sbj[0][1] withcolor blue; + else: + draw sbj[0][1]; + draw iln[0]; + draw l_ilb[0]; + draw sbj[1][0]; + if index=1: + draw sbj[1][1] withcolor blue; + else: + draw sbj[1][1]; + draw iln[1]; + draw l_ilb[1]; + draw sbj[2][0]; + if index=2: + draw sbj[2][1] withcolor blue; + else: + draw sbj[2][1]; + draw iln[2]; + draw l_ilb[2]; + draw sbj[3][0]; + if index=3: + draw sbj[3][1] withcolor blue; + else: + draw sbj[3][1]; + draw iln[3]; + draw l_ilb[3]; + draw jdg[4]; + draw iln[4]; + draw l_ilb[4]; + draw jdg[5]; + draw iln[5]; + draw l_ilb[5]; + draw sbj[6][0]; + draw sbj[7][0]; + if index=4: + draw sbj[6][1] withcolor blue; + draw sbj[7][1] withcolor blue; + else: + draw sbj[6][1]; + draw iln[6]; + draw l_ilb[6]; + if index=5: + draw sbj[7][1] withcolor blue; + else: + draw sbj[7][1]; + draw iln[7]; + draw l_ilb[7]; + fi + fi + fi + fi + fi + fi + endfig; +endfor + +end diff --git a/Master/texmf-dist/doc/metapost/drv/sample/coq-sample.tex b/Master/texmf-dist/doc/metapost/drv/sample/coq-sample.tex new file mode 100644 index 00000000000..d572ef3e7b0 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/sample/coq-sample.tex @@ -0,0 +1,258 @@ +% Any piece of code related to font selection in the following preambule +% (document class, font package, font selection commands ...) should be +% reported in `coq-sample.mp'. + +\documentclass[8pt]{beamer} +\usetheme{Warsaw} + +\usepackage[T1]{fontenc} +\usepackage{amsmath} +\usepackage[varg]{txfonts} + +\usepackage{graphicx} +\makeatletter +\def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}} +\newsavebox{\graphicsbox} +\newcommand*{\drv}[1]{% +\sbox{\graphicsbox}{\includegraphics{#1}}% +\raisebox{\Gin@lly bp}% +{\usebox{\graphicsbox}}} +\makeatother + +\title{Une construction de preuve en logique minimale} +\institute{INF462 -- Master S\&T Informatique -- Bordeaux 1} +\date{} + +\begin{document} + +\begin{frame} +\titlepage +\end{frame} + +\ttfamily +\itshape +\small + +\begin{frame} +\begin{block}{} +% +% coq-tex output +% +\begin{overlayarea}{\textwidth}{.5\textheight} +\only<1>{% + \textup{Coq~{<}~Variables~P~Q~R~:~Prop.}\\ + P~is~assumed\\ + Q~is~assumed\\ + R~is~assumed\\ + \medskip + \textup{% + Coq~{<}~Lemma~imp\_perm~:~(P~-{>}~(Q~-{>}~R))~-{>}~(Q~-{>}~(P~-{>}~R)).}\\ + 1~subgoal\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~============================\\ + ~~~\textcolor{blue}{(P~-{>}~Q~-{>}~R)~-{>}~Q~-{>}~P~-{>}~R}\\ + \medskip + \textup{Coq~{<}~Proof.}\\ + \medskip + \textup{Coq~{<}}} +\only<2>{% + \textup{Coq~{<}~Variables~P~Q~R~:~Prop.}\\ + P~is~assumed\\ + Q~is~assumed\\ + R~is~assumed\\ + \medskip + \textup{% + Coq~{<}~Lemma~imp\_perm~:~(P~-{>}~(Q~-{>}~R))~-{>}~(Q~-{>}~(P~-{>}~R)).}\\ + 1~subgoal\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~============================\\ + ~~~\textcolor{blue}{(P~-{>}~Q~-{>}~R)~-{>}~Q~-{>}~P~-{>}~R}\\ + \medskip + \textup{Coq~{<}~Proof.}\\ + \medskip + \textup{Coq~{<}~~~intro~H.}} +\only<3>{% + \textup{Coq~{<}~~~intro~H.}\\ + 1~subgoal\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~H~:~P~-{>}~Q~-{>}~R\\ + ~~============================\\ + ~~~\textcolor{blue}{Q~-{>}~P~-{>}~R}\\ + \medskip + \textup{Coq~{<}}} +\only<4>{% + \textup{Coq~{<}~~~intro~H.}\\ + 1~subgoal\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~H~:~P~-{>}~Q~-{>}~R\\ + ~~============================\\ + ~~~\textcolor{blue}{Q~-{>}~P~-{>}~R}\\ + \medskip + \textup{Coq~{<}~~~intro~q.}} +\only<5>{% + \textup{Coq~{<}~~~intro~q.}\\ + 1~subgoal\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~H~:~P~-{>}~Q~-{>}~R\\ + ~~q~:~Q\\ + ~~============================\\ + ~~~\textcolor{blue}{P~-{>}~R}\\ + \medskip + \textup{Coq~{<}}} +\only<6>{% + \textup{Coq~{<}~~~intro~q.}\\ + 1~subgoal\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~H~:~P~-{>}~Q~-{>}~R\\ + ~~q~:~Q\\ + ~~============================\\ + ~~~\textcolor{blue}{P~-{>}~R}\\ + \medskip + \textup{Coq~{<}~~~intro~p.}} +\only<7>{% + \textup{Coq~{<}~~~intro~p.}\\ + 1~subgoal\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~H~:~P~-{>}~Q~-{>}~R\\ + ~~q~:~Q\\ + ~~p~:~P\\ + ~~============================\\ + ~~~\textcolor{blue}{R}\\ + \medskip + \textup{Coq~{<}}} +\only<8>{% + \textup{Coq~{<}~~~intro~p.}\\ + 1~subgoal\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~H~:~P~-{>}~Q~-{>}~R\\ + ~~q~:~Q\\ + ~~p~:~P\\ + ~~============================\\ + ~~~\textcolor{blue}{R}\\ + \medskip + \textup{Coq~{<}~~~apply~H.}} +\only<9>{% + \textup{Coq~{<}~~~apply~H.}\\ + 2~subgoals\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~H~:~P~-{>}~Q~-{>}~R\\ + ~~q~:~Q\\ + ~~p~:~P\\ + ~~============================\\ + ~~~\textcolor{blue}{P}\\ + subgoal~2~is:\\ + ~\textcolor{blue}{Q}\\ + \medskip + \textup{Coq~{<}}} +\only<10>{% + \textup{Coq~{<}~~~apply~H.}\\ + 2~subgoals\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~H~:~P~-{>}~Q~-{>}~R\\ + ~~q~:~Q\\ + ~~p~:~P\\ + ~~============================\\ + ~~~\textcolor{blue}{P}\\ + subgoal~2~is:\\ + ~\textcolor{blue}{Q}\\ + \medskip + \textup{Coq~{<}~~~assumption.}} +\only<11>{% + \textup{Coq~{<}~~~assumption.}\\ + 1~subgoal\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~H~:~P~-{>}~Q~-{>}~R\\ + ~~q~:~Q\\ + ~~p~:~P\\ + ~~============================\\ + ~~~\textcolor{blue}{Q}\\ + \medskip + \textup{Coq~{<}}} +\only<12>{% + \textup{Coq~{<}~~~assumption.}\\ + 1~subgoal\\ + ~~\\ + ~~P~:~Prop\\ + ~~Q~:~Prop\\ + ~~R~:~Prop\\ + ~~H~:~P~-{>}~Q~-{>}~R\\ + ~~q~:~Q\\ + ~~p~:~P\\ + ~~============================\\ + ~~~\textcolor{blue}{Q}\\ + \medskip + \textup{Coq~{<}~~~assumption.}} +\only<13>{% + \textup{Coq~{<}~~~assumption.}\\ + Proof~completed.\\ + \medskip + \textup{Coq~{<}}} +\only<14>{% + \textup{Coq~{<}~~~assumption.}\\ + Proof~completed.\\ + \medskip + \textup{Coq~{<}~Qed.}} +\only<15>{% + \textup{Coq~{<}~Qed.}\\ + intro~H.\\ + intro~q.\\ + intro~p.\\ + apply~H.\\ + assumption.\\ + assumption.\\ + imp\_perm~is~defined\\ + \medskip + \textup{Coq~{<}~}} +\end{overlayarea} +\end{block} +\begin{block}{} +% +% derivation tree +% +\begin{overprint} +\begin{gather*} +\only<1-2> {\drv{coq-sample.0}} +\only<3-4> {\drv{coq-sample.1}} +\only<5-6> {\drv{coq-sample.2}} +\only<7-8> {\drv{coq-sample.3}} +\only<9-10> {\drv{coq-sample.4}} +\only<11-12> {\drv{coq-sample.5}} +\only<13-15> {\drv{coq-sample.6}} +\end{gather*} +\end{overprint} +\end{block} +\end{frame} +\end{document} diff --git a/Master/texmf-dist/doc/metapost/drv/sample/drv.mp b/Master/texmf-dist/doc/metapost/drv/sample/drv.mp new file mode 100644 index 00000000000..5eb38396144 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/sample/drv.mp @@ -0,0 +1,2245 @@ +%% drv.mp 0.93 +%% Copyright 2009 Laurent M\'ehats +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Laurent M\'ehats. +% <laurent.mehats@gmail.com> +% +% This work consists of the file drv.mp + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% User's macros summary +% +% +% * Judgment & inference declarations +% =================================== +% +% jgm <nat> <str list> +% <nat> judgment index +% <str list> sub-judgments math-mode LaTeX code +% +% nfr <nat> (<nat list>) (<str>, <id>) +% <nat> inference index +% <nat list> list of premise indices +% <str> inference label math-mode LaTeX code +% <id> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% 0 none +% 1 simple +% 2 double +% 3 dotted +% 4 dashed +% 5 waved +% 6 TeX-dotted +% _ default (set by drv_path_style) +% +% mvd <nat 1> (<nat 2>, <id>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <id> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% Nfr <nat> (<nat list>) (<str 1>, <str 2>, <str 3>, <id>) +% <nat> inference index +% <nat list> list of premise indices +% <str 1> inference label math-mode LaTeX code +% <str 2> left delimiter label math-mode LaTeX code +% <str 3> right delimiter label math-mode LaTeX code +% <id> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% Mvd <nat 1> (<nat 2>, <str 1>, <str 2>, <id>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str 1> left label math-mode LaTeX code +% <str 2> right label math-mode LaTeX code +% <id> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% NFR <nat> (<nat list>) (<str 1>, <str 2>, <str 3>, <str 4>) +% (<id 1>, <id 2>, <id 3>) +% <nat> inference index +% <nat list> list of premise indices +% <str 1> left inference label math-mode LaTeX code +% <str 2> right inference label math-mode LaTeX code +% <str 3> left delimiter label math-mode LaTeX code +% <str 4> right delimiter label math-mode LaTeX code +% <id 1> junction style identifier (0, 1, 2, 3 or _) +% 0 fully-interlacing +% 1 semi-interlacing +% 2 non-interlacing +% 3 user specified (tricky) +% _ default (set by drv_junction_style) +% <id 2> alignment style identifier (l, c, r, u or _) +% l left +% c centered +% r right +% u user specified (tricky) +% _ default (set by drv_alignment_style) +% <id 3> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% MVD <nat 1> (<nat 2>, <str 1>, <str 2>, <id 1> <id 2>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str 1> left label math-mode LaTeX code +% <str 2> right label math-mode LaTeX code +% <id 1> alignment style identifier (l, c, r, u or _) +% <id 2> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% NFR_opt <nat> (<nat list>) (<str list 1>) (<str list 2>) +% (<id 1>, <id 2>, <id 3>) +% <nat> inference index +% <nat list> list of premise indices +% <str list 1> list of inference labels math-mode LaTeX code +% <str list 2> list of delimiter labels math-mode LaTeX code +% <id 1> junction style identifier (0, 1, 2, 3 or _) +% <id 2> alignment style identifier (l, c, r, u or _) +% <id 3> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% MVD_opt <nat 1> (<nat 2>) (<str list>) (<id 1> <id 2>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str list> list of labels math-mode LaTeX code +% <id 1> alignment style identifier (l, c, r or u) +% <id 2> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% * Tunings +% ========= +% +% drv_font_size <str> +% <str> LaTeX font-size command +% "\tiny" +% "\scriptsize" +% "\footnotesize" +% "\small" +% "\normalsize" +% "\large" +% "\Large" +% etc. +% +% drv_math_style (<id>, <str>) +% <id> component identifier (drv, jdg, ilb, dlb or plb) +% drv derivation trees +% jdg judgments +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <str> LaTeX math-style command +% +% drv_scale (<id>, <float>) +% <id> scale identifier (clr, prm, jdg or ilb) +% clr nice explanation soon (see examples) +% prm nice explanation soon (see examples) +% jdg nice explanation soon (see examples) +% ilb nice explanation soon (see examples) +% <float> scale value +% +% drv_junction_style <id> +% <id> junction style identifier (0, 1 or 2) +% 0 ``fully-interlacing'' +% 1 ``semi-interlacing'' +% 2 ``non-interlacing'' +% +% drv_alignment_style <id> +% <id> alignment style identifier (l, c or r) +% l left +% c centered +% r right +% +% drv_path_style (<id 1>, <id 2>) +% <id 1> path-type identifier (iln or phm) +% iln inference lines +% phm phantom steps paths +% <id 2> path-style identifier (0, 1, 2, 3, 4, 5 or 6) +% +% drv_labels_position (<id 1>, <id 2>) +% <id 1> label-type identifier (ilb, plb or dlb) +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <id 2> position identifier (l or r) +% l left +% r right +% +% drv_roots_position <id> +% <id> position identifier (t or b) +% t top +% b bottom +% +% drv_axis_reference <id> +% <id> reference identifier (iln or jdg) +% iln root inference line axis +% jdg root judgment math-axis +% +% drv_left_delimiter <str> +% <str> left delimiter math-mode LaTeX code +% "(" $($ +% "[" $[$ +% "\lbrace" $\lbrace$ +% "\langle" $\langle$ +% etc. +% +% drv_right_delimiter <str> +% <str> right delimiter math-mode LaTeX code +% ")" +% "]" +% "\rbrace" +% "\rangle" +% etc. +% +% drv_box_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_fraction_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_proof_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% * Derivation tree pictures +% ========================== +% +% drv_bbox <nat> +% <nat> sub-tree root index +% +% drv_axis (<id>, <nat>) +% <id> reference type identifier (iln, jdg or dlm) +% iln inference line axis +% jdg judgment math-axis +% dlm delimiter axis +% <nat> reference index +% +% <path> drv_styled <id> +% <path> MetaPost path expression +% <id> path style identifier (0, 1, 2, 3, 4, 5 or 6) +% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MetaPost messages formatting +% + +% drv_format prevents messages from being automatically cut into lines every +% 79 characters: if possible, a word which would otherwise be cut is 'pushed' +% to the following line by inserting space characters before it. + +vardef drv_format (expr str, fst_len, nxt_len, dbl_pcs)= + % str: the message to be formatted + % fst_len: first line length + % nxt_len: following lines length + % dbl_pcs (boolean): occurrences of the percent character must be doubled + save str_len, sub_len, aux_len, chr_rnk, occ_num; + numeric str_len, sub_len, aux_len, chr_rnk, occ_num; + save aux_str, chr; + string aux_str, chr; + str_len:=length str; + sub_len:=0; + chr_rnk:=0; + occ_num:=0; + aux_len:=0; + aux_str:=""; + forever: + exitif (chr_rnk=fst_len) or (chr_rnk=str_len); + chr:=substring (chr_rnk, chr_rnk+1) of str; + aux_str:=aux_str&chr; + if chr=" ": + sub_len:=chr_rnk+1; + aux_len:=sub_len+occ_num; + elseif (chr="%") and dbl_pcs: + aux_str:=aux_str&"%"; + occ_num:=occ_num+1; + fi + chr_rnk:=chr_rnk+1; + endfor + if chr_rnk=fst_len: + begingroup + if sub_len=0: + sub_len:=fst_len; + aux_len:=sub_len+occ_num; + fi + substring (0, aux_len) of aux_str& + for idx=sub_len+1 upto fst_len: + " "& + endfor + drv_format (substring (sub_len, str_len) of str, + nxt_len, nxt_len, dbl_pcs) + endgroup + else: + aux_str + fi +enddef; + +boolean drv_inside_fig; +drv_inside_fig:=false; + +vardef drv_context= + "drv"&if drv_inside_fig: " (fig. "&decimal charcode&")"&fi ": " +enddef; + +vardef drv_message expr str= + message drv_format (drv_context&str, 79, 79, false); +enddef; + +vardef drv_errhelp expr str= + % Occurrences of the percent character must be doubled: errhelp makes single + % single occurrences behave as newline characters (this is inherited from + % MetaFont). + errhelp drv_format (str, 79, 79, true); +enddef; + +vardef drv_errmessage expr str= + % errmessage inserts the 2-characters string "! " before its argument. + % Hence 77 as a first line length argument. + errmessage drv_format (drv_context&str, 77, 79, false); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Delayed LaTeX processing +% + +picture tex_pct[]; +string delayed_tex_file; +delayed_tex_file:=jobname&"-delayed.mp"; + +% +% reading LaTeX picture definitions +% + +boolean drv_nullpicture; +drv_nullpicture:=true; + +string readfrom_str; +readfrom_str:=readfrom delayed_tex_file; +if readfrom_str<>EOF: + closefrom delayed_tex_file; + drv_message ("reading `"&delayed_tex_file&"' LateX picture definitions."); + batchmode; + scantokens ("input "&delayed_tex_file); + errorstopmode; + drv_message "done."; + drv_nullpicture:=false; +fi + +% +% copying LaTeX preamble +% + +vardef drv_read (expr search_str) (suffix accum_str)= + save readfrom_str, readfrom_substr; + string readfrom_str, readfrom_substr; + accum_str:=""; + forever: + readfrom_str:=readfrom jobname; + readfrom_substr:=substring (0, length search_str) of readfrom_str; + exitif (readfrom_substr=search_str) or (readfrom_str=EOF); + accum_str:=accum_str&readfrom_str&char(10); + endfor + if readfrom_str=EOF: + closefrom jobname; + drv_errhelp ("`"&jobname&".mp' should contain a line starting with "& + ditto&search_str&ditto&"."); + drv_errmessage (ditto&search_str&ditto&" is missing"); + fi +enddef; + +string tex_preamble_str[]; +% tex_preamble_str[0] from "verbatimtex %&latex" to "\begin{document}" +% tex_preamble_str[1] from "\begin{document}" to "etex;" + +drv_message ("reading `"&jobname&".mp' LateX preamble."); + drv_read ("verbatimtex %&latex", tex_preamble_str[0]); + drv_read ("\begin{document}", tex_preamble_str[0]); + drv_read ("etex;", tex_preamble_str[1]); + closefrom jobname; + write + "%"&char(10)& + "% AUTOMATICALLY GENERATED BY DRV.MP - DO NOT MODIFY."&char(10)& + "%"&char(10)&char(10)& + "verbatimtex %&latex"&char(10)& + tex_preamble_str[0]& + "\begin{document}"&char(10)& + tex_preamble_str[1]& + "etex;" + to delayed_tex_file; +drv_message "done."; + +% +% writing LaTeX picture definitions +% + +numeric tex_pct_idx; +tex_pct_idx:=0; + +% Math style indices: 0, 1, 2, 3 +string mth_sty_str[]; +mth_sty_str[0]:="\displaystyle"; +mth_sty_str[1]:="\textstyle"; +mth_sty_str[2]:="\scriptstyle"; +mth_sty_str[3]:="\scriptscriptstyle"; + +string drv_fontsize; + +vardef drv_tex[] expr tex_str= + % @: math style index + % tex_str: math mode LaTeX code + save def_str, pct; + string def_str; + picture pct; + def_str:="btex{"&drv_fontsize&"$"&mth_sty_str[@]&"{}"&tex_str&"{}$}etex;"; + write "tex_pct["&(decimal tex_pct_idx)&"]:="&def_str to delayed_tex_file; + pct:= + if known tex_pct[tex_pct_idx]: + tex_pct[tex_pct_idx] + else: + nullpicture + fi; + tex_pct_idx:=tex_pct_idx+1; + pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MetaPost shorthands +% + +vardef depth expr pct= + ypart llcorner pct +enddef; + +vardef height expr pct= + ypart urcorner pct +enddef; + +vardef width expr pct= + xpart urcorner pct-xpart llcorner pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Font-specific parameters +% + +% +% em[s] width of an m (s: mathstyle index) +% ex[s] height of an x +% axis_hg[s] height of the mathematical axis +% num_bl_hg[s] height of a numerator baseline w.r.t. the fraction bar axis +% den_bl_dp[s] depth of a denominator baseline w.r.t. the fraction bar axis +% rul_thk[s] default rule thickness +% + +numeric em[], ex[], axis_hg[], num_bl_hg[], den_bl_dp[], rul_thk[]; + +% +% thn_sp[s] thin space, usually 1em/6 +% med_sp[s] medium space, usually 2em/9 +% thk_sp[s] thick space, usually 5em/18 +% + +numeric thn_sp[], med_sp[], thk_sp[]; + +% +% pdt_hg[s] height of a punctuation ldot +% pdt_wd[s] width of a punctuation ldot +% + +numeric pdt_hg[], pdt_wd[]; + +% +% tt_dgt[s][i] typewriter typeface digits (i ranges from 0 to 9) +% + +picture tt_dgt[][]; + +% +% min_clr[s] minimal clearance between a numerator +% or a denominator and the fraction bar +% prm_skp[s] <nice explanation> +% jdg_skp[s] <nice explanation> +% ilb_skp[s] <nice explanation> +% plb_skp[s] <nice explanation> +% + +numeric min_clr[], prm_skp[], jdg_skp[], ilb_skp[], plb_skp[]; + +vardef drv_fontdimen[] expr font= + save dim_pct; + picture dim_pct; + dim_pct:=drv_tex[0] ("\rule{\the\fontdimen"&(decimal @)&font&"}{0bp}"); + width dim_pct +enddef; + +vardef drv_font_size expr size_str= + save pdt_pct, sp_pct; + picture pdt_pct, sp_pct; + drv_fontsize:=size_str; + write char(10)&"% font-specific parameters ("&drv_fontsize&")"&char(10) + to delayed_tex_file; + ex[0]:=drv_fontdimen[5] "\textfont2"; + ex[1]:=drv_fontdimen[5] "\textfont2"; + ex[2]:=drv_fontdimen[5] "\scriptfont2"; + ex[3]:=drv_fontdimen[5] "\scriptscriptfont2"; + em[0]:=drv_fontdimen[6] "\textfont2"; + em[1]:=drv_fontdimen[6] "\textfont2"; + em[2]:=drv_fontdimen[6] "\scriptfont2"; + em[3]:=drv_fontdimen[6] "\scriptscriptfont2"; + rul_thk[0]:=drv_fontdimen[8] "\textfont3"; + rul_thk[1]:=drv_fontdimen[8] "\textfont3"; + rul_thk[2]:=drv_fontdimen[8] "\scriptfont3"; + rul_thk[3]:=drv_fontdimen[8] "\scriptscriptfont3"; + axis_hg[0]:=drv_fontdimen[22] "\textfont2"; + axis_hg[1]:=drv_fontdimen[22] "\textfont2"; + axis_hg[2]:=drv_fontdimen[22] "\scriptfont2"; + axis_hg[3]:=drv_fontdimen[22] "\scriptscriptfont2"; + num_bl_hg[0]:=(drv_fontdimen[8] "\textfont2")-axis_hg[0]; + num_bl_hg[1]:=(drv_fontdimen[9] "\textfont2")-axis_hg[1]; + num_bl_hg[2]:=(drv_fontdimen[9] "\scriptfont2")-axis_hg[2]; + num_bl_hg[3]:=(drv_fontdimen[9] "\scriptscriptfont2")-axis_hg[3]; + den_bl_dp[0]:=-(drv_fontdimen[11] "\textfont2")-axis_hg[0]; + den_bl_dp[1]:=-(drv_fontdimen[12] "\textfont2")-axis_hg[1]; + den_bl_dp[2]:=-(drv_fontdimen[12] "\scriptfont2")-axis_hg[2]; + den_bl_dp[3]:=-(drv_fontdimen[12] "\scriptscriptfont2")-axis_hg[3]; + min_clr[0]:=3*rul_thk[0]; % The TEXbook, + min_clr[1]:=1*rul_thk[1]; % Appendix G, + min_clr[2]:=1*rul_thk[2]; % Rule 15d. + min_clr[3]:=1*rul_thk[3]; % + for mth_sty:=0 upto 3: + sp_pct:=drv_tex[mth_sty] "\,"; + thn_sp[mth_sty]:=width sp_pct; + sp_pct:=drv_tex[mth_sty] "\>"; + med_sp[mth_sty]:=width sp_pct; + sp_pct:=drv_tex[mth_sty] "\;"; + thk_sp[mth_sty]:=width sp_pct; + pdt_pct:=drv_tex[mth_sty] "\ldotp"; + pdt_hg[mth_sty]:=height pdt_pct; + pdt_wd[mth_sty]:=width pdt_pct; + for dgt=0 upto 9: + tt_dgt[mth_sty][dgt]:=drv_tex[mth_sty] "\texttt{"&(decimal dgt)&"}"; + endfor + prm_skp[mth_sty]:=3*med_sp[mth_sty]; % arbitrary + jdg_skp[mth_sty]:=thn_sp[mth_sty]; % arbitrary + ilb_skp[mth_sty]:=thn_sp[mth_sty]; % arbitrary + plb_skp[mth_sty]:=thk_sp[mth_sty]; % arbitrary + endfor +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Math-related parameters & macros +% + +% +% Math styles +% drv_sty derivation trees +% jdg_sty[drv_sty] judgments +% ilb_sty[drv_sty] inference labels +% dlb_sty[drv_sty] delimiter labels +% plb_sty[drv_sty] phantom steps labels +% + +numeric drv_sty, jdg_sty[], ilb_sty[], dlb_sty[], plb_sty[]; + +% +% Math-axis centered LaTeX pictures +% + +vardef mth_tex[] expr tex_str= + (drv_tex[@] tex_str) shifted (0, -axis_hg[@]) +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% drv-boxes +% + +vardef drv_box text STR= + for str=STR: + expandafter picture scantokens str; + expandafter pair scantokens str.l; + expandafter pair scantokens str.c; + expandafter pair scantokens str.r; + expandafter numeric scantokens str.hg; + expandafter numeric scantokens str.dp; + endfor +enddef; + +vardef box_init @# (expr pct)= + @#:=pct; + @#.r-@#.l=(width pct, 0); + @#.c=(@#.l+@#.r)/2; + @#.hg:=height pct; + @#.dp:=depth pct; +enddef; + +vardef box_freeze @#= + @#:=@# shifted @#.l; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% beginfig & endfig +% + +% +% drv_beginfig: figure initialization +% + +pen drv_pen; + +vardef drv_beginfig= + % + % Judgments + % + % jdg[i] judgment drv-box + % sbj_num[i] number of sub-judgments + % sbj[i][j] sub-judgment drv-box (j ranges from 0 to sbj_num[i]-1) + % + drv_box "jdg[]"; + numeric sbj_num[]; + drv_box "sbj[][]"; + % + % Inferences + % + % prm_num[i] number of premises + % prm[i][j] premise index (j ranges from 0 to prm_num[i]-1) + % ccl[i] conclusion index + % jct_sty[i] junction style + % alg_sty[i] alignment style + % iln_sty[i] inference line style + % l_prm[i] leftmost `graphical' premise index + % r_prm[i] rightmost `graphical' premise index + % + numeric prm_num[], prm[][], ccl[]; + numeric jct_sty[]; + string alg_sty[]; + numeric iln_sty[]; + numeric l_prm[], r_prm[]; + % + % imin_x[i] inference minimal x + % l_dlb[i] left delimiter label drv-box + % l_dlm[i] left delimiter drv-box + % l_ilb[i] left label drv-box + % iln[i] inference line drv-box + % r_ilb[i] right label drv-box + % r_dlm[i] right delimiter drv-box + % r_dlb[i] right delimiter label drv-box + % imax_x[i] inference maximal x + % + numeric imin_x[]; + drv_box "l_dlb[]", "l_dlm[]", "l_ilb[]"; + drv_box "iln[]"; + drv_box "r_ilb[]", "r_dlm[]", "r_dlb[]"; + numeric imax_x[]; + % + % Sub-trees + % + % smin_x[i] sub-tree minimal x + % smax_x[i] sub-tree maximal x + % smin_y[i] sub-tree minimal y + % smax_y[i] sub-tree maximal y + % boxed[i] boolean + % + numeric smin_x[], smax_x[], smin_y[], smax_y[]; + boolean boxed[]; + % + % Pen initialization + % + drv_pen:=pencircle scaled rul_thk[drv_sty]; + % + % num_hg height of a numerator axis w.r.t. the fraction bar axis + % den_dp depth of a denominator axis w.r.t. the fraction bar axis + % iln_hg[s] height of a style s inference line + % iln_dp[s] depth of a style s inference line + % + numeric num_hg, den_dp, iln_hg[], iln_dp[]; + num_hg:=num_bl_hg[drv_sty]+axis_hg[jdg_sty[drv_sty]]; + den_dp:=den_bl_dp[drv_sty]+axis_hg[jdg_sty[drv_sty]]; + picture iln_pct; + for sty=0 upto 6: + iln_pct:=((0, 0)--(10, 0)) drv_styled sty; + iln_hg[sty]:=height iln_pct; + iln_dp[sty]:=depth iln_pct; + endfor + % + % Derivation trees + % + % root_num number of roots + % root[i] root index (i ranges from 0 to root_num-1) + % drv_built boolean + % drv_frozen boolean + % + numeric root_num, root[]; + boolean drv_checked, drv_built, drv_frozen; + root_num:=0; + drv_checked:=false; + drv_built:=false; + drv_frozen:=false; + % + % Phantom steps + % + % phm_idx phantom inferences index + % src[i] base phantom judgment index (in case of an origin judgment) + % tgt[i] origin judgment index (in case of a base phantom judgment) + % phm_sty[i] phantom steps style + % l_plb[i] left phantom steps label drv-box (in case of a base + % phantom judgment) + % phm[i] phantom steps drv-box (in case of a base phantom + % judgment) + % r_plb[i] right phantom steps label drv-box (in case of a base + % phantom judgment) + % + numeric phm_idx, src[], tgt[], phm_sty[]; + phm_idx:=0; + drv_box "l_plb[]", "phm[]", "r_plb[]"; + % + % Proof pictures + % + % jdg_prf[i] judgment index drv-box + % sbj_prf[i][j] sub-judgment index drv-box (j ranges from 0 to + % sbj_num[i]-1) + % + drv_box "jdg_prf[]", "sbj_prf[][]"; + % + % Info + % + write char(10)&"% fig. "&(decimal charcode)&char(10) to delayed_tex_file; + drv_inside_fig:=true; % context: inside a figure +enddef; + +extra_beginfig:=extra_beginfig&"drv_beginfig;"; + +% +% drv_endfig: proof-file generation +% + +string proof_file; +proof_file:=jobname&"-proof.tex"; + +% TODO: taking outputtemplate into account. +vardef output_file[]= + jobname&"."&(decimal @) +enddef; + +string buf_str; +buf_str:= + "%"&char(10)& + "% AUTOMATICALLY GENERATED BY DRV.MP."&char(10)& + "%"&char(10)&char(10)& + tex_preamble_str[0]& + "\usepackage{graphicx}"&char(10)& + "\makeatletter"&char(10)& + "\def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}}"&char(10)& + "\newsavebox{\graphicsbox}"&char(10)& + "\newcommand*{\drv}[1]{%"&char(10)& + "\sbox{\graphicsbox}{\includegraphics{#1}}%"&char(10)& + "\raisebox{\Gin@lly bp}%"&char(10)& + "{\usebox{\graphicsbox}}}"&char(10)& + "\makeatother"&char(10)&char(10)& + "\newcount\h"&char(10)& + "\newcount\m"&char(10)& + "\h=\time"&char(10)& + "\divide\h 60"&char(10)& + "\m=-\h"&char(10)& + "\multiply\m 60"&char(10)& + "\advance\m\time"&char(10)& + "\def\hm{\number\h:\ifnum\m<10{}0\fi\number\m}"&char(10)&char(10)& + "\newcommand{\mathaxis}{\frac{\quad}{}}"&char(10)&char(10)& + "\begin{document}"&char(10)& + tex_preamble_str[1]& + "\noindent\today\ at \hm\medskip"&char(10)&char(10)&"\noindent"; + +vardef drv_endfig= + drv_inside_fig:=false; % context: outside a figure + buf_str:=buf_str&char(10)& + "\texttt{"&output_file[charcode]&"}"&char(10)& + " (\verb+"&drv_fontsize&"+, \verb+"&(mth_sty_str[drv_sty])&"+)"&char(10)& + " {"&drv_fontsize&char(10)& + " \["&(mth_sty_str[drv_sty])&char(10)& + " \mathaxis\drv{"&output_file[charcode]&"}\mathaxis"&char(10)& + " \]}\\"; + write EOF to proof_file; % erases the previous content + write buf_str&char(10)&"\end{document}" to proof_file; + write EOF to proof_file; + if drv_nullpicture: + draw btex{\tt drv}: run {\tt mpost} again.etex withcolor (1, 0, 0); + fi +enddef; + +extra_endfig:="drv_endfig;"&extra_endfig; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Judgment declarations +% + +vardef jgm[] text SUB= + % @: judgment index + % SUB: list of `sub-judgments' (pictures or strings) + if @<0: + drv_errhelp "An judgment index can not be negative."; + drv_errmessage (decimal @)&" is negative"; + elseif known jdg[@]: + drv_errhelp "An index can be used only once to declare a judgment."; + drv_errmessage (decimal @)&" has been used already as a judgment index"; + else: + save jdg_pct, sbj_pct, jdg_wd, sbj_rnk; + picture jdg_pct, sbj_pct; + numeric jdg_wd, sbj_rnk; + jdg_pct:=nullpicture; + jdg_wd:=0; + sbj_rnk:=0; + for sub=SUB: + sbj_pct:= + if picture sub: + sub + elseif sub<>"": + mth_tex[jdg_sty[drv_sty]] sub + else: + nullpicture + fi; + box_init sbj[@][sbj_rnk] (sbj_pct); + if sbj_rnk>0: + sbj[@][sbj_rnk-1].r=sbj[@][sbj_rnk].l; + fi + addto jdg_pct also sbj_pct shifted (jdg_wd, 0); + jdg_wd:=width jdg_pct; + sbj_rnk:=sbj_rnk+1; + endfor + sbj_num[@]:=sbj_rnk; + box_init jdg[@] (jdg_pct); + if sbj_num[@]>0: + jdg[@].l=sbj[@][0].l; + jdg[@].r=sbj[@][sbj_num[@]-1].r; + fi + fi +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Inference declarations +% + +vardef check_junction_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="0") + or (sty_str="1") + or (sty_str="2") + or (sty_str="3"): + sty_sfx + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " 0 (fully-interlacing),"& + " 1 (semi-interlacing),"& + " 2 (non-interlacing),"& + " 3 (user specified) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid junction style identifier"; + default + endgroup + fi +enddef; + +vardef check_alignment_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="l") + or (sty_str="c") + or (sty_str="r") + or (sty_str="u"): + sty_str + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " l (none),"& + " c (simple),"& + " r (double),"& + " u (dotted) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid alignment style identifier"; + default + endgroup + fi +enddef; + +vardef check_path_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="0") + or (sty_str="1") + or (sty_str="2") + or (sty_str="3") + or (sty_str="4") + or (sty_str="5") + or (sty_str="6"): + sty_sfx + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " 0 (none),"& + " 1 (simple),"& + " 2 (double),"& + " 3 (dotted),"& + " 4 (dashed),"& + " 5 (waved),"& + " 6 (TeX-dotted) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid path style identifier"; + default + endgroup + fi +enddef; + +vardef opt_init[] @# expr arg= + if picture arg: + if arg<>nullpicture: + box_init @# (arg); + fi + elseif arg<>"": + box_init @# (mth_tex[@] arg); + fi +enddef; + +vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) + (suffix j_sty, a_sty, i_sty)= + % + % @: inference index + % + if known prm_num[@]: + drv_errhelp "An index can be used only once to declare an inference."; + drv_errmessage (decimal @)&" has been used already as an inference index"; + else: + % + % PRM: list of premise indices + % + save prm_rnk; + numeric prm_rnk; + prm_rnk:=0; + for prm_idx=PRM: + if prm_idx=@: + drv_errhelp "An inference index can not be used"& + " as one of its own premise indices."; + drv_errmessage "the inference index "&(decimal prm_idx)& + " is used as one of its own premise indices"; + elseif known ccl[prm_idx]: + drv_errhelp "An index can be used only once as a premise index."; + drv_errmessage (decimal prm_idx)&" has been used already as a"& + " premise index for inference declaration "&(decimal ccl[prm_idx]); + else: + if known prm_num[prm_idx]: + % + % roots list update + % + save root_idx; + numeric root_idx; + root_idx:=0; + forever: + exitif root[root_idx]=prm_idx; + root_idx:=root_idx+1; + endfor + forever: + exitif root_idx=root_num-1; + root[root_idx]:=root[root_idx+1]; + root_idx:=root_idx+1; + endfor + root_num:=root_num-1; + fi + ccl[prm_idx]:=@; + prm[@][prm_rnk]:=prm_idx; + prm_rnk:=prm_rnk+1; + fi + endfor + prm_num[@]:=prm_rnk; + if known ccl[@]: + % + % cycle detection + % + save ccl_idx, ccl_str; + numeric ccl_idx; + string ccl_str; + ccl_idx:=@; + ccl_str:=decimal ccl_idx; + forever: + ccl_idx:=ccl[ccl_idx]; + if ccl_idx>=0: + ccl_str:=(decimal ccl_idx)&", "&ccl_str; + fi + exitif (unknown ccl[ccl_idx]) or (ccl_idx=@); + endfor + if ccl_idx=@: + drv_errhelp "Inferences declarations can not be cyclic."; + drv_errmessage "inference declaration "&(decimal @)&" creates a"& + " cycle of inferences (indices "&ccl_str&" from conclusions to"& + " premises)"; + fi + else: + root[root_num]:=@; + root_num:=root_num+1; + fi + % + % lilb, rilb: inference labels + % + opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; + opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + % + % ldlb, rdlb: delimiter labels + % + opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; + opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + % + % j_sty, a_sty and i_sty: junction, alignment and inference styles + % + jct_sty[@]:=check_junction_style (j_sty, drv_jct_sty); + alg_sty[@]:=check_alignment_style (a_sty, drv_alg_sty); + iln_sty[@]:=check_path_style (i_sty, drv_iln_sty); + if drv_boxmode_on: + boxed[@]:=true; + fi + fi +enddef; + +vardef DCL[] (text PRM) (expr lilb, rilb, ldlb, rdlb) + (suffix j_sty, a_sty, i_sty) text SUB= + NFR[@] (PRM) (lilb, rilb, ldlb, rdlb, j_sty, a_sty, i_sty); + jgm[@] SUB; +enddef; + +vardef MVD[] (expr inf_num, lplb, rplb) (suffix a_sty, p_sty)= + if inf_num<1: + drv_errhelp "The minimal value is 1."; + drv_errmessage (decimal inf_num)&" is not a valid number of inference"& + " steps"; + else: + save aux_idx, aux_sty, phm_jdg; + numeric aux_idx, aux_sty; + picture phm_jdg; + aux_sty:=check_path_style (p_sty, drv_phm_sty); + phm_jdg:=nullpicture; + setbounds phm_jdg to (0, 0)--(iln_hg[aux_sty]-iln_dp[aux_sty], 0)--cycle; + aux_idx:=@; + for i=1 upto inf_num: + phm_idx:=phm_idx-1; + box_init jdg[phm_idx] (phm_jdg); + sbj_num[phm_idx]:=0; + NFR[phm_idx] (aux_idx) ("", "", "", "", 0, a_sty, 0); + aux_idx:=phm_idx; + endfor + src[@]:=phm_idx; + tgt[phm_idx]:=@; + phm_sty[phm_idx]:=aux_sty; + % + % lplb, rplb: phantom steps labels + % + opt_init[plb_sty[drv_sty]] l_plb[phm_idx] lplb; + opt_init[plb_sty[drv_sty]] r_plb[phm_idx] rplb; + phm_idx + fi +enddef; + +vardef bxd[]= + boxed[@]:=true; + @ +enddef; + +% +% Optional labels & shorthands +% + +numeric drv_jct_sty; % default junction style +string drv_alg_sty; % default junction style +numeric drv_iln_sty; % default inference line path-style +numeric drv_phm_sty; % default phantom steps path-style + +boolean drv_left_ilb; % inference labels on the left +boolean drv_left_dlb; % delimiter labels (hence delimiters) on the left +boolean drv_left_plb; % phantom steps labels on the left + +vardef arg_type expr arg= + if picture arg: + "picture" + else: + "string" + fi +enddef; + +vardef opt_lbls @# (text LBL) expr left_lbls= + save lbl_num, fst_lbl, snd_lbl; + numeric lbl_num; + lbl_num:=0; + for lbl=LBL: + if lbl_num=0: + scantokens (arg_type lbl) fst_lbl; + fst_lbl:=lbl; + elseif lbl_num=1: + scantokens (arg_type lbl) snd_lbl; + snd_lbl:=lbl; + else: + drv_errhelp "At most two labels can be specified:"& + " a left one and a right one."; + drv_errmessage "more than two labels have been specified"; + fi + lbl_num:=lbl_num+1; + endfor + if lbl_num=0: + string @#.l; + string @#.r; + @#.l:=""; + @#.r:=""; + elseif lbl_num=1: + if left_lbls: + scantokens (arg_type fst_lbl) @#.l; + string @#.r; + @#.l:=fst_lbl; + @#.r:=""; + else: + string @#.l; + scantokens (arg_type fst_lbl) @#.r; + @#.l:=""; + @#.r:=fst_lbl; + fi + else: + scantokens (arg_type fst_lbl) @#.l; + scantokens (arg_type snd_lbl) @#.r; + @#.l:=fst_lbl; + @#.r:=snd_lbl; + fi +enddef; + +vardef NFR_opt[] (text PRM) (text ILB) (text DLB) + (suffix j_sty, a_sty, i_sty)= + opt_lbls ilb (ILB) drv_left_ilb; + opt_lbls dlb (DLB) drv_left_dlb; + NFR[@] (PRM) (ilb.l, ilb.r, dlb.l, dlb.r, j_sty, a_sty, i_sty); +enddef; + +vardef DCL_opt[] (text PRM) (text ILB) (text DLB) + (suffix j_sty, a_sty, i_sty) text SUB= + NFR_opt[@] (PRM) (ILB) (DLB) (j_sty, a_sty, i_sty); + jgm[@] SUB; +enddef; + +vardef MVD_opt[] (expr inf_num) (text PLB) (suffix a_sty, p_sty)= + opt_lbls plb (PLB) drv_left_plb; + MVD[@] (inf_num, plb.l, plb.r, a_sty, p_sty) +enddef; + +% Nfr, Dcl & Mvd + +vardef Nfr[] (text PRM) (expr ilb, ldlb, rdlb) (suffix i_sty)= + NFR_opt[@] (PRM) (ilb) (ldlb, rdlb) (_, _, i_sty); +enddef; + +vardef Dcl[] (text PRM) (expr ilb, ldlb, rdlb) (suffix i_sty) text SUB= + Nfr[@] (PRM) (ilb, ldlb, rdlb, i_sty); + jgm[@] SUB; +enddef; + +vardef Mvd[] (expr inf_num, lplb, rplb) (suffix p_sty)= + MVD[@] (inf_num, lplb, rplb, _, p_sty) +enddef; + +% nfr, dcl & mvd + +vardef nfr[] (text PRM) (expr ilb) (suffix i_sty)= + NFR_opt[@] (PRM) (ilb) () (_, _, i_sty); +enddef; + +vardef dcl[] (text PRM) (expr ilb) (suffix i_sty) text SUB= + nfr[@] (PRM) (ilb, i_sty); + jgm[@] SUB; +enddef; + +vardef mvd[] (expr inf_num) (suffix p_sty)= + MVD_opt[@] (inf_num) () (_, p_sty) +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Pictured paths +% + +vardef dotted_aux (expr pth, dot_wd, dots_dist)= + save pth_len, pct; + numeric pth_len; + picture pct; + pth_len:=arclength pth; + pct:=nullpicture; + if dots_dist>0: + stp_num:=round ((pth_len-dot_wd)/dots_dist); + if stp_num>0: + stp_len:=(pth_len-dot_wd)/stp_num; + addto pct doublepath pth dashed dashpattern (on 0 off stp_len) + shifted (dot_wd/2, 0) withpen pencircle scaled dot_wd; + fi + fi + pct +enddef; + +primarydef pth dotted wd_dist= + dotted_aux(pth, xpart wd_dist, ypart wd_dist) +enddef; + +vardef expanded_aux (expr pth, scl, dir, stp_len)= + save pth_len, aux_len; + numeric pth_len, aux_len; + pth_len:=arclength pth; + if (stp_len>0) and (pth_len>stp_len): + aux_len:=pth_len/(pth_len div stp_len); + point arctime 0 of pth of pth shifted + (unitvector direction arctime 0 of pth of pth + rotated dir scaled scl).. + {direction arctime 0 of pth of pth} + for i=aux_len step aux_len until pth_len-aux_len: + point arctime i of pth of pth shifted + (unitvector direction arctime i of pth of pth + rotated dir scaled scl) + {direction arctime i of pth of pth}.. + endfor + point arctime pth_len of pth of pth shifted + (unitvector direction arctime pth_len of pth of pth + rotated dir scaled scl) + {direction arctime pth_len of pth of pth} + else: + pth + fi +enddef; + +primarydef pth expanded scl_dir_len= + expanded_aux (pth, + redpart scl_dir_len, greenpart scl_dir_len, bluepart scl_dir_len) +enddef; + +vardef waved_aux (expr pth, amp)= + save pth_len, mid; + numeric pth_len, mid; + pth_len:=arclength pth; + if (amp>0) and (pth_len>2(1+sqrt 5)*amp): + mid:=pth_len/(2(pth_len div (2(1+sqrt 5)*amp))); + point arctime 0 of pth of pth shifted + (unitvector direction arctime 0 of pth of pth + rotated -90 scaled amp) + {direction arctime 0 of pth of pth} + for i=mid step 2mid until pth_len: + ..point arctime i of pth of pth shifted + (unitvector direction arctime i of pth of pth + rotated 90 scaled amp) + {direction arctime i of pth of pth} + ..point arctime i+mid of pth of pth shifted + (unitvector direction arctime i+mid of pth of pth + rotated -90 scaled amp) + {direction arctime i+mid of pth of pth} + endfor + else: + pth + fi +enddef; + +primarydef pth waved amp= + waved_aux(pth, amp) +enddef; + +vardef drv_styled_aux[] expr pth= + save sty_idx, pth_len, pct; + numeric sty_idx, pth_len; + picture pct; + sty_idx:=check_path_style (@, 1); + pth_len:=arclength pth; + pct:=nullpicture; + if sty_idx=1: + interim linecap:=butt; + addto pct doublepath pth withpen drv_pen; + elseif sty_idx=2: + interim linecap:=butt; + addto pct doublepath pth + expanded (1.25rul_thk[drv_sty], 90, rul_thk[drv_sty]) + withpen drv_pen; + addto pct doublepath pth + expanded (1.25rul_thk[drv_sty], -90, rul_thk[drv_sty]) + withpen drv_pen; + elseif sty_idx=3: + addto pct also pth dotted (rul_thk[drv_sty], 2rul_thk[drv_sty]); + elseif sty_idx=4: + if rul_thk[drv_sty]>0: + interim linecap:=butt; + save dsh_num, dsh_len; + numeric dsh_num, dsh_len; + dsh_num:=round(pth_len/(3rul_thk[drv_sty])); + dsh_len:= + if odd dsh_num: + pth_len/dsh_num + else: + pth_len/(dsh_num+1) + fi; + addto pct doublepath pth dashed dashpattern(on dsh_len off dsh_len) + withpen drv_pen; + fi + elseif sty_idx=5: + interim linecap:=butt; + addto pct doublepath pth + waved 1.25rul_thk[drv_sty] withpen drv_pen; + elseif (sty_idx=6) and (pth_len>0): + addto pct also pth dotted (pdt_hg[drv_sty], pdt_wd[drv_sty]); + fi + pct +enddef; + +primarydef pth drv_styled sty= + drv_styled_aux[sty] pth +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Delimiters +% + +% +% 1. Global parameters +% + +string drv_l_dlm; % left delimiter LaTeX code +string drv_r_dlm; % right delimiter LaTeX code + +% +% 2. Macros +% + +vardef minmax_y[]=( + if drv_bot_roots: + if known ccl[@]: + ypart jdg[@].c-num_hg+iln_hg[(iln_sty[ccl[@]])] + +min_clr_scl*min_clr[drv_sty]/2 + else: + smin_y[@]-min_clr_scl*min_clr[drv_sty] + fi, + smax_y[@]+min_clr_scl*min_clr[drv_sty] + else: + smin_y[@]-min_clr_scl*min_clr[drv_sty], + if known ccl[@]: + ypart jdg[@].c-den_dp-iln_hg[(iln_sty[ccl[@]])] + -min_clr_scl*min_clr[drv_sty]/2 + else: + smax_y[@]+min_clr_scl*min_clr[drv_sty] + fi + fi) +enddef; + +vardef delim @# expr dlm_len= + save rule_str, dlm_str, dlm_pct, dlm_dp; + string rule_str, dlm_str; + picture dlm_pct; + numeric dlm_dp; + rule_str:="\rule{0bp}{"&(decimal(dlm_len/2+axis_hg[drv_sty]))&"bp}"; + dlm_str:= + if str @#="l": + "\left"&drv_l_dlm&rule_str&"\right." + else: + "\left."&rule_str&"\right"&drv_r_dlm + fi; + dlm_pct:=mth_tex[drv_sty] dlm_str; + dlm_dp:=depth dlm_pct; + if dlm_dp=0: + nullpicture + else: + begingroup + setbounds dlm_pct to + (xpart llcorner dlm_pct, dlm_dp) + --(xpart ulcorner dlm_pct, -dlm_dp) + --(xpart urcorner dlm_pct, -dlm_dp) + --(xpart lrcorner dlm_pct, dlm_dp) + --cycle; + dlm_pct yscaled (dlm_len/(2*height dlm_pct)) + endgroup + fi +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Checking, building, freezing (very inefficient, to be improved) +% + +% +% 1. Global parameters +% + +numeric min_clr_scl; % +numeric prm_skp_scl; % +numeric jdg_skp_scl; % +numeric ilb_skp_scl; % +numeric plb_skp_scl; % + +boolean drv_bot_roots; % +boolean drv_boxmode_on; % +boolean drv_fractionmode_on; % +string drv_axis_ref; % + +% +% 2. Macros +% + +% +% Checking +% + +vardef fraction_inference[]= + (prm_num[@]=0) + and (iln_sty[@]=0) + and (unknown l_ilb[@]) + and (unknown r_ilb[@]) + and drv_fractionmode_on +enddef; + +vardef drv_check_root[]= + if unknown jdg[@]: + drv_errhelp "An index must be used to declare a both a judgment and an"& + " inference."; + drv_errmessage (decimal @)&" has been used as an inference index but not"& + " as a judgment index"; + elseif unknown prm_num[@]: + drv_errhelp "An index must be used to declare a both a judgment and an"& + " inference."; + drv_errmessage (decimal @)&" has been used as a judgment index but not"& + " as an inference index"; + else: + save i_sty, prm_idx; + numeric i_sty, prm_idx; + i_sty:=iln_sty[@]; + for prm_rnk=0 upto prm_num[@]-1: + prm_idx:=prm[@][prm_rnk]; + drv_check_root[prm_idx]; + % + % numerators and denominators clearances + % The TEXbook, Appendix G, Rule 15d. + % + if drv_bot_roots: + num_hg:=max(num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].dp); + else: + den_dp:=min(den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].hg); + fi + endfor + if not fraction_inference[@]: + if drv_bot_roots: + den_dp:=min(den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[@].hg); + else: + num_hg:=max(num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[@].dp); + fi + fi + if unknown boxed[@]: + boxed[@]:=false; + fi + fi +enddef; + +vardef drv_check= + if root_num=0: + drv_errhelp "Well ..."; + drv_errmessage "no inference has been declared"; + else: + save root_idx; + numeric root_idx; + root_idx:=root[0]; + drv_check_root[root_idx]; + if root_num>1: + save root_str; + string root_str; + root_str:=decimal root_idx; + for idx=1 upto root_num-1: + root_idx:=root[idx]; + drv_check_root[root_idx]; + root_str:=root_str&", "&(decimal root_idx); + endfor + drv_message "warning, multiple root indices ("&root_str&")."; + fi + fi + drv_checked:=true; +enddef; + +% +% Building +% + +vardef drv_build_root[]= + % + % premises junction (from left to right) + % + for prm_rnk=0 upto prm_num[@]-1: + drv_build_root[prm[@][prm_rnk]]; + if prm_rnk>0: + save ll_idx, lr_idx, rl_idx, rr_idx; + save lmax_x, rmin_x, min_skp; + numeric ll_idx, lr_idx, rl_idx, rr_idx; + numeric lmax_x, rmin_x, min_skp; + ypart jdg[prm[@][prm_rnk-1]].c=ypart jdg[prm[@][prm_rnk]].c; + ll_idx:=prm[@][0]; + lr_idx:=prm[@][prm_rnk-1]; + rl_idx:=prm[@][prm_rnk]; + rr_idx:=prm[@][prm_rnk]; + lmax_x:=imax_x[lr_idx]; + rmin_x:=imin_x[rl_idx]; + min_skp[0]:=rmin_x-lmax_x; + forever: + exitif (unknown r_prm[lr_idx]) or (unknown l_prm[rl_idx]); + ll_idx:=l_prm[ll_idx]; + lr_idx:=r_prm[lr_idx]; + rl_idx:=l_prm[rl_idx]; + rr_idx:=r_prm[rr_idx]; + lmax_x:=max(lmax_x, imax_x[lr_idx]); + rmin_x:=min(rmin_x, imin_x[rl_idx]); + min_skp[0]:=min(min_skp[0], imin_x[rl_idx]-imax_x[lr_idx]); + endfor + min_skp[1]:=rmin_x-lmax_x; + if known r_prm[lr_idx]: + r_prm[rr_idx]:= r_prm[lr_idx]; + lmax_x:=smax_x[lr_idx]; + elseif known l_prm[rl_idx]: + l_prm[ll_idx]:=l_prm[rl_idx]; + rmin_x:=smin_x[rl_idx]; + fi + min_skp[2]:=rmin_x-lmax_x; + if jct_sty[@]<3: + min_skp[jct_sty[@]]=prm_skp_scl*prm_skp[drv_sty]; + fi + fi + endfor + if prm_num[@]>0: + l_prm[@]:=prm[@][0]; + r_prm[@]:=prm[@][prm_num[@]-1]; + fi + % + % judgment alignment + % + if prm_num[@]=0: + imin_x[@]:=xpart jdg[@].l-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + imax_x[@]:=xpart jdg[@].r+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + else: + save l_xref, r_xref; + l_xref= + if boxed[prm[@][0]]: + smin_x[prm[@][0]] + else: + xpart jdg[prm[@][0]].l + fi; + r_xref= + if boxed[prm[@][prm_num[@]-1]]: + smax_x[prm[@][prm_num[@]-1]] + else: + xpart jdg[prm[@][prm_num[@]-1]].r + fi; + if alg_sty[@]="l": + xpart jdg[@].l=l_xref; + elseif alg_sty[@]="c": + xpart jdg[@].c=(l_xref+r_xref)/2; + elseif alg_sty[@]="r": + xpart jdg[@].r=r_xref; + fi + imin_x[@]:=min(xpart jdg[@].l, l_xref) + -jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + imax_x[@]:=max(xpart jdg[@].r, r_xref) + +jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + fi + % + % inference line + % + save iln_wd, iln_pct; + numeric iln_wd; + picture iln_pct; + iln_wd:=imax_x[@]-imin_x[@]; + iln_pct:=((0, 0)--(iln_wd, 0)) drv_styled iln_sty[@]; + setbounds iln_pct to + (0, ypart llcorner iln_pct) + --(0, ypart ulcorner iln_pct) + --(iln_wd, ypart ulcorner iln_pct) + --(iln_wd, ypart llcorner iln_pct) + --cycle; % ! `linecap:=butt' and `linecap:=squared' -> same bounding box ! + box_init iln[@] (iln_pct); + xpart iln[@].c=(imin_x[@]+imax_x[@])/2; + % + % orientation, smin_y & smax_y + % + if drv_bot_roots: + ypart iln[@].c=ypart jdg[@].c-den_dp; + smin_y[@]:=ypart jdg[@].c+jdg[@].dp; + smax_y[@]:= + if iln_sty[@]=0: + ypart jdg[@].c+jdg[@].hg + else: + ypart iln[@].c+iln[@].hg + fi; + if prm_num[@]>0: + ypart iln[@].c=ypart jdg[prm[@][0]].c-num_hg; + for prm_rnk=0 upto prm_num[@]-1: + smax_y[@]:=max(smax_y[@], smax_y[prm[@][prm_rnk]]); + endfor; + fi + else: + ypart iln[@].c=ypart jdg[@].c-num_hg; + smin_y[@]:= + if iln_sty[@]=0: + ypart jdg[@].c+jdg[@].dp + else: + ypart iln[@].c+iln[@].dp + fi; + smax_y[@]:=ypart jdg[@].c+jdg[@].hg; + if prm_num[@]>0: + ypart iln[@].c=ypart jdg[prm[@][0]].c-den_dp; + for prm_rnk=0 upto prm_num[@]-1: + smin_y[@]:=min(smin_y[@], smin_y[prm[@][prm_rnk]]); + endfor; + fi + fi + % + % inference labels + % + if known l_ilb[@]: + l_ilb[@].r=iln[@].l shifted (-ilb_skp_scl*ilb_skp[drv_sty], 0); + imin_x[@]:=xpart l_ilb[@].l; + smin_y[@]:=min(smin_y[@], ypart l_ilb[@].c+l_ilb[@].dp); + smax_y[@]:=max(smax_y[@], ypart l_ilb[@].c+l_ilb[@].hg); + fi + if known r_ilb[@]: + r_ilb[@].l=iln[@].r shifted (ilb_skp_scl*ilb_skp[drv_sty], 0); + imax_x[@]:=xpart r_ilb[@].r; + smin_y[@]:=min(smin_y[@], ypart r_ilb[@].c+r_ilb[@].dp); + smax_y[@]:=max(smax_y[@], ypart r_ilb[@].c+r_ilb[@].hg); + fi + % + % phantom steps + % + if known tgt[@]: + save phm_pth, phm_pct; + path phm_pth; + picture phm_pct; + save top_y, mid_y, bot_y; + numeric top_y, bot_y; + if drv_bot_roots: + bot_y:=xpart minmax_y[@]+min_clr_scl*min_clr[drv_sty]/2; + top_y:=xpart minmax_y[tgt[@]]; + else: + bot_y:=ypart minmax_y[tgt[@]]; + top_y:=ypart minmax_y[@]-min_clr_scl*min_clr[drv_sty]/2; + fi + mid_y:=(top_y+bot_y)/2; + phm_pth:=(0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2); + phm_pct:=phm_pth drv_styled phm_sty[@]; + box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); + phm[@].c=(xpart jdg[@].c, mid_y); + imin_x[@]:=min(imin_x[@], xpart phm[@].l); + imax_x[@]:=max(imax_x[@], xpart phm[@].r); + % + % phantom steps labels + % + if known l_plb[@]: + l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); + imin_x[@]:=min(imin_x[@], xpart l_plb[@].l); + fi + if known r_plb[@]: + r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); + imax_x[@]:=max(imax_x[@], xpart r_plb[@].r); + fi + fi + % + % smin_x & smax_x + % + smin_x[@]:=imin_x[@]; + smax_x[@]:=imax_x[@]; + for prm_rnk=0 upto prm_num[@]-1: + smin_x[@]:=min(smin_x[@], smin_x[prm[@][prm_rnk]]); + smax_x[@]:=max(smax_x[@], smax_x[prm[@][prm_rnk]]); + endfor + % + % delimiters + % + if known l_dlb[@] or known r_dlb[@]: + save idx, mmy, min_y, max_y; + numeric idx, min_y, max_y; + pair mmy; + mmy:=minmax_y[@]; + min_y:=xpart mmy; + max_y:=ypart mmy; + if known l_dlb[@]: + box_init l_dlm[@] (delim l (max_y-min_y)); + l_dlm[@].r=(smin_x[@], (max_y+min_y)/2); + l_dlb[@].r=l_dlm[@].l; + smin_x[@]:=xpart l_dlb[@].l; + fi + if known r_dlb[@]: + box_init r_dlm[@] (delim r (max_y-min_y)); + r_dlm[@].l=(smax_x[@], (max_y+min_y)/2); + r_dlb[@].l=r_dlm[@].r; + smax_x[@]:=xpart r_dlb[@].r; + fi + fi + if (known l_dlb[@]) or boxed[@]: + idx:=@; + forever: + imin_x[idx]:=smin_x[@]; + exitif unknown l_prm[idx]; + idx:=l_prm[idx]; + endfor + fi + if (known r_dlb[@]) or boxed[@]: + idx:=@; + forever: + imax_x[idx]:=smax_x[@]; + exitif unknown r_prm[idx]; + idx:=r_prm[idx]; + endfor + fi +enddef; + +vardef drv_build= + if not drv_checked: + drv_check; + fi + for idx=0 upto root_num-1: + drv_build_root[root[idx]]; + endfor + drv_built:=true; +enddef; + +% +% Freezing +% + +vardef drv_freeze_root[]= + for prm_rnk=0 upto prm_num[@]-1: + drv_freeze_root[prm[@][prm_rnk]]; + endfor + for sbj_rnk=0 upto sbj_num[@]-1: + box_freeze sbj[@][sbj_rnk]; + endfor + forsuffixes sfx= + iln, jdg, phm, + l_dlb, l_dlm, l_ilb, l_plb, + r_dlb, r_dlm, r_ilb, r_plb: + if known sfx[@]: + box_freeze sfx[@]; + fi + endfor +enddef; + +vardef drv_freeze= + if not drv_built: + drv_build; + fi + save root_idx; + numeric root_idx; + root_idx:=root[0]; + if unknown iln[root_idx].c: + % + % default math axis + % + if drv_axis_ref="iln": + iln[root_idx].c=(0, axis_hg[drv_sty]); + else: % drv_axis_ref="jdg" + jdg[root_idx].c=(0, axis_hg[drv_sty]); + fi + drv_freeze_root[root_idx]; + fi + for idx=1 upto root_num-1: + root_idx:=root[idx]; + if unknown iln[root_idx].c: + smin_x[root_idx]=smax_x[root[idx-1]]+prm_skp_scl*prm_skp[drv_sty]; + ypart iln[root_idx].c=ypart iln[root[idx-1]].c; + fi + drv_freeze_root[root_idx]; + endfor + drv_frozen:=true; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Derivation tree pictures +% + +% +% 1. Global parameters +% + +boolean drv_proofmode_on; % +color prf_clr; % +color jdg_clr; % +color sbj_clr; % + +prf_clr:=.75background; % arbitrary +jdg_clr:=red; % arbitrary +sbj_clr:=blue; % arbitrary + +% +% 2. Macros +% + +vardef drv_tree_addto @# (expr idx) text draw_options= + for prm_rnk=0 upto prm_num[idx]-1: + drv_tree_addto @# (prm[idx][prm_rnk]) draw_options; + endfor + forsuffixes sfx= + jdg, phm, + l_dlb, l_dlm, l_ilb, l_plb, + r_dlb, r_dlm, r_ilb, r_plb: + if known sfx[idx]: + addto @# also sfx[idx] draw_options; + fi + endfor + if iln_sty[idx]>0: + addto @# also iln[idx] draw_options; + fi +enddef; + +vardef tt_nat[] expr nat= % typewriter typeface naturals + save nat_aux, nat_pct_wd, dgt_num, nat_pct; + numeric nat_aux, nat_pct_wd, dgt_num; + picture nat_pct; + nat_aux:=abs nat; + nat_pct:=nullpicture; + nat_pct_wd:=0; + dgt_num:=1; + forever: + exitif nat_aux div (10**dgt_num)=0; + dgt_num:=dgt_num+1; + endfor + for rnk:=1 upto dgt_num: + addto nat_pct also tt_dgt[@][nat_aux div (10**(dgt_num-rnk))] + shifted (nat_pct_wd, 0); + nat_pct_wd:=width nat_pct; + nat_aux:=nat_aux mod (10**(dgt_num-rnk)); + endfor + nat_pct shifted (0, -axis_hg[@]) +enddef; + +vardef prf_tree_addto @# expr idx= + for prm_rnk=0 upto prm_num[idx]-1: + prf_tree_addto @# (prm[idx][prm_rnk]); + endfor + if idx>=0: + box_init jdg_prf[idx] (tt_nat[2] idx); + jdg_prf[idx].r=jdg[idx].l; + box_freeze jdg_prf[idx]; + addto @# also jdg_prf[idx] withcolor jdg_clr; + addto @# doublepath jdg[idx].c withcolor jdg_clr + withpen pencircle scaled (2*pdt_hg[drv_sty]); + fi + for sbj_rnk=0 upto sbj_num[idx]-1: + box_init sbj_prf[idx][sbj_rnk] (tt_nat[3] sbj_rnk); + if odd sbj_rnk: + sbj_prf[idx][sbj_rnk].c shifted (0, sbj_prf[idx][sbj_rnk].hg)= + sbj[idx][sbj_rnk].c + shifted (0, -den_dp-min_clr_scl*min_clr[drv_sty]/2); + else: + sbj_prf[idx][sbj_rnk].c shifted (0, sbj_prf[idx][sbj_rnk].dp)= + sbj[idx][sbj_rnk].c + shifted (0, -num_hg+min_clr_scl*min_clr[drv_sty]/2); + fi + box_freeze sbj_prf[idx][sbj_rnk]; + addto @# also sbj_prf[idx][sbj_rnk] withcolor sbj_clr; + addto @# doublepath sbj[idx][sbj_rnk].c withcolor sbj_clr + withpen pencircle scaled pdt_hg[drv_sty]; + endfor +enddef; + +vardef drv_tree= + save pct; + picture pct; + pct:=nullpicture; + if not drv_frozen: + drv_freeze; + fi + for root_idx=0 upto root_num-1: + if drv_proofmode_on: + drv_tree_addto pct (root[root_idx]) withcolor prf_clr; + prf_tree_addto pct (root[root_idx]); + else: + drv_tree_addto pct (root[root_idx]); + fi + endfor + pct +enddef; + +vardef drv_bbox[]= + save min_x, max_x, mmy, min_y, max_y; + pair mmy; + numeric min_x, max_x, max_y, min_y; + if not drv_frozen: + drv_freeze; + fi + min_x:= + if known l_dlm[@].r: + xpart l_dlm[@].r + else: + smin_x[@] + fi-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + max_x:= + if known r_dlm[@].l: + xpart l_dlm[@].l + else: + smax_x[@] + fi+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + mmy:=minmax_y[@]; + min_y:=xpart mmy; + max_y:=ypart mmy; + (min_x, min_y)-- + (min_x, max_y)-- + (max_x, max_y)-- + (max_x, min_y)-- + cycle +enddef; + +vardef mth_axis @# (suffix ref_sfx) (expr idx)= + if not drv_frozen: + drv_freeze; + fi + if unknown prm_num[idx]: + drv_errhelp "An index must be used to declare an inference before it is"& + " used to set the math axis of a picture."; + drv_errmessage "no inference has been declared using index "&(decimal idx); + else: + save ref_str, yref; + string ref_str; + numeric yref; + ref_str:=str ref_sfx; + if ref_str="iln": + yref:=ypart iln[idx].c; + elseif ref_str="jdg": + yref:=ypart jdg[idx].c; + elseif ref_str="dlm": + if known l_dlm[idx]: + yref:=ypart l_dlm[idx].c; + elseif known r_dlm[idx]: + yref:=ypart r_dlm[idx].c; + else: + drv_errhelp "Well ..."; + drv_errmessage "no delimiter is attached to inference "&(decimal idx); + fi + else: + drv_errhelp "Valid identifiers are"& + " iln (inference line axis),"& + " jdg (judgment math-axis) and"& + " dlm (delimiter axis)."; + drv_errmessage (ref_str&" is not a valid reference type identifier"); + fi + if known yref: + @#:=@# shifted (0, axis_hg[drv_sty]-yref); + fi + fi +enddef; + +vardef drv_axis (suffix ref) (expr idx)= + mth_axis currentpicture (ref, idx); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Tunings +% + +vardef check_math_style (expr sty_str, default)= + if sty_str="\displaystyle": + 0 + elseif sty_str="\textstyle": + 1 + elseif sty_str="\scriptstyle": + 2 + elseif sty_str="\scriptscriptstyle": + 3 + else: + begingroup + drv_errhelp "Valid commands are"& + " \displaystyle,"& + " \textstyle,"& + " \scriptstyle and"& + " \scriptscriptstyle."; + drv_errmessage (sty_str&" is not a valid math-style command"); + default + endgroup + fi +enddef; + +vardef check_position_left (suffix pos_sfx) (expr default)= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if (pos_str="l"): + true + elseif (pos_str="r"): + false + else: + begingroup + drv_errhelp "Valid identifiers are l (left) and r (right)."; + drv_errmessage (pos_str&" is not a valid label position identifier"); + default + endgroup + fi +enddef; + +vardef check_mode_on (suffix status_sfx) (expr default)= + save status_str; + string status_str; + status_str:=str status_sfx; + if status_str="on": + true + elseif status_str="off": + false + else: + begingroup + drv_errhelp "Possible identifiers are on and off"; + drv_errmessage (status_str&" is not a valid status identifier"); + default + endgroup + fi +enddef; + +vardef drv_math_style (suffix typ_sfx) (expr sty_str)= + save typ_str, sty_idx; + string typ_str; + numeric sty_idx; + typ_str:=str typ_sfx; + if (typ_str<>"drv") + and (typ_str<>"jdg") + and (typ_str<>"ilb") + and (typ_str<>"dlb") + and (typ_str<>"plb"): + drv_errhelp "Valid identifiers are"& + " drv (derivation tree),"& + " jdg (judgment),"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (sty_str&" is not a valid component identifier"); + else: + sty_idx:=check_math_style (sty_str, 0); + if typ_str="drv": + drv_sty:=sty_idx; + else: + forsuffixes sfx=scantokens (typ_str&"_sty"): + for idx=0 upto 3: + sfx[idx]:=min(idx+sty_idx, 3); + endfor + endfor + fi + fi +enddef; + +vardef drv_scale (suffix scl_sfx) (expr scl)= + save scl_str; + string scl_str; + scl_str:=str scl_sfx; + if scl_str="clr": + min_clr_scl:=scl; + elseif scl_str="prm": + prm_skp_scl:=scl; + elseif (scl_str="jdg") or (scl_str="jgm"): % "jgm" is deprecated + jdg_skp_scl:=scl; + elseif (scl_str="ilb") or (scl_str="lbl"): % "lbl" is deprecated + ilb_skp_scl:=scl; + else: + drv_errhelp "Valid identifiers are"& + " clr,"& + " prm,"& + " jdg and"& + " ilb."; + drv_errmessage (scl_str&" is not a valid scale identifier"); + fi +enddef; + +vardef drv_junction_style suffix sty_sfx= + drv_jct_sty:=check_junction_style (sty_sfx, drv_jct_sty); +enddef; + +vardef drv_alignment_style suffix sty_sfx= + drv_alg_sty:=check_alignment_style (sty_sfx, drv_alg_sty); +enddef; + +vardef drv_path_style (suffix typ_sfx, sty_sfx)= + save typ_str; + string typ_str; + typ_str:=str typ_sfx; + if typ_str="iln": + drv_iln_sty:=check_path_style (sty_sfx, drv_iln_sty); + elseif typ_str="phm": + drv_phm_sty:=check_path_style (sty_sfx, drv_phm_sty); + else: + drv_errhelp "Valid identifiers are"& + " iln (inference line) and"& + " phm (phantom steps path)."; + drv_errmessage (typ_str&" is not a valid path-type identifier"); + fi +enddef; + +vardef drv_labels_position_aux (suffix typ_sfx, pos_sfx)= + save typ_str, idt_str, pos_str; + string typ_str, idt_str, pos_str; + typ_str:=str typ_sfx; + if typ_str="ilb": + drv_left_ilb:=check_position_left (pos_sfx, drv_left_ilb); + elseif typ_str="dlb": + drv_left_dlb:=check_position_left (pos_sfx, drv_left_dlb); + elseif typ_str="plb": + drv_left_plb:=check_position_left (pos_sfx, drv_left_plb); + else: + drv_errhelp "Valid identifiers are"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (typ_str&" is not a valid label-type identifier"); + fi +enddef; + +vardef drv_labels_position text ARG= + drv_labels_position_aux if pair ARG: ARG else: (ilb, ARG) fi; +enddef; + +vardef drv_roots_position suffix pos_sfx= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if pos_str="t": + drv_bot_roots:=false; + elseif pos_str="b": + drv_bot_roots:=true; + else: + drv_errhelp "Valid identifiers are"& + " t (top) and"& + " b (bottom)."; + drv_errmessage (pos_str&" is not a valid root position identifier"); + fi +enddef; + +vardef drv_axis_reference suffix ref_sfx= + save ref_str; + string ref_str; + ref_str:=str ref_sfx; + if (ref_str<>"iln") and (ref_str<>"jdg"): + drv_errhelp "Valid identifiers are iln (inference line axis) and"& + " jdg (judgment math-axis)."; + drv_errmessage (ref_str&" is not a valid reference identifier"); + else: + drv_axis_ref:=ref_str; + fi +enddef; + +vardef drv_delimiter (suffix pos_sfx) (expr dlm_str)= + if check_position_left (pos_sfx, true): + drv_l_dlm:=dlm_str; + else: + drv_r_dlm:=dlm_str; + fi +enddef; + +vardef drv_left_delimiter expr dlm_str= + drv_delimiter (l, dlm_str); +enddef; + +vardef drv_right_delimiter expr dlm_str= + drv_delimiter (r, dlm_str); +enddef; + +vardef drv_box_mode suffix status_sfx= + drv_boxmode_on:=check_mode_on (status_sfx, drv_boxmode_on); +enddef; + +vardef drv_fraction_mode suffix status_sfx= + drv_fractionmode_on:=check_mode_on (status_sfx, drv_fractionmode_on); +enddef; + +vardef drv_proof_mode suffix status_sfx= + drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Default settings +% + +drv_font_size "\normalsize"; +drv_math_style (drv, "\displaystyle"); +drv_math_style (jdg, "\textstyle"); +drv_math_style (ilb, "\scriptstyle"); +drv_math_style (dlb, "\textstyle"); +drv_math_style (plb, "\textstyle"); +drv_scale (clr, 1); +drv_scale (prm, 1); +drv_scale (jdg, 1); +drv_scale (ilb, 1); +drv_junction_style 1; +drv_alignment_style c; +drv_path_style (iln, 1); +drv_path_style (phm, 3); +drv_labels_position (ilb, r); +drv_labels_position (dlb, l); +drv_labels_position (plb, l); +drv_roots_position b; +drv_axis_reference iln; +drv_left_delimiter "\lbrace"; +drv_right_delimiter "\rbrace"; +drv_box_mode off; +drv_fraction_mode on; +drv_proof_mode off; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% LaTeX inclusion macro +% +% \drv includes a picture file in such a way that the baseline of the included +% picture coincides with the baseline of the inclusion point. The code for \drv +% was suggested by Josselin Noirel on the fr.comp.text.tex usenet group. +% +% \usepackage{graphicx} +% \makeatletter +% \def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}} +% \newsavebox{\graphicsbox} +% \newcommand*{\drv}[1]{% +% \sbox{\graphicsbox}{\includegraphics{#1}}% +% \raisebox{\Gin@lly bp}% +% {\usebox{\graphicsbox}}} +% \makeatother diff --git a/Master/texmf-dist/doc/metapost/drv/sample/makefile b/Master/texmf-dist/doc/metapost/drv/sample/makefile new file mode 100644 index 00000000000..ab57ffe9ace --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/sample/makefile @@ -0,0 +1,47 @@ +MAIN= coq-sample + +$(MAIN).pdf: $(MAIN).ps + ps2pdf $(MAIN).ps + +$(MAIN).ps: $(MAIN).tex $(MAIN)-delayed.mp + latex $(MAIN) + dvips -t unknown $(MAIN) -o + +$(MAIN)-proof.pdf: $(MAIN)-proof.ps + ps2pdf $(MAIN)-proof.ps + +$(MAIN)-proof.ps: $(MAIN)-delayed.mp + latex $(MAIN)-proof + dvips -t unknown $(MAIN)-proof -o + +$(MAIN)-delayed.mp: $(MAIN).mp + $(RM) $(MAIN)-delayed.mp + mpost $(MAIN) + mpost $(MAIN) + +.SILENT clean: + $(RM) drv.mpx + $(RM) $(MAIN).[0-9]* + $(RM) $(MAIN).aux + $(RM) $(MAIN).dvi + $(RM) $(MAIN).log + $(RM) $(MAIN).nav + $(RM) $(MAIN).out + $(RM) $(MAIN).snm + $(RM) $(MAIN).toc + $(RM) $(MAIN)-delayed.mp + $(RM) $(MAIN)-delayed.mpx + $(RM) $(MAIN)-proof.aux + $(RM) $(MAIN)-proof.dvi + $(RM) $(MAIN)-proof.log + $(RM) $(MAIN)-proof.nav + $(RM) $(MAIN)-proof.out + $(RM) $(MAIN)-proof.snm + $(RM) $(MAIN)-proof.tex + $(RM) $(MAIN)-proof.toc + +cleanall: clean + $(RM) $(MAIN).pdf + $(RM) $(MAIN).ps + $(RM) $(MAIN)-proof.pdf + $(RM) $(MAIN)-proof.ps diff --git a/Master/texmf-dist/doc/metapost/drv/sample/readme.txt b/Master/texmf-dist/doc/metapost/drv/sample/readme.txt new file mode 100644 index 00000000000..b0c3c91b5e5 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/sample/readme.txt @@ -0,0 +1,14 @@ +# In order to compile the sources and to get a pdf file, use `make' or: + +# 1. run metapost TWICE: +mpost coq-sample.mp +mpost coq-sample.mp + +# 2. run latex (once): +latex coq-sample.tex + +# 3. run dvips (once): +dvips coq-sample.dvi -o + +# 4. run ps2pdf (once): +ps2pdf coq-sample.ps diff --git a/Master/texmf-dist/doc/metapost/drv/template/drv.mp b/Master/texmf-dist/doc/metapost/drv/template/drv.mp new file mode 100644 index 00000000000..5eb38396144 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/template/drv.mp @@ -0,0 +1,2245 @@ +%% drv.mp 0.93 +%% Copyright 2009 Laurent M\'ehats +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Laurent M\'ehats. +% <laurent.mehats@gmail.com> +% +% This work consists of the file drv.mp + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% User's macros summary +% +% +% * Judgment & inference declarations +% =================================== +% +% jgm <nat> <str list> +% <nat> judgment index +% <str list> sub-judgments math-mode LaTeX code +% +% nfr <nat> (<nat list>) (<str>, <id>) +% <nat> inference index +% <nat list> list of premise indices +% <str> inference label math-mode LaTeX code +% <id> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% 0 none +% 1 simple +% 2 double +% 3 dotted +% 4 dashed +% 5 waved +% 6 TeX-dotted +% _ default (set by drv_path_style) +% +% mvd <nat 1> (<nat 2>, <id>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <id> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% Nfr <nat> (<nat list>) (<str 1>, <str 2>, <str 3>, <id>) +% <nat> inference index +% <nat list> list of premise indices +% <str 1> inference label math-mode LaTeX code +% <str 2> left delimiter label math-mode LaTeX code +% <str 3> right delimiter label math-mode LaTeX code +% <id> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% Mvd <nat 1> (<nat 2>, <str 1>, <str 2>, <id>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str 1> left label math-mode LaTeX code +% <str 2> right label math-mode LaTeX code +% <id> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% NFR <nat> (<nat list>) (<str 1>, <str 2>, <str 3>, <str 4>) +% (<id 1>, <id 2>, <id 3>) +% <nat> inference index +% <nat list> list of premise indices +% <str 1> left inference label math-mode LaTeX code +% <str 2> right inference label math-mode LaTeX code +% <str 3> left delimiter label math-mode LaTeX code +% <str 4> right delimiter label math-mode LaTeX code +% <id 1> junction style identifier (0, 1, 2, 3 or _) +% 0 fully-interlacing +% 1 semi-interlacing +% 2 non-interlacing +% 3 user specified (tricky) +% _ default (set by drv_junction_style) +% <id 2> alignment style identifier (l, c, r, u or _) +% l left +% c centered +% r right +% u user specified (tricky) +% _ default (set by drv_alignment_style) +% <id 3> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% MVD <nat 1> (<nat 2>, <str 1>, <str 2>, <id 1> <id 2>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str 1> left label math-mode LaTeX code +% <str 2> right label math-mode LaTeX code +% <id 1> alignment style identifier (l, c, r, u or _) +% <id 2> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% NFR_opt <nat> (<nat list>) (<str list 1>) (<str list 2>) +% (<id 1>, <id 2>, <id 3>) +% <nat> inference index +% <nat list> list of premise indices +% <str list 1> list of inference labels math-mode LaTeX code +% <str list 2> list of delimiter labels math-mode LaTeX code +% <id 1> junction style identifier (0, 1, 2, 3 or _) +% <id 2> alignment style identifier (l, c, r, u or _) +% <id 3> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% MVD_opt <nat 1> (<nat 2>) (<str list>) (<id 1> <id 2>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str list> list of labels math-mode LaTeX code +% <id 1> alignment style identifier (l, c, r or u) +% <id 2> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% * Tunings +% ========= +% +% drv_font_size <str> +% <str> LaTeX font-size command +% "\tiny" +% "\scriptsize" +% "\footnotesize" +% "\small" +% "\normalsize" +% "\large" +% "\Large" +% etc. +% +% drv_math_style (<id>, <str>) +% <id> component identifier (drv, jdg, ilb, dlb or plb) +% drv derivation trees +% jdg judgments +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <str> LaTeX math-style command +% +% drv_scale (<id>, <float>) +% <id> scale identifier (clr, prm, jdg or ilb) +% clr nice explanation soon (see examples) +% prm nice explanation soon (see examples) +% jdg nice explanation soon (see examples) +% ilb nice explanation soon (see examples) +% <float> scale value +% +% drv_junction_style <id> +% <id> junction style identifier (0, 1 or 2) +% 0 ``fully-interlacing'' +% 1 ``semi-interlacing'' +% 2 ``non-interlacing'' +% +% drv_alignment_style <id> +% <id> alignment style identifier (l, c or r) +% l left +% c centered +% r right +% +% drv_path_style (<id 1>, <id 2>) +% <id 1> path-type identifier (iln or phm) +% iln inference lines +% phm phantom steps paths +% <id 2> path-style identifier (0, 1, 2, 3, 4, 5 or 6) +% +% drv_labels_position (<id 1>, <id 2>) +% <id 1> label-type identifier (ilb, plb or dlb) +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <id 2> position identifier (l or r) +% l left +% r right +% +% drv_roots_position <id> +% <id> position identifier (t or b) +% t top +% b bottom +% +% drv_axis_reference <id> +% <id> reference identifier (iln or jdg) +% iln root inference line axis +% jdg root judgment math-axis +% +% drv_left_delimiter <str> +% <str> left delimiter math-mode LaTeX code +% "(" $($ +% "[" $[$ +% "\lbrace" $\lbrace$ +% "\langle" $\langle$ +% etc. +% +% drv_right_delimiter <str> +% <str> right delimiter math-mode LaTeX code +% ")" +% "]" +% "\rbrace" +% "\rangle" +% etc. +% +% drv_box_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_fraction_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_proof_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% * Derivation tree pictures +% ========================== +% +% drv_bbox <nat> +% <nat> sub-tree root index +% +% drv_axis (<id>, <nat>) +% <id> reference type identifier (iln, jdg or dlm) +% iln inference line axis +% jdg judgment math-axis +% dlm delimiter axis +% <nat> reference index +% +% <path> drv_styled <id> +% <path> MetaPost path expression +% <id> path style identifier (0, 1, 2, 3, 4, 5 or 6) +% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MetaPost messages formatting +% + +% drv_format prevents messages from being automatically cut into lines every +% 79 characters: if possible, a word which would otherwise be cut is 'pushed' +% to the following line by inserting space characters before it. + +vardef drv_format (expr str, fst_len, nxt_len, dbl_pcs)= + % str: the message to be formatted + % fst_len: first line length + % nxt_len: following lines length + % dbl_pcs (boolean): occurrences of the percent character must be doubled + save str_len, sub_len, aux_len, chr_rnk, occ_num; + numeric str_len, sub_len, aux_len, chr_rnk, occ_num; + save aux_str, chr; + string aux_str, chr; + str_len:=length str; + sub_len:=0; + chr_rnk:=0; + occ_num:=0; + aux_len:=0; + aux_str:=""; + forever: + exitif (chr_rnk=fst_len) or (chr_rnk=str_len); + chr:=substring (chr_rnk, chr_rnk+1) of str; + aux_str:=aux_str&chr; + if chr=" ": + sub_len:=chr_rnk+1; + aux_len:=sub_len+occ_num; + elseif (chr="%") and dbl_pcs: + aux_str:=aux_str&"%"; + occ_num:=occ_num+1; + fi + chr_rnk:=chr_rnk+1; + endfor + if chr_rnk=fst_len: + begingroup + if sub_len=0: + sub_len:=fst_len; + aux_len:=sub_len+occ_num; + fi + substring (0, aux_len) of aux_str& + for idx=sub_len+1 upto fst_len: + " "& + endfor + drv_format (substring (sub_len, str_len) of str, + nxt_len, nxt_len, dbl_pcs) + endgroup + else: + aux_str + fi +enddef; + +boolean drv_inside_fig; +drv_inside_fig:=false; + +vardef drv_context= + "drv"&if drv_inside_fig: " (fig. "&decimal charcode&")"&fi ": " +enddef; + +vardef drv_message expr str= + message drv_format (drv_context&str, 79, 79, false); +enddef; + +vardef drv_errhelp expr str= + % Occurrences of the percent character must be doubled: errhelp makes single + % single occurrences behave as newline characters (this is inherited from + % MetaFont). + errhelp drv_format (str, 79, 79, true); +enddef; + +vardef drv_errmessage expr str= + % errmessage inserts the 2-characters string "! " before its argument. + % Hence 77 as a first line length argument. + errmessage drv_format (drv_context&str, 77, 79, false); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Delayed LaTeX processing +% + +picture tex_pct[]; +string delayed_tex_file; +delayed_tex_file:=jobname&"-delayed.mp"; + +% +% reading LaTeX picture definitions +% + +boolean drv_nullpicture; +drv_nullpicture:=true; + +string readfrom_str; +readfrom_str:=readfrom delayed_tex_file; +if readfrom_str<>EOF: + closefrom delayed_tex_file; + drv_message ("reading `"&delayed_tex_file&"' LateX picture definitions."); + batchmode; + scantokens ("input "&delayed_tex_file); + errorstopmode; + drv_message "done."; + drv_nullpicture:=false; +fi + +% +% copying LaTeX preamble +% + +vardef drv_read (expr search_str) (suffix accum_str)= + save readfrom_str, readfrom_substr; + string readfrom_str, readfrom_substr; + accum_str:=""; + forever: + readfrom_str:=readfrom jobname; + readfrom_substr:=substring (0, length search_str) of readfrom_str; + exitif (readfrom_substr=search_str) or (readfrom_str=EOF); + accum_str:=accum_str&readfrom_str&char(10); + endfor + if readfrom_str=EOF: + closefrom jobname; + drv_errhelp ("`"&jobname&".mp' should contain a line starting with "& + ditto&search_str&ditto&"."); + drv_errmessage (ditto&search_str&ditto&" is missing"); + fi +enddef; + +string tex_preamble_str[]; +% tex_preamble_str[0] from "verbatimtex %&latex" to "\begin{document}" +% tex_preamble_str[1] from "\begin{document}" to "etex;" + +drv_message ("reading `"&jobname&".mp' LateX preamble."); + drv_read ("verbatimtex %&latex", tex_preamble_str[0]); + drv_read ("\begin{document}", tex_preamble_str[0]); + drv_read ("etex;", tex_preamble_str[1]); + closefrom jobname; + write + "%"&char(10)& + "% AUTOMATICALLY GENERATED BY DRV.MP - DO NOT MODIFY."&char(10)& + "%"&char(10)&char(10)& + "verbatimtex %&latex"&char(10)& + tex_preamble_str[0]& + "\begin{document}"&char(10)& + tex_preamble_str[1]& + "etex;" + to delayed_tex_file; +drv_message "done."; + +% +% writing LaTeX picture definitions +% + +numeric tex_pct_idx; +tex_pct_idx:=0; + +% Math style indices: 0, 1, 2, 3 +string mth_sty_str[]; +mth_sty_str[0]:="\displaystyle"; +mth_sty_str[1]:="\textstyle"; +mth_sty_str[2]:="\scriptstyle"; +mth_sty_str[3]:="\scriptscriptstyle"; + +string drv_fontsize; + +vardef drv_tex[] expr tex_str= + % @: math style index + % tex_str: math mode LaTeX code + save def_str, pct; + string def_str; + picture pct; + def_str:="btex{"&drv_fontsize&"$"&mth_sty_str[@]&"{}"&tex_str&"{}$}etex;"; + write "tex_pct["&(decimal tex_pct_idx)&"]:="&def_str to delayed_tex_file; + pct:= + if known tex_pct[tex_pct_idx]: + tex_pct[tex_pct_idx] + else: + nullpicture + fi; + tex_pct_idx:=tex_pct_idx+1; + pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MetaPost shorthands +% + +vardef depth expr pct= + ypart llcorner pct +enddef; + +vardef height expr pct= + ypart urcorner pct +enddef; + +vardef width expr pct= + xpart urcorner pct-xpart llcorner pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Font-specific parameters +% + +% +% em[s] width of an m (s: mathstyle index) +% ex[s] height of an x +% axis_hg[s] height of the mathematical axis +% num_bl_hg[s] height of a numerator baseline w.r.t. the fraction bar axis +% den_bl_dp[s] depth of a denominator baseline w.r.t. the fraction bar axis +% rul_thk[s] default rule thickness +% + +numeric em[], ex[], axis_hg[], num_bl_hg[], den_bl_dp[], rul_thk[]; + +% +% thn_sp[s] thin space, usually 1em/6 +% med_sp[s] medium space, usually 2em/9 +% thk_sp[s] thick space, usually 5em/18 +% + +numeric thn_sp[], med_sp[], thk_sp[]; + +% +% pdt_hg[s] height of a punctuation ldot +% pdt_wd[s] width of a punctuation ldot +% + +numeric pdt_hg[], pdt_wd[]; + +% +% tt_dgt[s][i] typewriter typeface digits (i ranges from 0 to 9) +% + +picture tt_dgt[][]; + +% +% min_clr[s] minimal clearance between a numerator +% or a denominator and the fraction bar +% prm_skp[s] <nice explanation> +% jdg_skp[s] <nice explanation> +% ilb_skp[s] <nice explanation> +% plb_skp[s] <nice explanation> +% + +numeric min_clr[], prm_skp[], jdg_skp[], ilb_skp[], plb_skp[]; + +vardef drv_fontdimen[] expr font= + save dim_pct; + picture dim_pct; + dim_pct:=drv_tex[0] ("\rule{\the\fontdimen"&(decimal @)&font&"}{0bp}"); + width dim_pct +enddef; + +vardef drv_font_size expr size_str= + save pdt_pct, sp_pct; + picture pdt_pct, sp_pct; + drv_fontsize:=size_str; + write char(10)&"% font-specific parameters ("&drv_fontsize&")"&char(10) + to delayed_tex_file; + ex[0]:=drv_fontdimen[5] "\textfont2"; + ex[1]:=drv_fontdimen[5] "\textfont2"; + ex[2]:=drv_fontdimen[5] "\scriptfont2"; + ex[3]:=drv_fontdimen[5] "\scriptscriptfont2"; + em[0]:=drv_fontdimen[6] "\textfont2"; + em[1]:=drv_fontdimen[6] "\textfont2"; + em[2]:=drv_fontdimen[6] "\scriptfont2"; + em[3]:=drv_fontdimen[6] "\scriptscriptfont2"; + rul_thk[0]:=drv_fontdimen[8] "\textfont3"; + rul_thk[1]:=drv_fontdimen[8] "\textfont3"; + rul_thk[2]:=drv_fontdimen[8] "\scriptfont3"; + rul_thk[3]:=drv_fontdimen[8] "\scriptscriptfont3"; + axis_hg[0]:=drv_fontdimen[22] "\textfont2"; + axis_hg[1]:=drv_fontdimen[22] "\textfont2"; + axis_hg[2]:=drv_fontdimen[22] "\scriptfont2"; + axis_hg[3]:=drv_fontdimen[22] "\scriptscriptfont2"; + num_bl_hg[0]:=(drv_fontdimen[8] "\textfont2")-axis_hg[0]; + num_bl_hg[1]:=(drv_fontdimen[9] "\textfont2")-axis_hg[1]; + num_bl_hg[2]:=(drv_fontdimen[9] "\scriptfont2")-axis_hg[2]; + num_bl_hg[3]:=(drv_fontdimen[9] "\scriptscriptfont2")-axis_hg[3]; + den_bl_dp[0]:=-(drv_fontdimen[11] "\textfont2")-axis_hg[0]; + den_bl_dp[1]:=-(drv_fontdimen[12] "\textfont2")-axis_hg[1]; + den_bl_dp[2]:=-(drv_fontdimen[12] "\scriptfont2")-axis_hg[2]; + den_bl_dp[3]:=-(drv_fontdimen[12] "\scriptscriptfont2")-axis_hg[3]; + min_clr[0]:=3*rul_thk[0]; % The TEXbook, + min_clr[1]:=1*rul_thk[1]; % Appendix G, + min_clr[2]:=1*rul_thk[2]; % Rule 15d. + min_clr[3]:=1*rul_thk[3]; % + for mth_sty:=0 upto 3: + sp_pct:=drv_tex[mth_sty] "\,"; + thn_sp[mth_sty]:=width sp_pct; + sp_pct:=drv_tex[mth_sty] "\>"; + med_sp[mth_sty]:=width sp_pct; + sp_pct:=drv_tex[mth_sty] "\;"; + thk_sp[mth_sty]:=width sp_pct; + pdt_pct:=drv_tex[mth_sty] "\ldotp"; + pdt_hg[mth_sty]:=height pdt_pct; + pdt_wd[mth_sty]:=width pdt_pct; + for dgt=0 upto 9: + tt_dgt[mth_sty][dgt]:=drv_tex[mth_sty] "\texttt{"&(decimal dgt)&"}"; + endfor + prm_skp[mth_sty]:=3*med_sp[mth_sty]; % arbitrary + jdg_skp[mth_sty]:=thn_sp[mth_sty]; % arbitrary + ilb_skp[mth_sty]:=thn_sp[mth_sty]; % arbitrary + plb_skp[mth_sty]:=thk_sp[mth_sty]; % arbitrary + endfor +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Math-related parameters & macros +% + +% +% Math styles +% drv_sty derivation trees +% jdg_sty[drv_sty] judgments +% ilb_sty[drv_sty] inference labels +% dlb_sty[drv_sty] delimiter labels +% plb_sty[drv_sty] phantom steps labels +% + +numeric drv_sty, jdg_sty[], ilb_sty[], dlb_sty[], plb_sty[]; + +% +% Math-axis centered LaTeX pictures +% + +vardef mth_tex[] expr tex_str= + (drv_tex[@] tex_str) shifted (0, -axis_hg[@]) +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% drv-boxes +% + +vardef drv_box text STR= + for str=STR: + expandafter picture scantokens str; + expandafter pair scantokens str.l; + expandafter pair scantokens str.c; + expandafter pair scantokens str.r; + expandafter numeric scantokens str.hg; + expandafter numeric scantokens str.dp; + endfor +enddef; + +vardef box_init @# (expr pct)= + @#:=pct; + @#.r-@#.l=(width pct, 0); + @#.c=(@#.l+@#.r)/2; + @#.hg:=height pct; + @#.dp:=depth pct; +enddef; + +vardef box_freeze @#= + @#:=@# shifted @#.l; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% beginfig & endfig +% + +% +% drv_beginfig: figure initialization +% + +pen drv_pen; + +vardef drv_beginfig= + % + % Judgments + % + % jdg[i] judgment drv-box + % sbj_num[i] number of sub-judgments + % sbj[i][j] sub-judgment drv-box (j ranges from 0 to sbj_num[i]-1) + % + drv_box "jdg[]"; + numeric sbj_num[]; + drv_box "sbj[][]"; + % + % Inferences + % + % prm_num[i] number of premises + % prm[i][j] premise index (j ranges from 0 to prm_num[i]-1) + % ccl[i] conclusion index + % jct_sty[i] junction style + % alg_sty[i] alignment style + % iln_sty[i] inference line style + % l_prm[i] leftmost `graphical' premise index + % r_prm[i] rightmost `graphical' premise index + % + numeric prm_num[], prm[][], ccl[]; + numeric jct_sty[]; + string alg_sty[]; + numeric iln_sty[]; + numeric l_prm[], r_prm[]; + % + % imin_x[i] inference minimal x + % l_dlb[i] left delimiter label drv-box + % l_dlm[i] left delimiter drv-box + % l_ilb[i] left label drv-box + % iln[i] inference line drv-box + % r_ilb[i] right label drv-box + % r_dlm[i] right delimiter drv-box + % r_dlb[i] right delimiter label drv-box + % imax_x[i] inference maximal x + % + numeric imin_x[]; + drv_box "l_dlb[]", "l_dlm[]", "l_ilb[]"; + drv_box "iln[]"; + drv_box "r_ilb[]", "r_dlm[]", "r_dlb[]"; + numeric imax_x[]; + % + % Sub-trees + % + % smin_x[i] sub-tree minimal x + % smax_x[i] sub-tree maximal x + % smin_y[i] sub-tree minimal y + % smax_y[i] sub-tree maximal y + % boxed[i] boolean + % + numeric smin_x[], smax_x[], smin_y[], smax_y[]; + boolean boxed[]; + % + % Pen initialization + % + drv_pen:=pencircle scaled rul_thk[drv_sty]; + % + % num_hg height of a numerator axis w.r.t. the fraction bar axis + % den_dp depth of a denominator axis w.r.t. the fraction bar axis + % iln_hg[s] height of a style s inference line + % iln_dp[s] depth of a style s inference line + % + numeric num_hg, den_dp, iln_hg[], iln_dp[]; + num_hg:=num_bl_hg[drv_sty]+axis_hg[jdg_sty[drv_sty]]; + den_dp:=den_bl_dp[drv_sty]+axis_hg[jdg_sty[drv_sty]]; + picture iln_pct; + for sty=0 upto 6: + iln_pct:=((0, 0)--(10, 0)) drv_styled sty; + iln_hg[sty]:=height iln_pct; + iln_dp[sty]:=depth iln_pct; + endfor + % + % Derivation trees + % + % root_num number of roots + % root[i] root index (i ranges from 0 to root_num-1) + % drv_built boolean + % drv_frozen boolean + % + numeric root_num, root[]; + boolean drv_checked, drv_built, drv_frozen; + root_num:=0; + drv_checked:=false; + drv_built:=false; + drv_frozen:=false; + % + % Phantom steps + % + % phm_idx phantom inferences index + % src[i] base phantom judgment index (in case of an origin judgment) + % tgt[i] origin judgment index (in case of a base phantom judgment) + % phm_sty[i] phantom steps style + % l_plb[i] left phantom steps label drv-box (in case of a base + % phantom judgment) + % phm[i] phantom steps drv-box (in case of a base phantom + % judgment) + % r_plb[i] right phantom steps label drv-box (in case of a base + % phantom judgment) + % + numeric phm_idx, src[], tgt[], phm_sty[]; + phm_idx:=0; + drv_box "l_plb[]", "phm[]", "r_plb[]"; + % + % Proof pictures + % + % jdg_prf[i] judgment index drv-box + % sbj_prf[i][j] sub-judgment index drv-box (j ranges from 0 to + % sbj_num[i]-1) + % + drv_box "jdg_prf[]", "sbj_prf[][]"; + % + % Info + % + write char(10)&"% fig. "&(decimal charcode)&char(10) to delayed_tex_file; + drv_inside_fig:=true; % context: inside a figure +enddef; + +extra_beginfig:=extra_beginfig&"drv_beginfig;"; + +% +% drv_endfig: proof-file generation +% + +string proof_file; +proof_file:=jobname&"-proof.tex"; + +% TODO: taking outputtemplate into account. +vardef output_file[]= + jobname&"."&(decimal @) +enddef; + +string buf_str; +buf_str:= + "%"&char(10)& + "% AUTOMATICALLY GENERATED BY DRV.MP."&char(10)& + "%"&char(10)&char(10)& + tex_preamble_str[0]& + "\usepackage{graphicx}"&char(10)& + "\makeatletter"&char(10)& + "\def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}}"&char(10)& + "\newsavebox{\graphicsbox}"&char(10)& + "\newcommand*{\drv}[1]{%"&char(10)& + "\sbox{\graphicsbox}{\includegraphics{#1}}%"&char(10)& + "\raisebox{\Gin@lly bp}%"&char(10)& + "{\usebox{\graphicsbox}}}"&char(10)& + "\makeatother"&char(10)&char(10)& + "\newcount\h"&char(10)& + "\newcount\m"&char(10)& + "\h=\time"&char(10)& + "\divide\h 60"&char(10)& + "\m=-\h"&char(10)& + "\multiply\m 60"&char(10)& + "\advance\m\time"&char(10)& + "\def\hm{\number\h:\ifnum\m<10{}0\fi\number\m}"&char(10)&char(10)& + "\newcommand{\mathaxis}{\frac{\quad}{}}"&char(10)&char(10)& + "\begin{document}"&char(10)& + tex_preamble_str[1]& + "\noindent\today\ at \hm\medskip"&char(10)&char(10)&"\noindent"; + +vardef drv_endfig= + drv_inside_fig:=false; % context: outside a figure + buf_str:=buf_str&char(10)& + "\texttt{"&output_file[charcode]&"}"&char(10)& + " (\verb+"&drv_fontsize&"+, \verb+"&(mth_sty_str[drv_sty])&"+)"&char(10)& + " {"&drv_fontsize&char(10)& + " \["&(mth_sty_str[drv_sty])&char(10)& + " \mathaxis\drv{"&output_file[charcode]&"}\mathaxis"&char(10)& + " \]}\\"; + write EOF to proof_file; % erases the previous content + write buf_str&char(10)&"\end{document}" to proof_file; + write EOF to proof_file; + if drv_nullpicture: + draw btex{\tt drv}: run {\tt mpost} again.etex withcolor (1, 0, 0); + fi +enddef; + +extra_endfig:="drv_endfig;"&extra_endfig; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Judgment declarations +% + +vardef jgm[] text SUB= + % @: judgment index + % SUB: list of `sub-judgments' (pictures or strings) + if @<0: + drv_errhelp "An judgment index can not be negative."; + drv_errmessage (decimal @)&" is negative"; + elseif known jdg[@]: + drv_errhelp "An index can be used only once to declare a judgment."; + drv_errmessage (decimal @)&" has been used already as a judgment index"; + else: + save jdg_pct, sbj_pct, jdg_wd, sbj_rnk; + picture jdg_pct, sbj_pct; + numeric jdg_wd, sbj_rnk; + jdg_pct:=nullpicture; + jdg_wd:=0; + sbj_rnk:=0; + for sub=SUB: + sbj_pct:= + if picture sub: + sub + elseif sub<>"": + mth_tex[jdg_sty[drv_sty]] sub + else: + nullpicture + fi; + box_init sbj[@][sbj_rnk] (sbj_pct); + if sbj_rnk>0: + sbj[@][sbj_rnk-1].r=sbj[@][sbj_rnk].l; + fi + addto jdg_pct also sbj_pct shifted (jdg_wd, 0); + jdg_wd:=width jdg_pct; + sbj_rnk:=sbj_rnk+1; + endfor + sbj_num[@]:=sbj_rnk; + box_init jdg[@] (jdg_pct); + if sbj_num[@]>0: + jdg[@].l=sbj[@][0].l; + jdg[@].r=sbj[@][sbj_num[@]-1].r; + fi + fi +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Inference declarations +% + +vardef check_junction_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="0") + or (sty_str="1") + or (sty_str="2") + or (sty_str="3"): + sty_sfx + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " 0 (fully-interlacing),"& + " 1 (semi-interlacing),"& + " 2 (non-interlacing),"& + " 3 (user specified) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid junction style identifier"; + default + endgroup + fi +enddef; + +vardef check_alignment_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="l") + or (sty_str="c") + or (sty_str="r") + or (sty_str="u"): + sty_str + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " l (none),"& + " c (simple),"& + " r (double),"& + " u (dotted) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid alignment style identifier"; + default + endgroup + fi +enddef; + +vardef check_path_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="0") + or (sty_str="1") + or (sty_str="2") + or (sty_str="3") + or (sty_str="4") + or (sty_str="5") + or (sty_str="6"): + sty_sfx + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " 0 (none),"& + " 1 (simple),"& + " 2 (double),"& + " 3 (dotted),"& + " 4 (dashed),"& + " 5 (waved),"& + " 6 (TeX-dotted) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid path style identifier"; + default + endgroup + fi +enddef; + +vardef opt_init[] @# expr arg= + if picture arg: + if arg<>nullpicture: + box_init @# (arg); + fi + elseif arg<>"": + box_init @# (mth_tex[@] arg); + fi +enddef; + +vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) + (suffix j_sty, a_sty, i_sty)= + % + % @: inference index + % + if known prm_num[@]: + drv_errhelp "An index can be used only once to declare an inference."; + drv_errmessage (decimal @)&" has been used already as an inference index"; + else: + % + % PRM: list of premise indices + % + save prm_rnk; + numeric prm_rnk; + prm_rnk:=0; + for prm_idx=PRM: + if prm_idx=@: + drv_errhelp "An inference index can not be used"& + " as one of its own premise indices."; + drv_errmessage "the inference index "&(decimal prm_idx)& + " is used as one of its own premise indices"; + elseif known ccl[prm_idx]: + drv_errhelp "An index can be used only once as a premise index."; + drv_errmessage (decimal prm_idx)&" has been used already as a"& + " premise index for inference declaration "&(decimal ccl[prm_idx]); + else: + if known prm_num[prm_idx]: + % + % roots list update + % + save root_idx; + numeric root_idx; + root_idx:=0; + forever: + exitif root[root_idx]=prm_idx; + root_idx:=root_idx+1; + endfor + forever: + exitif root_idx=root_num-1; + root[root_idx]:=root[root_idx+1]; + root_idx:=root_idx+1; + endfor + root_num:=root_num-1; + fi + ccl[prm_idx]:=@; + prm[@][prm_rnk]:=prm_idx; + prm_rnk:=prm_rnk+1; + fi + endfor + prm_num[@]:=prm_rnk; + if known ccl[@]: + % + % cycle detection + % + save ccl_idx, ccl_str; + numeric ccl_idx; + string ccl_str; + ccl_idx:=@; + ccl_str:=decimal ccl_idx; + forever: + ccl_idx:=ccl[ccl_idx]; + if ccl_idx>=0: + ccl_str:=(decimal ccl_idx)&", "&ccl_str; + fi + exitif (unknown ccl[ccl_idx]) or (ccl_idx=@); + endfor + if ccl_idx=@: + drv_errhelp "Inferences declarations can not be cyclic."; + drv_errmessage "inference declaration "&(decimal @)&" creates a"& + " cycle of inferences (indices "&ccl_str&" from conclusions to"& + " premises)"; + fi + else: + root[root_num]:=@; + root_num:=root_num+1; + fi + % + % lilb, rilb: inference labels + % + opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; + opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + % + % ldlb, rdlb: delimiter labels + % + opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; + opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + % + % j_sty, a_sty and i_sty: junction, alignment and inference styles + % + jct_sty[@]:=check_junction_style (j_sty, drv_jct_sty); + alg_sty[@]:=check_alignment_style (a_sty, drv_alg_sty); + iln_sty[@]:=check_path_style (i_sty, drv_iln_sty); + if drv_boxmode_on: + boxed[@]:=true; + fi + fi +enddef; + +vardef DCL[] (text PRM) (expr lilb, rilb, ldlb, rdlb) + (suffix j_sty, a_sty, i_sty) text SUB= + NFR[@] (PRM) (lilb, rilb, ldlb, rdlb, j_sty, a_sty, i_sty); + jgm[@] SUB; +enddef; + +vardef MVD[] (expr inf_num, lplb, rplb) (suffix a_sty, p_sty)= + if inf_num<1: + drv_errhelp "The minimal value is 1."; + drv_errmessage (decimal inf_num)&" is not a valid number of inference"& + " steps"; + else: + save aux_idx, aux_sty, phm_jdg; + numeric aux_idx, aux_sty; + picture phm_jdg; + aux_sty:=check_path_style (p_sty, drv_phm_sty); + phm_jdg:=nullpicture; + setbounds phm_jdg to (0, 0)--(iln_hg[aux_sty]-iln_dp[aux_sty], 0)--cycle; + aux_idx:=@; + for i=1 upto inf_num: + phm_idx:=phm_idx-1; + box_init jdg[phm_idx] (phm_jdg); + sbj_num[phm_idx]:=0; + NFR[phm_idx] (aux_idx) ("", "", "", "", 0, a_sty, 0); + aux_idx:=phm_idx; + endfor + src[@]:=phm_idx; + tgt[phm_idx]:=@; + phm_sty[phm_idx]:=aux_sty; + % + % lplb, rplb: phantom steps labels + % + opt_init[plb_sty[drv_sty]] l_plb[phm_idx] lplb; + opt_init[plb_sty[drv_sty]] r_plb[phm_idx] rplb; + phm_idx + fi +enddef; + +vardef bxd[]= + boxed[@]:=true; + @ +enddef; + +% +% Optional labels & shorthands +% + +numeric drv_jct_sty; % default junction style +string drv_alg_sty; % default junction style +numeric drv_iln_sty; % default inference line path-style +numeric drv_phm_sty; % default phantom steps path-style + +boolean drv_left_ilb; % inference labels on the left +boolean drv_left_dlb; % delimiter labels (hence delimiters) on the left +boolean drv_left_plb; % phantom steps labels on the left + +vardef arg_type expr arg= + if picture arg: + "picture" + else: + "string" + fi +enddef; + +vardef opt_lbls @# (text LBL) expr left_lbls= + save lbl_num, fst_lbl, snd_lbl; + numeric lbl_num; + lbl_num:=0; + for lbl=LBL: + if lbl_num=0: + scantokens (arg_type lbl) fst_lbl; + fst_lbl:=lbl; + elseif lbl_num=1: + scantokens (arg_type lbl) snd_lbl; + snd_lbl:=lbl; + else: + drv_errhelp "At most two labels can be specified:"& + " a left one and a right one."; + drv_errmessage "more than two labels have been specified"; + fi + lbl_num:=lbl_num+1; + endfor + if lbl_num=0: + string @#.l; + string @#.r; + @#.l:=""; + @#.r:=""; + elseif lbl_num=1: + if left_lbls: + scantokens (arg_type fst_lbl) @#.l; + string @#.r; + @#.l:=fst_lbl; + @#.r:=""; + else: + string @#.l; + scantokens (arg_type fst_lbl) @#.r; + @#.l:=""; + @#.r:=fst_lbl; + fi + else: + scantokens (arg_type fst_lbl) @#.l; + scantokens (arg_type snd_lbl) @#.r; + @#.l:=fst_lbl; + @#.r:=snd_lbl; + fi +enddef; + +vardef NFR_opt[] (text PRM) (text ILB) (text DLB) + (suffix j_sty, a_sty, i_sty)= + opt_lbls ilb (ILB) drv_left_ilb; + opt_lbls dlb (DLB) drv_left_dlb; + NFR[@] (PRM) (ilb.l, ilb.r, dlb.l, dlb.r, j_sty, a_sty, i_sty); +enddef; + +vardef DCL_opt[] (text PRM) (text ILB) (text DLB) + (suffix j_sty, a_sty, i_sty) text SUB= + NFR_opt[@] (PRM) (ILB) (DLB) (j_sty, a_sty, i_sty); + jgm[@] SUB; +enddef; + +vardef MVD_opt[] (expr inf_num) (text PLB) (suffix a_sty, p_sty)= + opt_lbls plb (PLB) drv_left_plb; + MVD[@] (inf_num, plb.l, plb.r, a_sty, p_sty) +enddef; + +% Nfr, Dcl & Mvd + +vardef Nfr[] (text PRM) (expr ilb, ldlb, rdlb) (suffix i_sty)= + NFR_opt[@] (PRM) (ilb) (ldlb, rdlb) (_, _, i_sty); +enddef; + +vardef Dcl[] (text PRM) (expr ilb, ldlb, rdlb) (suffix i_sty) text SUB= + Nfr[@] (PRM) (ilb, ldlb, rdlb, i_sty); + jgm[@] SUB; +enddef; + +vardef Mvd[] (expr inf_num, lplb, rplb) (suffix p_sty)= + MVD[@] (inf_num, lplb, rplb, _, p_sty) +enddef; + +% nfr, dcl & mvd + +vardef nfr[] (text PRM) (expr ilb) (suffix i_sty)= + NFR_opt[@] (PRM) (ilb) () (_, _, i_sty); +enddef; + +vardef dcl[] (text PRM) (expr ilb) (suffix i_sty) text SUB= + nfr[@] (PRM) (ilb, i_sty); + jgm[@] SUB; +enddef; + +vardef mvd[] (expr inf_num) (suffix p_sty)= + MVD_opt[@] (inf_num) () (_, p_sty) +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Pictured paths +% + +vardef dotted_aux (expr pth, dot_wd, dots_dist)= + save pth_len, pct; + numeric pth_len; + picture pct; + pth_len:=arclength pth; + pct:=nullpicture; + if dots_dist>0: + stp_num:=round ((pth_len-dot_wd)/dots_dist); + if stp_num>0: + stp_len:=(pth_len-dot_wd)/stp_num; + addto pct doublepath pth dashed dashpattern (on 0 off stp_len) + shifted (dot_wd/2, 0) withpen pencircle scaled dot_wd; + fi + fi + pct +enddef; + +primarydef pth dotted wd_dist= + dotted_aux(pth, xpart wd_dist, ypart wd_dist) +enddef; + +vardef expanded_aux (expr pth, scl, dir, stp_len)= + save pth_len, aux_len; + numeric pth_len, aux_len; + pth_len:=arclength pth; + if (stp_len>0) and (pth_len>stp_len): + aux_len:=pth_len/(pth_len div stp_len); + point arctime 0 of pth of pth shifted + (unitvector direction arctime 0 of pth of pth + rotated dir scaled scl).. + {direction arctime 0 of pth of pth} + for i=aux_len step aux_len until pth_len-aux_len: + point arctime i of pth of pth shifted + (unitvector direction arctime i of pth of pth + rotated dir scaled scl) + {direction arctime i of pth of pth}.. + endfor + point arctime pth_len of pth of pth shifted + (unitvector direction arctime pth_len of pth of pth + rotated dir scaled scl) + {direction arctime pth_len of pth of pth} + else: + pth + fi +enddef; + +primarydef pth expanded scl_dir_len= + expanded_aux (pth, + redpart scl_dir_len, greenpart scl_dir_len, bluepart scl_dir_len) +enddef; + +vardef waved_aux (expr pth, amp)= + save pth_len, mid; + numeric pth_len, mid; + pth_len:=arclength pth; + if (amp>0) and (pth_len>2(1+sqrt 5)*amp): + mid:=pth_len/(2(pth_len div (2(1+sqrt 5)*amp))); + point arctime 0 of pth of pth shifted + (unitvector direction arctime 0 of pth of pth + rotated -90 scaled amp) + {direction arctime 0 of pth of pth} + for i=mid step 2mid until pth_len: + ..point arctime i of pth of pth shifted + (unitvector direction arctime i of pth of pth + rotated 90 scaled amp) + {direction arctime i of pth of pth} + ..point arctime i+mid of pth of pth shifted + (unitvector direction arctime i+mid of pth of pth + rotated -90 scaled amp) + {direction arctime i+mid of pth of pth} + endfor + else: + pth + fi +enddef; + +primarydef pth waved amp= + waved_aux(pth, amp) +enddef; + +vardef drv_styled_aux[] expr pth= + save sty_idx, pth_len, pct; + numeric sty_idx, pth_len; + picture pct; + sty_idx:=check_path_style (@, 1); + pth_len:=arclength pth; + pct:=nullpicture; + if sty_idx=1: + interim linecap:=butt; + addto pct doublepath pth withpen drv_pen; + elseif sty_idx=2: + interim linecap:=butt; + addto pct doublepath pth + expanded (1.25rul_thk[drv_sty], 90, rul_thk[drv_sty]) + withpen drv_pen; + addto pct doublepath pth + expanded (1.25rul_thk[drv_sty], -90, rul_thk[drv_sty]) + withpen drv_pen; + elseif sty_idx=3: + addto pct also pth dotted (rul_thk[drv_sty], 2rul_thk[drv_sty]); + elseif sty_idx=4: + if rul_thk[drv_sty]>0: + interim linecap:=butt; + save dsh_num, dsh_len; + numeric dsh_num, dsh_len; + dsh_num:=round(pth_len/(3rul_thk[drv_sty])); + dsh_len:= + if odd dsh_num: + pth_len/dsh_num + else: + pth_len/(dsh_num+1) + fi; + addto pct doublepath pth dashed dashpattern(on dsh_len off dsh_len) + withpen drv_pen; + fi + elseif sty_idx=5: + interim linecap:=butt; + addto pct doublepath pth + waved 1.25rul_thk[drv_sty] withpen drv_pen; + elseif (sty_idx=6) and (pth_len>0): + addto pct also pth dotted (pdt_hg[drv_sty], pdt_wd[drv_sty]); + fi + pct +enddef; + +primarydef pth drv_styled sty= + drv_styled_aux[sty] pth +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Delimiters +% + +% +% 1. Global parameters +% + +string drv_l_dlm; % left delimiter LaTeX code +string drv_r_dlm; % right delimiter LaTeX code + +% +% 2. Macros +% + +vardef minmax_y[]=( + if drv_bot_roots: + if known ccl[@]: + ypart jdg[@].c-num_hg+iln_hg[(iln_sty[ccl[@]])] + +min_clr_scl*min_clr[drv_sty]/2 + else: + smin_y[@]-min_clr_scl*min_clr[drv_sty] + fi, + smax_y[@]+min_clr_scl*min_clr[drv_sty] + else: + smin_y[@]-min_clr_scl*min_clr[drv_sty], + if known ccl[@]: + ypart jdg[@].c-den_dp-iln_hg[(iln_sty[ccl[@]])] + -min_clr_scl*min_clr[drv_sty]/2 + else: + smax_y[@]+min_clr_scl*min_clr[drv_sty] + fi + fi) +enddef; + +vardef delim @# expr dlm_len= + save rule_str, dlm_str, dlm_pct, dlm_dp; + string rule_str, dlm_str; + picture dlm_pct; + numeric dlm_dp; + rule_str:="\rule{0bp}{"&(decimal(dlm_len/2+axis_hg[drv_sty]))&"bp}"; + dlm_str:= + if str @#="l": + "\left"&drv_l_dlm&rule_str&"\right." + else: + "\left."&rule_str&"\right"&drv_r_dlm + fi; + dlm_pct:=mth_tex[drv_sty] dlm_str; + dlm_dp:=depth dlm_pct; + if dlm_dp=0: + nullpicture + else: + begingroup + setbounds dlm_pct to + (xpart llcorner dlm_pct, dlm_dp) + --(xpart ulcorner dlm_pct, -dlm_dp) + --(xpart urcorner dlm_pct, -dlm_dp) + --(xpart lrcorner dlm_pct, dlm_dp) + --cycle; + dlm_pct yscaled (dlm_len/(2*height dlm_pct)) + endgroup + fi +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Checking, building, freezing (very inefficient, to be improved) +% + +% +% 1. Global parameters +% + +numeric min_clr_scl; % +numeric prm_skp_scl; % +numeric jdg_skp_scl; % +numeric ilb_skp_scl; % +numeric plb_skp_scl; % + +boolean drv_bot_roots; % +boolean drv_boxmode_on; % +boolean drv_fractionmode_on; % +string drv_axis_ref; % + +% +% 2. Macros +% + +% +% Checking +% + +vardef fraction_inference[]= + (prm_num[@]=0) + and (iln_sty[@]=0) + and (unknown l_ilb[@]) + and (unknown r_ilb[@]) + and drv_fractionmode_on +enddef; + +vardef drv_check_root[]= + if unknown jdg[@]: + drv_errhelp "An index must be used to declare a both a judgment and an"& + " inference."; + drv_errmessage (decimal @)&" has been used as an inference index but not"& + " as a judgment index"; + elseif unknown prm_num[@]: + drv_errhelp "An index must be used to declare a both a judgment and an"& + " inference."; + drv_errmessage (decimal @)&" has been used as a judgment index but not"& + " as an inference index"; + else: + save i_sty, prm_idx; + numeric i_sty, prm_idx; + i_sty:=iln_sty[@]; + for prm_rnk=0 upto prm_num[@]-1: + prm_idx:=prm[@][prm_rnk]; + drv_check_root[prm_idx]; + % + % numerators and denominators clearances + % The TEXbook, Appendix G, Rule 15d. + % + if drv_bot_roots: + num_hg:=max(num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].dp); + else: + den_dp:=min(den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].hg); + fi + endfor + if not fraction_inference[@]: + if drv_bot_roots: + den_dp:=min(den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[@].hg); + else: + num_hg:=max(num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[@].dp); + fi + fi + if unknown boxed[@]: + boxed[@]:=false; + fi + fi +enddef; + +vardef drv_check= + if root_num=0: + drv_errhelp "Well ..."; + drv_errmessage "no inference has been declared"; + else: + save root_idx; + numeric root_idx; + root_idx:=root[0]; + drv_check_root[root_idx]; + if root_num>1: + save root_str; + string root_str; + root_str:=decimal root_idx; + for idx=1 upto root_num-1: + root_idx:=root[idx]; + drv_check_root[root_idx]; + root_str:=root_str&", "&(decimal root_idx); + endfor + drv_message "warning, multiple root indices ("&root_str&")."; + fi + fi + drv_checked:=true; +enddef; + +% +% Building +% + +vardef drv_build_root[]= + % + % premises junction (from left to right) + % + for prm_rnk=0 upto prm_num[@]-1: + drv_build_root[prm[@][prm_rnk]]; + if prm_rnk>0: + save ll_idx, lr_idx, rl_idx, rr_idx; + save lmax_x, rmin_x, min_skp; + numeric ll_idx, lr_idx, rl_idx, rr_idx; + numeric lmax_x, rmin_x, min_skp; + ypart jdg[prm[@][prm_rnk-1]].c=ypart jdg[prm[@][prm_rnk]].c; + ll_idx:=prm[@][0]; + lr_idx:=prm[@][prm_rnk-1]; + rl_idx:=prm[@][prm_rnk]; + rr_idx:=prm[@][prm_rnk]; + lmax_x:=imax_x[lr_idx]; + rmin_x:=imin_x[rl_idx]; + min_skp[0]:=rmin_x-lmax_x; + forever: + exitif (unknown r_prm[lr_idx]) or (unknown l_prm[rl_idx]); + ll_idx:=l_prm[ll_idx]; + lr_idx:=r_prm[lr_idx]; + rl_idx:=l_prm[rl_idx]; + rr_idx:=r_prm[rr_idx]; + lmax_x:=max(lmax_x, imax_x[lr_idx]); + rmin_x:=min(rmin_x, imin_x[rl_idx]); + min_skp[0]:=min(min_skp[0], imin_x[rl_idx]-imax_x[lr_idx]); + endfor + min_skp[1]:=rmin_x-lmax_x; + if known r_prm[lr_idx]: + r_prm[rr_idx]:= r_prm[lr_idx]; + lmax_x:=smax_x[lr_idx]; + elseif known l_prm[rl_idx]: + l_prm[ll_idx]:=l_prm[rl_idx]; + rmin_x:=smin_x[rl_idx]; + fi + min_skp[2]:=rmin_x-lmax_x; + if jct_sty[@]<3: + min_skp[jct_sty[@]]=prm_skp_scl*prm_skp[drv_sty]; + fi + fi + endfor + if prm_num[@]>0: + l_prm[@]:=prm[@][0]; + r_prm[@]:=prm[@][prm_num[@]-1]; + fi + % + % judgment alignment + % + if prm_num[@]=0: + imin_x[@]:=xpart jdg[@].l-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + imax_x[@]:=xpart jdg[@].r+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + else: + save l_xref, r_xref; + l_xref= + if boxed[prm[@][0]]: + smin_x[prm[@][0]] + else: + xpart jdg[prm[@][0]].l + fi; + r_xref= + if boxed[prm[@][prm_num[@]-1]]: + smax_x[prm[@][prm_num[@]-1]] + else: + xpart jdg[prm[@][prm_num[@]-1]].r + fi; + if alg_sty[@]="l": + xpart jdg[@].l=l_xref; + elseif alg_sty[@]="c": + xpart jdg[@].c=(l_xref+r_xref)/2; + elseif alg_sty[@]="r": + xpart jdg[@].r=r_xref; + fi + imin_x[@]:=min(xpart jdg[@].l, l_xref) + -jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + imax_x[@]:=max(xpart jdg[@].r, r_xref) + +jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + fi + % + % inference line + % + save iln_wd, iln_pct; + numeric iln_wd; + picture iln_pct; + iln_wd:=imax_x[@]-imin_x[@]; + iln_pct:=((0, 0)--(iln_wd, 0)) drv_styled iln_sty[@]; + setbounds iln_pct to + (0, ypart llcorner iln_pct) + --(0, ypart ulcorner iln_pct) + --(iln_wd, ypart ulcorner iln_pct) + --(iln_wd, ypart llcorner iln_pct) + --cycle; % ! `linecap:=butt' and `linecap:=squared' -> same bounding box ! + box_init iln[@] (iln_pct); + xpart iln[@].c=(imin_x[@]+imax_x[@])/2; + % + % orientation, smin_y & smax_y + % + if drv_bot_roots: + ypart iln[@].c=ypart jdg[@].c-den_dp; + smin_y[@]:=ypart jdg[@].c+jdg[@].dp; + smax_y[@]:= + if iln_sty[@]=0: + ypart jdg[@].c+jdg[@].hg + else: + ypart iln[@].c+iln[@].hg + fi; + if prm_num[@]>0: + ypart iln[@].c=ypart jdg[prm[@][0]].c-num_hg; + for prm_rnk=0 upto prm_num[@]-1: + smax_y[@]:=max(smax_y[@], smax_y[prm[@][prm_rnk]]); + endfor; + fi + else: + ypart iln[@].c=ypart jdg[@].c-num_hg; + smin_y[@]:= + if iln_sty[@]=0: + ypart jdg[@].c+jdg[@].dp + else: + ypart iln[@].c+iln[@].dp + fi; + smax_y[@]:=ypart jdg[@].c+jdg[@].hg; + if prm_num[@]>0: + ypart iln[@].c=ypart jdg[prm[@][0]].c-den_dp; + for prm_rnk=0 upto prm_num[@]-1: + smin_y[@]:=min(smin_y[@], smin_y[prm[@][prm_rnk]]); + endfor; + fi + fi + % + % inference labels + % + if known l_ilb[@]: + l_ilb[@].r=iln[@].l shifted (-ilb_skp_scl*ilb_skp[drv_sty], 0); + imin_x[@]:=xpart l_ilb[@].l; + smin_y[@]:=min(smin_y[@], ypart l_ilb[@].c+l_ilb[@].dp); + smax_y[@]:=max(smax_y[@], ypart l_ilb[@].c+l_ilb[@].hg); + fi + if known r_ilb[@]: + r_ilb[@].l=iln[@].r shifted (ilb_skp_scl*ilb_skp[drv_sty], 0); + imax_x[@]:=xpart r_ilb[@].r; + smin_y[@]:=min(smin_y[@], ypart r_ilb[@].c+r_ilb[@].dp); + smax_y[@]:=max(smax_y[@], ypart r_ilb[@].c+r_ilb[@].hg); + fi + % + % phantom steps + % + if known tgt[@]: + save phm_pth, phm_pct; + path phm_pth; + picture phm_pct; + save top_y, mid_y, bot_y; + numeric top_y, bot_y; + if drv_bot_roots: + bot_y:=xpart minmax_y[@]+min_clr_scl*min_clr[drv_sty]/2; + top_y:=xpart minmax_y[tgt[@]]; + else: + bot_y:=ypart minmax_y[tgt[@]]; + top_y:=ypart minmax_y[@]-min_clr_scl*min_clr[drv_sty]/2; + fi + mid_y:=(top_y+bot_y)/2; + phm_pth:=(0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2); + phm_pct:=phm_pth drv_styled phm_sty[@]; + box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); + phm[@].c=(xpart jdg[@].c, mid_y); + imin_x[@]:=min(imin_x[@], xpart phm[@].l); + imax_x[@]:=max(imax_x[@], xpart phm[@].r); + % + % phantom steps labels + % + if known l_plb[@]: + l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); + imin_x[@]:=min(imin_x[@], xpart l_plb[@].l); + fi + if known r_plb[@]: + r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); + imax_x[@]:=max(imax_x[@], xpart r_plb[@].r); + fi + fi + % + % smin_x & smax_x + % + smin_x[@]:=imin_x[@]; + smax_x[@]:=imax_x[@]; + for prm_rnk=0 upto prm_num[@]-1: + smin_x[@]:=min(smin_x[@], smin_x[prm[@][prm_rnk]]); + smax_x[@]:=max(smax_x[@], smax_x[prm[@][prm_rnk]]); + endfor + % + % delimiters + % + if known l_dlb[@] or known r_dlb[@]: + save idx, mmy, min_y, max_y; + numeric idx, min_y, max_y; + pair mmy; + mmy:=minmax_y[@]; + min_y:=xpart mmy; + max_y:=ypart mmy; + if known l_dlb[@]: + box_init l_dlm[@] (delim l (max_y-min_y)); + l_dlm[@].r=(smin_x[@], (max_y+min_y)/2); + l_dlb[@].r=l_dlm[@].l; + smin_x[@]:=xpart l_dlb[@].l; + fi + if known r_dlb[@]: + box_init r_dlm[@] (delim r (max_y-min_y)); + r_dlm[@].l=(smax_x[@], (max_y+min_y)/2); + r_dlb[@].l=r_dlm[@].r; + smax_x[@]:=xpart r_dlb[@].r; + fi + fi + if (known l_dlb[@]) or boxed[@]: + idx:=@; + forever: + imin_x[idx]:=smin_x[@]; + exitif unknown l_prm[idx]; + idx:=l_prm[idx]; + endfor + fi + if (known r_dlb[@]) or boxed[@]: + idx:=@; + forever: + imax_x[idx]:=smax_x[@]; + exitif unknown r_prm[idx]; + idx:=r_prm[idx]; + endfor + fi +enddef; + +vardef drv_build= + if not drv_checked: + drv_check; + fi + for idx=0 upto root_num-1: + drv_build_root[root[idx]]; + endfor + drv_built:=true; +enddef; + +% +% Freezing +% + +vardef drv_freeze_root[]= + for prm_rnk=0 upto prm_num[@]-1: + drv_freeze_root[prm[@][prm_rnk]]; + endfor + for sbj_rnk=0 upto sbj_num[@]-1: + box_freeze sbj[@][sbj_rnk]; + endfor + forsuffixes sfx= + iln, jdg, phm, + l_dlb, l_dlm, l_ilb, l_plb, + r_dlb, r_dlm, r_ilb, r_plb: + if known sfx[@]: + box_freeze sfx[@]; + fi + endfor +enddef; + +vardef drv_freeze= + if not drv_built: + drv_build; + fi + save root_idx; + numeric root_idx; + root_idx:=root[0]; + if unknown iln[root_idx].c: + % + % default math axis + % + if drv_axis_ref="iln": + iln[root_idx].c=(0, axis_hg[drv_sty]); + else: % drv_axis_ref="jdg" + jdg[root_idx].c=(0, axis_hg[drv_sty]); + fi + drv_freeze_root[root_idx]; + fi + for idx=1 upto root_num-1: + root_idx:=root[idx]; + if unknown iln[root_idx].c: + smin_x[root_idx]=smax_x[root[idx-1]]+prm_skp_scl*prm_skp[drv_sty]; + ypart iln[root_idx].c=ypart iln[root[idx-1]].c; + fi + drv_freeze_root[root_idx]; + endfor + drv_frozen:=true; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Derivation tree pictures +% + +% +% 1. Global parameters +% + +boolean drv_proofmode_on; % +color prf_clr; % +color jdg_clr; % +color sbj_clr; % + +prf_clr:=.75background; % arbitrary +jdg_clr:=red; % arbitrary +sbj_clr:=blue; % arbitrary + +% +% 2. Macros +% + +vardef drv_tree_addto @# (expr idx) text draw_options= + for prm_rnk=0 upto prm_num[idx]-1: + drv_tree_addto @# (prm[idx][prm_rnk]) draw_options; + endfor + forsuffixes sfx= + jdg, phm, + l_dlb, l_dlm, l_ilb, l_plb, + r_dlb, r_dlm, r_ilb, r_plb: + if known sfx[idx]: + addto @# also sfx[idx] draw_options; + fi + endfor + if iln_sty[idx]>0: + addto @# also iln[idx] draw_options; + fi +enddef; + +vardef tt_nat[] expr nat= % typewriter typeface naturals + save nat_aux, nat_pct_wd, dgt_num, nat_pct; + numeric nat_aux, nat_pct_wd, dgt_num; + picture nat_pct; + nat_aux:=abs nat; + nat_pct:=nullpicture; + nat_pct_wd:=0; + dgt_num:=1; + forever: + exitif nat_aux div (10**dgt_num)=0; + dgt_num:=dgt_num+1; + endfor + for rnk:=1 upto dgt_num: + addto nat_pct also tt_dgt[@][nat_aux div (10**(dgt_num-rnk))] + shifted (nat_pct_wd, 0); + nat_pct_wd:=width nat_pct; + nat_aux:=nat_aux mod (10**(dgt_num-rnk)); + endfor + nat_pct shifted (0, -axis_hg[@]) +enddef; + +vardef prf_tree_addto @# expr idx= + for prm_rnk=0 upto prm_num[idx]-1: + prf_tree_addto @# (prm[idx][prm_rnk]); + endfor + if idx>=0: + box_init jdg_prf[idx] (tt_nat[2] idx); + jdg_prf[idx].r=jdg[idx].l; + box_freeze jdg_prf[idx]; + addto @# also jdg_prf[idx] withcolor jdg_clr; + addto @# doublepath jdg[idx].c withcolor jdg_clr + withpen pencircle scaled (2*pdt_hg[drv_sty]); + fi + for sbj_rnk=0 upto sbj_num[idx]-1: + box_init sbj_prf[idx][sbj_rnk] (tt_nat[3] sbj_rnk); + if odd sbj_rnk: + sbj_prf[idx][sbj_rnk].c shifted (0, sbj_prf[idx][sbj_rnk].hg)= + sbj[idx][sbj_rnk].c + shifted (0, -den_dp-min_clr_scl*min_clr[drv_sty]/2); + else: + sbj_prf[idx][sbj_rnk].c shifted (0, sbj_prf[idx][sbj_rnk].dp)= + sbj[idx][sbj_rnk].c + shifted (0, -num_hg+min_clr_scl*min_clr[drv_sty]/2); + fi + box_freeze sbj_prf[idx][sbj_rnk]; + addto @# also sbj_prf[idx][sbj_rnk] withcolor sbj_clr; + addto @# doublepath sbj[idx][sbj_rnk].c withcolor sbj_clr + withpen pencircle scaled pdt_hg[drv_sty]; + endfor +enddef; + +vardef drv_tree= + save pct; + picture pct; + pct:=nullpicture; + if not drv_frozen: + drv_freeze; + fi + for root_idx=0 upto root_num-1: + if drv_proofmode_on: + drv_tree_addto pct (root[root_idx]) withcolor prf_clr; + prf_tree_addto pct (root[root_idx]); + else: + drv_tree_addto pct (root[root_idx]); + fi + endfor + pct +enddef; + +vardef drv_bbox[]= + save min_x, max_x, mmy, min_y, max_y; + pair mmy; + numeric min_x, max_x, max_y, min_y; + if not drv_frozen: + drv_freeze; + fi + min_x:= + if known l_dlm[@].r: + xpart l_dlm[@].r + else: + smin_x[@] + fi-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + max_x:= + if known r_dlm[@].l: + xpart l_dlm[@].l + else: + smax_x[@] + fi+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + mmy:=minmax_y[@]; + min_y:=xpart mmy; + max_y:=ypart mmy; + (min_x, min_y)-- + (min_x, max_y)-- + (max_x, max_y)-- + (max_x, min_y)-- + cycle +enddef; + +vardef mth_axis @# (suffix ref_sfx) (expr idx)= + if not drv_frozen: + drv_freeze; + fi + if unknown prm_num[idx]: + drv_errhelp "An index must be used to declare an inference before it is"& + " used to set the math axis of a picture."; + drv_errmessage "no inference has been declared using index "&(decimal idx); + else: + save ref_str, yref; + string ref_str; + numeric yref; + ref_str:=str ref_sfx; + if ref_str="iln": + yref:=ypart iln[idx].c; + elseif ref_str="jdg": + yref:=ypart jdg[idx].c; + elseif ref_str="dlm": + if known l_dlm[idx]: + yref:=ypart l_dlm[idx].c; + elseif known r_dlm[idx]: + yref:=ypart r_dlm[idx].c; + else: + drv_errhelp "Well ..."; + drv_errmessage "no delimiter is attached to inference "&(decimal idx); + fi + else: + drv_errhelp "Valid identifiers are"& + " iln (inference line axis),"& + " jdg (judgment math-axis) and"& + " dlm (delimiter axis)."; + drv_errmessage (ref_str&" is not a valid reference type identifier"); + fi + if known yref: + @#:=@# shifted (0, axis_hg[drv_sty]-yref); + fi + fi +enddef; + +vardef drv_axis (suffix ref) (expr idx)= + mth_axis currentpicture (ref, idx); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Tunings +% + +vardef check_math_style (expr sty_str, default)= + if sty_str="\displaystyle": + 0 + elseif sty_str="\textstyle": + 1 + elseif sty_str="\scriptstyle": + 2 + elseif sty_str="\scriptscriptstyle": + 3 + else: + begingroup + drv_errhelp "Valid commands are"& + " \displaystyle,"& + " \textstyle,"& + " \scriptstyle and"& + " \scriptscriptstyle."; + drv_errmessage (sty_str&" is not a valid math-style command"); + default + endgroup + fi +enddef; + +vardef check_position_left (suffix pos_sfx) (expr default)= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if (pos_str="l"): + true + elseif (pos_str="r"): + false + else: + begingroup + drv_errhelp "Valid identifiers are l (left) and r (right)."; + drv_errmessage (pos_str&" is not a valid label position identifier"); + default + endgroup + fi +enddef; + +vardef check_mode_on (suffix status_sfx) (expr default)= + save status_str; + string status_str; + status_str:=str status_sfx; + if status_str="on": + true + elseif status_str="off": + false + else: + begingroup + drv_errhelp "Possible identifiers are on and off"; + drv_errmessage (status_str&" is not a valid status identifier"); + default + endgroup + fi +enddef; + +vardef drv_math_style (suffix typ_sfx) (expr sty_str)= + save typ_str, sty_idx; + string typ_str; + numeric sty_idx; + typ_str:=str typ_sfx; + if (typ_str<>"drv") + and (typ_str<>"jdg") + and (typ_str<>"ilb") + and (typ_str<>"dlb") + and (typ_str<>"plb"): + drv_errhelp "Valid identifiers are"& + " drv (derivation tree),"& + " jdg (judgment),"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (sty_str&" is not a valid component identifier"); + else: + sty_idx:=check_math_style (sty_str, 0); + if typ_str="drv": + drv_sty:=sty_idx; + else: + forsuffixes sfx=scantokens (typ_str&"_sty"): + for idx=0 upto 3: + sfx[idx]:=min(idx+sty_idx, 3); + endfor + endfor + fi + fi +enddef; + +vardef drv_scale (suffix scl_sfx) (expr scl)= + save scl_str; + string scl_str; + scl_str:=str scl_sfx; + if scl_str="clr": + min_clr_scl:=scl; + elseif scl_str="prm": + prm_skp_scl:=scl; + elseif (scl_str="jdg") or (scl_str="jgm"): % "jgm" is deprecated + jdg_skp_scl:=scl; + elseif (scl_str="ilb") or (scl_str="lbl"): % "lbl" is deprecated + ilb_skp_scl:=scl; + else: + drv_errhelp "Valid identifiers are"& + " clr,"& + " prm,"& + " jdg and"& + " ilb."; + drv_errmessage (scl_str&" is not a valid scale identifier"); + fi +enddef; + +vardef drv_junction_style suffix sty_sfx= + drv_jct_sty:=check_junction_style (sty_sfx, drv_jct_sty); +enddef; + +vardef drv_alignment_style suffix sty_sfx= + drv_alg_sty:=check_alignment_style (sty_sfx, drv_alg_sty); +enddef; + +vardef drv_path_style (suffix typ_sfx, sty_sfx)= + save typ_str; + string typ_str; + typ_str:=str typ_sfx; + if typ_str="iln": + drv_iln_sty:=check_path_style (sty_sfx, drv_iln_sty); + elseif typ_str="phm": + drv_phm_sty:=check_path_style (sty_sfx, drv_phm_sty); + else: + drv_errhelp "Valid identifiers are"& + " iln (inference line) and"& + " phm (phantom steps path)."; + drv_errmessage (typ_str&" is not a valid path-type identifier"); + fi +enddef; + +vardef drv_labels_position_aux (suffix typ_sfx, pos_sfx)= + save typ_str, idt_str, pos_str; + string typ_str, idt_str, pos_str; + typ_str:=str typ_sfx; + if typ_str="ilb": + drv_left_ilb:=check_position_left (pos_sfx, drv_left_ilb); + elseif typ_str="dlb": + drv_left_dlb:=check_position_left (pos_sfx, drv_left_dlb); + elseif typ_str="plb": + drv_left_plb:=check_position_left (pos_sfx, drv_left_plb); + else: + drv_errhelp "Valid identifiers are"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (typ_str&" is not a valid label-type identifier"); + fi +enddef; + +vardef drv_labels_position text ARG= + drv_labels_position_aux if pair ARG: ARG else: (ilb, ARG) fi; +enddef; + +vardef drv_roots_position suffix pos_sfx= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if pos_str="t": + drv_bot_roots:=false; + elseif pos_str="b": + drv_bot_roots:=true; + else: + drv_errhelp "Valid identifiers are"& + " t (top) and"& + " b (bottom)."; + drv_errmessage (pos_str&" is not a valid root position identifier"); + fi +enddef; + +vardef drv_axis_reference suffix ref_sfx= + save ref_str; + string ref_str; + ref_str:=str ref_sfx; + if (ref_str<>"iln") and (ref_str<>"jdg"): + drv_errhelp "Valid identifiers are iln (inference line axis) and"& + " jdg (judgment math-axis)."; + drv_errmessage (ref_str&" is not a valid reference identifier"); + else: + drv_axis_ref:=ref_str; + fi +enddef; + +vardef drv_delimiter (suffix pos_sfx) (expr dlm_str)= + if check_position_left (pos_sfx, true): + drv_l_dlm:=dlm_str; + else: + drv_r_dlm:=dlm_str; + fi +enddef; + +vardef drv_left_delimiter expr dlm_str= + drv_delimiter (l, dlm_str); +enddef; + +vardef drv_right_delimiter expr dlm_str= + drv_delimiter (r, dlm_str); +enddef; + +vardef drv_box_mode suffix status_sfx= + drv_boxmode_on:=check_mode_on (status_sfx, drv_boxmode_on); +enddef; + +vardef drv_fraction_mode suffix status_sfx= + drv_fractionmode_on:=check_mode_on (status_sfx, drv_fractionmode_on); +enddef; + +vardef drv_proof_mode suffix status_sfx= + drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Default settings +% + +drv_font_size "\normalsize"; +drv_math_style (drv, "\displaystyle"); +drv_math_style (jdg, "\textstyle"); +drv_math_style (ilb, "\scriptstyle"); +drv_math_style (dlb, "\textstyle"); +drv_math_style (plb, "\textstyle"); +drv_scale (clr, 1); +drv_scale (prm, 1); +drv_scale (jdg, 1); +drv_scale (ilb, 1); +drv_junction_style 1; +drv_alignment_style c; +drv_path_style (iln, 1); +drv_path_style (phm, 3); +drv_labels_position (ilb, r); +drv_labels_position (dlb, l); +drv_labels_position (plb, l); +drv_roots_position b; +drv_axis_reference iln; +drv_left_delimiter "\lbrace"; +drv_right_delimiter "\rbrace"; +drv_box_mode off; +drv_fraction_mode on; +drv_proof_mode off; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% LaTeX inclusion macro +% +% \drv includes a picture file in such a way that the baseline of the included +% picture coincides with the baseline of the inclusion point. The code for \drv +% was suggested by Josselin Noirel on the fr.comp.text.tex usenet group. +% +% \usepackage{graphicx} +% \makeatletter +% \def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}} +% \newsavebox{\graphicsbox} +% \newcommand*{\drv}[1]{% +% \sbox{\graphicsbox}{\includegraphics{#1}}% +% \raisebox{\Gin@lly bp}% +% {\usebox{\graphicsbox}}} +% \makeatother diff --git a/Master/texmf-dist/doc/metapost/drv/template/makefile b/Master/texmf-dist/doc/metapost/drv/template/makefile new file mode 100644 index 00000000000..239bbc6a46e --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/template/makefile @@ -0,0 +1,46 @@ +MAIN= template + +$(MAIN).pdf: $(MAIN).ps + ps2pdf $(MAIN).ps + +$(MAIN).ps: $(MAIN).tex $(MAIN)-delayed.mp + latex $(MAIN) + latex $(MAIN) + latex $(MAIN) + dvips $(MAIN) -o + +$(MAIN)-proof.pdf: $(MAIN)-proof.ps + ps2pdf $(MAIN)-proof.ps + +$(MAIN)-proof.ps: $(MAIN)-delayed.mp + latex $(MAIN)-proof + dvips $(MAIN)-proof -o + +$(MAIN)-delayed.mp: $(MAIN).mp + $(RM) $(MAIN)-delayed.mp + mpost $(MAIN) + mpost $(MAIN) + mpost $(MAIN) + +.SILENT clean: + $(RM) drv.mpx + $(RM) $(MAIN).[0-9]* + $(RM) $(MAIN).aux + $(RM) $(MAIN).dvi + $(RM) $(MAIN).log + $(RM) $(MAIN).nav + $(RM) $(MAIN).out + $(RM) $(MAIN).toc + $(RM) $(MAIN)-delayed.mp + $(RM) $(MAIN)-delayed.mpx + $(RM) $(MAIN)-proof.aux + $(RM) $(MAIN)-proof.dvi + $(RM) $(MAIN)-proof.log + $(RM) $(MAIN)-proof.tex + $(RM) $(MAIN)-proof.toc + +cleanall: clean + $(RM) $(MAIN).pdf + $(RM) $(MAIN).ps + $(RM) $(MAIN)-proof.pdf + $(RM) $(MAIN)-proof.ps diff --git a/Master/texmf-dist/doc/metapost/drv/template/readme.txt b/Master/texmf-dist/doc/metapost/drv/template/readme.txt new file mode 100644 index 00000000000..be277b760a8 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/template/readme.txt @@ -0,0 +1,17 @@ +# In order to compile the sources and to get a pdf file, use `make' or: + +# 1. run metapost THREE TIMES: +mpost template.mp +mpost template.mp +mpost template.mp + +# 2. run latex (three times): +latex template.tex +latex template.tex +latex template.tex + +# 3. run dvips (once): +dvips template.dvi -o + +# 4. run ps2pdf (once): +ps2pdf template.ps diff --git a/Master/texmf-dist/doc/metapost/drv/template/template.mp b/Master/texmf-dist/doc/metapost/drv/template/template.mp new file mode 100644 index 00000000000..0875f9df042 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/template/template.mp @@ -0,0 +1,131 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Structure of a MetaPost file using drv.mp +% 1. Preamble +% input drv; +% verbatimtex %&latex +% <LaTeX preamble> +% \begin{document} +% etex; +% 2. Figures +% <optional drv tunings> +% beginfig(<index>) +% <judgment & inference declarations> +% draw drv_tree; +% <optional extra MetaPost code> +% endfig; +% 3. Postamble +% end +% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% 1. Preamble +% + +input drv; + +verbatimtex %&latex + +% Any piece of code related to font selection in the preamble of +% `template.tex' (document class, font package, font selection commands ...) +% should be reported here. + +\documentclass[twoside,11pt]{article} +\usepackage[T1]{fontenc} +\usepackage{amsmath} +\usepackage{amssymb} + +% Choose your favourite fonts combination (if available). +% See "http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey". +% +%\usepackage{cmbright} % CM text & CM Bright math +%\usepackage{ccfonts,eulervm} % Concrete text & Euler math +%\usepackage{ccfonts} % Concrete text & math +%\usepackage[math]{iwona} % Iwona text & math +%\usepackage[math]{kurier} % Kurier text & math +%\usepackage[math]{anttor} % Antykwa Torunska text & math +%\usepackage{kmath,kerkis} % Kerkis text & math +%\usepackage{fouriernc} % New Century Schoolbook & Fourier math +%\usepackage{pxfonts} % Palatino & pxfonts math +%\usepackage{mathpazo} % Palatino & Pazo math +%\usepackage{mathpple} % Palatino & Euler math +\usepackage[varg]{txfonts} % Times & txfonts math +%\usepackage{mathtime} % Times & Belleek math +%\usepackage{mathptmx} % Times & Symbol math +%\usepackage{mbtimes} % Omega Serif text & Omega math +%\usepackage{arev} % Arev Sans text with Arev math +%\usepackage[charter]{mathdesign} % Bitstream Charter & Math Design math +%\usepackage{comicsans} % Comic Sans text & math +%\usepackage[garamond]{mathdesign} % Garamond & Math Design math +%\usepackage{fourier} % Utopia & Fourier math +%\usepackage[utopia]{mathdesign} % Utopia & Math Design math + +\begin{document} +etex; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% 2. Figures +% + +% Default settings +% +% drv_font_size "\normalsize"; +% drv_math_style (drv, "\displaystyle"); +% drv_math_style (jdg, "\textstyle"); +% drv_math_style (ilb, "\scriptstyle"); +% drv_math_style (dlb, "\textstyle"); +% drv_math_style (plb, "\textstyle"); +% drv_scale (clr, 1); +% drv_scale (prm, 1); +% drv_scale (jdg, 1); +% drv_scale (ilb, 1); +% drv_junction_style 1; +% drv_alignment_style c; +% drv_path_style (iln, 1); +% drv_path_style (phm, 3); +% drv_labels_position (ilb, r); +% drv_labels_position (dlb, l); +% drv_labels_position (plb, l); +% drv_roots_position b; +% drv_axis_reference iln; +% drv_left_delimiter "\lbrace"; +% drv_right_delimiter "\rbrace"; +% drv_box_mode off; +% drv_fraction_mode on; +% drv_proof_mode off; + +beginfig(100) +jgm 0 "\Gamma, \Delta, \Theta, \Pi, \Upsilon\vdash F"; + jgm 1 "\Pi\vdash (A\to D)\to E"; + jgm 2 "\Gamma, \Delta, \Theta, (A\to D)\to E, \Upsilon\vdash F"; + jgm 3 "\Gamma, \Delta, \Theta\vdash A\to D"; + jgm 4 "A, \Gamma, \Delta, \Theta\vdash D"; + jgm 5 "A, \Gamma, \Delta\vdash B\wedge C"; + jgm 6 "A, \Gamma\vdash B"; + jgm 7 "\Delta\vdash C"; + jgm 8 "B\wedge C, \Theta\vdash D"; + jgm 9 "E, \Upsilon\vdash F"; +nfr 0 (1, 2) ("\text{cut}", 1); + nfr 1 () ("\pi", 4); + nfr 2 (3, 9) ("\to_L", 1); + nfr 3 (4) ("\to_R", 1); + nfr 4 (5, 8) ("\text{cut}", 1); + nfr 5 (6, 7) ("\wedge_R", 1); + nfr 6 () ("\gamma", 2); + nfr 7 () ("\delta", 1); + nfr 8 () ("\theta", 3); + nfr 9 () ("\upsilon", 2); +draw drv_tree; +endfig; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% 3. Postamble +% + +end diff --git a/Master/texmf-dist/doc/metapost/drv/template/template.tex b/Master/texmf-dist/doc/metapost/drv/template/template.tex new file mode 100644 index 00000000000..687c45778b3 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/drv/template/template.tex @@ -0,0 +1,55 @@ +% Any piece of code related to font selection in the following preamble +% (document class, font package, font selection commands ...) should be +% reported in `template.mp'. + +\documentclass[twoside,11pt]{article} +\usepackage[T1]{fontenc} +\usepackage{amsmath} +\usepackage{amssymb} + +% Choose your favourite fonts combination (if available). +% See "http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey". +% +%\usepackage{cmbright} % CM text & CM Bright math +%\usepackage{ccfonts,eulervm} % Concrete text & Euler math +%\usepackage{ccfonts} % Concrete text & math +%\usepackage[math]{iwona} % Iwona text & math +%\usepackage[math]{kurier} % Kurier text & math +%\usepackage[math]{anttor} % Antykwa Torunska text & math +%\usepackage{kmath,kerkis} % Kerkis text & math +%\usepackage{fouriernc} % New Century Schoolbook & Fourier math +%\usepackage{pxfonts} % Palatino & pxfonts math +%\usepackage{mathpazo} % Palatino & Pazo math +%\usepackage{mathpple} % Palatino & Euler math +\usepackage[varg]{txfonts} % Times & txfonts math +%\usepackage{mathtime} % Times & Belleek math +%\usepackage{mathptmx} % Times & Symbol math +%\usepackage{mbtimes} % Omega Serif text & Omega math +%\usepackage{arev} % Arev Sans text with Arev math +%\usepackage[charter]{mathdesign} % Bitstream Charter & Math Design math +%\usepackage{comicsans} % Comic Sans text & math +%\usepackage[garamond]{mathdesign} % Garamond & Math Design math +%\usepackage{fourier} % Utopia & Fourier math +%\usepackage[utopia]{mathdesign} % Utopia & Math Design math + +% Picture inclusion macro: \drv +% +% \drv includes a picture file in such a way that the baseline of the included +% picture coincides with the baseline of the inclusion point. The code for \drv +% was suggested by Josselin Noirel on the fr.comp.text.tex usenet group. + +\usepackage{graphicx} +\makeatletter +\def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}} +\newsavebox{\graphicsbox} +\newcommand*{\drv}[1]{% +\sbox{\graphicsbox}{\includegraphics{#1}}% +\raisebox{\Gin@lly bp}% +{\usebox{\graphicsbox}}} +\makeatother + +\begin{document} +\begin{gather*} +\frac{\qquad}{}\drv{template.100}\frac{\qquad}{} +\end{gather*} +\end{document} diff --git a/Master/texmf-dist/metapost/drv/drv.mp b/Master/texmf-dist/metapost/drv/drv.mp new file mode 100644 index 00000000000..5eb38396144 --- /dev/null +++ b/Master/texmf-dist/metapost/drv/drv.mp @@ -0,0 +1,2245 @@ +%% drv.mp 0.93 +%% Copyright 2009 Laurent M\'ehats +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Laurent M\'ehats. +% <laurent.mehats@gmail.com> +% +% This work consists of the file drv.mp + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% User's macros summary +% +% +% * Judgment & inference declarations +% =================================== +% +% jgm <nat> <str list> +% <nat> judgment index +% <str list> sub-judgments math-mode LaTeX code +% +% nfr <nat> (<nat list>) (<str>, <id>) +% <nat> inference index +% <nat list> list of premise indices +% <str> inference label math-mode LaTeX code +% <id> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% 0 none +% 1 simple +% 2 double +% 3 dotted +% 4 dashed +% 5 waved +% 6 TeX-dotted +% _ default (set by drv_path_style) +% +% mvd <nat 1> (<nat 2>, <id>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <id> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% Nfr <nat> (<nat list>) (<str 1>, <str 2>, <str 3>, <id>) +% <nat> inference index +% <nat list> list of premise indices +% <str 1> inference label math-mode LaTeX code +% <str 2> left delimiter label math-mode LaTeX code +% <str 3> right delimiter label math-mode LaTeX code +% <id> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% Mvd <nat 1> (<nat 2>, <str 1>, <str 2>, <id>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str 1> left label math-mode LaTeX code +% <str 2> right label math-mode LaTeX code +% <id> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% NFR <nat> (<nat list>) (<str 1>, <str 2>, <str 3>, <str 4>) +% (<id 1>, <id 2>, <id 3>) +% <nat> inference index +% <nat list> list of premise indices +% <str 1> left inference label math-mode LaTeX code +% <str 2> right inference label math-mode LaTeX code +% <str 3> left delimiter label math-mode LaTeX code +% <str 4> right delimiter label math-mode LaTeX code +% <id 1> junction style identifier (0, 1, 2, 3 or _) +% 0 fully-interlacing +% 1 semi-interlacing +% 2 non-interlacing +% 3 user specified (tricky) +% _ default (set by drv_junction_style) +% <id 2> alignment style identifier (l, c, r, u or _) +% l left +% c centered +% r right +% u user specified (tricky) +% _ default (set by drv_alignment_style) +% <id 3> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% MVD <nat 1> (<nat 2>, <str 1>, <str 2>, <id 1> <id 2>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str 1> left label math-mode LaTeX code +% <str 2> right label math-mode LaTeX code +% <id 1> alignment style identifier (l, c, r, u or _) +% <id 2> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% NFR_opt <nat> (<nat list>) (<str list 1>) (<str list 2>) +% (<id 1>, <id 2>, <id 3>) +% <nat> inference index +% <nat list> list of premise indices +% <str list 1> list of inference labels math-mode LaTeX code +% <str list 2> list of delimiter labels math-mode LaTeX code +% <id 1> junction style identifier (0, 1, 2, 3 or _) +% <id 2> alignment style identifier (l, c, r, u or _) +% <id 3> inference line style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% MVD_opt <nat 1> (<nat 2>) (<str list>) (<id 1> <id 2>) +% <nat 1> index of the origin judgment +% <nat 2> number of phantom steps +% <str list> list of labels math-mode LaTeX code +% <id 1> alignment style identifier (l, c, r or u) +% <id 2> phantom steps path-style identifier +% (0, 1, 2, 3, 4, 5, 6 or _) +% +% * Tunings +% ========= +% +% drv_font_size <str> +% <str> LaTeX font-size command +% "\tiny" +% "\scriptsize" +% "\footnotesize" +% "\small" +% "\normalsize" +% "\large" +% "\Large" +% etc. +% +% drv_math_style (<id>, <str>) +% <id> component identifier (drv, jdg, ilb, dlb or plb) +% drv derivation trees +% jdg judgments +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <str> LaTeX math-style command +% +% drv_scale (<id>, <float>) +% <id> scale identifier (clr, prm, jdg or ilb) +% clr nice explanation soon (see examples) +% prm nice explanation soon (see examples) +% jdg nice explanation soon (see examples) +% ilb nice explanation soon (see examples) +% <float> scale value +% +% drv_junction_style <id> +% <id> junction style identifier (0, 1 or 2) +% 0 ``fully-interlacing'' +% 1 ``semi-interlacing'' +% 2 ``non-interlacing'' +% +% drv_alignment_style <id> +% <id> alignment style identifier (l, c or r) +% l left +% c centered +% r right +% +% drv_path_style (<id 1>, <id 2>) +% <id 1> path-type identifier (iln or phm) +% iln inference lines +% phm phantom steps paths +% <id 2> path-style identifier (0, 1, 2, 3, 4, 5 or 6) +% +% drv_labels_position (<id 1>, <id 2>) +% <id 1> label-type identifier (ilb, plb or dlb) +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <id 2> position identifier (l or r) +% l left +% r right +% +% drv_roots_position <id> +% <id> position identifier (t or b) +% t top +% b bottom +% +% drv_axis_reference <id> +% <id> reference identifier (iln or jdg) +% iln root inference line axis +% jdg root judgment math-axis +% +% drv_left_delimiter <str> +% <str> left delimiter math-mode LaTeX code +% "(" $($ +% "[" $[$ +% "\lbrace" $\lbrace$ +% "\langle" $\langle$ +% etc. +% +% drv_right_delimiter <str> +% <str> right delimiter math-mode LaTeX code +% ")" +% "]" +% "\rbrace" +% "\rangle" +% etc. +% +% drv_box_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_fraction_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_proof_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% * Derivation tree pictures +% ========================== +% +% drv_bbox <nat> +% <nat> sub-tree root index +% +% drv_axis (<id>, <nat>) +% <id> reference type identifier (iln, jdg or dlm) +% iln inference line axis +% jdg judgment math-axis +% dlm delimiter axis +% <nat> reference index +% +% <path> drv_styled <id> +% <path> MetaPost path expression +% <id> path style identifier (0, 1, 2, 3, 4, 5 or 6) +% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MetaPost messages formatting +% + +% drv_format prevents messages from being automatically cut into lines every +% 79 characters: if possible, a word which would otherwise be cut is 'pushed' +% to the following line by inserting space characters before it. + +vardef drv_format (expr str, fst_len, nxt_len, dbl_pcs)= + % str: the message to be formatted + % fst_len: first line length + % nxt_len: following lines length + % dbl_pcs (boolean): occurrences of the percent character must be doubled + save str_len, sub_len, aux_len, chr_rnk, occ_num; + numeric str_len, sub_len, aux_len, chr_rnk, occ_num; + save aux_str, chr; + string aux_str, chr; + str_len:=length str; + sub_len:=0; + chr_rnk:=0; + occ_num:=0; + aux_len:=0; + aux_str:=""; + forever: + exitif (chr_rnk=fst_len) or (chr_rnk=str_len); + chr:=substring (chr_rnk, chr_rnk+1) of str; + aux_str:=aux_str&chr; + if chr=" ": + sub_len:=chr_rnk+1; + aux_len:=sub_len+occ_num; + elseif (chr="%") and dbl_pcs: + aux_str:=aux_str&"%"; + occ_num:=occ_num+1; + fi + chr_rnk:=chr_rnk+1; + endfor + if chr_rnk=fst_len: + begingroup + if sub_len=0: + sub_len:=fst_len; + aux_len:=sub_len+occ_num; + fi + substring (0, aux_len) of aux_str& + for idx=sub_len+1 upto fst_len: + " "& + endfor + drv_format (substring (sub_len, str_len) of str, + nxt_len, nxt_len, dbl_pcs) + endgroup + else: + aux_str + fi +enddef; + +boolean drv_inside_fig; +drv_inside_fig:=false; + +vardef drv_context= + "drv"&if drv_inside_fig: " (fig. "&decimal charcode&")"&fi ": " +enddef; + +vardef drv_message expr str= + message drv_format (drv_context&str, 79, 79, false); +enddef; + +vardef drv_errhelp expr str= + % Occurrences of the percent character must be doubled: errhelp makes single + % single occurrences behave as newline characters (this is inherited from + % MetaFont). + errhelp drv_format (str, 79, 79, true); +enddef; + +vardef drv_errmessage expr str= + % errmessage inserts the 2-characters string "! " before its argument. + % Hence 77 as a first line length argument. + errmessage drv_format (drv_context&str, 77, 79, false); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Delayed LaTeX processing +% + +picture tex_pct[]; +string delayed_tex_file; +delayed_tex_file:=jobname&"-delayed.mp"; + +% +% reading LaTeX picture definitions +% + +boolean drv_nullpicture; +drv_nullpicture:=true; + +string readfrom_str; +readfrom_str:=readfrom delayed_tex_file; +if readfrom_str<>EOF: + closefrom delayed_tex_file; + drv_message ("reading `"&delayed_tex_file&"' LateX picture definitions."); + batchmode; + scantokens ("input "&delayed_tex_file); + errorstopmode; + drv_message "done."; + drv_nullpicture:=false; +fi + +% +% copying LaTeX preamble +% + +vardef drv_read (expr search_str) (suffix accum_str)= + save readfrom_str, readfrom_substr; + string readfrom_str, readfrom_substr; + accum_str:=""; + forever: + readfrom_str:=readfrom jobname; + readfrom_substr:=substring (0, length search_str) of readfrom_str; + exitif (readfrom_substr=search_str) or (readfrom_str=EOF); + accum_str:=accum_str&readfrom_str&char(10); + endfor + if readfrom_str=EOF: + closefrom jobname; + drv_errhelp ("`"&jobname&".mp' should contain a line starting with "& + ditto&search_str&ditto&"."); + drv_errmessage (ditto&search_str&ditto&" is missing"); + fi +enddef; + +string tex_preamble_str[]; +% tex_preamble_str[0] from "verbatimtex %&latex" to "\begin{document}" +% tex_preamble_str[1] from "\begin{document}" to "etex;" + +drv_message ("reading `"&jobname&".mp' LateX preamble."); + drv_read ("verbatimtex %&latex", tex_preamble_str[0]); + drv_read ("\begin{document}", tex_preamble_str[0]); + drv_read ("etex;", tex_preamble_str[1]); + closefrom jobname; + write + "%"&char(10)& + "% AUTOMATICALLY GENERATED BY DRV.MP - DO NOT MODIFY."&char(10)& + "%"&char(10)&char(10)& + "verbatimtex %&latex"&char(10)& + tex_preamble_str[0]& + "\begin{document}"&char(10)& + tex_preamble_str[1]& + "etex;" + to delayed_tex_file; +drv_message "done."; + +% +% writing LaTeX picture definitions +% + +numeric tex_pct_idx; +tex_pct_idx:=0; + +% Math style indices: 0, 1, 2, 3 +string mth_sty_str[]; +mth_sty_str[0]:="\displaystyle"; +mth_sty_str[1]:="\textstyle"; +mth_sty_str[2]:="\scriptstyle"; +mth_sty_str[3]:="\scriptscriptstyle"; + +string drv_fontsize; + +vardef drv_tex[] expr tex_str= + % @: math style index + % tex_str: math mode LaTeX code + save def_str, pct; + string def_str; + picture pct; + def_str:="btex{"&drv_fontsize&"$"&mth_sty_str[@]&"{}"&tex_str&"{}$}etex;"; + write "tex_pct["&(decimal tex_pct_idx)&"]:="&def_str to delayed_tex_file; + pct:= + if known tex_pct[tex_pct_idx]: + tex_pct[tex_pct_idx] + else: + nullpicture + fi; + tex_pct_idx:=tex_pct_idx+1; + pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MetaPost shorthands +% + +vardef depth expr pct= + ypart llcorner pct +enddef; + +vardef height expr pct= + ypart urcorner pct +enddef; + +vardef width expr pct= + xpart urcorner pct-xpart llcorner pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Font-specific parameters +% + +% +% em[s] width of an m (s: mathstyle index) +% ex[s] height of an x +% axis_hg[s] height of the mathematical axis +% num_bl_hg[s] height of a numerator baseline w.r.t. the fraction bar axis +% den_bl_dp[s] depth of a denominator baseline w.r.t. the fraction bar axis +% rul_thk[s] default rule thickness +% + +numeric em[], ex[], axis_hg[], num_bl_hg[], den_bl_dp[], rul_thk[]; + +% +% thn_sp[s] thin space, usually 1em/6 +% med_sp[s] medium space, usually 2em/9 +% thk_sp[s] thick space, usually 5em/18 +% + +numeric thn_sp[], med_sp[], thk_sp[]; + +% +% pdt_hg[s] height of a punctuation ldot +% pdt_wd[s] width of a punctuation ldot +% + +numeric pdt_hg[], pdt_wd[]; + +% +% tt_dgt[s][i] typewriter typeface digits (i ranges from 0 to 9) +% + +picture tt_dgt[][]; + +% +% min_clr[s] minimal clearance between a numerator +% or a denominator and the fraction bar +% prm_skp[s] <nice explanation> +% jdg_skp[s] <nice explanation> +% ilb_skp[s] <nice explanation> +% plb_skp[s] <nice explanation> +% + +numeric min_clr[], prm_skp[], jdg_skp[], ilb_skp[], plb_skp[]; + +vardef drv_fontdimen[] expr font= + save dim_pct; + picture dim_pct; + dim_pct:=drv_tex[0] ("\rule{\the\fontdimen"&(decimal @)&font&"}{0bp}"); + width dim_pct +enddef; + +vardef drv_font_size expr size_str= + save pdt_pct, sp_pct; + picture pdt_pct, sp_pct; + drv_fontsize:=size_str; + write char(10)&"% font-specific parameters ("&drv_fontsize&")"&char(10) + to delayed_tex_file; + ex[0]:=drv_fontdimen[5] "\textfont2"; + ex[1]:=drv_fontdimen[5] "\textfont2"; + ex[2]:=drv_fontdimen[5] "\scriptfont2"; + ex[3]:=drv_fontdimen[5] "\scriptscriptfont2"; + em[0]:=drv_fontdimen[6] "\textfont2"; + em[1]:=drv_fontdimen[6] "\textfont2"; + em[2]:=drv_fontdimen[6] "\scriptfont2"; + em[3]:=drv_fontdimen[6] "\scriptscriptfont2"; + rul_thk[0]:=drv_fontdimen[8] "\textfont3"; + rul_thk[1]:=drv_fontdimen[8] "\textfont3"; + rul_thk[2]:=drv_fontdimen[8] "\scriptfont3"; + rul_thk[3]:=drv_fontdimen[8] "\scriptscriptfont3"; + axis_hg[0]:=drv_fontdimen[22] "\textfont2"; + axis_hg[1]:=drv_fontdimen[22] "\textfont2"; + axis_hg[2]:=drv_fontdimen[22] "\scriptfont2"; + axis_hg[3]:=drv_fontdimen[22] "\scriptscriptfont2"; + num_bl_hg[0]:=(drv_fontdimen[8] "\textfont2")-axis_hg[0]; + num_bl_hg[1]:=(drv_fontdimen[9] "\textfont2")-axis_hg[1]; + num_bl_hg[2]:=(drv_fontdimen[9] "\scriptfont2")-axis_hg[2]; + num_bl_hg[3]:=(drv_fontdimen[9] "\scriptscriptfont2")-axis_hg[3]; + den_bl_dp[0]:=-(drv_fontdimen[11] "\textfont2")-axis_hg[0]; + den_bl_dp[1]:=-(drv_fontdimen[12] "\textfont2")-axis_hg[1]; + den_bl_dp[2]:=-(drv_fontdimen[12] "\scriptfont2")-axis_hg[2]; + den_bl_dp[3]:=-(drv_fontdimen[12] "\scriptscriptfont2")-axis_hg[3]; + min_clr[0]:=3*rul_thk[0]; % The TEXbook, + min_clr[1]:=1*rul_thk[1]; % Appendix G, + min_clr[2]:=1*rul_thk[2]; % Rule 15d. + min_clr[3]:=1*rul_thk[3]; % + for mth_sty:=0 upto 3: + sp_pct:=drv_tex[mth_sty] "\,"; + thn_sp[mth_sty]:=width sp_pct; + sp_pct:=drv_tex[mth_sty] "\>"; + med_sp[mth_sty]:=width sp_pct; + sp_pct:=drv_tex[mth_sty] "\;"; + thk_sp[mth_sty]:=width sp_pct; + pdt_pct:=drv_tex[mth_sty] "\ldotp"; + pdt_hg[mth_sty]:=height pdt_pct; + pdt_wd[mth_sty]:=width pdt_pct; + for dgt=0 upto 9: + tt_dgt[mth_sty][dgt]:=drv_tex[mth_sty] "\texttt{"&(decimal dgt)&"}"; + endfor + prm_skp[mth_sty]:=3*med_sp[mth_sty]; % arbitrary + jdg_skp[mth_sty]:=thn_sp[mth_sty]; % arbitrary + ilb_skp[mth_sty]:=thn_sp[mth_sty]; % arbitrary + plb_skp[mth_sty]:=thk_sp[mth_sty]; % arbitrary + endfor +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Math-related parameters & macros +% + +% +% Math styles +% drv_sty derivation trees +% jdg_sty[drv_sty] judgments +% ilb_sty[drv_sty] inference labels +% dlb_sty[drv_sty] delimiter labels +% plb_sty[drv_sty] phantom steps labels +% + +numeric drv_sty, jdg_sty[], ilb_sty[], dlb_sty[], plb_sty[]; + +% +% Math-axis centered LaTeX pictures +% + +vardef mth_tex[] expr tex_str= + (drv_tex[@] tex_str) shifted (0, -axis_hg[@]) +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% drv-boxes +% + +vardef drv_box text STR= + for str=STR: + expandafter picture scantokens str; + expandafter pair scantokens str.l; + expandafter pair scantokens str.c; + expandafter pair scantokens str.r; + expandafter numeric scantokens str.hg; + expandafter numeric scantokens str.dp; + endfor +enddef; + +vardef box_init @# (expr pct)= + @#:=pct; + @#.r-@#.l=(width pct, 0); + @#.c=(@#.l+@#.r)/2; + @#.hg:=height pct; + @#.dp:=depth pct; +enddef; + +vardef box_freeze @#= + @#:=@# shifted @#.l; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% beginfig & endfig +% + +% +% drv_beginfig: figure initialization +% + +pen drv_pen; + +vardef drv_beginfig= + % + % Judgments + % + % jdg[i] judgment drv-box + % sbj_num[i] number of sub-judgments + % sbj[i][j] sub-judgment drv-box (j ranges from 0 to sbj_num[i]-1) + % + drv_box "jdg[]"; + numeric sbj_num[]; + drv_box "sbj[][]"; + % + % Inferences + % + % prm_num[i] number of premises + % prm[i][j] premise index (j ranges from 0 to prm_num[i]-1) + % ccl[i] conclusion index + % jct_sty[i] junction style + % alg_sty[i] alignment style + % iln_sty[i] inference line style + % l_prm[i] leftmost `graphical' premise index + % r_prm[i] rightmost `graphical' premise index + % + numeric prm_num[], prm[][], ccl[]; + numeric jct_sty[]; + string alg_sty[]; + numeric iln_sty[]; + numeric l_prm[], r_prm[]; + % + % imin_x[i] inference minimal x + % l_dlb[i] left delimiter label drv-box + % l_dlm[i] left delimiter drv-box + % l_ilb[i] left label drv-box + % iln[i] inference line drv-box + % r_ilb[i] right label drv-box + % r_dlm[i] right delimiter drv-box + % r_dlb[i] right delimiter label drv-box + % imax_x[i] inference maximal x + % + numeric imin_x[]; + drv_box "l_dlb[]", "l_dlm[]", "l_ilb[]"; + drv_box "iln[]"; + drv_box "r_ilb[]", "r_dlm[]", "r_dlb[]"; + numeric imax_x[]; + % + % Sub-trees + % + % smin_x[i] sub-tree minimal x + % smax_x[i] sub-tree maximal x + % smin_y[i] sub-tree minimal y + % smax_y[i] sub-tree maximal y + % boxed[i] boolean + % + numeric smin_x[], smax_x[], smin_y[], smax_y[]; + boolean boxed[]; + % + % Pen initialization + % + drv_pen:=pencircle scaled rul_thk[drv_sty]; + % + % num_hg height of a numerator axis w.r.t. the fraction bar axis + % den_dp depth of a denominator axis w.r.t. the fraction bar axis + % iln_hg[s] height of a style s inference line + % iln_dp[s] depth of a style s inference line + % + numeric num_hg, den_dp, iln_hg[], iln_dp[]; + num_hg:=num_bl_hg[drv_sty]+axis_hg[jdg_sty[drv_sty]]; + den_dp:=den_bl_dp[drv_sty]+axis_hg[jdg_sty[drv_sty]]; + picture iln_pct; + for sty=0 upto 6: + iln_pct:=((0, 0)--(10, 0)) drv_styled sty; + iln_hg[sty]:=height iln_pct; + iln_dp[sty]:=depth iln_pct; + endfor + % + % Derivation trees + % + % root_num number of roots + % root[i] root index (i ranges from 0 to root_num-1) + % drv_built boolean + % drv_frozen boolean + % + numeric root_num, root[]; + boolean drv_checked, drv_built, drv_frozen; + root_num:=0; + drv_checked:=false; + drv_built:=false; + drv_frozen:=false; + % + % Phantom steps + % + % phm_idx phantom inferences index + % src[i] base phantom judgment index (in case of an origin judgment) + % tgt[i] origin judgment index (in case of a base phantom judgment) + % phm_sty[i] phantom steps style + % l_plb[i] left phantom steps label drv-box (in case of a base + % phantom judgment) + % phm[i] phantom steps drv-box (in case of a base phantom + % judgment) + % r_plb[i] right phantom steps label drv-box (in case of a base + % phantom judgment) + % + numeric phm_idx, src[], tgt[], phm_sty[]; + phm_idx:=0; + drv_box "l_plb[]", "phm[]", "r_plb[]"; + % + % Proof pictures + % + % jdg_prf[i] judgment index drv-box + % sbj_prf[i][j] sub-judgment index drv-box (j ranges from 0 to + % sbj_num[i]-1) + % + drv_box "jdg_prf[]", "sbj_prf[][]"; + % + % Info + % + write char(10)&"% fig. "&(decimal charcode)&char(10) to delayed_tex_file; + drv_inside_fig:=true; % context: inside a figure +enddef; + +extra_beginfig:=extra_beginfig&"drv_beginfig;"; + +% +% drv_endfig: proof-file generation +% + +string proof_file; +proof_file:=jobname&"-proof.tex"; + +% TODO: taking outputtemplate into account. +vardef output_file[]= + jobname&"."&(decimal @) +enddef; + +string buf_str; +buf_str:= + "%"&char(10)& + "% AUTOMATICALLY GENERATED BY DRV.MP."&char(10)& + "%"&char(10)&char(10)& + tex_preamble_str[0]& + "\usepackage{graphicx}"&char(10)& + "\makeatletter"&char(10)& + "\def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}}"&char(10)& + "\newsavebox{\graphicsbox}"&char(10)& + "\newcommand*{\drv}[1]{%"&char(10)& + "\sbox{\graphicsbox}{\includegraphics{#1}}%"&char(10)& + "\raisebox{\Gin@lly bp}%"&char(10)& + "{\usebox{\graphicsbox}}}"&char(10)& + "\makeatother"&char(10)&char(10)& + "\newcount\h"&char(10)& + "\newcount\m"&char(10)& + "\h=\time"&char(10)& + "\divide\h 60"&char(10)& + "\m=-\h"&char(10)& + "\multiply\m 60"&char(10)& + "\advance\m\time"&char(10)& + "\def\hm{\number\h:\ifnum\m<10{}0\fi\number\m}"&char(10)&char(10)& + "\newcommand{\mathaxis}{\frac{\quad}{}}"&char(10)&char(10)& + "\begin{document}"&char(10)& + tex_preamble_str[1]& + "\noindent\today\ at \hm\medskip"&char(10)&char(10)&"\noindent"; + +vardef drv_endfig= + drv_inside_fig:=false; % context: outside a figure + buf_str:=buf_str&char(10)& + "\texttt{"&output_file[charcode]&"}"&char(10)& + " (\verb+"&drv_fontsize&"+, \verb+"&(mth_sty_str[drv_sty])&"+)"&char(10)& + " {"&drv_fontsize&char(10)& + " \["&(mth_sty_str[drv_sty])&char(10)& + " \mathaxis\drv{"&output_file[charcode]&"}\mathaxis"&char(10)& + " \]}\\"; + write EOF to proof_file; % erases the previous content + write buf_str&char(10)&"\end{document}" to proof_file; + write EOF to proof_file; + if drv_nullpicture: + draw btex{\tt drv}: run {\tt mpost} again.etex withcolor (1, 0, 0); + fi +enddef; + +extra_endfig:="drv_endfig;"&extra_endfig; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Judgment declarations +% + +vardef jgm[] text SUB= + % @: judgment index + % SUB: list of `sub-judgments' (pictures or strings) + if @<0: + drv_errhelp "An judgment index can not be negative."; + drv_errmessage (decimal @)&" is negative"; + elseif known jdg[@]: + drv_errhelp "An index can be used only once to declare a judgment."; + drv_errmessage (decimal @)&" has been used already as a judgment index"; + else: + save jdg_pct, sbj_pct, jdg_wd, sbj_rnk; + picture jdg_pct, sbj_pct; + numeric jdg_wd, sbj_rnk; + jdg_pct:=nullpicture; + jdg_wd:=0; + sbj_rnk:=0; + for sub=SUB: + sbj_pct:= + if picture sub: + sub + elseif sub<>"": + mth_tex[jdg_sty[drv_sty]] sub + else: + nullpicture + fi; + box_init sbj[@][sbj_rnk] (sbj_pct); + if sbj_rnk>0: + sbj[@][sbj_rnk-1].r=sbj[@][sbj_rnk].l; + fi + addto jdg_pct also sbj_pct shifted (jdg_wd, 0); + jdg_wd:=width jdg_pct; + sbj_rnk:=sbj_rnk+1; + endfor + sbj_num[@]:=sbj_rnk; + box_init jdg[@] (jdg_pct); + if sbj_num[@]>0: + jdg[@].l=sbj[@][0].l; + jdg[@].r=sbj[@][sbj_num[@]-1].r; + fi + fi +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Inference declarations +% + +vardef check_junction_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="0") + or (sty_str="1") + or (sty_str="2") + or (sty_str="3"): + sty_sfx + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " 0 (fully-interlacing),"& + " 1 (semi-interlacing),"& + " 2 (non-interlacing),"& + " 3 (user specified) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid junction style identifier"; + default + endgroup + fi +enddef; + +vardef check_alignment_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="l") + or (sty_str="c") + or (sty_str="r") + or (sty_str="u"): + sty_str + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " l (none),"& + " c (simple),"& + " r (double),"& + " u (dotted) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid alignment style identifier"; + default + endgroup + fi +enddef; + +vardef check_path_style (suffix sty_sfx) (expr default)= + save sty_str; + string sty_str; + sty_str:=str sty_sfx; + if (sty_str="0") + or (sty_str="1") + or (sty_str="2") + or (sty_str="3") + or (sty_str="4") + or (sty_str="5") + or (sty_str="6"): + sty_sfx + elseif (sty_str="_"): + default + else: + begingroup + drv_errhelp "Valid identifiers are"& + " 0 (none),"& + " 1 (simple),"& + " 2 (double),"& + " 3 (dotted),"& + " 4 (dashed),"& + " 5 (waved),"& + " 6 (TeX-dotted) and"& + " _ (default)."; + drv_errmessage sty_str&" is not a valid path style identifier"; + default + endgroup + fi +enddef; + +vardef opt_init[] @# expr arg= + if picture arg: + if arg<>nullpicture: + box_init @# (arg); + fi + elseif arg<>"": + box_init @# (mth_tex[@] arg); + fi +enddef; + +vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) + (suffix j_sty, a_sty, i_sty)= + % + % @: inference index + % + if known prm_num[@]: + drv_errhelp "An index can be used only once to declare an inference."; + drv_errmessage (decimal @)&" has been used already as an inference index"; + else: + % + % PRM: list of premise indices + % + save prm_rnk; + numeric prm_rnk; + prm_rnk:=0; + for prm_idx=PRM: + if prm_idx=@: + drv_errhelp "An inference index can not be used"& + " as one of its own premise indices."; + drv_errmessage "the inference index "&(decimal prm_idx)& + " is used as one of its own premise indices"; + elseif known ccl[prm_idx]: + drv_errhelp "An index can be used only once as a premise index."; + drv_errmessage (decimal prm_idx)&" has been used already as a"& + " premise index for inference declaration "&(decimal ccl[prm_idx]); + else: + if known prm_num[prm_idx]: + % + % roots list update + % + save root_idx; + numeric root_idx; + root_idx:=0; + forever: + exitif root[root_idx]=prm_idx; + root_idx:=root_idx+1; + endfor + forever: + exitif root_idx=root_num-1; + root[root_idx]:=root[root_idx+1]; + root_idx:=root_idx+1; + endfor + root_num:=root_num-1; + fi + ccl[prm_idx]:=@; + prm[@][prm_rnk]:=prm_idx; + prm_rnk:=prm_rnk+1; + fi + endfor + prm_num[@]:=prm_rnk; + if known ccl[@]: + % + % cycle detection + % + save ccl_idx, ccl_str; + numeric ccl_idx; + string ccl_str; + ccl_idx:=@; + ccl_str:=decimal ccl_idx; + forever: + ccl_idx:=ccl[ccl_idx]; + if ccl_idx>=0: + ccl_str:=(decimal ccl_idx)&", "&ccl_str; + fi + exitif (unknown ccl[ccl_idx]) or (ccl_idx=@); + endfor + if ccl_idx=@: + drv_errhelp "Inferences declarations can not be cyclic."; + drv_errmessage "inference declaration "&(decimal @)&" creates a"& + " cycle of inferences (indices "&ccl_str&" from conclusions to"& + " premises)"; + fi + else: + root[root_num]:=@; + root_num:=root_num+1; + fi + % + % lilb, rilb: inference labels + % + opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; + opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + % + % ldlb, rdlb: delimiter labels + % + opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; + opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + % + % j_sty, a_sty and i_sty: junction, alignment and inference styles + % + jct_sty[@]:=check_junction_style (j_sty, drv_jct_sty); + alg_sty[@]:=check_alignment_style (a_sty, drv_alg_sty); + iln_sty[@]:=check_path_style (i_sty, drv_iln_sty); + if drv_boxmode_on: + boxed[@]:=true; + fi + fi +enddef; + +vardef DCL[] (text PRM) (expr lilb, rilb, ldlb, rdlb) + (suffix j_sty, a_sty, i_sty) text SUB= + NFR[@] (PRM) (lilb, rilb, ldlb, rdlb, j_sty, a_sty, i_sty); + jgm[@] SUB; +enddef; + +vardef MVD[] (expr inf_num, lplb, rplb) (suffix a_sty, p_sty)= + if inf_num<1: + drv_errhelp "The minimal value is 1."; + drv_errmessage (decimal inf_num)&" is not a valid number of inference"& + " steps"; + else: + save aux_idx, aux_sty, phm_jdg; + numeric aux_idx, aux_sty; + picture phm_jdg; + aux_sty:=check_path_style (p_sty, drv_phm_sty); + phm_jdg:=nullpicture; + setbounds phm_jdg to (0, 0)--(iln_hg[aux_sty]-iln_dp[aux_sty], 0)--cycle; + aux_idx:=@; + for i=1 upto inf_num: + phm_idx:=phm_idx-1; + box_init jdg[phm_idx] (phm_jdg); + sbj_num[phm_idx]:=0; + NFR[phm_idx] (aux_idx) ("", "", "", "", 0, a_sty, 0); + aux_idx:=phm_idx; + endfor + src[@]:=phm_idx; + tgt[phm_idx]:=@; + phm_sty[phm_idx]:=aux_sty; + % + % lplb, rplb: phantom steps labels + % + opt_init[plb_sty[drv_sty]] l_plb[phm_idx] lplb; + opt_init[plb_sty[drv_sty]] r_plb[phm_idx] rplb; + phm_idx + fi +enddef; + +vardef bxd[]= + boxed[@]:=true; + @ +enddef; + +% +% Optional labels & shorthands +% + +numeric drv_jct_sty; % default junction style +string drv_alg_sty; % default junction style +numeric drv_iln_sty; % default inference line path-style +numeric drv_phm_sty; % default phantom steps path-style + +boolean drv_left_ilb; % inference labels on the left +boolean drv_left_dlb; % delimiter labels (hence delimiters) on the left +boolean drv_left_plb; % phantom steps labels on the left + +vardef arg_type expr arg= + if picture arg: + "picture" + else: + "string" + fi +enddef; + +vardef opt_lbls @# (text LBL) expr left_lbls= + save lbl_num, fst_lbl, snd_lbl; + numeric lbl_num; + lbl_num:=0; + for lbl=LBL: + if lbl_num=0: + scantokens (arg_type lbl) fst_lbl; + fst_lbl:=lbl; + elseif lbl_num=1: + scantokens (arg_type lbl) snd_lbl; + snd_lbl:=lbl; + else: + drv_errhelp "At most two labels can be specified:"& + " a left one and a right one."; + drv_errmessage "more than two labels have been specified"; + fi + lbl_num:=lbl_num+1; + endfor + if lbl_num=0: + string @#.l; + string @#.r; + @#.l:=""; + @#.r:=""; + elseif lbl_num=1: + if left_lbls: + scantokens (arg_type fst_lbl) @#.l; + string @#.r; + @#.l:=fst_lbl; + @#.r:=""; + else: + string @#.l; + scantokens (arg_type fst_lbl) @#.r; + @#.l:=""; + @#.r:=fst_lbl; + fi + else: + scantokens (arg_type fst_lbl) @#.l; + scantokens (arg_type snd_lbl) @#.r; + @#.l:=fst_lbl; + @#.r:=snd_lbl; + fi +enddef; + +vardef NFR_opt[] (text PRM) (text ILB) (text DLB) + (suffix j_sty, a_sty, i_sty)= + opt_lbls ilb (ILB) drv_left_ilb; + opt_lbls dlb (DLB) drv_left_dlb; + NFR[@] (PRM) (ilb.l, ilb.r, dlb.l, dlb.r, j_sty, a_sty, i_sty); +enddef; + +vardef DCL_opt[] (text PRM) (text ILB) (text DLB) + (suffix j_sty, a_sty, i_sty) text SUB= + NFR_opt[@] (PRM) (ILB) (DLB) (j_sty, a_sty, i_sty); + jgm[@] SUB; +enddef; + +vardef MVD_opt[] (expr inf_num) (text PLB) (suffix a_sty, p_sty)= + opt_lbls plb (PLB) drv_left_plb; + MVD[@] (inf_num, plb.l, plb.r, a_sty, p_sty) +enddef; + +% Nfr, Dcl & Mvd + +vardef Nfr[] (text PRM) (expr ilb, ldlb, rdlb) (suffix i_sty)= + NFR_opt[@] (PRM) (ilb) (ldlb, rdlb) (_, _, i_sty); +enddef; + +vardef Dcl[] (text PRM) (expr ilb, ldlb, rdlb) (suffix i_sty) text SUB= + Nfr[@] (PRM) (ilb, ldlb, rdlb, i_sty); + jgm[@] SUB; +enddef; + +vardef Mvd[] (expr inf_num, lplb, rplb) (suffix p_sty)= + MVD[@] (inf_num, lplb, rplb, _, p_sty) +enddef; + +% nfr, dcl & mvd + +vardef nfr[] (text PRM) (expr ilb) (suffix i_sty)= + NFR_opt[@] (PRM) (ilb) () (_, _, i_sty); +enddef; + +vardef dcl[] (text PRM) (expr ilb) (suffix i_sty) text SUB= + nfr[@] (PRM) (ilb, i_sty); + jgm[@] SUB; +enddef; + +vardef mvd[] (expr inf_num) (suffix p_sty)= + MVD_opt[@] (inf_num) () (_, p_sty) +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Pictured paths +% + +vardef dotted_aux (expr pth, dot_wd, dots_dist)= + save pth_len, pct; + numeric pth_len; + picture pct; + pth_len:=arclength pth; + pct:=nullpicture; + if dots_dist>0: + stp_num:=round ((pth_len-dot_wd)/dots_dist); + if stp_num>0: + stp_len:=(pth_len-dot_wd)/stp_num; + addto pct doublepath pth dashed dashpattern (on 0 off stp_len) + shifted (dot_wd/2, 0) withpen pencircle scaled dot_wd; + fi + fi + pct +enddef; + +primarydef pth dotted wd_dist= + dotted_aux(pth, xpart wd_dist, ypart wd_dist) +enddef; + +vardef expanded_aux (expr pth, scl, dir, stp_len)= + save pth_len, aux_len; + numeric pth_len, aux_len; + pth_len:=arclength pth; + if (stp_len>0) and (pth_len>stp_len): + aux_len:=pth_len/(pth_len div stp_len); + point arctime 0 of pth of pth shifted + (unitvector direction arctime 0 of pth of pth + rotated dir scaled scl).. + {direction arctime 0 of pth of pth} + for i=aux_len step aux_len until pth_len-aux_len: + point arctime i of pth of pth shifted + (unitvector direction arctime i of pth of pth + rotated dir scaled scl) + {direction arctime i of pth of pth}.. + endfor + point arctime pth_len of pth of pth shifted + (unitvector direction arctime pth_len of pth of pth + rotated dir scaled scl) + {direction arctime pth_len of pth of pth} + else: + pth + fi +enddef; + +primarydef pth expanded scl_dir_len= + expanded_aux (pth, + redpart scl_dir_len, greenpart scl_dir_len, bluepart scl_dir_len) +enddef; + +vardef waved_aux (expr pth, amp)= + save pth_len, mid; + numeric pth_len, mid; + pth_len:=arclength pth; + if (amp>0) and (pth_len>2(1+sqrt 5)*amp): + mid:=pth_len/(2(pth_len div (2(1+sqrt 5)*amp))); + point arctime 0 of pth of pth shifted + (unitvector direction arctime 0 of pth of pth + rotated -90 scaled amp) + {direction arctime 0 of pth of pth} + for i=mid step 2mid until pth_len: + ..point arctime i of pth of pth shifted + (unitvector direction arctime i of pth of pth + rotated 90 scaled amp) + {direction arctime i of pth of pth} + ..point arctime i+mid of pth of pth shifted + (unitvector direction arctime i+mid of pth of pth + rotated -90 scaled amp) + {direction arctime i+mid of pth of pth} + endfor + else: + pth + fi +enddef; + +primarydef pth waved amp= + waved_aux(pth, amp) +enddef; + +vardef drv_styled_aux[] expr pth= + save sty_idx, pth_len, pct; + numeric sty_idx, pth_len; + picture pct; + sty_idx:=check_path_style (@, 1); + pth_len:=arclength pth; + pct:=nullpicture; + if sty_idx=1: + interim linecap:=butt; + addto pct doublepath pth withpen drv_pen; + elseif sty_idx=2: + interim linecap:=butt; + addto pct doublepath pth + expanded (1.25rul_thk[drv_sty], 90, rul_thk[drv_sty]) + withpen drv_pen; + addto pct doublepath pth + expanded (1.25rul_thk[drv_sty], -90, rul_thk[drv_sty]) + withpen drv_pen; + elseif sty_idx=3: + addto pct also pth dotted (rul_thk[drv_sty], 2rul_thk[drv_sty]); + elseif sty_idx=4: + if rul_thk[drv_sty]>0: + interim linecap:=butt; + save dsh_num, dsh_len; + numeric dsh_num, dsh_len; + dsh_num:=round(pth_len/(3rul_thk[drv_sty])); + dsh_len:= + if odd dsh_num: + pth_len/dsh_num + else: + pth_len/(dsh_num+1) + fi; + addto pct doublepath pth dashed dashpattern(on dsh_len off dsh_len) + withpen drv_pen; + fi + elseif sty_idx=5: + interim linecap:=butt; + addto pct doublepath pth + waved 1.25rul_thk[drv_sty] withpen drv_pen; + elseif (sty_idx=6) and (pth_len>0): + addto pct also pth dotted (pdt_hg[drv_sty], pdt_wd[drv_sty]); + fi + pct +enddef; + +primarydef pth drv_styled sty= + drv_styled_aux[sty] pth +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Delimiters +% + +% +% 1. Global parameters +% + +string drv_l_dlm; % left delimiter LaTeX code +string drv_r_dlm; % right delimiter LaTeX code + +% +% 2. Macros +% + +vardef minmax_y[]=( + if drv_bot_roots: + if known ccl[@]: + ypart jdg[@].c-num_hg+iln_hg[(iln_sty[ccl[@]])] + +min_clr_scl*min_clr[drv_sty]/2 + else: + smin_y[@]-min_clr_scl*min_clr[drv_sty] + fi, + smax_y[@]+min_clr_scl*min_clr[drv_sty] + else: + smin_y[@]-min_clr_scl*min_clr[drv_sty], + if known ccl[@]: + ypart jdg[@].c-den_dp-iln_hg[(iln_sty[ccl[@]])] + -min_clr_scl*min_clr[drv_sty]/2 + else: + smax_y[@]+min_clr_scl*min_clr[drv_sty] + fi + fi) +enddef; + +vardef delim @# expr dlm_len= + save rule_str, dlm_str, dlm_pct, dlm_dp; + string rule_str, dlm_str; + picture dlm_pct; + numeric dlm_dp; + rule_str:="\rule{0bp}{"&(decimal(dlm_len/2+axis_hg[drv_sty]))&"bp}"; + dlm_str:= + if str @#="l": + "\left"&drv_l_dlm&rule_str&"\right." + else: + "\left."&rule_str&"\right"&drv_r_dlm + fi; + dlm_pct:=mth_tex[drv_sty] dlm_str; + dlm_dp:=depth dlm_pct; + if dlm_dp=0: + nullpicture + else: + begingroup + setbounds dlm_pct to + (xpart llcorner dlm_pct, dlm_dp) + --(xpart ulcorner dlm_pct, -dlm_dp) + --(xpart urcorner dlm_pct, -dlm_dp) + --(xpart lrcorner dlm_pct, dlm_dp) + --cycle; + dlm_pct yscaled (dlm_len/(2*height dlm_pct)) + endgroup + fi +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Checking, building, freezing (very inefficient, to be improved) +% + +% +% 1. Global parameters +% + +numeric min_clr_scl; % +numeric prm_skp_scl; % +numeric jdg_skp_scl; % +numeric ilb_skp_scl; % +numeric plb_skp_scl; % + +boolean drv_bot_roots; % +boolean drv_boxmode_on; % +boolean drv_fractionmode_on; % +string drv_axis_ref; % + +% +% 2. Macros +% + +% +% Checking +% + +vardef fraction_inference[]= + (prm_num[@]=0) + and (iln_sty[@]=0) + and (unknown l_ilb[@]) + and (unknown r_ilb[@]) + and drv_fractionmode_on +enddef; + +vardef drv_check_root[]= + if unknown jdg[@]: + drv_errhelp "An index must be used to declare a both a judgment and an"& + " inference."; + drv_errmessage (decimal @)&" has been used as an inference index but not"& + " as a judgment index"; + elseif unknown prm_num[@]: + drv_errhelp "An index must be used to declare a both a judgment and an"& + " inference."; + drv_errmessage (decimal @)&" has been used as a judgment index but not"& + " as an inference index"; + else: + save i_sty, prm_idx; + numeric i_sty, prm_idx; + i_sty:=iln_sty[@]; + for prm_rnk=0 upto prm_num[@]-1: + prm_idx:=prm[@][prm_rnk]; + drv_check_root[prm_idx]; + % + % numerators and denominators clearances + % The TEXbook, Appendix G, Rule 15d. + % + if drv_bot_roots: + num_hg:=max(num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].dp); + else: + den_dp:=min(den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].hg); + fi + endfor + if not fraction_inference[@]: + if drv_bot_roots: + den_dp:=min(den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[@].hg); + else: + num_hg:=max(num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[@].dp); + fi + fi + if unknown boxed[@]: + boxed[@]:=false; + fi + fi +enddef; + +vardef drv_check= + if root_num=0: + drv_errhelp "Well ..."; + drv_errmessage "no inference has been declared"; + else: + save root_idx; + numeric root_idx; + root_idx:=root[0]; + drv_check_root[root_idx]; + if root_num>1: + save root_str; + string root_str; + root_str:=decimal root_idx; + for idx=1 upto root_num-1: + root_idx:=root[idx]; + drv_check_root[root_idx]; + root_str:=root_str&", "&(decimal root_idx); + endfor + drv_message "warning, multiple root indices ("&root_str&")."; + fi + fi + drv_checked:=true; +enddef; + +% +% Building +% + +vardef drv_build_root[]= + % + % premises junction (from left to right) + % + for prm_rnk=0 upto prm_num[@]-1: + drv_build_root[prm[@][prm_rnk]]; + if prm_rnk>0: + save ll_idx, lr_idx, rl_idx, rr_idx; + save lmax_x, rmin_x, min_skp; + numeric ll_idx, lr_idx, rl_idx, rr_idx; + numeric lmax_x, rmin_x, min_skp; + ypart jdg[prm[@][prm_rnk-1]].c=ypart jdg[prm[@][prm_rnk]].c; + ll_idx:=prm[@][0]; + lr_idx:=prm[@][prm_rnk-1]; + rl_idx:=prm[@][prm_rnk]; + rr_idx:=prm[@][prm_rnk]; + lmax_x:=imax_x[lr_idx]; + rmin_x:=imin_x[rl_idx]; + min_skp[0]:=rmin_x-lmax_x; + forever: + exitif (unknown r_prm[lr_idx]) or (unknown l_prm[rl_idx]); + ll_idx:=l_prm[ll_idx]; + lr_idx:=r_prm[lr_idx]; + rl_idx:=l_prm[rl_idx]; + rr_idx:=r_prm[rr_idx]; + lmax_x:=max(lmax_x, imax_x[lr_idx]); + rmin_x:=min(rmin_x, imin_x[rl_idx]); + min_skp[0]:=min(min_skp[0], imin_x[rl_idx]-imax_x[lr_idx]); + endfor + min_skp[1]:=rmin_x-lmax_x; + if known r_prm[lr_idx]: + r_prm[rr_idx]:= r_prm[lr_idx]; + lmax_x:=smax_x[lr_idx]; + elseif known l_prm[rl_idx]: + l_prm[ll_idx]:=l_prm[rl_idx]; + rmin_x:=smin_x[rl_idx]; + fi + min_skp[2]:=rmin_x-lmax_x; + if jct_sty[@]<3: + min_skp[jct_sty[@]]=prm_skp_scl*prm_skp[drv_sty]; + fi + fi + endfor + if prm_num[@]>0: + l_prm[@]:=prm[@][0]; + r_prm[@]:=prm[@][prm_num[@]-1]; + fi + % + % judgment alignment + % + if prm_num[@]=0: + imin_x[@]:=xpart jdg[@].l-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + imax_x[@]:=xpart jdg[@].r+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + else: + save l_xref, r_xref; + l_xref= + if boxed[prm[@][0]]: + smin_x[prm[@][0]] + else: + xpart jdg[prm[@][0]].l + fi; + r_xref= + if boxed[prm[@][prm_num[@]-1]]: + smax_x[prm[@][prm_num[@]-1]] + else: + xpart jdg[prm[@][prm_num[@]-1]].r + fi; + if alg_sty[@]="l": + xpart jdg[@].l=l_xref; + elseif alg_sty[@]="c": + xpart jdg[@].c=(l_xref+r_xref)/2; + elseif alg_sty[@]="r": + xpart jdg[@].r=r_xref; + fi + imin_x[@]:=min(xpart jdg[@].l, l_xref) + -jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + imax_x[@]:=max(xpart jdg[@].r, r_xref) + +jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + fi + % + % inference line + % + save iln_wd, iln_pct; + numeric iln_wd; + picture iln_pct; + iln_wd:=imax_x[@]-imin_x[@]; + iln_pct:=((0, 0)--(iln_wd, 0)) drv_styled iln_sty[@]; + setbounds iln_pct to + (0, ypart llcorner iln_pct) + --(0, ypart ulcorner iln_pct) + --(iln_wd, ypart ulcorner iln_pct) + --(iln_wd, ypart llcorner iln_pct) + --cycle; % ! `linecap:=butt' and `linecap:=squared' -> same bounding box ! + box_init iln[@] (iln_pct); + xpart iln[@].c=(imin_x[@]+imax_x[@])/2; + % + % orientation, smin_y & smax_y + % + if drv_bot_roots: + ypart iln[@].c=ypart jdg[@].c-den_dp; + smin_y[@]:=ypart jdg[@].c+jdg[@].dp; + smax_y[@]:= + if iln_sty[@]=0: + ypart jdg[@].c+jdg[@].hg + else: + ypart iln[@].c+iln[@].hg + fi; + if prm_num[@]>0: + ypart iln[@].c=ypart jdg[prm[@][0]].c-num_hg; + for prm_rnk=0 upto prm_num[@]-1: + smax_y[@]:=max(smax_y[@], smax_y[prm[@][prm_rnk]]); + endfor; + fi + else: + ypart iln[@].c=ypart jdg[@].c-num_hg; + smin_y[@]:= + if iln_sty[@]=0: + ypart jdg[@].c+jdg[@].dp + else: + ypart iln[@].c+iln[@].dp + fi; + smax_y[@]:=ypart jdg[@].c+jdg[@].hg; + if prm_num[@]>0: + ypart iln[@].c=ypart jdg[prm[@][0]].c-den_dp; + for prm_rnk=0 upto prm_num[@]-1: + smin_y[@]:=min(smin_y[@], smin_y[prm[@][prm_rnk]]); + endfor; + fi + fi + % + % inference labels + % + if known l_ilb[@]: + l_ilb[@].r=iln[@].l shifted (-ilb_skp_scl*ilb_skp[drv_sty], 0); + imin_x[@]:=xpart l_ilb[@].l; + smin_y[@]:=min(smin_y[@], ypart l_ilb[@].c+l_ilb[@].dp); + smax_y[@]:=max(smax_y[@], ypart l_ilb[@].c+l_ilb[@].hg); + fi + if known r_ilb[@]: + r_ilb[@].l=iln[@].r shifted (ilb_skp_scl*ilb_skp[drv_sty], 0); + imax_x[@]:=xpart r_ilb[@].r; + smin_y[@]:=min(smin_y[@], ypart r_ilb[@].c+r_ilb[@].dp); + smax_y[@]:=max(smax_y[@], ypart r_ilb[@].c+r_ilb[@].hg); + fi + % + % phantom steps + % + if known tgt[@]: + save phm_pth, phm_pct; + path phm_pth; + picture phm_pct; + save top_y, mid_y, bot_y; + numeric top_y, bot_y; + if drv_bot_roots: + bot_y:=xpart minmax_y[@]+min_clr_scl*min_clr[drv_sty]/2; + top_y:=xpart minmax_y[tgt[@]]; + else: + bot_y:=ypart minmax_y[tgt[@]]; + top_y:=ypart minmax_y[@]-min_clr_scl*min_clr[drv_sty]/2; + fi + mid_y:=(top_y+bot_y)/2; + phm_pth:=(0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2); + phm_pct:=phm_pth drv_styled phm_sty[@]; + box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); + phm[@].c=(xpart jdg[@].c, mid_y); + imin_x[@]:=min(imin_x[@], xpart phm[@].l); + imax_x[@]:=max(imax_x[@], xpart phm[@].r); + % + % phantom steps labels + % + if known l_plb[@]: + l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); + imin_x[@]:=min(imin_x[@], xpart l_plb[@].l); + fi + if known r_plb[@]: + r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); + imax_x[@]:=max(imax_x[@], xpart r_plb[@].r); + fi + fi + % + % smin_x & smax_x + % + smin_x[@]:=imin_x[@]; + smax_x[@]:=imax_x[@]; + for prm_rnk=0 upto prm_num[@]-1: + smin_x[@]:=min(smin_x[@], smin_x[prm[@][prm_rnk]]); + smax_x[@]:=max(smax_x[@], smax_x[prm[@][prm_rnk]]); + endfor + % + % delimiters + % + if known l_dlb[@] or known r_dlb[@]: + save idx, mmy, min_y, max_y; + numeric idx, min_y, max_y; + pair mmy; + mmy:=minmax_y[@]; + min_y:=xpart mmy; + max_y:=ypart mmy; + if known l_dlb[@]: + box_init l_dlm[@] (delim l (max_y-min_y)); + l_dlm[@].r=(smin_x[@], (max_y+min_y)/2); + l_dlb[@].r=l_dlm[@].l; + smin_x[@]:=xpart l_dlb[@].l; + fi + if known r_dlb[@]: + box_init r_dlm[@] (delim r (max_y-min_y)); + r_dlm[@].l=(smax_x[@], (max_y+min_y)/2); + r_dlb[@].l=r_dlm[@].r; + smax_x[@]:=xpart r_dlb[@].r; + fi + fi + if (known l_dlb[@]) or boxed[@]: + idx:=@; + forever: + imin_x[idx]:=smin_x[@]; + exitif unknown l_prm[idx]; + idx:=l_prm[idx]; + endfor + fi + if (known r_dlb[@]) or boxed[@]: + idx:=@; + forever: + imax_x[idx]:=smax_x[@]; + exitif unknown r_prm[idx]; + idx:=r_prm[idx]; + endfor + fi +enddef; + +vardef drv_build= + if not drv_checked: + drv_check; + fi + for idx=0 upto root_num-1: + drv_build_root[root[idx]]; + endfor + drv_built:=true; +enddef; + +% +% Freezing +% + +vardef drv_freeze_root[]= + for prm_rnk=0 upto prm_num[@]-1: + drv_freeze_root[prm[@][prm_rnk]]; + endfor + for sbj_rnk=0 upto sbj_num[@]-1: + box_freeze sbj[@][sbj_rnk]; + endfor + forsuffixes sfx= + iln, jdg, phm, + l_dlb, l_dlm, l_ilb, l_plb, + r_dlb, r_dlm, r_ilb, r_plb: + if known sfx[@]: + box_freeze sfx[@]; + fi + endfor +enddef; + +vardef drv_freeze= + if not drv_built: + drv_build; + fi + save root_idx; + numeric root_idx; + root_idx:=root[0]; + if unknown iln[root_idx].c: + % + % default math axis + % + if drv_axis_ref="iln": + iln[root_idx].c=(0, axis_hg[drv_sty]); + else: % drv_axis_ref="jdg" + jdg[root_idx].c=(0, axis_hg[drv_sty]); + fi + drv_freeze_root[root_idx]; + fi + for idx=1 upto root_num-1: + root_idx:=root[idx]; + if unknown iln[root_idx].c: + smin_x[root_idx]=smax_x[root[idx-1]]+prm_skp_scl*prm_skp[drv_sty]; + ypart iln[root_idx].c=ypart iln[root[idx-1]].c; + fi + drv_freeze_root[root_idx]; + endfor + drv_frozen:=true; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Derivation tree pictures +% + +% +% 1. Global parameters +% + +boolean drv_proofmode_on; % +color prf_clr; % +color jdg_clr; % +color sbj_clr; % + +prf_clr:=.75background; % arbitrary +jdg_clr:=red; % arbitrary +sbj_clr:=blue; % arbitrary + +% +% 2. Macros +% + +vardef drv_tree_addto @# (expr idx) text draw_options= + for prm_rnk=0 upto prm_num[idx]-1: + drv_tree_addto @# (prm[idx][prm_rnk]) draw_options; + endfor + forsuffixes sfx= + jdg, phm, + l_dlb, l_dlm, l_ilb, l_plb, + r_dlb, r_dlm, r_ilb, r_plb: + if known sfx[idx]: + addto @# also sfx[idx] draw_options; + fi + endfor + if iln_sty[idx]>0: + addto @# also iln[idx] draw_options; + fi +enddef; + +vardef tt_nat[] expr nat= % typewriter typeface naturals + save nat_aux, nat_pct_wd, dgt_num, nat_pct; + numeric nat_aux, nat_pct_wd, dgt_num; + picture nat_pct; + nat_aux:=abs nat; + nat_pct:=nullpicture; + nat_pct_wd:=0; + dgt_num:=1; + forever: + exitif nat_aux div (10**dgt_num)=0; + dgt_num:=dgt_num+1; + endfor + for rnk:=1 upto dgt_num: + addto nat_pct also tt_dgt[@][nat_aux div (10**(dgt_num-rnk))] + shifted (nat_pct_wd, 0); + nat_pct_wd:=width nat_pct; + nat_aux:=nat_aux mod (10**(dgt_num-rnk)); + endfor + nat_pct shifted (0, -axis_hg[@]) +enddef; + +vardef prf_tree_addto @# expr idx= + for prm_rnk=0 upto prm_num[idx]-1: + prf_tree_addto @# (prm[idx][prm_rnk]); + endfor + if idx>=0: + box_init jdg_prf[idx] (tt_nat[2] idx); + jdg_prf[idx].r=jdg[idx].l; + box_freeze jdg_prf[idx]; + addto @# also jdg_prf[idx] withcolor jdg_clr; + addto @# doublepath jdg[idx].c withcolor jdg_clr + withpen pencircle scaled (2*pdt_hg[drv_sty]); + fi + for sbj_rnk=0 upto sbj_num[idx]-1: + box_init sbj_prf[idx][sbj_rnk] (tt_nat[3] sbj_rnk); + if odd sbj_rnk: + sbj_prf[idx][sbj_rnk].c shifted (0, sbj_prf[idx][sbj_rnk].hg)= + sbj[idx][sbj_rnk].c + shifted (0, -den_dp-min_clr_scl*min_clr[drv_sty]/2); + else: + sbj_prf[idx][sbj_rnk].c shifted (0, sbj_prf[idx][sbj_rnk].dp)= + sbj[idx][sbj_rnk].c + shifted (0, -num_hg+min_clr_scl*min_clr[drv_sty]/2); + fi + box_freeze sbj_prf[idx][sbj_rnk]; + addto @# also sbj_prf[idx][sbj_rnk] withcolor sbj_clr; + addto @# doublepath sbj[idx][sbj_rnk].c withcolor sbj_clr + withpen pencircle scaled pdt_hg[drv_sty]; + endfor +enddef; + +vardef drv_tree= + save pct; + picture pct; + pct:=nullpicture; + if not drv_frozen: + drv_freeze; + fi + for root_idx=0 upto root_num-1: + if drv_proofmode_on: + drv_tree_addto pct (root[root_idx]) withcolor prf_clr; + prf_tree_addto pct (root[root_idx]); + else: + drv_tree_addto pct (root[root_idx]); + fi + endfor + pct +enddef; + +vardef drv_bbox[]= + save min_x, max_x, mmy, min_y, max_y; + pair mmy; + numeric min_x, max_x, max_y, min_y; + if not drv_frozen: + drv_freeze; + fi + min_x:= + if known l_dlm[@].r: + xpart l_dlm[@].r + else: + smin_x[@] + fi-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + max_x:= + if known r_dlm[@].l: + xpart l_dlm[@].l + else: + smax_x[@] + fi+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + mmy:=minmax_y[@]; + min_y:=xpart mmy; + max_y:=ypart mmy; + (min_x, min_y)-- + (min_x, max_y)-- + (max_x, max_y)-- + (max_x, min_y)-- + cycle +enddef; + +vardef mth_axis @# (suffix ref_sfx) (expr idx)= + if not drv_frozen: + drv_freeze; + fi + if unknown prm_num[idx]: + drv_errhelp "An index must be used to declare an inference before it is"& + " used to set the math axis of a picture."; + drv_errmessage "no inference has been declared using index "&(decimal idx); + else: + save ref_str, yref; + string ref_str; + numeric yref; + ref_str:=str ref_sfx; + if ref_str="iln": + yref:=ypart iln[idx].c; + elseif ref_str="jdg": + yref:=ypart jdg[idx].c; + elseif ref_str="dlm": + if known l_dlm[idx]: + yref:=ypart l_dlm[idx].c; + elseif known r_dlm[idx]: + yref:=ypart r_dlm[idx].c; + else: + drv_errhelp "Well ..."; + drv_errmessage "no delimiter is attached to inference "&(decimal idx); + fi + else: + drv_errhelp "Valid identifiers are"& + " iln (inference line axis),"& + " jdg (judgment math-axis) and"& + " dlm (delimiter axis)."; + drv_errmessage (ref_str&" is not a valid reference type identifier"); + fi + if known yref: + @#:=@# shifted (0, axis_hg[drv_sty]-yref); + fi + fi +enddef; + +vardef drv_axis (suffix ref) (expr idx)= + mth_axis currentpicture (ref, idx); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Tunings +% + +vardef check_math_style (expr sty_str, default)= + if sty_str="\displaystyle": + 0 + elseif sty_str="\textstyle": + 1 + elseif sty_str="\scriptstyle": + 2 + elseif sty_str="\scriptscriptstyle": + 3 + else: + begingroup + drv_errhelp "Valid commands are"& + " \displaystyle,"& + " \textstyle,"& + " \scriptstyle and"& + " \scriptscriptstyle."; + drv_errmessage (sty_str&" is not a valid math-style command"); + default + endgroup + fi +enddef; + +vardef check_position_left (suffix pos_sfx) (expr default)= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if (pos_str="l"): + true + elseif (pos_str="r"): + false + else: + begingroup + drv_errhelp "Valid identifiers are l (left) and r (right)."; + drv_errmessage (pos_str&" is not a valid label position identifier"); + default + endgroup + fi +enddef; + +vardef check_mode_on (suffix status_sfx) (expr default)= + save status_str; + string status_str; + status_str:=str status_sfx; + if status_str="on": + true + elseif status_str="off": + false + else: + begingroup + drv_errhelp "Possible identifiers are on and off"; + drv_errmessage (status_str&" is not a valid status identifier"); + default + endgroup + fi +enddef; + +vardef drv_math_style (suffix typ_sfx) (expr sty_str)= + save typ_str, sty_idx; + string typ_str; + numeric sty_idx; + typ_str:=str typ_sfx; + if (typ_str<>"drv") + and (typ_str<>"jdg") + and (typ_str<>"ilb") + and (typ_str<>"dlb") + and (typ_str<>"plb"): + drv_errhelp "Valid identifiers are"& + " drv (derivation tree),"& + " jdg (judgment),"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (sty_str&" is not a valid component identifier"); + else: + sty_idx:=check_math_style (sty_str, 0); + if typ_str="drv": + drv_sty:=sty_idx; + else: + forsuffixes sfx=scantokens (typ_str&"_sty"): + for idx=0 upto 3: + sfx[idx]:=min(idx+sty_idx, 3); + endfor + endfor + fi + fi +enddef; + +vardef drv_scale (suffix scl_sfx) (expr scl)= + save scl_str; + string scl_str; + scl_str:=str scl_sfx; + if scl_str="clr": + min_clr_scl:=scl; + elseif scl_str="prm": + prm_skp_scl:=scl; + elseif (scl_str="jdg") or (scl_str="jgm"): % "jgm" is deprecated + jdg_skp_scl:=scl; + elseif (scl_str="ilb") or (scl_str="lbl"): % "lbl" is deprecated + ilb_skp_scl:=scl; + else: + drv_errhelp "Valid identifiers are"& + " clr,"& + " prm,"& + " jdg and"& + " ilb."; + drv_errmessage (scl_str&" is not a valid scale identifier"); + fi +enddef; + +vardef drv_junction_style suffix sty_sfx= + drv_jct_sty:=check_junction_style (sty_sfx, drv_jct_sty); +enddef; + +vardef drv_alignment_style suffix sty_sfx= + drv_alg_sty:=check_alignment_style (sty_sfx, drv_alg_sty); +enddef; + +vardef drv_path_style (suffix typ_sfx, sty_sfx)= + save typ_str; + string typ_str; + typ_str:=str typ_sfx; + if typ_str="iln": + drv_iln_sty:=check_path_style (sty_sfx, drv_iln_sty); + elseif typ_str="phm": + drv_phm_sty:=check_path_style (sty_sfx, drv_phm_sty); + else: + drv_errhelp "Valid identifiers are"& + " iln (inference line) and"& + " phm (phantom steps path)."; + drv_errmessage (typ_str&" is not a valid path-type identifier"); + fi +enddef; + +vardef drv_labels_position_aux (suffix typ_sfx, pos_sfx)= + save typ_str, idt_str, pos_str; + string typ_str, idt_str, pos_str; + typ_str:=str typ_sfx; + if typ_str="ilb": + drv_left_ilb:=check_position_left (pos_sfx, drv_left_ilb); + elseif typ_str="dlb": + drv_left_dlb:=check_position_left (pos_sfx, drv_left_dlb); + elseif typ_str="plb": + drv_left_plb:=check_position_left (pos_sfx, drv_left_plb); + else: + drv_errhelp "Valid identifiers are"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (typ_str&" is not a valid label-type identifier"); + fi +enddef; + +vardef drv_labels_position text ARG= + drv_labels_position_aux if pair ARG: ARG else: (ilb, ARG) fi; +enddef; + +vardef drv_roots_position suffix pos_sfx= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if pos_str="t": + drv_bot_roots:=false; + elseif pos_str="b": + drv_bot_roots:=true; + else: + drv_errhelp "Valid identifiers are"& + " t (top) and"& + " b (bottom)."; + drv_errmessage (pos_str&" is not a valid root position identifier"); + fi +enddef; + +vardef drv_axis_reference suffix ref_sfx= + save ref_str; + string ref_str; + ref_str:=str ref_sfx; + if (ref_str<>"iln") and (ref_str<>"jdg"): + drv_errhelp "Valid identifiers are iln (inference line axis) and"& + " jdg (judgment math-axis)."; + drv_errmessage (ref_str&" is not a valid reference identifier"); + else: + drv_axis_ref:=ref_str; + fi +enddef; + +vardef drv_delimiter (suffix pos_sfx) (expr dlm_str)= + if check_position_left (pos_sfx, true): + drv_l_dlm:=dlm_str; + else: + drv_r_dlm:=dlm_str; + fi +enddef; + +vardef drv_left_delimiter expr dlm_str= + drv_delimiter (l, dlm_str); +enddef; + +vardef drv_right_delimiter expr dlm_str= + drv_delimiter (r, dlm_str); +enddef; + +vardef drv_box_mode suffix status_sfx= + drv_boxmode_on:=check_mode_on (status_sfx, drv_boxmode_on); +enddef; + +vardef drv_fraction_mode suffix status_sfx= + drv_fractionmode_on:=check_mode_on (status_sfx, drv_fractionmode_on); +enddef; + +vardef drv_proof_mode suffix status_sfx= + drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Default settings +% + +drv_font_size "\normalsize"; +drv_math_style (drv, "\displaystyle"); +drv_math_style (jdg, "\textstyle"); +drv_math_style (ilb, "\scriptstyle"); +drv_math_style (dlb, "\textstyle"); +drv_math_style (plb, "\textstyle"); +drv_scale (clr, 1); +drv_scale (prm, 1); +drv_scale (jdg, 1); +drv_scale (ilb, 1); +drv_junction_style 1; +drv_alignment_style c; +drv_path_style (iln, 1); +drv_path_style (phm, 3); +drv_labels_position (ilb, r); +drv_labels_position (dlb, l); +drv_labels_position (plb, l); +drv_roots_position b; +drv_axis_reference iln; +drv_left_delimiter "\lbrace"; +drv_right_delimiter "\rbrace"; +drv_box_mode off; +drv_fraction_mode on; +drv_proof_mode off; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% LaTeX inclusion macro +% +% \drv includes a picture file in such a way that the baseline of the included +% picture coincides with the baseline of the inclusion point. The code for \drv +% was suggested by Josselin Noirel on the fr.comp.text.tex usenet group. +% +% \usepackage{graphicx} +% \makeatletter +% \def\Gin@def@bp#1\relax#2#3{\gdef#2{#3}} +% \newsavebox{\graphicsbox} +% \newcommand*{\drv}[1]{% +% \sbox{\graphicsbox}{\includegraphics{#1}}% +% \raisebox{\Gin@lly bp}% +% {\usebox{\graphicsbox}}} +% \makeatother diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index ce74180aef9..726dbcb175e 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -80,7 +80,7 @@ my @WorkingTLP = qw( doc-pictex docmfp doi doipubmed dotarrow dot2texi dottex doublestroke dox dozenal dpfloat dprogress drac draftcopy - draftwatermark dramatist dratex dtxgallery + draftwatermark dramatist dratex drv dtxgallery dtxtut duerer-latex dvdcoll dviasm dviincl dvipdfmx-def dvipsconfig dyntree ean13isbn easy easylist diff --git a/Master/tlpkg/tlpsrc/00texlive.autopatterns.tlpsrc b/Master/tlpkg/tlpsrc/00texlive.autopatterns.tlpsrc index 21ad14423f7..7dbc0d9518c 100644 --- a/Master/tlpkg/tlpsrc/00texlive.autopatterns.tlpsrc +++ b/Master/tlpkg/tlpsrc/00texlive.autopatterns.tlpsrc @@ -1,5 +1,5 @@ category TLCore -shortdesc Defines the default patterns per category used by tlpsrc2tlpdb. +shortdesc Defines category patterns used by tlpsrc-to-tlpdb conversion longdesc As can be seen, the syntax here is slightly different than a longdesc normal tlpsrc file: an additional first argument specifies the longdesc category for this pattern, and a final %NAME% is replaced with diff --git a/Master/tlpkg/tlpsrc/00texlive.config.tlpsrc b/Master/tlpkg/tlpsrc/00texlive.config.tlpsrc index 4c06e600bda..6a93411728f 100644 --- a/Master/tlpkg/tlpsrc/00texlive.config.tlpsrc +++ b/Master/tlpkg/tlpsrc/00texlive.config.tlpsrc @@ -1,5 +1,5 @@ category TLCore -shortdesc TeX Live network archive option settings. +shortdesc TeX Live network archive option settings longdesc This package contains configuration options for the TeX Live archive longdesc If container_split_{doc,src}_files occurs in the depend lines the longdesc {doc,src} files are split into separate containers (.tar.xz) diff --git a/Master/tlpkg/tlpsrc/00texlive.image.tlpsrc b/Master/tlpkg/tlpsrc/00texlive.image.tlpsrc index c3a319aba3f..a0b74de5254 100644 --- a/Master/tlpkg/tlpsrc/00texlive.image.tlpsrc +++ b/Master/tlpkg/tlpsrc/00texlive.image.tlpsrc @@ -1,5 +1,5 @@ category TLCore -shortdesc TeX Live files only in the source repository and DVD image. +shortdesc TeX Live files only in the source repository and DVD image longdesc This package collects some files which are not caught by any of the longdesc other TL packages. Its purpose is to make the file coverage longdesc check happy. The files here are not copied by the installer diff --git a/Master/tlpkg/tlpsrc/00texlive.installation.tlpsrc b/Master/tlpkg/tlpsrc/00texlive.installation.tlpsrc index af9c21cbd22..0d1bacb8113 100644 --- a/Master/tlpkg/tlpsrc/00texlive.installation.tlpsrc +++ b/Master/tlpkg/tlpsrc/00texlive.installation.tlpsrc @@ -1,5 +1,5 @@ category TLCore -shortdesc TeX Live configuration settings. +shortdesc TeX Live configuration settings longdesc This package serves two purposes: longdesc longdesc 1. at installation time the present values are taken as default for diff --git a/Master/tlpkg/tlpsrc/00texlive.installer.tlpsrc b/Master/tlpkg/tlpsrc/00texlive.installer.tlpsrc index c674b01ec48..0ef468ea54b 100644 --- a/Master/tlpkg/tlpsrc/00texlive.installer.tlpsrc +++ b/Master/tlpkg/tlpsrc/00texlive.installer.tlpsrc @@ -1,5 +1,5 @@ category TLCore -shortdesc TeX Live standalone installer package. +shortdesc TeX Live standalone installer package longdesc This package defines the files to go into the installer longdesc archives (install-tl-unx.tar.gz, install-tl.zip) built longdesc by the tl-make-installer script. Most of what's here is also diff --git a/Master/tlpkg/tlpsrc/collection-metapost.tlpsrc b/Master/tlpkg/tlpsrc/collection-metapost.tlpsrc index d335748ca0c..864c1df96cb 100644 --- a/Master/tlpkg/tlpsrc/collection-metapost.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-metapost.tlpsrc @@ -5,6 +5,7 @@ depend bbcard depend blockdraw_mp depend bpolynomial depend cmarrows +depend drv depend dviincl depend emp depend epsincl diff --git a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc index b2c904a9483..bdb3ae8b387 100644 --- a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc @@ -1,5 +1,5 @@ category Collection -shortdesc Graphics packages and programs. +shortdesc Graphics packages and programs depend asyfig depend autoarea depend bardiag diff --git a/Master/tlpkg/tlpsrc/drv.tlpsrc b/Master/tlpkg/tlpsrc/drv.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/drv.tlpsrc diff --git a/Master/tlpkg/tlpsrc/luatex.tlpsrc b/Master/tlpkg/tlpsrc/luatex.tlpsrc index b132cab5eeb..8188bfd1256 100644 --- a/Master/tlpkg/tlpsrc/luatex.tlpsrc +++ b/Master/tlpkg/tlpsrc/luatex.tlpsrc @@ -1,5 +1,5 @@ category TLCore -shortdesc The LuaTeX engine. +shortdesc The LuaTeX engine longdesc LuaTeX is an extended version of pdfTeX using Lua as an embedded longdesc scripting language. The LuaTeX projects main objective is to provide longdesc an open and configurable variant of TeX while at the same time |