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
f7c035fe
Commit
f7c035fe
authored
13 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
fixing some bug with the substitution of vars in the postcondition
parent
a61a9ffe
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mytest/Abs.scala
+12
-9
12 additions, 9 deletions
mytest/Abs.scala
src/main/scala/leon/ImperativeCodeElimination.scala
+4
-3
4 additions, 3 deletions
src/main/scala/leon/ImperativeCodeElimination.scala
with
16 additions
and
12 deletions
mytest/Abs.scala
+
12
−
9
View file @
f7c035fe
...
...
@@ -3,19 +3,22 @@ import leon.Utils._
object
Abs
{
def
abs
(
tab
:
Map
[
Int
,
Int
],
size
:
Int
,
j
:
Int
)
:
Map
[
Int
,
Int
]
=
{
require
(
j
>=
0
&&
j
<
size
&&
tab
.
isDefinedAt
(
j
)
&&
size
>
0
)
def
abs
(
tab
:
Map
[
Int
,
Int
],
size
:
Int
,
j
:
Int
)
:
Map
[
Int
,
Int
]
=
(
{
require
(
j
>=
0
&&
j
<
size
&&
size
>
0
)
var
k
=
0
var
tabres
=
Map
.
empty
[
Int
,
Int
]
(
while
(
k
<
size
)
{
if
(
tab
(
k
)
<
0
)
tabres
=
tabres
.
updated
(
k
,
-
tab
(
k
))
else
tabres
=
tabres
.
updated
(
k
,
tab
(
k
))
if
(
tab
.
isDefinedAt
(
k
))
{
if
(
tab
(
k
)
<
0
)
tabres
=
tabres
.
updated
(
k
,
-
tab
(
k
))
else
tabres
=
tabres
.
updated
(
k
,
tab
(
k
))
}
else
{
tabres
=
tabres
.
updated
(
k
,
0
)
}
k
=
k
+
1
})
invariant
(
k
>=
0
)
})
invariant
(
k
>=
0
&&
(
if
(
j
<
k
)
tabres
(
j
)
>=
0
else
true
)
)
tabres
}
})
ensuring
(
res
=>
res
(
j
)
>=
0
)
}
This diff is collapsed.
Click to expand it.
src/main/scala/leon/ImperativeCodeElimination.scala
+
4
−
3
View file @
f7c035fe
...
...
@@ -91,14 +91,15 @@ object ImperativeCodeElimination extends Pass {
Map
(
whileFunVars
.
head
.
toVariable
->
resVar
)
else
whileFunVars
.
zipWithIndex
.
map
{
case
(
v
,
i
)
=>
(
v
.
toVariable
,
TupleSelect
(
resVar
,
i
+
1
).
setType
(
v
.
getType
))
}.
toMap
val
modifiedVars2ResultVars
:
Map
[
Expr
,
Expr
]
=
modifiedVars
.
map
(
v
=>
(
v
.
toVariable
,
modifiedVars2WhileFunVars
(
v
.
toVariable
))).
toMap
val
modifiedVars2ResultVars
:
Map
[
Expr
,
Expr
]
=
modifiedVars
.
map
(
v
=>
(
v
.
toVariable
,
whileFunVars2ResultVars
(
modifiedVars2WhileFunVars
(
v
.
toVariable
)))
)
.
toMap
val
trivialPostcondition
:
Option
[
Expr
]
=
Some
(
Not
(
replace
(
whileFunVars2ResultVars
,
whileFunCond
)))
val
invariantPrecondition
:
Option
[
Expr
]
=
wh
.
invariant
.
map
(
expr
=>
replace
(
modifiedVars2WhileFunVars
,
expr
))
val
invariantPostcondition
:
Option
[
Expr
]
=
wh
.
invariant
.
map
(
expr
=>
replace
(
modifiedVars2ResultVars
,
expr
))
whileFunDef
.
precondition
=
invariantPrecondition
whileFunDef
.
postcondition
=
trivialPostcondition
.
map
(
expr
=>
And
(
expr
,
invariantP
re
condition
match
{
case
Some
(
e
)
=>
replace
(
modifiedVars2ResultVars
,
e
)
And
(
expr
,
invariantP
ost
condition
match
{
case
Some
(
e
)
=>
e
case
None
=>
BooleanLiteral
(
true
)
}))
...
...
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