convertRecord :: Int -> (f -> f) -> Record f (FORMULA f) (TERM f)
convertRecord n mf = (mapRecord mf)
    { foldQuantification = \ orig _ _ _ _ ->
      let Quantification q vs qf ps = orig
          nvs = flatVAR_DECLs vs
          mkVar i = mkSimpleId $ 'v' : show i
          rvs = map mkVar [n .. ]
          nf = replaceVarsF (Map.fromList $ zipWith ( \ (v, s) i ->
                             (v, Qual_var i s ps)) nvs rvs) mf
               $ convertFormula (n + length nvs) mf qf
      in foldr ( \ (v, s) cf ->
           Quantification q [Var_decl [v] s ps] cf ps)
             nf $ zip rvs $ map snd nvs
    }
convertRecord :: Int -> (f -> f) -> Record f (FORMULA f) (TERM f)
convertRecord n mf = (mapRecord mf)
    { foldQuantification = \ orig _ _ _ _ ->
      let Quantification q vs qf ps = orig
          nvs = flatVAR_DECLs vs
          mkVar i = mkSimpleId $ 'v' : show i
          rvs = map mkVar [n .. ]
          nf = replaceVarsF (Map.fromList $ zipWith ( \ (v, s) i ->
                             (v, Qual_var i s ps)) nvs rvs) mf
               $ convertFormula (n + length nvs) mf qf
      in foldr ( \ (v, s) cf ->
           Quantification q [Var_decl [v] s ps] cf ps)
             nf $ zip rvs $ map snd nvs
    }
convertRecord n mf = (mapRecord mf)
    { foldQuantification = \ orig _ _ _ _ ->
      let Quantification q vs qf ps = orig
          nvs = flatVAR_DECLs vs
          mkVar i = mkSimpleId $ 'v' : show i
          rvs = map mkVar [n .. ]
          nf = replaceVarsF (Map.fromList $ zipWith ( \ (v, s) i ->
                             (v, Qual_var i s ps)) nvs rvs) mf
               $ convertFormula (n + length nvs) mf qf
      in foldr ( \ (v, s) cf ->
           Quantification q [Var_decl [v] s ps] cf ps)
             nf $ zip rvs $ map snd nvs
    }