Prove.hs revision ad69cb3627839ed3d33f13d71c81378b65a24b35
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannModule : $Header$
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannDescription : Provers for propositional logic
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannCopyright : (c) Dominik Luecke, Uni Bremen 2007
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannMaintainer : luecke@informatik.uni-bremen.de
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannStability : experimental
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannPortability : portable
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannThis is the connection of the SAT-Solver minisat to Hets
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann zchaffProver, -- the zChaff II Prover
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann propConsChecker
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Propositional.AS_BASIC_Propositional as AS_BASIC
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Propositional.Conversions as Cons
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Propositional.Conversions as PC
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Propositional.Morphism as PMorphism
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Propositional.ProverState as PState
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Propositional.Sign as Sig
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Logic.Prover as LP
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified GUI.GenericATPState as ATPState
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport GUI.Utils (infoDialog)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport ChildProcess as CP
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport Common.Utils (readMaybe)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Common.AS_Annotation as AS_Anno
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Common.Id as Id
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Common.OrderedMap as OMap
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Common.Result as Result
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Control.Concurrent as Concurrent
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Control.Exception as Exception
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport Data.Time (TimeOfDay,timeToTimeOfDay)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann-- * Prover implementation
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannzchaffHelpText :: String
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannzchaffHelpText = "Zchaff is a very fast SAT-Solver \n"++
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann "No additional Options are available"++
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann-- | the name of the prover
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannzchaffS :: String
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannzchaffS = "zchaff"
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann The Prover implementation.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann Implemented are: a prover GUI, and both commandline prover interfaces.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann :: LP.Prover Sig.Sign AS_BASIC.FORMULA PMorphism.Morphism PropSL ProofTree
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannzchaffProver = (LP.mkProverTemplate zchaffS top zchaffProveGUI)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann { LP.proveCMDLautomatic = Just $ zchaffProveCMDLautomatic
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , LP.proveCMDLautomaticBatch = Just $ zchaffProveCMDLautomaticBatch }
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann The Consistency Cheker.
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannpropConsChecker :: LP.ConsChecker Sig.Sign AS_BASIC.FORMULA PropSL
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannpropConsChecker = LP.mkProverTemplate zchaffS top consCheck
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannconsCheck :: String -> LP.TheoryMorphism Sig.Sign AS_BASIC.FORMULA
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann -> [LP.FreeDefMorphism AS_BASIC.FORMULA PMorphism.Morphism] -- ^ free definitions
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann -> IO([LP.Proof_status ProofTree])
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannconsCheck thName tm _ =
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann LP.Theory sig nSens -> do
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann let axioms = getAxioms $ snd $ unzip $ OMap.toList nSens
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann tmpFile = "/tmp/" ++ (thName ++ "_cc.dimacs")
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann resultFile = tmpFile ++ ".result"
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann dimacsOutput <- PC.ioDIMACSProblem (thName ++ "_cc")
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann sig ( [(AS_Anno.makeNamed "myAxioms" $
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann outputHf <- openFile tmpFile ReadWriteMode
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann hPutStr outputHf dimacsOutput
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann hClose outputHf
-> IO([LP.Proof_status ProofTree]) -- ^ proof status for each goal
genericATPgui (atpFun thName) True (LP.prover_name zchaffProver) thName th
'GUI.GenericATPState.ATPTactic_script' if possible.
parseZchaffTactic_script :: LP.Tactic_script
'GUI.GenericATPState.ATPTactic_script' if possible. Otherwise a default
parseTactic_script tLimit (LP.Tactic_script ts) =
ATPState.ts_extraOpts = [] })
Implementation of 'Logic.Prover.proveCMDLautomatic' which provides an
-> LP.Tactic_script -- ^ default tactic script
genericCMDLautomatic (atpFun thName) (LP.prover_name zchaffProver) thName
Implementation of 'Logic.Prover.proveCMDLautomaticBatch' which provides an
-> LP.Tactic_script -- ^ default tactic script
resultMVar (LP.prover_name zchaffProver) thName
-> ATPState.ATPFunctions Sig.Sign AS_BASIC.FORMULA PMorphism.Morphism ProofTree PState.PropProverState
atpFun thName = ATPState.ATPFunctions
, ATPState.proverHelpText = zchaffHelpText
, ATPState.runProver = runZchaff
, ATPState.batchTimeEnv = "HETS_ZCHAFF_BATCH_TIME_LIMIT"
ATPState.proverOutput = ".zchaff",
ATPState.theoryConfiguration = ".czchaff"}
, ATPState.createProverOptions = createZchaffOptions
runZchaff :: PState.PropProverState
-> ATPState.GenericConfig ProofTree
-> IO (ATPState.ATPRetval
, ATPState.GenericConfig ProofTree
prob <- Cons.goalDIMACSProblem thName pState nGoal []
(writeFile (thName++'_':AS_Anno.senAttr nGoal++".dimacs")
zchaff <- newChildProcess "zchaff" [CP.arguments allOptions]
Exception.catch (runZchaffReal zchaff)
excepToATPResult (LP.prover_name zchaffProver) nGoal excep)
cfg{ATPState.proof_status = retval,
ATPState.resultOutput = output,
ATPState.timeUsed = tUsed})
, LP.proofTree = ProofTree $ out })
(ATPState.ATPTLimitExceeded, defaultProof_status options)
(ATPState.ATPError "Internal error.", defaultProof_status options)
| otherwise = (ATPState.ATPSuccess, defaultProof_status options)
{ATPState.ts_timeLimit = configTimeLimit cfg,
ATPState.ts_extraOpts = opts} }
-> IO (ATPState.ATPRetval,
ATPState.GenericConfig ProofTree)
(ATPState.ATPError ("Internal error communicating with " ++
(ATPState.ATPBatchStopped, emptyCfg)
_ -> (ATPState.ATPError ("Error running " ++ prName ++ ".\n"
configTimeLimit :: ATPState.GenericConfig ProofTree
maybe (guiDefaultTimeLimit) id $ ATPState.timeLimit cfg
createZchaffOptions :: ATPState.GenericConfig ProofTree -> [String]