
(/VERSIONCHECK 2) 

(DEFUN |MMLFORM;coerce;OfS;1| (|expr| $)
  (PROG (|s|)
    (RETURN
     (SEQ
      (LETT |s|
            (|MMLFORM;postcondition|
             (|MMLFORM;formatMml| (|MMLFORM;precondition| |expr| $)
              (QREFELT $ 8) $)
             $)
            |MMLFORM;coerce;OfS;1|)
      (EXIT |s|))))) 

(DEFUN |MMLFORM;coerceS;OfS;2| (|expr| $)
  (PROG (|s|)
    (RETURN
     (SEQ
      (LETT |s|
            (|MMLFORM;postcondition|
             (|MMLFORM;formatMml| (|MMLFORM;precondition| |expr| $)
              (QREFELT $ 8) $)
             $)
            |MMLFORM;coerceS;OfS;2|)
      (|sayTeX|
       "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" mathsize=\"big\" display=\"block\">")
      (|MMLFORM;displayElt| |s| $) (|sayTeX| "</math>") (EXIT |s|))))) 

(DEFUN |MMLFORM;coerceL;OfS;3| (|expr| $)
  (PROG (|s|)
    (RETURN
     (SEQ
      (LETT |s|
            (|MMLFORM;postcondition|
             (|MMLFORM;formatMml| (|MMLFORM;precondition| |expr| $)
              (QREFELT $ 8) $)
             $)
            |MMLFORM;coerceL;OfS;3|)
      (|sayTeX|
       "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" mathsize=\"big\" display=\"block\">")
      (|sayTeX| |s|) (|sayTeX| "</math>") (EXIT |s|))))) 

(DEFUN |MMLFORM;display;SV;4| (|mathml| $)
  (SEQ
   (|sayTeX|
    "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" mathsize=\"big\" display=\"block\">")
   (|sayTeX| |mathml|) (|sayTeX| "</math>") (EXIT (SPADCALL (QREFELT $ 27))))) 

(DEFUN |MMLFORM;exprex;OfS;5| (|expr| $)
  (PROG (|s| |s1| #1=#:G726 |a| |nargs| |args| |sop| |op| |le|)
    (RETURN
     (SEQ
      (LETT |expr| (|MMLFORM;precondition| |expr| $)
            . #2=(|MMLFORM;exprex;OfS;5|))
      (COND
       ((OR (ATOM |expr|) (EQUAL (|MMLFORM;stringify| |expr| $) "NOTHING"))
        (EXIT
         (SPADCALL (LIST "{" (|MMLFORM;stringify| |expr| $) "}")
                   (QREFELT $ 30)))))
      (LETT |le| |expr| . #2#) (LETT |op| (|SPADfirst| |le|) . #2#)
      (LETT |sop| (SPADCALL |op| (QREFELT $ 31)) . #2#)
      (LETT |args| (CDR |le|) . #2#) (LETT |nargs| (LENGTH |args|) . #2#)
      (LETT |s| (SPADCALL (LIST "{" |sop|) (QREFELT $ 30)) . #2#)
      (COND
       ((< 0 |nargs|)
        (SEQ (LETT |a| NIL . #2#) (LETT #1# |args| . #2#) G190
             (COND
              ((OR (ATOM #1#) (PROGN (LETT |a| (CAR #1#) . #2#) NIL))
               (GO G191)))
             (SEQ (LETT |s1| (SPADCALL |a| (QREFELT $ 31)) . #2#)
                  (EXIT
                   (LETT |s| (SPADCALL (LIST |s| |s1|) (QREFELT $ 30)) . #2#)))
             (LETT #1# (CDR #1#) . #2#) (GO G190) G191 (EXIT NIL))))
      (EXIT (LETT |s| (SPADCALL (LIST |s| "}") (QREFELT $ 30)) . #2#)))))) 

(DEFUN |MMLFORM;displayElt| (|mathML| $)
  (PROG (|u| |enT| |enE| |name| |length| |end|)
    (RETURN
     (SEQ (LETT |end| (QCSIZE |mathML|) . #1=(|MMLFORM;displayElt|))
          (LETT |length| 60 . #1#)
          (LETT |name| (|MMLFORM;eltName| 1 |mathML| $) . #1#)
          (LETT |enE|
                (|MMLFORM;eltLimit| |name| (+ 2 (QCSIZE |name|)) |mathML| $)
                . #1#)
          (COND
           ((< |enE| |length|)
            (SEQ (LETT |u| (SPADCALL 1 |enE| (QREFELT $ 34)) . #1#)
                 (EXIT (|sayTeX| (SPADCALL |mathML| |u| (QREFELT $ 35))))))
           ('T
            (SEQ (LETT |enT| (|MMLFORM;tagEnd| |name| 1 |mathML| $) . #1#)
                 (LETT |u| (SPADCALL 1 |enT| (QREFELT $ 34)) . #1#)
                 (|sayTeX| (SPADCALL |mathML| |u| (QREFELT $ 35)))
                 (LETT |u|
                       (SPADCALL (+ |enT| 1) (- (- |enE| (QCSIZE |name|)) 3)
                                 (QREFELT $ 34))
                       . #1#)
                 (|MMLFORM;displayElt| (SPADCALL |mathML| |u| (QREFELT $ 35))
                  $)
                 (LETT |u|
                       (SPADCALL (- (- |enE| (QCSIZE |name|)) 2) |enE|
                                 (QREFELT $ 34))
                       . #1#)
                 (EXIT (|sayTeX| (SPADCALL |mathML| |u| (QREFELT $ 35)))))))
          (COND
           ((< |enE| |end|)
            (SEQ (LETT |u| (SPADCALL (+ |enE| 1) |end| (QREFELT $ 34)) . #1#)
                 (EXIT
                  (|MMLFORM;displayElt| (SPADCALL |mathML| |u| (QREFELT $ 35))
                   $)))))
          (EXIT (SPADCALL (QREFELT $ 27))))))) 

(DEFUN |MMLFORM;eltName| (|pos| |mathML| $)
  (PROG (|name| |u| |i|)
    (RETURN
     (SEQ (LETT |i| (+ |pos| 1) . #1=(|MMLFORM;eltName|))
          (SEQ G190
               (COND
                ((NULL
                  (SPADCALL (SPADCALL |mathML| |i| (QREFELT $ 37))
                            (|spadConstant| $ 39) (QREFELT $ 41)))
                 (GO G191)))
               (SEQ (EXIT (LETT |i| (+ |i| 1) . #1#))) NIL (GO G190) G191
               (EXIT NIL))
          (LETT |u| (SPADCALL (+ |pos| 1) (- |i| 1) (QREFELT $ 34)) . #1#)
          (EXIT (LETT |name| (SPADCALL |mathML| |u| (QREFELT $ 35)) . #1#)))))) 

(DEFUN |MMLFORM;eltLimit| (|name| |pos| |mathML| $)
  (PROG (|pI| |level| |endI| |startI| |endS| |startS|)
    (RETURN
     (SEQ (LETT |pI| |pos| . #1=(|MMLFORM;eltLimit|))
          (LETT |startS| (SPADCALL (LIST "<" |name|) (QREFELT $ 30)) . #1#)
          (LETT |endS| (SPADCALL (LIST "</" |name| ">") (QREFELT $ 30)) . #1#)
          (LETT |level| 1 . #1#)
          (SEQ G190 (COND ((NULL (< 0 |level|)) (GO G191)))
               (SEQ
                (LETT |startI| (SPADCALL |startS| |mathML| |pI| (QREFELT $ 42))
                      . #1#)
                (LETT |endI| (SPADCALL |endS| |mathML| |pI| (QREFELT $ 42))
                      . #1#)
                (EXIT
                 (COND
                  ((OR (EQL |startI| 0) (NULL (< |startI| |endI|)))
                   (SEQ (LETT |level| (- |level| 1) . #1#)
                        (EXIT
                         (LETT |pI| (|MMLFORM;tagEnd| |name| |endI| |mathML| $)
                               . #1#))))
                  ('T
                   (SEQ (LETT |level| (+ |level| 1) . #1#)
                        (EXIT
                         (LETT |pI|
                               (|MMLFORM;tagEnd| |name| |startI| |mathML| $)
                               . #1#)))))))
               NIL (GO G190) G191 (EXIT NIL))
          (EXIT |pI|))))) 

(DEFUN |MMLFORM;tagEnd| (|name| |pos| |mathML| $)
  (PROG (|u| |pI|)
    (RETURN
     (SEQ (LETT |pI| |pos| . #1=(|MMLFORM;tagEnd|))
          (SEQ G190
               (COND
                ((NULL
                  (COND
                   ((SPADCALL (SPADCALL |mathML| |pI| (QREFELT $ 37))
                              (SPADCALL ">" (QREFELT $ 43)) (QREFELT $ 44))
                    'NIL)
                   ('T 'T)))
                 (GO G191)))
               (SEQ (EXIT (LETT |pI| (+ |pI| 1) . #1#))) NIL (GO G190) G191
               (EXIT NIL))
          (LETT |u| (SPADCALL |pos| |pI| (QREFELT $ 34)) . #1#) (EXIT |pI|))))) 

(DEFUN |MMLFORM;atomize| (|expr| $)
  (PROG (|le| #1=#:G751 |a| |letmp|)
    (RETURN
     (SEQ (LETT |le| NIL . #2=(|MMLFORM;atomize|))
          (COND
           ((OR (ATOM |expr|) (EQUAL (|MMLFORM;stringify| |expr| $) "NOTHING"))
            (EXIT
             (LETT |le| (APPEND |le| (SPADCALL |expr| (QREFELT $ 46)))
                   . #2#))))
          (LETT |letmp| |expr| . #2#)
          (SEQ (LETT |a| NIL . #2#) (LETT #1# |letmp| . #2#) G190
               (COND
                ((OR (ATOM #1#) (PROGN (LETT |a| (CAR #1#) . #2#) NIL))
                 (GO G191)))
               (SEQ
                (EXIT
                 (LETT |le| (APPEND |le| (|MMLFORM;atomize| |a| $)) . #2#)))
               (LETT #1# (CDR #1#) . #2#) (GO G190) G191 (EXIT NIL))
          (EXIT |le|))))) 

(DEFUN |MMLFORM;ungroup| (|str| $)
  (PROG (|u| |u2| |u1| |rrow| |lrow| |len|)
    (RETURN
     (SEQ (LETT |len| (QCSIZE |str|) . #1=(|MMLFORM;ungroup|))
          (EXIT
           (COND ((< |len| 14) |str|)
                 ('T
                  (SEQ (LETT |lrow| "<mrow>" . #1#)
                       (LETT |rrow| "</mrow>" . #1#)
                       (LETT |u1| (SPADCALL 1 6 (QREFELT $ 34)) . #1#)
                       (LETT |u2| (SPADCALL (- |len| 6) |len| (QREFELT $ 34))
                             . #1#)
                       (COND
                        ((EQUAL (SPADCALL |str| |u1| (QREFELT $ 35)) |lrow|)
                         (COND
                          ((EQUAL (SPADCALL |str| |u2| (QREFELT $ 35)) |rrow|)
                           (SEQ
                            (LETT |u| (SPADCALL 7 (- |len| 7) (QREFELT $ 34))
                                  . #1#)
                            (EXIT
                             (LETT |str| (SPADCALL |str| |u| (QREFELT $ 35))
                                   . #1#)))))))
                       (EXIT |str|))))))))) 

(DEFUN |MMLFORM;postcondition| (|str| $)
  (PROG (|uend| |ustart| |pos| |plusminus| |len|)
    (RETURN
     (SEQ (LETT |len| (QCSIZE |str|) . #1=(|MMLFORM;postcondition|))
          (LETT |plusminus| "<mo>+</mo><mo>-</mo>" . #1#)
          (LETT |pos| (SPADCALL |plusminus| |str| 1 (QREFELT $ 42)) . #1#)
          (COND
           ((< 0 |pos|)
            (SEQ (LETT |ustart| (SPADCALL 1 (- |pos| 1) (QREFELT $ 34)) . #1#)
                 (LETT |uend| (SPADCALL (+ |pos| 20) |len| (QREFELT $ 34))
                       . #1#)
                 (LETT |str|
                       (SPADCALL
                        (LIST (SPADCALL |str| |ustart| (QREFELT $ 35))
                              "<mo>-</mo>"
                              (SPADCALL |str| |uend| (QREFELT $ 35)))
                        (QREFELT $ 30))
                       . #1#)
                 (EXIT
                  (COND
                   ((< |pos| (- |len| 18))
                    (LETT |str| (|MMLFORM;postcondition| |str| $) . #1#)))))))
          (EXIT |str|))))) 

(PUT '|MMLFORM;stringify| '|SPADreplace| '|mathObject2String|) 

(DEFUN |MMLFORM;stringify| (|expr| $) (|mathObject2String| |expr|)) 

(DEFUN |MMLFORM;group| (|str| $)
  (SPADCALL (LIST "<mrow>" |str| "</mrow>") (QREFELT $ 30))) 

(DEFUN |MMLFORM;addBraces| (|str| $)
  (SPADCALL (LIST "<mo>{</mo>" |str| "<mo>}</mo>") (QREFELT $ 30))) 

(DEFUN |MMLFORM;addBrackets| (|str| $)
  (SPADCALL (LIST "<mo>[</mo>" |str| "<mo>]</mo>") (QREFELT $ 30))) 

(DEFUN |MMLFORM;parenthesize| (|str| $)
  (SPADCALL (LIST "<mo>(</mo>" |str| "<mo>)</mo>") (QREFELT $ 30))) 

(PUT '|MMLFORM;precondition| '|SPADreplace| '|outputTran|) 

(DEFUN |MMLFORM;precondition| (|expr| $) (|outputTran| |expr|)) 

(DEFUN |MMLFORM;formatSpecial| (|op| |args| |prec| $)
  (PROG (|tmp| |base| #1=#:G779 |u| #2=#:G778 |prescript|)
    (RETURN
     (SEQ (LETT |prescript| 'NIL . #3=(|MMLFORM;formatSpecial|))
          (EXIT
           (COND ((EQUAL |op| "theMap") "<mtext>theMap(...)</mtext>")
                 ((EQUAL |op| "AGGLST")
                  (|MMLFORM;formatNary| "," |args| |prec| $))
                 ((EQUAL |op| "AGGSET")
                  (|MMLFORM;formatNary| ";" |args| |prec| $))
                 ((EQUAL |op| "TAG")
                  (|MMLFORM;group|
                   (SPADCALL
                    (LIST (|MMLFORM;formatMml| (|SPADfirst| |args|) |prec| $)
                          "<mo>&#x02192;</mo>"
                          (|MMLFORM;formatMml| (SPADCALL |args| (QREFELT $ 47))
                           |prec| $))
                    (QREFELT $ 30))
                   $))
                 ((EQUAL |op| "SLASH")
                  (|MMLFORM;group|
                   (SPADCALL
                    (LIST (|MMLFORM;formatMml| (|SPADfirst| |args|) |prec| $)
                          "<mo>/</mo>"
                          (|MMLFORM;formatMml| (SPADCALL |args| (QREFELT $ 47))
                           |prec| $))
                    (QREFELT $ 30))
                   $))
                 ((EQUAL |op| "VCONCAT")
                  (|MMLFORM;group|
                   (STRCONC "<mtable><mtr>"
                            (STRCONC
                             (SPADCALL
                              (PROGN
                               (LETT #2# NIL . #3#)
                               (SEQ (LETT |u| NIL . #3#)
                                    (LETT #1# |args| . #3#) G190
                                    (COND
                                     ((OR (ATOM #1#)
                                          (PROGN
                                           (LETT |u| (CAR #1#) . #3#)
                                           NIL))
                                      (GO G191)))
                                    (SEQ
                                     (EXIT
                                      (LETT #2#
                                            (CONS
                                             (STRCONC "<mtd>"
                                                      (STRCONC
                                                       (|MMLFORM;formatMml| |u|
                                                        (QREFELT $ 8) $)
                                                       "</mtd>"))
                                             #2#)
                                            . #3#)))
                                    (LETT #1# (CDR #1#) . #3#) (GO G190) G191
                                    (EXIT (NREVERSE0 #2#))))
                              (QREFELT $ 30))
                             "</mtr></mtable>"))
                   $))
                 ((EQUAL |op| "CONCATB")
                  (|MMLFORM;formatNary| " " |args| |prec| $))
                 ((EQUAL |op| "CONCAT")
                  (|MMLFORM;formatNary| "" |args| (QREFELT $ 8) $))
                 ((EQUAL |op| "QUOTE")
                  (|MMLFORM;group|
                   (STRCONC "<mo>'</mo>"
                            (|MMLFORM;formatMml| (|SPADfirst| |args|)
                             (QREFELT $ 8) $))
                   $))
                 ((EQUAL |op| "BRACKET")
                  (|MMLFORM;group|
                   (|MMLFORM;addBrackets|
                    (|MMLFORM;ungroup|
                     (|MMLFORM;formatMml| (|SPADfirst| |args|) (QREFELT $ 8) $)
                     $)
                    $)
                   $))
                 ((EQUAL |op| "BRACE")
                  (|MMLFORM;group|
                   (|MMLFORM;addBraces|
                    (|MMLFORM;ungroup|
                     (|MMLFORM;formatMml| (|SPADfirst| |args|) (QREFELT $ 8) $)
                     $)
                    $)
                   $))
                 ((EQUAL |op| "PAREN")
                  (|MMLFORM;group|
                   (|MMLFORM;parenthesize|
                    (|MMLFORM;ungroup|
                     (|MMLFORM;formatMml| (|SPADfirst| |args|) (QREFELT $ 8) $)
                     $)
                    $)
                   $))
                 ((EQUAL |op| "OVERBAR")
                  (COND ((NULL |args|) "")
                        (#4='T
                         (|MMLFORM;group|
                          (SPADCALL
                           (LIST "<mover accent='true'><mrow>"
                                 (|MMLFORM;formatMml| (|SPADfirst| |args|)
                                  (QREFELT $ 8) $)
                                 "</mrow><mo stretchy='true'>&#x000AF;</mo></mover>")
                           (QREFELT $ 30))
                          $))))
                 ((EQUAL |op| "ROOT")
                  (COND ((NULL |args|) "")
                        (#4#
                         (SEQ
                          (LETT |tmp|
                                (|MMLFORM;group|
                                 (|MMLFORM;formatMml| (|SPADfirst| |args|)
                                  (QREFELT $ 8) $)
                                 $)
                                . #3#)
                          (EXIT
                           (COND
                            ((NULL (CDR |args|))
                             (SPADCALL (LIST "<msqrt>" |tmp| "</msqrt>")
                                       (QREFELT $ 30)))
                            (#4#
                             (|MMLFORM;group|
                              (SPADCALL
                               (LIST "<mroot><mrow>" |tmp| "</mrow>"
                                     (|MMLFORM;formatMml|
                                      (|SPADfirst| (CDR |args|)) (QREFELT $ 8)
                                      $)
                                     "</mroot>")
                               (QREFELT $ 30))
                              $))))))))
                 ((EQUAL |op| "SEGMENT")
                  (SEQ
                   (LETT |tmp|
                         (SPADCALL
                          (LIST
                           (|MMLFORM;formatMml| (|SPADfirst| |args|)
                            (QREFELT $ 8) $)
                           "<mo>..</mo>")
                          (QREFELT $ 30))
                         . #3#)
                   (EXIT
                    (|MMLFORM;group|
                     (COND ((NULL (CDR |args|)) |tmp|)
                           (#4#
                            (SPADCALL
                             (LIST |tmp|
                                   (|MMLFORM;formatMml|
                                    (|SPADfirst| (CDR |args|)) (QREFELT $ 8)
                                    $))
                             (QREFELT $ 30))))
                     $))))
                 ((EQUAL |op| "SUB")
                  (|MMLFORM;group|
                   (SPADCALL
                    (LIST "<msub>"
                          (|MMLFORM;formatMml| (|SPADfirst| |args|)
                           (QREFELT $ 8) $)
                          (|MMLFORM;formatSpecial| "AGGLST" (CDR |args|)
                           (QREFELT $ 8) $)
                          "</msub>")
                    (QREFELT $ 30))
                   $))
                 ((EQUAL |op| "SUPERSUB")
                  (SEQ
                   (LETT |base|
                         (|MMLFORM;formatMml| (|SPADfirst| |args|)
                          (QREFELT $ 8) $)
                         . #3#)
                   (LETT |args| (CDR |args|) . #3#)
                   (EXIT
                    (COND
                     ((EQL (LENGTH |args|) 1)
                      (SPADCALL "<msub><mrow>"
                                (SPADCALL |base|
                                          (SPADCALL "</mrow><mrow>"
                                                    (SPADCALL
                                                     (|MMLFORM;formatMml|
                                                      (|SPADfirst| |args|)
                                                      (QREFELT $ 8) $)
                                                     "</mrow></msub>"
                                                     (QREFELT $ 48))
                                                    (QREFELT $ 48))
                                          (QREFELT $ 48))
                                (QREFELT $ 48)))
                     ((EQL (LENGTH |args|) 2)
                      (SPADCALL "<msubsup><mrow>"
                                (SPADCALL |base|
                                          (SPADCALL "</mrow><mrow>"
                                                    (SPADCALL
                                                     (|MMLFORM;formatMml|
                                                      (|SPADfirst| |args|)
                                                      (QREFELT $ 8) $)
                                                     (SPADCALL "</mrow><mrow>"
                                                               (SPADCALL
                                                                (|MMLFORM;formatMml|
                                                                 (|SPADfirst|
                                                                  (CDR |args|))
                                                                 (QREFELT $ 8)
                                                                 $)
                                                                "</mrow></msubsup>"
                                                                (QREFELT $ 48))
                                                               (QREFELT $ 48))
                                                     (QREFELT $ 48))
                                                    (QREFELT $ 48))
                                          (QREFELT $ 48))
                                (QREFELT $ 48)))
                     ((EQL (LENGTH |args|) 3)
                      (SPADCALL "<mmultiscripts><mrow>"
                                (SPADCALL |base|
                                          (SPADCALL "</mrow><mrow>"
                                                    (SPADCALL
                                                     (|MMLFORM;formatMml|
                                                      (|SPADfirst| |args|)
                                                      (QREFELT $ 8) $)
                                                     (SPADCALL "</mrow><mrow>"
                                                               (SPADCALL
                                                                (|MMLFORM;formatMml|
                                                                 (|SPADfirst|
                                                                  (CDR |args|))
                                                                 (QREFELT $ 8)
                                                                 $)
                                                                (SPADCALL
                                                                 "</mrow><mprescripts/><mrow>"
                                                                 (SPADCALL
                                                                  (|MMLFORM;formatMml|
                                                                   (|SPADfirst|
                                                                    (CDR
                                                                     (CDR
                                                                      |args|)))
                                                                   (QREFELT $
                                                                            8)
                                                                   $)
                                                                  "</mrow><none/></mmultiscripts>"
                                                                  (QREFELT $
                                                                           48))
                                                                 (QREFELT $
                                                                          48))
                                                                (QREFELT $ 48))
                                                               (QREFELT $ 48))
                                                     (QREFELT $ 48))
                                                    (QREFELT $ 48))
                                          (QREFELT $ 48))
                                (QREFELT $ 48)))
                     ((EQL (LENGTH |args|) 4)
                      (SPADCALL "<mmultiscripts><mrow>"
                                (SPADCALL |base|
                                          (SPADCALL "</mrow><mrow>"
                                                    (SPADCALL
                                                     (|MMLFORM;formatMml|
                                                      (|SPADfirst| |args|)
                                                      (QREFELT $ 8) $)
                                                     (SPADCALL "</mrow><mrow>"
                                                               (SPADCALL
                                                                (|MMLFORM;formatMml|
                                                                 (|SPADfirst|
                                                                  (CDR |args|))
                                                                 (QREFELT $ 8)
                                                                 $)
                                                                (SPADCALL
                                                                 "</mrow><mprescripts/><mrow>"
                                                                 (SPADCALL
                                                                  (|MMLFORM;formatMml|
                                                                   (|SPADfirst|
                                                                    (CDR
                                                                     (CDR
                                                                      |args|)))
                                                                   (QREFELT $
                                                                            8)
                                                                   $)
                                                                  (SPADCALL
                                                                   "</mrow><mrow>"
                                                                   (SPADCALL
                                                                    (|MMLFORM;formatMml|
                                                                     (|SPADfirst|
                                                                      (CDR
                                                                       (CDR
                                                                        (CDR
                                                                         |args|))))
                                                                     (QREFELT $
                                                                              8)
                                                                     $)
                                                                    "</mrow></mmultiscripts>"
                                                                    (QREFELT $
                                                                             48))
                                                                   (QREFELT $
                                                                            48))
                                                                  (QREFELT $
                                                                           48))
                                                                 (QREFELT $
                                                                          48))
                                                                (QREFELT $ 48))
                                                               (QREFELT $ 48))
                                                     (QREFELT $ 48))
                                                    (QREFELT $ 48))
                                          (QREFELT $ 48))
                                (QREFELT $ 48)))
                     (#4# "<mtext>Problem with multiscript object</mtext>")))))
                 ((EQUAL |op| "SC")
                  (COND ((NULL |args|) "")
                        (#4#
                         (SEQ
                          (LETT |tmp|
                                (|MMLFORM;formatNaryNoGroup|
                                 "</mtd></mtr><mtr><mtd>" |args| (QREFELT $ 8)
                                 $)
                                . #3#)
                          (EXIT
                           (|MMLFORM;group|
                            (SPADCALL
                             (LIST "<mtable><mtr><mtd>" |tmp|
                                   "</mtd></mtr></mtable>")
                             (QREFELT $ 30))
                            $))))))
                 ((EQUAL |op| "MATRIX")
                  (|MMLFORM;formatMatrix| (CDR |args|) $))
                 ((EQUAL |op| "ZAG")
                  (SPADCALL
                   (LIST " \\zag{"
                         (|MMLFORM;formatMml| (|SPADfirst| |args|)
                          (QREFELT $ 8) $)
                         "}{"
                         (|MMLFORM;formatMml| (|SPADfirst| (CDR |args|))
                          (QREFELT $ 8) $)
                         "}")
                   (QREFELT $ 30)))
                 (#4#
                  (SPADCALL (LIST "<mtext>not done yet for: " |op| "</mtext>")
                            (QREFELT $ 30))))))))) 

(DEFUN |MMLFORM;formatSub| (|expr| |args| |opPrec| $)
  (PROG (|s| |i| |tmpS| |k| |j| |posLS| |numLS| |tmpLE| |ndiffs| |op| |atomE|)
    (RETURN
     (SEQ
      (LETT |atomE| (|MMLFORM;atomize| |expr| $) . #1=(|MMLFORM;formatSub|))
      (LETT |op| (|MMLFORM;stringify| (|SPADfirst| |atomE|) $) . #1#)
      (EXIT
       (COND
        ((EQUAL |op| "SUB")
         (COND
          ((NULL
            (EQUAL (|MMLFORM;stringify| (|SPADfirst| (CDR (CDR |atomE|))) $)
                   "CONCAT"))
           "<mtext>Mistake in formatSub: no CONCAT</mtext>")
          ('T
           (SEQ (LETT |ndiffs| 0 . #1#)
                (LETT |tmpLE| (CDR (CDR |atomE|)) . #1#)
                (SEQ G190
                     (COND
                      ((NULL
                        (EQUAL (|MMLFORM;stringify| (|SPADfirst| |tmpLE|) $)
                               "CONCAT"))
                       #2=(GO G191)))
                     (SEQ (LETT |ndiffs| (+ |ndiffs| 1) . #1#)
                          (EXIT (LETT |tmpLE| (CDR |tmpLE|) . #1#)))
                     NIL #3=(GO G190) G191 (EXIT NIL))
                (LETT |numLS| NIL . #1#) (LETT |i| 1 . #1#)
                (SEQ G190 (COND ((NULL (< |i| |ndiffs|)) #2#))
                     (SEQ
                      (LETT |numLS|
                            (APPEND |numLS|
                                    (SPADCALL
                                     (|MMLFORM;stringify|
                                      (|SPADfirst| (CDR |tmpLE|)) $)
                                     (QREFELT $ 50)))
                            . #1#)
                      (LETT |tmpLE| (CDR (CDR (CDR |tmpLE|))) . #1#)
                      (EXIT (LETT |i| (+ |i| 1) . #1#)))
                     NIL #3# G191 (EXIT NIL))
                (LETT |numLS|
                      (APPEND |numLS|
                              (SPADCALL
                               (|MMLFORM;stringify| (|SPADfirst| (CDR |tmpLE|))
                                $)
                               (QREFELT $ 50)))
                      . #1#)
                (LETT |posLS| NIL . #1#) (LETT |i| 0 . #1#)
                (SEQ G190 (COND ((NULL (< |i| (LENGTH |args|))) #2#))
                     (SEQ
                      (LETT |posLS|
                            (APPEND |posLS|
                                    (SPADCALL (STRINGIMAGE (+ |i| 1))
                                              (QREFELT $ 50)))
                            . #1#)
                      (EXIT (LETT |i| (+ |i| 1) . #1#)))
                     NIL #3# G191 (EXIT NIL))
                (LETT |tmpS|
                      (|MMLFORM;stringify| (SPADCALL |atomE| 2 (QREFELT $ 51))
                       $)
                      . #1#)
                (COND
                 ((EQL |ndiffs| 1)
                  (LETT |s|
                        (SPADCALL "<mfrac><mo>&#x02202;</mo><mi>"
                                  (SPADCALL |tmpS| "</mi><mrow>"
                                            (QREFELT $ 48))
                                  (QREFELT $ 48))
                        . #1#))
                 (#4='T
                  (LETT |s|
                        (SPADCALL "<mfrac><mrow><msup><mo>&#x02202;</mo><mn>"
                                  (SPADCALL (STRINGIMAGE |ndiffs|)
                                            (SPADCALL "</mn></msup><mi>"
                                                      (SPADCALL |tmpS|
                                                                "</mi></mrow><mrow>"
                                                                (QREFELT $ 48))
                                                      (QREFELT $ 48))
                                            (QREFELT $ 48))
                                  (QREFELT $ 48))
                        . #1#)))
                (LETT |i| 1 . #1#)
                (SEQ G190 (COND ((NULL (< |i| (+ (LENGTH |posLS|) 1))) #2#))
                     (SEQ (LETT |j| 0 . #1#) (LETT |k| 1 . #1#)
                          (SEQ G190
                               (COND
                                ((NULL (< |k| (+ (LENGTH |numLS|) 1))) #2#))
                               (SEQ
                                (COND
                                 ((EQUAL (SPADCALL |numLS| |k| (QREFELT $ 52))
                                         (STRINGIMAGE |i|))
                                  (LETT |j| (+ |j| 1) . #1#)))
                                (EXIT (LETT |k| (+ |k| 1) . #1#)))
                               NIL #3# G191 (EXIT NIL))
                          (COND
                           ((< 0 |j|)
                            (SEQ
                             (LETT |tmpS|
                                   (|MMLFORM;stringify|
                                    (SPADCALL |args| |i| (QREFELT $ 51)) $)
                                   . #1#)
                             (EXIT
                              (COND
                               ((EQL |j| 1)
                                (LETT |s|
                                      (SPADCALL |s|
                                                (SPADCALL
                                                 "<mo>&#x02202;</mo><mi>"
                                                 (SPADCALL |tmpS| "</mi>"
                                                           (QREFELT $ 48))
                                                 (QREFELT $ 48))
                                                (QREFELT $ 48))
                                      . #1#))
                               ('T
                                (LETT |s|
                                      (SPADCALL |s|
                                                (SPADCALL
                                                 "<mo>&#x02202;</mo><msup><mi>"
                                                 (SPADCALL |tmpS|
                                                           (SPADCALL
                                                            "</mi><mn>"
                                                            (SPADCALL
                                                             (STRINGIMAGE |j|)
                                                             "</mn></msup>"
                                                             (QREFELT $ 48))
                                                            (QREFELT $ 48))
                                                           (QREFELT $ 48))
                                                 (QREFELT $ 48))
                                                (QREFELT $ 48))
                                      . #1#)))))))
                          (EXIT (LETT |i| (+ |i| 1) . #1#)))
                     NIL #3# G191 (EXIT NIL))
                (LETT |s|
                      (SPADCALL |s| "</mrow></mfrac><mo>(</mo>" (QREFELT $ 48))
                      . #1#)
                (LETT |i| 1 . #1#)
                (SEQ G190 (COND ((NULL (< |i| (+ (LENGTH |posLS|) 1))) #2#))
                     (SEQ
                      (LETT |tmpS|
                            (|MMLFORM;stringify|
                             (SPADCALL |args| |i| (QREFELT $ 51)) $)
                            . #1#)
                      (LETT |s|
                            (SPADCALL |s|
                                      (SPADCALL "<mi>"
                                                (SPADCALL |tmpS| "</mi>"
                                                          (QREFELT $ 48))
                                                (QREFELT $ 48))
                                      (QREFELT $ 48))
                            . #1#)
                      (COND
                       ((< |i| (LENGTH |posLS|))
                        (LETT |s| (SPADCALL |s| "<mo>,</mo>" (QREFELT $ 48))
                              . #1#)))
                      (EXIT (LETT |i| (+ |i| 1) . #1#)))
                     NIL #3# G191 (EXIT NIL))
                (EXIT
                 (LETT |s| (SPADCALL |s| "<mo>)</mo>" (QREFELT $ 48))
                       . #1#))))))
        (#4# "<mtext>Mistake in formatSub: no SUB</mtext>"))))))) 

(DEFUN |MMLFORM;formatSub1| (|expr| |args| |opPrec| $)
  (PROG (|s| |i| |tmpS| |funcS| |posLS| |numLS| |tmpLE| |ndiffs| |op| |atomE|)
    (RETURN
     (SEQ
      (LETT |atomE| (|MMLFORM;atomize| |expr| $) . #1=(|MMLFORM;formatSub1|))
      (LETT |op| (|MMLFORM;stringify| (|SPADfirst| |atomE|) $) . #1#)
      (EXIT
       (COND
        ((EQUAL |op| "SUB")
         (COND
          ((NULL
            (EQUAL (|MMLFORM;stringify| (|SPADfirst| (CDR (CDR |atomE|))) $)
                   "CONCAT"))
           "<mtext>Mistake in formatSub: no CONCAT</mtext>")
          ('T
           (SEQ (LETT |ndiffs| 0 . #1#)
                (LETT |tmpLE| (CDR (CDR |atomE|)) . #1#)
                (SEQ G190
                     (COND
                      ((NULL
                        (EQUAL (|MMLFORM;stringify| (|SPADfirst| |tmpLE|) $)
                               "CONCAT"))
                       #2=(GO G191)))
                     (SEQ (LETT |ndiffs| (+ |ndiffs| 1) . #1#)
                          (EXIT (LETT |tmpLE| (CDR |tmpLE|) . #1#)))
                     NIL #3=(GO G190) G191 (EXIT NIL))
                (LETT |numLS| NIL . #1#) (LETT |i| 1 . #1#)
                (SEQ G190 (COND ((NULL (< |i| |ndiffs|)) #2#))
                     (SEQ
                      (LETT |numLS|
                            (APPEND |numLS|
                                    (SPADCALL
                                     (|MMLFORM;stringify|
                                      (|SPADfirst| (CDR |tmpLE|)) $)
                                     (QREFELT $ 50)))
                            . #1#)
                      (LETT |tmpLE| (CDR (CDR (CDR |tmpLE|))) . #1#)
                      (EXIT (LETT |i| (+ |i| 1) . #1#)))
                     NIL #3# G191 (EXIT NIL))
                (LETT |numLS|
                      (APPEND |numLS|
                              (SPADCALL
                               (|MMLFORM;stringify| (|SPADfirst| (CDR |tmpLE|))
                                $)
                               (QREFELT $ 50)))
                      . #1#)
                (LETT |posLS| NIL . #1#) (LETT |i| 0 . #1#)
                (SEQ G190 (COND ((NULL (< |i| (LENGTH |args|))) #2#))
                     (SEQ
                      (LETT |posLS|
                            (APPEND |posLS|
                                    (SPADCALL (STRINGIMAGE (+ |i| 1))
                                              (QREFELT $ 50)))
                            . #1#)
                      (EXIT (LETT |i| (+ |i| 1) . #1#)))
                     NIL #3# G191 (EXIT NIL))
                (LETT |funcS|
                      (|MMLFORM;stringify| (SPADCALL |atomE| 2 (QREFELT $ 51))
                       $)
                      . #1#)
                (LETT |s|
                      (SPADCALL "<msub><mi>"
                                (SPADCALL |funcS| "</mi><mrow>" (QREFELT $ 48))
                                (QREFELT $ 48))
                      . #1#)
                (LETT |i| 1 . #1#)
                (SEQ G190 (COND ((NULL (< |i| (+ (LENGTH |numLS|) 1))) #2#))
                     (SEQ
                      (LETT |s|
                            (SPADCALL |s|
                                      (SPADCALL "<mo>,</mo><mn>"
                                                (SPADCALL
                                                 (SPADCALL |numLS| |i|
                                                           (QREFELT $ 52))
                                                 "</mn>" (QREFELT $ 48))
                                                (QREFELT $ 48))
                                      (QREFELT $ 48))
                            . #1#)
                      (EXIT (LETT |i| (+ |i| 1) . #1#)))
                     NIL #3# G191 (EXIT NIL))
                (LETT |s|
                      (SPADCALL |s| "</mrow></msub><mo>(</mo>" (QREFELT $ 48))
                      . #1#)
                (LETT |i| 1 . #1#)
                (SEQ G190 (COND ((NULL (< |i| (+ (LENGTH |posLS|) 1))) #2#))
                     (SEQ
                      (LETT |tmpS|
                            (|MMLFORM;formatMml| (|SPADfirst| |args|)
                             (QREFELT $ 8) $)
                            . #1#)
                      (LETT |args| (CDR |args|) . #1#)
                      (LETT |s|
                            (SPADCALL |s|
                                      (SPADCALL "<mi>"
                                                (SPADCALL |tmpS| "</mi>"
                                                          (QREFELT $ 48))
                                                (QREFELT $ 48))
                                      (QREFELT $ 48))
                            . #1#)
                      (COND
                       ((< |i| (LENGTH |posLS|))
                        (LETT |s| (SPADCALL |s| "<mo>,</mo>" (QREFELT $ 48))
                              . #1#)))
                      (EXIT (LETT |i| (+ |i| 1) . #1#)))
                     NIL #3# G191 (EXIT NIL))
                (EXIT
                 (LETT |s| (SPADCALL |s| "<mo>)</mo>" (QREFELT $ 48))
                       . #1#))))))
        ('T "<mtext>Mistake in formatSub: no SUB</mtext>"))))))) 

(DEFUN |MMLFORM;formatSuperSub| (|expr| |args| |opPrec| $)
  (PROG (|s| |j| |commaTest| |i| |commaS| |bvarS| |funcS| |var| |op| |atomE|)
    (RETURN
     (SEQ
      (LETT |atomE| (|MMLFORM;atomize| |expr| $)
            . #1=(|MMLFORM;formatSuperSub|))
      (LETT |op| (|MMLFORM;stringify| (|SPADfirst| |atomE|) $) . #1#)
      (EXIT
       (COND
        ((EQUAL |op| "SUPERSUB")
         (COND
          ((NULL (EQL (LENGTH |args|) 1))
           "<mtext>Mistake in SuperSub1: #args <> 1</mtext>")
          ('T
           (SEQ (LETT |var| (|SPADfirst| |args|) . #1#)
                (LETT |funcS|
                      (|MMLFORM;stringify| (|SPADfirst| (CDR |atomE|)) $)
                      . #1#)
                (LETT |bvarS| (|MMLFORM;stringify| (|SPADfirst| |args|) $)
                      . #1#)
                (LETT |commaS|
                      (|MMLFORM;stringify|
                       (|SPADfirst| (CDR (CDR (CDR |atomE|)))) $)
                      . #1#)
                (LETT |commaTest| "," . #1#) (LETT |i| 0 . #1#)
                (SEQ G190
                     (COND
                      ((NULL
                        (< 0 (SPADCALL |commaTest| |commaS| 1 (QREFELT $ 42))))
                       #2=(GO G191)))
                     (SEQ (LETT |i| (+ |i| 1) . #1#)
                          (EXIT
                           (LETT |commaTest|
                                 (SPADCALL |commaTest| "," (QREFELT $ 48))
                                 . #1#)))
                     NIL #3=(GO G190) G191 (EXIT NIL))
                (LETT |s|
                      (SPADCALL "<msup><mi>"
                                (SPADCALL |funcS| "</mi><mrow>" (QREFELT $ 48))
                                (QREFELT $ 48))
                      . #1#)
                (LETT |j| 0 . #1#)
                (SEQ G190 (COND ((NULL (< |j| |i|)) #2#))
                     (SEQ
                      (LETT |s|
                            (SPADCALL |s| "<mo>&#x02032;</mo>" (QREFELT $ 48))
                            . #1#)
                      (EXIT (LETT |j| (+ |j| 1) . #1#)))
                     NIL #3# G191 (EXIT NIL))
                (EXIT
                 (LETT |s|
                       (SPADCALL |s|
                                 (SPADCALL
                                  "</mrow></msup><mo>&#x02061;</mo><mo>(</mo>"
                                  (SPADCALL
                                   (|MMLFORM;formatMml| (|SPADfirst| |args|)
                                    (QREFELT $ 8) $)
                                   "<mo>)</mo>" (QREFELT $ 48))
                                  (QREFELT $ 48))
                                 (QREFELT $ 48))
                       . #1#))))))
        ('T "<mtext>Mistake in formatSuperSub: no SUPERSUB1</mtext>"))))))) 

(DEFUN |MMLFORM;formatSuperSub1| (|expr| |args| |opPrec| $)
  (PROG (|s| |commaTest| |ndiffs| |commaS| |bvarS| |funcS| |var| |op| |atomE|)
    (RETURN
     (SEQ
      (LETT |atomE| (|MMLFORM;atomize| |expr| $)
            . #1=(|MMLFORM;formatSuperSub1|))
      (LETT |op| (|MMLFORM;stringify| (|SPADfirst| |atomE|) $) . #1#)
      (EXIT
       (COND
        ((EQUAL |op| "SUPERSUB")
         (COND
          ((NULL (EQL (LENGTH |args|) 1))
           "<mtext>Mistake in SuperSub: #args <> 1</mtext>")
          ('T
           (SEQ (LETT |var| (|SPADfirst| |args|) . #1#)
                (LETT |funcS|
                      (|MMLFORM;stringify| (|SPADfirst| (CDR |atomE|)) $)
                      . #1#)
                (LETT |bvarS| (|MMLFORM;stringify| (|SPADfirst| |args|) $)
                      . #1#)
                (LETT |commaS|
                      (|MMLFORM;stringify|
                       (|SPADfirst| (CDR (CDR (CDR |atomE|)))) $)
                      . #1#)
                (LETT |commaTest| "," . #1#) (LETT |ndiffs| 0 . #1#)
                (SEQ G190
                     (COND
                      ((NULL
                        (< 0 (SPADCALL |commaTest| |commaS| 1 (QREFELT $ 42))))
                       (GO G191)))
                     (SEQ (LETT |ndiffs| (+ |ndiffs| 1) . #1#)
                          (EXIT
                           (LETT |commaTest|
                                 (SPADCALL |commaTest| "," (QREFELT $ 48))
                                 . #1#)))
                     NIL (GO G190) G191 (EXIT NIL))
                (EXIT
                 (LETT |s|
                       (SPADCALL "<mfrac><mrow><msup><mo>&#x02146;</mo><mn>"
                                 (SPADCALL (STRINGIMAGE |ndiffs|)
                                           (SPADCALL "</mn></msup><mi>"
                                                     (SPADCALL |funcS|
                                                               (SPADCALL
                                                                "</mi></mrow><mrow><mo>&#x02146;</mo><msup><mi>"
                                                                (SPADCALL
                                                                 (|MMLFORM;formatMml|
                                                                  (|SPADfirst|
                                                                   |args|)
                                                                  (QREFELT $ 8)
                                                                  $)
                                                                 (SPADCALL
                                                                  "</mi><mn>"
                                                                  (SPADCALL
                                                                   (STRINGIMAGE
                                                                    |ndiffs|)
                                                                   (SPADCALL
                                                                    "</mn></msup></mrow></mfrac><mo>&#x02061;</mo><mo>(</mo><mi>"
                                                                    (SPADCALL
                                                                     (|MMLFORM;formatMml|
                                                                      (|SPADfirst|
                                                                       |args|)
                                                                      (QREFELT
                                                                       $ 8)
                                                                      $)
                                                                     "</mi><mo>)</mo>"
                                                                     (QREFELT $
                                                                              48))
                                                                    (QREFELT $
                                                                             48))
                                                                   (QREFELT $
                                                                            48))
                                                                  (QREFELT $
                                                                           48))
                                                                 (QREFELT $
                                                                          48))
                                                                (QREFELT $ 48))
                                                               (QREFELT $ 48))
                                                     (QREFELT $ 48))
                                           (QREFELT $ 48))
                                 (QREFELT $ 48))
                       . #1#))))))
        ('T "<mtext>Mistake in formatSuperSub: no SUPERSUB</mtext>"))))))) 

(DEFUN |MMLFORM;formatPlex| (|op| |args| |prec| $)
  (PROG (|s| |opa| |la| |hold| |checkarg| |n| |opPrec| |p|)
    (RETURN
     (SEQ (LETT |checkarg| 'NIL . #1=(|MMLFORM;formatPlex|))
          (LETT |p| (SPADCALL |op| (QREFELT $ 16) (QREFELT $ 53)) . #1#)
          (EXIT
           (COND ((< |p| 1) (|error| "unknown plex op"))
                 ((EQUAL |op| "INTSIGN")
                  (|MMLFORM;formatIntSign| |args| (QREFELT $ 8) $))
                 (#2='T
                  (SEQ
                   (LETT |opPrec| (SPADCALL (QREFELT $ 17) |p| (QREFELT $ 55))
                         . #1#)
                   (LETT |n| (LENGTH |args|) . #1#)
                   (COND
                    ((NULL (EQL |n| 2))
                     (COND
                      ((NULL (EQL |n| 3))
                       (EXIT
                        (|error| "wrong number of arguments for plex"))))))
                   (LETT |s|
                         (COND
                          ((OR (EQUAL |op| "SIGMA") (EQUAL |op| "SIGMA2"))
                           (SEQ (LETT |checkarg| 'T . #1#)
                                (EXIT "<mo>&#x02211;</mo>")))
                          ((OR (EQUAL |op| "PI") (EQUAL |op| "PI2"))
                           (SEQ (LETT |checkarg| 'T . #1#)
                                (EXIT "<mo>&#x0220F;</mo>")))
                          ((EQUAL |op| "INDEFINTEGRAL") "<mo>&#x0222B;</mo>")
                          (#2# "????"))
                         . #1#)
                   (LETT |hold|
                         (|MMLFORM;formatMml| (|SPADfirst| |args|)
                          (QREFELT $ 8) $)
                         . #1#)
                   (LETT |args| (CDR |args|) . #1#)
                   (COND
                    ((EQUAL |op| "INDEFINTEGRAL")
                     (SEQ
                      (LETT |hold|
                            (|MMLFORM;group|
                             (SPADCALL
                              (LIST |hold|
                                    (|MMLFORM;formatMml| (|SPADfirst| |args|)
                                     (QREFELT $ 8) $))
                              (QREFELT $ 30))
                             $)
                            . #1#)
                      (EXIT
                       (LETT |s| (SPADCALL (LIST |s| |hold|) (QREFELT $ 30))
                             . #1#))))
                    (#2#
                     (SEQ
                      (COND
                       ((EQUAL |hold| "")
                        (LETT |s|
                              (SPADCALL
                               (LIST "<munderover>" |s|
                                     (|MMLFORM;group| " " $))
                               (QREFELT $ 30))
                              . #1#))
                       (#2#
                        (LETT |s|
                              (SPADCALL
                               (LIST "<munderover>" |s|
                                     (|MMLFORM;group| |hold| $))
                               (QREFELT $ 30))
                              . #1#)))
                      (COND
                       ((NULL (NULL (CDR |args|)))
                        (SEQ
                         (LETT |hold|
                               (|MMLFORM;formatMml| (|SPADfirst| |args|)
                                (QREFELT $ 8) $)
                               . #1#)
                         (COND
                          ((EQUAL |hold| "")
                           (LETT |s|
                                 (SPADCALL
                                  (LIST |s| (|MMLFORM;group| " " $)
                                        "</munderover>")
                                  (QREFELT $ 30))
                                 . #1#))
                          (#2#
                           (LETT |s|
                                 (SPADCALL
                                  (LIST |s| (|MMLFORM;group| |hold| $)
                                        "</munderover>")
                                  (QREFELT $ 30))
                                 . #1#)))
                         (EXIT (LETT |args| (CDR |args|) . #1#)))))
                      (EXIT
                       (COND
                        (|checkarg|
                         (SEQ (LETT |la| (|SPADfirst| |args|) . #1#)
                              (LETT |opa|
                                    (|MMLFORM;stringify| (|SPADfirst| |la|) $)
                                    . #1#)
                              (EXIT
                               (COND
                                ((EQUAL |opa| "+")
                                 (LETT |s|
                                       (SPADCALL
                                        (LIST |s| "<mo>(</mo>"
                                              (|MMLFORM;formatMml|
                                               (|SPADfirst| |args|)
                                               (QREFELT $ 8) $)
                                              "<mo>)</mo>")
                                        (QREFELT $ 30))
                                       . #1#))
                                (#2#
                                 (LETT |s|
                                       (SPADCALL
                                        (LIST |s|
                                              (|MMLFORM;formatMml|
                                               (|SPADfirst| |args|)
                                               (QREFELT $ 8) $))
                                        (QREFELT $ 30))
                                       . #1#))))))
                        (#2#
                         (LETT |s|
                               (SPADCALL
                                (LIST |s|
                                      (|MMLFORM;formatMml| (|SPADfirst| |args|)
                                       (QREFELT $ 8) $))
                                (QREFELT $ 30))
                               . #1#)))))))
                   (EXIT (|MMLFORM;group| |s| $)))))))))) 

(DEFUN |MMLFORM;formatIntSign| (|args| |opPrec| $)
  (PROG (|integrand| |tmpLE| |bvarS| |bvar| |highlim| |lowlim| |u2| |u1| |i|
         |varRS| |atomE|)
    (RETURN
     (SEQ
      (COND
       ((EQUAL (|MMLFORM;stringify| (|SPADfirst| |args|) $) "NOTHING")
        (SEQ
         (LETT |bvar| (|SPADfirst| (CDR |args|))
               . #1=(|MMLFORM;formatIntSign|))
         (LETT |bvarS| (|MMLFORM;stringify| |bvar| $) . #1#) (LETT |i| 0 . #1#)
         (LETT |atomE| (|MMLFORM;atomize| (|SPADfirst| (CDR (CDR |args|))) $)
               . #1#)
         (LETT |varRS|
               (|MMLFORM;stringify| (SPADCALL |atomE| (QREFELT $ 56)) $) . #1#)
         (LETT |tmpLE| (|SPADfirst| (CDR (CDR |args|))) . #1#)
         (LETT |integrand|
               (|MMLFORM;formatMml| (|SPADfirst| (CDR |tmpLE|)) (QREFELT $ 8)
                $)
               . #1#)
         (SEQ G190
              (COND
               ((NULL
                 (< 0
                    (LETT |i|
                          (SPADCALL |varRS| |integrand| (+ |i| 1)
                                    (QREFELT $ 42))
                          . #1#)))
                (GO G191)))
              (SEQ (LETT |u1| (SPADCALL 1 (- |i| 1) (QREFELT $ 34)) . #1#)
                   (LETT |u2|
                         (SPADCALL (+ |i| 2) (QCSIZE |integrand|)
                                   (QREFELT $ 34))
                         . #1#)
                   (EXIT
                    (LETT |integrand|
                          (SPADCALL
                           (LIST (SPADCALL |integrand| |u1| (QREFELT $ 35))
                                 |bvarS|
                                 (SPADCALL |integrand| |u2| (QREFELT $ 35)))
                           (QREFELT $ 30))
                          . #1#)))
              NIL (GO G190) G191 (EXIT NIL))
         (EXIT
          (SPADCALL
           (LIST
            (SPADCALL "<mrow><mo>&#x0222B;</mo>"
                      (SPADCALL |integrand|
                                (SPADCALL "<mo>&#x02146;</mo><mi>"
                                          (SPADCALL |bvarS| "</mi></mrow>"
                                                    (QREFELT $ 48))
                                          (QREFELT $ 48))
                                (QREFELT $ 48))
                      (QREFELT $ 48)))
           (QREFELT $ 30)))))
       ('T
        (SEQ (LETT |lowlim| (|MMLFORM;stringify| (|SPADfirst| |args|) $) . #1#)
             (LETT |highlim| (|MMLFORM;stringify| (|SPADfirst| (CDR |args|)) $)
                   . #1#)
             (LETT |bvar|
                   (SPADCALL
                    (|MMLFORM;atomize| (|SPADfirst| (CDR (CDR |args|))) $)
                    (QREFELT $ 56))
                   . #1#)
             (LETT |bvarS| (|MMLFORM;stringify| |bvar| $) . #1#)
             (LETT |tmpLE| (|SPADfirst| (CDR (CDR |args|))) . #1#)
             (LETT |integrand|
                   (|MMLFORM;formatMml| (|SPADfirst| (CDR |tmpLE|))
                    (QREFELT $ 8) $)
                   . #1#)
             (EXIT
              (SPADCALL
               (LIST
                (SPADCALL "<mrow><munderover><mo>&#x0222B;</mo><mi>"
                          (SPADCALL |lowlim|
                                    (SPADCALL "</mi><mi>"
                                              (SPADCALL |highlim|
                                                        (SPADCALL
                                                         "</mi></munderover>"
                                                         (SPADCALL |integrand|
                                                                   (SPADCALL
                                                                    "<mo>&#x02146;</mo><mi>"
                                                                    (SPADCALL
                                                                     |bvarS|
                                                                     "</mi></mrow>"
                                                                     (QREFELT $
                                                                              48))
                                                                    (QREFELT $
                                                                             48))
                                                                   (QREFELT $
                                                                            48))
                                                         (QREFELT $ 48))
                                                        (QREFELT $ 48))
                                              (QREFELT $ 48))
                                    (QREFELT $ 48))
                          (QREFELT $ 48)))
               (QREFELT $ 30)))))))))) 

(DEFUN |MMLFORM;formatMatrix| (|args| $)
  (|MMLFORM;group|
   (|MMLFORM;addBrackets|
    (SPADCALL
     (LIST "<mtable><mtr><mtd>"
           (|MMLFORM;formatNaryNoGroup| "</mtd></mtr><mtr><mtd>" |args|
            (QREFELT $ 8) $)
           "</mtd></mtr></mtable>")
     (QREFELT $ 30))
    $)
   $)) 

(DEFUN |MMLFORM;formatFunction| (|op| |args| |prec| $)
  (|MMLFORM;group|
   (SPADCALL
    (LIST "<mo>" |op| "</mo>"
          (|MMLFORM;parenthesize|
           (|MMLFORM;formatNary| "," |args| (QREFELT $ 8) $) $))
    (QREFELT $ 30))
   $)) 

(DEFUN |MMLFORM;formatNullary| (|op| $)
  (COND ((EQUAL |op| "NOTHING") "")
        ('T
         (|MMLFORM;group|
          (SPADCALL (LIST "<mo>" |op| "</mo><mo>(</mo><mo>)</mo>")
                    (QREFELT $ 30))
          $)))) 

(DEFUN |MMLFORM;formatUnary| (|op| |arg| |prec| $)
  (PROG (|s| |opPrec| |p|)
    (RETURN
     (SEQ
      (LETT |p| (SPADCALL |op| (QREFELT $ 9) (QREFELT $ 53))
            . #1=(|MMLFORM;formatUnary|))
      (EXIT
       (COND ((< |p| 1) (|error| "unknown unary op"))
             (#2='T
              (SEQ
               (LETT |opPrec| (SPADCALL (QREFELT $ 10) |p| (QREFELT $ 55))
                     . #1#)
               (LETT |s|
                     (SPADCALL
                      (LIST "<mo>" |op| "</mo>"
                            (|MMLFORM;formatMml| |arg| |opPrec| $))
                      (QREFELT $ 30))
                     . #1#)
               (EXIT
                (COND
                 ((< |opPrec| |prec|)
                  (|MMLFORM;group| (|MMLFORM;parenthesize| |s| $) $))
                 ((EQUAL |op| "-") |s|) (#2# (|MMLFORM;group| |s| $)))))))))))) 

(DEFUN |MMLFORM;formatBinary| (|op| |args| |prec| $)
  (PROG (|s| |s2| |s1| |opa| |la| |opPrec| |p|)
    (RETURN
     (SEQ
      (LETT |p| (SPADCALL |op| (QREFELT $ 11) (QREFELT $ 53))
            . #1=(|MMLFORM;formatBinary|))
      (EXIT
       (COND ((< |p| 1) (|error| "unknown binary op"))
             (#2='T
              (SEQ
               (LETT |opPrec| (SPADCALL (QREFELT $ 12) |p| (QREFELT $ 55))
                     . #1#)
               (COND
                ((ATOM (|SPADfirst| |args|))
                 (LETT |opa| (|MMLFORM;stringify| (|SPADfirst| |args|) $)
                       . #1#))
                (#2#
                 (SEQ (LETT |la| (|SPADfirst| |args|) . #1#)
                      (EXIT
                       (LETT |opa| (|MMLFORM;stringify| (|SPADfirst| |la|) $)
                             . #1#)))))
               (COND
                ((OR
                  (OR (OR (EQUAL |opa| "SIGMA") (EQUAL |opa| "SIGMA2"))
                      (EQUAL |opa| "PI"))
                  (EQUAL |opa| "PI2"))
                 (COND
                  ((EQUAL |op| "^")
                   (LETT |s1|
                         (SPADCALL
                          (LIST "<mo>(</mo>"
                                (|MMLFORM;formatMml| (|SPADfirst| |args|)
                                 |opPrec| $)
                                "<mo>)</mo>")
                          (QREFELT $ 30))
                         . #1#))
                  (#2#
                   (LETT |s1|
                         (|MMLFORM;formatMml| (|SPADfirst| |args|) |opPrec| $)
                         . #1#))))
                (#2#
                 (LETT |s1|
                       (|MMLFORM;formatMml| (|SPADfirst| |args|) |opPrec| $)
                       . #1#)))
               (LETT |s2|
                     (|MMLFORM;formatMml| (|SPADfirst| (CDR |args|)) |opPrec|
                      $)
                     . #1#)
               (LETT |op|
                     (COND
                      ((EQUAL |op| "|")
                       (LETT |s|
                             (SPADCALL
                              (LIST "<mrow>" |s1| "</mrow><mo>" |op|
                                    "</mo><mrow>" |s2| "</mrow>")
                              (QREFELT $ 30))
                             . #1#))
                      ((EQUAL |op| "^")
                       (LETT |s|
                             (SPADCALL
                              (LIST "<msup><mrow>" |s1| "</mrow><mrow>" |s2|
                                    "</mrow></msup>")
                              (QREFELT $ 30))
                             . #1#))
                      ((OR (EQUAL |op| "/") (EQUAL |op| "OVER"))
                       (LETT |s|
                             (SPADCALL
                              (LIST "<mfrac><mrow>" |s1| "</mrow><mrow>" |s2|
                                    "</mrow></mfrac>")
                              (QREFELT $ 30))
                             . #1#))
                      ((OR (EQUAL |op| "+->") #2#)
                       (LETT |s|
                             (SPADCALL
                              (LIST "<mrow>" |s1| "</mrow><mo>" |op|
                                    "</mo><mrow>" |s2| "</mrow>")
                              (QREFELT $ 30))
                             . #1#)))
                     . #1#)
               (EXIT
                (|MMLFORM;group| (COND ((OR (EQUAL |op| "OVER") #2#) |s|))
                 $)))))))))) 

(DEFUN |MMLFORM;formatNary| (|op| |args| |prec| $)
  (|MMLFORM;group| (|MMLFORM;formatNaryNoGroup| |op| |args| |prec| $) $)) 

(DEFUN |MMLFORM;formatNaryNoGroup| (|op| |args| |prec| $)
  (PROG (|s| |count| |l| |opa| |la| #1=#:G874 |a| |opPrec| |checkargs| |tmpS|
         |p|)
    (RETURN
     (SEQ (LETT |checkargs| 'NIL . #2=(|MMLFORM;formatNaryNoGroup|))
          (EXIT
           (COND ((NULL |args|) "")
                 (#3='T
                  (SEQ
                   (LETT |p| (SPADCALL |op| (QREFELT $ 13) (QREFELT $ 53))
                         . #2#)
                   (EXIT
                    (COND ((< |p| 1) (|error| "unknown nary op"))
                          (#3#
                           (SEQ
                            (COND
                             ((< 1 (LENGTH |args|))
                              (COND
                               ((< 0
                                   (SPADCALL "ZAG"
                                             (|MMLFORM;stringify|
                                              (|SPADfirst| (CDR |args|)) $)
                                             1 (QREFELT $ 42)))
                                (EXIT
                                 (SEQ
                                  (LETT |tmpS|
                                        (|MMLFORM;stringify|
                                         (|SPADfirst| |args|) $)
                                        . #2#)
                                  (EXIT
                                   (COND
                                    ((< 0
                                        (SPADCALL "ZAG" |tmpS| 1
                                                  (QREFELT $ 42)))
                                     (|MMLFORM;formatZag| |args| $))
                                    (#3#
                                     (SPADCALL
                                      (LIST
                                       (SPADCALL
                                        (|MMLFORM;formatMml|
                                         (|SPADfirst| |args|) (QREFELT $ 8) $)
                                        (SPADCALL "<mo>+</mo>"
                                                  (|MMLFORM;formatZag|
                                                   (CDR |args|) $)
                                                  (QREFELT $ 48))
                                        (QREFELT $ 48)))
                                      (QREFELT $ 30)))))))))))
                            (LETT |op|
                                  (COND ((EQUAL |op| ",") "<mo>,</mo>")
                                        ((EQUAL |op| ";") "<mo>;</mo>")
                                        ((EQUAL |op| "*")
                                         (SEQ (LETT |checkargs| 'T . #2#)
                                              (EXIT "<mo>&#x02062;</mo>")))
                                        ((EQUAL |op| " ")
                                         "<mspace width='0.5em'/>")
                                        ((EQUAL |op| "ROW") "</mtd><mtd>")
                                        ((EQUAL |op| "+")
                                         (SEQ (LETT |checkargs| 'T . #2#)
                                              (EXIT "<mo>+</mo>")))
                                        ((EQUAL |op| "-")
                                         (SEQ (LETT |checkargs| 'T . #2#)
                                              (EXIT "<mo>-</mo>")))
                                        (#3# |op|))
                                  . #2#)
                            (LETT |l| NIL . #2#)
                            (LETT |opPrec|
                                  (SPADCALL (QREFELT $ 14) |p| (QREFELT $ 55))
                                  . #2#)
                            (LETT |count| 1 . #2#)
                            (SEQ (LETT |a| NIL . #2#) (LETT #1# |args| . #2#)
                                 G190
                                 (COND
                                  ((OR (ATOM #1#)
                                       (PROGN (LETT |a| (CAR #1#) . #2#) NIL))
                                   (GO G191)))
                                 (SEQ
                                  (COND
                                   (|checkargs|
                                    (COND
                                     ((< |count| (LENGTH |args|))
                                      (SEQ
                                       (COND
                                        ((ATOM |a|)
                                         (LETT |opa|
                                               (|MMLFORM;stringify| |a| $)
                                               . #2#))
                                        ('T
                                         (SEQ (LETT |la| |a| . #2#)
                                              (EXIT
                                               (LETT |opa|
                                                     (|MMLFORM;stringify|
                                                      (|SPADfirst| |la|) $)
                                                     . #2#)))))
                                       (EXIT
                                        (COND
                                         ((OR
                                           (OR
                                            (OR (EQUAL |opa| "SIGMA")
                                                (EQUAL |opa| "SIGMA2"))
                                            (EQUAL |opa| "PI"))
                                           (EQUAL |opa| "PI2"))
                                          (LETT |l|
                                                (CONS |op|
                                                      (CONS
                                                       (SPADCALL
                                                        (LIST "<mo>(</mo>"
                                                              (|MMLFORM;formatMml|
                                                               |a| |opPrec| $)
                                                              "<mo>)</mo>")
                                                        (QREFELT $ 30))
                                                       |l|))
                                                . #2#))
                                         ('T
                                          (LETT |l|
                                                (CONS |op|
                                                      (CONS
                                                       (|MMLFORM;formatMml| |a|
                                                        |opPrec| $)
                                                       |l|))
                                                . #2#))))))
                                     ('T
                                      (LETT |l|
                                            (CONS |op|
                                                  (CONS
                                                   (|MMLFORM;formatMml| |a|
                                                    |opPrec| $)
                                                   |l|))
                                            . #2#))))
                                   ('T
                                    (LETT |l|
                                          (CONS |op|
                                                (CONS
                                                 (|MMLFORM;formatMml| |a|
                                                  |opPrec| $)
                                                 |l|))
                                          . #2#)))
                                  (EXIT (LETT |count| (+ |count| 1) . #2#)))
                                 (LETT #1# (CDR #1#) . #2#) (GO G190) G191
                                 (EXIT NIL))
                            (LETT |s|
                                  (SPADCALL (REVERSE (CDR |l|)) (QREFELT $ 30))
                                  . #2#)
                            (EXIT
                             (COND
                              ((< |opPrec| |prec|)
                               (|MMLFORM;parenthesize| |s| $))
                              (#3# |s|))))))))))))))) 

(DEFUN |MMLFORM;formatZag| (|args| $)
  (PROG (|op| |tmpZag|)
    (RETURN
     (SEQ (LETT |tmpZag| (|SPADfirst| |args|) . #1=(|MMLFORM;formatZag|))
          (EXIT
           (COND
            ((< 1 (LENGTH |args|))
             (SPADCALL "<mfrac>"
                       (SPADCALL
                        (|MMLFORM;formatMml| (|SPADfirst| (CDR |tmpZag|))
                         (QREFELT $ 8) $)
                        (SPADCALL "<mrow><mn>"
                                  (SPADCALL
                                   (|MMLFORM;formatMml|
                                    (|SPADfirst| (CDR (CDR |tmpZag|)))
                                    (QREFELT $ 8) $)
                                   (SPADCALL "</mn><mo>+</mo>"
                                             (SPADCALL
                                              (|MMLFORM;formatZag| (CDR |args|)
                                               $)
                                              "</mrow></mfrac>" (QREFELT $ 48))
                                             (QREFELT $ 48))
                                   (QREFELT $ 48))
                                  (QREFELT $ 48))
                        (QREFELT $ 48))
                       (QREFELT $ 48)))
            ((SPADCALL (|SPADfirst| |args|) "..." (QREFELT $ 57))
             "<mo>&#x2026;</mo>")
            (#2='T
             (SEQ
              (LETT |op| (|MMLFORM;stringify| (|SPADfirst| |args|) $) . #1#)
              (EXIT
               (COND
                ((< 0 (SPADCALL "ZAG" |op| 1 (QREFELT $ 42)))
                 (SPADCALL "<mfrac>"
                           (SPADCALL
                            (|MMLFORM;formatMml| (|SPADfirst| (CDR |tmpZag|))
                             (QREFELT $ 8) $)
                            (SPADCALL
                             (|MMLFORM;formatMml|
                              (|SPADfirst| (CDR (CDR |tmpZag|))) (QREFELT $ 8)
                              $)
                             "</mfrac>" (QREFELT $ 48))
                            (QREFELT $ 48))
                           (QREFELT $ 48)))
                (#2#
                 (|error|
                  (SPADCALL
                   (SPADCALL
                    "formatZag: Last argument in ZAG construct has unknown operator: "
                    |op| (QREFELT $ 48))
                   (QREFELT $ 58)))))))))))))) 

(DEFUN |MMLFORM;formatZag1| (|args| $)
  (PROG (|tmpZag|)
    (RETURN
     (SEQ (LETT |tmpZag| (|SPADfirst| |args|) |MMLFORM;formatZag1|)
          (EXIT
           (COND
            ((< 1 (LENGTH |args|))
             (SPADCALL "<mfrac>"
                       (SPADCALL
                        (|MMLFORM;formatMml| (|SPADfirst| (CDR |tmpZag|))
                         (QREFELT $ 8) $)
                        (SPADCALL "<mrow><mn>"
                                  (SPADCALL
                                   (|MMLFORM;formatMml|
                                    (|SPADfirst| (CDR (CDR |tmpZag|)))
                                    (QREFELT $ 8) $)
                                   (SPADCALL "</mn><mo>+</mo>"
                                             (SPADCALL
                                              (|MMLFORM;formatZag| (CDR |args|)
                                               $)
                                              "</mrow></mfrac>" (QREFELT $ 48))
                                             (QREFELT $ 48))
                                   (QREFELT $ 48))
                                  (QREFELT $ 48))
                        (QREFELT $ 48))
                       (QREFELT $ 48)))
            ((SPADCALL (|SPADfirst| |args|) "..." (QREFELT $ 57))
             "<mo>&#x2026;</mo>")
            ('T (|error| "formatZag1: Unexpected kind of ZAG")))))))) 

(DEFUN |MMLFORM;formatMml| (|expr| |prec| $)
  (PROG (|op| |nargs| |args| |l| |i| |str| |nstr| |len| |intSplitLen|)
    (RETURN
     (SEQ (LETT |intSplitLen| 20 . #1=(|MMLFORM;formatMml|))
          (EXIT
           (COND
            ((ATOM |expr|)
             (SEQ (LETT |str| (|MMLFORM;stringify| |expr| $) . #1#)
                  (LETT |len| (QCSIZE |str|) . #1#)
                  (EXIT
                   (COND
                    ((FIXP |expr|)
                     (SEQ (LETT |i| |expr| . #1#)
                          (EXIT
                           (COND
                            ((OR (< |i| 0) (< 9 |i|))
                             (|MMLFORM;group|
                              (SEQ (LETT |nstr| "" . #1#)
                                   (SEQ G190
                                        (COND
                                         ((NULL
                                           (< |intSplitLen|
                                              (LETT |len| (QCSIZE |str|)
                                                    . #1#)))
                                          (GO G191)))
                                        (SEQ
                                         (LETT |nstr|
                                               (SPADCALL
                                                (LIST |nstr| " "
                                                      (SPADCALL |str|
                                                                (SPADCALL 1
                                                                          |intSplitLen|
                                                                          (QREFELT
                                                                           $
                                                                           34))
                                                                (QREFELT $
                                                                         35)))
                                                (QREFELT $ 30))
                                               . #1#)
                                         (EXIT
                                          (LETT |str|
                                                (SPADCALL |str|
                                                          (SPADCALL
                                                           (+ |intSplitLen| 1)
                                                           (QREFELT $ 59))
                                                          (QREFELT $ 35))
                                                . #1#)))
                                        NIL (GO G190) G191 (EXIT NIL))
                                   (EXIT
                                    (COND
                                     ((SPADCALL |nstr| (QREFELT $ 60))
                                      (SPADCALL (LIST "<mn>" |str| "</mn>")
                                                (QREFELT $ 30)))
                                     (#2='T
                                      (SEQ
                                       (LETT |nstr|
                                             (COND
                                              ((SPADCALL |str| (QREFELT $ 60))
                                               |nstr|)
                                              (#2#
                                               (SPADCALL
                                                (LIST |nstr| " " |str|)
                                                (QREFELT $ 30))))
                                             . #1#)
                                       (EXIT
                                        (SPADCALL
                                         (LIST "<mn>"
                                               (SPADCALL |nstr|
                                                         (SPADCALL 2
                                                                   (QREFELT $
                                                                            59))
                                                         (QREFELT $ 35))
                                               "</mn>")
                                         (QREFELT $ 30))))))))
                              $))
                            ('T
                             (LETT |str|
                                   (SPADCALL (LIST "<mn>" |str| "</mn>")
                                             (QREFELT $ 30))
                                   . #1#))))))
                    ((EQUAL |str| "%pi") "<mi>&#x003C0;</mi>")
                    ((EQUAL |str| "%e") "<mi>&#x02147;</mi>")
                    ((EQUAL |str| "%i") "<mi>&#x02148;</mi>")
                    (#2#
                     (SEQ
                      (COND
                       ((< 0 |len|)
                        (COND
                         ((SPADCALL (SPADCALL |str| 1 (QREFELT $ 37))
                                    (SPADCALL "%" (QREFELT $ 43))
                                    (QREFELT $ 44))
                          (EXIT (STRCONC (STRCONC "<mi>" |str|) "</mi>"))))))
                      (COND
                       ((< 1 |len|)
                        (COND
                         ((SPADCALL (SPADCALL |str| 1 (QREFELT $ 37))
                                    (QREFELT $ 61))
                          (EXIT
                           (SPADCALL (LIST "<mn>" |str| "</mn>")
                                     (QREFELT $ 30)))))))
                      (COND
                       ((< 0 |len|)
                        (COND
                         ((SPADCALL (SPADCALL |str| 1 (QREFELT $ 37))
                                    (SPADCALL "\"" (QREFELT $ 43))
                                    (QREFELT $ 44))
                          (EXIT
                           (STRCONC (STRCONC "<mtext>" |str|) "</mtext>"))))))
                      (COND
                       ((EQL |len| 1)
                        (COND
                         ((SPADCALL (SPADCALL |str| 1 (QREFELT $ 37))
                                    (SPADCALL " " (QREFELT $ 43))
                                    (QREFELT $ 44))
                          (EXIT " ")))))
                      (LETT |i| (SPADCALL |str| (QREFELT $ 19) (QREFELT $ 53))
                            . #1#)
                      (EXIT
                       (COND
                        ((< 0 |i|)
                         (SPADCALL (QREFELT $ 20) |i| (QREFELT $ 52)))
                        (#2#
                         (SEQ
                          (LETT |i|
                                (SPADCALL (SPADCALL " " (QREFELT $ 43)) |str|
                                          (QREFELT $ 62))
                                . #1#)
                          (EXIT
                           (COND
                            ((< 0 |i|)
                             (STRCONC (STRCONC "<mtext>" |str|) "</mtext>"))
                            (#2#
                             (SPADCALL (LIST "<mi>" |str| "</mi>")
                                       (QREFELT $ 30)))))))))))))))
            (#2#
             (SEQ (LETT |l| |expr| . #1#)
                  (EXIT
                   (COND ((NULL |l|) (QREFELT $ 6))
                         (#2#
                          (SEQ
                           (LETT |op| (|MMLFORM;stringify| (|SPADfirst| |l|) $)
                                 . #1#)
                           (LETT |args| (CDR |l|) . #1#)
                           (LETT |nargs| (LENGTH |args|) . #1#)
                           (EXIT
                            (COND
                             ((< 0 (SPADCALL "SUPERSUB" |op| 1 (QREFELT $ 42)))
                              (|MMLFORM;formatSuperSub| (|SPADfirst| |l|)
                               |args| (QREFELT $ 8) $))
                             ((< 0 (SPADCALL "SUB" |op| 1 (QREFELT $ 42)))
                              (|MMLFORM;formatSub1| (|SPADfirst| |l|) |args|
                               (QREFELT $ 8) $))
                             ((SPADCALL |op| (QREFELT $ 18) (QREFELT $ 63))
                              (|MMLFORM;formatSpecial| |op| |args| |prec| $))
                             ((SPADCALL |op| (QREFELT $ 16) (QREFELT $ 63))
                              (|MMLFORM;formatPlex| |op| |args| |prec| $))
                             ((EQL 0 |nargs|) (|MMLFORM;formatNullary| |op| $))
                             (#2#
                              (SEQ
                               (COND
                                ((EQL 1 |nargs|)
                                 (COND
                                  ((SPADCALL |op| (QREFELT $ 9) (QREFELT $ 63))
                                   (EXIT
                                    (|MMLFORM;formatUnary| |op|
                                     (|SPADfirst| |args|) |prec| $))))))
                               (COND
                                ((EQL 2 |nargs|)
                                 (COND
                                  ((SPADCALL |op| (QREFELT $ 11)
                                             (QREFELT $ 63))
                                   (EXIT
                                    (|MMLFORM;formatBinary| |op| |args| |prec|
                                     $))))))
                               (EXIT
                                (COND
                                 ((SPADCALL |op| (QREFELT $ 15) (QREFELT $ 63))
                                  (|MMLFORM;formatNaryNoGroup| |op| |args|
                                   |prec| $))
                                 ((SPADCALL |op| (QREFELT $ 13) (QREFELT $ 63))
                                  (|MMLFORM;formatNary| |op| |args| |prec| $))
                                 (#2#
                                  (SEQ
                                   (LETT |op|
                                         (|MMLFORM;formatMml| (|SPADfirst| |l|)
                                          (QREFELT $ 8) $)
                                         . #1#)
                                   (EXIT
                                    (|MMLFORM;formatFunction| |op| |args|
                                     |prec| $)))))))))))))))))))))) 

(DEFUN |MathMLFormat| #1=()
  (PROG #1#
    (RETURN
     (PROG (#2=#:G913)
       (RETURN
        (COND
         ((LETT #2# (HGET |$ConstructorCache| '|MathMLFormat|)
                . #3=(|MathMLFormat|))
          (|CDRwithIncrement| (CDAR #2#)))
         ('T
          (UNWIND-PROTECT
              (PROG1
                  (CDDAR
                   (HPUT |$ConstructorCache| '|MathMLFormat|
                         (LIST (CONS NIL (CONS 1 (|MathMLFormat;|))))))
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#) (HREM |$ConstructorCache| '|MathMLFormat|))))))))))) 

(DEFUN |MathMLFormat;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
     (PROGN
      (LETT |dv$| '(|MathMLFormat|) . #1=(|MathMLFormat|))
      (LETT $ (GETREFV 65) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|MathMLFormat| NIL (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 " \\  ")
      (QSETREFV $ 7 1000000)
      (QSETREFV $ 8 0)
      (QSETREFV $ 9 (LIST #2="-"))
      (QSETREFV $ 10 '(700))
      (QSETREFV $ 11 (LIST "+->" "|" "^" "/" "<" ">" "=" "OVER"))
      (QSETREFV $ 12 (LIST 0 0 900 700 400 400 400 700))
      (QSETREFV $ 13
                (LIST #2# "+" "*" (QREFELT $ 6) "," ";" " " #3="ROW" ""
                      " \\cr " #4="&" "</mtd></mtr><mtr><mtd>"))
      (QSETREFV $ 14 (LIST 700 700 800 800 110 110 0 0 0 0 0 0))
      (QSETREFV $ 15 (LIST #3# #4#))
      (QSETREFV $ 16
                (LIST "SIGMA" "SIGMA2" "PI" "PI2" "INTSIGN" "INDEFINTEGRAL"))
      (QSETREFV $ 17 '(700 800 700 800 700 700))
      (QSETREFV $ 18
                (LIST "MATRIX" "BRACKET" "BRACE" "CONCATB" "VCONCAT" "AGGLST"
                      "CONCAT" "OVERBAR" "ROOT" "SUB" "TAG" "SUPERSUB" "ZAG"
                      "AGGSET" "SC" "PAREN" "SEGMENT" "QUOTE" "theMap"
                      "SLASH"))
      (QSETREFV $ 19
                (LIST "cos" "cot" "csc" "log" "sec" "sin" "tan" "cosh" "coth"
                      "csch" "sech" "sinh" "tanh" "acos" "asin" "atan" "erf"
                      "..." "$" "infinity" "Gamma"))
      (QSETREFV $ 20
                (LIST "<mo>cos</mo>" "<mo>cot</mo>" "<mo>csc</mo>"
                      "<mo>log</mo>" "<mo>sec</mo>" "<mo>sin</mo>"
                      "<mo>tan</mo>" "<mo>cosh</mo>" "<mo>coth</mo>"
                      "<mo>csch</mo>" "<mo>sech</mo>" "<mo>sinh</mo>"
                      "<mo>tanh</mo>" "<mo>arccos</mo>" "<mo>arcsin</mo>"
                      "<mo>arctan</mo>" "<mo>erf</mo>" "<mo>&#x2026;</mo>"
                      "<mo>$</mo>" "<mo>&#x221E;</mo>" "<mo>&#x0413;</mo>"))
      $)))) 

(MAKEPROP '|MathMLFormat| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL '|blank| '|maxPrec| '|minPrec|
              '|unaryOps| '|unaryPrecs| '|binaryOps| '|binaryPrecs| '|naryOps|
              '|naryPrecs| '|naryNGOps| '|plexOps| '|plexPrecs| '|specialOps|
              '|specialStrings| '|specialStringsInMML| (|String|)
              (|OutputForm|) |MMLFORM;coerce;OfS;1| |MMLFORM;coerceS;OfS;2|
              |MMLFORM;coerceL;OfS;3| (|Void|) (0 . |void|)
              |MMLFORM;display;SV;4| (|List| $) (4 . |concat|)
              |MMLFORM;exprex;OfS;5| (|Integer|) (|UniversalSegment| 32)
              (9 . |segment|) (15 . |elt|) (|Character|) (21 . |elt|)
              (|CharacterClass|) (27 . |lowerCase|) (|Boolean|)
              (31 . |member?|) (37 . |position|) (44 . |char|) (49 . =)
              (|List| 22) (55 . |list|) (60 . |second|) (65 . |elt|)
              (|List| 21) (71 . |list|) (76 . |elt|) (82 . |elt|)
              (88 . |position|) (|List| 32) (94 . |elt|) (100 . |last|)
              (105 . =) (111 . |coerce|) (116 . |segment|) (121 . |empty?|)
              (126 . |digit?|) (131 . |position|) (137 . |member?|)
              (|SingleInteger|))
           '#(~= 143 |latex| 149 |hash| 154 |exprex| 159 |display| 164
              |coerceS| 169 |coerceL| 174 |coerce| 179 = 189)
           'NIL
           (CONS (|makeByteWordVec2| 1 '(0 0 0))
                 (CONS '#(|SetCategory&| |BasicType&| NIL)
                       (CONS
                        '#((|SetCategory|) (|BasicType|) (|CoercibleTo| 22))
                        (|makeByteWordVec2| 64
                                            '(0 26 0 27 1 21 0 29 30 2 33 0 32
                                              32 34 2 21 0 0 33 35 2 21 36 0 32
                                              37 0 38 0 39 2 38 40 36 0 41 3 21
                                              32 0 0 32 42 1 36 0 21 43 2 36 40
                                              0 0 44 1 45 0 22 46 1 45 22 0 47
                                              2 21 0 0 0 48 1 49 0 21 50 2 45
                                              22 0 32 51 2 49 21 0 32 52 2 49
                                              32 21 0 53 2 54 32 0 32 55 1 45
                                              22 0 56 2 22 40 0 0 57 1 21 22 0
                                              58 1 33 0 32 59 1 21 40 0 60 1 36
                                              40 0 61 2 21 32 36 0 62 2 49 40
                                              21 0 63 2 0 40 0 0 1 1 0 21 0 1 1
                                              0 64 0 1 1 0 21 22 31 1 0 26 21
                                              28 1 0 21 22 24 1 0 21 22 25 1 0
                                              21 22 23 1 0 22 0 1 2 0 40 0 0
                                              1)))))
           '|lookupComplete|)) 

(MAKEPROP '|MathMLFormat| 'NILADIC T) 
