// This file is now automatically produced from the files in the MHTML directory. // Its only reason is to have just one big .xsl file in the Mizar distro. // So any changes should be done to the MHTML files, running 'make miz.xsl' afterwards. // The main stylesheet mhtml_main.xsl can be used instead miz.xsl, // provided the included .xsl files are available in the same directory stylesheet 1.0 extension-element-prefixes = "dc"; xmlns dc "http://purl.org/dc/elements/1.1/"; output method=html; // $Revision: 1.8 $ // // File: mhtml_main.xsltxt - html-ization of Mizar XML, main file // // Author: Josef Urban // // License: GPL (GNU GENERAL PUBLIC LICENSE) // XSLTXT (https://xsltxt.dev.java.net/) stylesheet taking // XML terms, formulas and types to less verbose format. // To produce standard XSLT from this do e.g.: // java -jar xsltxt.jar toXSL miz.xsltxt | sed -e 's//\1/g' >miz.xsl // (the sed hack is there because xsl:document is not yet supported by xsltxtx) // Then e.g.: xsltproc miz.xsl ordinal2.pre >ordinal2.pre1 // TODO: number B vars in fraenkel - done since 1.72 // handle F and H parenthesis as K parenthesis // article numbering in Ref? // absolute definiens numbers for thesisExpansions? - done // do not display BlockThesis for Proof? - done, should but should be optional for Now // add @nr to canceled // Constructor should know its serial number! - needed in defs // possibly also article? // change globally 'G' to 'L' for types? -> then change the // hacks here and in emacs.el // display definiens? - done // NOTES: constructor disambiguation is done using the absolute numbers // (attribute 'nr' and 'aid' of the Constructor element. // This info for Constructors not defined in the article is // taken from the .atr file (see variable $constrs) // // File: params.xsltxt - html-ization of Mizar XML, top-level parameters // // Author: Josef Urban // // License: GPL (GNU GENERAL PUBLIC LICENSE) // The following are user-customizable // mmlquery address #mmlq= { "http://merak.pb.bialystok.pl/mmlquery/fillin.php?entry="; } //#mmlq= {"";} // linking methods: // "q" - query, everything is linked to mmlquery // "s" - self, everything is linked to these xml/html files // "m" - mizaring and mmlquery, current article's constructs are linked to self, // the rest is linked to mmlquery // "l" - local mizaring, current article's constructs are linked to self, // the rest to $MIZFILES/html #linking = { "l"; } // needed for local linking, document("") gives the sylesheet as a document #mizfiles = { `string(/*/@mizfiles)`; } #mizhtml = { `concat("file://",$mizfiles,"html/")`; } // extension for linking to other articles - either xml or html #ext = { "html"; } // extension for linking to other articles - either xml or html #selfext = { choose { when [$linking = "l"] { "xml"; } when [$linking = "s"] { $ext; } when [$linking = "m"] { "xml"; } when [$linking = "q"] { "html"; } } } // default target frame for links #default_target = { if [$linking = "s"] { "_self"; } else { "mmlquery";} } // put titles to links or not #titles = { "0"; } // coloured output or not #colored = { "0"; } // print identifiers (like in JFM) instead of normalized names $print_identifiers = { "1"; } // new brackets: trying to print brackets as mizar does - // when two or more arguments of a functor - now default #mizar_brackets = { "1"; } // no spaces around functor symbols #funcs_no_spaces = { "0"; } // print label identifiers instead of normalized names // this is kept separate from $print_identifiers, because // it should be turned off for item generating $print_lab_identifiers = { "1"; } // print "for" in registrations - newly in version 1132 #regs_use_for = { "1"; } // tells whether relative or absolute names are shown #relnames= { "1"; } // link by (now also from) inferences to ATP solutions rendered by MMLQuery; experimental - off // 1 - static linking (to pre-generated html) // 2 - dynamic linking to MML Query (static dli sent to MMLQuery DLI-processor) // 3 - dynamic linking to the TPTP-processor CGI ($lbytptpcgi) #linkby= { "0"; } // if non zero, add icons for atp exlpanation calls to theorems and proofs in the same way as to by's #linkarproofs= { "0"; } // if > 0, call the mk_by_title function to create a title for by|from|; #by_titles = { "0"; } // If 1, the target frame for by explanations is _self #linkbytoself = { "0"; } // directory with by ATP solutions in HTML; each article in its own subdir #lbydir= { "_by/"; } // directory with by ATP solutions in DLI; each article in its own subdir // now whole url for the CGI script #lbydliurl= { "http://lipa.ms.mff.cuni.cz/~urban/xmlmml/html.930/_by_dli/"; } // URL of the DLI-processor CGI #lbydlicgi= { "http://mmlquery.mizar.org/cgi-bin/mmlquery/dli"; } // complete prefix of the DLI-processor CGI request $lbydlicgipref= { `concat($lbydlicgi,"?url=",$lbydliurl)`; } // URL of the MizAR root dir // #ltptproot= { "http://octopi.mizar.org/~mptp/"; } #ltptproot= { "http://mws.cs.ru.nl/~mptp/"; } // URL of the TPTP-processor CGI #ltptpcgi= { `concat($ltptproot,"cgi-bin/")`; } // URL of the showby CGI #lbytptpcgi= { `concat($ltptpcgi,"showby.cgi")`; } // URL of the showtmpfile CGI #ltmpftptpcgi= { `concat($ltptpcgi,"showtmpfile.cgi")`; } // tells if by action is fetched through AJAX; default is off #ajax_by = { "0"; } // temporary dir with the tptp by files, needs to be passed as a param #lbytmpdir = { ""; } // additional params for lbytptpcgi, needs to be passed as a param #lbycgiparams = { ""; } // add links to tptp files for thms #thms_tptp_links = { "0"; } // add editing, history, and possibly other links for wiki // the namespace for the scripts is taken from #ltptproot #wiki_links = { "0"; } // add buttons for editing wiki sections #wiki_sections = { "0"; } // domain name of the "wiki" server #lwikihost = { "mws.cs.ru.nl"; } // URL of the "wiki" server #lwikiserver = { `concat("http://",$lwikihost)`; } // URL of the "mwiki" cgi, used for mwiki actions #lmwikicgi= { `concat($lwikiserver,"/cgi-bin/mwiki/mwiki.cgi")`; } // name of the index page for wiki #lmwikiindex= { "00INDEX.html"; } // URL of the "wiki" raw cgi, showing the raw file #lrawcgi= { `concat($lwikiserver,"/cgi-bin/mwiki/raw.cgi")`; } // URL of the "gitweb" cgi, showing git history #lgitwebcgi= { `concat($lwikiserver,":1234/")`; } // name of the git repository (project) in which this page is contained - // used for gitweb history #lgitproject= { "mw1.git"; } // git clone address used for wiki cloning #lgitclone = { `concat("git://",$lwikihost,"/git/", $lgitproject)`; } // http clone address used for wiki cloning #lhttpclone = { `concat("http://",$lwikihost,"/git/", $lgitproject)`; } // tells if linkage of proof elements is done; default is off #proof_links = { "0"; } // tells if linkage of constants is done; default is 0 (off), // 1 tells to only create the anchors, 2 tells to also link constants // ##TODO: 2 is implement incorrectly and should not be used now, // it should be done like privname (via the C key, not like now) #const_links = { "0"; } // tells if proofs are fetched through AJAX; default is off // value 2 tells to produce the proofs, but not to insert the ajax calls, // and instead insert tags for easy regexp-based post-insertion of files // value 3 uses the ltmpftptpcgi to fetch the proof in the ajax request - like for by #ajax_proofs = { "0"; } // the dir with proofs that are fetched through AJAX #ajax_proof_dir = { "proofs"; } // tells to display thesis after skeleton items #display_thesis = { "1"; } // tells if only selected items are generated to subdirs; default is off #generate_items = { "0"; } // relevant only if $generate_items>0 // tells if proofs of selected items are generated to subdirs; default is off #generate_items_proofs = { "0"; } // add IDV links and icons #idv = { "0"; } // create header info from .hdr file #mk_header = { "0"; } // include comment info from .cmt file #mk_comments = { "0"; } // Suppress the header and trailer of the final document. // Thus, you can insert the resulting document into a larger one. #body_only = { "0"; } $lcletters= { "abcdefghijklmnopqrstuvwxyz"; } $ucletters= { "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } // name of current article (upper case) #aname= { `string(/*/@aid)`; } // name of current article (lower case) #anamelc= { `translate($aname, $ucletters, $lcletters)`; } // this needs to be set to 1 for processing MML files #mml = { if [/Article] { "0"; } else { "1"; } } // nr. of clusters in Typ // this is set to 1 for processing MML files #cluster_nr = { if [$mml = "0"] { "2"; } else { "1"; }} // whether we print all attributes (not just those with @pid) // this is set to 1 for processing MML files #print_all_attrs = { $mml; } // .atr file with imported constructors #constrs= { `concat($anamelc, '.atr')`; } // .eth file with imported theorems #thms= { `concat($anamelc, '.eth')`; } // .esh file with imported schemes #schms= { `concat($anamelc, '.esh')`; } // .eno file with imported patterns #patts= { `concat($anamelc, '.eno')`; } // .frx file with all (both imported and article's) formats #formats= { `concat($anamelc, '.frx')`; } // .dcx file with vocabulary #vocs= { `concat($anamelc, '.dcx')`; } // .idx file with identifier names #ids= { `concat($anamelc, '.idx')`; } // .dfs file with imported definientia #dfs= { `concat($anamelc, '.dfs')`; } // .hdr file with header info (done by mkxmlhdr.pl) #hdr= { `concat($anamelc, '.hdr')`; } // .cmt file with comments info (done by MizComments.pl) #cmt= { `concat($anamelc, '.cmt')`; } #varcolor = { "Olive"; } #constcolor = { "Maroon"; } #locicolor = { "Maroon"; } #schpcolor = { "Maroon"; } #schfcolor = { "Maroon"; } #ppcolor = { "Maroon"; } #pfcolor = { "Maroon"; } #labcolor = { "Green"; } #commentcolor = { "firebrick"; } // use spans for brackets #parenspans = { "1"; } // number of parenthesis colors (see the stylesheet in the bottom) #pcolors_nr = { "6"; } // top level element instead of top-level document, which is hard to // know #top = `/`; // debugging message #dbgmsg = { "zzzzzzzzz"; } // relative nr of the first expandable mode // #first_exp = { `//Pattern[(@constrkind='M') and (@constrnr=0)][1]/@relnr`; } // symbols, should be overloaded with different (eg tex, mathml) presentations #for_s = { " for "; } #ex_s = { " ex "; } #not_s = { " not "; } #non_s = { " non "; } #and_s = { " & "; } #imp_s = { " implies "; } #equiv_s = { " iff "; } #or_s = { " or "; } #holds_s = { " holds "; } #being_s = { " being "; } #be_s = { " be "; } #st_s = { " st "; } #is_s = { " is "; } #dots_s = { " ... "; } #fraenkel_start = { " { "; } #fraenkel_end = { " } "; } #of_sel_s = { " of "; } #of_typ_s = { " of "; } #the_sel_s = { " the "; } #choice_s = { " the "; } #lbracket_s = { "("; } #rbracket_s = { ")"; } // // File: keys.xsltxt - html-ization of Mizar XML, definition of keys (indexes) // // Author: Josef Urban // // License: GPL (GNU GENERAL PUBLIC LICENSE) // keys for fast constructor and reference lookup key "M" [Constructor[@kind='M']] `@relnr` ; key "L" [Constructor[@kind='L']] `@relnr` ; key "V" [Constructor[@kind='V']] `@relnr` ; key "R" [Constructor[@kind='R']] `@relnr` ; key "K" [Constructor[@kind='K']] `@relnr` ; key "U" [Constructor[@kind='U']] `@relnr` ; key "G" [Constructor[@kind='G']] `@relnr` ; key "T" [/Theorems/Theorem[@kind='T']] `concat(@articlenr,':',@nr)`; key "D" [/Theorems/Theorem[@kind='D']] `concat(@articlenr,':',@nr)`; key "S" [/Schemes/Scheme] `concat(@articlenr,':',@nr)`; key "DF" [Definiens] `@relnr` ; // patterns are slightly tricky, since a predicate pattern // may be linked to an attribute constructor; hence the // indexing is done according to @constrkind and not @kind // TODO: the attribute<->predicate change should propagate to usage // of "is" // Expandable modes have all @constrkind='M' and @constrnr=0, // they are indexed separately only on their @relnr (@pid) key "P_M" [Pattern[(@constrkind='M') and (@constrnr>0)]] `@constrnr` ; key "P_L" [Pattern[@constrkind='L']] `@constrnr` ; key "P_V" [Pattern[@constrkind='V']] `@constrnr` ; key "P_R" [Pattern[@constrkind='R']] `@constrnr` ; key "P_K" [Pattern[@constrkind='K']] `@constrnr` ; key "P_U" [Pattern[@constrkind='U']] `@constrnr` ; key "P_G" [Pattern[@constrkind='G']] `@constrnr` ; key "EXP" [Pattern[(@constrkind='M') and (@constrnr=0)]] `@relnr` ; key "F" [Format] `@nr`; key "D_G" [Symbol[@kind='G']] `@nr`; key "D_K" [Symbol[@kind='K']] `@nr`; key "D_J" [Symbol[@kind='J']] `@nr`; key "D_L" [Symbol[@kind='L']] `@nr`; key "D_M" [Symbol[@kind='M']] `@nr`; key "D_O" [Symbol[@kind='O']] `@nr`; key "D_R" [Symbol[@kind='R']] `@nr`; key "D_U" [Symbol[@kind='U']] `@nr`; key "D_V" [Symbol[@kind='V']] `@nr`; // identifiers key "D_I" [Symbol[@kind='I']] `@nr`; // keys for absolute linkage inside proofs; // requires preprocessing by addabsrefs, otherwise wrong results, // so commented now (could be uncommented using conditional include probably) // lookup for local constants key "C" [Let|Given|TakeAsVar|Consider|Set|Reconsider] `@plevel` ; // lookup for propositions key "E" [Proposition|IterEquality|Now] `concat(@nr,":",@plevel)` ; // lookup for scheme functors and predicates key "f" [SchemeFuncDecl] `concat(@nr,":",@plevel)` ; key "p" [SchemePredDecl] `concat(@nr,":",@plevel)` ; // lookup for private functors and predicates key "pf" [DefFunc] `concat(@nr,":",@plevel)` ; key "pp" [DefPred] `concat(@nr,":",@plevel)` ; // lookup for comments key "CMT" [Comment] `@endline`; // // File: print_simple.xsltxt - html-ization of Mizar XML, simple printing funcs // // Author: Josef Urban // // License: GPL (GNU GENERAL PUBLIC LICENSE) // pretty print variables and labels // ##TODO: link variables and consts to their introduction? // private - look up the name of id tpl get_vid_name(#vid) { for-each [document($ids, /)] { for-each [key('D_I', $vid)] { `@name`; } } } tpl pqvar(#nr, #vid) { if [($print_identifiers > 0) and ($vid > 0)] { $nm = { get_vid_name(#vid = $vid); } if [$colored = "1"] { 0) and ($vid > 0)] { $ctarget = { if [($const_links>0) and ($pl)] { "c"; $nr; addp(#pl=$pl); } else { `concat("c",$nr)`; } } $nm = { get_vid_name(#vid = $vid); } if [($const_links=2)] // const_links imply colored here { 0) and ($proof_links>0)] { $pl = get_nearest_level(#el = `..`); absconst(#nr = `@nr`, #pl = $pl); } else { pconst(#nr=`@nr`); } } tpl ploci(#nr) { if [$colored="1"] { 0) and ($vid > 0)] { $nm = { get_vid_name(#vid = $vid); } 0] { $el1=`$els[position()=$nr]`; $res1 = { is_positive(#el=`$els[position()=$nr]`); } $res2 = { count_positive(#els=$els,#nr=`$nr - 1`); } //DEBUG `concat($res1,":",$res2)`; `$res1 + $res2`; } else { "0"; }} // if $neg, then put negative, striping the negation tpl put_positive(#separ,#els,#nr,#neg,#i) { if [$nr > 0] { $el1=`$els[position()=1]`; $pos = is_positive(#el=$el1); $pos1 = { if [$neg="1"] { `($neg + $pos) mod 2`; } else { $pos; }} if [$pos1="1"] { $nm = `name($el1)`; if [$neg="1"] { // change this if is_positive changes! choose { when [$nm="Not"] { apply[$el1/*[1]](#i=$i); } when [$nm="Pred"] { apply[$el1](#i=$i,#not="1"); } otherwise { $dbgmsg; $nm; } } } else { if [$nm="Not"] { apply[$el1/*[1]](#i=$i,#not="1"); } else { apply[$el1](#i=$i); }} if [$nr > 1] { $separ; } } put_positive(#separ=$separ,#els=`$els[position() > 1]`,#nr=`$nr - $pos1`,#neg=$neg); } } tpl is_or(#el) { for-each [$el] { if [(@pid=$pid_Or) and (*[1][@pid=$pid_Or_And]) and (count(*[1]/*)=2) and (*[1]/*[1][@pid=$pid_Or_LeftNot]) and (*[1]/*[2][@pid=$pid_Or_RightNot])] { "1"; } else { "0"; }}} // now also used when included "or" ate the implicant tpl is_or1(#el) { for-each [$el] { if [((@pid=$pid_Or) or (@pid=$pid_Impl)) and (*[1][@pid=$pid_Or_And]) and (count(*[1]/*)>=2)] { "1"; } else { "0"; }}} // used when is_or failed tpl is_or3(#el) { for-each [$el] { if [(@pid=$pid_Or) and (*[1][@pid=$pid_Or_And]) and (count(*[1]/*)=2)] { $neg1 = { is_negative(#el=`*[1]/*[1]`); } $neg2 = { is_negative(#el=`*[1]/*[2]`); } `$neg1 * $neg2`; } else { "0"; }}} // used when is_or3 failed tpl is_or4(#el) { for-each [$el] { if [(@pid=$pid_Or) and (*[1][@pid=$pid_Or_And]) and (count(*[1]/*)=2)] { "1"; } else { "0"; }}} tpl is_impl(#el) { for-each [$el] { if [(@pid=$pid_Impl) and (*[1][@pid=$pid_Impl_And]) and (count(*[1]/*)=2) and (*[1]/*[2][@pid=$pid_Impl_RightNot])] { "1"; } else { "0"; }}} tpl is_impl1(#el) { for-each [$el] { if [(@pid=$pid_Impl) and (*[1][@pid=$pid_Impl_And]) and (count(*[1]/*)>=2)] { choose { when [*[1]/*[@pid=$pid_Impl_RightNot]] { "2"; } when [name(*[1]/*[position()=last()]) = "For"] { "4"; } otherwise { $neg1 = { is_negative(#el=`*[1]/*[position()=last()]`); } if [$neg1 = "1"] { "3"; } else { "5"; } } } } else { "0"; }}} tpl is_impl2(#el) { for-each [$el] { if [(@pid=$pid_Impl) and (*[1][@pid=$pid_Impl_And]) and (count(*[1]/*)>=2) and ((*[1]/*[@pid=$pid_Impl_RightNot]))] { "1"; } else { "0"; }}} // used when is_impl2 failed tpl is_impl3(#el) { for-each [$el] { if [(@pid=$pid_Impl) and (*[1][@pid=$pid_Impl_And]) and (count(*[1]/*)>=2)] { is_negative(#el=`*[1]/*[position()=last()]`); } else { "0"; }}} // used when is_impl3 failed tpl is_impl4(#el) { for-each [$el] { if [(@pid=$pid_Impl) and (*[1][@pid=$pid_Impl_And]) and (count(*[1]/*)>=2) and (name(*[1]/*[position()=last()]) = "For")] { "1"; } else { "0"; }}} // used when is_impl4 failed tpl is_impl5(#el) { for-each [$el] { if [(@pid=$pid_Impl) and (*[1][@pid=$pid_Impl_And]) and (count(*[1]/*)>=2)] { "1"; } else { "0"; }}} tpl is_equiv(#el) { for-each [$el] { $e1 = { if [(@pid=$pid_Iff) and (count(*)=2)] { $i1 = { is_impl(#el=`$el/*[1]`); } if [$i1="1"] { is_impl(#el=`*[2]`); } else { "0"; }} else { "0"; } } if [$e1="1"] { $res1 = { are_equal( #el1=`*[1]/*[1]/*[1]`, #el2=`*[2]/*[1]/*[2]/*[1]`); } $res2 = { are_equal( #el1=`*[2]/*[1]/*[1]`, #el2=`*[1]/*[1]/*[2]/*[1]`); } if [($res1="1") and ($res2="1")] { "1"; } else { "0"; }} else { $e1; }}} // recursive equality on subnodes and attributes tpl are_equal(#el1,#el2) { if[ not(name($el1)=name($el2)) or not(count($el1/*)=count($el2/*)) or not(count($el1/@*)=count($el2/@*))] { "0"; } else { $s1 = { for-each [$el1/@*] { `string()`;} } $s2 = { for-each [$el2/@*] { `string()`;} } if [not($s1=$s2)] { "0"; } else { are_equal_many(#els1=`$el1/*`,#els2=`$el2/*`,#nr=`count($el1/*)`); }}} tpl are_equal_many(#els1,#els2,#nr) { if [$nr > 0] { $el1=`$els1[position()=$nr]`; $el2=`$els2[position()=$nr]`; $res1 = { are_equal(#el1=$el1, #el2=$el2); } if [$res1="1"] { are_equal_many(#els1=$els1, #els2=$els2, #nr=`$nr - 1`);} else { "0"; }} else { "1"; }} // recursive equality on subnodes and attributes upto the @vid attribute tpl are_equal_vid(#el1,#el2) { if[ not(name($el1)=name($el2)) or not(count($el1/*)=count($el2/*)) or not(count($el1/@*)=count($el2/@*))] { "0"; } else { $s1 = { for-each [$el1/@*] { if[not(name()="vid")] { `string()`;}} } $s2 = { for-each [$el2/@*] { if[not(name()="vid")] { `string()`;}} } if [not($s1=$s2)] { "0"; } else { are_equal_many_vid(#els1=`$el1/*`,#els2=`$el2/*`,#nr=`count($el1/*)`); }}} tpl are_equal_many_vid(#els1,#els2,#nr) { if [$nr > 0] { $el1=`$els1[position()=$nr]`; $el2=`$els2[position()=$nr]`; $res1 = { are_equal_vid(#el1=$el1, #el2=$el2); } if [$res1="1"] { are_equal_many_vid(#els1=$els1, #els2=$els2, #nr=`$nr - 1`);} else { "0"; }} else { "1"; }} tpl lc(#s) { `translate($s, $ucletters, $lcletters)`; } tpl uc(#s) { `translate($s, $lcletters, $ucletters)`; } // utilities for adding lemma names tpl addp(#pl) { if [string-length($pl)>0] { ":"; $pl; }} tpl propname(#n,#pl) { "E"; $n; addp(#pl=$pl); } // poor man's data structure, aka "colon-list" #nil = { ""; } tpl cons(#h,#t) { `concat($h,":",$t)`; } tpl car(#l) { `substring-before($l,":")`;} tpl cdr(#l) { `substring-after($l,":")`;} tpl cadr(#l) { car(#l=cdr(#l=$l));} tpl cddr(#l) { cdr(#l=cdr(#l=$l));} tpl third(#l) { car(#l=cddr(#l=$l)); } tpl cdddr(#l) { cdr(#l=cddr(#l=$l));} // poor man's 0-based integer arrays (integer is non-negative and four digits long now) // the biggest identifier number is 1061 for jordan7 in MML 758 #int_size = { "4"; } // #index must be 0-based tpl arr_ref(#array,#index) { $beg = `$int_size * $index`; `number(substring($array, $beg, $beg + $int_size))`; } tpl apush(#array,#obj) { $obj1 = { arr_pad_obj(#obj); } `concat($array, $obj1)`; } tpl arr_set(#array,#index,#obj) { $obj1 = { arr_pad_obj(#obj); } $beg = `$int_size * $index`; $end = `$beg + $int_size`; $prefix = `substring($array, 0, $beg)`; $postfix = `substring($array, $end)`; `concat($prefix, $obj1, $postfix)`; } // explicit for speed tpl arr_zeros(#l) { choose { when [$l = 0] { "";} when [$l = 1] { "0";} when [$l = 2] { "00";} when [$l = 3] { "000";} when [$l = 4] { "0000";} when [$l = 5] { "00000";} } } tpl arr_pad_obj(#obj) { $length = `$int_size - string-length($obj)`; $padding = { arr_zeros(#l = $length); } `concat($padding, $obj)`; } // List utilities tpl list(#separ,#elems) { for-each [$elems] { apply[.]; if [not(position()=last())] { copy-of $separ; } } } // List utility with additional arg - now only used for formula lists tpl ilist(#separ,#elems,#i,#pr) { for-each [$elems] { apply[.](#i=$i,#pr=$pr); if [not(position()=last())] { copy-of $separ; } } } // newlined list tpl nlist(#separ,#elems) { for-each [$elems] { apply[.]; if [not(position()=last())] { 0] { addp(#pl = $pl); } } for-each [$elems] { $nr1 = `$j+position()`; if [$const_links>0] { 0] { "1"; } else { "0"; } } $vis = mk_vis_list(#els=`Visible/Int`); cons(#h = `@formatnr`, #t = cons(#h = $shift, #t = cons(#h = $plink, #t = $vis))); } // this is a small hack to minimize chasing patterns // returns list [formatnr, antonymic or expandable (+2 if attrpred), // redefinition | visiblelist] tpl patt_info(#k, #nr, #pid) { $k1 = { if [$k="L"] { "G"; } else { $k; } } $typ = `($k1 = "G") or ($k1="M")`; $pkey = `concat('P_',$k1)`; if [$pid>0] { $doc = { if [($typ and key('EXP',$pid)) or (key($pkey,$nr)[$pid=@relnr])] { ""; } else { $patts; } } for-each [document($doc,/)] { if [$typ and key('EXP',$pid)] { for-each [key('EXP',$pid)] { $vis = mk_vis_list(#els = `Visible/Int`); cons(#h = `@formatnr`, #t = cons(#h ="1",#t = cons(#h = "0",#t = $vis))); } } else { if [key($pkey,$nr)[$pid=@relnr]] { for-each [key($pkey,$nr)[$pid=@relnr]] { encode_std_pattern(#k = $k); } } else { "failedpid:"; $k1;":";$nr;":"; $pid;":"; } } } } else { $doc = { if [key($pkey,$nr)] { ""; } else { $patts; } } for-each [document($doc,/)] { for-each [key($pkey,$nr)[position()=1]] { encode_std_pattern(#k = $k); } } } } // the string length #ls does not change; // test if the #n-th position in #pl from back is underscore, // if so, cut it and what follows it, // otherwise try with n+1 // called externally with #n=1; // $n<10 is probably needed to guard the recursion - limits us // to nine digit numbers of previous blocks - seems safe now tpl get_parent_level(#pl, #ls, #n) { $p = { `$ls - $n`; } $p1 = { `$ls - ($n + 1)`; } if [substring($pl, $p, 1) = '_'] { `substring($pl, 1, $p1)`; } else { if [$n < 10] { get_parent_level(#pl = $pl, #ls = $ls, #n = `$n+1`); } } } tpl add_hs_attrs { @class="txt"; @onclick="hs(this)"; @href="javascript:()"; } tpl add_hs2_attrs { @class="txt"; @onclick="hs2(this)"; @href="javascript:()"; } tpl add_hsNdiv_attrs { @class="txt"; @onclick="hsNdiv(this)"; @href="javascript:()"; } tpl add_ajax_attrs(#u) { @class="txt"; @onclick=`concat("makeRequest(this,'",$u,"')")`; @href="javascript:()"; } // // File: frmtrm.xsltxt - html-ization of Mizar XML, code for terms, formulas, and types // // Author: Josef Urban // // License: GPL (GNU GENERAL PUBLIC LICENSE) // Formulas // #i is nr of the bound variable, 0 by default // #k is start of the sequence of vars with the same type, $i by default // we now output only one typing for such sequences // #ex tells that we should print it as existential statement, // i.e. also omitting the first descending Not (the caller // should guarantee that there _is_ a Not after the block of For-s) // #pr tells to put the formula in paranthesis tpl [For](#i,#k,#ex,#pr) { $j = { if [$i] { $i;} else { "0"; } } $l = { if [$k] { $k;} else { $j; } } if [$l = $j] { // print initial quantifier if at the beginning of var segment if [$pr] { copy-of $lbracket_s; " "; } if [$ex="1"] { copy-of $ex_s; } else { copy-of $for_s; } } pqvar(#nr = `$j + 1`, #vid = `@vid`); $nm = { `name(*[2])`; } $eq1 = { if [($nm = "For") and (*[1]/@nr = *[2]/*[1]/@nr)] { are_equal(#el1=`*[1]`,#el2=`*[2]/*[1]`); } else { "0"; } } if [$eq1="1"] { ", "; apply[*[2]](#i=`$j+1`,#k=$l,#ex=$ex,#pr=$pr); } else { if [$ex="1"] { copy-of $being_s; apply[*[1]](#i=`$j + 1`); if [$nm = "For"] { apply[*[2]](#i=`$j+1`,#ex=$ex); } else { copy-of $st_s; // $nm; if [($nm = "And") or (name(Not/*[1]) = "And") or (name(Not/*[1]) = "For")] { 1] { copy-of $or_s; } $neg1 = { is_negative(#el=`.`); } if [$neg1 = "1"] { if [name() = "Not"] { apply[*[1]](#i=`$j+1`); } // now Pred, which is antonymous else { apply[.](#i=`$j+1`,#not="1"); } } else { if [name() = "For"] { apply[.](#i=`$j+1`,#ex="1"); } else { " not "; apply[.](#i=`$j+1`); } } } } else { // pretend this is an impl ilist(#separ = $and_s, #elems=`*[2]/*[position() 0] { // " IMPL1 "; $i3; if [$st="1"] { copy-of $st_s; } else { copy-of $lbracket_s; " "; } if [$i3=2] { ilist(#separ = $and_s, #elems=`*[1]/*[not(@pid=$pid_Impl_RightNot)]`, #i=$i,#pr="1"); if [$st="1"] { copy-of $holds_s; =2)] { "1"; } else { "0";}}} if [$i1="1"] { copy-of $lbracket_s; " "; // " OR1 "; for-each [*[1]/*] { if [position()>1] { copy-of $or_s; } $neg1 = { is_negative(#el=`.`); } if [$neg1 = "1"] { if [name() = "Not"] { apply[*[1]](#i=$i); } // now Pred, which is antonymous else { apply[.](#i=$i,#not="1"); } } else { if [name() = "For"] { apply[.](#i=$i,#ex="1"); } else { copy-of $not_s; apply[.](#i=$i); } } } " "; copy-of $rbracket_s; } else { copy-of $not_s; if[@pid] { comment { "HUMANRECFAILED"; } } // else {"NOPID ";} apply[*[1]](#i=$i); } } } } } // this was too AI, mizar is much simpler // $cnt=`count(*[1]/*)`; // $pcnt1 = { if [$i3="1"] { count_positive(#els=`*[1]/*`,#nr=$cnt); } else {"10000";} } // $pcnt = $pcnt1; // // $pcnt1; ":"; $cnt; ":"; $i3; // if [($pcnt>0) and ($pcnt<$cnt)] { // // "hhhhhhhhhhhh"; // copy-of $lbracket_s; " "; put_positive(#separ=copy-of $and_s,#els=`*[1]/*`,#nr=$pcnt,#i=$i); copy-of $imp_s; // put_positive(#separ=copy-of $or_s,#els=`*[1]/*`,#nr=`$cnt - $pcnt`,#neg="1",#i=$i); copy-of $rbracket_s; // } // else { if [($i3="1") and ($pcnt=0)] { copy-of $lbracket_s; " "; put_positive(#separ=copy-of $or_s,#els=`*[1]/*`,#nr=$cnt,#neg="1",#i=$i); copy-of $rbracket_s; } // if [$i3="1" and (*[1]/*[not(name()="Not")]) and (*[1]/Not)] { "( ( "; // ilist(#separ=$and_s, #elems=`*[1]/*[not(name()="Not")]`, #i=$i,#pr="1"); // " "; copy-of $rbracket_s; copy-of $imp_s; // copy-of $lbracket_s; " "; ilist(#separ=$or_s, #elems=`*[1]/Not/*[1]`, #i=$i,#pr="1"); " ) )"; } tpl [And](#i,#pr) { $e1= is_equiv(#el=`.`); if [$e1="1"] { copy-of $lbracket_s; " "; apply[*[1]/*[1]/*[1]](#i=$i,#pr="1"); copy-of $equiv_s; apply[*[1]/*[1]/*[2]/*[1]](#i=$i); " "; copy-of $rbracket_s; } else { // a bit risky if [(@pid=$pid_Iff) and (count(*)=2)] { $i1= is_impl(#el=`*[1]`); if [$i1="1"] { copy-of $lbracket_s; " "; apply[*[1]/*[1]/*[1]](#i=$i,#pr="1"); copy-of $equiv_s; apply[*[1]/*[1]/*[2]/*[1]](#i=$i); " "; copy-of $rbracket_s; } else { $i2= is_impl(#el=`*[2]`); if [$i2="1"] { copy-of $lbracket_s; " "; apply[*[2]/*[1]/*[2]/*[1]](#i=$i,#pr="1"); copy-of $equiv_s; apply[*[2]/*[1]/*[1]](#i=$i); " "; copy-of $rbracket_s; } else { $i3 = is_impl1(#el=`*[1]`); $i4 = is_impl1(#el=`*[2]`); if [($i3 > 0) or ($i4 > 0)] { // select better impl - no, prefer the first $which = { if [($i3 = 0)] { "2"; } else { "1"; }} // if [($i4 = 0)] { "1"; } else { // if [$i3 > $i4] { "2"; } else { "1"; }}}} $i5 = { if [$which=1] { $i3; } else { $i4; }} for-each [*[position()=$which]] { // " IFF2: "; $which; copy-of $lbracket_s; " "; if [$i5=2] { ilist(#separ = $and_s, #elems=`*[1]/*[not(@pid=$pid_Impl_RightNot)]`, #i=$i,#pr="1"); copy-of $equiv_s; apply[*[1]/*[@pid=$pid_Impl_RightNot]/*[1]](#i=$i); } else { ilist(#separ = $and_s, #elems=`*[1]/*[position()1] { "1";} else { "0"; }} $neg = { if [$not="1"] { `($antonym + $not) mod 2`; } else { `$antonym mod 2`; }} if [$neg="1"] { copy-of $not_s;} if [(@kind='V') and ($predattr="0")] { apply[*[position() = last()]](#i = $i); copy-of $is_s; pp(#k=`@kind`,#nr=`@nr`,#args=`*[position() < last()]`,#pid=`@pid`,#i=$i); // abs(#k=`@kind`, #nr=`@nr`, #sym=abs1(#k=`@kind`, #nr=`@nr`, #fnr=$fnr, #pid=$pid)); } else { pp(#k=`@kind`,#nr=`@nr`,#args=`*`,#pid=`@pid`,#i=$i); } } } } //,#sym1=abs(#k=`@kind`, #nr=`@nr`, #sym=abs1(#k=`@kind`, #nr=`@nr`))); }} // "[ "; list(#separ=",", #elems=`*`); "]"; } tpl [PrivPred](#i,#pr,#not) { if [$not="1"] { copy-of $not_s; } pppred(#nr=`@nr`); "["; ilist(#separ=",", #elems=`*[position() < last()]`, #i = $i); "]"; } tpl [Is](#i,#pr,#not) { apply[*[1]](#i = $i); copy-of $is_s; if [$not="1"] { copy-of $not_s; } apply[*[2]](#i = $i); } tpl [Verum](#i,#pr,#not) { if [$not="1"] { "contradiction"; } else { "verum";} } tpl [ErrorFrm](#i,#pr,#not) { if [$not="1"] { copy-of $not_s; } "errorfrm"; } tpl [FlexFrm](#i,#pr,#not) { $conn = { if [$not="1"] { $or_s; } else { $and_s; } } apply[*[1]](#i = $i, #pr = $pr, #not = $not); $conn; copy-of $dots_s; $conn; apply[*[2]](#i = $i, #pr = $pr, #not = $not); } // Terms // #p is the parenthesis count // #i is the size of the var stack tpl [Var](#p,#i) { if [$print_identifiers > 0] { $vid = { get_vid(#up = `$i - @nr`); } pqvar(#nr = `@nr`, #vid = $vid); } else { pvar(#nr=`@nr`); } } // search parent For and Fraenkel for #nr, return its vid // #bound says how many vars ( -1) are currently quantified // (depth of the quantifier stack), so we need to go // #bound - #nr times up (this is now passed just as #up) tpl get_vid(#up) { if [name() = "For"] { if [$up = "0"] { `@vid`; } else { for-each [..] { get_vid(#up = `$up - 1`); } } } else { if [(name() = "Typ") and (name(..) = "Fraenkel")] { // the case for var inside fraenkel typ - // only previous lamdaargs are available $tnr = `count(preceding-sibling::Typ)`; if [$up < $tnr] { `preceding-sibling::Typ[position() = (last() - $up)]/@vid`; } else { for-each [../..] { get_vid(#up = `$up - $tnr`); } } } else { if [name() = "Fraenkel"] { // the case for var inside lambdaterm and lambdaformula - // all lamdaargs are available $tnr = `count(Typ)`; if [$up < $tnr] { `Typ[position() = (last() - $up)]/@vid`; } else { for-each [..] { get_vid(#up = `$up - $tnr`); } } } else { for-each [..] { get_vid(#up = $up); } } } } } // trickery to translate loci to constants and identifiers when needed // this unfortunately does not work for IdentifyRegistration, so that's // dealt with by looking at the compatibility fla now :-( // ###TODO: also the constructor types tpl [LocusVar](#p, #i) { // try definienda possibly containing "it" if [($mml="0") and (ancestor::DefMeaning)] { $it_possible = { if [(ancestor::Definiens[(@constrkind="M") or (@constrkind="K")])] { "1"; } else { "0"; } } $maxnr = { for-each [ancestor::Definiens] { `count(Typ)`;} } if [(@nr = $maxnr) and ($it_possible="1")] { pkeyword(#str="it"); } else { if [@nr <= $maxnr] { $nr = `@nr`; // preceding-sibling written this way selects in reverse document order for-each [ancestor::Definiens] { $argtypes = `preceding-sibling::DefinitionBlock[1]/Let/Typ`; ppconst(#nr = $nr, #vid = `$argtypes[position() = $nr]/@vid`); } } else { ploci(#nr = `@nr`); } } } else { // note that the Constructor may come from different document here // even if $mml = 0, but that can be handled above, because this is // only used for result types which in that case shouldn't have changed // Exapnsion used for expandable mode defs if [($mml="0") and ((ancestor::Constructor) or (ancestor::Expansion)) and (ancestor::Definition)] { $nr = `@nr`; $argtypes = `ancestor::DefinitionBlock/Let/Typ`; ppconst(#nr = $nr, #vid = `$argtypes[position() = $nr]/@vid`); } else { if [($mml="0") and (ancestor::Registration)] { $nr = `@nr`; $argtypes = `ancestor::RegistrationBlock/Let/Typ`; ppconst(#nr = $nr, #vid = `$argtypes[position() = $nr]/@vid`); } else { if [($mml="0") and ((ancestor::DefPred) or (ancestor::DefFunc))] { "$"; `@nr`; } else { ploci(#nr = `@nr`); } } } } } tpl [FreeVar](#p,#i) { "X"; `@nr`; } tpl [Const](#p,#i) { if [($print_identifiers > 0) and ((@vid>0) or ($proof_links>0))] { if [@vid > 0] { $pl = { if[$const_links=2] { get_nearest_level(#el = `..`); } } ppconst(#nr = `@nr`, #vid = `@vid`, #pl = $pl); } else { $pl = get_nearest_level(#el = `..`); absconst(#nr = `@nr`, #pl = $pl); } } else { pconst(#nr = `@nr`); } } tpl [InfConst](#p,#i) { "D"; `@nr`; } tpl [Num](#p,#i) { `@nr`; } tpl [Func](#p,#i) { choose { when [@kind='F'] { pschfvar(#nr=`@nr`); copy-of $lbracket_s; ilist(#separ=",", #elems=`*`, #i = $i); copy-of $rbracket_s;} when [@kind='U'] { copy-of $the_sel_s; abs(#k=`@kind`, #nr=`@nr`, #sym=abs1(#k=`@kind`, #nr=`@nr`)); copy-of $of_sel_s; apply[*[position() = last()]](#p = $p, #i = $i); } otherwise { $par = { if [$p>0] { `$p+1`;} else { if [name(..)='Func'] { "1"; } else { "0";} } } pp(#k=`@kind`,#nr=`@nr`,#args=`*`,#parenth=$par,#pid=`@pid`,#i=$i); }}} tpl [PrivFunc](#p,#i) { ppfunc(#nr=`@nr`); copy-of $lbracket_s; ilist(#separ=",", #elems=`*[position()>1]`, #i = $i); copy-of $rbracket_s; } tpl [ErrorTrm](#p,#i) { "errortrm"; } tpl [Choice](#p,#i) { copy-of $choice_s; apply[Typ](#i = $i); } tpl [Fraenkel](#p,#i) { $j = { if [$i] { $i;} else { "0"; } } $par = { if [$p>0] { `$p+1`;} else { "1"; } } $inc = { `count(*) - 2`; } // number of vars introduced here $paren_color = `$par mod $pcolors_nr`; 2] { " where "; for-each[*[position() < last() - 1]] { pqvar(#nr = `$j + position()`, #vid = `@vid`); $eq1 = { if [position()=last()] { "0"; } else { are_equal_vid(#el1=`.`,#el2=`following-sibling::*[1]`); } } if [$eq1="0"] { copy-of $is_s; apply[.](#i=`$j + position() - 1`); } if [not(position()=last())] { ", "; } } } // then the formula " : "; apply[*[position() = last()]](#i = `$j + $inc`); " "; } copy-of $fraenkel_end; } " "; } // Types // element Typ { // attribute kind { "M" | "G" | "L" | "errortyp" }, // attribute nr { xsd:integer }?, // ( attribute absnr { xsd:integer }, // attribute aid { xsd:string } )?, // attribute pid { xsd:integer }?, // Cluster*, // Term* // } tpl [Typ](#i) { " "; if [count(*)>0] { apply[*[1]](#i = $i); } if [(@kind="M") or (@kind="G") or (@kind="L")] { $pi = { patt_info(#k = `@kind`, #nr = `@nr`, #pid = `@pid`); } //DEBUG ":"; `@pid`; ":"; $pi; ":"; $fnr = car(#l = $pi); $expand = cadr(#l = $pi); $plink = third(#l = $pi); $k1 = { if [@kind = "M"] { "M"; } else { "L";} } if [($expand="0") or not(@pid)] { pp(#k = $k1, #nr = `@nr`, #args = `*[not(name()="Cluster")]`, #pid = `@pid`, #i = $i); } else { $sym = abs1(#k = `@kind`, #nr = `@nr`, #fnr = $fnr); $vis = cdddr(#l = $pi); $el = `.`; //DEBUG ":"; `@pid`; ":"; $pi; ":"; $pid = `@pid`; $doc = { if [key('EXP',$pid)] { ""; } else { $patts; } } $c1 = { if [($doc = "") and ($mml = "0")] { "1"; } else { "0"; } } for-each [document($doc,/)] { absref(#elems = `key('EXP',$pid)`, #c = $c1, #sym = $sym, #pid = $pid); if [not($vis = "")] { $of_typ_s; for-each [key('EXP',$pid)] { descent_many_vis(#patt = `Expansion/Typ`, #fix = $el, #vis = `Visible/Int`, #i = $i); } } } } } else { `@kind`; } } // Gets two Typ (#patt and #fix), and a list of Visible/Int . // Tries to find and print the terms in #fix corresponding // to the visible loci; #patt is structurally similar to // #fix, up to the loci . // The handling of #i is potentially incorrect if there is a Fraenkel as // a param of the type . // Newly we also descent through Clusters, because dependent adjectives // allow things like: mode ManySortedSet of I is I -defined total Function . // We still optimize by starting with the terms (after "of"), the clusters // are used last (if nothing was found in terms). tpl descent_many_vis(#patt,#fix,#vis,#i) { if [$vis] { $v1= `$vis[position()=1]/@x`; $v2= `$vis[position()>1]`; $adjnrs = { for-each [$patt/Cluster[1]/Adjective] { ":"; `@nr`; ":"; } } //DEBUG "descen:"; $v1; ":"; apply[$patt]; ":"; descent_many(#patts = `$patt/*[(not(name()="Cluster"))] | $patt/Cluster[1]/Adjective`, #fixs = `$fix/*[(not(name()="Cluster"))] | $fix/Cluster[1]/Adjective[(contains($adjnrs, concat(":",@nr,":")))]`, #lnr = $v1, #nr = `count($patt/*[(not(name()="Cluster"))]) + count($patt/Cluster[1]/Adjective)`, #i = $i); if [$v2] { ","; descent_many_vis(#patt=$patt,#fix=$fix, #vis=`$vis[position()>1]`, #i = $i); } } } tpl descent_many(#patts,#fixs,#lnr,#nr,#i) { if [$nr > 0] { $patt=`$patts[position()=$nr]`; $fix =`$fixs[position()=$nr]`; //DEBUG "desone:"; $nr; ":"; `name($patt)`; ":"; `name($fix)`; ":"; if [(name($patt)="LocusVar") and ($patt/@nr=$lnr)] { //DEBUG $lnr; ":"; `$patt/@nr`; ":"; "fff"; for-each [$top] { apply[$fix](#p="0", #i = $i); } } // the duplication here is needed to generated the html properly; // it does not cause any visible slowdown in practice else { $res= { if [name($patt) = name($fix)] { descent_many(#patts=`$patt/*`,#fixs=`$fix/*`, #lnr=$lnr,#nr=`count($patt/*)`, #i = $i); } else {"";}} if [$res and not($res="")] { //DEBUG [and contains($res,"fff")] descent_many(#patts=`$patt/*`,#fixs=`$fix/*`, #lnr=$lnr,#nr=`count($patt/*)`, #i = $i); } else { descent_many(#patts=$patts,#fixs=$fixs,#lnr=$lnr,#nr=`$nr - 1`, #i = $i); }} } } // Clusters // only attributes with pid are now printed, unless %all=1; // others are results of // cluster mechanisms - this holds in the current article // (.xml file) only, environmental files do not have the @pid // info (yet), so we print everything for them tpl [Cluster](#i,#all) { if [($print_all_attrs = 1) or ($all = 1)] { list(#separ=" ", #elems=`*`); } else { list(#separ=" ", #elems=`*[@pid]`); } " "; } // Adjective // element Adjective { // attribute nr { xsd:integer }, // attribute value { xsd:boolean }?, // ( attribute absnr { xsd:integer }, // attribute aid { xsd:string } )?, // attribute kind { "V" }?, // attribute pid { xsd:integer }?, // Term* // } tpl [Adjective](#i) { $pi = { patt_info(#k="V", #nr=`@nr`, #pid =`@pid`); } $fnr = car(#l = $pi); $anto = cadr(#l = $pi); $plink = third(#l = $pi); $pid = { if [$plink="1"] { `@pid`; } else { "0";} } $neg = { if [@value="false"] { `($anto + 1) mod 2`; } else { `$anto mod 2`; }} if [$neg="1"] { copy-of $non_s; } pp(#k="V",#nr=`@nr`,#args=`*`,#pid=`@pid`,#i=$i); // abs(#k="V", #nr=`@nr`,#sym=abs1(#k="V", #nr=`@nr`, #fnr=$fnr, #pid=$pid), #pid = $pid); } // // File: print_complex.xsltxt - html-ization of Mizar XML, more complex printing stuff // // Author: Josef Urban // // License: GPL (GNU GENERAL PUBLIC LICENSE) // ##TODO: try some unification of mkref and absref // // theorem, definition and scheme references // add the reference's href, $c tells if it is from current article // $nm passes the explicit text to be displayed tpl mkref(#aid, #nr, #k, #c, #nm) { $mk = { refkind(#kind = $k); } $alc = { lc(#s = $aid); } 0)] { "N"; } else { ""; } } for-each [$elems] { $mk0 = mkind(#kind = `@kind`); $mk = { if [($pid > 0)] { `concat($mk0, "not")`; } else { $mk0; } } $alc = lc(#s=`@aid`); 0] { `@kind`; } else { $mk; } } @title=`concat(@aid, ":", $n1, $t1, ".", @nr)`; } if [$sym] { $sym; } else { if [$relnames > 0] { $n1; `@kind`; `@relnr`; } else { $n1; `@kind`; `@nr`; "_"; `@aid`; } } } } } // look up and link the constructor/pattern with kind #k and #nr; // #sym is optionally forces the given Mizar symbol // #pid links to patterns instead of constructors // note that we can be inside a Notation document here already (see pp), // so the $doc = "" test does not have to mean that we are inside // the article (could be probably fixed in pp, don't know about expnadable modes though) tpl abs(#k, #nr, #sym, #pid) { if [$pid>0] { $k1 = `concat('P_',$k)`; $doc = { if [key($k1,$nr)[$pid=@relnr]] { ""; } else { $patts; } } for-each [document($doc,/)] { $c1 = { if [(name(/*) = "Article") and ($mml = "0")] { "1"; } else { "0"; } } absref(#elems = `key($k1,$nr)[$pid=@relnr]`, #c = $c1, #sym = $sym, #pid = $pid); } } else { $doc = { if [key($k,$nr)] { ""; } else { $constrs; } } for-each [document($doc,/)] { $c1 = { if [(name(/*) = "Article") and ($mml = "0")] { "1"; } else { "0"; } } absref(#elems = `key($k,$nr)`, #c = $c1, #sym = $sym); } } } // pretty printer - gets arguments, visibility info from pattern, // format telling arities, the linked symbol and optionally right bracket // parenth hints to put the whole expression in parentheses, but this // is overrriden if the expression uses functor brackets // #loci tells to print loci instead of arguments // #i is the bound var nbr tpl pp(#k, #nr, #args, #parenth, #pid, #loci, #i) { $pkey = `concat('P_',$k)`; // pattern number given if [$pid>0] { $doc = { if [key($pkey,$nr)[$pid=@relnr]] { ""; } else { $patts; } } for-each [document($doc,/)] { if [key($pkey,$nr)[$pid=@relnr]] { for-each [key($pkey,$nr)[$pid=@relnr]] { $npid = { if [@redefnr>0] { $pid; } } // $vis = { if [$k = "V"] { `Visible/Int[position() < last()]`; } else { `Visible/Int`; } } if [$k = "V"] { pp1(#k = $k, #nr = $nr, #args = $args, #vis = `Visible/Int[position() < last()]`, #fnr = `@formatnr`, #parenth = $parenth, #loci = $loci, #pid = $npid, #i = $i); } else { pp1(#k = $k, #nr = $nr, #args = $args, #vis = `Visible/Int`, #fnr = `@formatnr`, #parenth = $parenth, #loci = $loci, #pid = $npid, #i = $i); } } } // failure, print in absolute notation else { abs(#k = $k, #nr = $nr); "("; list(#separ = ",", #elems = $args); ")"; } } } // pattern number not given - take first suitable else { $doc = { if [key($pkey,$nr)] { ""; } else { $patts; } } for-each [document($doc,/)] { if [key($pkey,$nr)] { for-each [key($pkey,$nr)[position()=1]] { $npid = { if [@redefnr>0] { `@relnr`; } } // $vis = { if [$k = "V"] { `Visible/Int[position() < last()]`; } else { `Visible/Int`; } } if [$k = "V"] { pp1(#k = $k, #nr = $nr, #args = $args, #vis = `Visible/Int[position() < last()]`, #fnr = `@formatnr`, #parenth = $parenth, #loci = $loci, #pid = $npid, #i = $i); } else { pp1(#k = $k, #nr = $nr, #args = $args, #vis = `Visible/Int`, #fnr = `@formatnr`, #parenth = $parenth, #loci = $loci, #pid = $npid, #i = $i); } } } // failure, print in absolute notation else { abs(#k = $k, #nr = $nr); "("; list(#separ = ",", #elems = $args); ")"; } } } } // it is legal to pass only #loci instead of #args here // #pid is passed to abs, causes linking to patterns // #i is the bound var nbr tpl pp1(#k,#nr,#args,#vis,#fnr,#parenth,#loci,#pid,#i) { $la = { if [($k='M') or ($k='G') or ($k='L')] { "0"; } else { for-each [document($formats,/)] { for-each [key('F',$fnr)] { choose { when [@kind="V"] { `@argnr - 1`;} when [@leftargnr] { `@leftargnr`;} otherwise { "0";} } }}} } // try if right bracket - returns '' if not $rsym = { if [($k='K') and ($la='0')] { abs1(#k=$k, #nr=$nr, #fnr=$fnr, #r="1"); } } $np = { if [not($vis) or ($k='G')] { "0"; } else { if [$parenth>0] { $parenth; } else { if [not($rsym='')] { "1"; } else { "0";} } } } $paren_color = `$np mod $pcolors_nr`; // print spanned paranthesis or left bracket if [($parenspans = 1) and ($np > 0)] { 0)] { if [$rsym=''] { "("; } else { abs(#k=$k, #nr=$nr, #sym=abs1(#k=$k, #nr=$nr, #fnr=$fnr), #pid=$pid); } } pp2(#k = $k, #nr = $nr, #i = $i, #vis = $vis, #la = $la, #loci = $loci, #args = $args, #np = $np, #rsym = $rsym, #parenth = $parenth, #fnr = $fnr, #pid = $pid); if[($np > 0)] { if [$rsym=''] { ")"; } else { abs(#k=$k, #nr=$nr, #sym=$rsym, #pid=$pid); } } } } tpl pp2(#k, #nr, #i, #vis, #la, #loci, #args, #np, #rsym, #parenth, #fnr, #pid) { $visnr = `count($vis)`; $dofuncbrackets = { if [($rsym='') and ($mizar_brackets > 0) and ($k = "K")] { "1"; } else { "0"; } } if [($dofuncbrackets>0) and ($la>1)] { "("; } // print left args for-each [$vis] { if [position() <= $la] { $x=`@x`; if [$loci>0] { if [$loci="2"] { ppconst(#nr=$x,#vid=`$args[position()=$x]/@vid`); } else { ploci(#nr=$x); } } else { apply[$args[position() = $x]](#p=$np,#i=$i); } if [position() < $la] { ",";} } } if [($dofuncbrackets>0) and ($la>1)] { ")"; } // print symbol if [$rsym=''] { // only consider printing space if $parenth was not printed or there were left args // there were left arg(s), and $dofuncbrackets>0 (we are inside a functor), the left arg(s) will have brackets // then if $funcs_no_spaces>0 don't do the space if [not($parenth>0) or ($la>0)] { // do not print space if either: // opening parenth was printed and no left args exist // or // $la>1 and we do func brackets (that means a closing bracket of args was printed) // or $la=1 and the left arg got its own parenth (this si implied by $parenth>0) if [not(($k='K') and ($parenth>0) and ($la=0)) and not(($funcs_no_spaces>0) and ($dofuncbrackets>0) and ($la>0))] {" "; } } abs(#k=$k, #nr=$nr, #sym=abs1(#k=$k, #nr=$nr, #fnr=$fnr), #pid=$pid); if [$k='G'] { "(#"; } // do not print space if either: // closing parenth will be printed and no right args exist // or // $ra>1 and we do func brackets (that means an opening bracket of args will be printed) if [not(($k='K') and ($parenth>0) and (($visnr - $la)=0)) and not(($funcs_no_spaces>0) and ($dofuncbrackets>0) and (($visnr - $la)>0))] {" "; } } if [($dofuncbrackets>0) and (($visnr - $la)>1)] { "("; } // print right args preceded by "of" for types for-each [$vis] { if [(position() = 1)] { if[($k='M')] { "of "; } else { if [($k='L')] { "over "; } } } if [position() > $la] { $x=`@x`; if [$loci>0] { if [$loci="2"] { ppconst(#nr=$x,#vid=`$args[position()=$x]/@vid`); } else { ploci(#nr=$x); } } else { apply[$args[position() = $x]](#p=$np,#i=$i); } if [position() < last()] { ",";} } } if [$k='G'] { " #)"; } if [($dofuncbrackets>0) and (($visnr - $la)>1)] { ")"; } } // theorem, definition and scheme references tpl getref(#k, #anr, #nr) { if [$anr>0] { $refdoc = { if [$k="S"] { $schms; } else { $thms; } } for-each [document($refdoc,/)] { for-each [key($k,concat($anr,':',$nr))[position()=1]] { mkref(#aid = `@aid`, #nr = $nr, #k = $k); } } } else { mkref(#aid = $aname, #nr = $nr, #k = $k, #c = "1"); } } // find the constant with #nr on level #pl or higher, // and pretty print it // now assumes that proof levels are available, which is only through // addabsrefs preprocessing tpl absconst(#nr,#pl) { if [key("C",$pl)[@nr = $nr]] { for-each [key("C",$pl)[@nr = $nr]] { ppconst(#nr = $nr, #vid = `Typ[position() = 1]/@vid`); } } else { if [key("C",$pl)[@nr < $nr]] { for-each [key("C",$pl)[@nr < $nr]] { if [position() = last()] { $n1 = getcnr(#el = `.`); $lastnr = `@nr + $n1 - 1`; $n2 = `@nr`; if [$lastnr >= $nr] { ppconst(#nr = $nr, #vid = `Typ[position() = ($nr - $n2 + 1)]/@vid`); } else { $dbgmsg; } } } } else { $ls = `string-length($pl)`; if [$ls>0] { $pl1 = { get_parent_level(#pl = $pl, #ls = $ls, #n = "1"); } absconst(#nr = $nr, #pl = $pl1); } else { $dbgmsg; } } } } // // File: reasoning.xsltxt - html-ization of Mizar XML, code for reasoning items // // Author: Josef Urban // // License: GPL (GNU GENERAL PUBLIC LICENSE) tpl [Proposition] { if [$proof_links>0] {0] { if [($proof_links>0) and ($print_lab_identifiers = 0) and not(string-length(@plevel)>0)] { plab1(#nr=`@nr`,#txt="Lemma"); } else { pplab(#nr=`@nr`, #vid = `@vid`); } ": "; } // ###TODO: include the possible link when generating items if [($generate_items>0) and not(string-length(@plevel)>0)] { if [name(..) = "SchemeBlock"] { apply; " "; } else { if [not(name(..) = "SchemePremises")] { pcomment(#str = `concat($aname, ":lemma ", @propnr)`); } apply; " "; if [($generate_items_proofs>0) and (following-sibling::*[1][(name()="By") or (name()="From") or (name()="Proof")])] { apply[`following-sibling::*[1]`]; } } } // we can only say that this is a lemma if it is a toplevel proposition // nontoplevel could be assumptions, etc. - this is a ##TODO else { if [not(string-length(@plevel)>0)] { 0] { $byurl = { choose { when [$linkby=1] { `concat($lbydir,$anamelc,"/",$line,"_",$col,".html")`; } when [$linkby=2] { `concat($lbydlicgipref,$anamelc,"/",$line,"_",$col,".dli")`; } when [$linkby=3] { `concat($lbytptpcgi,"?article=",$anamelc,"&lc=",$line,"_",$col,"&tmp=",$lbytmpdir,$lbycgiparams)`; } } } 0] { add_ajax_attrs(#u=$byurl); } else { @href=$byurl; @class="txt"; if[$linkbytoself > 0] {@target="_self"; } else {@target="byATP";} } if [$by_titles>0] { @title=mk_by_title(#line=$line,#col=$col); } pkeyword(#str=$by); " "; } if[$ajax_by > 0] { 0)] { linkbyif(#line = `@line`, #col = `@col`,#by = "by"); 0] { linkbyif(#line = `@line`, #col = `@col`,#by = ";"); } else { ";"; } } if [not($nbr = "1")] { 0)] { linkbyif(#line=`@line`,#col=`@col`,#by="by"); 0 tpl top_propname(#el) { for-each [$el/..] { if [(name() = "DefTheorem") or (name() = "JustifiedTheorem")] { $k = { if [@kind='D'] { "Def"; } else { "Th"; } } $nm = { if [($print_lab_identifiers > 0) and ($el/@vid > 0)] { get_vid_name(#vid = `$el/@vid`); } else { `concat($k,@nr)`; } } mkref(#aid = $aname, #nr = `@nr`, #k = `@kind`, #c = "1", #nm = $nm); } else { $k1 = `concat($el/@nr,":")`; $k2 = `key("E",$k1)/@propnr`; 0) and ($el/@vid > 0)] { pplab(#nr = `$el/@nr`, #vid = `$el/@vid`); } else { plab1(#nr = `$el/@nr`, #txt = "Lemma"); } } } } } // name of private reference - name of the proposition tpl privname(#nr,#pl) { $k1 = `concat($nr,":",$pl)`; if [key("E",$k1)] { for-each [key("E",$k1)] { if [not(string-length($pl)>0)] { top_propname(#el = `.`); } else { $txt= { propname(#n = `@propnr`, #pl = $pl); } 0] { $pl1 = { get_parent_level(#pl=$pl,#ls=$ls,#n="1"); } privname(#nr=$nr,#pl=$pl1); } } } // count local constants introduced in the current element - // this asssumes Let | Given | TakeAsVar | Consider | Set | Reconsider tpl getcnr(#el) { `count($el/Typ)`; } // relies on addabsrefs preprocessing tpl get_nearest_level(#el) { for-each [$el] { if [@newlevel] { `@newlevel`; } else { get_nearest_level(#el=`..`); } } } tpl [Ref] { if [not(@articlenr)] { if [$proof_links = 0] { // experimental!! $n1 = `@nr`; $vid = { if [@vid] { `@vid`; } else { if [$print_lab_identifiers > 0] // makes things faster if not, cause this is expensive { // for-each [preceding::*[((name()="Proposition") or (name()="Now") or (name()="IterEquality")) and (@nr=$n1)][1]] // this seems to be reasonably fast for-each [(preceding::Proposition[@nr=$n1]|preceding::Now[@nr=$n1] |preceding::IterEquality[@nr=$n1])[last()]] { `@vid`; } } else { "0"; } } } pplab(#nr = $n1, #vid= $vid); } else { $pl = get_nearest_level(#el = `..`); privname(#nr = `@nr`, #pl = $pl); } } else { getref(#k = `@kind`, #anr = `@articlenr`, #nr = `@nr`); } } tpl [ErrorInf](#nbr) { "errorinference;"; if [not($nbr="1")] { 0] { pplab(#nr = `@nr`, #vid = `@vid`); ": ";} apply[*[1]]; " = "; nlist(#separ=".= ", #elems=`IterStep`); ";"; if [not($nbr="1")] { 0] { $addpl = { addp(#pl=`@plevel`); } 0] { $addpl = { addp(#pl=`@plevel`); } 1] { pkeyword(#str="that "); 1)]`); ";"; try_th_exps(); 0] { $addpl = { addp(#pl=`@plevel`); } 1] { pkeyword(#str=" such that "); 1]`); } apply[*[2]]; } // First comes the series of target types and reconsidered terms. // For all these terms a new local variable with its target type // is created, and its equality to the corresponding term is remembered. // Finally the proposition about the typing is given and justified. // For easier presentation, atNr optionally contains the number // of the first local constant created here. // Each type may optionally have presentational info about // the variable (atVid) inside. // element elReconsider { // attribute atNr { xsd:integer }?, // (elTyp, Term)+, // elProposition, Justification // } tpl [Reconsider] { $j=`@nr`; if [By[@linked="true"]] { pkeyword(#str="then "); } pkeyword(#str="reconsider "); $addpl = { if [$const_links>0] { addp(#pl=`@plevel`); } } // should work both for old and new reconsider for-each [*[(not(name() = "Typ")) and (position() < (last() - 1))]] { $p1 = `position()`; $nr1 = `$j + $p1 - 1`; if [$const_links>0] {0] { $addpl = { addp(#pl=`@plevel`); } 1] { pkeyword(#str="that "); } andlist(#elems = `*`); ";"; // this will break the thesis display in diffuse statements // for earlier kernel (analyzer v. < 1.94) - mea culpa, // the only reasonable backward-compatibility fix would be to // keep the kernel version as a parameter and check it here try_th_exps(); 1]]; // thesis after per cases is broken yet and would have // to be reconstructed from subblocks' theses; // don't display it, only display the expansions try_th_exps(#nd="1"); } // // File: block_top.xsltxt - html-ization of Mizar XML, code for bloc and top elements // // Author: Josef Urban // // License: GPL (GNU GENERAL PUBLIC LICENSE) // Registrations tpl [RCluster] { if [Presentation/RCluster] { apply [Presentation/RCluster]; } else { $nr1 = `@nr`; if [$generate_items>0] { // rc(); // $bogus=`1`; } else {
0)] { apply[ArgTypes]; } $nr1 = `@nr`; 0] { // cc(); // $bogus=`1`; } else {
0)] { apply[ArgTypes]; } $nr1 = `@nr`; 0] { // fc(); // $bogus=`1`; } else {
0)] { apply[ArgTypes]; } $nr1 = `@nr`; 0] { // iy(); // $bogus=`1`; } else {
0)] { argtypes(#el=`Typ`); } $nr1 = `@nr`; 0)] { if [$iname = 'Identify'] { apply[Func[1]]; pkeyword(#str=" with "); apply[Func[2]]; } else { apply[*[position() = last() - 1]]; pkeyword(#str=" with "); apply[*[position() = last()]]; } } else // try nice display from the compatibility formula { for-each [following-sibling::*[1]/Proposition/*[1]] { if [name() = "Pred"] // equality - terms { apply[*[1]]; pkeyword(#str=" with "); apply[*[2]]; } else { if [name() = "And"] // equivalence - predicates { $e1= is_equiv(#el=`.`); if [$e1="1"] { apply[*[1]/*[1]/*[1]]; pkeyword(#str=" with "); apply[*[1]/*[1]/*[2]/*[1]]; } else { "IDENTIFY DISPLAY FAILED - PLEASE COMPLAIN!"; 0] { // reduce(); // $bogus=`1`; } else {
0)] { argtypes(#el=`Typ`); } $nr1 = `@nr`; 0)] { apply[*[position() = last() - 1]]; pkeyword(#str=" to "); apply[*[position() = last()]]; } else // try nice display from the compatibility formula { for-each [following-sibling::*[1]/Proposition/*[1]] { if [name() = "Pred"] // equality - terms { apply[*[1]]; pkeyword(#str=" with "); apply[*[2]]; } else { "REDUCE DISPLAY FAILED - PLEASE COMPLAIN!"; 0] { $prevline = `$line - 1`; for-each [document($cmt,/)] { for-each [key('CMT',$prevline)] { apply[.]; } } } } // http://en.wikipedia.org/wiki/Cantor_Theorem to // http://dbpedia.org/resource/Cantor_theorem tpl wp2dp(#txt) { `concat("http://dbpedia.org/resource/",substring-after($txt,'/wiki/'))`; } tpl add_dbpedia(#line) { if[$mk_comments > 0] { $prevline = `$line - 1`; for-each [document($cmt,/)] { for-each [key('CMT',$prevline)] { for-each [CmtLink/a] { $dbplink = wp2dp(#txt=`@href`); 0] { // jt(); // $bogus=`1`; } else { // optional interestingness rating produced by external soft if [@interesting > 0] { // scale red and blue from 0% (green) to 100% (white) $intensity = `(1 - @interesting) * 100`;
0) and ($print_lab_identifiers = 0)] { plab1(#nr=$nr1,#txt="Th"); ": "; } else { for-each [Proposition[@nr > 0]] { pplab(#nr=`@nr`, #vid=`@vid`); ": "; } } 0] { " interestingness: "; `@interesting`; } if [$idv > 0] { idv_for_item(#k="t", #nr=$nr1); } if [$wiki_sections = 1] { $endpos = { if [Proof] { `Proof[1]/EndPosition[1]/@line`; } else { if [By|From] { `*[2]/@line`; } else { "0"; } }} if [$endpos > 0] { " "; wiki_edit_section_for(#k="t", #nr=$nr1, #line1=`Proposition[1]/@line`, #line2=$endpos); } } if [$thms_tptp_links = 1] { tptp_for_thm(#line=`Proposition[1]/@line`, #col=`Proposition[1]/@col`); " "; add_ar_iconif(#line=`Proposition[1]/@line`, #col=`Proposition[1]/@col`); " "; edit_for_thm(#line=`Proposition[1]/@line`, #col=`Proposition[1]/@col`); } 0) or ($generate_items_proofs>0)] { apply[*[2]]; } } else {
0] { $byurl = { choose { when [$linkby=1] { `concat($lbydir,$anamelc,"/",$line,"_",$col,".html")`; } when [$linkby=2] { `concat($lbydlicgipref,$anamelc,"/",$line,"_",$col,".dli")`; } when [$linkby=3] { `concat($lbytptpcgi,"?article=",$anamelc,"&lc=",$line,"_",$col,"&tmp=",$lbytmpdir,$lbycgiparams)`; } } } 0] { add_ajax_attrs(#u=$byurl); } else { @href=$byurl; @class="txt"; if[$linkbytoself > 0] {@target="_self"; } else {@target="byATP";} } $txt = { mk_by_title(#line=$line,#col=$col); } if [$by_titles>0] { @title=mk_by_title(#line=$line,#col=$col); } 0] { @title = $txt; } } " "; } if[$ajax_by > 0] { // $bogus=`1`; // $section; // // 0] { // dt(); // $bogus=`1`; } else {
0) and ($print_lab_identifiers = 0)] { plab1(#nr = $nr1, #txt = "Def"); } else { for-each [Proposition[@nr > 0]] { pplab(#nr = `@nr`, #vid = `@vid`); } } " "; // 2]]; } // Formula | ( elProposition, Justification ) tpl [UnknownCorrCond|Coherence|Compatibility|Consistency|Existence|Reducibility|Uniqueness] { 1] { apply[*[position()>1]]; } else { ";"; 0] { // sd(); // $bogus=`1`; } else {
0) and ($print_lab_identifiers = 0)] { plab1(#nr = `@schemenr`, #txt = "Sch"); } else { pplab(#nr = `@schemenr`, #vid = `@vid`, #txt = "Sch"); } "{ "; list(#separ=", ", #elems=`SchemeFuncDecl|SchemePredDecl`); " } :"; 0)] { apply[*[position() = last() - 1]]; } } } // ( ( CorrectnessCondition*, elCorrectness?, // elJustifiedProperty*, elConstructor?, elPattern? ) // | ( elConstructor, elConstructor, elConstructor+, // elRegistration, CorrectnessCondition*, // elCorrectness?, elPattern+ )) // ##TODO: commented registration and strict attr for defstruct tpl [Definition] { add_comments(#line=`@line`); if [@expandable = "true"] { $argtypes = `../Let/Typ`; $loci = { if [($mml="1") or ($generate_items>0)] { "1"; } else { "2"; }} for-each [Pattern] { 0)] { $cnt1 = `1 + count(preceding-sibling::Definition[@nr])`; $defnr = `../following-sibling::Definiens[position() = $cnt1]/@defnr`; // dfs(); // $bogus = `1`; } else { if [@nr] {
0)] { "0"; } else { "1"; } } apply[Constructor](#indef = $indef1, #nl = $nl, #argt = $argtypes); } // @nr is present iff Definiens is present; it can be 0 if // the deiniens is not labeled, otherwise it is the proposition number // of its deftheorem if [@nr] { $nr1 = `@nr`; $vid = `@vid`; $cnt1 = `1 + count(preceding-sibling::Definition[@nr])`; $cnstr = `count(Constructor)`; if [($generate_items > 0)] { // Definiens is better than Constructor for loci display, // since Constructor may be missing for redefinitions. for-each [../following-sibling::Definiens[position() = $cnt1]] { argtypes(#el=`Typ`); } } apply[Constructor](#indef = "1", #nl = $nl, #argt = $argtypes); for-each [../following-sibling::Definiens[position() = $cnt1]] { $ckind = `@constrkind`; $cnr = `@constrnr`; if [$cnstr = 0] { // here the redefined constructor is retrieved from definiens pkeyword(#str="redefine "); $doc = { if [key($ckind, $cnr)] { ""; } else { $constrs; } } for-each [document($doc, /)] { apply[key($ckind, $cnr)](#indef = "1", #nl = $nl, #argt = $argtypes, #nrt= "1",#old="1"); } } if [DefMeaning/@kind = 'e'] { pkeyword(#str=" equals "); } else { pkeyword(#str=" means "); } if [$nr1 > 0] { ":"; if [($proof_links > 0) and ($print_lab_identifiers = 0)] { plab1(#nr = `@defnr`, #txt = "Def"); } else { pplab(#nr = $nr1, #vid = $vid); } ": "; } 0] { @title=`@newlevel`; } pkeyword(#str="case "); } apply[Case];
0] { @title=`@newlevel`; } pkeyword(#str="suppose "); } apply[Suppose];
0] { @title=`@newlevel`; } pkeyword(#str="per "); } apply[PerCases];
0] { @title=`@newlevel`; } pkeyword(#str="proof "); } // add_ar_iconif(#line=`EndPosition[1]/@line`, #col=`EndPosition[1]/@col`);
0)] { 0] { @title=`@newlevel`; } pkeyword(#str="proof "); } // add_ar_iconif(#line=`EndPosition[1]/@line`, #col=`EndPosition[1]/@col`); if [$ajax_proofs>0] {
$bogus=`1`; } else {
0] { pplab(#nr=`@nr`, #vid=`@vid`); ": ";} 0] { @title=`@newlevel`; } pkeyword(#str="now "); if [($display_thesis = 1)] { for-each [ BlockThesis] { " "; 0)] { pcomment0(#str=`concat($aname, " semantic presentation")`); } if [$idv > 0] { idv_for_top(); } } 0)] { "1"; } else { "2"; }} if [not($indef="1")] { apply[ArgTypes]; } if [@redefnr>0] { pcomment0(#str = "original: "); abs(#k=`@kind`,#nr=`@redefnr`,#sym=abs1(#k=`@kind`, #nr=`@redefnr`)); apply[`.`]; // $bogus=`1`; } } else { if [$body_only = "0"] { 0] { $aname; ": "; for-each [document($hdr,/)/Header/dc:title] { `text()`; } } else { $aname; }}