Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
120
Issues
120
List
Boards
Labels
Service Desk
Milestones
Merge Requests
17
Merge Requests
17
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
bb609f33
Commit
bb609f33
authored
Jan 23, 2013
by
MARCHE Claude
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dumb version of insertion sort
(from challenge 1 of verifythis@fm2012 competition *)
parent
6dc70dbf
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1062 additions
and
0 deletions
+1062
-0
examples/programs/insertion_sort_dumb.mlw
examples/programs/insertion_sort_dumb.mlw
+45
-0
examples/programs/insertion_sort_dumb/why3session.xml
examples/programs/insertion_sort_dumb/why3session.xml
+1017
-0
No files found.
examples/programs/insertion_sort_dumb.mlw
0 → 100644
View file @
bb609f33
(*
"dumb" version of insertion sort: makes too many swap
see insertion_sort.mlw for a better version
*)
module InsertionSortDumb
use import int.Int
use import ref.Ref
use import ref.Refint
use import array.Array
use import array.ArraySorted
use import array.ArrayPermut
let sort (a:array int)
ensures { sorted a }
ensures { permut (old a) a }
=
'Init:
for i = 0 to a.length - 1 do
invariant { permut (at a 'Init) a }
invariant { sorted_sub a 0 i }
let j = ref i in
while !j > 0 && a[!j-1] > a[!j] do
invariant { 0 <= !j <= i }
invariant { permut (at a 'Init) a }
invariant { sorted_sub a 0 !j }
invariant { sorted_sub a !j (i+1) }
invariant { forall k1 k2:int. 0 <= k1 < !j /\ !j+1 <= k2 <= i ->
a[k1] <= a[k2] }
'L:
let b = !j - 1 in
let t = a[!j] in
a[!j] <- a[b];
a[b] <- t;
assert { exchange (at a 'L) a (!j-1) !j };
decr j
done
done
end
\ No newline at end of file
examples/programs/insertion_sort_dumb/why3session.xml
0 → 100644
View file @
bb609f33
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment