runMetis :: SoftFOLProverState
           {- ^ logical part containing the input Sign and axioms and possibly
           goals that have been proved earlier as additional axioms -}
           -> GenericConfig ProofTree -- ^ configuration to use
           -> Bool -- ^ True means save TPTP file
           -> String -- ^ name of the theory in the DevGraph
           -> AS_Anno.Named SPTerm -- ^ goal to prove
           -> IO (ATPRetval, GenericConfig ProofTree)
           -- ^ (retval, configuration with proof status and complete output)
runMetis sps cfg saveTPTP thName nGoal = do
  let saveFile = basename thName ++ '_' : AS_Anno.senAttr nGoal ++ ".tptp"
  prob <- showTPTPProblem thName sps nGoal []
  when saveTPTP (writeFile saveFile prob)
  timeTmpFile <- getTempFile prob saveFile
  start <- getHetsTime
  -- try timeout using perl
  (ex, out, err) <- executeProcess "perl"
    ["-e", "alarm shift @ARGV; exec @ARGV"
    , show (configTimeLimit cfg), "metis", timeTmpFile] ""
  finish <- getHetsTime
  let executetime = diffHetsTime finish start
      newCfg = cfg
        { timeUsed = executetime
        , proofStatus = (proofStatus cfg) {usedTime = executetime}}
      finCfg = newCfg { resultOutput = lines $ out ++ err }
  removeFile timeTmpFile
  return $ case ex of
         ExitSuccess ->
           ( ATPSuccess
           , finCfg
             { proofStatus = (proofStatus finCfg)
               { usedAxioms = getAxioms sps
               , goalStatus = getGoalStatus out }})
         ExitFailure e -> if e == 14 then
           ( ATPTLimitExceeded
           , newCfg
               { timeLimitExceeded = True
               , resultOutput = ["TimeOut"] })
           else (ATPError err, finCfg)

{-
  mapping from SZS Status to Goalstatus
-}
runMetis :: SoftFOLProverState
           {- ^ logical part containing the input Sign and axioms and possibly
           goals that have been proved earlier as additional axioms -}
           -> GenericConfig ProofTree -- ^ configuration to use
           -> Bool -- ^ True means save TPTP file
           -> String -- ^ name of the theory in the DevGraph
           -> AS_Anno.Named SPTerm -- ^ goal to prove
           -> IO (ATPRetval, GenericConfig ProofTree)
runMetis sps cfg saveTPTP thName nGoal = do
  let saveFile = basename thName ++ '_' : AS_Anno.senAttr nGoal ++ ".tptp"
  prob <- showTPTPProblem thName sps nGoal []
  when saveTPTP (writeFile saveFile prob)
  timeTmpFile <- getTempFile prob saveFile
  start <- getHetsTime
  -- try timeout using perl
  (ex, out, err) <- executeProcess "perl"
    ["-e", "alarm shift @ARGV; exec @ARGV"
    , show (configTimeLimit cfg), "metis", timeTmpFile] ""
  finish <- getHetsTime
  let executetime = diffHetsTime finish start
      newCfg = cfg
        { timeUsed = executetime
        , proofStatus = (proofStatus cfg) {usedTime = executetime}}
      finCfg = newCfg { resultOutput = lines $ out ++ err }
  removeFile timeTmpFile
  return $ case ex of
         ExitSuccess ->
           ( ATPSuccess
           , finCfg
             { proofStatus = (proofStatus finCfg)
               { usedAxioms = getAxioms sps
               , goalStatus = getGoalStatus out }})
         ExitFailure e -> if e == 14 then
           ( ATPTLimitExceeded
           , newCfg
               { timeLimitExceeded = True
               , resultOutput = ["TimeOut"] })
           else (ATPError err, finCfg)

{-
  mapping from SZS Status to Goalstatus
-}
runMetis sps cfg saveTPTP thName nGoal = do
  let saveFile = basename thName ++ '_' : AS_Anno.senAttr nGoal ++ ".tptp"
  prob <- showTPTPProblem thName sps nGoal []
  when saveTPTP (writeFile saveFile prob)
  timeTmpFile <- getTempFile prob saveFile
  start <- getHetsTime
  -- try timeout using perl
  (ex, out, err) <- executeProcess "perl"
    ["-e", "alarm shift @ARGV; exec @ARGV"
    , show (configTimeLimit cfg), "metis", timeTmpFile] ""
  finish <- getHetsTime
  let executetime = diffHetsTime finish start
      newCfg = cfg
        { timeUsed = executetime
        , proofStatus = (proofStatus cfg) {usedTime = executetime}}
      finCfg = newCfg { resultOutput = lines $ out ++ err }
  removeFile timeTmpFile
  return $ case ex of
         ExitSuccess ->
           ( ATPSuccess
           , finCfg
             { proofStatus = (proofStatus finCfg)
               { usedAxioms = getAxioms sps
               , goalStatus = getGoalStatus out }})
         ExitFailure e -> if e == 14 then
           ( ATPTLimitExceeded
           , newCfg
               { timeLimitExceeded = True
               , resultOutput = ["TimeOut"] })
           else (ATPError err, finCfg)

{-
  mapping from SZS Status to Goalstatus
-}