From 589f029747709b25009ff3cb15199193b26c5b4f Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Mon, 4 Mar 2013 14:31:38 +0100 Subject: [PATCH] more use of module array.ArraySwap in examples --- examples/quicksort.mlw | 8 +- examples/quicksort/why3session.xml | 176 +++++++-------- examples/selection_sort.mlw | 8 +- examples/selection_sort/why3session.xml | 209 +++++++++++------- examples/vstte12_two_way_sort.mlw | 8 +- examples/vstte12_two_way_sort/why3session.xml | 98 ++++---- 6 files changed, 243 insertions(+), 264 deletions(-) diff --git a/examples/quicksort.mlw b/examples/quicksort.mlw index ccd43381d..6222317b8 100644 --- a/examples/quicksort.mlw +++ b/examples/quicksort.mlw @@ -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) } diff --git a/examples/quicksort/why3session.xml b/examples/quicksort/why3session.xml index 6103a5059..d802b913b 100644 --- a/examples/quicksort/why3session.xml +++ b/examples/quicksort/why3session.xml @@ -24,39 +24,19 @@ + expanded="false"> - - + expanded="false"> @@ -69,9 +49,9 @@ @@ -89,9 +69,9 @@ @@ -109,9 +89,9 @@ @@ -129,9 +109,9 @@ @@ -149,9 +129,9 @@ @@ -169,9 +149,9 @@ @@ -189,9 +169,9 @@ @@ -209,9 +189,9 @@ @@ -229,9 +209,9 @@ @@ -249,9 +229,9 @@ @@ -269,9 +249,9 @@ @@ -289,9 +269,9 @@ @@ -304,9 +284,9 @@ @@ -324,9 +304,9 @@ @@ -344,9 +324,9 @@ @@ -359,15 +339,15 @@ edited="quicksort_WP_Quicksort_WP_parameter_quick_rec_1.v" obsolete="false" archived="false"> - + @@ -385,9 +365,9 @@ @@ -405,9 +385,9 @@ @@ -427,9 +407,9 @@ @@ -447,9 +427,9 @@ @@ -467,9 +447,9 @@ @@ -482,9 +462,9 @@ @@ -502,9 +482,9 @@ @@ -522,9 +502,9 @@ @@ -542,9 +522,9 @@ @@ -564,9 +544,9 @@ @@ -584,9 +564,9 @@ @@ -604,9 +584,9 @@ @@ -624,9 +604,9 @@ @@ -644,9 +624,9 @@ @@ -659,15 +639,15 @@ edited="quicksort_WP_Quicksort_WP_parameter_quick_rec_2.v" obsolete="false" archived="false"> - + @@ -680,9 +660,9 @@ @@ -700,9 +680,9 @@ @@ -724,9 +704,9 @@ @@ -739,9 +719,9 @@ @@ -775,9 +755,9 @@ diff --git a/examples/selection_sort.mlw b/examples/selection_sort.mlw index b1ad5faea..44798f025 100644 --- a/examples/selection_sort.mlw +++ b/examples/selection_sort.mlw @@ -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: diff --git a/examples/selection_sort/why3session.xml b/examples/selection_sort/why3session.xml index f902252fe..e345ea7e7 100644 --- a/examples/selection_sort/why3session.xml +++ b/examples/selection_sort/why3session.xml @@ -19,32 +19,12 @@ loclnum="4" loccnumb="7" loccnume="20" verified="true" expanded="true"> - - @@ -57,11 +37,11 @@