/
miz.xsltxt
4782 lines (4146 loc) · 130 KB
/
miz.xsltxt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 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/<!\-\- *\(<\/*xsl:document.*\) *\-\->/\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"; }
// tells if ajax-able clicking requests (like proofs) are
// executed already on mouseover; default is on, but this
// will only work of $ajax_proofs>0
#ajax_tooltips = { "1"; }
// the dir with proofs that are fetched through AJAX
#ajax_proof_dir = { "proofs"; }
// tells to display thesis after skeleton items
#display_thesis = { "1"; }
// tooltips wherever the corresponding hide/show functions apply
#hs_tooltips= { "1"; }
#hs2_tooltips= { "1"; }
// tooltips for references
#ref_tooltips= { "1"; }
// tells if only selected items are generated to subdirs; default is off
#generate_items = { "0"; }
// put ajax for references (theorems, defs, schems) to $ajax_refs_dir
// seems to be wanted in the same situations as $ajax_proofs, so it is linked to them
#mk_ajax_refs = { $ajax_proofs; }
// the dir with refs that can be fetched by AJAX
#ajax_refs_dir = { "refs"; }
// 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"; }
// include environ info from .evl file
#mk_environ = { "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')`; }
// .evl file with environ info
#evl = { `concat($anamelc, '.evl')`; }
#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 = { ")"; }
#top_proof_end = { "end;"; }
// the javascript that we are so reluctant to outsource
#mizjs1 = {
"
function hs(obj)
{
// document.getElementById('myimage').nextSibling.style.display = 'block';
if (obj.nextSibling.style.display == 'inline')
{ obj.nextSibling.style.display = 'none'; }
else { if (obj.nextSibling.style.display == 'none')
{ obj.nextSibling.style.display = 'inline'; }
else { obj.nextSibling.style.display = 'inline'; }}
return false;
}
function hs2(obj)
{
if (obj.nextSibling.style.display == 'block')
{ obj.nextSibling.style.display = 'none'; }
else { if (obj.nextSibling.style.display == 'none')
{ obj.nextSibling.style.display = 'block'; }
else { obj.nextSibling.style.display = 'none'; }}
return false;
}
function hsNdiv(obj)
{
var ndiv = obj;
while (ndiv.nextSibling.nodeName != 'DIV') { ndiv = ndiv.nextSibling; }
return hs2(ndiv);
}
// remote request cache - for each url its http_request.responseText
var rrCache= {};
rrCache[0]='';
// explorer7 implements XMLHttpRequest in some strange way
// optional tooltip is passed to insertRequest
function makeRequest(obj,url,tooltip)
{
// if the result is cached, insert it now
if (rrCache[url] != null)
{
insertRequest(obj,null,url,tooltip);
}
else
{
var http_request = false;
if (window.XMLHttpRequest && !(window.ActiveXObject)) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
http_request = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = function() { insertRequest(obj,http_request,url,tooltip); };
http_request.open('GET', url, true);
http_request.send(null);
}
}
// commented the 200 state to have local requests too
// if tooltip nonnil, obj.innerHTML is changed, and the result is put in rrCache
function insertRequest(obj,http_request,url,tooltip)
{
var respText = null;
if(http_request == null) // no request done, we are called with cached result
{
respText = rrCache[url];
}
else { if (http_request.readyState == 4) {
respText = http_request.responseText;
}}
if (respText != null)
{
// if (http_request.status == 200) {
if(http_request != null) {rrCache[url] = respText;}
if(tooltip != null)
{
obj.innerHTML = respText;
}
else
{
var ndiv = obj;
while (ndiv.nodeName != 'SPAN') { ndiv = ndiv.nextSibling; }
ndiv.innerHTML = respText;
obj.onclick = function(){ return hs2(obj) };
}
}
}
// simple tooltips
var tooltip=function(){
var id = 'tt';
var top = 3;
var left = 3;
var maxw = 500;
var speed = 10;
var timer = 2;
var endalpha = 95;
var alpha = 0;
var tt,t,c,b,h;
var ie = document.all ? true : false;
return{
show:function(how,v,w){
if(tt == null){
tt = document.createElement('div');
tt.setAttribute('id',id);
document.body.appendChild(tt);
tt.style.opacity = 0;
tt.style.filter = 'alpha(opacity=0)';
document.onmousemove = this.pos;
}
tt.style.display = 'block';
if(how == 'url')
{
if(rrCache[v]==null) {
tt.innerHTML ='<div>loading...</div>';
makeRequest(tt,v,1);
} else {
tt.innerHTML = rrCache[v];
}
}
else { if ((how == 'hs') || (how == 'hs2')) { tt.innerHTML = v.nextSibling.innerHTML; }
else { if (how == 'txt') { tt.innerHTML = v; }
else { tt.innerHTML = ''; }
}
}
tt.style.width = w ? w + 'px' : 'auto';
if(!w && ie){
tt.style.width = tt.offsetWidth;
}
if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
h = parseInt(tt.offsetHeight) + top;
clearInterval(tt.timer);
tt.timer = setInterval(function(){tooltip.fade(1)},timer);
},
pos:function(e){
var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
tt.style.top = (u - h) + 'px';
tt.style.left = (l + left) + 'px';
},
fade:function(d){
var a = alpha;
if((a != endalpha && d == 1) || (a != 0 && d == -1)){
var i = speed;
if(endalpha - a < speed && d == 1){
i = endalpha - a;
}else if(alpha < speed && d == -1){
i = a;
}
alpha = a + (i * d);
tt.style.opacity = alpha * .01;
tt.style.filter = 'alpha(opacity=' + alpha + ')';
}else{
clearInterval(tt.timer);
if(d == -1){tt.style.display = 'none'}
}
},
hide:function(){tt.style.display = 'none';}
};
}();
// reference show/hide - shortened because frequent, just a wrapper to tooltip.show/hide
function rs(ref) { tooltip.show('url', mizhtm + 'refs/' + ref); }
function rh() { tooltip.hide(); }
// End -->
"; }
//
// 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"]
{
<font
{
@color = $varcolor;
if [$titles="1"] { @title=`concat("b",$nr)`; }
$nm;
}
}
else
{
$nm;
}
}
else
{
pvar(#nr = $nr);
}
}
tpl pvar(#nr) { if [$colored="1"] { <font { @color=$varcolor;
"b"; <sub { $nr;} } } else { "b"; <sub { $nr;} } }
tpl pconst(#nr) { if [$colored="1"] { <font { @color=$constcolor;
"c"; <sub { $nr;} } } else { "c"; <sub { $nr;} } }
// #pl gives the optional proof level
tpl ppconst(#nr, #vid, #pl)
{
if [($print_identifiers > 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
{
<a
{
@class = "txt";
@href = `concat("#",$ctarget)`;
<font
{
@color = $constcolor;
if [$titles="1"] { @title = $ctarget; }
$nm;
}
}
}
else { if [$colored = "1"]
{
<font
{
@color = $constcolor;
if [$titles="1"] { @title = $ctarget; }
$nm;
}
}
else { $nm;} }
}
else { pconst(#nr = $nr); }
}
tpl pploci(#nr)
{
if [($print_identifiers > 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"] { <font { @color=$locicolor;
"a"; <sub { $nr;} } } else { "a"; <sub { $nr;} } }
tpl pschpvar(#nr) { if [$colored="1"] { <font { @color=$schpcolor;
"P"; <sub { $nr;} } } else { "P"; <sub { $nr;} } }
tpl pschfvar(#nr) { if [$colored="1"] { <font { @color=$schfcolor;
"F"; <sub { $nr;} } } else { "F"; <sub { $nr;} } }
tpl pppred(#nr) { if [$colored="1"] { <font { @color=$ppcolor;
"S"; <sub { $nr;} } } else { "S"; <sub { $nr;} } }
tpl ppfunc(#nr) { if [$colored="1"] { <font { @color=$pfcolor;
"H"; <sub { $nr;} } } else { "H"; <sub { $nr;} } }
tpl pplab(#nr, #vid, #txt)
{
if [($print_lab_identifiers > 0) and ($vid > 0)]
{
$nm = { get_vid_name(#vid = $vid); }
<span
{
@class="lab";
if [$colored = "1"]
{
<font
{
@color = $labcolor;
if [$titles="1"] { @title=`concat("E",$nr)`; }
$nm;
}
}
else { $nm;}
}
}
else
{
if [$txt]
{
plab1(#nr = $nr, #txt = $txt);
}
else { plab(#nr = $nr); }
}
}
tpl plab(#nr)
{
<span
{
@class="lab";
if [$colored="1"] { <font { @color=$labcolor; "E"; $nr;} }
else { "E"; $nr;}
}
}
tpl plab1(#nr,#txt)
{
<span
{
@class="lab";
if [$colored="1"] { <font { @color=$labcolor; $txt; $nr;} }
else { $txt; $nr;}
}
}
tpl pkeyword(#str) { <span { @class = "kw"; $str; } }
tpl pcomment0(#str) { <span { @class="comment"; if [$colored="1"] {
<font {@color=$commentcolor; ":: "; $str;}} else { ":: "; $str;}}}
tpl pcomment(#str) { pcomment0(#str=$str); <br;}
// this assumes comments with :: already
tpl pcommentedblock(#str)
{
<div { @class="comment mathjax";
if [$colored="1"] {
<font {@color=$commentcolor; br(#text=$str);}
}
else { br(#text=$str); }
}
}
// argument list
tpl arglist(#separ,#elems)
{
for-each [$elems]
{
ploci(#nr = `position()`);
if [not(position() = last())] { $separ; }
}
}
// translate newlines to <br;
tpl br(#text) {
choose {
when [contains($text,'
')] {
`substring-before($text,'
')`;
<br;
br(#text = `substring-after($text,'
')`);
}
otherwise { $text; }
}
}
// like jlist, but with loci
tpl alist(#j, #sep1, #sep2, #elems)
{
for-each [$elems]
{
apply[.];
if [not(position() = last())]
{
$sep1;
ploci(#nr = `$j+position()`);
$sep2;
}
}
}
//
// File: utils.xsltxt - html-ization of Mizar XML, various utility functions
//
// Author: Josef Urban
//
// License: GPL (GNU GENERAL PUBLIC LICENSE)
#pid_Ex = { "-1"; } // usually NegFrmPtr
#pid_Ex_Univ = { "-2"; } // usually UnivFrmPtr
#pid_Ex_InnerNot = { "-3"; } // usually NegFrmPtr
#pid_Impl = { "-4"; } // usually NegFrmPtr
#pid_Impl_And = { "-5"; } // usually ConjFrmPtr
#pid_Impl_RightNot = { "-6"; } // usually NegFrmPtr
#pid_Iff = { "-7"; } // usually ConjFrmPtr
#pid_Or = { "-8"; } // usually NegFrmPtr
#pid_Or_And = { "-9"; } // usually ConjFrmPtr
#pid_Or_LeftNot = { "-10"; } // usually NegFrmPtr
#pid_Or_RightNot = { "-11"; } // usually NegFrmPtr
// means that "not" will not be used
tpl is_positive(#el) { for-each [$el] {
if [(name()="Not")] {
if [Pred[(@kind='V') or (@kind='R')]] {
$pi = { patt_info(#k=`*[1]/@kind`, #nr=`*[1]/@nr`, #pid =`*[1]/@pid`); }
$antonym = cadr(#l=$pi);
`$antonym mod 2`; }
else { "0"; }
}
else {
if [(name()="Pred") and ((@kind='V') or (@kind='R'))] {
$pi = { patt_info(#k=`@kind`, #nr=`@nr`, #pid =`@pid`); }
$antonym = cadr(#l=$pi);
`($antonym + 1) mod 2`;
}
else { "1"; }}}}
tpl is_negative(#el) { $pos = { is_positive(#el=$el); } `1 - $pos`;}
tpl count_positive(#els,#nr) {
if [$nr > 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"; }}}