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
6bb6fc29
Commit
6bb6fc29
authored
14 years ago
by
Philippe Suter
Browse files
Options
Downloads
Patches
Plain Diff
bug fix and support for set membership in evaluator
parent
fdb95653
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/purescala/DefaultTactic.scala
+2
-1
2 additions, 1 deletion
src/purescala/DefaultTactic.scala
src/purescala/Evaluator.scala
+5
-0
5 additions, 0 deletions
src/purescala/Evaluator.scala
src/purescala/Z3ModelReconstruction.scala
+14
-18
14 additions, 18 deletions
src/purescala/Z3ModelReconstruction.scala
with
21 additions
and
19 deletions
src/purescala/DefaultTactic.scala
+
2
−
1
View file @
6bb6fc29
...
@@ -33,6 +33,7 @@ class DefaultTactic(reporter: Reporter) extends Tactic(reporter) {
...
@@ -33,6 +33,7 @@ class DefaultTactic(reporter: Reporter) extends Tactic(reporter) {
val
theExpr
=
{
val
theExpr
=
{
val
resFresh
=
FreshIdentifier
(
"result"
,
true
).
setType
(
body
.
getType
)
val
resFresh
=
FreshIdentifier
(
"result"
,
true
).
setType
(
body
.
getType
)
val
bodyAndPost
=
Let
(
resFresh
,
body
,
replace
(
Map
(
ResultVariable
()
->
Variable
(
resFresh
)),
matchToIfThenElse
(
post
.
get
)))
val
bodyAndPost
=
Let
(
resFresh
,
body
,
replace
(
Map
(
ResultVariable
()
->
Variable
(
resFresh
)),
matchToIfThenElse
(
post
.
get
)))
val
withPrec
=
if
(
prec
.
isEmpty
)
{
val
withPrec
=
if
(
prec
.
isEmpty
)
{
bodyAndPost
bodyAndPost
}
else
{
}
else
{
...
@@ -83,7 +84,7 @@ class DefaultTactic(reporter: Reporter) extends Tactic(reporter) {
...
@@ -83,7 +84,7 @@ class DefaultTactic(reporter: Reporter) extends Tactic(reporter) {
def
generatePreconditions
(
function
:
FunDef
)
:
Seq
[
VerificationCondition
]
=
{
def
generatePreconditions
(
function
:
FunDef
)
:
Seq
[
VerificationCondition
]
=
{
val
toRet
=
if
(
function
.
hasBody
)
{
val
toRet
=
if
(
function
.
hasBody
)
{
val
cleanBody
=
matchToIfThenElse
(
function
.
body
.
get
)
val
cleanBody
=
expandLets
(
matchToIfThenElse
(
function
.
body
.
get
)
)
val
allPathConds
=
collectWithPathCondition
((
t
=>
t
match
{
val
allPathConds
=
collectWithPathCondition
((
t
=>
t
match
{
case
FunctionInvocation
(
fd
,
_
)
if
(
fd
.
hasPrecondition
)
=>
true
case
FunctionInvocation
(
fd
,
_
)
if
(
fd
.
hasPrecondition
)
=>
true
...
...
This diff is collapsed.
Click to expand it.
src/purescala/Evaluator.scala
+
5
−
0
View file @
6bb6fc29
...
@@ -217,6 +217,11 @@ object Evaluator {
...
@@ -217,6 +217,11 @@ object Evaluator {
}
}
case
(
le
,
re
)
=>
throw
TypeErrorEx
(
TypeError
(
le
,
s1
.
getType
))
case
(
le
,
re
)
=>
throw
TypeErrorEx
(
TypeError
(
le
,
s1
.
getType
))
}
}
case
ElementOfSet
(
el
,
s
)
=>
(
rec
(
ctx
,
el
),
rec
(
ctx
,
s
))
match
{
case
(
_
,
EmptySet
(
_
))
=>
BooleanLiteral
(
false
)
case
(
e
,
f
@
FiniteSet
(
els
))
=>
BooleanLiteral
(
els
.
contains
(
e
))
case
(
l
,
r
)
=>
throw
TypeErrorEx
(
TypeError
(
r
,
SetType
(
l
.
getType
)))
}
case
f
@
FiniteSet
(
els
)
=>
FiniteSet
(
els
.
map
(
rec
(
ctx
,
_
)).
distinct
).
setType
(
f
.
getType
)
case
f
@
FiniteSet
(
els
)
=>
FiniteSet
(
els
.
map
(
rec
(
ctx
,
_
)).
distinct
).
setType
(
f
.
getType
)
case
e
@
EmptySet
(
_
)
=>
e
case
e
@
EmptySet
(
_
)
=>
e
...
...
This diff is collapsed.
Click to expand it.
src/purescala/Z3ModelReconstruction.scala
+
14
−
18
View file @
6bb6fc29
...
@@ -13,7 +13,7 @@ trait Z3ModelReconstruction {
...
@@ -13,7 +13,7 @@ trait Z3ModelReconstruction {
// exprToZ3Id, softFromZ3Formula, reporter
// exprToZ3Id, softFromZ3Formula, reporter
private
final
val
AUTOCOMPLETEMODELS
:
Boolean
=
true
private
final
val
AUTOCOMPLETEMODELS
:
Boolean
=
true
private
final
val
SIMPLESTCOMPLETION
:
Boolean
=
fals
e
// if true, use 0, Nil(), etc., else random
private
final
val
SIMPLESTCOMPLETION
:
Boolean
=
tru
e
// if true, use 0, Nil(), etc., else random
def
modelValue
(
model
:
Z3Model
,
id
:
Identifier
,
tpe
:
TypeTree
=
null
)
:
Option
[
Expr
]
=
{
def
modelValue
(
model
:
Z3Model
,
id
:
Identifier
,
tpe
:
TypeTree
=
null
)
:
Option
[
Expr
]
=
{
val
expectedType
=
if
(
tpe
==
null
)
id
.
getType
else
tpe
val
expectedType
=
if
(
tpe
==
null
)
id
.
getType
else
tpe
...
@@ -34,25 +34,21 @@ trait Z3ModelReconstruction {
...
@@ -34,25 +34,21 @@ trait Z3ModelReconstruction {
def
modelToMap
(
model
:
Z3Model
,
ids
:
Iterable
[
Identifier
])
:
Map
[
Identifier
,
Expr
]
=
{
def
modelToMap
(
model
:
Z3Model
,
ids
:
Iterable
[
Identifier
])
:
Map
[
Identifier
,
Expr
]
=
{
var
asMap
=
Map
.
empty
[
Identifier
,
Expr
]
var
asMap
=
Map
.
empty
[
Identifier
,
Expr
]
def
completeID
(
id
:
Identifier
)
:
Unit
=
if
(
SIMPLESTCOMPLETION
)
{
asMap
=
asMap
+
((
id
->
simplestValue
(
id
.
toVariable
)))
reporter
.
info
(
"Completing variable '"
+
id
+
"' to simplest value"
)
}
else
{
asMap
=
asMap
+
((
id
->
randomValue
(
id
.
toVariable
)))
reporter
.
info
(
"Completing variable '"
+
id
+
"' to random value"
)
}
for
(
id
<-
ids
)
{
for
(
id
<-
ids
)
{
modelValue
(
model
,
id
)
match
{
modelValue
(
model
,
id
)
match
{
case
None
=>
;
// can't do much here
case
None
if
(
AUTOCOMPLETEMODELS
)
=>
completeID
(
id
)
case
Some
(
ex
)
=>
case
None
=>
;
if
(
AUTOCOMPLETEMODELS
)
{
case
Some
(
v
@
Variable
(
exprId
))
if
(
AUTOCOMPLETEMODELS
&&
exprId
==
id
)
=>
completeID
(
id
)
ex
match
{
case
Some
(
ex
)
=>
asMap
=
asMap
+
((
id
->
ex
))
case
v
@
Variable
(
exprId
)
if
exprId
==
id
=>
if
(
SIMPLESTCOMPLETION
)
{
asMap
=
asMap
+
((
id
->
simplestValue
(
id
.
toVariable
)))
reporter
.
info
(
"Completing variable '"
+
id
+
"' to simplest value"
)
}
else
{
asMap
=
asMap
+
((
id
->
randomValue
(
id
.
toVariable
)))
reporter
.
info
(
"Completing variable '"
+
id
+
"' to random value"
)
}
case
_
=>
asMap
=
asMap
+
((
id
->
ex
))
}
}
else
{
asMap
=
asMap
+
((
id
->
ex
))
}
}
}
}
}
asMap
asMap
...
...
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