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
05156cb2
Commit
05156cb2
authored
12 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
add a List imperative and use bestRealType
parent
4db2f838
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/leon/purescala/Trees.scala
+3
-3
3 additions, 3 deletions
src/main/scala/leon/purescala/Trees.scala
testcases/ListImp.scala
+49
-0
49 additions, 0 deletions
testcases/ListImp.scala
with
52 additions
and
3 deletions
src/main/scala/leon/purescala/Trees.scala
+
3
−
3
View file @
05156cb2
...
@@ -45,14 +45,14 @@ object Trees {
...
@@ -45,14 +45,14 @@ object Trees {
/* Like vals */
/* Like vals */
case
class
Let
(
binder
:
Identifier
,
value
:
Expr
,
body
:
Expr
)
extends
Expr
{
case
class
Let
(
binder
:
Identifier
,
value
:
Expr
,
body
:
Expr
)
extends
Expr
{
binder
.
markAsLetBinder
binder
.
markAsLetBinder
val
et
=
b
ody
.
getType
val
et
=
b
inder
.
getType
if
(
et
!=
Untyped
)
if
(
et
!=
Untyped
)
setType
(
et
)
setType
(
et
)
}
}
//same as let, buf for mutable variable declaration
//same as let, buf for mutable variable declaration
case
class
LetVar
(
binder
:
Identifier
,
value
:
Expr
,
body
:
Expr
)
extends
Expr
{
case
class
LetVar
(
binder
:
Identifier
,
value
:
Expr
,
body
:
Expr
)
extends
Expr
{
binder
.
markAsLetBinder
binder
.
markAsLetBinder
val
et
=
b
ody
.
getType
val
et
=
b
inder
.
getType
if
(
et
!=
Untyped
)
if
(
et
!=
Untyped
)
setType
(
et
)
setType
(
et
)
}
}
...
@@ -77,7 +77,7 @@ object Trees {
...
@@ -77,7 +77,7 @@ object Trees {
case
class
IfExpr
(
cond
:
Expr
,
then
:
Expr
,
elze
:
Expr
)
extends
Expr
case
class
IfExpr
(
cond
:
Expr
,
then
:
Expr
,
elze
:
Expr
)
extends
Expr
case
class
Tuple
(
exprs
:
Seq
[
Expr
])
extends
Expr
{
case
class
Tuple
(
exprs
:
Seq
[
Expr
])
extends
Expr
{
val
subTpes
=
exprs
.
map
(
_
.
getType
)
val
subTpes
=
exprs
.
map
(
_
.
getType
)
.
map
(
bestRealType
)
if
(!
subTpes
.
exists
(
_
==
Untyped
))
{
if
(!
subTpes
.
exists
(
_
==
Untyped
))
{
setType
(
TupleType
(
subTpes
))
setType
(
TupleType
(
subTpes
))
}
}
...
...
This diff is collapsed.
Click to expand it.
testcases/ListImp.scala
0 → 100644
+
49
−
0
View file @
05156cb2
import
leon.Utils._
object
ListImp
{
sealed
abstract
class
List
case
class
Cons
(
head
:
Int
,
tail
:
List
)
extends
List
case
class
Nil
()
extends
List
def
content
(
l
:
List
)
:
Set
[
Int
]
=
l
match
{
case
Nil
()
=>
Set
.
empty
[
Int
]
case
Cons
(
x
,
xs
)
=>
Set
(
x
)
++
content
(
xs
)
}
def
size
(
l
:
List
)
:
Int
=
{
var
r
=
0
(
while
(!
l
.
isInstanceOf
[
Nil
])
{
r
=
r
+
1
})
invariant
(
r
>=
0
)
r
}
ensuring
(
res
=>
res
>=
0
)
def
reverse
(
l
:
List
)
:
List
=
{
var
r
:
List
=
Nil
()
var
l2
:
List
=
l
(
while
(!
l2
.
isInstanceOf
[
Nil
])
{
val
Cons
(
head
,
tail
)
=
l2
l2
=
tail
r
=
Cons
(
head
,
r
)
})
invariant
(
content
(
r
)
++
content
(
l2
)
==
content
(
l
))
r
}
ensuring
(
res
=>
content
(
res
)
==
content
(
l
))
def
append
(
l1
:
List
,
l2
:
List
)
:
List
=
{
var
r
:
List
=
l2
var
tmp
:
List
=
reverse
(
l1
)
(
while
(!
tmp
.
isInstanceOf
[
Nil
])
{
val
Cons
(
head
,
tail
)
=
tmp
tmp
=
tail
r
=
Cons
(
head
,
r
)
})
invariant
(
content
(
r
)
++
content
(
tmp
)
==
content
(
l1
)
++
content
(
l2
))
r
}
ensuring
(
content
(
_
)
==
content
(
l1
)
++
content
(
l2
))
}
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