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
80c3df73
Commit
80c3df73
authored
12 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
remove invariants of BubbleSort to identify a clearer bug
parent
67e30baf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
demo/BubbleSortBug.scala
+2
-37
2 additions, 37 deletions
demo/BubbleSortBug.scala
with
2 additions
and
37 deletions
demo/BubbleSortBug.scala
+
2
−
37
View file @
80c3df73
...
@@ -18,23 +18,9 @@ object BubbleSortBug {
...
@@ -18,23 +18,9 @@ object BubbleSortBug {
sa
(
j
+
1
)
=
tmp
sa
(
j
+
1
)
=
tmp
}
}
j
=
j
+
1
j
=
j
+
1
})
invariant
(
})
invariant
(
j
>=
0
&&
j
<=
i
&&
i
<
sa
.
length
)
j
>=
0
&&
j
<=
i
&&
i
<
sa
.
length
&&
sa
.
length
>=
0
&&
partitioned
(
sa
,
0
,
i
,
i
+
1
,
sa
.
length
-
1
)
&&
sorted
(
sa
,
i
,
sa
.
length
-
1
)
&&
partitioned
(
sa
,
0
,
j
,
j
+
1
,
j
+
1
)
)
i
=
i
-
1
i
=
i
-
1
})
invariant
(
})
invariant
(
i
>=
0
&&
i
<
sa
.
length
)
i
>=
0
&&
i
<
sa
.
length
&&
sa
.
length
>=
0
&&
partitioned
(
sa
,
0
,
i
,
i
+
1
,
sa
.
length
-
1
)
&&
sorted
(
sa
,
i
,
sa
.
length
-
1
)
)
sa
sa
})
ensuring
(
res
=>
sorted
(
res
,
0
,
a
.
length
-
1
))
})
ensuring
(
res
=>
sorted
(
res
,
0
,
a
.
length
-
1
))
...
@@ -50,25 +36,4 @@ object BubbleSortBug {
...
@@ -50,25 +36,4 @@ object BubbleSortBug {
isSorted
isSorted
}
}
def
partitioned
(
a
:
Array
[
Int
],
l1
:
Int
,
u1
:
Int
,
l2
:
Int
,
u2
:
Int
)
:
Boolean
=
{
require
(
a
.
length
>=
0
&&
l1
>=
0
&&
u1
<
l2
&&
u2
<
a
.
length
)
if
(
l2
>
u2
||
l1
>
u1
)
true
else
{
var
i
=
l1
var
j
=
l2
var
isPartitionned
=
true
(
while
(
i
<=
u1
)
{
j
=
l2
(
while
(
j
<=
u2
)
{
if
(
a
(
i
)
>
a
(
j
))
isPartitionned
=
false
j
=
j
+
1
})
invariant
(
j
>=
l2
&&
i
<=
u1
)
i
=
i
+
1
})
invariant
(
i
>=
l1
)
isPartitionned
}
}
}
}
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