ProveDarwin.hs revision 95b3cfab4eca1e97bf707e88684c80afb1ab3b94
842ae4bd224140319ae7feec1872b93dfd491143fieldingModule : $Header$
842ae4bd224140319ae7feec1872b93dfd491143fieldingDescription : Interface to the TPTP theorem prover via Darwin.
842ae4bd224140319ae7feec1872b93dfd491143fieldingCopyright : (c) Heng Jiang, Uni Bremen 2004-2007
842ae4bd224140319ae7feec1872b93dfd491143fieldingLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
842ae4bd224140319ae7feec1872b93dfd491143fieldingMaintainer : jiang@informatik.uni-bremen.de
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingStability : provisional
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcndPortability : needs POSIX
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcndInterface for the Darwin service, uses GUI.GenericATP.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcndSee <http://spass.mpi-sb.mpg.de/> for details on SPASS, and
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding ( darwinProver
92ae63a7151376cfb024555195deb4860af1a90afuankg , darwinCMDLautomaticBatch
92ae63a7151376cfb024555195deb4860af1a90afuankg , darwinConsChecker
92ae63a7151376cfb024555195deb4860af1a90afuankg-- preliminary hacks for display of CASL models
92ae63a7151376cfb024555195deb4860af1a90afuankgimport Common.AS_Annotation as AS_Anno
cccd31fa4a72fe23cc3249c06db181b274a55a69gsteinimport qualified Common.Result as Result
92ae63a7151376cfb024555195deb4860af1a90afuankgimport Data.Char (isDigit)
a50ebe9ca7a0a8e3e9b3f0abd3b9ef55b8dc36c5fuankgimport Data.List (isPrefixOf)
a50ebe9ca7a0a8e3e9b3f0abd3b9ef55b8dc36c5fuankgimport Data.Time (timeToTimeOfDay)
92ae63a7151376cfb024555195deb4860af1a90afuankgimport Data.Time.Clock (UTCTime(..), secondsToDiffTime, getCurrentTime)
cccd31fa4a72fe23cc3249c06db181b274a55a69gsteinimport qualified Control.Concurrent as Concurrent
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingimport GUI.Utils (infoDialog)
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh-- * Prover implementation
3de8d8649277a02f53aa4f06121420985e8eee08nd{- | The Prover implementation. First runs the batch prover (with
10db6c4117794cbb76695f8b81b02a82bcf986e1ben graphical feedback), then starts the GUI prover. -}
81cc440ca73845f44dc589db106d3feb7a36f33bminfrindarwinProver :: Prover Sign Sentence SoftFOLMorphism () ProofTree
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingdarwinProver = mkAutomaticProver "Darwin" () darwinGUI darwinCMDLautomaticBatch
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingdarwinConsChecker :: ConsChecker Sign Sentence () SoftFOLMorphism ProofTree
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingdarwinConsChecker = (mkConsChecker "darwin" () consCheck)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding { ccNeedsTimer = False }
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh Record for prover specific functions. This is used by both GUI and command
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh line interface.
2261031aa94be82d7e6b1b8c367afc1b282317f5ianhatpFun :: String -- ^ theory name
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh -> ATPFunctions Sign Sentence SoftFOLMorphism ProofTree SoftFOLProverState
3de8d8649277a02f53aa4f06121420985e8eee08ndatpFun thName = ATPFunctions
10db6c4117794cbb76695f8b81b02a82bcf986e1ben { initialProverState = spassProverState
81cc440ca73845f44dc589db106d3feb7a36f33bminfrin , atpTransSenName = transSenName
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh , atpInsertSentence = insertSentenceGen
8b64441666c2d3894744886fc5eda2e9ee15605eben , goalOutput = showTPTPProblem thName
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh , proverHelpText = "no help for darwin available"
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh , batchTimeEnv = "HETS_SPASS_BATCH_TIME_LIMIT"
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh , fileExtensions = FileExtensions
3de8d8649277a02f53aa4f06121420985e8eee08nd { problemOutput = ".tptp"
10db6c4117794cbb76695f8b81b02a82bcf986e1ben , proverOutput = ".spass"
81cc440ca73845f44dc589db106d3feb7a36f33bminfrin , theoryConfiguration = ".spcf" }
81cc440ca73845f44dc589db106d3feb7a36f33bminfrin , runProver = runDarwin
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding , createProverOptions = extraOpts }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding Invokes the generic prover GUI. SPASS specific functions are omitted by
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh data type ATPFunctions.
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhdarwinGUI :: String -- ^ theory name
8b9a4881f960811c0804bd11e13f7341be5bace8wrowe -> Theory Sign Sentence ProofTree
8b9a4881f960811c0804bd11e13f7341be5bace8wrowe -- ^ theory consisting of a SoftFOL.Sign.Sign
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh -- and a list of Named SoftFOL.Sign.Sentence
e8f95a682820a599fe41b22977010636be5c2717jim -> [FreeDefMorphism SPTerm SoftFOLMorphism] -- ^ freeness constraints
e8f95a682820a599fe41b22977010636be5c2717jim -> IO([ProofStatus ProofTree]) -- ^ proof status for each goal
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhdarwinGUI thName th freedefs =
85c4a4d5ba3751702855fd9b1a78daed874941dcwrowe genericATPgui (atpFun thName) True (proverName darwinProver) thName th
85c4a4d5ba3751702855fd9b1a78daed874941dcwrowe freedefs emptyProofTree
fdf0370f05f77efd6e8f7e888dc21afc1fc79cbfben-- ** command line function
8b9a4881f960811c0804bd11e13f7341be5bace8wrowe Implementation of 'Logic.Prover.proveCMDLautomaticBatch' which provides an
fdf0370f05f77efd6e8f7e888dc21afc1fc79cbfben automatic command line interface to the Darwin prover via MathServe.
85c4a4d5ba3751702855fd9b1a78daed874941dcwrowe Darwin specific functions are omitted by data type ATPFunctions.
8b9a4881f960811c0804bd11e13f7341be5bace8wrowedarwinCMDLautomaticBatch ::
8b9a4881f960811c0804bd11e13f7341be5bace8wrowe Bool -- ^ True means include proved theorems
85c4a4d5ba3751702855fd9b1a78daed874941dcwrowe -> Bool -- ^ True means save problem file
85c4a4d5ba3751702855fd9b1a78daed874941dcwrowe -> Concurrent.MVar (Result.Result [ProofStatus ProofTree])
85c4a4d5ba3751702855fd9b1a78daed874941dcwrowe -- ^ used to store the result of the batch run
85c4a4d5ba3751702855fd9b1a78daed874941dcwrowe -> String -- ^ theory name
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh -> TacticScript -- ^ default tactic script
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh -> Theory Sign Sentence ProofTree -- ^ theory consisting of a
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh -- 'SoftFOL.Sign.Sign' and a list of Named 'SoftFOL.Sign.Sentence'
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding -> [FreeDefMorphism SPTerm SoftFOLMorphism] -- ^ freeness constraints
81cc440ca73845f44dc589db106d3feb7a36f33bminfrin -- ^ fst: identifier of the batch thread for killing it
81cc440ca73845f44dc589db106d3feb7a36f33bminfrin -- snd: MVar to wait for the end of the thread
81cc440ca73845f44dc589db106d3feb7a36f33bminfrindarwinCMDLautomaticBatch inclProvedThs saveProblem_batch resultMVar
c7b8ebf28db0c79631ddcc97aaf7ea7d3e029d2ffielding thName defTS th freedefs =
c7b8ebf28db0c79631ddcc97aaf7ea7d3e029d2ffielding genericCMDLautomaticBatch (atpFun thName) inclProvedThs saveProblem_batch
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh resultMVar (proverName darwinProver) thName
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh (parseTacticScript batchTimeLimit [] defTS) th freedefs emptyProofTree
3de8d8649277a02f53aa4f06121420985e8eee08nd-- * Main prover functions
3de8d8649277a02f53aa4f06121420985e8eee08nd Runs the Darwin service. The tactic script only contains a string for the
3de8d8649277a02f53aa4f06121420985e8eee08nd time limit.
3de8d8649277a02f53aa4f06121420985e8eee08ndconsCheck :: String
3de8d8649277a02f53aa4f06121420985e8eee08nd -> TacticScript
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding -> TheoryMorphism Sign Sentence SoftFOLMorphism ProofTree
e50ebb2b77c4b1837242925e3e3bcf3a4717664bben -> [FreeDefMorphism SPTerm SoftFOLMorphism] -- ^ freeness constraints
10db6c4117794cbb76695f8b81b02a82bcf986e1ben -> IO(CCStatus ProofTree)
10db6c4117794cbb76695f8b81b02a82bcf986e1benconsCheck thName (TacticScript tl) tm freedefs = case tTarget tm of
10db6c4117794cbb76695f8b81b02a82bcf986e1ben Theory sig nSens -> let
8b64441666c2d3894744886fc5eda2e9ee15605eben saveTPTP = False
10db6c4117794cbb76695f8b81b02a82bcf986e1ben proverStateI = spassProverState sig (toNamedList nSens) freedefs
10db6c4117794cbb76695f8b81b02a82bcf986e1ben problem = showTPTPProblemM thName proverStateI []
10db6c4117794cbb76695f8b81b02a82bcf986e1ben extraOptions = "-pc false -pmtptp true -fd true -to "
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding saveFileName = reverse $ fst $ span (/= '/') $ reverse thName
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh runDarwinRealM :: IO(CCStatus ProofTree)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding runDarwinRealM = do
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding probl <- problem
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding noProg <- missingExecutableInPath "darwin"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if noProg then do
-> AS_Anno.Named SPTerm -- ^ goal to prove
saveFileName = thName++'_':AS_Anno.senAttr nGoal
'_':AS_Anno.senAttr nGoal
(AS_Anno.senAttr nGoal) emptyProofTree)
(AS_Anno.senAttr nGoal) (proverName darwinProver) $
{ goalName = AS_Anno.senAttr nGoal
in map AS_Anno.senAttr fs