more use of module array.ArraySwap in examples

parent dd3790af
......@@ -11,16 +11,10 @@ module Quicksort
use import ref.Ref
use import array.Array
use import array.ArraySorted
use import array.ArraySwap
use import array.ArrayPermut
use import array.ArrayEq
let swap (t:array int) (i:int) (j:int)
requires { 0 <= i < length t /\ 0 <= j < length t }
ensures { exchange (old t) t i j }
= let v = t[i] in
t[i] <- t[j];
t[j] <- v
let rec quick_rec (t:array int) (l:int) (r:int) : unit variant { 1+r-l }
requires { 0 <= l /\ r < length t }
ensures { sorted_sub t l (r+1) /\ permut_sub (old t) t l (r+1) }
......
This diff is collapsed.
......@@ -7,16 +7,10 @@ module SelectionSort
use import ref.Ref
use import array.Array
use import array.ArraySorted
use import array.ArraySwap
use import array.ArrayPermut
use import array.ArrayEq
let swap (a: array int) (i: int) (j: int)
requires { 0 <= i < length a /\ 0 <= j < length a }
ensures { exchange (old a) a i j }
= let v = a[i] in
a[i] <- a[j];
a[j] <- v
let selection_sort (a: array int)
ensures { sorted a /\ permut (old a) a } =
'L:
......
This diff is collapsed.
......@@ -11,6 +11,7 @@ module TwoWaySort
use import bool.Bool
use import ref.Refint
use import array.Array
use import array.ArraySwap
use import array.ArrayPermut
predicate le (x y: bool) = x = False \/ y = True
......@@ -18,13 +19,6 @@ module TwoWaySort
predicate sorted (a: array bool) =
forall i1 i2: int. 0 <= i1 <= i2 < a.length -> le a[i1] a[i2]
let swap (a: array bool) (i: int) (j: int)
requires { 0 <= i < length a /\ 0 <= j < length a }
ensures { exchange (old a) a i j }
= let v = a[i] in
a[i] <- a[j];
a[j] <- v
let two_way_sort (a: array bool)
ensures { sorted a /\ permut (old a) a }
= 'Init:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment