Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
javawlp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
impresshs
javawlp
Commits
47b9f3fc
Commit
47b9f3fc
authored
7 years ago
by
ISWB Prasetya
Browse files
Options
Downloads
Patches
Plain Diff
putting back a function to calculate the wlp of a method and check its satisfiability.
parent
418349e7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Javawlp/API.hs
+16
-1
16 additions, 1 deletion
src/Javawlp/API.hs
src/Javawlp/Engine/Verifier.hs
+16
-0
16 additions, 0 deletions
src/Javawlp/Engine/Verifier.hs
with
32 additions
and
1 deletion
src/Javawlp/API.hs
+
16
−
1
View file @
47b9f3fc
...
...
@@ -6,6 +6,7 @@ module Javawlp.API where
import
Language.Java.Syntax
import
Language.Java.Parser
import
Language.Java.Pretty
import
Z3.Monad
import
Javawlp.Engine.WLP
import
Javawlp.Engine.Types
...
...
@@ -77,9 +78,23 @@ printWlp sourcePath methodName postCond = do
let
q
=
post_
postCond
p
<-
wlpMethod
defaultConf
typeEnv
decls
(
Ident
methodName
)
q
putStrLn
$
showMethodWlp
methodName
q
p
let
(
result
,
model
)
=
unsafeIsSatisfiable
(
extendEnv
typeEnv
decls
(
Ident
methodName
))
decls
p
case
result
of
Unsat
->
putStrLn
"** The wlp is UNSATISFIABLE."
Undef
->
putStrLn
"** Unable to decide the wlp's satisfiablity."
_
->
do
putStrLn
"** The wlp is SATISFIABLE."
case
model
of
Just
m
->
do
{
putStrLn
"** Model:"
;
s
<-
evalZ3
(
modelToString
m
)
;
putStrLn
s
}
_
->
return
()
showMethodWlp
::
String
->
Exp
->
Exp
->
String
showMethodWlp
methodName
postCond
wlp
=
"wlp of "
++
methodName
++
" over "
++
prettyPrint
postCond
"
**
wlp of "
++
methodName
++
" over "
++
prettyPrint
postCond
++
" is "
++
prettyPrint
wlp
This diff is collapsed.
Click to expand it.
src/Javawlp/Engine/Verifier.hs
+
16
−
0
View file @
47b9f3fc
...
...
@@ -30,6 +30,22 @@ isFalse env decls e =
Unsat
->
return
True
_
->
return
False
-- | Check if a formula is satisfiable, and if so, return the model for it as well.
-- The result is a pair (r,m) where r is either Sat, Unsat, or Undef. If r is Sat,
-- then m is Just v where v a model witnessing the satisfiability of the input
-- formula. Else m is Nothing.
--
unsafeIsSatisfiable
::
TypeEnv
->
[
TypeDecl
]
->
Exp
->
(
Result
,
Maybe
Model
)
unsafeIsSatisfiable
env
decls
e
=
unsafePerformIO
$
evalZ3
z3
where
z3
=
do
ast
<-
foldExp
expAssertAlgebra
e
env
decls
assert
ast
r
<-
solverCheckAndGetModel
solverReset
return
r
-- | Unsafe version of isTrue
unsafeIsTrue
::
TypeEnv
->
[
TypeDecl
]
->
Exp
->
Bool
unsafeIsTrue
env
decls
=
unsafePerformIO
.
evalZ3
.
isTrue
env
decls
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment