0N/ADescription : Interface to the theorem prover e-krhyper in CASC-mode.
0N/ACopyright : (c) Dominik Luecke, Uni Bremen 2010
0N/ALicense : GPLv2 or higher
157N/AMaintainer : luecke@informatik.uni-bremen.de
0N/AStability : provisional
0N/APortability : needs POSIX
0N/Afor details. For the ease of maintenance we are using e-krhyper in
157N/Aits CASC-mode, aka tptp-input. It works for single input files and
0N/A{- | The Prover implementation. -}
0N/AhyperProver :: Prover Sign Sentence SoftFOLMorphism () ProofTree
0N/AhyperProver = mkAutomaticProver "ekrhyper" () hyperGUI hyperCMDLautomaticBatch
0N/A Record for prover specific functions. This is used by both GUI and command
0N/AatpFun :: String -- ^ theory name
-> ATPFunctions Sign Sentence SoftFOLMorphism ProofTree SoftFOLProverState
atpFun thName = ATPFunctions
{ initialProverState = spassProverState
, atpTransSenName = transSenName
, atpInsertSentence = insertSentenceGen
, goalOutput = showTPTPProblem thName
, proverHelpText = "for more information visit " ++
, batchTimeEnv = "HETS_HYPER_BATCH_TIME_LIMIT"
, fileExtensions = FileExtensions
{ problemOutput = ".tptp"
, proverOutput = ".hyper"
, theoryConfiguration = ".hypcf" }
, createProverOptions = extraOpts }
Invokes the generic prover GUI.
hyperGUI :: String -- ^ theory name
-> Theory Sign Sentence ProofTree
-> [FreeDefMorphism SPTerm SoftFOLMorphism] -- ^ freeness constraints
-> IO([ProofStatus ProofTree]) -- ^ proof status for each goal
hyperGUI thName th freedefs =
genericATPgui (atpFun thName) True (proverName hyperProver) thName th
automatic command line interface to the prover.
hyperCMDLautomaticBatch ::
Bool -- ^ True means include proved theorems
-> Bool -- ^ True means save problem file
-- ^ used to store the result of the batch run
-> String -- ^ theory name
-> TacticScript -- ^ default tactic script
-> Theory Sign Sentence ProofTree -- ^ theory consisting of a
-> [FreeDefMorphism SPTerm SoftFOLMorphism] -- ^ freeness constraints
-- ^ fst: identifier of the batch thread for killing it
-- snd: MVar to wait for the end of the thread
hyperCMDLautomaticBatch inclProvedThs saveProblem_batch resultMVar
thName defTS th freedefs =
genericCMDLautomaticBatch (atpFun thName) inclProvedThs saveProblem_batch
resultMVar (proverName hyperProver) thName
(parseTacticScript batchTimeLimit [] defTS) th freedefs emptyProofTree
prelTxt :: String -> String
"% only print essential output\n" ++
"#(set_verbosity(1)).\n\n" ++
"% assume all input to be in tptp-syntax\n" ++
"#(set_parameter(input_type, 2)).\n\n" ++
"% To prevent blowing up my memory\n" ++
"#(set_memory_limit(500)).\n\n" ++
"% produce SZS results\n" ++
"#(set_flag(szs_output_flag, true)).\n\n" ++
"% do not use special evaluable symbols\n" ++
"#(clear_builtins).\n\n" ++
"% initial term weight bound, 3 recommended for TPTP-problems\n" ++
"#(set_parameter(max_weight_initial, 3)).\n\n" ++
"% Terminate if out of memory\n" ++
"#(set_parameter(limit_termination_method,0)).\n\n" ++
"% Terminate if out of time\n" ++
"#(set_parameter(timeout_termination_method,0)).\n\n" ++
"#(start_wallclock_timer("++ t ++".0)).\n"
uniteOptions :: [String] -> [String]
if ("#(" `isPrefixOf` a && ")." `isSuffixOf` a)
(a ++ b):(uniteOptions cs)
"% start derivation with the input received so far\n" ++
"% print normal E-KRHyper proof\n" ++
"%#(print_proof).\n\n" ++
"% print result and proof using SZS terminology;\n" ++
"% requires postprocessing with post_szs script for proper legibility\n" ++
runHyper :: 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
-> IO (ATPRetval, GenericConfig ProofTree)
-- ^ (retval, configuration with proof status and complete output)
runHyper sps cfg saveTPTP thName nGoal =
tmpFile = (reverse $ fst $ span (/='/') $ reverse thName) ++
prelFile = "prelude_" ++ (reverse $ fst $ span (/='/') $ reverse
runFile = "run_" ++ (reverse $ fst $ span (/='/') $ reverse
simpleOptions = uniteOptions $ extraOpts cfg
let chk = and $ map (\x ->
prob <- showTPTPProblem thName sps nGoal $ []
(writeFile (saveFile ++".tptp") prob)
let stpTmpFile = "/tmp/" ++ tmpFile ++ (show $ utctDay t) ++
"-" ++ (show $ utctDayTime t) ++ ".tptp"
stpPrelFile = "/tmp/" ++ prelFile ++ (show $ utctDay t) ++
"-" ++ (show $ utctDayTime t) ++ ".tme"
stpRunFile = "/tmp/" ++ runFile ++ (show $ utctDay t) ++
"-" ++ (show $ utctDayTime t) ++ ".tme"
((prelTxt $ show tl) ++ "\n" ++ unlines
writeFile stpRunFile $ runTxt
writeFile stpTmpFile $ prob
let command = "ekrh " ++ stpPrelFile ++ " " ++ stpTmpFile ++
(_, stdouth, stderrh, proch) <- runInteractiveCommand command
let t_u = diffHetsTime t_end t_start
stdoutC <- hGetContents stdouth
stderrC <- hGetContents stderrh
(pStat, ret) <- examineProof sps cfg stdoutC stderrC nGoal t_u tl
, resultOutput = lines (stdoutC ++ stderrC)
, timeUsed = usedTime ret
let tScript opts = TacticScript $ show ATPTacticScript
{ tsTimeLimit = configTimeLimit cfg
(ATPError "Syntax error in options"
ProofStatus { goalName = senAttr nGoal
, goalStatus = openGoalStatus
, usedProver = proverName hyperProver
, proofTree = emptyProofTree
, tacticScript = tScript $
(\x -> "#" `isPrefixOf` x)$
lines $ (prelTxt $ show tl)
, resultOutput = ["Parse Error"]
{- | Mapping type from SZS to Hets -}
data HyperResult = HProved | HDisproved | HTimeout | HError | HMemout
getHyperResult :: [String] -> HyperResult
getHyperResult out = case map (takeWhile isAlpha . dropWhile isSpace)
$ mapMaybe (stripPrefix "% SZS status ") out of
[s] | szsProved s -> HProved
| szsDisproved s -> HDisproved
| szsTimeout s -> HTimeout
| szsMemoryOut s -> HMemout
{- | examine SZS output -}
examineProof :: SoftFOLProverState
-> GenericConfig ProofTree
-> IO (ATPRetval, ProofStatus ProofTree)
examineProof sps cfg stdoutC stderrC nGoal tUsed tl =
tScript opts = TacticScript $ show ATPTacticScript
{ tsTimeLimit = configTimeLimit cfg
ProofStatus { goalName = senAttr nGoal
, goalStatus = openGoalStatus
, usedProver = proverName hyperProver
, proofTree = emptyProofTree
, tacticScript = tScript $ (filter
(\x -> "#" `isPrefixOf` x) $
lines $ (prelTxt $ show tl) ++ runTxt)}
fl = formulaLists $ initialLogicalPart sps
fs = concatMap formulae $ filter (\x ->
in case getHyperResult $ lines stdoutC of
HProved -> return (ATPSuccess, defaultStatus
, proofTree = ProofTree stdoutC
HTimeout -> return (ATPTLimitExceeded, defaultStatus)
HDisproved -> return (ATPSuccess, defaultStatus
, proofTree = ProofTree stdoutC
HMemout -> return (ATPError ("Out of Memory."
++ "\nOutput was:\n\n" ++
HError -> return (ATPError ("Internal Error in ekrhyper."
++ "\nOutput was:\n\n" ++
hyperConsChecker :: ConsChecker Sign Sentence () SoftFOLMorphism ProofTree
hyperConsChecker = (mkConsChecker "ekrhyper" () consCheck)
Runs the krhyper cons-chcker. The tactic script only contains a string for the
"% start derivation with the input received so far\n" ++
"% print normal E-KRHyper proof\n" ++
"%#(print_proof).\n\n" ++
"% print result and proof using SZS terminology;\n" ++
"% requires postprocessing with post_szs script for proper legibility\n" ++
"%#(print_szs_proof).\n\n" ++
-> TheoryMorphism Sign Sentence SoftFOLMorphism ProofTree
-> [FreeDefMorphism SPTerm SoftFOLMorphism] -- ^ freeness constraints
-> IO(CCStatus ProofTree)
consCheck thName (TacticScript tl) tm freedefs =
proverStateI = spassProverState sig (toNamedList nSens) freedefs
problem = showTPTPProblemM thName proverStateI []
saveFile = reverse $ fst $ span (/= '/') $ reverse thName
tmpFile = (reverse $ fst $ span (/='/') $ reverse thName)
prelFile = "prelude_" ++ (reverse $ fst $ span (/='/') $ reverse
runFile = "run_" ++ (reverse $ fst $ span (/='/') $ reverse
(writeFile (saveFile ++".tptp") prob)
let stpTmpFile = "/tmp/" ++ tmpFile ++ (show $ utctDay t) ++
"-" ++ (show $ utctDayTime t) ++ ".tptp"
stpPrelFile = "/tmp/" ++ prelFile ++ (show $ utctDay t) ++
"-" ++ (show $ utctDayTime t) ++ ".tme"
stpRunFile = "/tmp/" ++ runFile ++ (show $ utctDay t) ++
"-" ++ (show $ utctDayTime t) ++ ".tme"
writeFile stpPrelFile $ prelTxt tl
writeFile stpRunFile $ runTxtC
writeFile stpTmpFile $ prob
let command = "ekrh " ++ stpPrelFile ++ " " ++ stpTmpFile ++
(_, stdouth, stderrh, proch) <- runInteractiveCommand command
stdoutC <- hGetContents stdouth
stderrC <- hGetContents stderrh
let t_u = diffHetsTime t_end t_start
, ccProofTree = ProofTree $ stdoutC ++ stderrC
case getHyperResult $ lines stdoutC of
HProved -> return outstate
HDisproved -> return outstate