4752N/ACopyright : (c) University of Cambridge, Cambridge, England
4752N/A adaption (c) Till Mossakowski, Uni Bremen 2002-2005
4752N/AInterface for Isabelle theorem prover.
4752N/A todo: thy files in subdir, check of legal changes in thy file
4752N/A Interface between Isabelle and Hets:
4752N/A Hets writes Isabelle .thy file and starts Isabelle
4752N/A User extends .thy file with proofs
4752N/A Hets reads in created *.deps files
4752N/AisabelleProver :: Prover Sign Sentence ()
4752N/A Prover { prover_name = isabelleS,
4752N/A prover_sublogic = isabelleS,
4752N/AisabelleConsChecker :: ConsChecker Sign Sentence (DefaultMorphism Sign) ()
4752N/A Prover { prover_name = "Isabelle-refute",
4752N/A prover_sublogic = isabelleS,
4752N/A-- | the name of the inconsistent lemma for consistency checks
4752N/AinconsistentS = "inconsistent"
4752N/AconsCheck :: String -> TheoryMorphism Sign Sentence (DefaultMorphism Sign) ()
4752N/AconsCheck thName tm = case t_target tm of
4752N/A Theory sig nSens -> let (axs, _) = getAxioms $ toNamedList nSens in
4752N/A isaProve (thName ++ "_c") $
4752N/A Theory emptySign { baseSig = baseSig sig }
4752N/A $ markAsGoal $ toThSens $ if null axs then [] else
4752N/A [ (emptyName $ mkRefuteSen $ termAppl notOp
4752N/A $ foldr1 binConj $ map (senTerm . sentence) axs)
4752N/A { senName = inconsistentS } ]
4752N/AprepareTheory :: Theory Sign Sentence ()
4752N/A -> (Sign, [Named Sentence], [Named Sentence],
Map.Map String String)
4752N/AprepareTheory (Theory sig nSens) = let
4752N/A nSens' = prepareSenNames transString oSens
4752N/A (disAxs, disGoals) = getAxioms nSens'
4752N/A in (sig, map markSimp disAxs, map markSimp disGoals,
4752N/A-- return a reverse mapping for renamed sentences
4752N/AremoveDepFiles :: String -> [String] -> IO ()
4752N/AremoveDepFiles thName = mapM_ $ \ thm -> do
4752N/A let depFile = getDepsFileName thName thm
4752N/A ex <- doesFileExist depFile
4752N/A when ex $ removeFile depFile
4752N/AgetDepsFileName :: String -> String -> String
4752N/AgetDepsFileName thName thm = thName ++ "_" ++ thm ++ ".deps"
4752N/AgetProofDeps m thName thm = do
4752N/A let file = getDepsFileName thName thm
4752N/A strip = takeWhile (not . isSpace) . dropWhile isSpace
4752N/A if null s then return $ Open $ mapN thm
4752N/A else let l = filter (not . null) $ map strip $ lines s
4752N/A in return $ mkProved (mapN thm) $ map mapN l
4752N/A else return $ Open $ mapN thm
4752N/AgetAllProofDeps m thName = mapM $ getProofDeps m thName
4752N/AmkProved :: String -> [String] -> Proof_status ()
4752N/A , tacticScript = Tactic_script "unknown isabelle user input"
4752N/AprepareThyFiles :: String -> String -> IO ()
4752N/AprepareThyFiles thyFile thy = do
4752N/A let origFile = thyFile ++ ".orig"
4752N/A exOrig <- checkInFile origFile
4752N/A exThyFile <- checkInFile thyFile
4752N/A if exOrig then return () else writeFile origFile thy
4752N/A if exThyFile then return () else writeFile thyFile thy
4752N/A thy_time <- getModificationTime thyFile
4752N/A orig_time <- getModificationTime origFile
unless (thy_time >= orig_time && s == thy)
$ patchThyFile origFile thyFile thy
patchThyFile :: FilePath -> FilePath -> String -> IO ()
patchThyFile origFile thyFile thy = do
let patchFile = thyFile ++ ".patch"
oldFile = thyFile ++ ".old"
diffCall = "diff -u " ++ origFile ++ " " ++ thyFile
patchCall = "patch -fu " ++ thyFile ++ " " ++ patchFile
renameFile thyFile oldFile
callSystem :: String -> IO ExitCode
callSystem s = putStrLn s >> system s
isaProve :: String -> Theory Sign Sentence () -> IO([Proof_status ()])
let (sig, axs, ths, m) = prepareTheory th
hlibdir <- getEnv "HETS_LIB"
let thBaseName = reverse . takeWhile (/= '/') $ reverse thName
thy = show $ printIsaTheory thBaseName hlibdir sig $ axs ++ ths
thyFile = thName ++ ".thy"
prepareThyFiles thyFile thy
removeDepFiles thName thms
isabelle <- getEnv "HETS_ISABELLE"
callSystem $ isabelle ++ " " ++ thyFile
getAllProofDeps m thName thms
markSimp :: Named Sentence -> Named Sentence
markSimp = mapNamed markSimpSen
markSimpSen :: Sentence -> Sentence
markSimpSen s = case s of
Sentence {} -> s {isSimp = isSimpRuleSen s}
isSimpRuleSen :: Sentence -> Bool
isSimpRuleSen sen = case sen of
_ -> isSimpRule $ senTerm sen
-- | test whether a formula should be put into the simpset
isSimpRule :: Term -> Bool
-- only universal quantifications
isSimpRule App { funId = Const {termName = VName { new = q }}
| q == exS || q == ex1S = False
| q == allS = isSimpRule (termId arg)
-- accept everything expect from abstractions
isSimpRule App {funId = arg1, argId = arg2} =
isSimpRule arg1 && isSimpRule arg2
isSimpRule MixfixApp {funId = arg1, argIds = args } =
isSimpRule arg1 && all isSimpRule args
isSimpRule Const{} = True
isSimpRule Bound{} = True
isSimpRule (Paren t) = isSimpRule t