diff options
Diffstat (limited to 'Master/texmf-dist/doc')
15 files changed, 3487 insertions, 584 deletions
diff --git a/Master/texmf-dist/doc/metapost/drv/README b/Master/texmf-dist/doc/metapost/drv/README index 31246497d23..05bd4192cf0 100644 --- a/Master/texmf-dist/doc/metapost/drv/README +++ b/Master/texmf-dist/doc/metapost/drv/README @@ -1,11 +1,11 @@ -drv.mp - derivation trees with MetaPost -version 0.94 +drv - derivation trees with MetaPost +version 0.95 Licence lppl Description -drv.mp is a set of MetaPost macros for typesetting derivation trees (such as +drv 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. diff --git a/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp index 8c5e207cafe..515cb68a6c7 100644 --- a/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp +++ b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.mp @@ -1,6 +1,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Structure of a MetaPost file using drv.mp +% Structure of a MetaPost file using drv % 1. Preamble % input drv; % verbatimtex %&latex @@ -63,6 +63,9 @@ verbatimtex %&latex %\usepackage{fourier} % Utopia & Fourier math %\usepackage[utopia]{mathdesign} % Utopia & Math Design math +\newcommand{\limp}{\thinspace{\multimapinv}\thinspace} +\newcommand{\rimp}{\thinspace{\multimap}\thinspace} + \begin{document} etex; @@ -73,6 +76,11 @@ etex; % % +% Uncomment the following line to experiment the radial mode. +% drv_radial_mode on; +% + +% % title page % @@ -233,6 +241,12 @@ dcl 0 () ("f", 1) "A", "\vdash", "B"; draw drv_tree; endfig; +beginfig(141) +dcl 0 () ("f", 1) "A\vdash B"; +dcl 1 (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"; @@ -273,11 +287,26 @@ draw drv_tree; endfig; vardef auxbox[]= - ((sub_min_x[@], ypart iln[ccl[@]].c+iln[ccl[@]].hg)-- - (sub_min_x[@], sub_max_y[@])-- - (sub_max_x[@], sub_max_y[@])-- - (sub_max_x[@], ypart iln[ccl[@]].c+iln[ccl[@]].hg)-- - cycle) shifted (0, min_clr_scl*min_clr[drv_sty]/2) + if drv_radialmode_on: + save l_ngl, r_ngl, min_rad, max_rad, tnum; + numeric l_ngl, r_ngl, min_rad, max_rad, tnum; + l_ngl:=ngl_part sub_lmost_ppt[@]; + r_ngl:=ngl_part sub_rmost_ppt[@]; + tnum:=if bot_jdg[@]: - fi 1; + min_rad:=iln[ccl[@]].rad+iln[ccl[@]].hg+min_clr_scl*min_clr[drv_sty]/2; + max_rad:=sub_max_rad[@]+min_clr_scl*min_clr[drv_sty]/2; + ((dir l_ngl) scaled min_rad--(dir l_ngl) scaled max_rad + {dir (l_ngl+tnum*90)} .. {dir (r_ngl+tnum*90)} + (dir r_ngl) scaled max_rad--(dir r_ngl) scaled min_rad + {dir (r_ngl-tnum*90)} .. {dir (l_ngl-tnum*90)} + cycle) shifted jdg[@].org + else: + ((sub_min_x[@], ypart iln[ccl[@]].c+iln[ccl[@]].hg)-- + (sub_min_x[@], sub_max_y[@])-- + (sub_max_x[@], sub_max_y[@])-- + (sub_max_x[@], ypart iln[ccl[@]].c+iln[ccl[@]].hg)-- + cycle) shifted (0, min_clr_scl*min_clr[drv_sty]/2) + fi enddef; beginfig(162) @@ -1041,7 +1070,7 @@ 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 background withpen drv_pen scaled 2; draw iln[0] withcolor (1, 0, 0); endfig; @@ -1081,7 +1110,7 @@ endfig; % a fraction % -drv_math_style (drv, "\textstyle"); +drv_font_size "\huge"; drv_scale (jgm, 0); beginfig(400) @@ -1090,7 +1119,7 @@ dcl 1 (0) ("", 1) "\delta"; draw drv_tree; endfig; -drv_math_style (drv, "\displaystyle"); +drv_font_size "\normalsize"; drv_scale (jgm, 1); % @@ -1171,16 +1200,16 @@ endfig; % 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)) ("", _); +jgm 0 "a"; + jgm 1 "b"; + jgm 2 "cccccc"; + jgm 3 "ddd"; + jgm 4 "eeeeeeeee"; +nfr 0 (1, MVD 4 (5, "", "F", r, 4)) ("", _); + nfr 1 (MVD 2 (2, "G", "", l, 3), 3) ("", _); + nfr 2 () ("", _); + nfr 3 () ("", _); + nfr 4 () ("", _); draw drv_tree; endfig; @@ -1371,12 +1400,20 @@ endfig; 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.}"; +jgm 2 "\text{You may check that"& + if drv_radialmode_on: + " the angle between the two dots above is 45$^\circ$.}" + else: + " the distance between the two dots above is 5 cm.}" + fi; NFR 0 () ("", "", "", "", _, _, _); NFR 1 () ("", "", "", "", _, _, _); NFR 2 (0, 1) ("", "", "", "", 3, _, _); % caution: 3 -xpart jdg[1].c=xpart jdg[0].c+5cm; +if drv_radialmode_on: + jdg[1].lng=jdg[0].rng-45; +else: + xpart jdg[1].c=xpart jdg[0].c+5cm; +fi draw drv_tree; endfig; @@ -1391,8 +1428,13 @@ 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; +if drv_radialmode_on: + sbj[1][1].cng=sbj[0][1].cng; + sbj[2][1].cng=sbj[1][1].cng; +else: + xpart sbj[1][1].c=xpart sbj[0][1].c; + xpart sbj[2][1].c=xpart sbj[1][1].c; +fi draw drv_tree; endfig; @@ -1403,8 +1445,13 @@ 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; +if drv_radialmode_on: + sbj[1][1].lng=sbj[0][1].rng; + sbj[2][1].lng=sbj[1][1].rng; +else: + xpart sbj[1][1].l=xpart sbj[0][1].r; + xpart sbj[2][1].l=xpart sbj[1][1].r; +fi draw drv_tree; endfig; @@ -1427,6 +1474,326 @@ draw drv_tree; endfig; % +% derivation forests +% + +beginfig(530) +% first tree +dcl 10 () ("", _) "a"; +% second tree +dcl 20 (21, 22) ("", _) "d"; + dcl 21 () ("", _) "b"; + dcl 22 () ("", _) "c"; +draw drv_tree; +endfig; + +beginfig(531) +% first tree +dcl 10 () ("", _) "a"; +% second tree +dcl 20 (21, 22) ("", _) "d"; + dcl 21 () ("", _) "b"; + dcl 22 () ("", _) "c"; +% relative positionning +if drv_radialmode_on: + jdg[10].rad=jdg[22].rad; +else: + ypart jdg[10].c=ypart jdg[22].c; +fi +draw drv_tree; +endfig; + +beginfig(532) +% first tree +dcl 10 () ("", _) "a"; +% second tree +dcl 20 (21, 22) ("", _) "d"; + dcl 21 () ("", _) "b"; + dcl 22 () ("", _) "c"; +% relative positionning +if drv_radialmode_on: + iln[10].rng=iln[20].lng; +else: + xpart iln[10].r=xpart iln[20].l; +fi +draw drv_tree; +endfig; + +% +% drv_root +% + +beginfig(533) +% first tree +dcl 10 () ("", _) "a"; +% second tree +dcl 20 (21, 22) ("", _) "d"; + dcl 21 () ("", _) "b"; + dcl 22 () ("", _) "c"; +drv_root (20, t); % root at top! +draw drv_tree; +endfig; + +drv_left_delimiter "\downarrow"; +drv_right_delimiter "\uparrow"; + +beginfig(540) +% first tree +jgm 10 "A\vdash D"; +Nfr 10 (11, 14) ("\circ", "h\circ (g\circ f)", "", 1); + dcl 11 (12, 13) ("\circ", 1) "A\vdash C"; + dcl 12 () ("f", 2) "A\vdash B"; + dcl 13 () ("g", 3) "B\vdash C"; + dcl 14 () ("h", 4) "C\vdash D"; +% second tree +jgm 20 "\phantom{A\vdash D}"; +Nfr 20 (21, 22) ("\circ", "", "(h\circ g)\circ f", 1); + dcl 21 () ("f", 2) "A\vdash B"; + dcl 22 (23, 24) ("\circ", 1) "B\vdash D"; + dcl 23 () ("g", 3) "B\vdash C"; + dcl 24 () ("h", 4) "C\vdash D"; +drv_root (20, t); % root at top! +% overlapping +jdg[10].c=jdg[20].c; +draw drv_tree; +endfig; + +drv_left_delimiter "\lbrace"; +drv_right_delimiter "\rbrace"; + +% +% drv_radial_mode +% + +drv_radial_mode on; + +beginfig(550) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 () ("h", 4) "C\vdash D"; +dcl 3 (1, 2) ("\circ", 1) "B\vdash D"; +dcl 4 (0, 3) ("\circ", 1) "A\vdash D"; +draw drv_tree; +endfig; + +drv_roots_position t; + +beginfig(551) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 () ("h", 4) "C\vdash D"; +dcl 3 (1, 2) ("\circ", 1) "B\vdash D"; +dcl 4 (0, 3) ("\circ", 1) "A\vdash D"; +draw drv_tree; +endfig; + +drv_roots_position b; +drv_radial_mode off; + +beginfig(552) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 () ("h", 4) "C\vdash D"; +dcl 3 (1, 2) ("\circ", 1) "B\vdash D"; +dcl 4 (0, 3) ("\circ", 1) "A\vdash D"; +draw drv_tree; +endfig; + +drv_roots_position t; + +beginfig(553) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 () ("h", 4) "C\vdash D"; +dcl 3 (1, 2) ("\circ", 1) "B\vdash D"; +dcl 4 (0, 3) ("\circ", 1) "A\vdash D"; +draw drv_tree; +endfig; + +drv_roots_position b; + +% +% drv_scale (crv, ); +% + +drv_radial_mode on; +drv_scale (crv, 0.5); + +beginfig(560) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 (0, 1) ("\circ", 1) "A\vdash C"; +draw drv_tree; +endfig; + +drv_scale (crv, 1); + +beginfig(561) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 (0, 1) ("\circ", 1) "A\vdash C"; +draw drv_tree; +endfig; + +drv_scale (crv, 2); + +beginfig(562) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 (0, 1) ("\circ", 1) "A\vdash C"; +draw drv_tree; +endfig; + +drv_scale (crv, 4); + +beginfig(563) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 (0, 1) ("\circ", 1) "A\vdash C"; +draw drv_tree; +endfig; + +drv_scale (crv, 1); +drv_radial_mode off; + +% +% drv_azimuth +% + +drv_radial_mode on; +drv_azimuth 120; + +beginfig(570) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 (0, 1) ("\circ", 1) "A\vdash C"; +draw drv_tree; +endfig; + +drv_azimuth 90; + +beginfig(571) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 (0, 1) ("\circ", 1) "A\vdash C"; +draw drv_tree; +endfig; + +drv_azimuth 60; + +beginfig(572) +dcl 0 () ("f", 2) "A\vdash B"; +dcl 1 () ("g", 3) "B\vdash C"; +dcl 2 (0, 1) ("\circ", 1) "A\vdash C"; +draw drv_tree; +endfig; + +drv_azimuth 90; +drv_radial_mode off; + +% +% Size matters - Part 3 +% + +drv_radial_mode on; + +beginfig(580) +dcl 0 () ("", 0) "\textsc{Size matters -- Part 3}"; +dcl 1 (0) ("", 1) "\text{How could this very long judgment fit on the page"& + " without being desperately bent into a circle arc ?}"; +draw drv_tree; +endfig; + +drv_radial_mode off; + +% +% User specified junction and alignment styles +% + +drv_radial_mode on; + +beginfig(590) % "\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 +sbj[1][1].cng=sbj[0][1].cng; +sbj[2][1].cng=sbj[1][1].cng; +draw drv_tree; +endfig; + +beginfig(591) % "\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 +sbj[1][1].lng=sbj[0][1].rng; +sbj[2][1].lng=sbj[1][1].rng; +draw drv_tree; +endfig; + +drv_radial_mode off; + +% +% example - triple unit +% + +string id, Llimp, Rlimp, Lrimp, Rrimp; +id:="\text{id}"; +Llimp:="\overset{\multimapinv}{\eta}"; +Rlimp:="\overset{\multimapinv}{\varepsilon}"; +Lrimp:="\overset{\multimap}{\eta}"; +Rrimp:="\overset{\multimap}{\varepsilon}"; + +beginfig(600) +jgm 10 "1\limp(a\rimp 1)\otimes\bigl(1\limp(a\rimp 1)\bigr)\rimp 1\vdash 1"; + jgm 11 "1\limp(a\rimp 1)\vdash 1\limp(a\rimp 1)"; + jgm 12 "1\limp(a\rimp 1)\otimes a\rimp 1\vdash 1"; + jgm 13 "a\rimp 1\vdash a\rimp 1"; + jgm 14 "a\otimes a\rimp 1\vdash 1"; + jgm 15 "a\vdash a"; + jgm 16 "1\vdash 1"; + jgm 17 "1\vdash 1"; + jgm 18 "1\vdash 1"; +nfr 10 (11, 18) (Lrimp, 1); + nfr 11 (12) (Rlimp, 1); + nfr 12 (13, 17) (Llimp, 1); + nfr 13 (14) (Rrimp, 1); + nfr 14 (15, 16) (Lrimp, 1); + nfr 15 () (id, 1); + nfr 16 () (id, 1); + nfr 17 () (id, 1); + nfr 18 () (id, 1); +draw drv_tree; +endfig; + +beginfig(601) +jgm 20 "1\limp(a\rimp 1)\otimes\bigl(1\limp(a\rimp 1)\bigr)\rimp 1\vdash 1"; + jgm 21 "\bigl(1\limp(a\rimp 1)\bigr)\rimp 1\vdash a\rimp 1"; + jgm 22 "a\otimes\bigl(1\limp(a\rimp 1)\bigr)\rimp 1\vdash 1"; + jgm 23 "a\vdash 1\limp(a\rimp 1)"; + jgm 24 "a\otimes a\rimp 1\vdash 1"; + jgm 25 "a\vdash a"; + jgm 26 "1\vdash 1"; + jgm 27 "1\vdash 1"; + jgm 28 "1\vdash 1"; +nfr 20 (21, 28) (Llimp, 1); + nfr 21 (22) (Rrimp, 1); + nfr 22 (23, 27) (Lrimp, 1); + nfr 23 (24) (Rlimp, 1); + nfr 24 (25, 26) (Lrimp, 1); + nfr 25 () (id, 1); + nfr 26 () (id, 1); + nfr 27 () (id, 1); + nfr 28 () (id, 1); +draw drv_tree; +endfig; + +% % example - Restall % @@ -1438,7 +1805,7 @@ Land1:="\wedge L_1"; Land2:="\wedge L_2"; Rand:="\wedge R"; -beginfig(530) +beginfig(610) 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"; @@ -1455,12 +1822,12 @@ jgm 0 "p\wedge(q\vee(r_1\wedge r_2))\vdash p\wedge(q\vee(r_1\wedge 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 3 (bxd 4) (Land2, 1); % fig. 611 -> nfr 3 (mvd 4 (1, 3)) + nfr 4 (5, 7) (Lor, 1); % fig. 611 -> 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 7 (bxd 8) (Ror2, 1); % fig. 611 -> nfr 7 (mvd 8 (1, 3)) + nfr 8 (9, 11) (Rand, 1); % fig. 611 -> Nfr nfr 9 (10) (Land1, 1); nfr 10 () ("", 0); nfr 11 (12) (Land2, 1); @@ -1470,7 +1837,7 @@ fill drv_bbox 8 withcolor (236, 211, 185)/255; draw drv_tree; endfig; -beginfig(531) +beginfig(611) 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"; @@ -1514,7 +1881,7 @@ vardef mix[]= "\textit{mix}("&(decimal @)&")" enddef; -beginfig(540) +beginfig(620) 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"; @@ -1577,13 +1944,14 @@ drv_scale (prm, 1); drv_math_style (ilb, "\textstyle"); drv_labels_position (ilb, l); drv_scale (clr, 1.5); +drv_axis_reference jdg; string neg, par, otm; neg:="^\bot"; par:="\mathbin{\bindnasrepma}"; % from stmaryrd.sty otm:="\otimes"; -beginfig(550) +beginfig(630) % 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, ")", ")"; @@ -1631,10 +1999,10 @@ draw sbj[4][4].c {down} .. sbj[4][4].c shifted (0, -num_hg); drawoptions (); -draw drv_tree; % fig. 551 -> draw jdg[4]; +draw drv_tree; % fig. 631 -> draw jdg[4]; endfig; -beginfig(551) +beginfig(631) % 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, ")", ")"; @@ -1682,15 +2050,16 @@ draw sbj[4][4].c {down} .. sbj[4][4].c shifted (0, -num_hg); drawoptions (); -draw jdg[4]; % fig. 550 -> draw drv_tree; +draw jdg[4]; % fig. 630 -> draw drv_tree; endfig; drv_math_style (ilb, "\scriptstyle"); drv_labels_position (ilb, r); drv_scale (clr, 1); +drv_axis_reference iln; % -% a continued fraction +% example - a continued fraction % drv_math_style (ilb, "\textstyle"); @@ -1700,9 +2069,7 @@ drv_labels_position (ilb, l); drv_roots_position t; drv_box_mode on; -drv_font_size "\normalsize"; - -beginfig(560) +beginfig(640) dcl 0 (1) ("1+", 1) "a"; dcl 1 (2) ("2+", 1) "b"; dcl 2 (3) ("3+", 1) "c"; diff --git a/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex index 02d0f8376c0..6f2fff63c77 100644 --- a/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex +++ b/Master/texmf-dist/doc/metapost/drv/doc/drv-guide.tex @@ -40,16 +40,24 @@ \usepackage{fancyvrb} \fvset{fontsize=\small} \usepackage{color} -\definecolor{myblue}{rgb}{0,0,.5} +\definecolor{myblue}{rgb}{.0,.0,.5} +\definecolor{mygrey}{rgb}{.75,.75,.75} \usepackage{hyperref} \hypersetup{colorlinks=true} \hypersetup{citecolor=myblue} \hypersetup{linkcolor=myblue} \hypersetup{urlcolor=myblue} -\hypersetup{pdftitle={drv.mp - derivation trees with MetaPost}} +\hypersetup{pdftitle={drv - derivation trees with MetaPost}} \hypersetup{pdfauthor={Laurent M\'ehats}} - +\hypersetup{pdfkeywords={% +derivation trees, +proof trees, +deduction trees, +sequent proofs, +natural deduction, +latex, +metapost}} % Picture inclusion macro: \drv % % \drv includes a picture file in such a way that the baseline of the included @@ -71,16 +79,18 @@ \newcommand{\tbs}{\textbackslash} \newcommand{\resplap}{\llap{\textrm{\emph{resp. }}}} -\title{\texttt{drv.mp}\\ +\title{\texttt{drv}\\ derivation trees with \MP% -\thanks{You don't need to know \MP\ to use this package.}\\ +\thanks{Available on +\href{http://www.ctan.org/tex-archive/graphics/metapost/contrib/macros/drv/} +{CTAN}. 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.) +\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?subject=[drv 0.94]} +{\small\href{mailto:laurent.mehats@gmail.com?subject=[drv 0.95]} {\texttt{laurent.mehats@gmail.com}}}} -\date{documented version: 0.94} +\date{documented version: 0.95} \pagestyle{myheadings} \renewcommand{\sectionmark}[1]{% @@ -103,7 +113,7 @@ Last update: \today.}}} \section{Usage\label{sec-usage}} % % -\subsection{Structure of a \MP\ file using \texttt{drv.mp}% +\subsection{Structure of a \MP\ file using \texttt{drv}% \label{sec-structure}} % % @@ -120,7 +130,7 @@ Last update: \today.}}} \begin{Verbatim}[commandchars=\\\{\}] \param{optional \texttt{drv} tunings} beginfig(\param{index}) - \param{judgment \& inference declarations} + \param{judgment and inference declarations} draw drv_tree; \param{optional extra \MP\ code} endfig; @@ -143,14 +153,14 @@ You have to run \emph{at least twice} \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} +first run \MP\ collects the \LaTeX\ code generated by \texttt{drv} 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 +\texttt{drv}/\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 @@ -164,11 +174,11 @@ 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} +\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 +However \texttt{drv} 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 @@ -189,10 +199,10 @@ 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}} +\section{Judgment and inference declarations\label{sec-declarations}} % % -\subsection{\texttt{jgm} \& \texttt{nfr}\label{sec-jgm-nfr}} +\subsection{\texttt{jgm} and \texttt{nfr}\label{sec-jgm-nfr}} % % \texttt{jgm \param{nat} \param{str list}}\\ @@ -210,15 +220,15 @@ The code for \texttt{\tbs{}drv} was suggested by Josselin \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). +conclusion is the index \param{nat} judgment (you can declare a judgment +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} +\paragraph{First example\label{fig-110}} % % %\begin{multicols}{2} @@ -435,7 +445,8 @@ draw drv_tree; endfig; beginfig(141) -dcl 0 () ("f", 1) "A", "\vdash", "B"; +dcl 0 () ("f", 1) "A\vdash B"; +dcl 1 (0) ("f", 1) "A", "\vdash", "B"; draw drv_tree; endfig; \end{Verbatim} @@ -472,7 +483,7 @@ endfig; \end{gather*} % % -\subsection{\texttt{bxd} \& \texttt{mvd}\label{sec-bxd-mvd}} +\subsection{\texttt{bxd} and \texttt{mvd}\label{sec-bxd-mvd}} % % \paragraph{\texttt{bxd}} @@ -559,7 +570,7 @@ endfig; %\texttt{drv\_path\_style} macro (see~\S~\ref{sec-path-style}). % % -\subsection{Sub-tree delimiters \& labels\label{sec-sub-tree}} +\subsection{Sub-tree delimiters and labels\label{sec-sub-tree}} % % \paragraph{\texttt{Nfr}} @@ -579,14 +590,15 @@ enables the typesetting of delimiters.\\[1ex] {\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. +\texttt{""} then \texttt{Nfr} behaves exactly the same way as \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) @@ -676,7 +688,7 @@ endfig; % % \texttt{drv} tuning macros set the parameters according to which derivation -trees are typeset. All these macros have to be called outside figure +trees are typeset. You have to call these macros \emph{outside} figure environments (delimited by ``\texttt{beginfig(\param{index})}, \texttt{endfig;}'' pairs). % @@ -860,7 +872,7 @@ determines the math-style of numerators and denominators. \subsection{\texttt{drv\_junction\_style}\label{sec-junction-style}} % % -This macro sets the default way the premises of an inference have to be +This macro sets the default way the premises of an inference are horizontally joined.\\[1ex] \texttt{drv\_junction\_style \param{id}}\\ \begin{tabular}{ll} @@ -886,7 +898,7 @@ horizontally joined.\\[1ex] \subsection{\texttt{drv\_alignment\_style}\label{sec-alignment-style}} % % -This macro sets the default way a judgment has to be horizontally aligned +This macro sets the default way a judgment is horizontally aligned relatively to its premises.\\[1ex] \texttt{drv\_alignment\_style \param{id}}\\ \begin{tabular}{ll} @@ -986,15 +998,15 @@ taking optional label arguments (see~\S~\ref{sec-labels}). % % 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 +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 + {\tt jdg}&root judgment math axis \end{tabular} \end{tabular} \begin{gather*} @@ -1006,7 +1018,7 @@ 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}% +\subsection{\texttt{drv\_left\_delimiter} and \texttt{drv\_right\_delimiter}% \label{sec-delimiters}} % % @@ -1088,11 +1100,11 @@ typeset as& \subsection{\texttt{drv\_fraction\_mode}\label{sec-fraction-mode}} % % -\nopagebreak\parbox{\textwidth}{\texttt{drv.mp} typesets derivation trees in +\nopagebreak\parbox{\textwidth}{\texttt{drv} 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}, +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}, +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 @@ -1144,30 +1156,29 @@ 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}} +\section{Pictures, bounding boxes and math axis\label{sec-pictures}} % % -\subsection{\texttt{drv\_freeze} \& \texttt{drv\_tree}} +\subsection{\texttt{drv\_freeze} and \texttt{drv\_tree}} % % -\texttt{drv.mp} composes derivation trees with respect to judgment and +\texttt{drv} 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 +This is usually done by \texttt{drv\_tree} which is 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 +\texttt{drv} 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 +(see~\cite{jackowski06,knuth84}). In particular, \texttt{drv} 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. +you use. As an example, compare the following fractions (the first one is +composed by \texttt{drv} while the second one is composed by the standard +\texttt{\tbs{}frac} command).\\[1ex]\mbox{}{\hfill% +\drv{drv-guide.400}\quad{\huge$\displaystyle\frac{\gamma}{\delta}$}\hfill} % % \subsection{\texttt{drv\_bbox}\label{sec-bbox}} @@ -1177,9 +1188,10 @@ command. \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. +``\texttt{drv\_bbox \param{nat}}'' returns a \MP\ closed path +(see~\cite[Section~4]{hobby09}) standing for 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"; @@ -1189,7 +1201,8 @@ dcl 0 (1, 5) ("", _) "a"; dcl 3 () ("", _) "d"; dcl 4 () ("", _) "e"; dcl 5 () ("", _) "f"; -fill drv_bbox 1 withcolor (255, 230, 205)/255; % rgb color +fill drv_bbox 1 withcolor (255, 230, 205)/255;\textrm{\emph{ + % rgb color}} draw drv_tree; endfig; \end{Verbatim} @@ -1201,14 +1214,15 @@ endfig; \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} locally overrides \texttt{drv\_axis\_reference} (see +\S~\ref{sec-axis-reference}), allowing you to explicitly set +the math axis of a tree once it has been drawn.\\[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 jdg}&judgment math axis\\ {\tt dlm}&delimiter axis \end{tabular}\\ \param{nat}& reference index @@ -1224,6 +1238,7 @@ drv_axis (iln, 0); endfig; \end{Verbatim} \begin{gather*} +\frac{\qquad}{}\textit{ math axis }\frac{\qquad}{} \drv{drv-guide.420}\frac{\qquad}{}\text{ resp. }\frac{\qquad}{} \drv{drv-guide.421}\frac{\qquad}{}\text{ resp. }\frac{\qquad}{} \drv{drv-guide.422} @@ -1235,7 +1250,7 @@ Notice that \texttt{drv\_axis} is irrelevant if you don't use the \section{Low level inference declaration macros\label{sec-low-level}} % % -\subsection{\texttt{NFR}, \texttt{DCL} \& \texttt{MVD}\label{sec-NFR-DCL-MVD}} +\subsection{\texttt{NFR}, \texttt{DCL} and \texttt{MVD}\label{sec-NFR-DCL-MVD}} % % \paragraph{\texttt{NFR}} @@ -1247,8 +1262,8 @@ 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})} +(\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\\ @@ -1327,30 +1342,29 @@ endfig; 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})}\\ +(\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 1}& alignment style identifier ({\tt l}, {\tt c} or {\tt r})\\ \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)) ("", _); +jgm 0 "a"; + jgm 1 "b"; + jgm 2 "cccccc"; + jgm 3 "ddd"; + jgm 4 "eeeeeeeee"; +nfr 0 (1, MVD 4 (5, "", "F", r, 4)) ("", _); + nfr 1 (MVD 2 (2, "G", "", l, 3), 3) ("", _); + nfr 2 () ("", _); + nfr 3 () ("", _); + nfr 4 () ("", _); draw drv_tree; endfig; \end{Verbatim} @@ -1450,8 +1464,8 @@ specify labels at your option.\\[1ex] \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 1}& alignment style identifier ({\tt l}, {\tt c} + or {\tt r})\\ \param{id 2}& phantom steps path-style identifier ({\tt0}, {\tt1}, {\tt2}, {\tt3}, {\tt4}, {\tt5}, {\tt6} or {\tt\_}) \end{tabular}\\[1ex] @@ -1478,7 +1492,7 @@ 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}. +As an example, 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); @@ -1533,7 +1547,7 @@ endfig; 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. +the right of the component math axis. \begin{gather*} \begin{array}{cc} \text{components}&\text{central points}\\[1ex] @@ -1547,11 +1561,11 @@ the right of the component math-axis. % 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 +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 +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 +math axis relatively to the axis of an inference line below it. Depths are negative while heights are positive. \begin{Verbatim} beginfig(470) @@ -1569,8 +1583,9 @@ endfig; \subsection{\texttt{drv\_styled}\label{sec-styled}} % % -\texttt{drv\_styled} allows you to draw \MP\ paths using \texttt{drv.mp} -path-styles.\\[1ex] +\texttt{drv\_styled} allows you to draw \MP\ paths +%(see~\cite[Section~4]{hobby09}) +using \texttt{drv} path-styles.\\[1ex] \texttt{\param{path} drv\_styled \param{id}}\\ \begin{tabular}{ll} \param{path}& \MP\ path expression\\ @@ -1605,11 +1620,11 @@ endfig; \end{gather*} % % -\subsection{User specified junction \& alignment styles +\subsection{User specified junction and alignment styles (tricky)\label{sec-user-specified}} % % -\texttt{drp.mp} composes derivation trees by stating geometrical constraints to +\texttt{drv} 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 @@ -1619,7 +1634,7 @@ 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} +You can prevent \texttt{drv} 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 @@ -1675,6 +1690,7 @@ xpart sbj[2][1].c=xpart sbj[1][1].c; draw drv_tree; endfig; \end{Verbatim} +\label{fig-510} \begin{gather*} \drv{drv-guide.510}\quad\text{resp.}\quad\drv{drv-guide.511} \end{gather*} @@ -1713,12 +1729,15 @@ Lutz \textsc{Stra\ss{}burger}. % % \appendix -\section{Debugging\label{sec-debugging}} +\section{Debugging and proofing\label{sec-debugging}} +% +% +\subsection*{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 +the first run then it comes from the \texttt{drv}/\MP\ code. If you get an error on the second run then it comes from the \LaTeX\ code. % % @@ -1728,7 +1747,7 @@ error on the second run then it comes from the \LaTeX\ code. (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 +an inconsistency that \texttt{drv} can detect. In such a case the explanation should be quite understandable. \begin{multicols}{2} \begin{Verbatim}[numbers=left,firstnumber=46] @@ -1768,38 +1787,331 @@ part of the \LaTeX\ code is faulty but unfortunately not where to find it in \texttt{\param{jobname}.mp}. % % -\section{Gallery\label{sec-gallery}} +\subsection*{Proofing} % % -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). +Recall that 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}}. In addition, +\texttt{drv} generates a \LaTeX\ file \texttt{\param{jobname}-proof.tex} +that contains a copy of the \LaTeX\ preamble in \texttt{\param{jobname}.mp} +and includes each \texttt{\param{jobname}.\param{index}}% +\footnote{To \MP\ users: proof file generation does not take +\texttt{outputtemplate} into account yet.} +picture file using the \texttt{\tbs{}drv} inclusion command, together with +some information about its text size, math style and math axis. As an example, +regarding the first figure on page~\pageref{fig-110}, processing +\texttt{drv-guide-proof.tex} produces:\\[1ex] +\texttt{drv-guide.110} + (\verb+\normalsize+, \verb+\displaystyle+) + {\normalsize + \[\displaystyle + \frac{\quad}{}\drv{drv-guide.110}\frac{\quad}{} + \]} % % +\section{Derivation forests\label{sec-forests}} +% +% +You may declare several derivation trees within a single figure environment. +Then trees are drawn from left to right in the order their roots are +declared, and in such a way that: root judgments are horizontally aligned; the +distance between two trees is the same as the distance between two +non-interleaving premises (and thus is affected by \texttt{drv\_scale}, see +\S~\ref{sec-scale}). +\begin{multicols}{2} +\begin{Verbatim} +beginfig(530) +% first tree +dcl 10 () ("", _) "a"; +% second tree +dcl 20 (21, 22) ("", _) "d"; + dcl 21 () ("", _) "b"; + dcl 22 () ("", _) "c"; +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak + \begin{gather*} +\textcolor{mygrey}{\frac{\quad}{}\textit{math axis}\frac{\quad}{}} \drv{drv-guide.530} \end{gather*} +\end{multicols} +\noindent You can however state constraints (horizontal or vertical, at your +option) specifying the relative positioning of trees before +\texttt{drv\_freeze} is called. +\begin{multicols}{2} +\begin{Verbatim}[commandchars=\\\{\}] +beginfig(531) +% first tree +dcl 10 () ("", _) "a"; +% second tree +dcl 20 (21, 22) ("", _) "d"; + dcl 21 () ("", _) "b"; + dcl 22 () ("", _) "c"; +% relative positionning +ypart jdg[10].c=ypart jdg[22].c; +\resplap{}xpart iln[10].r=xpart iln[20].l; +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak + \begin{gather*} +\textcolor{mygrey}{\frac{\quad}{}\textit{math axis}\frac{\quad}{}} \drv{drv-guide.531} \end{gather*} +\begin{gather*} +\textcolor{mygrey}{\frac{\quad}{}\textit{math axis}\frac{\quad}{}} +\drv{drv-guide.532} +\end{gather*} +\end{multicols} +\noindent Notice that the math axis of a forest is set according to +\texttt{drv\_axis\_reference} (see \S~\ref{sec-axis-reference}) relatively to +the first declared root (you can override this behaviour by using +\texttt{drv\_axis}, see \S~\ref{sec-axis}). +% +% +\subsection*{\texttt{drv\_root}} +% +% +\texttt{drv\_root} locally overrides \texttt{drv\_roots\_position} (see +\S~\ref{sec-roots-position}), allowing you to explicitly set +the position of a root.\\[1ex] +\texttt{drv\_root (\param{nat}, \param{id})}\\ +\begin{tabular}{ll} +\param{nat}& root index\\ +\param{id}& position identifier ({\tt t} or {\tt b})\\ +& \begin{tabular}{ll} + {\tt t}&top\\ + {\tt b}&bottom + \end{tabular} +\end{tabular} +\begin{multicols}{2} +\begin{Verbatim} +beginfig(533) +% first tree +dcl 10 () ("", _) "a"; +% second tree +dcl 20 (21, 22) ("", _) "d"; + dcl 21 () ("", _) "b"; + dcl 22 () ("", _) "c"; +drv_root (20, t); % root at top! +draw drv_tree; +endfig; +\end{Verbatim} +\columnbreak + +\begin{gather*} +\textcolor{mygrey}{\frac{\quad}{}\textit{math axis}\frac{\quad}{}} +\drv{drv-guide.533} +\end{gather*} +\end{multicols} +\noindent Then again, you can state constraints specifying the relative +positioning (e.g., the overlapping) of trees before \texttt{drv\_freeze} is +called\label{code-overlapping}. +\begin{Verbatim} +drv_left_delimiter "\downarrow"; +drv_right_delimiter "\uparrow"; + +beginfig(540) +% first tree +jgm 10 "A\vdash D"; +Nfr 10 (11, 14) ("\circ", "h\circ (g\circ f)", "", 1); + dcl 11 (12, 13) ("\circ", 1) "A\vdash C"; + dcl 12 () ("f", 2) "A\vdash B"; + dcl 13 () ("g", 3) "B\vdash C"; + dcl 14 () ("h", 4) "C\vdash D"; +% second tree +jgm 20 "\phantom{A\vdash D}"; % hidden judgment +Nfr 20 (21, 22) ("\circ", "", "(h\circ g)\circ f", 1); + dcl 21 () ("f", 2) "A\vdash B"; + dcl 22 (23, 24) ("\circ", 1) "B\vdash D"; + dcl 23 () ("g", 3) "B\vdash C"; + dcl 24 () ("h", 4) "C\vdash D"; +drv_root (20, t); % root at top! +% overlapping +jdg[10].c=jdg[20].c; +draw drv_tree; +endfig; +\end{Verbatim} +(The resulting figure is in Appendix~\ref{sec-gallery} on +page~\pageref{fig-overlapping}.) +% +% +\section{Radial mode (beta version)\label{sec-radial}} +% +% +A few more tuning macros (see~\S~\ref{sec-tunings}) are available that allow +you to manipulate \emph{radial} trees rather than ``linear'' ones. +% +% +\subsection*{\texttt{drv\_radial\_mode}} +% +% +\texttt{drv\_radial\_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.550}& +\drv{drv-guide.552}&\\[4ex] +\drv{drv-guide.551}& +\drv{drv-guide.553}& +\end{array} +\end{gather*} +% +% +\subsection*{\texttt{drv\_scale (crv, {\rm ---})}} +% +% +\texttt{drv\_scale (crv, \param{float})}\\ +\begin{tabular}{lll} +{\tt crv}& scale identifier\\ +\param{float}&scale value&\default[: 1] +\end{tabular} +% +% +\begin{gather*} +\begin{array}{*{4}{@{}>{\centering}p{.25\textwidth}}@{}l@{}} +\texttt{0.5}& +\texttt{1}& +\texttt{2}& +\texttt{4}&\\[1ex] +\drv{drv-guide.560}& +\drv{drv-guide.561}& +\drv{drv-guide.562}& +\drv{drv-guide.563}& +\end{array} +\end{gather*} +% +% +\enlargethispage{1.75\baselineskip}% +\subsection*{\texttt{drv\_azimuth}} +% +% +\texttt{drv\_azimuth \param{float}}\\ +\begin{tabular}{lll} +\param{float}&azimuth degree&\default[: 90] +\end{tabular} +% +% +\begin{gather*} +\begin{array}{*{3}{@{}>{\centering}p{.33\textwidth}}@{}l@{}} +\texttt{120}& +\texttt{90}& +\texttt{60}&\\[1ex] +\drv{drv-guide.570}& +\drv{drv-guide.571}& +\drv{drv-guide.572}& +\end{array} +\end{gather*} +The azimuth of a derivation tree is that of the central point of its root +judgment. Notice that both \texttt{drv\_scale (crv, {\rm ---})} and +\texttt{drv\_azimuth} are irrelevant when not in radial mode. +% +% +\begin{gather*} +\drv{drv-guide.580} +\end{gather*} +% +% +\subsection*{User specified junction and alignment styles (tricky)} +% +% +When in radial mode, \texttt{drv} composes derivation trees by stating +\emph{angular} constraints rather than horizontal ones. To this end, three +distinguished angles are associated with each component \param{cpn}, namely +\texttt{\param{cpn}.lng}, \texttt{\param{cpn}.cng} and \texttt{\param{cpn}.rng} +that refer to the relative angles of \texttt{\param{cpn}.l}, +\texttt{\param{cpn}.c} and \texttt{\param{cpn}.r} respectively. (Radial +constraints are essentially the same as vertical ones; however, each component +comes also with a radius \texttt{\param{cpn}.rad} and an origin point +\texttt{\param{cpn}.org}.) + +You can prevent \texttt{drv} from stating angular 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}). +Then again, you have to state your own constraints. As an example, compare the +code below with the one for figure~510 on page~\pageref{fig-510}. +% +% +\begin{Verbatim}[commandchars=\\\{\}] +beginfig(590) % "\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 +sbj[1][1].cng=sbj[0][1].cng; +\resplap{}sbj[1][1].lng=sbj[0][1].rng; +sbj[2][1].cng=sbj[1][1].cng; +\resplap{}sbj[2][1].lng=sbj[1][1].rng; +draw drv_tree; +endfig; +\end{Verbatim} +\begin{gather*} +\drv{drv-guide.590}\quad\text{resp.}\quad\drv{drv-guide.591} +\end{gather*} +% +% +\section{Gallery\label{sec-gallery}} +% +% +Here are two simple derivation trees (figures~600,~601). +\begin{gather*} +\drv{drv-guide.600}\quad +\drv{drv-guide.601} +\end{gather*} +% +% +Here are the \texttt{drv} version of a derivation tree found +in~\cite[p.~57]{restall06} and an alternative for it (figures~610,~611). +\begin{gather*} +\drv{drv-guide.610} +\end{gather*} +\begin{gather*} +\drv{drv-guide.611} +\end{gather*} +% +% +Here are overlapping trees with opposite directions (figure~540, code on +page~\pageref{code-overlapping}). +\begin{gather*} +\drv{drv-guide.540}\label{fig-overlapping} +\end{gather*} % % -Here is the \texttt{drv.mp} version of a derivation tree found -in~\cite[p.~86]{roegel02} (figure~540). +Here is the \texttt{drv} version of a derivation tree found +in~\cite[p.~86]{roegel02} (figure~620). \begin{gather*} -\drv{drv-guide.540} +\drv{drv-guide.620} \end{gather*} % % -Here are the \texttt{drv.mp} versions of derivations trees found -in~\cite[p.~50]{lutz06} (figures~550,~551). +Here are the \texttt{drv} versions of derivation trees found +in~\cite[p.~50]{lutz06} (figures~630,~631). \begin{gather*} -\drv{drv-guide.550}\quad\to\quad\drv{drv-guide.551} +\drv{drv-guide.630}\quad\to\quad\drv{drv-guide.631} \end{gather*} % % -Here is a continued fraction composed by \texttt{drv.mp} (figure~560). +Here is a continued fraction (figure~640). \begin{gather*} -\drv{drv-guide.560} +\drv{drv-guide.640} \end{gather*} % % @@ -1858,7 +2170,7 @@ metapost/contrib/macros/metaobj/}{\texttt{metaobj.mp}} \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}); +(Peter M\o ller \textsc{Neergaard} and Arne John \textsc{Glenstrup}); \item \href{http://www.utdallas.edu/~hamlen/projects.html} {\texttt{trfrac.sty}} @@ -1869,6 +2181,6 @@ metapost/contrib/macros/metaobj/}{\texttt{metaobj.mp}} (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. +``\href{http://www.logicmatters.net/latex-for-logicians/} +{\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 index 69f2f9f72c7..a5791649f82 100644 --- a/Master/texmf-dist/doc/metapost/drv/doc/drv.mp +++ b/Master/texmf-dist/doc/metapost/drv/doc/drv.mp @@ -1,5 +1,5 @@ -%% drv.mp 0.94 -%% Copyright 2009 Laurent M\'ehats +%% drv 0.95 +%% Copyright 2010 Laurent M\'ehats % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -16,6 +16,9 @@ % % This work consists of the file drv.mp +newinternal drv_version; +drv_version:=0.95; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -142,8 +145,9 @@ % <str> LaTeX math-style command % % drv_scale (<id>, <float>) -% <id> scale identifier (clr, prm, jdg or ilb) +% <id> scale identifier (clr, crv, prm, jdg or ilb) % clr nice explanation soon (see examples) +% crv nice explanation soon (see examples) % prm nice explanation soon (see examples) % jdg nice explanation soon (see examples) % ilb nice explanation soon (see examples) @@ -217,6 +221,15 @@ % on % off % +% drv_radial_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_azimuth <float> +% <float> azimuth degree +% +% % * Derivation tree pictures % ========================== % @@ -234,6 +247,12 @@ % <path> MetaPost path expression % <id> path style identifier (0, 1, 2, 3, 4, 5 or 6) % +% drv_root (<nat>, <id>) +% <nat> root index +% <id> position identifier (t or b) +% t top +% b bottom +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -250,9 +269,8 @@ vardef drv_format (expr str, fst_len, nxt_len, dbl_pcs)= % 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; + save str_len, sub_len, aux_len, chr_rnk, occ_num, aux_str, chr; 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; @@ -315,6 +333,8 @@ vardef drv_errmessage expr str= errmessage drv_format (drv_context&str, 77, 79, false); enddef; +drv_message "version "&decimal drv_version&"."; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -488,11 +508,23 @@ picture tt_dgt[][]; 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_fontdimen[] expr font= - save dim_pct; + save dim_pct, dim_str; picture dim_pct; - dim_pct:=drv_tex[0] ("\rule{\the\fontdimen"&(decimal @)&font&"}{0bp}"); - width dim_pct + string dim_str; + dim_pct:=drv_tex[0] ("\mbox{\the\fontdimen"&(decimal @)&font&"}"); + dim_str:="0"; + for tok within dim_pct: + dim_str:=dim_str&(textpart tok); + endfor + scantokens dim_str enddef; vardef drv_font_size expr size_str= @@ -530,11 +562,11 @@ vardef drv_font_size expr size_str= 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] "\,"; + sp_pct:=drv_tex[mth_sty] "\thinspace"; thn_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\>"; + sp_pct:=drv_tex[mth_sty] "\medspace"; med_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\;"; + sp_pct:=drv_tex[mth_sty] "\thickspace"; thk_sp[mth_sty]:=width sp_pct; pdt_pct:=drv_tex[mth_sty] "\ldotp"; pdt_hg[mth_sty]:=height pdt_pct; @@ -588,6 +620,7 @@ vardef drv_box text STR= expandafter pair scantokens str.r; expandafter numeric scantokens str.hg; expandafter numeric scantokens str.dp; + drv_arc str; endfor enddef; @@ -606,6 +639,119 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +% drv-arcs +% + +vardef drv_arc text STR= + for str=STR: + expandafter numeric scantokens str.rad; + expandafter numeric scantokens str.lng; + expandafter numeric scantokens str.cng; + expandafter numeric scantokens str.rng; + expandafter pair scantokens str.org; + endfor +enddef; + +vardef arc_init @# (expr pct, ngl)= + @#:=pct; + @#.rng-@#.lng=ngl; + @#.cng=(@#.lng+@#.rng)/2; +enddef; + +vardef arc_freeze @#= + @#:=@# rotated @#.lng shifted @#.org; + @#.l:=(dir @#.lng) scaled @#.rad shifted @#.org; + @#.c:=(dir @#.cng) scaled @#.rad shifted @#.org; + @#.r:=(dir @#.rng) scaled @#.rad shifted @#.org; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Polar coordinates, angles & text torsion +% + +vardef rad_part expr ppt= + xpart ppt +enddef; + +vardef ngl_part expr ppt= + ypart ppt +enddef; + +vardef minrad (expr ppt_a, ppt_b)= + min (rad_part ppt_a, rad_part ppt_b) +enddef; + +% "tnum" (turning number) argument: +% -1: clockwise +% 1: counterclockwise + +vardef lmost_ppt (expr ppt_a, ppt_b) expr tnum= + if tnum*(ngl_part ppt_a)<tnum*(ngl_part ppt_b): + ppt_a + else: + ppt_b + fi +enddef; + +vardef rmost_ppt (expr ppt_a, ppt_b) expr tnum= + if tnum*(ngl_part ppt_a)>tnum*(ngl_part ppt_b): + ppt_a + else: + ppt_b + fi +enddef; + +vardef arc_angle (expr rad, arc_len) expr tnum= + if rad>0: + save pth; + path pth; + pth:=fullcircle scaled (2*rad); + tnum*(angle point (arctime arc_len of pth) of pth) + else: + 0 + fi +enddef; + +vardef circ_path (expr rad, ngl) expr tnum= + save pth; + path pth; + pth:=if tnum=-1: reverse fi fullcircle scaled (2*rad); + subpath (0, directiontime (dir (ngl+tnum*90)) of pth) of pth +enddef; + +vardef text_arc (expr pct, rad) expr tnum= + save arc_pct, tok_str, tok_trn, tok_ngl, hlf_wd, chr_pct; + picture arc_pct, chr_pct; + numeric tok_ngl, hlf_wd; + string tok_str; + arc_pct:=nullpicture; + for tok within pct: + transform tok_trn; + tok_str:=textpart tok; + (0, 0) transformed tok_trn=(0, 0); + (0, 1) transformed tok_trn=(xypart tok, yypart tok); + (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); + tok_ngl:=arc_angle (rad, xpart tok) tnum; + for chr_rnk=0 upto (length tok_str-1): + chr_pct:=substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) + transformed tok_trn; + hlf_wd:=(width chr_pct)/2; + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + addto arc_pct also chr_pct + shifted (-hlf_wd, 0) + rotated (tok_ngl+tnum*90) + shifted ((dir tok_ngl) scaled (rad-tnum*(ypart tok))); + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + endfor + endfor + arc_pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % beginfig & endfig % @@ -637,14 +783,17 @@ vardef drv_beginfig= % iln_sty[i] inference line style % l_prm[i] leftmost `graphical' premise index % r_prm[i] rightmost `graphical' premise index + % bot_jdg[i] boolean % numeric prm_num[], prm[][], ccl[]; numeric jct_sty[]; string alg_sty[]; numeric iln_sty[]; numeric l_prm[], r_prm[]; + boolean bot_jdg[]; % % nfr_min_x[i] inference minimal x + % nfr_lmost_ppt[i] inference leftmost polar point % l_dlb[i] left delimiter label drv-box % l_dlm[i] left delimiter drv-box % l_ilb[i] left label drv-box @@ -653,22 +802,31 @@ vardef drv_beginfig= % r_dlm[i] right delimiter drv-box % r_dlb[i] right delimiter label drv-box % nfr_max_x[i] inference maximal x + % nfr_rmost_ppt[i] inference rightmost polar point % numeric nfr_min_x[]; + pair nfr_lmost_ppt[]; drv_box "l_dlb[]", "l_dlm[]", "l_ilb[]"; drv_box "iln[]"; drv_box "r_ilb[]", "r_dlm[]", "r_dlb[]"; numeric nfr_max_x[]; + pair nfr_rmost_ppt[]; % % Sub-trees % % sub_min_x[i] sub-tree minimal x + % sub_lmost_ppt[i] sub-tree leftmost polar point % sub_max_x[i] sub-tree maximal x + % sub_rmost_ppt[i] sub-tree rightmost polar point % sub_min_y[i] sub-tree minimal y + % sub_min_rad[i] sub-tree minimal radius % sub_max_y[i] sub-tree maximal y + % sub_max_rad[i] sub-tree maximal radius % boxed[i] boolean % numeric sub_min_x[], sub_max_x[], sub_min_y[], sub_max_y[]; + pair sub_lmost_ppt[], sub_rmost_ppt[]; + numeric sub_min_rad[], sub_max_rad[]; boolean boxed[]; % % Pen initialization @@ -953,8 +1111,8 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % PRM: list of premise indices % - save prm_rnk; - numeric prm_rnk; + save prm_rnk, root_rnk; + numeric prm_rnk, root_rnk; prm_rnk:=0; for prm_idx=PRM: if prm_idx=@: @@ -971,8 +1129,6 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % roots list update % - save root_rnk; - numeric root_rnk; root_rnk:=0; forever: exitif root[root_rnk]=prm_idx; @@ -1324,24 +1480,46 @@ string drv_rdlm_str; % right delimiter LaTeX code % 2. Macros % -vardef minmax_y[]=( - if drv_bot_roots: +vardef min_y[]= + if bot_jdg[@]: if known ccl[@]: ypart jdg[@].c-num_hg+iln_hg[(iln_sty[ccl[@]])] +min_clr_scl*min_clr[drv_sty]/2 else: sub_min_y[@]-min_clr_scl*min_clr[drv_sty] - fi, + fi + else: + sub_min_y[@]-min_clr_scl*min_clr[drv_sty] + fi +enddef; + +vardef max_y[]= + if bot_jdg[@]: sub_max_y[@]+min_clr_scl*min_clr[drv_sty] else: - sub_min_y[@]-min_clr_scl*min_clr[drv_sty], if known ccl[@]: ypart jdg[@].c-den_dp+iln_dp[(iln_sty[ccl[@]])] -min_clr_scl*min_clr[drv_sty]/2 else: sub_max_y[@]+min_clr_scl*min_clr[drv_sty] fi - fi) + fi +enddef; + +vardef min_rad[]= + if known ccl[@]: + if bot_jdg[@]: + jdg[@].rad-num_hg+iln_hg[(iln_sty[ccl[@]])] + else: + jdg[@].rad+den_dp-iln_dp[(iln_sty[ccl[@]])] + fi+min_clr_scl*min_clr[drv_sty]/2 + else: + sub_min_rad[@]-min_clr_scl*min_clr[drv_sty] + fi +enddef; + +vardef max_rad[]= + sub_max_rad[@]+min_clr_scl*min_clr[drv_sty] enddef; vardef delim @# expr dlm_len= @@ -1394,6 +1572,10 @@ boolean drv_boxmode_on; % boolean drv_fractionmode_on; % string drv_axis_ref; % +boolean drv_radialmode_on; % +numeric crv_scl; % +numeric azimuth_ngl; % + % % 2. Macros % @@ -1410,7 +1592,7 @@ vardef fraction_inference[]= and drv_fractionmode_on enddef; -vardef drv_check_root[]= +vardef drv_bot_check[]= if unknown jdg[@]: drv_errhelp "An index must be used to declare a both a judgment and an"& " inference."; @@ -1425,29 +1607,56 @@ vardef drv_check_root[]= save i_sty, prm_idx; numeric i_sty, prm_idx; i_sty:=iln_sty[@]; + bot_jdg[@]:=true; for prm_rnk=0 upto prm_num[@]-1: prm_idx:=prm[@][prm_rnk]; - drv_check_root[prm_idx]; + drv_bot_check[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 + num_hg:=max (num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].dp); 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 + den_dp:=min (den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[@].hg); + fi + if unknown boxed[@]: + boxed[@]:=drv_boxmode_on; + fi + fi +enddef; + +vardef drv_top_check[]= + 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[@]; + bot_jdg[@]:=false; + for prm_rnk=0 upto prm_num[@]-1: + prm_idx:=prm[@][prm_rnk]; + drv_top_check[prm_idx]; + % + % numerators and denominators clearances + % The TEXbook, Appendix G, Rule 15d. + % + den_dp:=min (den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].hg); + endfor + if not fraction_inference[@]: + num_hg:=max (num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[@].dp); fi if unknown boxed[@]: boxed[@]:=drv_boxmode_on; @@ -1455,24 +1664,42 @@ vardef drv_check_root[]= fi enddef; +vardef drv_root (expr idx) (suffix pos_sfx)= + save root_idx; + numeric root_idx; + root_idx:=idx; + forever: + exitif unknown ccl[root_idx]; + root_idx:=ccl[root_idx]; + endfor + if idx<>root_idx: + drv_message "warning, "&(decimal idx)&" is not a root index"& + " (the actual root index is "&(decimal root_idx)&")."; + fi + bot_jdg[root_idx]:=check_position_bot (pos_sfx) (drv_bot_roots); +enddef; + vardef drv_check= if root_num=0: drv_errhelp "Well ..."; drv_errmessage "no inference has been declared"; else: - save root_idx; + save root_idx, root_str; numeric root_idx; - root_idx:=root[0]; - drv_check_root[root_idx]; + string root_str; + for root_rnk=0 upto root_num-1: + root_idx:=root[root_rnk]; + if unknown bot_jdg[root_idx]: + bot_jdg[root_idx]:=drv_bot_roots; + fi + if bot_jdg[root_idx]: + drv_bot_check[root_idx]; + else: + drv_top_check[root_idx]; + fi + root_str:=if root_rnk>0: root_str&", "& fi decimal root_idx; + endfor if root_num>1: - save root_str; - string root_str; - root_str:=decimal root_idx; - for root_rnk=1 upto root_num-1: - root_idx:=root[root_rnk]; - drv_check_root[root_idx]; - root_str:=root_str&", "&(decimal root_idx); - endfor drv_message "warning, multiple root indices ("&root_str&")."; fi fi @@ -1483,11 +1710,11 @@ enddef; % Building % -vardef drv_build_root[]= +vardef drv_lin_build[]= % % orientation % - if drv_bot_roots: + if bot_jdg[@]: ypart iln[@].c=ypart jdg[@].c-den_dp; sub_min_y[@]:=ypart jdg[@].c+jdg[@].dp; sub_max_y[@]:= @@ -1498,8 +1725,8 @@ vardef drv_build_root[]= fi; for prm_rnk=0 upto prm_num[@]-1: ypart jdg[prm[@][prm_rnk]].c=ypart iln[@].c+num_hg; - drv_build_root[prm[@][prm_rnk]]; - sub_max_y[@]:=max(sub_max_y[@], sub_max_y[prm[@][prm_rnk]]); + drv_lin_build[prm[@][prm_rnk]]; + sub_max_y[@]:=max (sub_max_y[@], sub_max_y[prm[@][prm_rnk]]); endfor else: ypart iln[@].c=ypart jdg[@].c-num_hg; @@ -1512,18 +1739,16 @@ vardef drv_build_root[]= sub_max_y[@]:=ypart jdg[@].c+jdg[@].hg; for prm_rnk=0 upto prm_num[@]-1: ypart jdg[prm[@][prm_rnk]].c=ypart iln[@].c+den_dp; - drv_build_root[prm[@][prm_rnk]]; - sub_min_y[@]:=min(sub_min_y[@], sub_min_y[prm[@][prm_rnk]]); + drv_lin_build[prm[@][prm_rnk]]; + sub_min_y[@]:=min (sub_min_y[@], sub_min_y[prm[@][prm_rnk]]); endfor fi % % premises junction (from left to right) % - for prm_rnk=1 upto prm_num[@]-1: - save l_lmost, l_rmost, r_lmost, r_rmost; - save l_max_x, r_min_x, min_skp; - numeric l_lmost, l_rmost, r_lmost, r_rmost; - numeric l_max_x, r_min_x, min_skp[]; + save l_lmost, l_rmost, r_lmost, r_rmost, l_max_x, r_min_x, min_skp; + numeric l_lmost, l_rmost, r_lmost, r_rmost, l_max_x, r_min_x, min_skp[]; + for prm_rnk=1 upto prm_num[@]-1: l_lmost:=prm[@][0]; l_rmost:=prm[@][prm_rnk-1]; r_lmost:=prm[@][prm_rnk]; @@ -1537,9 +1762,9 @@ vardef drv_build_root[]= l_rmost:=r_prm[l_rmost]; r_lmost:=l_prm[r_lmost]; r_rmost:=r_prm[r_rmost]; - l_max_x:=max(l_max_x, nfr_max_x[l_rmost]); - r_min_x:=min(r_min_x, nfr_min_x[r_lmost]); - min_skp[0]:=min(min_skp[0], nfr_min_x[r_lmost]-nfr_max_x[l_rmost]); + l_max_x:=max (l_max_x, nfr_max_x[l_rmost]); + r_min_x:=min (r_min_x, nfr_min_x[r_lmost]); + min_skp[0]:=min (min_skp[0], nfr_min_x[r_lmost]-nfr_max_x[l_rmost]); endfor min_skp[1]:=r_min_x-l_max_x; if known r_prm[l_rmost]: @@ -1583,8 +1808,8 @@ vardef drv_build_root[]= elseif alg_sty[@]="r": xpart jdg[@].r=r_xref; fi - nfr_min_x[@]:=min(xpart jdg[@].l, l_xref); - nfr_max_x[@]:=max(xpart jdg[@].r, r_xref); + nfr_min_x[@]:=min (xpart jdg[@].l, l_xref); + nfr_max_x[@]:=max (xpart jdg[@].r, r_xref); fi % % inference line @@ -1612,14 +1837,14 @@ vardef drv_build_root[]= if known l_ilb[@]: l_ilb[@].r=iln[@].l shifted (-ilb_skp_scl*ilb_skp[drv_sty], 0); nfr_min_x[@]:=xpart l_ilb[@].l; - sub_min_y[@]:=min(sub_min_y[@], ypart l_ilb[@].c+l_ilb[@].dp); - sub_max_y[@]:=max(sub_max_y[@], ypart l_ilb[@].c+l_ilb[@].hg); + sub_min_y[@]:=min (sub_min_y[@], ypart l_ilb[@].c+l_ilb[@].dp); + sub_max_y[@]:=max (sub_max_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); nfr_max_x[@]:=xpart r_ilb[@].r; - sub_min_y[@]:=min(sub_min_y[@], ypart r_ilb[@].c+r_ilb[@].dp); - sub_max_y[@]:=max(sub_max_y[@], ypart r_ilb[@].c+r_ilb[@].hg); + sub_min_y[@]:=min (sub_min_y[@], ypart r_ilb[@].c+r_ilb[@].dp); + sub_max_y[@]:=max (sub_max_y[@], ypart r_ilb[@].c+r_ilb[@].hg); fi % % phantom steps @@ -1628,29 +1853,29 @@ vardef drv_build_root[]= save bot_y, top_y, phm_pct; numeric bot_y, top_y; picture phm_pct; - if drv_bot_roots: - bot_y:=xpart minmax_y[@]+min_clr_scl*min_clr[drv_sty]/2; - top_y:=xpart minmax_y[tgt[@]]; + if bot_jdg[@]: + bot_y:=min_y[@]+min_clr_scl*min_clr[drv_sty]/2; + top_y:=min_y[tgt[@]]; else: - bot_y:=ypart minmax_y[tgt[@]]; - top_y:=ypart minmax_y[@]-min_clr_scl*min_clr[drv_sty]/2; + bot_y:=max_y[tgt[@]]; + top_y:=max_y[@]-min_clr_scl*min_clr[drv_sty]/2; fi phm_pct:=((0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2)) drv_styled phm_sty[@]; box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); phm[@].c=(xpart jdg[@].c, (top_y+bot_y)/2); - nfr_min_x[@]:=min(nfr_min_x[@], xpart phm[@].l); - nfr_max_x[@]:=max(nfr_max_x[@], xpart phm[@].r); + nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[@].l); + nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[@].r); % % phantom steps labels % if known l_plb[@]: l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); - nfr_min_x[@]:=min(nfr_min_x[@], xpart l_plb[@].l); + nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[@].l); fi if known r_plb[@]: r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); - nfr_max_x[@]:=max(nfr_max_x[@], xpart r_plb[@].r); + nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[@].r); fi fi % @@ -1659,28 +1884,26 @@ vardef drv_build_root[]= sub_min_x[@]:=nfr_min_x[@]; sub_max_x[@]:=nfr_max_x[@]; for prm_rnk=0 upto prm_num[@]-1: - sub_min_x[@]:=min(sub_min_x[@], sub_min_x[prm[@][prm_rnk]]); - sub_max_x[@]:=max(sub_max_x[@], sub_max_x[prm[@][prm_rnk]]); + sub_min_x[@]:=min (sub_min_x[@], sub_min_x[prm[@][prm_rnk]]); + sub_max_x[@]:=max (sub_max_x[@], sub_max_x[prm[@][prm_rnk]]); endfor % % delimiters % if known l_dlb[@] or known r_dlb[@]: - save mmy, min_y, max_y; - numeric min_y, max_y; - pair mmy; - mmy:=minmax_y[@]; - min_y:=xpart mmy; - max_y:=ypart mmy; + save miny, maxy; + numeric miny, maxy; + miny:=min_y[@]; + maxy:=max_y[@]; if known l_dlb[@]: - box_init l_dlm[@] (delim l (max_y-min_y)); - l_dlm[@].r=(sub_min_x[@], (max_y+min_y)/2); + box_init l_dlm[@] (delim l (maxy-miny)); + l_dlm[@].r=(sub_min_x[@], (maxy+miny)/2); l_dlb[@].r=l_dlm[@].l; sub_min_x[@]:=xpart l_dlb[@].l; fi if known r_dlb[@]: - box_init r_dlm[@] (delim r (max_y-min_y)); - r_dlm[@].l=(sub_max_x[@], (max_y+min_y)/2); + box_init r_dlm[@] (delim r (maxy-miny)); + r_dlm[@].l=(sub_max_x[@], (maxy+miny)/2); r_dlb[@].l=r_dlm[@].r; sub_max_x[@]:=xpart r_dlb[@].r; fi @@ -1707,13 +1930,372 @@ vardef drv_build_root[]= fi enddef; +vardef drv_rad_build[]= + for sbj_rnk=0 upto (sbj_num[@]-1): + sbj[@][sbj_rnk].rad=jdg[@].rad; + sbj[@][sbj_rnk].org=jdg[@].org; + endfor + % + % orientation + % + if bot_jdg[@]: + iln[@].rad=jdg[@].rad-den_dp; + iln[@].org=jdg[@].org; + sub_min_rad[@]:=jdg[@].rad+jdg[@].dp; + sub_max_rad[@]:= + if iln_sty[@]=0: + jdg[@].rad+jdg[@].hg + else: + iln[@].rad+iln_hg[iln_sty[@]] + fi; + for prm_rnk=0 upto prm_num[@]-1: + jdg[prm[@][prm_rnk]].rad=iln[@].rad+num_hg; + jdg[prm[@][prm_rnk]].org=iln[@].org; + drv_rad_build[prm[@][prm_rnk]]; + sub_max_rad[@]:=max (sub_max_rad[@], sub_max_rad[prm[@][prm_rnk]]); + endfor + else: + iln[@].rad=jdg[@].rad+num_hg; + iln[@].org=jdg[@].org; + sub_min_rad[@]:=jdg[@].rad-jdg[@].hg; + sub_max_rad[@]:= + if iln_sty[@]=0: + jdg[@].rad-jdg[@].dp + else: + iln[@].rad-iln_dp[iln_sty[@]] + fi; + for prm_rnk=0 upto prm_num[@]-1: + jdg[prm[@][prm_rnk]].rad=iln[@].rad-den_dp; + jdg[prm[@][prm_rnk]].org=iln[@].org; + drv_rad_build[prm[@][prm_rnk]]; + sub_max_rad[@]:=max (sub_max_rad[@], sub_max_rad[prm[@][prm_rnk]]); + endfor; + fi + % + % inference labels + % + if known l_ilb[@]: + l_ilb[@].rad=iln[@].rad; + l_ilb[@].org=iln[@].org; + sub_max_rad[@]:=max (sub_max_rad[@], + l_ilb[@].rad if bot_jdg[@]: +l_ilb[@].hg else: -l_ilb[@].dp fi); + fi + if known r_ilb[@]: + r_ilb[@].rad=iln[@].rad; + r_ilb[@].org=iln[@].org; + sub_max_rad[@]:=max (sub_max_rad[@], + r_ilb[@].rad if bot_jdg[@]: +r_ilb[@].hg else: -r_ilb[@].dp fi); + fi + % + % phantom steps + % + if known tgt[@]: + save src_rad, tgt_rad; + numeric src_rad, tgt_rad; + src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; + tgt_rad:=min_rad[tgt[@]]; + phm[@].rad=(src_rad+tgt_rad)/2; + phm[@].org=jdg[@].org; + % + % phantom steps labels + % + if known l_plb[@]: + l_plb[@].rad=phm[@].rad; + l_plb[@].org=phm[@].org; + fi + if known r_plb[@]: + r_plb[@].rad=phm[@].rad; + r_plb[@].org=phm[@].org; + fi + fi + % + % delimiters + % + if known l_dlb[@] or known r_dlb[@]: + save minr, maxr; + numeric minr, maxr; + minr:=min_rad[@]; + maxr:=max_rad[@]; + if known l_dlb[@]: + l_dlm[@].rad=(minr+maxr)/2; + l_dlb[@].rad=l_dlm[@].rad; + l_dlb[@].org=l_dlm[@].org=jdg[@].org; + fi + if known r_dlb[@]: + r_dlm[@].rad=(minr+maxr)/2; + r_dlb[@].rad=r_dlm[@].rad; + r_dlb[@].org=r_dlm[@].org=jdg[@].org; + fi + fi +enddef; + +vardef drv_ngl_build[]= + for prm_rnk=0 upto prm_num[@]-1: + drv_ngl_build[prm[@][prm_rnk]]; + endfor + save tnum; + numeric tnum; + tnum:=if bot_jdg[@]: - fi 1; % turning number + % + % judgment arc + % + save jdg_pct, jdg_ngl; + picture jdg_pct; + numeric jdg_ngl; + jdg_pct:=nullpicture; + jdg_ngl:=0; + for sbj_rnk=0 upto (sbj_num[@]-1): + arc_init sbj[@][sbj_rnk] + (text_arc (sbj[@][sbj_rnk], sbj[@][sbj_rnk].rad) tnum, + arc_angle (sbj[@][sbj_rnk].rad, width sbj[@][sbj_rnk]) tnum); + if sbj_rnk>0: % non mandatory test + sbj[@][sbj_rnk-1].rng=sbj[@][sbj_rnk].lng;% irrelevant if rnk=0 + fi + addto jdg_pct also sbj[@][sbj_rnk] rotated jdg_ngl; + jdg_ngl:=jdg_ngl+sbj[@][sbj_rnk].rng-sbj[@][sbj_rnk].lng; + endfor + arc_init jdg[@] (jdg_pct, jdg_ngl); + if sbj_num[@]>0: % non mandatory test + jdg[@].lng=sbj[@][0].lng; % irrelevant if sbj_num=0 + fi + % + % premises junction (from left to right) + % + save l_lmost, l_rmost, r_lmost, r_rmost, l_rmost_ppt, r_lmost_ppt, ppt_skp; + numeric l_lmost, l_rmost, r_lmost, r_rmost; + pair l_rmost_ppt, r_lmost_ppt, ppt_skp[]; + for prm_rnk=1 upto prm_num[@]-1: + l_lmost:=prm[@][0]; + l_rmost:=prm[@][prm_rnk-1]; + r_lmost:=prm[@][prm_rnk]; + r_rmost:=prm[@][prm_rnk]; + l_rmost_ppt:=nfr_rmost_ppt[l_rmost]; + r_lmost_ppt:=nfr_lmost_ppt[r_lmost]; + ppt_skp[0]:=(minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt)); + forever: + exitif (unknown r_prm[l_rmost]) or (unknown l_prm[r_lmost]); + l_lmost:=l_prm[l_lmost]; + l_rmost:=r_prm[l_rmost]; + r_lmost:=l_prm[r_lmost]; + r_rmost:=r_prm[r_rmost]; + l_rmost_ppt:=rmost_ppt (l_rmost_ppt, nfr_rmost_ppt[l_rmost]) tnum; + r_lmost_ppt:=lmost_ppt (r_lmost_ppt, nfr_lmost_ppt[r_lmost]) tnum; + ppt_skp[0]:=rmost_ppt (ppt_skp[0], (minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt))) tnum; + endfor + ppt_skp[1]:=(minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt)); + if known r_prm[l_rmost]: + r_prm[r_rmost]:=r_prm[l_rmost]; + l_rmost_ppt:=sub_rmost_ppt[l_rmost]; + elseif known l_prm[r_lmost]: + l_prm[l_lmost]:=l_prm[r_lmost]; + r_lmost_ppt:=sub_lmost_ppt[r_lmost]; + fi + ppt_skp[2]:=(minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt)); + if jct_sty[@]<3: + (ngl_part ppt_skp[jct_sty[@]])= + arc_angle(rad_part ppt_skp[jct_sty[@]], + prm_skp_scl*prm_skp[drv_sty]) tnum; + fi + endfor + % + % judgment alignment + % + if prm_num[@]=0: + nfr_lmost_ppt[@]:=(jdg[@].rad, jdg[@].lng); + nfr_rmost_ppt[@]:=(jdg[@].rad, jdg[@].rng); + else: + l_prm[@]:=prm[@][0]; + r_prm[@]:=prm[@][prm_num[@]-1]; + save l_ngl_ref, r_ngl_ref; + numeric l_ngl_ref, r_ngl_ref; + l_ngl_ref= + if boxed[l_prm[@]]: + ngl_part sub_lmost_ppt[l_prm[@]] + else: + jdg[l_prm[@]].lng + fi; + r_ngl_ref= + if boxed[r_prm[@]]: + ngl_part sub_rmost_ppt[r_prm[@]] + else: + jdg[r_prm[@]].rng + fi; + if alg_sty[@]="l": + jdg[@].lng=l_ngl_ref; + elseif alg_sty[@]="c": + jdg[@].cng=(l_ngl_ref+r_ngl_ref)/2; + elseif alg_sty[@]="r": + jdg[@].rng=r_ngl_ref; + fi + nfr_lmost_ppt[@]:=( + jdg[@].rad, + tnum*min (tnum*jdg[@].lng, tnum*l_ngl_ref)); + nfr_rmost_ppt[@]:=( + jdg[@].rad, + tnum*max (tnum*jdg[@].rng, tnum*r_ngl_ref)); + fi + % + % inference line + % + save iln_ngl; + numeric iln_ngl; + iln_ngl:=2*(arc_angle(iln[@].rad, + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum) + +(ngl_part nfr_rmost_ppt[@]) + -(ngl_part nfr_lmost_ppt[@]); + arc_init iln[@] + ((circ_path (iln[@].rad, iln_ngl) tnum) drv_styled iln_sty[@], iln_ngl); + iln[@].hg=iln_hg[iln_sty[@]]; + iln[@].dp=iln_dp[iln_sty[@]]; + iln[@].cng=((ngl_part nfr_lmost_ppt[@])+(ngl_part nfr_rmost_ppt[@]))/2; + if iln_sty[@]>0: + nfr_lmost_ppt[@]:=(iln[@].rad, iln[@].lng); + nfr_rmost_ppt[@]:=(iln[@].rad, iln[@].rng); + fi + % + % inference labels + % + if known l_ilb[@]: + arc_init l_ilb[@]( + text_arc (l_ilb[@], l_ilb[@].rad) tnum, + arc_angle (l_ilb[@].rad, width l_ilb[@]) tnum); + l_ilb[@].rng=iln[@].lng + -arc_angle (l_ilb[@].rad, ilb_skp_scl*ilb_skp[drv_sty]) tnum; + nfr_lmost_ppt[@]:=(l_ilb[@].rad, l_ilb[@].lng); + fi + if known r_ilb[@]: + arc_init r_ilb[@]( + text_arc (r_ilb[@], r_ilb[@].rad) tnum, + arc_angle (r_ilb[@].rad, width r_ilb[@]) tnum); + r_ilb[@].lng=iln[@].rng + +arc_angle (r_ilb[@].rad, ilb_skp_scl*ilb_skp[drv_sty]) tnum; + nfr_rmost_ppt[@]:=(r_ilb[@].rad, r_ilb[@].rng); + fi + % + % phantom steps + % + if known tgt[@]: + save phm_pct, src_rad, tgt_rad; + picture phm_pct; + numeric src_rad, tgt_rad; + src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; + tgt_rad:=min_rad[tgt[@]]; + phm_pct:=((0, (src_rad-tgt_rad)/2)--(0, (tgt_rad-src_rad)/2)) + drv_styled phm_sty[@]; + arc_init phm[@] ( + phm_pct + rotated (tnum*90+arc_angle (phm[@].rad, (width phm_pct)/2) tnum) + shifted ((dir 0) scaled phm[@].rad), + arc_angle (phm[@].rad, width phm_pct) tnum); + phm[@].cng=jdg[@].cng; + nfr_lmost_ppt[@]:=lmost_ppt (nfr_lmost_ppt[@], + (phm[@].rad, phm[@].lng)) tnum; + nfr_rmost_ppt[@]:=rmost_ppt (nfr_rmost_ppt[@], + (phm[@].rad, phm[@].rng)) tnum; + % + % phantom steps labels + % + if known l_plb[@]: + arc_init l_plb[@]( + text_arc (l_plb[@], l_plb[@].rad) tnum, + arc_angle (l_plb[@].rad, width l_plb[@]) tnum); + l_plb[@].rng=phm[@].lng + -arc_angle (l_plb[@].rad, plb_skp[drv_sty]) tnum; + nfr_lmost_ppt[@]:= + lmost_ppt(nfr_lmost_ppt[@], (l_plb[@].rad, l_plb[@].lng)) tnum; + fi + if known r_plb[@]: + arc_init r_plb[@]( + text_arc (r_plb[@], r_plb[@].rad) tnum, + arc_angle (r_plb[@].rad, width r_plb[@]) tnum); + r_plb[@].lng=phm[@].rng + +arc_angle (r_plb[@].rad, plb_skp[drv_sty]) tnum; + nfr_rmost_ppt[@]:= + rmost_ppt(nfr_rmost_ppt[@], (r_plb[@].rad, r_plb[@].rng)) tnum; + fi + fi + % + % sub_lmost_ppt & sub_rmost_ppt + % + sub_lmost_ppt[@]:=nfr_lmost_ppt[@]; + sub_rmost_ppt[@]:=nfr_rmost_ppt[@]; + for prm_rnk=0 upto prm_num[@]-1: + sub_lmost_ppt[@]:= + lmost_ppt (sub_lmost_ppt[@], sub_lmost_ppt[prm[@][prm_rnk]]) tnum; + sub_rmost_ppt[@]:= + rmost_ppt (sub_rmost_ppt[@], sub_rmost_ppt[prm[@][prm_rnk]]) tnum; + endfor + % + % delimiters + % + if known l_dlb[@] or known r_dlb[@]: + save dlm_pct, minr, maxr; + picture dlm_pct; + numeric minr, maxr; + minr:=min_rad[@]; + maxr:=max_rad[@]; + if known l_dlb[@]: + dlm_pct:=delim l (maxr-minr); + arc_init l_dlm[@] ( + dlm_pct + rotated (tnum*90+arc_angle (l_dlm[@].rad, (width dlm_pct)/2) tnum) + shifted ((dir 0) scaled l_dlm[@].rad), + arc_angle (l_dlm[@].rad, width dlm_pct) tnum); + l_dlm[@].rng=ngl_part sub_lmost_ppt[@]; + arc_init l_dlb[@]( + text_arc (l_dlb[@], l_dlb[@].rad) tnum, + arc_angle (l_dlb[@].rad, width l_dlb[@]) tnum); + l_dlb[@].rng=l_dlm[@].lng; + sub_lmost_ppt[@]:= (l_dlb[@].rad, l_dlb[@].lng); + fi + if known r_dlb[@]: + dlm_pct:=delim r (maxr-minr); + arc_init r_dlm[@] ( + dlm_pct + rotated (tnum*90+arc_angle (r_dlm[@].rad, (width dlm_pct)/2) tnum) + shifted ((dir 0) scaled r_dlm[@].rad), + arc_angle (r_dlm[@].rad, width dlm_pct) tnum); + r_dlm[@].lng=ngl_part sub_rmost_ppt[@]; + arc_init r_dlb[@]( + text_arc (r_dlb[@], r_dlb[@].rad) tnum, + arc_angle (r_dlb[@].rad, width r_dlb[@]) tnum); + r_dlb[@].lng=r_dlm[@].rng; + sub_rmost_ppt[@]:=(r_dlb[@].rad, r_dlb[@].rng); + fi + fi + if (known l_dlb[@]) or boxed[@]: + save idx; + numeric idx; + idx:=@; + forever: + nfr_lmost_ppt[idx]:=sub_lmost_ppt[@]; + exitif unknown l_prm[idx]; + idx:=l_prm[idx]; + endfor + fi + if (known r_dlb[@]) or boxed[@]: + save idx; + numeric idx; + idx:=@; + forever: + nfr_rmost_ppt[idx]:=sub_rmost_ppt[@]; + exitif unknown r_prm[idx]; + idx:=r_prm[idx]; + endfor + fi +enddef; + % % Freezing % -vardef drv_freeze_root[]= +vardef drv_box_freeze[]= for prm_rnk=0 upto prm_num[@]-1: - drv_freeze_root[prm[@][prm_rnk]]; + drv_box_freeze[prm[@][prm_rnk]]; endfor for sbj_rnk=0 upto sbj_num[@]-1: box_freeze sbj[@][sbj_rnk]; @@ -1728,22 +2310,60 @@ vardef drv_freeze_root[]= endfor enddef; +vardef drv_arc_freeze[]= + for prm_rnk=0 upto prm_num[@]-1: + drv_arc_freeze[prm[@][prm_rnk]]; + endfor + for sbj_rnk=0 upto sbj_num[@]-1: + arc_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[@]: + arc_freeze sfx[@]; + fi + endfor +enddef; + vardef drv_freeze= if not drv_checked: drv_check; fi - save root_idx; - numeric root_idx; - for root_rnk=0 upto root_num-1: - root_idx:=root[root_rnk]; - drv_build_root[root_idx]; + save root_idx, tnum; + numeric root_idx, tnum; + % + % first root + % + root_idx:=root[0]; + if drv_radialmode_on: + drv_rad_build[root_idx]; + if unknown jdg[root_idx].rad: + jdg[root_idx].rad=10(num_hg-den_dp)/crv_scl; + fi + drv_ngl_build[root_idx]; + tnum:=if bot_jdg[root_idx]: - fi 1; % turning number + if unknown jdg[root_idx].cng: + jdg[root_idx].cng=-tnum*azimuth_ngl; + fi + if unknown jdg[root_idx].org: + % + % default math axis + % + jdg[root_idx].org= + (dir -jdg[root_idx].cng) scaled (tnum*axis_hg[drv_sty]+ + if drv_axis_ref="iln": + iln[root_idx].rad + else: % drv_axis_ref="jdg" + jdg[root_idx].rad + fi); + fi + drv_arc_freeze[root_idx]; + else: + drv_lin_build[root_idx]; if unknown xpart jdg[root_idx].c: - if root_rnk=0: - xpart jdg[root_idx].c=0; - else: - sub_min_x[root_idx]=sub_max_x[root[root_rnk-1]] - +prm_skp_scl*prm_skp[drv_sty]; - fi + xpart jdg[root_idx].c=0; fi if unknown ypart jdg[root_idx].c: % @@ -1755,8 +2375,64 @@ vardef drv_freeze= ypart jdg[root_idx].c=axis_hg[drv_sty]; fi fi - drv_freeze_root[root_idx]; - endfor + drv_box_freeze[root_idx]; + fi + % + % other roots + % + if drv_radialmode_on: + save l_rmost_rad, l_rmost_ngl, r_lmost_rad, r_lmost_ngl; + numeric l_rmost_rad, l_rmost_ngl, r_lmost_rad, r_lmost_ngl; + for root_rnk=1 upto root_num-1: + root_idx:=root[root_rnk]; + drv_rad_build[root_idx]; + if unknown jdg[root_idx].rad: + jdg[root_idx].rad=10(num_hg-den_dp)/crv_scl; + fi + drv_ngl_build[root_idx]; + tnum:=if bot_jdg[root_idx]: - fi 1; % turning number + l_rmost_rad:=rad_part sub_rmost_ppt[root[root_rnk-1]]; + l_rmost_ngl:=ngl_part sub_rmost_ppt[root[root_rnk-1]]; + r_lmost_rad:=rad_part sub_lmost_ppt[root_idx]; + r_lmost_ngl:=ngl_part sub_lmost_ppt[root_idx]; + if unknown jdg[root_idx].cng: + r_lmost_ngl=l_rmost_ngl+ + if bot_jdg[root_idx]=bot_jdg[root[root_rnk-1]]: + arc_angle (min (r_lmost_rad, l_rmost_rad), + prm_skp_scl*prm_skp[drv_sty]) tnum + else: + 180 + fi; + fi + if unknown jdg[root_idx].org: + jdg[root_idx].org= + if bot_jdg[root_idx]=bot_jdg[root[root_rnk-1]]: + jdg[root[root_rnk-1]].org + else: + (dir l_rmost_ngl) + scaled jdg[root[root_rnk-1]].rad + shifted jdg[root[root_rnk-1]].org + shifted ((dir (l_rmost_ngl-tnum*90)) + scaled (prm_skp_scl*prm_skp[drv_sty])) + shifted ((dir l_rmost_ngl) scaled jdg[root_idx].rad) + fi; + fi + drv_arc_freeze[root_idx]; + endfor + else: + for root_rnk=1 upto root_num-1: + root_idx:=root[root_rnk]; + drv_lin_build[root_idx]; + if unknown xpart jdg[root_idx].c: + sub_min_x[root_idx]=sub_max_x[root[root_rnk-1]] + +prm_skp_scl*prm_skp[drv_sty]; + fi + if unknown ypart jdg[root_idx].c: + ypart jdg[root_idx].c=ypart jdg[root[root_rnk-1]].c; + fi + drv_box_freeze[root_idx]; + endfor + fi drv_frozen:=true; enddef; @@ -1870,32 +2546,57 @@ vardef drv_tree= 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: - sub_min_x[@] - fi-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; - max_x:= - if known r_dlm[@].l: - xpart l_dlm[@].l - else: - sub_max_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 + if drv_radialmode_on: + save l_ngl, r_ngl, tnum; + numeric l_ngl, r_ngl, tnum; + tnum:=if bot_jdg[@]: - fi 1; % turning number + l_ngl:= + if known l_dlm[@].rng: + l_dlm[@].rng-arc_angle + (l_dlm[@].rad, jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + else: + (ngl_part sub_lmost_ppt[@])-arc_angle + (rad_part sub_lmost_ppt[@], + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + fi; + r_ngl:= + if known r_dlm[@].lng: + r_dlm[@].lng+arc_angle + (r_dlm[@].rad, jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + else: + (ngl_part sub_rmost_ppt[@])+arc_angle + (rad_part sub_rmost_ppt[@], + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + fi; + (circ_path(max_rad[@], r_ngl-l_ngl) tnum-- + reverse circ_path(min_rad[@], r_ngl-l_ngl) tnum-- + cycle) rotated l_ngl shifted jdg[@].org + else: + save minx, maxx, miny, maxy; + numeric minx, maxx, maxy, miny; + minx:= + if known l_dlm[@].r: + xpart l_dlm[@].r + else: + sub_min_x[@] + fi-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + maxx:= + if known r_dlm[@].l: + xpart l_dlm[@].l + else: + sub_max_x[@] + fi+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + miny:=min_y[@]; + maxy:=max_y[@]; + (minx, miny)-- + (minx, maxy)-- + (maxx, maxy)-- + (maxx, miny)-- + cycle + fi enddef; vardef mth_axis @# (suffix ref_sfx) (expr idx)= @@ -1986,6 +2687,25 @@ vardef check_position_left (suffix pos_sfx) (expr default)= fi enddef; +vardef check_position_bot (suffix pos_sfx) (expr default)= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if pos_str="t": + false + elseif pos_str="b": + true + else: + begingroup + drv_errhelp "Valid identifiers are"& + " t (top) and"& + " b (bottom)."; + drv_errmessage (pos_str&" is not a valid root position identifier"); + default + endgroup + fi +enddef; + vardef check_mode_on (suffix status_sfx) (expr default)= save status_str; string status_str; @@ -2027,7 +2747,7 @@ vardef drv_math_style (suffix typ_sfx) (expr sty_str)= else: forsuffixes sfx=scantokens (typ_str&"_sty"): for idx=0 upto 3: - sfx[idx]:=min(idx+sty_idx, 3); + sfx[idx]:=min (idx+sty_idx, 3); endfor endfor fi @@ -2046,12 +2766,15 @@ vardef drv_scale (suffix scl_sfx) (expr scl)= jdg_skp_scl:=scl; elseif (scl_str="ilb") or (scl_str="lbl"): % "lbl" is deprecated ilb_skp_scl:=scl; + elseif scl_str="crv": + crv_scl:=scl; else: drv_errhelp "Valid identifiers are"& " clr,"& " prm,"& - " jdg and"& - " ilb."; + " jdg,"& + " ilb and"& + " crv."; drv_errmessage (scl_str&" is not a valid scale identifier"); fi enddef; @@ -2104,19 +2827,7 @@ vardef drv_labels_position text ARG= 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 + drv_bot_roots:=check_position_bot (pos_sfx) (drv_bot_roots); enddef; vardef drv_axis_reference suffix ref_sfx= @@ -2161,6 +2872,14 @@ vardef drv_proof_mode suffix status_sfx= drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); enddef; +vardef drv_radial_mode suffix status_sfx= + drv_radialmode_on:=check_mode_on (status_sfx, drv_radialmode_on); +enddef; + +vardef drv_azimuth expr ngl= + azimuth_ngl:=ngl; +enddef; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -2192,6 +2911,10 @@ drv_box_mode off; drv_fraction_mode on; drv_proof_mode off; +drv_radial_mode off; +drv_scale (crv, 1); +drv_azimuth 90; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % diff --git a/Master/texmf-dist/doc/metapost/drv/doc/makefile b/Master/texmf-dist/doc/metapost/drv/doc/makefile index ce2f2b8c6cf..05796563275 100644 --- a/Master/texmf-dist/doc/metapost/drv/doc/makefile +++ b/Master/texmf-dist/doc/metapost/drv/doc/makefile @@ -2,6 +2,8 @@ MAIN= drv-guide $(MAIN).pdf: $(MAIN).ps ps2pdf $(MAIN).ps + pdfopt $(MAIN).pdf $(MAIN)-opt.pdf + mv $(MAIN)-opt.pdf $(MAIN).pdf $(MAIN).ps: $(MAIN).tex $(MAIN)-delayed.mp latex $(MAIN) diff --git a/Master/texmf-dist/doc/metapost/drv/doc/readme.txt b/Master/texmf-dist/doc/metapost/drv/doc/readme.sh index 66f2719391a..e9d55e741d5 100644 --- a/Master/texmf-dist/doc/metapost/drv/doc/readme.txt +++ b/Master/texmf-dist/doc/metapost/drv/doc/readme.sh @@ -1,4 +1,5 @@ -# In order to compile the sources and to get a pdf file, use `make' or: +# In order to compile the sources and to get a pdf file, +# use `make' or `./readme.sh' or: # 1. run metapost THREE TIMES: mpost drv-guide.mp diff --git a/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf b/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf Binary files differindex 8b1cf44c736..6f16b8ecd87 100644 --- a/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf +++ b/Master/texmf-dist/doc/metapost/drv/drv-guide.pdf diff --git a/Master/texmf-dist/doc/metapost/drv/sample/drv.mp b/Master/texmf-dist/doc/metapost/drv/sample/drv.mp index 69f2f9f72c7..a5791649f82 100644 --- a/Master/texmf-dist/doc/metapost/drv/sample/drv.mp +++ b/Master/texmf-dist/doc/metapost/drv/sample/drv.mp @@ -1,5 +1,5 @@ -%% drv.mp 0.94 -%% Copyright 2009 Laurent M\'ehats +%% drv 0.95 +%% Copyright 2010 Laurent M\'ehats % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -16,6 +16,9 @@ % % This work consists of the file drv.mp +newinternal drv_version; +drv_version:=0.95; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -142,8 +145,9 @@ % <str> LaTeX math-style command % % drv_scale (<id>, <float>) -% <id> scale identifier (clr, prm, jdg or ilb) +% <id> scale identifier (clr, crv, prm, jdg or ilb) % clr nice explanation soon (see examples) +% crv nice explanation soon (see examples) % prm nice explanation soon (see examples) % jdg nice explanation soon (see examples) % ilb nice explanation soon (see examples) @@ -217,6 +221,15 @@ % on % off % +% drv_radial_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_azimuth <float> +% <float> azimuth degree +% +% % * Derivation tree pictures % ========================== % @@ -234,6 +247,12 @@ % <path> MetaPost path expression % <id> path style identifier (0, 1, 2, 3, 4, 5 or 6) % +% drv_root (<nat>, <id>) +% <nat> root index +% <id> position identifier (t or b) +% t top +% b bottom +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -250,9 +269,8 @@ vardef drv_format (expr str, fst_len, nxt_len, dbl_pcs)= % 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; + save str_len, sub_len, aux_len, chr_rnk, occ_num, aux_str, chr; 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; @@ -315,6 +333,8 @@ vardef drv_errmessage expr str= errmessage drv_format (drv_context&str, 77, 79, false); enddef; +drv_message "version "&decimal drv_version&"."; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -488,11 +508,23 @@ picture tt_dgt[][]; 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_fontdimen[] expr font= - save dim_pct; + save dim_pct, dim_str; picture dim_pct; - dim_pct:=drv_tex[0] ("\rule{\the\fontdimen"&(decimal @)&font&"}{0bp}"); - width dim_pct + string dim_str; + dim_pct:=drv_tex[0] ("\mbox{\the\fontdimen"&(decimal @)&font&"}"); + dim_str:="0"; + for tok within dim_pct: + dim_str:=dim_str&(textpart tok); + endfor + scantokens dim_str enddef; vardef drv_font_size expr size_str= @@ -530,11 +562,11 @@ vardef drv_font_size expr size_str= 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] "\,"; + sp_pct:=drv_tex[mth_sty] "\thinspace"; thn_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\>"; + sp_pct:=drv_tex[mth_sty] "\medspace"; med_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\;"; + sp_pct:=drv_tex[mth_sty] "\thickspace"; thk_sp[mth_sty]:=width sp_pct; pdt_pct:=drv_tex[mth_sty] "\ldotp"; pdt_hg[mth_sty]:=height pdt_pct; @@ -588,6 +620,7 @@ vardef drv_box text STR= expandafter pair scantokens str.r; expandafter numeric scantokens str.hg; expandafter numeric scantokens str.dp; + drv_arc str; endfor enddef; @@ -606,6 +639,119 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +% drv-arcs +% + +vardef drv_arc text STR= + for str=STR: + expandafter numeric scantokens str.rad; + expandafter numeric scantokens str.lng; + expandafter numeric scantokens str.cng; + expandafter numeric scantokens str.rng; + expandafter pair scantokens str.org; + endfor +enddef; + +vardef arc_init @# (expr pct, ngl)= + @#:=pct; + @#.rng-@#.lng=ngl; + @#.cng=(@#.lng+@#.rng)/2; +enddef; + +vardef arc_freeze @#= + @#:=@# rotated @#.lng shifted @#.org; + @#.l:=(dir @#.lng) scaled @#.rad shifted @#.org; + @#.c:=(dir @#.cng) scaled @#.rad shifted @#.org; + @#.r:=(dir @#.rng) scaled @#.rad shifted @#.org; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Polar coordinates, angles & text torsion +% + +vardef rad_part expr ppt= + xpart ppt +enddef; + +vardef ngl_part expr ppt= + ypart ppt +enddef; + +vardef minrad (expr ppt_a, ppt_b)= + min (rad_part ppt_a, rad_part ppt_b) +enddef; + +% "tnum" (turning number) argument: +% -1: clockwise +% 1: counterclockwise + +vardef lmost_ppt (expr ppt_a, ppt_b) expr tnum= + if tnum*(ngl_part ppt_a)<tnum*(ngl_part ppt_b): + ppt_a + else: + ppt_b + fi +enddef; + +vardef rmost_ppt (expr ppt_a, ppt_b) expr tnum= + if tnum*(ngl_part ppt_a)>tnum*(ngl_part ppt_b): + ppt_a + else: + ppt_b + fi +enddef; + +vardef arc_angle (expr rad, arc_len) expr tnum= + if rad>0: + save pth; + path pth; + pth:=fullcircle scaled (2*rad); + tnum*(angle point (arctime arc_len of pth) of pth) + else: + 0 + fi +enddef; + +vardef circ_path (expr rad, ngl) expr tnum= + save pth; + path pth; + pth:=if tnum=-1: reverse fi fullcircle scaled (2*rad); + subpath (0, directiontime (dir (ngl+tnum*90)) of pth) of pth +enddef; + +vardef text_arc (expr pct, rad) expr tnum= + save arc_pct, tok_str, tok_trn, tok_ngl, hlf_wd, chr_pct; + picture arc_pct, chr_pct; + numeric tok_ngl, hlf_wd; + string tok_str; + arc_pct:=nullpicture; + for tok within pct: + transform tok_trn; + tok_str:=textpart tok; + (0, 0) transformed tok_trn=(0, 0); + (0, 1) transformed tok_trn=(xypart tok, yypart tok); + (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); + tok_ngl:=arc_angle (rad, xpart tok) tnum; + for chr_rnk=0 upto (length tok_str-1): + chr_pct:=substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) + transformed tok_trn; + hlf_wd:=(width chr_pct)/2; + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + addto arc_pct also chr_pct + shifted (-hlf_wd, 0) + rotated (tok_ngl+tnum*90) + shifted ((dir tok_ngl) scaled (rad-tnum*(ypart tok))); + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + endfor + endfor + arc_pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % beginfig & endfig % @@ -637,14 +783,17 @@ vardef drv_beginfig= % iln_sty[i] inference line style % l_prm[i] leftmost `graphical' premise index % r_prm[i] rightmost `graphical' premise index + % bot_jdg[i] boolean % numeric prm_num[], prm[][], ccl[]; numeric jct_sty[]; string alg_sty[]; numeric iln_sty[]; numeric l_prm[], r_prm[]; + boolean bot_jdg[]; % % nfr_min_x[i] inference minimal x + % nfr_lmost_ppt[i] inference leftmost polar point % l_dlb[i] left delimiter label drv-box % l_dlm[i] left delimiter drv-box % l_ilb[i] left label drv-box @@ -653,22 +802,31 @@ vardef drv_beginfig= % r_dlm[i] right delimiter drv-box % r_dlb[i] right delimiter label drv-box % nfr_max_x[i] inference maximal x + % nfr_rmost_ppt[i] inference rightmost polar point % numeric nfr_min_x[]; + pair nfr_lmost_ppt[]; drv_box "l_dlb[]", "l_dlm[]", "l_ilb[]"; drv_box "iln[]"; drv_box "r_ilb[]", "r_dlm[]", "r_dlb[]"; numeric nfr_max_x[]; + pair nfr_rmost_ppt[]; % % Sub-trees % % sub_min_x[i] sub-tree minimal x + % sub_lmost_ppt[i] sub-tree leftmost polar point % sub_max_x[i] sub-tree maximal x + % sub_rmost_ppt[i] sub-tree rightmost polar point % sub_min_y[i] sub-tree minimal y + % sub_min_rad[i] sub-tree minimal radius % sub_max_y[i] sub-tree maximal y + % sub_max_rad[i] sub-tree maximal radius % boxed[i] boolean % numeric sub_min_x[], sub_max_x[], sub_min_y[], sub_max_y[]; + pair sub_lmost_ppt[], sub_rmost_ppt[]; + numeric sub_min_rad[], sub_max_rad[]; boolean boxed[]; % % Pen initialization @@ -953,8 +1111,8 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % PRM: list of premise indices % - save prm_rnk; - numeric prm_rnk; + save prm_rnk, root_rnk; + numeric prm_rnk, root_rnk; prm_rnk:=0; for prm_idx=PRM: if prm_idx=@: @@ -971,8 +1129,6 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % roots list update % - save root_rnk; - numeric root_rnk; root_rnk:=0; forever: exitif root[root_rnk]=prm_idx; @@ -1324,24 +1480,46 @@ string drv_rdlm_str; % right delimiter LaTeX code % 2. Macros % -vardef minmax_y[]=( - if drv_bot_roots: +vardef min_y[]= + if bot_jdg[@]: if known ccl[@]: ypart jdg[@].c-num_hg+iln_hg[(iln_sty[ccl[@]])] +min_clr_scl*min_clr[drv_sty]/2 else: sub_min_y[@]-min_clr_scl*min_clr[drv_sty] - fi, + fi + else: + sub_min_y[@]-min_clr_scl*min_clr[drv_sty] + fi +enddef; + +vardef max_y[]= + if bot_jdg[@]: sub_max_y[@]+min_clr_scl*min_clr[drv_sty] else: - sub_min_y[@]-min_clr_scl*min_clr[drv_sty], if known ccl[@]: ypart jdg[@].c-den_dp+iln_dp[(iln_sty[ccl[@]])] -min_clr_scl*min_clr[drv_sty]/2 else: sub_max_y[@]+min_clr_scl*min_clr[drv_sty] fi - fi) + fi +enddef; + +vardef min_rad[]= + if known ccl[@]: + if bot_jdg[@]: + jdg[@].rad-num_hg+iln_hg[(iln_sty[ccl[@]])] + else: + jdg[@].rad+den_dp-iln_dp[(iln_sty[ccl[@]])] + fi+min_clr_scl*min_clr[drv_sty]/2 + else: + sub_min_rad[@]-min_clr_scl*min_clr[drv_sty] + fi +enddef; + +vardef max_rad[]= + sub_max_rad[@]+min_clr_scl*min_clr[drv_sty] enddef; vardef delim @# expr dlm_len= @@ -1394,6 +1572,10 @@ boolean drv_boxmode_on; % boolean drv_fractionmode_on; % string drv_axis_ref; % +boolean drv_radialmode_on; % +numeric crv_scl; % +numeric azimuth_ngl; % + % % 2. Macros % @@ -1410,7 +1592,7 @@ vardef fraction_inference[]= and drv_fractionmode_on enddef; -vardef drv_check_root[]= +vardef drv_bot_check[]= if unknown jdg[@]: drv_errhelp "An index must be used to declare a both a judgment and an"& " inference."; @@ -1425,29 +1607,56 @@ vardef drv_check_root[]= save i_sty, prm_idx; numeric i_sty, prm_idx; i_sty:=iln_sty[@]; + bot_jdg[@]:=true; for prm_rnk=0 upto prm_num[@]-1: prm_idx:=prm[@][prm_rnk]; - drv_check_root[prm_idx]; + drv_bot_check[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 + num_hg:=max (num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].dp); 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 + den_dp:=min (den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[@].hg); + fi + if unknown boxed[@]: + boxed[@]:=drv_boxmode_on; + fi + fi +enddef; + +vardef drv_top_check[]= + 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[@]; + bot_jdg[@]:=false; + for prm_rnk=0 upto prm_num[@]-1: + prm_idx:=prm[@][prm_rnk]; + drv_top_check[prm_idx]; + % + % numerators and denominators clearances + % The TEXbook, Appendix G, Rule 15d. + % + den_dp:=min (den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].hg); + endfor + if not fraction_inference[@]: + num_hg:=max (num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[@].dp); fi if unknown boxed[@]: boxed[@]:=drv_boxmode_on; @@ -1455,24 +1664,42 @@ vardef drv_check_root[]= fi enddef; +vardef drv_root (expr idx) (suffix pos_sfx)= + save root_idx; + numeric root_idx; + root_idx:=idx; + forever: + exitif unknown ccl[root_idx]; + root_idx:=ccl[root_idx]; + endfor + if idx<>root_idx: + drv_message "warning, "&(decimal idx)&" is not a root index"& + " (the actual root index is "&(decimal root_idx)&")."; + fi + bot_jdg[root_idx]:=check_position_bot (pos_sfx) (drv_bot_roots); +enddef; + vardef drv_check= if root_num=0: drv_errhelp "Well ..."; drv_errmessage "no inference has been declared"; else: - save root_idx; + save root_idx, root_str; numeric root_idx; - root_idx:=root[0]; - drv_check_root[root_idx]; + string root_str; + for root_rnk=0 upto root_num-1: + root_idx:=root[root_rnk]; + if unknown bot_jdg[root_idx]: + bot_jdg[root_idx]:=drv_bot_roots; + fi + if bot_jdg[root_idx]: + drv_bot_check[root_idx]; + else: + drv_top_check[root_idx]; + fi + root_str:=if root_rnk>0: root_str&", "& fi decimal root_idx; + endfor if root_num>1: - save root_str; - string root_str; - root_str:=decimal root_idx; - for root_rnk=1 upto root_num-1: - root_idx:=root[root_rnk]; - drv_check_root[root_idx]; - root_str:=root_str&", "&(decimal root_idx); - endfor drv_message "warning, multiple root indices ("&root_str&")."; fi fi @@ -1483,11 +1710,11 @@ enddef; % Building % -vardef drv_build_root[]= +vardef drv_lin_build[]= % % orientation % - if drv_bot_roots: + if bot_jdg[@]: ypart iln[@].c=ypart jdg[@].c-den_dp; sub_min_y[@]:=ypart jdg[@].c+jdg[@].dp; sub_max_y[@]:= @@ -1498,8 +1725,8 @@ vardef drv_build_root[]= fi; for prm_rnk=0 upto prm_num[@]-1: ypart jdg[prm[@][prm_rnk]].c=ypart iln[@].c+num_hg; - drv_build_root[prm[@][prm_rnk]]; - sub_max_y[@]:=max(sub_max_y[@], sub_max_y[prm[@][prm_rnk]]); + drv_lin_build[prm[@][prm_rnk]]; + sub_max_y[@]:=max (sub_max_y[@], sub_max_y[prm[@][prm_rnk]]); endfor else: ypart iln[@].c=ypart jdg[@].c-num_hg; @@ -1512,18 +1739,16 @@ vardef drv_build_root[]= sub_max_y[@]:=ypart jdg[@].c+jdg[@].hg; for prm_rnk=0 upto prm_num[@]-1: ypart jdg[prm[@][prm_rnk]].c=ypart iln[@].c+den_dp; - drv_build_root[prm[@][prm_rnk]]; - sub_min_y[@]:=min(sub_min_y[@], sub_min_y[prm[@][prm_rnk]]); + drv_lin_build[prm[@][prm_rnk]]; + sub_min_y[@]:=min (sub_min_y[@], sub_min_y[prm[@][prm_rnk]]); endfor fi % % premises junction (from left to right) % - for prm_rnk=1 upto prm_num[@]-1: - save l_lmost, l_rmost, r_lmost, r_rmost; - save l_max_x, r_min_x, min_skp; - numeric l_lmost, l_rmost, r_lmost, r_rmost; - numeric l_max_x, r_min_x, min_skp[]; + save l_lmost, l_rmost, r_lmost, r_rmost, l_max_x, r_min_x, min_skp; + numeric l_lmost, l_rmost, r_lmost, r_rmost, l_max_x, r_min_x, min_skp[]; + for prm_rnk=1 upto prm_num[@]-1: l_lmost:=prm[@][0]; l_rmost:=prm[@][prm_rnk-1]; r_lmost:=prm[@][prm_rnk]; @@ -1537,9 +1762,9 @@ vardef drv_build_root[]= l_rmost:=r_prm[l_rmost]; r_lmost:=l_prm[r_lmost]; r_rmost:=r_prm[r_rmost]; - l_max_x:=max(l_max_x, nfr_max_x[l_rmost]); - r_min_x:=min(r_min_x, nfr_min_x[r_lmost]); - min_skp[0]:=min(min_skp[0], nfr_min_x[r_lmost]-nfr_max_x[l_rmost]); + l_max_x:=max (l_max_x, nfr_max_x[l_rmost]); + r_min_x:=min (r_min_x, nfr_min_x[r_lmost]); + min_skp[0]:=min (min_skp[0], nfr_min_x[r_lmost]-nfr_max_x[l_rmost]); endfor min_skp[1]:=r_min_x-l_max_x; if known r_prm[l_rmost]: @@ -1583,8 +1808,8 @@ vardef drv_build_root[]= elseif alg_sty[@]="r": xpart jdg[@].r=r_xref; fi - nfr_min_x[@]:=min(xpart jdg[@].l, l_xref); - nfr_max_x[@]:=max(xpart jdg[@].r, r_xref); + nfr_min_x[@]:=min (xpart jdg[@].l, l_xref); + nfr_max_x[@]:=max (xpart jdg[@].r, r_xref); fi % % inference line @@ -1612,14 +1837,14 @@ vardef drv_build_root[]= if known l_ilb[@]: l_ilb[@].r=iln[@].l shifted (-ilb_skp_scl*ilb_skp[drv_sty], 0); nfr_min_x[@]:=xpart l_ilb[@].l; - sub_min_y[@]:=min(sub_min_y[@], ypart l_ilb[@].c+l_ilb[@].dp); - sub_max_y[@]:=max(sub_max_y[@], ypart l_ilb[@].c+l_ilb[@].hg); + sub_min_y[@]:=min (sub_min_y[@], ypart l_ilb[@].c+l_ilb[@].dp); + sub_max_y[@]:=max (sub_max_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); nfr_max_x[@]:=xpart r_ilb[@].r; - sub_min_y[@]:=min(sub_min_y[@], ypart r_ilb[@].c+r_ilb[@].dp); - sub_max_y[@]:=max(sub_max_y[@], ypart r_ilb[@].c+r_ilb[@].hg); + sub_min_y[@]:=min (sub_min_y[@], ypart r_ilb[@].c+r_ilb[@].dp); + sub_max_y[@]:=max (sub_max_y[@], ypart r_ilb[@].c+r_ilb[@].hg); fi % % phantom steps @@ -1628,29 +1853,29 @@ vardef drv_build_root[]= save bot_y, top_y, phm_pct; numeric bot_y, top_y; picture phm_pct; - if drv_bot_roots: - bot_y:=xpart minmax_y[@]+min_clr_scl*min_clr[drv_sty]/2; - top_y:=xpart minmax_y[tgt[@]]; + if bot_jdg[@]: + bot_y:=min_y[@]+min_clr_scl*min_clr[drv_sty]/2; + top_y:=min_y[tgt[@]]; else: - bot_y:=ypart minmax_y[tgt[@]]; - top_y:=ypart minmax_y[@]-min_clr_scl*min_clr[drv_sty]/2; + bot_y:=max_y[tgt[@]]; + top_y:=max_y[@]-min_clr_scl*min_clr[drv_sty]/2; fi phm_pct:=((0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2)) drv_styled phm_sty[@]; box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); phm[@].c=(xpart jdg[@].c, (top_y+bot_y)/2); - nfr_min_x[@]:=min(nfr_min_x[@], xpart phm[@].l); - nfr_max_x[@]:=max(nfr_max_x[@], xpart phm[@].r); + nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[@].l); + nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[@].r); % % phantom steps labels % if known l_plb[@]: l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); - nfr_min_x[@]:=min(nfr_min_x[@], xpart l_plb[@].l); + nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[@].l); fi if known r_plb[@]: r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); - nfr_max_x[@]:=max(nfr_max_x[@], xpart r_plb[@].r); + nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[@].r); fi fi % @@ -1659,28 +1884,26 @@ vardef drv_build_root[]= sub_min_x[@]:=nfr_min_x[@]; sub_max_x[@]:=nfr_max_x[@]; for prm_rnk=0 upto prm_num[@]-1: - sub_min_x[@]:=min(sub_min_x[@], sub_min_x[prm[@][prm_rnk]]); - sub_max_x[@]:=max(sub_max_x[@], sub_max_x[prm[@][prm_rnk]]); + sub_min_x[@]:=min (sub_min_x[@], sub_min_x[prm[@][prm_rnk]]); + sub_max_x[@]:=max (sub_max_x[@], sub_max_x[prm[@][prm_rnk]]); endfor % % delimiters % if known l_dlb[@] or known r_dlb[@]: - save mmy, min_y, max_y; - numeric min_y, max_y; - pair mmy; - mmy:=minmax_y[@]; - min_y:=xpart mmy; - max_y:=ypart mmy; + save miny, maxy; + numeric miny, maxy; + miny:=min_y[@]; + maxy:=max_y[@]; if known l_dlb[@]: - box_init l_dlm[@] (delim l (max_y-min_y)); - l_dlm[@].r=(sub_min_x[@], (max_y+min_y)/2); + box_init l_dlm[@] (delim l (maxy-miny)); + l_dlm[@].r=(sub_min_x[@], (maxy+miny)/2); l_dlb[@].r=l_dlm[@].l; sub_min_x[@]:=xpart l_dlb[@].l; fi if known r_dlb[@]: - box_init r_dlm[@] (delim r (max_y-min_y)); - r_dlm[@].l=(sub_max_x[@], (max_y+min_y)/2); + box_init r_dlm[@] (delim r (maxy-miny)); + r_dlm[@].l=(sub_max_x[@], (maxy+miny)/2); r_dlb[@].l=r_dlm[@].r; sub_max_x[@]:=xpart r_dlb[@].r; fi @@ -1707,13 +1930,372 @@ vardef drv_build_root[]= fi enddef; +vardef drv_rad_build[]= + for sbj_rnk=0 upto (sbj_num[@]-1): + sbj[@][sbj_rnk].rad=jdg[@].rad; + sbj[@][sbj_rnk].org=jdg[@].org; + endfor + % + % orientation + % + if bot_jdg[@]: + iln[@].rad=jdg[@].rad-den_dp; + iln[@].org=jdg[@].org; + sub_min_rad[@]:=jdg[@].rad+jdg[@].dp; + sub_max_rad[@]:= + if iln_sty[@]=0: + jdg[@].rad+jdg[@].hg + else: + iln[@].rad+iln_hg[iln_sty[@]] + fi; + for prm_rnk=0 upto prm_num[@]-1: + jdg[prm[@][prm_rnk]].rad=iln[@].rad+num_hg; + jdg[prm[@][prm_rnk]].org=iln[@].org; + drv_rad_build[prm[@][prm_rnk]]; + sub_max_rad[@]:=max (sub_max_rad[@], sub_max_rad[prm[@][prm_rnk]]); + endfor + else: + iln[@].rad=jdg[@].rad+num_hg; + iln[@].org=jdg[@].org; + sub_min_rad[@]:=jdg[@].rad-jdg[@].hg; + sub_max_rad[@]:= + if iln_sty[@]=0: + jdg[@].rad-jdg[@].dp + else: + iln[@].rad-iln_dp[iln_sty[@]] + fi; + for prm_rnk=0 upto prm_num[@]-1: + jdg[prm[@][prm_rnk]].rad=iln[@].rad-den_dp; + jdg[prm[@][prm_rnk]].org=iln[@].org; + drv_rad_build[prm[@][prm_rnk]]; + sub_max_rad[@]:=max (sub_max_rad[@], sub_max_rad[prm[@][prm_rnk]]); + endfor; + fi + % + % inference labels + % + if known l_ilb[@]: + l_ilb[@].rad=iln[@].rad; + l_ilb[@].org=iln[@].org; + sub_max_rad[@]:=max (sub_max_rad[@], + l_ilb[@].rad if bot_jdg[@]: +l_ilb[@].hg else: -l_ilb[@].dp fi); + fi + if known r_ilb[@]: + r_ilb[@].rad=iln[@].rad; + r_ilb[@].org=iln[@].org; + sub_max_rad[@]:=max (sub_max_rad[@], + r_ilb[@].rad if bot_jdg[@]: +r_ilb[@].hg else: -r_ilb[@].dp fi); + fi + % + % phantom steps + % + if known tgt[@]: + save src_rad, tgt_rad; + numeric src_rad, tgt_rad; + src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; + tgt_rad:=min_rad[tgt[@]]; + phm[@].rad=(src_rad+tgt_rad)/2; + phm[@].org=jdg[@].org; + % + % phantom steps labels + % + if known l_plb[@]: + l_plb[@].rad=phm[@].rad; + l_plb[@].org=phm[@].org; + fi + if known r_plb[@]: + r_plb[@].rad=phm[@].rad; + r_plb[@].org=phm[@].org; + fi + fi + % + % delimiters + % + if known l_dlb[@] or known r_dlb[@]: + save minr, maxr; + numeric minr, maxr; + minr:=min_rad[@]; + maxr:=max_rad[@]; + if known l_dlb[@]: + l_dlm[@].rad=(minr+maxr)/2; + l_dlb[@].rad=l_dlm[@].rad; + l_dlb[@].org=l_dlm[@].org=jdg[@].org; + fi + if known r_dlb[@]: + r_dlm[@].rad=(minr+maxr)/2; + r_dlb[@].rad=r_dlm[@].rad; + r_dlb[@].org=r_dlm[@].org=jdg[@].org; + fi + fi +enddef; + +vardef drv_ngl_build[]= + for prm_rnk=0 upto prm_num[@]-1: + drv_ngl_build[prm[@][prm_rnk]]; + endfor + save tnum; + numeric tnum; + tnum:=if bot_jdg[@]: - fi 1; % turning number + % + % judgment arc + % + save jdg_pct, jdg_ngl; + picture jdg_pct; + numeric jdg_ngl; + jdg_pct:=nullpicture; + jdg_ngl:=0; + for sbj_rnk=0 upto (sbj_num[@]-1): + arc_init sbj[@][sbj_rnk] + (text_arc (sbj[@][sbj_rnk], sbj[@][sbj_rnk].rad) tnum, + arc_angle (sbj[@][sbj_rnk].rad, width sbj[@][sbj_rnk]) tnum); + if sbj_rnk>0: % non mandatory test + sbj[@][sbj_rnk-1].rng=sbj[@][sbj_rnk].lng;% irrelevant if rnk=0 + fi + addto jdg_pct also sbj[@][sbj_rnk] rotated jdg_ngl; + jdg_ngl:=jdg_ngl+sbj[@][sbj_rnk].rng-sbj[@][sbj_rnk].lng; + endfor + arc_init jdg[@] (jdg_pct, jdg_ngl); + if sbj_num[@]>0: % non mandatory test + jdg[@].lng=sbj[@][0].lng; % irrelevant if sbj_num=0 + fi + % + % premises junction (from left to right) + % + save l_lmost, l_rmost, r_lmost, r_rmost, l_rmost_ppt, r_lmost_ppt, ppt_skp; + numeric l_lmost, l_rmost, r_lmost, r_rmost; + pair l_rmost_ppt, r_lmost_ppt, ppt_skp[]; + for prm_rnk=1 upto prm_num[@]-1: + l_lmost:=prm[@][0]; + l_rmost:=prm[@][prm_rnk-1]; + r_lmost:=prm[@][prm_rnk]; + r_rmost:=prm[@][prm_rnk]; + l_rmost_ppt:=nfr_rmost_ppt[l_rmost]; + r_lmost_ppt:=nfr_lmost_ppt[r_lmost]; + ppt_skp[0]:=(minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt)); + forever: + exitif (unknown r_prm[l_rmost]) or (unknown l_prm[r_lmost]); + l_lmost:=l_prm[l_lmost]; + l_rmost:=r_prm[l_rmost]; + r_lmost:=l_prm[r_lmost]; + r_rmost:=r_prm[r_rmost]; + l_rmost_ppt:=rmost_ppt (l_rmost_ppt, nfr_rmost_ppt[l_rmost]) tnum; + r_lmost_ppt:=lmost_ppt (r_lmost_ppt, nfr_lmost_ppt[r_lmost]) tnum; + ppt_skp[0]:=rmost_ppt (ppt_skp[0], (minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt))) tnum; + endfor + ppt_skp[1]:=(minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt)); + if known r_prm[l_rmost]: + r_prm[r_rmost]:=r_prm[l_rmost]; + l_rmost_ppt:=sub_rmost_ppt[l_rmost]; + elseif known l_prm[r_lmost]: + l_prm[l_lmost]:=l_prm[r_lmost]; + r_lmost_ppt:=sub_lmost_ppt[r_lmost]; + fi + ppt_skp[2]:=(minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt)); + if jct_sty[@]<3: + (ngl_part ppt_skp[jct_sty[@]])= + arc_angle(rad_part ppt_skp[jct_sty[@]], + prm_skp_scl*prm_skp[drv_sty]) tnum; + fi + endfor + % + % judgment alignment + % + if prm_num[@]=0: + nfr_lmost_ppt[@]:=(jdg[@].rad, jdg[@].lng); + nfr_rmost_ppt[@]:=(jdg[@].rad, jdg[@].rng); + else: + l_prm[@]:=prm[@][0]; + r_prm[@]:=prm[@][prm_num[@]-1]; + save l_ngl_ref, r_ngl_ref; + numeric l_ngl_ref, r_ngl_ref; + l_ngl_ref= + if boxed[l_prm[@]]: + ngl_part sub_lmost_ppt[l_prm[@]] + else: + jdg[l_prm[@]].lng + fi; + r_ngl_ref= + if boxed[r_prm[@]]: + ngl_part sub_rmost_ppt[r_prm[@]] + else: + jdg[r_prm[@]].rng + fi; + if alg_sty[@]="l": + jdg[@].lng=l_ngl_ref; + elseif alg_sty[@]="c": + jdg[@].cng=(l_ngl_ref+r_ngl_ref)/2; + elseif alg_sty[@]="r": + jdg[@].rng=r_ngl_ref; + fi + nfr_lmost_ppt[@]:=( + jdg[@].rad, + tnum*min (tnum*jdg[@].lng, tnum*l_ngl_ref)); + nfr_rmost_ppt[@]:=( + jdg[@].rad, + tnum*max (tnum*jdg[@].rng, tnum*r_ngl_ref)); + fi + % + % inference line + % + save iln_ngl; + numeric iln_ngl; + iln_ngl:=2*(arc_angle(iln[@].rad, + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum) + +(ngl_part nfr_rmost_ppt[@]) + -(ngl_part nfr_lmost_ppt[@]); + arc_init iln[@] + ((circ_path (iln[@].rad, iln_ngl) tnum) drv_styled iln_sty[@], iln_ngl); + iln[@].hg=iln_hg[iln_sty[@]]; + iln[@].dp=iln_dp[iln_sty[@]]; + iln[@].cng=((ngl_part nfr_lmost_ppt[@])+(ngl_part nfr_rmost_ppt[@]))/2; + if iln_sty[@]>0: + nfr_lmost_ppt[@]:=(iln[@].rad, iln[@].lng); + nfr_rmost_ppt[@]:=(iln[@].rad, iln[@].rng); + fi + % + % inference labels + % + if known l_ilb[@]: + arc_init l_ilb[@]( + text_arc (l_ilb[@], l_ilb[@].rad) tnum, + arc_angle (l_ilb[@].rad, width l_ilb[@]) tnum); + l_ilb[@].rng=iln[@].lng + -arc_angle (l_ilb[@].rad, ilb_skp_scl*ilb_skp[drv_sty]) tnum; + nfr_lmost_ppt[@]:=(l_ilb[@].rad, l_ilb[@].lng); + fi + if known r_ilb[@]: + arc_init r_ilb[@]( + text_arc (r_ilb[@], r_ilb[@].rad) tnum, + arc_angle (r_ilb[@].rad, width r_ilb[@]) tnum); + r_ilb[@].lng=iln[@].rng + +arc_angle (r_ilb[@].rad, ilb_skp_scl*ilb_skp[drv_sty]) tnum; + nfr_rmost_ppt[@]:=(r_ilb[@].rad, r_ilb[@].rng); + fi + % + % phantom steps + % + if known tgt[@]: + save phm_pct, src_rad, tgt_rad; + picture phm_pct; + numeric src_rad, tgt_rad; + src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; + tgt_rad:=min_rad[tgt[@]]; + phm_pct:=((0, (src_rad-tgt_rad)/2)--(0, (tgt_rad-src_rad)/2)) + drv_styled phm_sty[@]; + arc_init phm[@] ( + phm_pct + rotated (tnum*90+arc_angle (phm[@].rad, (width phm_pct)/2) tnum) + shifted ((dir 0) scaled phm[@].rad), + arc_angle (phm[@].rad, width phm_pct) tnum); + phm[@].cng=jdg[@].cng; + nfr_lmost_ppt[@]:=lmost_ppt (nfr_lmost_ppt[@], + (phm[@].rad, phm[@].lng)) tnum; + nfr_rmost_ppt[@]:=rmost_ppt (nfr_rmost_ppt[@], + (phm[@].rad, phm[@].rng)) tnum; + % + % phantom steps labels + % + if known l_plb[@]: + arc_init l_plb[@]( + text_arc (l_plb[@], l_plb[@].rad) tnum, + arc_angle (l_plb[@].rad, width l_plb[@]) tnum); + l_plb[@].rng=phm[@].lng + -arc_angle (l_plb[@].rad, plb_skp[drv_sty]) tnum; + nfr_lmost_ppt[@]:= + lmost_ppt(nfr_lmost_ppt[@], (l_plb[@].rad, l_plb[@].lng)) tnum; + fi + if known r_plb[@]: + arc_init r_plb[@]( + text_arc (r_plb[@], r_plb[@].rad) tnum, + arc_angle (r_plb[@].rad, width r_plb[@]) tnum); + r_plb[@].lng=phm[@].rng + +arc_angle (r_plb[@].rad, plb_skp[drv_sty]) tnum; + nfr_rmost_ppt[@]:= + rmost_ppt(nfr_rmost_ppt[@], (r_plb[@].rad, r_plb[@].rng)) tnum; + fi + fi + % + % sub_lmost_ppt & sub_rmost_ppt + % + sub_lmost_ppt[@]:=nfr_lmost_ppt[@]; + sub_rmost_ppt[@]:=nfr_rmost_ppt[@]; + for prm_rnk=0 upto prm_num[@]-1: + sub_lmost_ppt[@]:= + lmost_ppt (sub_lmost_ppt[@], sub_lmost_ppt[prm[@][prm_rnk]]) tnum; + sub_rmost_ppt[@]:= + rmost_ppt (sub_rmost_ppt[@], sub_rmost_ppt[prm[@][prm_rnk]]) tnum; + endfor + % + % delimiters + % + if known l_dlb[@] or known r_dlb[@]: + save dlm_pct, minr, maxr; + picture dlm_pct; + numeric minr, maxr; + minr:=min_rad[@]; + maxr:=max_rad[@]; + if known l_dlb[@]: + dlm_pct:=delim l (maxr-minr); + arc_init l_dlm[@] ( + dlm_pct + rotated (tnum*90+arc_angle (l_dlm[@].rad, (width dlm_pct)/2) tnum) + shifted ((dir 0) scaled l_dlm[@].rad), + arc_angle (l_dlm[@].rad, width dlm_pct) tnum); + l_dlm[@].rng=ngl_part sub_lmost_ppt[@]; + arc_init l_dlb[@]( + text_arc (l_dlb[@], l_dlb[@].rad) tnum, + arc_angle (l_dlb[@].rad, width l_dlb[@]) tnum); + l_dlb[@].rng=l_dlm[@].lng; + sub_lmost_ppt[@]:= (l_dlb[@].rad, l_dlb[@].lng); + fi + if known r_dlb[@]: + dlm_pct:=delim r (maxr-minr); + arc_init r_dlm[@] ( + dlm_pct + rotated (tnum*90+arc_angle (r_dlm[@].rad, (width dlm_pct)/2) tnum) + shifted ((dir 0) scaled r_dlm[@].rad), + arc_angle (r_dlm[@].rad, width dlm_pct) tnum); + r_dlm[@].lng=ngl_part sub_rmost_ppt[@]; + arc_init r_dlb[@]( + text_arc (r_dlb[@], r_dlb[@].rad) tnum, + arc_angle (r_dlb[@].rad, width r_dlb[@]) tnum); + r_dlb[@].lng=r_dlm[@].rng; + sub_rmost_ppt[@]:=(r_dlb[@].rad, r_dlb[@].rng); + fi + fi + if (known l_dlb[@]) or boxed[@]: + save idx; + numeric idx; + idx:=@; + forever: + nfr_lmost_ppt[idx]:=sub_lmost_ppt[@]; + exitif unknown l_prm[idx]; + idx:=l_prm[idx]; + endfor + fi + if (known r_dlb[@]) or boxed[@]: + save idx; + numeric idx; + idx:=@; + forever: + nfr_rmost_ppt[idx]:=sub_rmost_ppt[@]; + exitif unknown r_prm[idx]; + idx:=r_prm[idx]; + endfor + fi +enddef; + % % Freezing % -vardef drv_freeze_root[]= +vardef drv_box_freeze[]= for prm_rnk=0 upto prm_num[@]-1: - drv_freeze_root[prm[@][prm_rnk]]; + drv_box_freeze[prm[@][prm_rnk]]; endfor for sbj_rnk=0 upto sbj_num[@]-1: box_freeze sbj[@][sbj_rnk]; @@ -1728,22 +2310,60 @@ vardef drv_freeze_root[]= endfor enddef; +vardef drv_arc_freeze[]= + for prm_rnk=0 upto prm_num[@]-1: + drv_arc_freeze[prm[@][prm_rnk]]; + endfor + for sbj_rnk=0 upto sbj_num[@]-1: + arc_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[@]: + arc_freeze sfx[@]; + fi + endfor +enddef; + vardef drv_freeze= if not drv_checked: drv_check; fi - save root_idx; - numeric root_idx; - for root_rnk=0 upto root_num-1: - root_idx:=root[root_rnk]; - drv_build_root[root_idx]; + save root_idx, tnum; + numeric root_idx, tnum; + % + % first root + % + root_idx:=root[0]; + if drv_radialmode_on: + drv_rad_build[root_idx]; + if unknown jdg[root_idx].rad: + jdg[root_idx].rad=10(num_hg-den_dp)/crv_scl; + fi + drv_ngl_build[root_idx]; + tnum:=if bot_jdg[root_idx]: - fi 1; % turning number + if unknown jdg[root_idx].cng: + jdg[root_idx].cng=-tnum*azimuth_ngl; + fi + if unknown jdg[root_idx].org: + % + % default math axis + % + jdg[root_idx].org= + (dir -jdg[root_idx].cng) scaled (tnum*axis_hg[drv_sty]+ + if drv_axis_ref="iln": + iln[root_idx].rad + else: % drv_axis_ref="jdg" + jdg[root_idx].rad + fi); + fi + drv_arc_freeze[root_idx]; + else: + drv_lin_build[root_idx]; if unknown xpart jdg[root_idx].c: - if root_rnk=0: - xpart jdg[root_idx].c=0; - else: - sub_min_x[root_idx]=sub_max_x[root[root_rnk-1]] - +prm_skp_scl*prm_skp[drv_sty]; - fi + xpart jdg[root_idx].c=0; fi if unknown ypart jdg[root_idx].c: % @@ -1755,8 +2375,64 @@ vardef drv_freeze= ypart jdg[root_idx].c=axis_hg[drv_sty]; fi fi - drv_freeze_root[root_idx]; - endfor + drv_box_freeze[root_idx]; + fi + % + % other roots + % + if drv_radialmode_on: + save l_rmost_rad, l_rmost_ngl, r_lmost_rad, r_lmost_ngl; + numeric l_rmost_rad, l_rmost_ngl, r_lmost_rad, r_lmost_ngl; + for root_rnk=1 upto root_num-1: + root_idx:=root[root_rnk]; + drv_rad_build[root_idx]; + if unknown jdg[root_idx].rad: + jdg[root_idx].rad=10(num_hg-den_dp)/crv_scl; + fi + drv_ngl_build[root_idx]; + tnum:=if bot_jdg[root_idx]: - fi 1; % turning number + l_rmost_rad:=rad_part sub_rmost_ppt[root[root_rnk-1]]; + l_rmost_ngl:=ngl_part sub_rmost_ppt[root[root_rnk-1]]; + r_lmost_rad:=rad_part sub_lmost_ppt[root_idx]; + r_lmost_ngl:=ngl_part sub_lmost_ppt[root_idx]; + if unknown jdg[root_idx].cng: + r_lmost_ngl=l_rmost_ngl+ + if bot_jdg[root_idx]=bot_jdg[root[root_rnk-1]]: + arc_angle (min (r_lmost_rad, l_rmost_rad), + prm_skp_scl*prm_skp[drv_sty]) tnum + else: + 180 + fi; + fi + if unknown jdg[root_idx].org: + jdg[root_idx].org= + if bot_jdg[root_idx]=bot_jdg[root[root_rnk-1]]: + jdg[root[root_rnk-1]].org + else: + (dir l_rmost_ngl) + scaled jdg[root[root_rnk-1]].rad + shifted jdg[root[root_rnk-1]].org + shifted ((dir (l_rmost_ngl-tnum*90)) + scaled (prm_skp_scl*prm_skp[drv_sty])) + shifted ((dir l_rmost_ngl) scaled jdg[root_idx].rad) + fi; + fi + drv_arc_freeze[root_idx]; + endfor + else: + for root_rnk=1 upto root_num-1: + root_idx:=root[root_rnk]; + drv_lin_build[root_idx]; + if unknown xpart jdg[root_idx].c: + sub_min_x[root_idx]=sub_max_x[root[root_rnk-1]] + +prm_skp_scl*prm_skp[drv_sty]; + fi + if unknown ypart jdg[root_idx].c: + ypart jdg[root_idx].c=ypart jdg[root[root_rnk-1]].c; + fi + drv_box_freeze[root_idx]; + endfor + fi drv_frozen:=true; enddef; @@ -1870,32 +2546,57 @@ vardef drv_tree= 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: - sub_min_x[@] - fi-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; - max_x:= - if known r_dlm[@].l: - xpart l_dlm[@].l - else: - sub_max_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 + if drv_radialmode_on: + save l_ngl, r_ngl, tnum; + numeric l_ngl, r_ngl, tnum; + tnum:=if bot_jdg[@]: - fi 1; % turning number + l_ngl:= + if known l_dlm[@].rng: + l_dlm[@].rng-arc_angle + (l_dlm[@].rad, jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + else: + (ngl_part sub_lmost_ppt[@])-arc_angle + (rad_part sub_lmost_ppt[@], + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + fi; + r_ngl:= + if known r_dlm[@].lng: + r_dlm[@].lng+arc_angle + (r_dlm[@].rad, jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + else: + (ngl_part sub_rmost_ppt[@])+arc_angle + (rad_part sub_rmost_ppt[@], + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + fi; + (circ_path(max_rad[@], r_ngl-l_ngl) tnum-- + reverse circ_path(min_rad[@], r_ngl-l_ngl) tnum-- + cycle) rotated l_ngl shifted jdg[@].org + else: + save minx, maxx, miny, maxy; + numeric minx, maxx, maxy, miny; + minx:= + if known l_dlm[@].r: + xpart l_dlm[@].r + else: + sub_min_x[@] + fi-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + maxx:= + if known r_dlm[@].l: + xpart l_dlm[@].l + else: + sub_max_x[@] + fi+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + miny:=min_y[@]; + maxy:=max_y[@]; + (minx, miny)-- + (minx, maxy)-- + (maxx, maxy)-- + (maxx, miny)-- + cycle + fi enddef; vardef mth_axis @# (suffix ref_sfx) (expr idx)= @@ -1986,6 +2687,25 @@ vardef check_position_left (suffix pos_sfx) (expr default)= fi enddef; +vardef check_position_bot (suffix pos_sfx) (expr default)= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if pos_str="t": + false + elseif pos_str="b": + true + else: + begingroup + drv_errhelp "Valid identifiers are"& + " t (top) and"& + " b (bottom)."; + drv_errmessage (pos_str&" is not a valid root position identifier"); + default + endgroup + fi +enddef; + vardef check_mode_on (suffix status_sfx) (expr default)= save status_str; string status_str; @@ -2027,7 +2747,7 @@ vardef drv_math_style (suffix typ_sfx) (expr sty_str)= else: forsuffixes sfx=scantokens (typ_str&"_sty"): for idx=0 upto 3: - sfx[idx]:=min(idx+sty_idx, 3); + sfx[idx]:=min (idx+sty_idx, 3); endfor endfor fi @@ -2046,12 +2766,15 @@ vardef drv_scale (suffix scl_sfx) (expr scl)= jdg_skp_scl:=scl; elseif (scl_str="ilb") or (scl_str="lbl"): % "lbl" is deprecated ilb_skp_scl:=scl; + elseif scl_str="crv": + crv_scl:=scl; else: drv_errhelp "Valid identifiers are"& " clr,"& " prm,"& - " jdg and"& - " ilb."; + " jdg,"& + " ilb and"& + " crv."; drv_errmessage (scl_str&" is not a valid scale identifier"); fi enddef; @@ -2104,19 +2827,7 @@ vardef drv_labels_position text ARG= 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 + drv_bot_roots:=check_position_bot (pos_sfx) (drv_bot_roots); enddef; vardef drv_axis_reference suffix ref_sfx= @@ -2161,6 +2872,14 @@ vardef drv_proof_mode suffix status_sfx= drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); enddef; +vardef drv_radial_mode suffix status_sfx= + drv_radialmode_on:=check_mode_on (status_sfx, drv_radialmode_on); +enddef; + +vardef drv_azimuth expr ngl= + azimuth_ngl:=ngl; +enddef; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -2192,6 +2911,10 @@ drv_box_mode off; drv_fraction_mode on; drv_proof_mode off; +drv_radial_mode off; +drv_scale (crv, 1); +drv_azimuth 90; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % diff --git a/Master/texmf-dist/doc/metapost/drv/sample/makefile b/Master/texmf-dist/doc/metapost/drv/sample/makefile index ab57ffe9ace..18f01e9eecb 100644 --- a/Master/texmf-dist/doc/metapost/drv/sample/makefile +++ b/Master/texmf-dist/doc/metapost/drv/sample/makefile @@ -2,9 +2,12 @@ MAIN= coq-sample $(MAIN).pdf: $(MAIN).ps ps2pdf $(MAIN).ps + pdfopt $(MAIN).pdf $(MAIN)-opt.pdf + mv $(MAIN)-opt.pdf $(MAIN).pdf $(MAIN).ps: $(MAIN).tex $(MAIN)-delayed.mp latex $(MAIN) + latex $(MAIN) dvips -t unknown $(MAIN) -o $(MAIN)-proof.pdf: $(MAIN)-proof.ps diff --git a/Master/texmf-dist/doc/metapost/drv/sample/readme.txt b/Master/texmf-dist/doc/metapost/drv/sample/readme.sh index b0c3c91b5e5..65e275906e9 100644 --- a/Master/texmf-dist/doc/metapost/drv/sample/readme.txt +++ b/Master/texmf-dist/doc/metapost/drv/sample/readme.sh @@ -1,10 +1,12 @@ -# In order to compile the sources and to get a pdf file, use `make' or: +# In order to compile the sources and to get a pdf file, +# use `make' or `./readme.sh' or: # 1. run metapost TWICE: mpost coq-sample.mp mpost coq-sample.mp -# 2. run latex (once): +# 2. run latex (twice): +latex coq-sample.tex latex coq-sample.tex # 3. run dvips (once): diff --git a/Master/texmf-dist/doc/metapost/drv/template/drv.mp b/Master/texmf-dist/doc/metapost/drv/template/drv.mp index 69f2f9f72c7..a5791649f82 100644 --- a/Master/texmf-dist/doc/metapost/drv/template/drv.mp +++ b/Master/texmf-dist/doc/metapost/drv/template/drv.mp @@ -1,5 +1,5 @@ -%% drv.mp 0.94 -%% Copyright 2009 Laurent M\'ehats +%% drv 0.95 +%% Copyright 2010 Laurent M\'ehats % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -16,6 +16,9 @@ % % This work consists of the file drv.mp +newinternal drv_version; +drv_version:=0.95; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -142,8 +145,9 @@ % <str> LaTeX math-style command % % drv_scale (<id>, <float>) -% <id> scale identifier (clr, prm, jdg or ilb) +% <id> scale identifier (clr, crv, prm, jdg or ilb) % clr nice explanation soon (see examples) +% crv nice explanation soon (see examples) % prm nice explanation soon (see examples) % jdg nice explanation soon (see examples) % ilb nice explanation soon (see examples) @@ -217,6 +221,15 @@ % on % off % +% drv_radial_mode <id> +% <id> status identifier (on or off) +% on +% off +% +% drv_azimuth <float> +% <float> azimuth degree +% +% % * Derivation tree pictures % ========================== % @@ -234,6 +247,12 @@ % <path> MetaPost path expression % <id> path style identifier (0, 1, 2, 3, 4, 5 or 6) % +% drv_root (<nat>, <id>) +% <nat> root index +% <id> position identifier (t or b) +% t top +% b bottom +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -250,9 +269,8 @@ vardef drv_format (expr str, fst_len, nxt_len, dbl_pcs)= % 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; + save str_len, sub_len, aux_len, chr_rnk, occ_num, aux_str, chr; 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; @@ -315,6 +333,8 @@ vardef drv_errmessage expr str= errmessage drv_format (drv_context&str, 77, 79, false); enddef; +drv_message "version "&decimal drv_version&"."; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -488,11 +508,23 @@ picture tt_dgt[][]; 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_fontdimen[] expr font= - save dim_pct; + save dim_pct, dim_str; picture dim_pct; - dim_pct:=drv_tex[0] ("\rule{\the\fontdimen"&(decimal @)&font&"}{0bp}"); - width dim_pct + string dim_str; + dim_pct:=drv_tex[0] ("\mbox{\the\fontdimen"&(decimal @)&font&"}"); + dim_str:="0"; + for tok within dim_pct: + dim_str:=dim_str&(textpart tok); + endfor + scantokens dim_str enddef; vardef drv_font_size expr size_str= @@ -530,11 +562,11 @@ vardef drv_font_size expr size_str= 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] "\,"; + sp_pct:=drv_tex[mth_sty] "\thinspace"; thn_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\>"; + sp_pct:=drv_tex[mth_sty] "\medspace"; med_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\;"; + sp_pct:=drv_tex[mth_sty] "\thickspace"; thk_sp[mth_sty]:=width sp_pct; pdt_pct:=drv_tex[mth_sty] "\ldotp"; pdt_hg[mth_sty]:=height pdt_pct; @@ -588,6 +620,7 @@ vardef drv_box text STR= expandafter pair scantokens str.r; expandafter numeric scantokens str.hg; expandafter numeric scantokens str.dp; + drv_arc str; endfor enddef; @@ -606,6 +639,119 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +% drv-arcs +% + +vardef drv_arc text STR= + for str=STR: + expandafter numeric scantokens str.rad; + expandafter numeric scantokens str.lng; + expandafter numeric scantokens str.cng; + expandafter numeric scantokens str.rng; + expandafter pair scantokens str.org; + endfor +enddef; + +vardef arc_init @# (expr pct, ngl)= + @#:=pct; + @#.rng-@#.lng=ngl; + @#.cng=(@#.lng+@#.rng)/2; +enddef; + +vardef arc_freeze @#= + @#:=@# rotated @#.lng shifted @#.org; + @#.l:=(dir @#.lng) scaled @#.rad shifted @#.org; + @#.c:=(dir @#.cng) scaled @#.rad shifted @#.org; + @#.r:=(dir @#.rng) scaled @#.rad shifted @#.org; +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Polar coordinates, angles & text torsion +% + +vardef rad_part expr ppt= + xpart ppt +enddef; + +vardef ngl_part expr ppt= + ypart ppt +enddef; + +vardef minrad (expr ppt_a, ppt_b)= + min (rad_part ppt_a, rad_part ppt_b) +enddef; + +% "tnum" (turning number) argument: +% -1: clockwise +% 1: counterclockwise + +vardef lmost_ppt (expr ppt_a, ppt_b) expr tnum= + if tnum*(ngl_part ppt_a)<tnum*(ngl_part ppt_b): + ppt_a + else: + ppt_b + fi +enddef; + +vardef rmost_ppt (expr ppt_a, ppt_b) expr tnum= + if tnum*(ngl_part ppt_a)>tnum*(ngl_part ppt_b): + ppt_a + else: + ppt_b + fi +enddef; + +vardef arc_angle (expr rad, arc_len) expr tnum= + if rad>0: + save pth; + path pth; + pth:=fullcircle scaled (2*rad); + tnum*(angle point (arctime arc_len of pth) of pth) + else: + 0 + fi +enddef; + +vardef circ_path (expr rad, ngl) expr tnum= + save pth; + path pth; + pth:=if tnum=-1: reverse fi fullcircle scaled (2*rad); + subpath (0, directiontime (dir (ngl+tnum*90)) of pth) of pth +enddef; + +vardef text_arc (expr pct, rad) expr tnum= + save arc_pct, tok_str, tok_trn, tok_ngl, hlf_wd, chr_pct; + picture arc_pct, chr_pct; + numeric tok_ngl, hlf_wd; + string tok_str; + arc_pct:=nullpicture; + for tok within pct: + transform tok_trn; + tok_str:=textpart tok; + (0, 0) transformed tok_trn=(0, 0); + (0, 1) transformed tok_trn=(xypart tok, yypart tok); + (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); + tok_ngl:=arc_angle (rad, xpart tok) tnum; + for chr_rnk=0 upto (length tok_str-1): + chr_pct:=substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) + transformed tok_trn; + hlf_wd:=(width chr_pct)/2; + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + addto arc_pct also chr_pct + shifted (-hlf_wd, 0) + rotated (tok_ngl+tnum*90) + shifted ((dir tok_ngl) scaled (rad-tnum*(ypart tok))); + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + endfor + endfor + arc_pct +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % beginfig & endfig % @@ -637,14 +783,17 @@ vardef drv_beginfig= % iln_sty[i] inference line style % l_prm[i] leftmost `graphical' premise index % r_prm[i] rightmost `graphical' premise index + % bot_jdg[i] boolean % numeric prm_num[], prm[][], ccl[]; numeric jct_sty[]; string alg_sty[]; numeric iln_sty[]; numeric l_prm[], r_prm[]; + boolean bot_jdg[]; % % nfr_min_x[i] inference minimal x + % nfr_lmost_ppt[i] inference leftmost polar point % l_dlb[i] left delimiter label drv-box % l_dlm[i] left delimiter drv-box % l_ilb[i] left label drv-box @@ -653,22 +802,31 @@ vardef drv_beginfig= % r_dlm[i] right delimiter drv-box % r_dlb[i] right delimiter label drv-box % nfr_max_x[i] inference maximal x + % nfr_rmost_ppt[i] inference rightmost polar point % numeric nfr_min_x[]; + pair nfr_lmost_ppt[]; drv_box "l_dlb[]", "l_dlm[]", "l_ilb[]"; drv_box "iln[]"; drv_box "r_ilb[]", "r_dlm[]", "r_dlb[]"; numeric nfr_max_x[]; + pair nfr_rmost_ppt[]; % % Sub-trees % % sub_min_x[i] sub-tree minimal x + % sub_lmost_ppt[i] sub-tree leftmost polar point % sub_max_x[i] sub-tree maximal x + % sub_rmost_ppt[i] sub-tree rightmost polar point % sub_min_y[i] sub-tree minimal y + % sub_min_rad[i] sub-tree minimal radius % sub_max_y[i] sub-tree maximal y + % sub_max_rad[i] sub-tree maximal radius % boxed[i] boolean % numeric sub_min_x[], sub_max_x[], sub_min_y[], sub_max_y[]; + pair sub_lmost_ppt[], sub_rmost_ppt[]; + numeric sub_min_rad[], sub_max_rad[]; boolean boxed[]; % % Pen initialization @@ -953,8 +1111,8 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % PRM: list of premise indices % - save prm_rnk; - numeric prm_rnk; + save prm_rnk, root_rnk; + numeric prm_rnk, root_rnk; prm_rnk:=0; for prm_idx=PRM: if prm_idx=@: @@ -971,8 +1129,6 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % roots list update % - save root_rnk; - numeric root_rnk; root_rnk:=0; forever: exitif root[root_rnk]=prm_idx; @@ -1324,24 +1480,46 @@ string drv_rdlm_str; % right delimiter LaTeX code % 2. Macros % -vardef minmax_y[]=( - if drv_bot_roots: +vardef min_y[]= + if bot_jdg[@]: if known ccl[@]: ypart jdg[@].c-num_hg+iln_hg[(iln_sty[ccl[@]])] +min_clr_scl*min_clr[drv_sty]/2 else: sub_min_y[@]-min_clr_scl*min_clr[drv_sty] - fi, + fi + else: + sub_min_y[@]-min_clr_scl*min_clr[drv_sty] + fi +enddef; + +vardef max_y[]= + if bot_jdg[@]: sub_max_y[@]+min_clr_scl*min_clr[drv_sty] else: - sub_min_y[@]-min_clr_scl*min_clr[drv_sty], if known ccl[@]: ypart jdg[@].c-den_dp+iln_dp[(iln_sty[ccl[@]])] -min_clr_scl*min_clr[drv_sty]/2 else: sub_max_y[@]+min_clr_scl*min_clr[drv_sty] fi - fi) + fi +enddef; + +vardef min_rad[]= + if known ccl[@]: + if bot_jdg[@]: + jdg[@].rad-num_hg+iln_hg[(iln_sty[ccl[@]])] + else: + jdg[@].rad+den_dp-iln_dp[(iln_sty[ccl[@]])] + fi+min_clr_scl*min_clr[drv_sty]/2 + else: + sub_min_rad[@]-min_clr_scl*min_clr[drv_sty] + fi +enddef; + +vardef max_rad[]= + sub_max_rad[@]+min_clr_scl*min_clr[drv_sty] enddef; vardef delim @# expr dlm_len= @@ -1394,6 +1572,10 @@ boolean drv_boxmode_on; % boolean drv_fractionmode_on; % string drv_axis_ref; % +boolean drv_radialmode_on; % +numeric crv_scl; % +numeric azimuth_ngl; % + % % 2. Macros % @@ -1410,7 +1592,7 @@ vardef fraction_inference[]= and drv_fractionmode_on enddef; -vardef drv_check_root[]= +vardef drv_bot_check[]= if unknown jdg[@]: drv_errhelp "An index must be used to declare a both a judgment and an"& " inference."; @@ -1425,29 +1607,56 @@ vardef drv_check_root[]= save i_sty, prm_idx; numeric i_sty, prm_idx; i_sty:=iln_sty[@]; + bot_jdg[@]:=true; for prm_rnk=0 upto prm_num[@]-1: prm_idx:=prm[@][prm_rnk]; - drv_check_root[prm_idx]; + drv_bot_check[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 + num_hg:=max (num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].dp); 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 + den_dp:=min (den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[@].hg); + fi + if unknown boxed[@]: + boxed[@]:=drv_boxmode_on; + fi + fi +enddef; + +vardef drv_top_check[]= + 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[@]; + bot_jdg[@]:=false; + for prm_rnk=0 upto prm_num[@]-1: + prm_idx:=prm[@][prm_rnk]; + drv_top_check[prm_idx]; + % + % numerators and denominators clearances + % The TEXbook, Appendix G, Rule 15d. + % + den_dp:=min (den_dp, + iln_dp[i_sty]-min_clr_scl*min_clr[drv_sty]-jdg[prm_idx].hg); + endfor + if not fraction_inference[@]: + num_hg:=max (num_hg, + iln_hg[i_sty]+min_clr_scl*min_clr[drv_sty]-jdg[@].dp); fi if unknown boxed[@]: boxed[@]:=drv_boxmode_on; @@ -1455,24 +1664,42 @@ vardef drv_check_root[]= fi enddef; +vardef drv_root (expr idx) (suffix pos_sfx)= + save root_idx; + numeric root_idx; + root_idx:=idx; + forever: + exitif unknown ccl[root_idx]; + root_idx:=ccl[root_idx]; + endfor + if idx<>root_idx: + drv_message "warning, "&(decimal idx)&" is not a root index"& + " (the actual root index is "&(decimal root_idx)&")."; + fi + bot_jdg[root_idx]:=check_position_bot (pos_sfx) (drv_bot_roots); +enddef; + vardef drv_check= if root_num=0: drv_errhelp "Well ..."; drv_errmessage "no inference has been declared"; else: - save root_idx; + save root_idx, root_str; numeric root_idx; - root_idx:=root[0]; - drv_check_root[root_idx]; + string root_str; + for root_rnk=0 upto root_num-1: + root_idx:=root[root_rnk]; + if unknown bot_jdg[root_idx]: + bot_jdg[root_idx]:=drv_bot_roots; + fi + if bot_jdg[root_idx]: + drv_bot_check[root_idx]; + else: + drv_top_check[root_idx]; + fi + root_str:=if root_rnk>0: root_str&", "& fi decimal root_idx; + endfor if root_num>1: - save root_str; - string root_str; - root_str:=decimal root_idx; - for root_rnk=1 upto root_num-1: - root_idx:=root[root_rnk]; - drv_check_root[root_idx]; - root_str:=root_str&", "&(decimal root_idx); - endfor drv_message "warning, multiple root indices ("&root_str&")."; fi fi @@ -1483,11 +1710,11 @@ enddef; % Building % -vardef drv_build_root[]= +vardef drv_lin_build[]= % % orientation % - if drv_bot_roots: + if bot_jdg[@]: ypart iln[@].c=ypart jdg[@].c-den_dp; sub_min_y[@]:=ypart jdg[@].c+jdg[@].dp; sub_max_y[@]:= @@ -1498,8 +1725,8 @@ vardef drv_build_root[]= fi; for prm_rnk=0 upto prm_num[@]-1: ypart jdg[prm[@][prm_rnk]].c=ypart iln[@].c+num_hg; - drv_build_root[prm[@][prm_rnk]]; - sub_max_y[@]:=max(sub_max_y[@], sub_max_y[prm[@][prm_rnk]]); + drv_lin_build[prm[@][prm_rnk]]; + sub_max_y[@]:=max (sub_max_y[@], sub_max_y[prm[@][prm_rnk]]); endfor else: ypart iln[@].c=ypart jdg[@].c-num_hg; @@ -1512,18 +1739,16 @@ vardef drv_build_root[]= sub_max_y[@]:=ypart jdg[@].c+jdg[@].hg; for prm_rnk=0 upto prm_num[@]-1: ypart jdg[prm[@][prm_rnk]].c=ypart iln[@].c+den_dp; - drv_build_root[prm[@][prm_rnk]]; - sub_min_y[@]:=min(sub_min_y[@], sub_min_y[prm[@][prm_rnk]]); + drv_lin_build[prm[@][prm_rnk]]; + sub_min_y[@]:=min (sub_min_y[@], sub_min_y[prm[@][prm_rnk]]); endfor fi % % premises junction (from left to right) % - for prm_rnk=1 upto prm_num[@]-1: - save l_lmost, l_rmost, r_lmost, r_rmost; - save l_max_x, r_min_x, min_skp; - numeric l_lmost, l_rmost, r_lmost, r_rmost; - numeric l_max_x, r_min_x, min_skp[]; + save l_lmost, l_rmost, r_lmost, r_rmost, l_max_x, r_min_x, min_skp; + numeric l_lmost, l_rmost, r_lmost, r_rmost, l_max_x, r_min_x, min_skp[]; + for prm_rnk=1 upto prm_num[@]-1: l_lmost:=prm[@][0]; l_rmost:=prm[@][prm_rnk-1]; r_lmost:=prm[@][prm_rnk]; @@ -1537,9 +1762,9 @@ vardef drv_build_root[]= l_rmost:=r_prm[l_rmost]; r_lmost:=l_prm[r_lmost]; r_rmost:=r_prm[r_rmost]; - l_max_x:=max(l_max_x, nfr_max_x[l_rmost]); - r_min_x:=min(r_min_x, nfr_min_x[r_lmost]); - min_skp[0]:=min(min_skp[0], nfr_min_x[r_lmost]-nfr_max_x[l_rmost]); + l_max_x:=max (l_max_x, nfr_max_x[l_rmost]); + r_min_x:=min (r_min_x, nfr_min_x[r_lmost]); + min_skp[0]:=min (min_skp[0], nfr_min_x[r_lmost]-nfr_max_x[l_rmost]); endfor min_skp[1]:=r_min_x-l_max_x; if known r_prm[l_rmost]: @@ -1583,8 +1808,8 @@ vardef drv_build_root[]= elseif alg_sty[@]="r": xpart jdg[@].r=r_xref; fi - nfr_min_x[@]:=min(xpart jdg[@].l, l_xref); - nfr_max_x[@]:=max(xpart jdg[@].r, r_xref); + nfr_min_x[@]:=min (xpart jdg[@].l, l_xref); + nfr_max_x[@]:=max (xpart jdg[@].r, r_xref); fi % % inference line @@ -1612,14 +1837,14 @@ vardef drv_build_root[]= if known l_ilb[@]: l_ilb[@].r=iln[@].l shifted (-ilb_skp_scl*ilb_skp[drv_sty], 0); nfr_min_x[@]:=xpart l_ilb[@].l; - sub_min_y[@]:=min(sub_min_y[@], ypart l_ilb[@].c+l_ilb[@].dp); - sub_max_y[@]:=max(sub_max_y[@], ypart l_ilb[@].c+l_ilb[@].hg); + sub_min_y[@]:=min (sub_min_y[@], ypart l_ilb[@].c+l_ilb[@].dp); + sub_max_y[@]:=max (sub_max_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); nfr_max_x[@]:=xpart r_ilb[@].r; - sub_min_y[@]:=min(sub_min_y[@], ypart r_ilb[@].c+r_ilb[@].dp); - sub_max_y[@]:=max(sub_max_y[@], ypart r_ilb[@].c+r_ilb[@].hg); + sub_min_y[@]:=min (sub_min_y[@], ypart r_ilb[@].c+r_ilb[@].dp); + sub_max_y[@]:=max (sub_max_y[@], ypart r_ilb[@].c+r_ilb[@].hg); fi % % phantom steps @@ -1628,29 +1853,29 @@ vardef drv_build_root[]= save bot_y, top_y, phm_pct; numeric bot_y, top_y; picture phm_pct; - if drv_bot_roots: - bot_y:=xpart minmax_y[@]+min_clr_scl*min_clr[drv_sty]/2; - top_y:=xpart minmax_y[tgt[@]]; + if bot_jdg[@]: + bot_y:=min_y[@]+min_clr_scl*min_clr[drv_sty]/2; + top_y:=min_y[tgt[@]]; else: - bot_y:=ypart minmax_y[tgt[@]]; - top_y:=ypart minmax_y[@]-min_clr_scl*min_clr[drv_sty]/2; + bot_y:=max_y[tgt[@]]; + top_y:=max_y[@]-min_clr_scl*min_clr[drv_sty]/2; fi phm_pct:=((0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2)) drv_styled phm_sty[@]; box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); phm[@].c=(xpart jdg[@].c, (top_y+bot_y)/2); - nfr_min_x[@]:=min(nfr_min_x[@], xpart phm[@].l); - nfr_max_x[@]:=max(nfr_max_x[@], xpart phm[@].r); + nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[@].l); + nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[@].r); % % phantom steps labels % if known l_plb[@]: l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); - nfr_min_x[@]:=min(nfr_min_x[@], xpart l_plb[@].l); + nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[@].l); fi if known r_plb[@]: r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); - nfr_max_x[@]:=max(nfr_max_x[@], xpart r_plb[@].r); + nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[@].r); fi fi % @@ -1659,28 +1884,26 @@ vardef drv_build_root[]= sub_min_x[@]:=nfr_min_x[@]; sub_max_x[@]:=nfr_max_x[@]; for prm_rnk=0 upto prm_num[@]-1: - sub_min_x[@]:=min(sub_min_x[@], sub_min_x[prm[@][prm_rnk]]); - sub_max_x[@]:=max(sub_max_x[@], sub_max_x[prm[@][prm_rnk]]); + sub_min_x[@]:=min (sub_min_x[@], sub_min_x[prm[@][prm_rnk]]); + sub_max_x[@]:=max (sub_max_x[@], sub_max_x[prm[@][prm_rnk]]); endfor % % delimiters % if known l_dlb[@] or known r_dlb[@]: - save mmy, min_y, max_y; - numeric min_y, max_y; - pair mmy; - mmy:=minmax_y[@]; - min_y:=xpart mmy; - max_y:=ypart mmy; + save miny, maxy; + numeric miny, maxy; + miny:=min_y[@]; + maxy:=max_y[@]; if known l_dlb[@]: - box_init l_dlm[@] (delim l (max_y-min_y)); - l_dlm[@].r=(sub_min_x[@], (max_y+min_y)/2); + box_init l_dlm[@] (delim l (maxy-miny)); + l_dlm[@].r=(sub_min_x[@], (maxy+miny)/2); l_dlb[@].r=l_dlm[@].l; sub_min_x[@]:=xpart l_dlb[@].l; fi if known r_dlb[@]: - box_init r_dlm[@] (delim r (max_y-min_y)); - r_dlm[@].l=(sub_max_x[@], (max_y+min_y)/2); + box_init r_dlm[@] (delim r (maxy-miny)); + r_dlm[@].l=(sub_max_x[@], (maxy+miny)/2); r_dlb[@].l=r_dlm[@].r; sub_max_x[@]:=xpart r_dlb[@].r; fi @@ -1707,13 +1930,372 @@ vardef drv_build_root[]= fi enddef; +vardef drv_rad_build[]= + for sbj_rnk=0 upto (sbj_num[@]-1): + sbj[@][sbj_rnk].rad=jdg[@].rad; + sbj[@][sbj_rnk].org=jdg[@].org; + endfor + % + % orientation + % + if bot_jdg[@]: + iln[@].rad=jdg[@].rad-den_dp; + iln[@].org=jdg[@].org; + sub_min_rad[@]:=jdg[@].rad+jdg[@].dp; + sub_max_rad[@]:= + if iln_sty[@]=0: + jdg[@].rad+jdg[@].hg + else: + iln[@].rad+iln_hg[iln_sty[@]] + fi; + for prm_rnk=0 upto prm_num[@]-1: + jdg[prm[@][prm_rnk]].rad=iln[@].rad+num_hg; + jdg[prm[@][prm_rnk]].org=iln[@].org; + drv_rad_build[prm[@][prm_rnk]]; + sub_max_rad[@]:=max (sub_max_rad[@], sub_max_rad[prm[@][prm_rnk]]); + endfor + else: + iln[@].rad=jdg[@].rad+num_hg; + iln[@].org=jdg[@].org; + sub_min_rad[@]:=jdg[@].rad-jdg[@].hg; + sub_max_rad[@]:= + if iln_sty[@]=0: + jdg[@].rad-jdg[@].dp + else: + iln[@].rad-iln_dp[iln_sty[@]] + fi; + for prm_rnk=0 upto prm_num[@]-1: + jdg[prm[@][prm_rnk]].rad=iln[@].rad-den_dp; + jdg[prm[@][prm_rnk]].org=iln[@].org; + drv_rad_build[prm[@][prm_rnk]]; + sub_max_rad[@]:=max (sub_max_rad[@], sub_max_rad[prm[@][prm_rnk]]); + endfor; + fi + % + % inference labels + % + if known l_ilb[@]: + l_ilb[@].rad=iln[@].rad; + l_ilb[@].org=iln[@].org; + sub_max_rad[@]:=max (sub_max_rad[@], + l_ilb[@].rad if bot_jdg[@]: +l_ilb[@].hg else: -l_ilb[@].dp fi); + fi + if known r_ilb[@]: + r_ilb[@].rad=iln[@].rad; + r_ilb[@].org=iln[@].org; + sub_max_rad[@]:=max (sub_max_rad[@], + r_ilb[@].rad if bot_jdg[@]: +r_ilb[@].hg else: -r_ilb[@].dp fi); + fi + % + % phantom steps + % + if known tgt[@]: + save src_rad, tgt_rad; + numeric src_rad, tgt_rad; + src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; + tgt_rad:=min_rad[tgt[@]]; + phm[@].rad=(src_rad+tgt_rad)/2; + phm[@].org=jdg[@].org; + % + % phantom steps labels + % + if known l_plb[@]: + l_plb[@].rad=phm[@].rad; + l_plb[@].org=phm[@].org; + fi + if known r_plb[@]: + r_plb[@].rad=phm[@].rad; + r_plb[@].org=phm[@].org; + fi + fi + % + % delimiters + % + if known l_dlb[@] or known r_dlb[@]: + save minr, maxr; + numeric minr, maxr; + minr:=min_rad[@]; + maxr:=max_rad[@]; + if known l_dlb[@]: + l_dlm[@].rad=(minr+maxr)/2; + l_dlb[@].rad=l_dlm[@].rad; + l_dlb[@].org=l_dlm[@].org=jdg[@].org; + fi + if known r_dlb[@]: + r_dlm[@].rad=(minr+maxr)/2; + r_dlb[@].rad=r_dlm[@].rad; + r_dlb[@].org=r_dlm[@].org=jdg[@].org; + fi + fi +enddef; + +vardef drv_ngl_build[]= + for prm_rnk=0 upto prm_num[@]-1: + drv_ngl_build[prm[@][prm_rnk]]; + endfor + save tnum; + numeric tnum; + tnum:=if bot_jdg[@]: - fi 1; % turning number + % + % judgment arc + % + save jdg_pct, jdg_ngl; + picture jdg_pct; + numeric jdg_ngl; + jdg_pct:=nullpicture; + jdg_ngl:=0; + for sbj_rnk=0 upto (sbj_num[@]-1): + arc_init sbj[@][sbj_rnk] + (text_arc (sbj[@][sbj_rnk], sbj[@][sbj_rnk].rad) tnum, + arc_angle (sbj[@][sbj_rnk].rad, width sbj[@][sbj_rnk]) tnum); + if sbj_rnk>0: % non mandatory test + sbj[@][sbj_rnk-1].rng=sbj[@][sbj_rnk].lng;% irrelevant if rnk=0 + fi + addto jdg_pct also sbj[@][sbj_rnk] rotated jdg_ngl; + jdg_ngl:=jdg_ngl+sbj[@][sbj_rnk].rng-sbj[@][sbj_rnk].lng; + endfor + arc_init jdg[@] (jdg_pct, jdg_ngl); + if sbj_num[@]>0: % non mandatory test + jdg[@].lng=sbj[@][0].lng; % irrelevant if sbj_num=0 + fi + % + % premises junction (from left to right) + % + save l_lmost, l_rmost, r_lmost, r_rmost, l_rmost_ppt, r_lmost_ppt, ppt_skp; + numeric l_lmost, l_rmost, r_lmost, r_rmost; + pair l_rmost_ppt, r_lmost_ppt, ppt_skp[]; + for prm_rnk=1 upto prm_num[@]-1: + l_lmost:=prm[@][0]; + l_rmost:=prm[@][prm_rnk-1]; + r_lmost:=prm[@][prm_rnk]; + r_rmost:=prm[@][prm_rnk]; + l_rmost_ppt:=nfr_rmost_ppt[l_rmost]; + r_lmost_ppt:=nfr_lmost_ppt[r_lmost]; + ppt_skp[0]:=(minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt)); + forever: + exitif (unknown r_prm[l_rmost]) or (unknown l_prm[r_lmost]); + l_lmost:=l_prm[l_lmost]; + l_rmost:=r_prm[l_rmost]; + r_lmost:=l_prm[r_lmost]; + r_rmost:=r_prm[r_rmost]; + l_rmost_ppt:=rmost_ppt (l_rmost_ppt, nfr_rmost_ppt[l_rmost]) tnum; + r_lmost_ppt:=lmost_ppt (r_lmost_ppt, nfr_lmost_ppt[r_lmost]) tnum; + ppt_skp[0]:=rmost_ppt (ppt_skp[0], (minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt))) tnum; + endfor + ppt_skp[1]:=(minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt)); + if known r_prm[l_rmost]: + r_prm[r_rmost]:=r_prm[l_rmost]; + l_rmost_ppt:=sub_rmost_ppt[l_rmost]; + elseif known l_prm[r_lmost]: + l_prm[l_lmost]:=l_prm[r_lmost]; + r_lmost_ppt:=sub_lmost_ppt[r_lmost]; + fi + ppt_skp[2]:=(minrad (l_rmost_ppt, r_lmost_ppt), + (ngl_part r_lmost_ppt)-(ngl_part l_rmost_ppt)); + if jct_sty[@]<3: + (ngl_part ppt_skp[jct_sty[@]])= + arc_angle(rad_part ppt_skp[jct_sty[@]], + prm_skp_scl*prm_skp[drv_sty]) tnum; + fi + endfor + % + % judgment alignment + % + if prm_num[@]=0: + nfr_lmost_ppt[@]:=(jdg[@].rad, jdg[@].lng); + nfr_rmost_ppt[@]:=(jdg[@].rad, jdg[@].rng); + else: + l_prm[@]:=prm[@][0]; + r_prm[@]:=prm[@][prm_num[@]-1]; + save l_ngl_ref, r_ngl_ref; + numeric l_ngl_ref, r_ngl_ref; + l_ngl_ref= + if boxed[l_prm[@]]: + ngl_part sub_lmost_ppt[l_prm[@]] + else: + jdg[l_prm[@]].lng + fi; + r_ngl_ref= + if boxed[r_prm[@]]: + ngl_part sub_rmost_ppt[r_prm[@]] + else: + jdg[r_prm[@]].rng + fi; + if alg_sty[@]="l": + jdg[@].lng=l_ngl_ref; + elseif alg_sty[@]="c": + jdg[@].cng=(l_ngl_ref+r_ngl_ref)/2; + elseif alg_sty[@]="r": + jdg[@].rng=r_ngl_ref; + fi + nfr_lmost_ppt[@]:=( + jdg[@].rad, + tnum*min (tnum*jdg[@].lng, tnum*l_ngl_ref)); + nfr_rmost_ppt[@]:=( + jdg[@].rad, + tnum*max (tnum*jdg[@].rng, tnum*r_ngl_ref)); + fi + % + % inference line + % + save iln_ngl; + numeric iln_ngl; + iln_ngl:=2*(arc_angle(iln[@].rad, + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum) + +(ngl_part nfr_rmost_ppt[@]) + -(ngl_part nfr_lmost_ppt[@]); + arc_init iln[@] + ((circ_path (iln[@].rad, iln_ngl) tnum) drv_styled iln_sty[@], iln_ngl); + iln[@].hg=iln_hg[iln_sty[@]]; + iln[@].dp=iln_dp[iln_sty[@]]; + iln[@].cng=((ngl_part nfr_lmost_ppt[@])+(ngl_part nfr_rmost_ppt[@]))/2; + if iln_sty[@]>0: + nfr_lmost_ppt[@]:=(iln[@].rad, iln[@].lng); + nfr_rmost_ppt[@]:=(iln[@].rad, iln[@].rng); + fi + % + % inference labels + % + if known l_ilb[@]: + arc_init l_ilb[@]( + text_arc (l_ilb[@], l_ilb[@].rad) tnum, + arc_angle (l_ilb[@].rad, width l_ilb[@]) tnum); + l_ilb[@].rng=iln[@].lng + -arc_angle (l_ilb[@].rad, ilb_skp_scl*ilb_skp[drv_sty]) tnum; + nfr_lmost_ppt[@]:=(l_ilb[@].rad, l_ilb[@].lng); + fi + if known r_ilb[@]: + arc_init r_ilb[@]( + text_arc (r_ilb[@], r_ilb[@].rad) tnum, + arc_angle (r_ilb[@].rad, width r_ilb[@]) tnum); + r_ilb[@].lng=iln[@].rng + +arc_angle (r_ilb[@].rad, ilb_skp_scl*ilb_skp[drv_sty]) tnum; + nfr_rmost_ppt[@]:=(r_ilb[@].rad, r_ilb[@].rng); + fi + % + % phantom steps + % + if known tgt[@]: + save phm_pct, src_rad, tgt_rad; + picture phm_pct; + numeric src_rad, tgt_rad; + src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; + tgt_rad:=min_rad[tgt[@]]; + phm_pct:=((0, (src_rad-tgt_rad)/2)--(0, (tgt_rad-src_rad)/2)) + drv_styled phm_sty[@]; + arc_init phm[@] ( + phm_pct + rotated (tnum*90+arc_angle (phm[@].rad, (width phm_pct)/2) tnum) + shifted ((dir 0) scaled phm[@].rad), + arc_angle (phm[@].rad, width phm_pct) tnum); + phm[@].cng=jdg[@].cng; + nfr_lmost_ppt[@]:=lmost_ppt (nfr_lmost_ppt[@], + (phm[@].rad, phm[@].lng)) tnum; + nfr_rmost_ppt[@]:=rmost_ppt (nfr_rmost_ppt[@], + (phm[@].rad, phm[@].rng)) tnum; + % + % phantom steps labels + % + if known l_plb[@]: + arc_init l_plb[@]( + text_arc (l_plb[@], l_plb[@].rad) tnum, + arc_angle (l_plb[@].rad, width l_plb[@]) tnum); + l_plb[@].rng=phm[@].lng + -arc_angle (l_plb[@].rad, plb_skp[drv_sty]) tnum; + nfr_lmost_ppt[@]:= + lmost_ppt(nfr_lmost_ppt[@], (l_plb[@].rad, l_plb[@].lng)) tnum; + fi + if known r_plb[@]: + arc_init r_plb[@]( + text_arc (r_plb[@], r_plb[@].rad) tnum, + arc_angle (r_plb[@].rad, width r_plb[@]) tnum); + r_plb[@].lng=phm[@].rng + +arc_angle (r_plb[@].rad, plb_skp[drv_sty]) tnum; + nfr_rmost_ppt[@]:= + rmost_ppt(nfr_rmost_ppt[@], (r_plb[@].rad, r_plb[@].rng)) tnum; + fi + fi + % + % sub_lmost_ppt & sub_rmost_ppt + % + sub_lmost_ppt[@]:=nfr_lmost_ppt[@]; + sub_rmost_ppt[@]:=nfr_rmost_ppt[@]; + for prm_rnk=0 upto prm_num[@]-1: + sub_lmost_ppt[@]:= + lmost_ppt (sub_lmost_ppt[@], sub_lmost_ppt[prm[@][prm_rnk]]) tnum; + sub_rmost_ppt[@]:= + rmost_ppt (sub_rmost_ppt[@], sub_rmost_ppt[prm[@][prm_rnk]]) tnum; + endfor + % + % delimiters + % + if known l_dlb[@] or known r_dlb[@]: + save dlm_pct, minr, maxr; + picture dlm_pct; + numeric minr, maxr; + minr:=min_rad[@]; + maxr:=max_rad[@]; + if known l_dlb[@]: + dlm_pct:=delim l (maxr-minr); + arc_init l_dlm[@] ( + dlm_pct + rotated (tnum*90+arc_angle (l_dlm[@].rad, (width dlm_pct)/2) tnum) + shifted ((dir 0) scaled l_dlm[@].rad), + arc_angle (l_dlm[@].rad, width dlm_pct) tnum); + l_dlm[@].rng=ngl_part sub_lmost_ppt[@]; + arc_init l_dlb[@]( + text_arc (l_dlb[@], l_dlb[@].rad) tnum, + arc_angle (l_dlb[@].rad, width l_dlb[@]) tnum); + l_dlb[@].rng=l_dlm[@].lng; + sub_lmost_ppt[@]:= (l_dlb[@].rad, l_dlb[@].lng); + fi + if known r_dlb[@]: + dlm_pct:=delim r (maxr-minr); + arc_init r_dlm[@] ( + dlm_pct + rotated (tnum*90+arc_angle (r_dlm[@].rad, (width dlm_pct)/2) tnum) + shifted ((dir 0) scaled r_dlm[@].rad), + arc_angle (r_dlm[@].rad, width dlm_pct) tnum); + r_dlm[@].lng=ngl_part sub_rmost_ppt[@]; + arc_init r_dlb[@]( + text_arc (r_dlb[@], r_dlb[@].rad) tnum, + arc_angle (r_dlb[@].rad, width r_dlb[@]) tnum); + r_dlb[@].lng=r_dlm[@].rng; + sub_rmost_ppt[@]:=(r_dlb[@].rad, r_dlb[@].rng); + fi + fi + if (known l_dlb[@]) or boxed[@]: + save idx; + numeric idx; + idx:=@; + forever: + nfr_lmost_ppt[idx]:=sub_lmost_ppt[@]; + exitif unknown l_prm[idx]; + idx:=l_prm[idx]; + endfor + fi + if (known r_dlb[@]) or boxed[@]: + save idx; + numeric idx; + idx:=@; + forever: + nfr_rmost_ppt[idx]:=sub_rmost_ppt[@]; + exitif unknown r_prm[idx]; + idx:=r_prm[idx]; + endfor + fi +enddef; + % % Freezing % -vardef drv_freeze_root[]= +vardef drv_box_freeze[]= for prm_rnk=0 upto prm_num[@]-1: - drv_freeze_root[prm[@][prm_rnk]]; + drv_box_freeze[prm[@][prm_rnk]]; endfor for sbj_rnk=0 upto sbj_num[@]-1: box_freeze sbj[@][sbj_rnk]; @@ -1728,22 +2310,60 @@ vardef drv_freeze_root[]= endfor enddef; +vardef drv_arc_freeze[]= + for prm_rnk=0 upto prm_num[@]-1: + drv_arc_freeze[prm[@][prm_rnk]]; + endfor + for sbj_rnk=0 upto sbj_num[@]-1: + arc_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[@]: + arc_freeze sfx[@]; + fi + endfor +enddef; + vardef drv_freeze= if not drv_checked: drv_check; fi - save root_idx; - numeric root_idx; - for root_rnk=0 upto root_num-1: - root_idx:=root[root_rnk]; - drv_build_root[root_idx]; + save root_idx, tnum; + numeric root_idx, tnum; + % + % first root + % + root_idx:=root[0]; + if drv_radialmode_on: + drv_rad_build[root_idx]; + if unknown jdg[root_idx].rad: + jdg[root_idx].rad=10(num_hg-den_dp)/crv_scl; + fi + drv_ngl_build[root_idx]; + tnum:=if bot_jdg[root_idx]: - fi 1; % turning number + if unknown jdg[root_idx].cng: + jdg[root_idx].cng=-tnum*azimuth_ngl; + fi + if unknown jdg[root_idx].org: + % + % default math axis + % + jdg[root_idx].org= + (dir -jdg[root_idx].cng) scaled (tnum*axis_hg[drv_sty]+ + if drv_axis_ref="iln": + iln[root_idx].rad + else: % drv_axis_ref="jdg" + jdg[root_idx].rad + fi); + fi + drv_arc_freeze[root_idx]; + else: + drv_lin_build[root_idx]; if unknown xpart jdg[root_idx].c: - if root_rnk=0: - xpart jdg[root_idx].c=0; - else: - sub_min_x[root_idx]=sub_max_x[root[root_rnk-1]] - +prm_skp_scl*prm_skp[drv_sty]; - fi + xpart jdg[root_idx].c=0; fi if unknown ypart jdg[root_idx].c: % @@ -1755,8 +2375,64 @@ vardef drv_freeze= ypart jdg[root_idx].c=axis_hg[drv_sty]; fi fi - drv_freeze_root[root_idx]; - endfor + drv_box_freeze[root_idx]; + fi + % + % other roots + % + if drv_radialmode_on: + save l_rmost_rad, l_rmost_ngl, r_lmost_rad, r_lmost_ngl; + numeric l_rmost_rad, l_rmost_ngl, r_lmost_rad, r_lmost_ngl; + for root_rnk=1 upto root_num-1: + root_idx:=root[root_rnk]; + drv_rad_build[root_idx]; + if unknown jdg[root_idx].rad: + jdg[root_idx].rad=10(num_hg-den_dp)/crv_scl; + fi + drv_ngl_build[root_idx]; + tnum:=if bot_jdg[root_idx]: - fi 1; % turning number + l_rmost_rad:=rad_part sub_rmost_ppt[root[root_rnk-1]]; + l_rmost_ngl:=ngl_part sub_rmost_ppt[root[root_rnk-1]]; + r_lmost_rad:=rad_part sub_lmost_ppt[root_idx]; + r_lmost_ngl:=ngl_part sub_lmost_ppt[root_idx]; + if unknown jdg[root_idx].cng: + r_lmost_ngl=l_rmost_ngl+ + if bot_jdg[root_idx]=bot_jdg[root[root_rnk-1]]: + arc_angle (min (r_lmost_rad, l_rmost_rad), + prm_skp_scl*prm_skp[drv_sty]) tnum + else: + 180 + fi; + fi + if unknown jdg[root_idx].org: + jdg[root_idx].org= + if bot_jdg[root_idx]=bot_jdg[root[root_rnk-1]]: + jdg[root[root_rnk-1]].org + else: + (dir l_rmost_ngl) + scaled jdg[root[root_rnk-1]].rad + shifted jdg[root[root_rnk-1]].org + shifted ((dir (l_rmost_ngl-tnum*90)) + scaled (prm_skp_scl*prm_skp[drv_sty])) + shifted ((dir l_rmost_ngl) scaled jdg[root_idx].rad) + fi; + fi + drv_arc_freeze[root_idx]; + endfor + else: + for root_rnk=1 upto root_num-1: + root_idx:=root[root_rnk]; + drv_lin_build[root_idx]; + if unknown xpart jdg[root_idx].c: + sub_min_x[root_idx]=sub_max_x[root[root_rnk-1]] + +prm_skp_scl*prm_skp[drv_sty]; + fi + if unknown ypart jdg[root_idx].c: + ypart jdg[root_idx].c=ypart jdg[root[root_rnk-1]].c; + fi + drv_box_freeze[root_idx]; + endfor + fi drv_frozen:=true; enddef; @@ -1870,32 +2546,57 @@ vardef drv_tree= 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: - sub_min_x[@] - fi-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; - max_x:= - if known r_dlm[@].l: - xpart l_dlm[@].l - else: - sub_max_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 + if drv_radialmode_on: + save l_ngl, r_ngl, tnum; + numeric l_ngl, r_ngl, tnum; + tnum:=if bot_jdg[@]: - fi 1; % turning number + l_ngl:= + if known l_dlm[@].rng: + l_dlm[@].rng-arc_angle + (l_dlm[@].rad, jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + else: + (ngl_part sub_lmost_ppt[@])-arc_angle + (rad_part sub_lmost_ppt[@], + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + fi; + r_ngl:= + if known r_dlm[@].lng: + r_dlm[@].lng+arc_angle + (r_dlm[@].rad, jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + else: + (ngl_part sub_rmost_ppt[@])+arc_angle + (rad_part sub_rmost_ppt[@], + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + fi; + (circ_path(max_rad[@], r_ngl-l_ngl) tnum-- + reverse circ_path(min_rad[@], r_ngl-l_ngl) tnum-- + cycle) rotated l_ngl shifted jdg[@].org + else: + save minx, maxx, miny, maxy; + numeric minx, maxx, maxy, miny; + minx:= + if known l_dlm[@].r: + xpart l_dlm[@].r + else: + sub_min_x[@] + fi-jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + maxx:= + if known r_dlm[@].l: + xpart l_dlm[@].l + else: + sub_max_x[@] + fi+jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]; + miny:=min_y[@]; + maxy:=max_y[@]; + (minx, miny)-- + (minx, maxy)-- + (maxx, maxy)-- + (maxx, miny)-- + cycle + fi enddef; vardef mth_axis @# (suffix ref_sfx) (expr idx)= @@ -1986,6 +2687,25 @@ vardef check_position_left (suffix pos_sfx) (expr default)= fi enddef; +vardef check_position_bot (suffix pos_sfx) (expr default)= + save pos_str; + string pos_str; + pos_str:=str pos_sfx; + if pos_str="t": + false + elseif pos_str="b": + true + else: + begingroup + drv_errhelp "Valid identifiers are"& + " t (top) and"& + " b (bottom)."; + drv_errmessage (pos_str&" is not a valid root position identifier"); + default + endgroup + fi +enddef; + vardef check_mode_on (suffix status_sfx) (expr default)= save status_str; string status_str; @@ -2027,7 +2747,7 @@ vardef drv_math_style (suffix typ_sfx) (expr sty_str)= else: forsuffixes sfx=scantokens (typ_str&"_sty"): for idx=0 upto 3: - sfx[idx]:=min(idx+sty_idx, 3); + sfx[idx]:=min (idx+sty_idx, 3); endfor endfor fi @@ -2046,12 +2766,15 @@ vardef drv_scale (suffix scl_sfx) (expr scl)= jdg_skp_scl:=scl; elseif (scl_str="ilb") or (scl_str="lbl"): % "lbl" is deprecated ilb_skp_scl:=scl; + elseif scl_str="crv": + crv_scl:=scl; else: drv_errhelp "Valid identifiers are"& " clr,"& " prm,"& - " jdg and"& - " ilb."; + " jdg,"& + " ilb and"& + " crv."; drv_errmessage (scl_str&" is not a valid scale identifier"); fi enddef; @@ -2104,19 +2827,7 @@ vardef drv_labels_position text ARG= 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 + drv_bot_roots:=check_position_bot (pos_sfx) (drv_bot_roots); enddef; vardef drv_axis_reference suffix ref_sfx= @@ -2161,6 +2872,14 @@ vardef drv_proof_mode suffix status_sfx= drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); enddef; +vardef drv_radial_mode suffix status_sfx= + drv_radialmode_on:=check_mode_on (status_sfx, drv_radialmode_on); +enddef; + +vardef drv_azimuth expr ngl= + azimuth_ngl:=ngl; +enddef; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -2192,6 +2911,10 @@ drv_box_mode off; drv_fraction_mode on; drv_proof_mode off; +drv_radial_mode off; +drv_scale (crv, 1); +drv_azimuth 90; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % diff --git a/Master/texmf-dist/doc/metapost/drv/template/makefile b/Master/texmf-dist/doc/metapost/drv/template/makefile index 239bbc6a46e..33507213d54 100644 --- a/Master/texmf-dist/doc/metapost/drv/template/makefile +++ b/Master/texmf-dist/doc/metapost/drv/template/makefile @@ -2,11 +2,11 @@ MAIN= template $(MAIN).pdf: $(MAIN).ps ps2pdf $(MAIN).ps + pdfopt $(MAIN).pdf $(MAIN)-opt.pdf + mv $(MAIN)-opt.pdf $(MAIN).pdf $(MAIN).ps: $(MAIN).tex $(MAIN)-delayed.mp latex $(MAIN) - latex $(MAIN) - latex $(MAIN) dvips $(MAIN) -o $(MAIN)-proof.pdf: $(MAIN)-proof.ps diff --git a/Master/texmf-dist/doc/metapost/drv/template/readme.txt b/Master/texmf-dist/doc/metapost/drv/template/readme.sh index be277b760a8..6aae46abd1b 100644 --- a/Master/texmf-dist/doc/metapost/drv/template/readme.txt +++ b/Master/texmf-dist/doc/metapost/drv/template/readme.sh @@ -1,13 +1,12 @@ -# In order to compile the sources and to get a pdf file, use `make' or: +# In order to compile the sources and to get a pdf file, +# use `make' or `./readme.sh' 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 +# 2. run latex (once): latex template.tex # 3. run dvips (once): diff --git a/Master/texmf-dist/doc/metapost/drv/template/template.mp b/Master/texmf-dist/doc/metapost/drv/template/template.mp index 0875f9df042..019c8f12da7 100644 --- a/Master/texmf-dist/doc/metapost/drv/template/template.mp +++ b/Master/texmf-dist/doc/metapost/drv/template/template.mp @@ -1,6 +1,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Structure of a MetaPost file using drv.mp +% Structure of a MetaPost file using drv % 1. Preamble % input drv; % verbatimtex %&latex @@ -97,6 +97,9 @@ etex; % drv_box_mode off; % drv_fraction_mode on; % drv_proof_mode off; +% drv_radial_mode off; +% drv_scale (crv, 1); +% drv_azimuth 90; beginfig(100) jgm 0 "\Gamma, \Delta, \Theta, \Pi, \Upsilon\vdash F"; @@ -122,6 +125,46 @@ nfr 0 (1, 2) ("\text{cut}", 1); draw drv_tree; endfig; +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(110) +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; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % diff --git a/Master/texmf-dist/doc/metapost/drv/template/template.tex b/Master/texmf-dist/doc/metapost/drv/template/template.tex index 687c45778b3..6b11487ae59 100644 --- a/Master/texmf-dist/doc/metapost/drv/template/template.tex +++ b/Master/texmf-dist/doc/metapost/drv/template/template.tex @@ -49,7 +49,12 @@ \makeatother \begin{document} +\paragraph{First example} \begin{gather*} -\frac{\qquad}{}\drv{template.100}\frac{\qquad}{} +\drv{template.100} +\end{gather*} +\paragraph{Second example} +\begin{gather*} +\drv{template.110} \end{gather*} \end{document} |