Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
LARA
inox
Commits
5ac4a64b
Commit
5ac4a64b
authored
14 years ago
by
Philippe Suter
Browse files
Options
Downloads
Patches
Plain Diff
summary
parent
627ac060
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/purescala/Analysis.scala
+41
-12
41 additions, 12 deletions
src/purescala/Analysis.scala
with
41 additions
and
12 deletions
src/purescala/Analysis.scala
+
41
−
12
View file @
5ac4a64b
...
@@ -52,20 +52,21 @@ class Analysis(val program: Program) {
...
@@ -52,20 +52,21 @@ class Analysis(val program: Program) {
}
}
def
checkVerificationConditions
:
Unit
=
{
def
checkVerificationConditions
:
Unit
=
{
// just for the summary:
var
verifiedVCs
:
List
[(
String
,
String
,
String
,
String
)]
=
Nil
solverExtensions
.
foreach
(
_
.
setProgram
(
program
))
solverExtensions
.
foreach
(
_
.
setProgram
(
program
))
// Analysis should check that:
// - all the postconditions are implied by preconds. + body
// - all callsites satisfy the preconditions
// - all matches are exhaustive
// In the future:
// - catamorphisms are catamorphisms (poss. with surjectivity conds.)
// - injective functions are injective
// - all global invariants are satisfied
for
(
funDef
<-
program
.
definedFunctions
)
if
(
Settings
.
functionsToAnalyse
.
isEmpty
||
Settings
.
functionsToAnalyse
.
contains
(
funDef
.
id
.
name
))
{
for
(
funDef
<-
program
.
definedFunctions
)
if
(
Settings
.
functionsToAnalyse
.
isEmpty
||
Settings
.
functionsToAnalyse
.
contains
(
funDef
.
id
.
name
))
{
if
(
funDef
.
body
.
isDefined
)
{
if
(
funDef
.
body
.
isDefined
)
{
val
vc
=
postconditionVC
(
funDef
)
val
vc
=
postconditionVC
(
funDef
)
if
(
vc
!=
BooleanLiteral
(
true
))
{
if
(
vc
==
BooleanLiteral
(
false
))
{
verifiedVCs
=
(
funDef
.
id
.
toString
,
"postcondition"
,
"invalid"
,
"trivial"
)
::
verifiedVCs
}
else
if
(
vc
==
BooleanLiteral
(
true
))
{
if
(
funDef
.
hasPostcondition
)
{
verifiedVCs
=
(
funDef
.
id
.
toString
,
"postcondition"
,
"valid"
,
"tautology"
)
::
verifiedVCs
}
}
else
{
reporter
.
info
(
"Verification condition (post) for ==== "
+
funDef
.
id
+
" ===="
)
reporter
.
info
(
"Verification condition (post) for ==== "
+
funDef
.
id
+
" ===="
)
if
(
Settings
.
unrollingLevel
==
0
)
{
if
(
Settings
.
unrollingLevel
==
0
)
{
reporter
.
info
(
vc
)
reporter
.
info
(
vc
)
...
@@ -83,20 +84,48 @@ class Analysis(val program: Program) {
...
@@ -83,20 +84,48 @@ class Analysis(val program: Program) {
reporter
.
info
(
"Trying with solver: "
+
se
.
shortDescription
)
reporter
.
info
(
"Trying with solver: "
+
se
.
shortDescription
)
se
.
solve
(
vc
)
match
{
se
.
solve
(
vc
)
match
{
case
None
=>
false
case
None
=>
false
case
Some
(
true
)
=>
reporter
.
info
(
"==== VALID ===="
);
true
case
Some
(
true
)
=>
{
case
Some
(
false
)
=>
reporter
.
error
(
"==== INVALID ===="
);
true
reporter
.
info
(
"==== VALID ===="
)
verifiedVCs
=
(
funDef
.
id
.
toString
,
"postcondition"
,
"valid"
,
se
.
shortDescription
)
::
verifiedVCs
true
}
case
Some
(
false
)
=>
{
reporter
.
error
(
"==== INVALID ===="
)
verifiedVCs
=
(
funDef
.
id
.
toString
,
"postcondition"
,
"invalid"
,
se
.
shortDescription
)
::
verifiedVCs
true
}
}
}
})
match
{
})
match
{
case
None
=>
reporter
.
warning
(
"No solver could prove or disprove the verification condition."
)
case
None
=>
{
reporter
.
warning
(
"No solver could prove or disprove the verification condition."
)
verifiedVCs
=
(
funDef
.
id
.
toString
,
"postcondition"
,
"unknown"
,
"---"
)
::
verifiedVCs
}
case
_
=>
case
_
=>
}
}
}
}
}
else
{
}
else
{
if
(
funDef
.
postcondition
.
isDefined
)
{
if
(
funDef
.
postcondition
.
isDefined
)
{
reporter
.
warning
(
funDef
,
"Could not verify postcondition: function implementation is unknown."
)
reporter
.
warning
(
funDef
,
"Could not verify postcondition: function implementation is unknown."
)
verifiedVCs
=
(
funDef
.
id
.
toString
,
"postcondition"
,
"unknown"
,
"no body"
)
::
verifiedVCs
}
}
}
}
}
}
verifiedVCs
=
verifiedVCs
.
reverse
val
col1wdth
=
verifiedVCs
.
map
(
_
.
_1
).
map
(
_
.
length
).
max
+
2
val
col2wdth
=
verifiedVCs
.
map
(
_
.
_2
).
map
(
_
.
length
).
max
+
2
val
col3wdth
=
verifiedVCs
.
map
(
_
.
_3
).
map
(
_
.
length
).
max
+
2
val
col4wdth
=
verifiedVCs
.
map
(
_
.
_4
).
map
(
_
.
length
).
max
def
mk1line
(
line
:
(
String
,
String
,
String
,
String
))
:
String
=
{
line
.
_1
+
(
" "
*
(
col1wdth
-
line
.
_1
.
length
))
+
line
.
_2
+
(
" "
*
(
col2wdth
-
line
.
_2
.
length
))
+
line
.
_3
+
(
" "
*
(
col3wdth
-
line
.
_3
.
length
))
+
line
.
_4
}
val
dashes
:
String
=
"="
*
(
col1wdth
+
col2wdth
+
col3wdth
+
col4wdth
)
reporter
.
info
(
"Summary:\n"
+
dashes
+
"\n"
+
verifiedVCs
.
map
(
mk1line
(
_
)).
mkString
(
"\n"
)
+
"\n"
+
dashes
)
}
}
def
postconditionVC
(
functionDefinition
:
FunDef
)
:
Expr
=
{
def
postconditionVC
(
functionDefinition
:
FunDef
)
:
Expr
=
{
...
...
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