trTerm :: DLSign -> TERM DL_FORMULA -> Result (TERM ())
trTerm inSig inF =
    case inF of
      Qual_var v s rn -> return (Qual_var v s rn)
      Application os tms rn ->
          do
            ot <- mapR (trTerm inSig) tms
            return (Application os ot rn)
      Sorted_term trm st rn ->
          do
            ot <- trTerm inSig trm
            return (Sorted_term ot st rn)
      Cast trm st rn ->
          do
            ot <- trTerm inSig trm
            return (Cast ot st rn)
      Conditional t1 frm t2 rn ->
          do
            ot1 <- trTerm inSig t1
            ot2 <- trTerm inSig t2
            of1 <- trSentence inSig frm
            return (Conditional ot1 of1 ot2 rn)
      Unparsed_term str rn -> return (Unparsed_term str rn)
      Mixfix_qual_pred ps  -> return (Mixfix_qual_pred ps)
      Mixfix_term trm ->
          do
            ot <- mapR (trTerm inSig) trm
            return (Mixfix_term ot)
      Mixfix_token tok         -> return (Mixfix_token tok)
      Mixfix_sorted_term st rn -> return (Mixfix_sorted_term st rn)
      Mixfix_cast st rn        -> return (Mixfix_cast st rn)
      Mixfix_parenthesized trm rn ->
          do
            ot <- mapR (trTerm inSig) trm
            return (Mixfix_parenthesized ot rn)
      Mixfix_bracketed trm rn ->
          do
            ot <- mapR (trTerm inSig) trm
            return (Mixfix_bracketed ot rn)
      Mixfix_braced trm rn ->
          do
            ot <-  mapR (trTerm inSig) trm
            return (Mixfix_braced ot rn)
      ExtTERM _ -> return $ ExtTERM ()
trTerm :: DLSign -> TERM DL_FORMULA -> Result (TERM ())
trTerm inSig inF =
    case inF of
      Qual_var v s rn -> return (Qual_var v s rn)
      Application os tms rn ->
          do
            ot <- mapR (trTerm inSig) tms
            return (Application os ot rn)
      Sorted_term trm st rn ->
          do
            ot <- trTerm inSig trm
            return (Sorted_term ot st rn)
      Cast trm st rn ->
          do
            ot <- trTerm inSig trm
            return (Cast ot st rn)
      Conditional t1 frm t2 rn ->
          do
            ot1 <- trTerm inSig t1
            ot2 <- trTerm inSig t2
            of1 <- trSentence inSig frm
            return (Conditional ot1 of1 ot2 rn)
      Unparsed_term str rn -> return (Unparsed_term str rn)
      Mixfix_qual_pred ps  -> return (Mixfix_qual_pred ps)
      Mixfix_term trm ->
          do
            ot <- mapR (trTerm inSig) trm
            return (Mixfix_term ot)
      Mixfix_token tok         -> return (Mixfix_token tok)
      Mixfix_sorted_term st rn -> return (Mixfix_sorted_term st rn)
      Mixfix_cast st rn        -> return (Mixfix_cast st rn)
      Mixfix_parenthesized trm rn ->
          do
            ot <- mapR (trTerm inSig) trm
            return (Mixfix_parenthesized ot rn)
      Mixfix_bracketed trm rn ->
          do
            ot <- mapR (trTerm inSig) trm
            return (Mixfix_bracketed ot rn)
      Mixfix_braced trm rn ->
          do
            ot <-  mapR (trTerm inSig) trm
            return (Mixfix_braced ot rn)
      ExtTERM _ -> return $ ExtTERM ()
trTerm inSig inF =
    case inF of
      Qual_var v s rn -> return (Qual_var v s rn)
      Application os tms rn ->
          do
            ot <- mapR (trTerm inSig) tms
            return (Application os ot rn)
      Sorted_term trm st rn ->
          do
            ot <- trTerm inSig trm
            return (Sorted_term ot st rn)
      Cast trm st rn ->
          do
            ot <- trTerm inSig trm
            return (Cast ot st rn)
      Conditional t1 frm t2 rn ->
          do
            ot1 <- trTerm inSig t1
            ot2 <- trTerm inSig t2
            of1 <- trSentence inSig frm
            return (Conditional ot1 of1 ot2 rn)
      Unparsed_term str rn -> return (Unparsed_term str rn)
      Mixfix_qual_pred ps  -> return (Mixfix_qual_pred ps)
      Mixfix_term trm ->
          do
            ot <- mapR (trTerm inSig) trm
            return (Mixfix_term ot)
      Mixfix_token tok         -> return (Mixfix_token tok)
      Mixfix_sorted_term st rn -> return (Mixfix_sorted_term st rn)
      Mixfix_cast st rn        -> return (Mixfix_cast st rn)
      Mixfix_parenthesized trm rn ->
          do
            ot <- mapR (trTerm inSig) trm
            return (Mixfix_parenthesized ot rn)
      Mixfix_bracketed trm rn ->
          do
            ot <- mapR (trTerm inSig) trm
            return (Mixfix_bracketed ot rn)
      Mixfix_braced trm rn ->
          do
            ot <-  mapR (trTerm inSig) trm
            return (Mixfix_braced ot rn)
      ExtTERM _ -> return $ ExtTERM ()