-
Notifications
You must be signed in to change notification settings - Fork 6
/
Proof.hs
40 lines (35 loc) · 1.53 KB
/
Proof.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module Proof(proveProgram) where
import L4.Syntax
( assertionsOfProgram,
Assertion(instrOfAssertion),
Program(elementsOfProgram),
Tp,
TopLevelElement(RuleTLE),
getRule,
typeOfTLE,
rulesOfProgram )
import ToASP(proveAssertionASP)
import TimedMC (proveAssertionTA)
import Smt(proveAssertionSMT)
import Control.Monad (foldM)
import RuleTransfo (rewriteRuleSetDerived, rewriteRuleSetSubjectTo, rewriteRuleSetDespite)
import L4.PrintProg
( renameAndPrintRule, namesUsedInProgram, printTest, PrintSystem (UppaalStyle, L4Style) )
proveAssertion :: Program (Tp ()) -> Assertion (Tp ()) -> IO ()
proveAssertion p asrt = foldM (\r (k,instr) ->
case k of
"SMT" -> proveAssertionSMT p instr asrt
"sCASP"-> proveAssertionASP p instr asrt
"TA" -> proveAssertionTA p instr asrt
"printUp" -> printTest p UppaalStyle
"printL4" -> printTest p L4Style
_ -> return ())
() (instrOfAssertion asrt)
proveProgram :: Program (Tp ()) -> IO ()
proveProgram p = do
let transfRules = rewriteRuleSetDerived (rewriteRuleSetSubjectTo (rewriteRuleSetDespite (rulesOfProgram p)))
let updRules = [e | e <- elementsOfProgram p, not (typeOfTLE getRule e)] ++ map RuleTLE transfRules
let transfProg = p{elementsOfProgram = updRules}
putStrLn "Generated rules:"
putStrLn (concatMap (renameAndPrintRule (namesUsedInProgram transfProg)) transfRules)
foldM (\r a -> proveAssertion transfProg a) () (assertionsOfProgram transfProg)