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
0ed92012
Commit
0ed92012
authored
15 years ago
by
Mirco Dotta
Browse files
Options
Downloads
Patches
Plain Diff
mergesort example and updated 'forall' script.
parent
d995dd2d
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
forall-tests.sh
+11
-0
11 additions, 0 deletions
forall-tests.sh
tests/plugin/kawaguchi/MergeSort.scala
+47
-0
47 additions, 0 deletions
tests/plugin/kawaguchi/MergeSort.scala
with
58 additions
and
0 deletions
forall-tests.sh
+
11
−
0
View file @
0ed92012
...
...
@@ -74,6 +74,9 @@ scalac plugin/PropositionalLogic.scala
scalac plugin/SetRedBlackTree.scala
scalac plugin/ConsSnoc.scala
scalac plugin/kawaguchi/InsertSort.scala
scalac plugin/kawaguchi/MergeSort.scala
cd
..
# Scala compiler with the Funcheck plugin integrated
...
...
@@ -100,6 +103,9 @@ export PropositionalLogic="plugin.PropositionalLogic"
export
SetRedBlackTree
=
"plugin.SetRedBlackTree"
export
ConsSnoc
=
"plugin.ConsSnoc"
export
InsertSort
=
"plugin.kawaguchi.InsertSort"
export
MergeSort
=
"plugin.kawaguchi.MergeSort"
echo
" - Testing
${
BST
}
"
scala
${
BST
}
...
...
@@ -121,3 +127,8 @@ scala ${PropositionalLogic}
echo
" - Testing
${
ConsSnoc
}
"
scala
${
ConsSnoc
}
echo
" - Testing
${
InsertSort
}
"
scala
${
InsertSort
}
echo
" - Testing
${
MergeSort
}
"
scala
${
MergeSort
}
This diff is collapsed.
Click to expand it.
tests/plugin/kawaguchi/MergeSort.scala
0 → 100644
+
47
−
0
View file @
0ed92012
package
plugin.kawaguchi
import
funcheck.lib.Specs._
/* Example from paper "Type-based Data Structure Verification"
* http://pho.ucsd.edu/liquid/demo/index2.php */
object
MergeSort
{
def
halve
(
xs
:
List
[
Int
])
:
(
List
[
Int
],
List
[
Int
])
=
xs
match
{
case
Nil
=>
(
Nil
,
Nil
)
case
x
::
xs
=>
val
(
ys
,
zs
)
=
halve
(
xs
)
(
x
::
zs
,
ys
)
}
def
merge
(
xs
:
List
[
Int
],
ys
:
List
[
Int
])
:
List
[
Int
]
=
(
xs
,
ys
)
match
{
case
(
Nil
,
_
)
=>
ys
case
(
_
,
Nil
)
=>
xs
case
(
x
::
xs
,
y
::
ys
)
=>
if
(
x
<
y
)
x
::
merge
(
xs
,
y
::
ys
)
else
y
::
merge
(
x
::
xs
,
ys
)
}
def
mergesort
(
ps
:
List
[
Int
])
:
List
[
Int
]
=
ps
match
{
case
Nil
=>
Nil
case
List
(
p
)
=>
List
(
p
)
case
_
=>
val
(
qs
,
rs
)
=
halve
(
ps
)
val
qs1
=
mergesort
(
qs
)
val
rs1
=
mergesort
(
rs
)
merge
(
qs1
,
rs1
)
}
def
check
(
xs
:
List
[
Int
])
:
Boolean
=
xs
match
{
case
x
::
y
::
xs
=>
x
<=
y
&&
check
(
y
::
xs
)
case
_
=>
true
}
def
test
(
xs
:
List
[
Int
])
:
Boolean
=
check
(
mergesort
(
xs
))
forAll
{
xs
:
List
[
Int
]
=>
test
(
xs
)}
def
main
(
args
:
Array
[
String
])
=
{}
}
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