trSentence ::  DLSign -> FORMULA DL_FORMULA -> Result (FORMULA ())
trSentence inSig inF =
      case inF of
        Quantification qf vs frm rn ->
            do
              outF <- trSentence inSig frm
              return (Quantification qf vs outF rn)
        Conjunction fns rn ->
            do
              outF <- mapR (trSentence inSig) fns
              return (Conjunction outF rn)
        Disjunction fns rn ->
            do
              outF <- mapR (trSentence inSig) fns
              return (Disjunction outF rn)
        Implication f1 f2 b rn ->
            do
              out1 <- trSentence inSig f1
              out2 <- trSentence inSig f2
              return (Implication out1 out2 b rn)
        Equivalence f1 f2 rn ->
            do
              out1 <- trSentence inSig f1
              out2 <- trSentence inSig f2
              return (Equivalence out1 out2 rn)
        Negation frm rn ->
            do
              outF <- trSentence inSig frm
              return (Negation outF rn)
        True_atom rn -> return (True_atom rn)
        False_atom rn -> return (False_atom rn)
        Predication pr trm rn ->
            do
              ot <- mapR (trTerm inSig) trm
              return (Predication pr ot rn)
        Definedness tm rn ->
            do
              ot <- trTerm inSig tm
              return (Definedness ot rn)
        Existl_equation t1 t2 rn ->
            do
              ot1 <- trTerm inSig t1
              ot2 <- trTerm inSig t2
              return (Existl_equation ot1 ot2 rn)
        Strong_equation t1 t2 rn ->
            do
              ot1 <- trTerm inSig t1
              ot2 <- trTerm inSig t2
              return (Strong_equation ot1 ot2 rn)
        Membership t1 st rn ->
            do
              ot <- trTerm inSig t1
              return (Membership ot st rn)
        Mixfix_formula trm ->
             do
              ot <- trTerm inSig trm
              return (Mixfix_formula ot)
        Unparsed_formula str rn ->
            return (Unparsed_formula str rn)
        Sort_gen_ax cstr ft ->
            return (Sort_gen_ax cstr ft)
        QuantOp _ _ _ -> fail "CASL_DL2CASL.QuantOp"
        QuantPred _ _ _ -> fail "CASL_DL2CASL.QuantPred"
        ExtFORMULA form ->
            case form of
              Cardinality _ _ _ _ _ _ ->
                    fail "Mapping of cardinality not implemented"

-- ^ translation of terms
trSentence ::  DLSign -> FORMULA DL_FORMULA -> Result (FORMULA ())
trSentence inSig inF =
      case inF of
        Quantification qf vs frm rn ->
            do
              outF <- trSentence inSig frm
              return (Quantification qf vs outF rn)
        Conjunction fns rn ->
            do
              outF <- mapR (trSentence inSig) fns
              return (Conjunction outF rn)
        Disjunction fns rn ->
            do
              outF <- mapR (trSentence inSig) fns
              return (Disjunction outF rn)
        Implication f1 f2 b rn ->
            do
              out1 <- trSentence inSig f1
              out2 <- trSentence inSig f2
              return (Implication out1 out2 b rn)
        Equivalence f1 f2 rn ->
            do
              out1 <- trSentence inSig f1
              out2 <- trSentence inSig f2
              return (Equivalence out1 out2 rn)
        Negation frm rn ->
            do
              outF <- trSentence inSig frm
              return (Negation outF rn)
        True_atom rn -> return (True_atom rn)
        False_atom rn -> return (False_atom rn)
        Predication pr trm rn ->
            do
              ot <- mapR (trTerm inSig) trm
              return (Predication pr ot rn)
        Definedness tm rn ->
            do
              ot <- trTerm inSig tm
              return (Definedness ot rn)
        Existl_equation t1 t2 rn ->
            do
              ot1 <- trTerm inSig t1
              ot2 <- trTerm inSig t2
              return (Existl_equation ot1 ot2 rn)
        Strong_equation t1 t2 rn ->
            do
              ot1 <- trTerm inSig t1
              ot2 <- trTerm inSig t2
              return (Strong_equation ot1 ot2 rn)
        Membership t1 st rn ->
            do
              ot <- trTerm inSig t1
              return (Membership ot st rn)
        Mixfix_formula trm ->
             do
              ot <- trTerm inSig trm
              return (Mixfix_formula ot)
        Unparsed_formula str rn ->
            return (Unparsed_formula str rn)
        Sort_gen_ax cstr ft ->
            return (Sort_gen_ax cstr ft)
        QuantOp _ _ _ -> fail "CASL_DL2CASL.QuantOp"
        QuantPred _ _ _ -> fail "CASL_DL2CASL.QuantPred"
        ExtFORMULA form ->
            case form of
              Cardinality _ _ _ _ _ _ ->
                    fail "Mapping of cardinality not implemented"

-- ^ translation of terms
trSentence inSig inF =
      case inF of
        Quantification qf vs frm rn ->
            do
              outF <- trSentence inSig frm
              return (Quantification qf vs outF rn)
        Conjunction fns rn ->
            do
              outF <- mapR (trSentence inSig) fns
              return (Conjunction outF rn)
        Disjunction fns rn ->
            do
              outF <- mapR (trSentence inSig) fns
              return (Disjunction outF rn)
        Implication f1 f2 b rn ->
            do
              out1 <- trSentence inSig f1
              out2 <- trSentence inSig f2
              return (Implication out1 out2 b rn)
        Equivalence f1 f2 rn ->
            do
              out1 <- trSentence inSig f1
              out2 <- trSentence inSig f2
              return (Equivalence out1 out2 rn)
        Negation frm rn ->
            do
              outF <- trSentence inSig frm
              return (Negation outF rn)
        True_atom rn -> return (True_atom rn)
        False_atom rn -> return (False_atom rn)
        Predication pr trm rn ->
            do
              ot <- mapR (trTerm inSig) trm
              return (Predication pr ot rn)
        Definedness tm rn ->
            do
              ot <- trTerm inSig tm
              return (Definedness ot rn)
        Existl_equation t1 t2 rn ->
            do
              ot1 <- trTerm inSig t1
              ot2 <- trTerm inSig t2
              return (Existl_equation ot1 ot2 rn)
        Strong_equation t1 t2 rn ->
            do
              ot1 <- trTerm inSig t1
              ot2 <- trTerm inSig t2
              return (Strong_equation ot1 ot2 rn)
        Membership t1 st rn ->
            do
              ot <- trTerm inSig t1
              return (Membership ot st rn)
        Mixfix_formula trm ->
             do
              ot <- trTerm inSig trm
              return (Mixfix_formula ot)
        Unparsed_formula str rn ->
            return (Unparsed_formula str rn)
        Sort_gen_ax cstr ft ->
            return (Sort_gen_ax cstr ft)
        QuantOp _ _ _ -> fail "CASL_DL2CASL.QuantOp"
        QuantPred _ _ _ -> fail "CASL_DL2CASL.QuantPred"
        ExtFORMULA form ->
            case form of
              Cardinality _ _ _ _ _ _ ->
                    fail "Mapping of cardinality not implemented"

-- ^ translation of terms