Commit b45604c2 by Jean-Christophe Filliâtre

modified definition of permutation; quicksort proof updated

parent 0496718b
 ... ... @@ -156,10 +156,8 @@ why.conf /examples/programs/vstte10_max_sum/ /examples/programs/vstte10_search_list/ /examples/programs/vstte10_aqueue/ /examples/programs/insertion_sort_list/ /examples/programs/mergesort_list/ /examples/programs/same_fringe/ /examples/programs/quicksort/ /examples/programs/algo63/ /examples/programs/algo64/ /examples/programs/algo65/ ... ...

 ... ... @@ -30,7 +30,7 @@ module Quicksort for i = l + 1 to r do invariant { (forall j:int. l < j <= !m -> t[j] < v) and (forall j:int. !m < j < i -> t[j] >= v) and permut_sub t (at t L) l r and permut_sub t (at t L) l (r+1) and t[l] = v and l <= !m < i } if t[i] < v then begin m := !m + 1; swap t i !m end done; ... ... @@ -38,11 +38,11 @@ module Quicksort quick_rec t l (!m - 1); quick_rec t (!m + 1) r end end { (l <= r and sorted_sub t l r and permut_sub t (old t) l r) or { (l <= r and sorted_sub t l (r+1) and permut_sub t (old t) l (r+1)) or (l > r and array_eq t (old t)) } let quicksort (t : array int) = {} { } quick_rec t 0 (length t - 1) { sorted t and permut t (old t) } ... ...

 ... ... @@ -131,9 +131,18 @@ module ArrayPermut logic permut (a1 a2: array 'a) = a1.length = a2.length and M.permut_sub a1.elts a2.elts 0 a1.length use import module ArrayEq lemma array_eq_sub_permut: forall a1 a2: array 'a, l u: int. array_eq_sub a1 a2 l u -> permut_sub a1 a2 l u lemma array_eq_permut: forall a1 a2: array 'a. array_eq a1 a2 -> permut a1 a2 end (*** module TestArray use import int.Int ... ... @@ -142,7 +151,7 @@ module TestArray let test_append () = let a1 = make 17 2 in assert { a1[3] = 2 }; set a1 3 4; a1[3] <- 4; assert { a1[3] = 4 }; let a2 = make 25 3 in assert { a2[0] = 3 }; (* needed to prove a[17]=3 below *) ... ... @@ -168,7 +177,6 @@ module TestArray assert { a2[24] = False } end ***) (* Local Variables: ... ...
 ... ... @@ -55,6 +55,7 @@ theory MapPermut use import int.Int use export Map use import MapEq logic exchange (a1 a2 : map int 'a) (i j : int) = a1[i] = a2[j] and a2[i] = a1[j] and ... ... @@ -66,7 +67,8 @@ theory MapPermut inductive permut_sub (map int 'a) (map int 'a) int int = | permut_refl : forall a : map int 'a. forall l u : int. permut_sub a a l u forall a1 a2 : map int 'a. forall l u : int. map_eq_sub a1 a2 l u -> permut_sub a1 a2 l u | permut_sym : forall a1 a2 : map int 'a. forall l u : int. permut_sub a1 a2 l u -> permut_sub a2 a1 l u ... ... @@ -84,13 +86,13 @@ theory MapPermut lemma permut_eq : forall a1 a2 : map int 'a. forall l u : int. l <= u -> permut_sub a1 a2 l u -> forall i:int. (i < l or u < i) -> a2[i] = a1[i] forall i:int. (i < l or u <= i) -> a2[i] = a1[i] lemma permut_exists : forall a1 a2 : map int 'a. forall l u : int. permut_sub a1 a2 l u -> forall i : int. l <= i <= u -> exists j : int. l <= j <= u and a2[i] = a1[j] forall i : int. l <= i < u -> exists j : int. l <= j < u and a2[i] = a1[j] end ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!