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
9ef0ded5
Commit
9ef0ded5
authored
9 years ago
by
Manos Koukoutos
Browse files
Options
Downloads
Patches
Plain Diff
Add run-lenght encoding benchmark
parent
5f5986a7
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
testcases/synthesis/current/RunLength/RunLength.scala
+60
-0
60 additions, 0 deletions
testcases/synthesis/current/RunLength/RunLength.scala
testcases/synthesis/current/run.sh
+3
-0
3 additions, 0 deletions
testcases/synthesis/current/run.sh
with
63 additions
and
0 deletions
testcases/synthesis/current/RunLength/RunLength.scala
0 → 100644
+
60
−
0
View file @
9ef0ded5
import
leon.lang._
import
leon.lang.synthesis._
import
leon.annotation._
import
leon.collection._
object
RunLength
{
def
decode
[
A
](
l
:
List
[(
BigInt
,
A
)])
:
List
[
A
]
=
{
def
fill
[
A
](
i
:
BigInt
,
a
:
A
)
:
List
[
A
]
=
{
if
(
i
>
0
)
a
::
fill
(
i
-
1
,
a
)
else
Nil
[
A
]()
}
l
match
{
case
Nil
()
=>
Nil
[
A
]()
case
Cons
((
i
,
x
),
xs
)
=>
fill
(
i
,
x
)
++
decode
(
xs
)
}
}
def
legal
[
A
](
l
:
List
[(
BigInt
,
A
)])
:
Boolean
=
l
match
{
case
Cons
((
i
,
x
),
tl
)
=>
i
>
0
&&
(
tl
match
{
case
Cons
((
_
,
y
),
_
)
=>
x
!=
y
case
_
=>
true
})
&&
legal
(
tl
)
case
_
=>
true
}
/*def unique[A](l1: List[A], l2: List[A]) => {
require(encode(l1) == encode(l2))
l1 == l2
}.holds*/
// Solvable with --manual=2,0,0,1,0,0,3,0,1,1,0,0,1,0,0,0,1,1,1
def
encode
[
A
](
l
:
List
[
A
])
:
List
[(
BigInt
,
A
)]
=
{
// Solution
/*l match {
case Nil() => Nil[(BigInt, A)]()
case Cons(x, xs) =>
val rec = encode(xs)
rec match {
case Nil() =>
Cons( (BigInt(1), x), Nil[(BigInt,A)]())
case Cons( (recC, recEl), recTl) =>
if (x == recEl) {
Cons( (1+recC, x), recTl)
} else {
Cons( (BigInt(1), x), rec )
}
}
}*/
???[
List
[(
BigInt
,
A
)]]
}
ensuring
{
(
res
:
List
[(
BigInt
,
A
)])
=>
legal
(
res
)
&&
decode
(
res
)
==
l
}
}
This diff is collapsed.
Click to expand it.
testcases/synthesis/current/run.sh
+
3
−
0
View file @
9ef0ded5
...
...
@@ -41,3 +41,6 @@ run testcases/synthesis/current/BatchedQueue/Dequeue.scala
# AddressBook
run testcases/synthesis/current/AddressBook/Make.scala
run testcases/synthesis/current/AddressBook/Merge.scala
# RunLength
run testcases/synthesis/current/RunLength/RunLength.scala
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