aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/strap/SYMBOL.lsp
blob: 298cb4951b548a5ebdead48019fa95a6f964dea0 (plain)
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
(/VERSIONCHECK 2) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Thing| |%Shell|) |%Void|)
                |SYMBOL;writeOMSym|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%String|)
                |SYMBOL;OMwrite;$S;2|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Boolean| |%Shell|) |%String|)
                |SYMBOL;OMwrite;$BS;3|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Thing| |%Shell|) |%Void|)
                |SYMBOL;OMwrite;Omd$V;4|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Thing| |%Boolean| |%Shell|)
                    |%Void|)
                |SYMBOL;OMwrite;Omd$BV;5|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Thing|)
                |SYMBOL;convert;$If;6|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Thing|)
                |SYMBOL;convert;2$;7|)) 

(PUT '|SYMBOL;convert;2$;7| '|SPADreplace| '(XLAM (|s|) |s|)) 

(DECLAIM (FTYPE (FUNCTION (|%String| |%Shell|) |%Thing|)
                |SYMBOL;coerce;S$;8|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Thing| |%Shell|) |%Boolean|)
                |SYMBOL;=;2$B;9|)) 

(PUT '|SYMBOL;=;2$B;9| '|SPADreplace| '|%equal|) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Thing| |%Shell|) |%Boolean|)
                |SYMBOL;<;2$B;10|)) 

(PUT '|SYMBOL;<;2$B;10| '|SPADreplace| '|%before?|) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Thing|)
                |SYMBOL;coerce;$Of;11|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%List| |%Shell|) |%Thing|)
                |SYMBOL;subscript;$L$;12|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%List| |%Shell|) |%Thing|)
                |SYMBOL;elt;$L$;13|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%List| |%Shell|) |%Thing|)
                |SYMBOL;superscript;$L$;14|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%List| |%Shell|) |%Thing|)
                |SYMBOL;argscript;$L$;15|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Thing| |%Thing| |%Shell|)
                    |%Thing|)
                |SYMBOL;patternMatch;$P2Pmr;16|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Thing| |%Thing| |%Shell|)
                    |%Thing|)
                |SYMBOL;patternMatch;$P2Pmr;17|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Thing|)
                |SYMBOL;convert;$P;18|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Thing|)
                |SYMBOL;convert;$P;19|)) 

(DECLAIM (FTYPE (FUNCTION (|%Shell| |%Shell|) |%String|)
                |SYMBOL;syprefix|)) 

(DECLAIM (FTYPE (FUNCTION (|%Shell| |%Shell|) |%List|)
                |SYMBOL;syscripts|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%List| |%Shell|) |%Thing|)
                |SYMBOL;script;$L$;22|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell| |%Shell|) |%Thing|)
                |SYMBOL;script;$R$;23|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%String|)
                |SYMBOL;string;$S;24|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%String|)
                |SYMBOL;latex;$S;25|)) 

(DECLAIM (FTYPE (FUNCTION (|%Integer| |%String| |%Shell|) |%String|)
                |SYMBOL;anyRadix|)) 

(DECLAIM (FTYPE (FUNCTION (|%Shell|) |%Thing|) |SYMBOL;new;$;27|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Thing|)
                |SYMBOL;new;2$;28|)) 

(DECLAIM (FTYPE (FUNCTION (|%Shell|) |%Void|) |SYMBOL;resetNew;V;29|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Boolean|)
                |SYMBOL;scripted?;$B;30|)) 

(PUT '|SYMBOL;scripted?;$B;30| '|SPADreplace| '|%pair?|) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Thing|)
                |SYMBOL;name;2$;31|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Shell|)
                |SYMBOL;scripts;$R;32|)) 

(DECLAIM (FTYPE (FUNCTION (|%Integer| |%Shell|) |%String|)
                |SYMBOL;istring|)) 

(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%List|)
                |SYMBOL;list;$L;34|)) 

(DECLAIM (FTYPE (FUNCTION (|%Shell|) |%Thing|) |SYMBOL;sample;$;35|)) 

(PUT '|SYMBOL;sample;$;35| '|SPADreplace| '(XLAM NIL '|aSymbol|)) 

(DEFUN |SYMBOL;writeOMSym| (|dev| |x| $)
  (COND
    ((CONSP |x|)
     (|error| "Cannot convert a scripted symbol to OpenMath"))
    (T (SPADCALL |dev| |x| (|shellEntry| $ 27))))) 

(DEFUN |SYMBOL;OMwrite;$S;2| (|x| $)
  (LET* ((|s| "") (|sp| (OM-STRINGTOSTRINGPTR |s|))
         (|dev| (SPADCALL |sp| (SPADCALL (|shellEntry| $ 29))
                    (|shellEntry| $ 30))))
    (SEQ (SPADCALL |dev| (|shellEntry| $ 31))
         (|SYMBOL;writeOMSym| |dev| |x| $)
         (SPADCALL |dev| (|shellEntry| $ 32))
         (SPADCALL |dev| (|shellEntry| $ 33))
         (SETQ |s| (OM-STRINGPTRTOSTRING |sp|)) (EXIT |s|)))) 

(DEFUN |SYMBOL;OMwrite;$BS;3| (|x| |wholeObj| $)
  (LET* ((|s| "") (|sp| (OM-STRINGTOSTRINGPTR |s|))
         (|dev| (SPADCALL |sp| (SPADCALL (|shellEntry| $ 29))
                    (|shellEntry| $ 30))))
    (SEQ (COND (|wholeObj| (SPADCALL |dev| (|shellEntry| $ 31))))
         (|SYMBOL;writeOMSym| |dev| |x| $)
         (COND (|wholeObj| (SPADCALL |dev| (|shellEntry| $ 32))))
         (SPADCALL |dev| (|shellEntry| $ 33))
         (SETQ |s| (OM-STRINGPTRTOSTRING |sp|)) (EXIT |s|)))) 

(DEFUN |SYMBOL;OMwrite;Omd$V;4| (|dev| |x| $)
  (SEQ (SPADCALL |dev| (|shellEntry| $ 31))
       (|SYMBOL;writeOMSym| |dev| |x| $)
       (EXIT (SPADCALL |dev| (|shellEntry| $ 32))))) 

(DEFUN |SYMBOL;OMwrite;Omd$BV;5| (|dev| |x| |wholeObj| $)
  (SEQ (COND (|wholeObj| (SPADCALL |dev| (|shellEntry| $ 31))))
       (|SYMBOL;writeOMSym| |dev| |x| $)
       (EXIT (COND (|wholeObj| (SPADCALL |dev| (|shellEntry| $ 32))))))) 

(DEFUN |SYMBOL;convert;$If;6| (|s| $)
  (SPADCALL |s| (|shellEntry| $ 47))) 

(DEFUN |SYMBOL;convert;2$;7| (|s| $) (DECLARE (IGNORE $)) |s|) 

(DEFUN |SYMBOL;coerce;S$;8| (|s| $) (VALUES (INTERN |s|))) 

(DEFUN |SYMBOL;=;2$B;9| (|x| |y| $)
  (DECLARE (IGNORE $))
  (EQUAL |x| |y|)) 

(DEFUN |SYMBOL;<;2$B;10| (|x| |y| $)
  (DECLARE (IGNORE $))
  (GGREATERP |y| |x|)) 

(DEFUN |SYMBOL;coerce;$Of;11| (|x| $)
  (SPADCALL |x| (|shellEntry| $ 54))) 

(DEFUN |SYMBOL;subscript;$L$;12| (|sy| |lx| $)
  (|SYMBOL;script;$L$;22| |sy| (LIST |lx| NIL NIL NIL NIL) $)) 

(DEFUN |SYMBOL;elt;$L$;13| (|sy| |lx| $)
  (|SYMBOL;subscript;$L$;12| |sy| |lx| $)) 

(DEFUN |SYMBOL;superscript;$L$;14| (|sy| |lx| $)
  (|SYMBOL;script;$L$;22| |sy| (LIST NIL |lx| NIL NIL NIL) $)) 

(DEFUN |SYMBOL;argscript;$L$;15| (|sy| |lx| $)
  (|SYMBOL;script;$L$;22| |sy| (LIST NIL NIL NIL NIL |lx|) $)) 

(DEFUN |SYMBOL;patternMatch;$P2Pmr;16| (|x| |p| |l| $)
  (SPADCALL |x| |p| |l| (|shellEntry| $ 67))) 

(DEFUN |SYMBOL;patternMatch;$P2Pmr;17| (|x| |p| |l| $)
  (SPADCALL |x| |p| |l| (|shellEntry| $ 74))) 

(DEFUN |SYMBOL;convert;$P;18| (|x| $)
  (SPADCALL |x| (|shellEntry| $ 77))) 

(DEFUN |SYMBOL;convert;$P;19| (|x| $)
  (SPADCALL |x| (|shellEntry| $ 79))) 

(DEFUN |SYMBOL;syprefix| (|sc| $)
  (LET ((|ns| (LIST (LIST-LENGTH (SVREF |sc| 3))
                    (LIST-LENGTH (SVREF |sc| 2))
                    (LIST-LENGTH (SVREF |sc| 1))
                    (LIST-LENGTH (SVREF |sc| 0)))))
    (SEQ (LOOP
           (COND
             ((NOT (COND
                     ((NOT (< (LIST-LENGTH |ns|) 2))
                      (ZEROP (|SPADfirst| |ns|)))
                     (T NIL)))
              (RETURN NIL))
             (T (SETQ |ns| (CDR |ns|)))))
         (EXIT (SPADCALL
                   (CONS (STRCONC (SVREF $ 38)
                                  (|SYMBOL;istring|
                                      (LIST-LENGTH (SVREF |sc| 4)) $))
                         (LET ((#0=#:G1524 (NREVERSE |ns|))
                               (#1=#:G1523 NIL))
                           (LOOP
                             (COND
                               ((ATOM #0#) (RETURN (NREVERSE #1#)))
                               (T (LET ((|n| (CAR #0#)))
                                    (SETQ #1#
                                     (CONS (|SYMBOL;istring| |n| $)
                                      #1#)))))
                             (SETQ #0# (CDR #0#)))))
                   (|shellEntry| $ 93)))))) 

(DEFUN |SYMBOL;syscripts| (|sc| $)
  (LET ((|all| (SVREF |sc| 3)))
    (SEQ (SETQ |all|
               (SPADCALL (SVREF |sc| 2) |all| (|shellEntry| $ 94)))
         (SETQ |all|
               (SPADCALL (SVREF |sc| 1) |all| (|shellEntry| $ 94)))
         (SETQ |all|
               (SPADCALL (SVREF |sc| 0) |all| (|shellEntry| $ 94)))
         (EXIT (SPADCALL |all| (SVREF |sc| 4) (|shellEntry| $ 94)))))) 

(DEFUN |SYMBOL;script;$L$;22| (|sy| |ls| $)
  (LET ((|sc| (VECTOR NIL NIL NIL NIL NIL)))
    (SEQ (COND
           ((NOT (NULL |ls|))
            (SEQ (SETF (SVREF |sc| 0) (|SPADfirst| |ls|))
                 (EXIT (SETQ |ls| (CDR |ls|))))))
         (COND
           ((NOT (NULL |ls|))
            (SEQ (SETF (SVREF |sc| 1) (|SPADfirst| |ls|))
                 (EXIT (SETQ |ls| (CDR |ls|))))))
         (COND
           ((NOT (NULL |ls|))
            (SEQ (SETF (SVREF |sc| 2) (|SPADfirst| |ls|))
                 (EXIT (SETQ |ls| (CDR |ls|))))))
         (COND
           ((NOT (NULL |ls|))
            (SEQ (SETF (SVREF |sc| 3) (|SPADfirst| |ls|))
                 (EXIT (SETQ |ls| (CDR |ls|))))))
         (COND
           ((NOT (NULL |ls|))
            (SEQ (SETF (SVREF |sc| 4) (|SPADfirst| |ls|))
                 (EXIT (SETQ |ls| (CDR |ls|))))))
         (EXIT (|SYMBOL;script;$R$;23| |sy| |sc| $))))) 

(DEFUN |SYMBOL;script;$R$;23| (|sy| |sc| $)
  (COND
    ((CONSP |sy|) (|error| "Cannot add scripts to a scripted symbol"))
    (T (CONS (|SYMBOL;coerce;$Of;11|
                 (|SYMBOL;coerce;S$;8|
                     (STRCONC (|SYMBOL;syprefix| |sc| $)
                              (|SYMBOL;string;$S;24|
                                  (|SYMBOL;name;2$;31| |sy| $) $))
                     $)
                 $)
             (|SYMBOL;syscripts| |sc| $))))) 

(DEFUN |SYMBOL;string;$S;24| (|e| $)
  (COND
    ((NOT (CONSP |e|)) (PNAME |e|))
    (T (|error| "Cannot form string from non-atomic symbols.")))) 

(DEFUN |SYMBOL;latex;$S;25| (|e| $)
  (PROG (|ss| |lo| |sc|)
    (RETURN
      (LET ((|s| (PNAME (|SYMBOL;name;2$;31| |e| $))))
        (SEQ (COND
               ((AND (< 1 (LENGTH |s|))
                     (SPADCALL (SPADCALL |s| 1 (|shellEntry| $ 106))
                         (SPADCALL "\\" (|shellEntry| $ 43))
                         (|shellEntry| $ 107)))
                (SETQ |s| (STRCONC "\\mbox{\\it " (STRCONC |s| "}")))))
             (COND ((NOT (CONSP |e|)) (EXIT |s|)))
             (LETT |ss| (|SYMBOL;scripts;$R;32| |e| $)
                   |SYMBOL;latex;$S;25|)
             (LETT |lo| (SVREF |ss| 0) |SYMBOL;latex;$S;25|)
             (COND
               ((NOT (NULL |lo|))
                (SEQ (LETT |sc| "_{" |SYMBOL;latex;$S;25|)
                     (LOOP
                       (COND
                         ((NOT (NOT (NULL |lo|))) (RETURN NIL))
                         (T (SEQ (SETQ |sc|
                                       (STRCONC |sc|
                                        (SPADCALL (|SPADfirst| |lo|)
                                         (|shellEntry| $ 112))))
                                 (SETQ |lo| (CDR |lo|))
                                 (EXIT (COND
                                         ((NOT (NULL |lo|))
                                          (SETQ |sc|
                                           (STRCONC |sc| ", ")))))))))
                     (SETQ |sc| (STRCONC |sc| "}"))
                     (EXIT (SETQ |s| (STRCONC |s| |sc|))))))
             (SETQ |lo| (SVREF |ss| 1))
             (COND
               ((NOT (NULL |lo|))
                (SEQ (LETT |sc| "^{" |SYMBOL;latex;$S;25|)
                     (LOOP
                       (COND
                         ((NOT (NOT (NULL |lo|))) (RETURN NIL))
                         (T (SEQ (SETQ |sc|
                                       (STRCONC |sc|
                                        (SPADCALL (|SPADfirst| |lo|)
                                         (|shellEntry| $ 112))))
                                 (SETQ |lo| (CDR |lo|))
                                 (EXIT (COND
                                         ((NOT (NULL |lo|))
                                          (SETQ |sc|
                                           (STRCONC |sc| ", ")))))))))
                     (SETQ |sc| (STRCONC |sc| "}"))
                     (EXIT (SETQ |s| (STRCONC |s| |sc|))))))
             (SETQ |lo| (SVREF |ss| 2))
             (COND
               ((NOT (NULL |lo|))
                (SEQ (LETT |sc| "{}^{" |SYMBOL;latex;$S;25|)
                     (LOOP
                       (COND
                         ((NOT (NOT (NULL |lo|))) (RETURN NIL))
                         (T (SEQ (SETQ |sc|
                                       (STRCONC |sc|
                                        (SPADCALL (|SPADfirst| |lo|)
                                         (|shellEntry| $ 112))))
                                 (SETQ |lo| (CDR |lo|))
                                 (EXIT (COND
                                         ((NOT (NULL |lo|))
                                          (SETQ |sc|
                                           (STRCONC |sc| ", ")))))))))
                     (SETQ |sc| (STRCONC |sc| "}"))
                     (EXIT (SETQ |s| (STRCONC |sc| |s|))))))
             (SETQ |lo| (SVREF |ss| 3))
             (COND
               ((NOT (NULL |lo|))
                (SEQ (LETT |sc| "{}_{" |SYMBOL;latex;$S;25|)
                     (LOOP
                       (COND
                         ((NOT (NOT (NULL |lo|))) (RETURN NIL))
                         (T (SEQ (SETQ |sc|
                                       (STRCONC |sc|
                                        (SPADCALL (|SPADfirst| |lo|)
                                         (|shellEntry| $ 112))))
                                 (SETQ |lo| (CDR |lo|))
                                 (EXIT (COND
                                         ((NOT (NULL |lo|))
                                          (SETQ |sc|
                                           (STRCONC |sc| ", ")))))))))
                     (SETQ |sc| (STRCONC |sc| "}"))
                     (EXIT (SETQ |s| (STRCONC |sc| |s|))))))
             (SETQ |lo| (SVREF |ss| 4))
             (COND
               ((NOT (NULL |lo|))
                (SEQ (LETT |sc| "\\left( {" |SYMBOL;latex;$S;25|)
                     (LOOP
                       (COND
                         ((NOT (NOT (NULL |lo|))) (RETURN NIL))
                         (T (SEQ (SETQ |sc|
                                       (STRCONC |sc|
                                        (SPADCALL (|SPADfirst| |lo|)
                                         (|shellEntry| $ 112))))
                                 (SETQ |lo| (CDR |lo|))
                                 (EXIT (COND
                                         ((NOT (NULL |lo|))
                                          (SETQ |sc|
                                           (STRCONC |sc| ", ")))))))))
                     (SETQ |sc| (STRCONC |sc| "} \\right)"))
                     (EXIT (SETQ |s| (STRCONC |s| |sc|))))))
             (EXIT |s|)))))) 

(DEFUN |SYMBOL;anyRadix| (|n| |s| $)
  (PROG (|qr|)
    (RETURN
      (LET ((|ns| ""))
        (LOOP
          (COND
            (NIL (RETURN NIL))
            (T (SEQ (LETT |qr|
                          (MULTIPLE-VALUE-CALL #'CONS
                              (TRUNCATE |n| (LENGTH |s|)))
                          |SYMBOL;anyRadix|)
                    (SETQ |n| (CAR |qr|))
                    (SETQ |ns|
                          (SPADCALL
                              (SPADCALL |s|
                                  (+ (CDR |qr|)
                                     (SPADCALL |s|
                                      (|shellEntry| $ 117)))
                                  (|shellEntry| $ 106))
                              |ns| (|shellEntry| $ 119)))
                    (EXIT (COND
                            ((ZEROP |n|)
                             (RETURN-FROM |SYMBOL;anyRadix| |ns|)))))))))))) 

(DEFUN |SYMBOL;new;$;27| ($)
  (LET ((|sym| (|SYMBOL;anyRadix|
                   (SPADCALL (SVREF $ 10) (|shellEntry| $ 120))
                   (SVREF $ 20) $)))
    (SEQ (SPADCALL (SVREF $ 10)
             (+ (SPADCALL (SVREF $ 10) (|shellEntry| $ 120)) 1)
             (|shellEntry| $ 121))
         (EXIT (|SYMBOL;coerce;S$;8| (STRCONC "%" |sym|) $))))) 

(DEFUN |SYMBOL;new;2$;28| (|x| $)
  (PROG (|u| |n| |xx|)
    (RETURN
      (SEQ (LETT |n|
                 (SEQ (LETT |u|
                            (SPADCALL |x| (SVREF $ 13)
                                (|shellEntry| $ 124))
                            |SYMBOL;new;2$;28|)
                      (EXIT (COND
                              ((EQL (CAR |u|) 1) 0)
                              (T (+ (CDR |u|) 1)))))
                 |SYMBOL;new;2$;28|)
           (SPADCALL (SVREF $ 13) |x| |n| (|shellEntry| $ 127))
           (LETT |xx|
                 (COND
                   ((NOT (CONSP |x|)) (|SYMBOL;string;$S;24| |x| $))
                   (T (|SYMBOL;string;$S;24|
                          (|SYMBOL;name;2$;31| |x| $) $)))
                 |SYMBOL;new;2$;28|)
           (SETQ |xx| (STRCONC "%" |xx|))
           (SETQ |xx|
                 (COND
                   ((NOT (< (SPADCALL
                                (SPADCALL |xx|
                                    (SPADCALL |xx|
                                     (|shellEntry| $ 128))
                                    (|shellEntry| $ 106))
                                (SVREF $ 19) (|shellEntry| $ 129))
                            (SPADCALL (SVREF $ 19)
                                (|shellEntry| $ 117))))
                    (STRCONC |xx|
                             (|SYMBOL;anyRadix| |n| (SVREF $ 21) $)))
                   (T (STRCONC |xx|
                               (|SYMBOL;anyRadix| |n| (SVREF $ 19) $)))))
           (COND
             ((NOT (CONSP |x|)) (EXIT (|SYMBOL;coerce;S$;8| |xx| $))))
           (EXIT (|SYMBOL;script;$R$;23| (|SYMBOL;coerce;S$;8| |xx| $)
                     (|SYMBOL;scripts;$R;32| |x| $) $)))))) 

(DEFUN |SYMBOL;resetNew;V;29| ($)
  (SEQ (SPADCALL (SVREF $ 10) 0 (|shellEntry| $ 121))
       (EXIT (LET ((#0=#:G1525
                       (SPADCALL (SVREF $ 13) (|shellEntry| $ 133))))
               (LOOP
                 (COND
                   ((ATOM #0#) (RETURN NIL))
                   (T (LET ((|k| (CAR #0#)))
                        (SPADCALL |k| (SVREF $ 13)
                            (|shellEntry| $ 134)))))
                 (SETQ #0# (CDR #0#))))))) 

(DEFUN |SYMBOL;scripted?;$B;30| (|sy| $)
  (DECLARE (IGNORE $))
  (CONSP |sy|)) 

(DEFUN |SYMBOL;name;2$;31| (|sy| $)
  (COND
    ((NOT (CONSP |sy|)) |sy|)
    (T (LET ((|str| (|SYMBOL;string;$S;24|
                        (SPADCALL (|SYMBOL;list;$L;34| |sy| $)
                            (|shellEntry| $ 137))
                        $)))
         (SEQ (LET ((|i| (+ (SVREF $ 41) 1))
                    (#0=#:G1526 (LENGTH |str|)))
                (LOOP
                  (COND
                    ((> |i| #0#) (RETURN NIL))
                    (T (COND
                         ((NOT (SPADCALL
                                   (SPADCALL |str| |i|
                                    (|shellEntry| $ 106))
                                   (|shellEntry| $ 139)))
                          (RETURN-FROM |SYMBOL;name;2$;31|
                            (|SYMBOL;coerce;S$;8|
                                (SPADCALL |str|
                                    (SPADCALL |i| (LENGTH |str|)
                                     (|shellEntry| $ 141))
                                    (|shellEntry| $ 142))
                                $))))))
                  (SETQ |i| (+ |i| 1))))
              (EXIT (|error| "Improper scripted symbol"))))))) 

(DEFUN |SYMBOL;scripts;$R;32| (|sy| $)
  (PROG (|allscripts|)
    (RETURN
      (COND
        ((NOT (CONSP |sy|)) (VECTOR NIL NIL NIL NIL NIL))
        (T (LET* ((|nscripts| '(0 0 0 0 0))
                  (|lscripts| (LIST NIL NIL NIL NIL NIL))
                  (|str| (|SYMBOL;string;$S;24|
                             (SPADCALL (|SYMBOL;list;$L;34| |sy| $)
                                 (|shellEntry| $ 137))
                             $))
                  (|nstr| (LENGTH |str|))
                  (|m| (SPADCALL |nscripts| (|shellEntry| $ 144))))
             (SEQ (LET ((|i| |m|) (|j| (+ (SVREF $ 41) 1)))
                    (LOOP
                      (COND
                        ((OR (> |j| |nstr|)
                             (NOT (SPADCALL
                                      (SPADCALL |str| |j|
                                       (|shellEntry| $ 106))
                                      (|shellEntry| $ 139))))
                         (RETURN NIL))
                        (T (SPADCALL |nscripts| |i|
                               (LET ((#0=#:G1517
                                      (-
                                       (SPADCALL
                                        (SPADCALL |str| |j|
                                         (|shellEntry| $ 106))
                                        (|shellEntry| $ 44))
                                       (SVREF $ 45))))
                                 (|check-subtype| (NOT (MINUSP #0#))
                                     '(|NonNegativeInteger|) #0#))
                               (|shellEntry| $ 148))))
                      (SETQ |i| (+ |i| 1))
                      (SETQ |j| (+ |j| 1))))
                  (SETQ |nscripts|
                        (SPADCALL (CDR |nscripts|)
                            (|SPADfirst| |nscripts|)
                            (|shellEntry| $ 151)))
                  (LETT |allscripts| (CDR (|SYMBOL;list;$L;34| |sy| $))
                        |SYMBOL;scripts;$R;32|)
                  (SETQ |m| (SPADCALL |lscripts| (|shellEntry| $ 153)))
                  (LET ((|i| |m|) (#1=#:G1527 |nscripts|))
                    (LOOP
                      (COND
                        ((ATOM #1#) (RETURN NIL))
                        (T (LET ((|n| (CAR #1#)))
                             (COND
                               ((< (LIST-LENGTH |allscripts|) |n|)
                                (|error| "Improper script count in symbol"))
                               (T (SEQ (SPADCALL |lscripts| |i|
                                        (LET
                                         ((#2=#:G1529
                                           (SPADCALL |allscripts| |n|
                                            (|shellEntry| $ 156)))
                                          (#3=#:G1528 NIL))
                                          (LOOP
                                            (COND
                                              ((ATOM #2#)
                                               (RETURN (NREVERSE #3#)))
                                              (T
                                               (LET ((|a| (CAR #2#)))
                                                 (SETQ #3#
                                                  (CONS
                                                   (|SYMBOL;coerce;$Of;11|
                                                    |a| $)
                                                   #3#)))))
                                            (SETQ #2# (CDR #2#))))
                                        (|shellEntry| $ 157))
                                       (EXIT
                                        (SETQ |allscripts|
                                         (SPADCALL |allscripts| |n|
                                          (|shellEntry| $ 158))))))))))
                      (SETQ |i| (+ |i| 1))
                      (SETQ #1# (CDR #1#))))
                  (EXIT (VECTOR (SPADCALL |lscripts| |m|
                                    (|shellEntry| $ 159))
                                (SPADCALL |lscripts| (+ |m| 1)
                                    (|shellEntry| $ 159))
                                (SPADCALL |lscripts| (+ |m| 2)
                                    (|shellEntry| $ 159))
                                (SPADCALL |lscripts| (+ |m| 3)
                                    (|shellEntry| $ 159))
                                (SPADCALL |lscripts| (+ |m| 4)
                                    (|shellEntry| $ 159))))))))))) 

(DEFUN |SYMBOL;istring| (|n| $)
  (COND
    ((< 9 |n|) (|error| "Can have at most 9 scripts of each kind"))
    (T (|getSimpleArrayEntry| (SVREF $ 18) |n|)))) 

(DEFUN |SYMBOL;list;$L;34| (|sy| $)
  (COND
    ((NOT (CONSP |sy|))
     (|error| "Cannot convert a symbol to a list if it is not subscripted"))
    (T |sy|))) 

(DEFUN |SYMBOL;sample;$;35| ($) (DECLARE (IGNORE $)) '|aSymbol|) 

(DEFUN |Symbol| ()
  (DECLARE (SPECIAL |$ConstructorCache|))
  (LET ((#0=#:G1531 (HGET |$ConstructorCache| '|Symbol|)))
    (COND
      (#0# (|CDRwithIncrement| (CDAR #0#)))
      (T (UNWIND-PROTECT
           (PROG1 (CDDAR (HPUT |$ConstructorCache| '|Symbol|
                               (LIST (CONS NIL (CONS 1 (|Symbol;|))))))
             (SETQ #0# T))
           (COND ((NOT #0#) (HREM |$ConstructorCache| '|Symbol|)))))))) 

(DEFUN |Symbol;| ()
  (DECLARE (SPECIAL |$ConstructorCache|))
  (LET ((|dv$| '(|Symbol|)) ($ (|newShell| 165))
        (|pv$| (|buildPredVector| 0 0 NIL)))
    (SETF (|shellEntry| $ 0) |dv$|)
    (SETF (|shellEntry| $ 3) |pv$|)
    (|haddProp| |$ConstructorCache| '|Symbol| NIL (CONS 1 $))
    (|stuffDomainSlots| $)
    (SETF (|shellEntry| $ 10) (SPADCALL 0 (|shellEntry| $ 9)))
    (SETF (|shellEntry| $ 13) (SPADCALL (|shellEntry| $ 12)))
    (SETF (|shellEntry| $ 18)
          (SPADCALL '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")
              (|shellEntry| $ 17)))
    (SETF (|shellEntry| $ 19) "0123456789")
    (SETF (|shellEntry| $ 20) "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    (SETF (|shellEntry| $ 21) "abcdefghijklmnopqrstuvwxyz")
    (SETF (|shellEntry| $ 38) "*")
    (SETF (|shellEntry| $ 41) (LENGTH (SVREF $ 38)))
    (SETF (|shellEntry| $ 45)
          (SPADCALL (SPADCALL "0" (|shellEntry| $ 43))
              (|shellEntry| $ 44)))
    $)) 

(MAKEPROP '|Symbol| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|Integer|) (0 . |Zero|)
             (|Reference| 6) (4 . |ref|) '|count|
             (|AssociationList| $$ 6) (9 . |empty|) '|xcount|
             (|String|) (|List| 14) (|PrimitiveArray| 14)
             (13 . |construct|) '|istrings| '|nums| 'ALPHAS '|alphas|
             (|Boolean|) |SYMBOL;scripted?;$B;30| (|Void|) (|Symbol|)
             (|OpenMathDevice|) (18 . |OMputVariable|)
             (|OpenMathEncoding|) (24 . |OMencodingXML|)
             (28 . |OMopenString|) (34 . |OMputObject|)
             (39 . |OMputEndObject|) (44 . |OMclose|)
             |SYMBOL;OMwrite;$S;2| |SYMBOL;OMwrite;$BS;3|
             |SYMBOL;OMwrite;Omd$V;4| |SYMBOL;OMwrite;Omd$BV;5| '|hd|
             (|NonNegativeInteger|) (49 . |#|) '|lhd| (|Character|)
             (54 . |char|) (59 . |ord|) '|ord0| (|InputForm|)
             (64 . |convert|) |SYMBOL;convert;$If;6|
             |SYMBOL;convert;2$;7| |SYMBOL;coerce;S$;8|
             |SYMBOL;=;2$B;9| |SYMBOL;<;2$B;10| (|OutputForm|)
             (69 . |outputForm|) |SYMBOL;coerce;$Of;11| (|List| 53)
             (74 . |nil|) (|List| 56) |SYMBOL;script;$L$;22|
             |SYMBOL;subscript;$L$;12| |SYMBOL;elt;$L$;13|
             |SYMBOL;superscript;$L$;14| |SYMBOL;argscript;$L$;15|
             (|PatternMatchResult| 6 25) (|Pattern| 6)
             (|PatternMatchSymbol| 6) (78 . |patternMatch|)
             (|PatternMatchResult| 6 $) |SYMBOL;patternMatch;$P2Pmr;16|
             (|Float|) (|PatternMatchResult| 70 25) (|Pattern| 70)
             (|PatternMatchSymbol| 70) (85 . |patternMatch|)
             (|PatternMatchResult| 70 $)
             |SYMBOL;patternMatch;$P2Pmr;17| (92 . |coerce|)
             |SYMBOL;convert;$P;18| (97 . |coerce|)
             |SYMBOL;convert;$P;19| (102 . |#|) (|List| 6) (107 . |#|)
             (112 . >=) (118 . |first|) (123 . |zero?|) (128 . |false|)
             (132 . |rest|) (137 . |concat|) (143 . |reverse!|)
             (148 . |concat|) (|List| $) (154 . |concat|)
             (159 . |concat|) (165 . |null|) (170 . |first|)
             (175 . |rest|)
             (|Record| (|:| |sub| 56) (|:| |sup| 56) (|:| |presup| 56)
                 (|:| |presub| 56) (|:| |args| 56))
             |SYMBOL;script;$R$;23| |SYMBOL;name;2$;31|
             |SYMBOL;string;$S;24| (180 . |concat|) (186 . |One|)
             (190 . >) (196 . |One|) (200 . |elt|) (206 . ~=)
             |SYMBOL;scripts;$R;32| (212 . |empty?|) (217 . |not|)
             (222 . |first|) (227 . |latex|) (232 . |rest|)
             |SYMBOL;latex;$S;25|
             (|Record| (|:| |quotient| $) (|:| |remainder| $))
             (237 . |divide|) (243 . |minIndex|) (248 . +)
             (254 . |concat|) (260 . |elt|) (265 . |setelt|)
             |SYMBOL;new;$;27| (|Union| 6 '"failed") (271 . |search|)
             (277 . |Zero|) (281 . |inc|) (286 . |setelt|)
             (293 . |maxIndex|) (298 . |position|) (304 . >=)
             |SYMBOL;new;2$;28| (|List| $$) (310 . |keys|)
             (315 . |remove!|) |SYMBOL;resetNew;V;29|
             |SYMBOL;list;$L;34| (321 . |first|) (326 . +)
             (332 . |digit?|) (|UniversalSegment| 6) (337 . SEGMENT)
             (343 . |elt|) (|List| 39) (349 . |minIndex|)
             (|PositiveInteger|) (354 . |One|) (358 . -)
             (364 . |setelt|) (371 . |rest|) (376 . |first|)
             (381 . |concat|) (387 . |rest|) (392 . |minIndex|)
             (397 . |#|) (402 . <) (408 . |first|) (414 . |setelt|)
             (421 . |rest|) (427 . |elt|) (433 . >) (439 . |minIndex|)
             (444 . |elt|)
             (CONS IDENTITY
                   (FUNCALL (|dispatchFunction| |SYMBOL;sample;$;35|)
                            $))
             (|SingleInteger|))
          '#(~= 450 |superscript| 456 |subscript| 462 |string| 468
             |scripts| 473 |scripted?| 478 |script| 483 |sample| 495
             |resetNew| 499 |patternMatch| 503 |new| 517 |name| 526
             |min| 531 |max| 537 |list| 543 |latex| 548 |hash| 553
             |elt| 558 |convert| 564 |coerce| 584 |before?| 594
             |argscript| 600 |OMwrite| 606 >= 630 > 636 = 642 <= 648 <
             654)
          'NIL
          (CONS (|makeByteWordVec2| 1 '(0 0 0 0 0 0 0 0 0 0 0 0 0 0))
                (CONS '#(NIL NIL NIL |SetCategory&| |OrderedType&|
                         |BasicType&| NIL NIL NIL NIL NIL NIL NIL NIL)
                      (CONS '#((|OrderedSet|) (|PatternMatchable| 70)
                               (|PatternMatchable| 6) (|SetCategory|)
                               (|OrderedType|) (|BasicType|)
                               (|ConvertibleTo| 72)
                               (|ConvertibleTo| 65)
                               (|CoercibleFrom| 14)
                               (|ConvertibleTo| 25) (|OpenMath|)
                               (|ConvertibleTo| 46) (|Type|)
                               (|CoercibleTo| 53))
                            (|makeByteWordVec2| 164
                                '(0 6 0 7 1 8 0 6 9 0 11 0 12 1 16 0 15
                                  17 2 26 24 0 25 27 0 28 0 29 2 26 0
                                  14 28 30 1 26 24 0 31 1 26 24 0 32 1
                                  26 24 0 33 1 14 39 0 40 1 42 0 14 43
                                  1 42 39 0 44 1 46 0 25 47 1 53 0 25
                                  54 0 56 0 57 3 66 64 25 65 64 67 3 73
                                  71 25 72 71 74 1 72 0 25 77 1 65 0 25
                                  79 1 56 39 0 81 1 82 39 0 83 2 39 22
                                  0 0 84 1 82 6 0 85 1 6 22 0 86 0 22 0
                                  87 1 82 0 0 88 2 14 0 0 0 89 1 82 0 0
                                  90 2 15 0 14 0 91 1 14 0 92 93 2 56 0
                                  0 0 94 1 58 22 0 95 1 58 56 0 96 1 58
                                  0 0 97 2 56 0 53 0 102 0 39 0 103 2
                                  39 22 0 0 104 0 6 0 105 2 14 42 0 6
                                  106 2 42 22 0 0 107 1 56 22 0 109 1
                                  22 0 0 110 1 56 53 0 111 1 53 14 0
                                  112 1 56 0 0 113 2 6 115 0 0 116 1 14
                                  6 0 117 2 6 0 0 0 118 2 14 0 42 0 119
                                  1 8 6 0 120 2 8 6 0 6 121 2 11 123 2
                                  0 124 0 39 0 125 1 6 0 0 126 3 11 6 0
                                  2 6 127 1 14 6 0 128 2 14 6 42 0 129
                                  2 6 22 0 0 130 1 11 132 0 133 2 11
                                  123 2 0 134 1 132 2 0 137 2 39 0 0 0
                                  138 1 42 22 0 139 2 140 0 6 6 141 2
                                  14 0 0 140 142 1 143 6 0 144 0 145 0
                                  146 2 6 0 0 0 147 3 143 39 0 6 39 148
                                  1 143 0 0 149 1 143 39 0 150 2 143 0
                                  0 39 151 1 132 0 0 152 1 58 6 0 153 1
                                  132 39 0 154 2 39 22 0 0 155 2 132 0
                                  0 39 156 3 58 56 0 6 56 157 2 132 0 0
                                  39 158 2 58 56 0 6 159 2 6 22 0 0 160
                                  1 16 6 0 161 2 16 14 0 6 162 2 0 22 0
                                  0 1 2 0 0 0 56 62 2 0 0 0 56 60 1 0
                                  14 0 101 1 0 98 0 108 1 0 22 0 23 2 0
                                  0 0 58 59 2 0 0 0 98 99 0 0 0 163 0 0
                                  24 135 3 0 75 0 72 75 76 3 0 68 0 65
                                  68 69 1 0 0 0 131 0 0 0 122 1 0 0 0
                                  100 2 0 0 0 0 1 2 0 0 0 0 1 1 0 92 0
                                  136 1 0 14 0 114 1 0 164 0 1 2 0 0 0
                                  56 61 1 0 65 0 80 1 0 72 0 78 1 0 25
                                  0 49 1 0 46 0 48 1 0 0 14 50 1 0 53 0
                                  55 2 0 22 0 0 1 2 0 0 0 56 63 2 0 24
                                  26 0 36 3 0 24 26 0 22 37 1 0 14 0 34
                                  2 0 14 0 22 35 2 0 22 0 0 1 2 0 22 0
                                  0 1 2 0 22 0 0 51 2 0 22 0 0 1 2 0 22
                                  0 0 52)))))
          '|lookupComplete|)) 

(MAKEPROP '|Symbol| 'NILADIC T)