- separate GoalStatus into its own Module
and specifify the whole SZS Ontology with appropiate types and functions
data SenStatus a tStatus = SenStatus
instance (Show b, Pretty a) => Pretty (SenStatus a b) where
pretty = printSenStatus pretty
printSenStatus :: (a -> Doc) -> SenStatus a b -> Doc
printSenStatus fA = fA . value
emptySenStatus :: SenStatus a b
emptySenStatus = SenStatus
{ value = error "emptySenStatus"
instance Eq a => Eq (SenStatus a b) where
d1 == d2 = (value d1, isAxiom d1, isDef d1) ==
(value d2, isAxiom d2, isDef d2)
instance Ord a => Ord (SenStatus a b) where
d1 <= d2 = (value d1, isAxiom d1, isDef d1) <=
(value d2, isAxiom d2, isDef d2)
pretty = printOMapElemWOrd pretty
type ThSens a b =
OMap.OMap String (SenStatus a b)
-- | join and disambiguate
-- * separate Axioms from Theorems
-- * don't merge sentences with same key but different contents?
joinSens :: (Ord a,Eq b) => ThSens a b -> ThSens a b -> ThSens a b
joinSens s1 s2 = let l1 = sortBy (comparing snd) $
Map.toList s1
where mergeSens [] l2 = l2
mergeSens l1@((k1, e1) : r1) l2@((k2, e2) : r2) =
LT -> (k1, e1) : mergeSens r1 l2
GT -> (k2, e2) : mergeSens l1 r2
diffSens :: (Ord a,Eq b) => ThSens a b -> ThSens a b -> ThSens a b
diffS l1@((k1, e1) : r1) l2@((_, e2) : r2) =
LT -> (k1, e1) : diffS r1 l2
mapValue :: (a -> b) -> SenStatus a c -> SenStatus b c
mapValue f d = d { value = f $ value d }
markAsAxiom :: Ord a => Bool -> ThSens a b -> ThSens a b
markAsAxiom b =
OMap.map (\d -> d { isAxiom = b})
markAsGoal :: Ord a => ThSens a b -> ThSens a b
markAsGoal = markAsAxiom False
-- | putting Sentences from a list into a map
-- | theories with a signature and sentences with proof states
data Theory sign sen proof_tree =
Theory sign (ThSens sen (Proof_status proof_tree))
-- | theory morphisms between two theories
data TheoryMorphism sign sen mor proof_tree = TheoryMorphism
{ t_source :: Theory sign sen proof_tree
, t_target :: Theory sign sen proof_tree
--
e.g. the file name, or the script itself, or a configuration string
data Tactic_script = Tactic_script
{ ts_timeLimit :: Int, -- ^ used time limit
ts_extraOpts :: String -- ^ used extra options (if any)
} deriving (Eq, Ord, Show)
-- | enumeration type representing the status of a goal
| Proved (Maybe Bool) -- ^ Just True means consistent;
-- Nothing means don't know
-- needed for automated theorem provers like SPASS;
-- provers like Isabelle set it to Nothing
instance Show GoalStatus where
(if c then "" else "in") ++
-- | data type representing the proof status for a goal or
data Proof_status proof_tree =
Proof_status { goalName :: String
, goalStatus :: GoalStatus
, usedAxioms :: [String] -- ^ used axioms
, proverName :: String -- ^ name of prover
, proofTree :: proof_tree
, tacticScript :: Tactic_script }
| Consistent Tactic_script
-- | constructs an open proof status with basic information filled in;
-- make sure to set proofTree to a useful value before you access it, because
-- its default value is 'undefined'
openProof_status :: Ord pt =>
String -- ^ name of the goal
-> String -- ^ name of the prover
openProof_status goalname provername proof_tree =
Proof_status { goalName = goalname
, proverName = provername
, tacticScript = Tactic_script
instance Eq a => Ord (Proof_status a) where
Disproved _ <= x = case x of
Proved _ _ _ _ _ <= x = case x of
-- Ord instance must match Eq instance!
instance Eq a => Eq (Proof_status a) where
a == b = compare a b == EQ
isProvedStat :: Proof_status proof_tree -> Bool
isProvedStat pst = case pst of
_ -> isProvedGStat . goalStatus $ pst
isProvedGStat :: GoalStatus -> Bool
isProvedGStat gs = case gs of
goalUsedInProof :: Monad m => Proof_status proof_tree -> m Bool
Proved m -> maybe (fail "don't know if goal was used") return m
-- | different kinds of prover interfaces
data ProverKind = ProveGUI | ProveCMDLautomatic | ProveCMDLinteractive
-- | determine if a prover kind is implemented
hasProverKind :: ProverKind -> ProverTemplate x y -> Bool
ProveGUI -> isJust $ proveGUI pt
ProveCMDLautomatic -> isJust (proveCMDLautomatic pt) &&
isJust (proveCMDLautomaticBatch pt)
ProveCMDLinteractive -> isJust $ proveCMDLinteractive pt
-- | prover or consistency checker
data ProverTemplate theory proof_tree = Prover
prover_sublogic :: String,
proveGUI :: Maybe (String -> theory -> IO ([Proof_status proof_tree])),
-- input: theory name, theory (incl. goals)
-- output: proof status for goals and lemmas
proveCMDLautomatic :: Maybe (String -> Tactic_script
-> theory -> IO (Result ([Proof_status proof_tree]))),
-- blocks until a result is determined
-- input: theory name, Tactic_script,
-- theory (incl. goals, but only the first one is tried)
-- output: proof status for goals and lemmas
proveCMDLinteractive :: Maybe (String -> Tactic_script
-> theory -> IO (Result ([Proof_status proof_tree]))),
-- input, output: see above
proveCMDLautomaticBatch ::
-> IORef (Result [Proof_status proof_tree])
-> String -> Tactic_script -> theory
-- input: 1. True means include proven theorems in subsequent
-- 2. True means save problem file for each goal;
-- 2. reference to a Result with an empty list (return []),
-- used to store the result of the batch run;
-- 4. default Tactic_script,
-- 5. theory (incl. goals and
-- Open SenStatus for individual tactic_scripts)
-- output: fst --> identifier of the batch thread for killing it,
-- after each proof attempt the result is stored in the
-- snd --> MVar to wait for the end of the thread
type Prover sign sentence proof_tree =
ProverTemplate (Theory sign sentence proof_tree) proof_tree
emptyProverTemplate :: ProverTemplate x y
emptyProverTemplate = Prover
{ prover_name = error "Empty proverTemplate name"
, prover_sublogic = error "Empty proverTemplate sublogic"
, proveCMDLautomatic = Nothing
, proveCMDLinteractive = Nothing
, proveCMDLautomaticBatch = Nothing }
type ConsChecker sign sentence morphism proof_tree =
ProverTemplate (TheoryMorphism sign sentence morphism proof_tree) proof_tree
instance (Typeable a, Typeable b) => Typeable (ProverTemplate a b) where
typeOf p = mkTyConApp proverTc
[typeOf ((undefined :: ProverTemplate a b -> a) p),
typeOf ((undefined :: ProverTemplate a b -> b) p)]