src/HOL/Imperative_HOL/ex/Imperative_Quicksort.thy
changeset 37805 0f797d586ce5
parent 37802 f2e9c104cebd
child 37806 a7679be14442
     1.1 --- a/src/HOL/Imperative_HOL/ex/Imperative_Quicksort.thy	Tue Jul 13 16:00:56 2010 +0200
     1.2 +++ b/src/HOL/Imperative_HOL/ex/Imperative_Quicksort.thy	Tue Jul 13 16:12:40 2010 +0200
     1.3 @@ -23,15 +23,15 @@
     1.4  
     1.5  lemma crel_swapI [crel_intros]:
     1.6    assumes "i < Array.length h a" "j < Array.length h a"
     1.7 -    "x = get_array a h ! i" "y = get_array a h ! j"
     1.8 +    "x = get_array h a ! i" "y = get_array h a ! j"
     1.9      "h' = Array.update a j x (Array.update a i y h)"
    1.10    shows "crel (swap a i j) h h' r"
    1.11    unfolding swap_def using assms by (auto intro!: crel_intros)
    1.12  
    1.13  lemma swap_permutes:
    1.14    assumes "crel (swap a i j) h h' rs"
    1.15 -  shows "multiset_of (get_array a h') 
    1.16 -  = multiset_of (get_array a h)"
    1.17 +  shows "multiset_of (get_array h' a) 
    1.18 +  = multiset_of (get_array h a)"
    1.19    using assms
    1.20    unfolding swap_def
    1.21    by (auto simp add: Array.length_def multiset_of_swap dest: sym [of _ "h'"] elim!: crel_bindE crel_nthE crel_returnE crel_updE)
    1.22 @@ -55,8 +55,8 @@
    1.23  
    1.24  lemma part_permutes:
    1.25    assumes "crel (part1 a l r p) h h' rs"
    1.26 -  shows "multiset_of (get_array a h') 
    1.27 -  = multiset_of (get_array a h)"
    1.28 +  shows "multiset_of (get_array h' a) 
    1.29 +  = multiset_of (get_array h a)"
    1.30    using assms
    1.31  proof (induct a l r p arbitrary: h h' rs rule:part1.induct)
    1.32    case (1 a l r p h h' rs)
    1.33 @@ -82,7 +82,7 @@
    1.34    next
    1.35      case False (* recursive case *)
    1.36      note rec_condition = this
    1.37 -    let ?v = "get_array a h ! l"
    1.38 +    let ?v = "get_array h a ! l"
    1.39      show ?thesis
    1.40      proof (cases "?v \<le> p")
    1.41        case True
    1.42 @@ -130,7 +130,7 @@
    1.43  
    1.44  lemma part_outer_remains:
    1.45    assumes "crel (part1 a l r p) h h' rs"
    1.46 -  shows "\<forall>i. i < l \<or> r < i \<longrightarrow> get_array (a::nat array) h ! i = get_array a h' ! i"
    1.47 +  shows "\<forall>i. i < l \<or> r < i \<longrightarrow> get_array h (a::nat array) ! i = get_array h' a ! i"
    1.48    using assms
    1.49  proof (induct a l r p arbitrary: h h' rs rule:part1.induct)
    1.50    case (1 a l r p h h' rs)
    1.51 @@ -145,7 +145,7 @@
    1.52    next
    1.53      case False (* recursive case *)
    1.54      note rec_condition = this
    1.55 -    let ?v = "get_array a h ! l"
    1.56 +    let ?v = "get_array h a ! l"
    1.57      show ?thesis
    1.58      proof (cases "?v \<le> p")
    1.59        case True
    1.60 @@ -163,7 +163,7 @@
    1.61          unfolding part1.simps[of a l r p]
    1.62          by (elim crel_bindE crel_nthE crel_ifE crel_returnE) auto
    1.63        from swp rec_condition have
    1.64 -        "\<forall>i. i < l \<or> r < i \<longrightarrow> get_array a h ! i = get_array a h1 ! i"
    1.65 +        "\<forall>i. i < l \<or> r < i \<longrightarrow> get_array h a ! i = get_array h1 a ! i"
    1.66          unfolding swap_def
    1.67          by (elim crel_bindE crel_nthE crel_updE crel_returnE) auto
    1.68        with 1(2) [OF rec_condition False rec2] show ?thesis by fastsimp
    1.69 @@ -174,8 +174,8 @@
    1.70  
    1.71  lemma part_partitions:
    1.72    assumes "crel (part1 a l r p) h h' rs"
    1.73 -  shows "(\<forall>i. l \<le> i \<and> i < rs \<longrightarrow> get_array (a::nat array) h' ! i \<le> p)
    1.74 -  \<and> (\<forall>i. rs < i \<and> i \<le> r \<longrightarrow> get_array a h' ! i \<ge> p)"
    1.75 +  shows "(\<forall>i. l \<le> i \<and> i < rs \<longrightarrow> get_array h' (a::nat array) ! i \<le> p)
    1.76 +  \<and> (\<forall>i. rs < i \<and> i \<le> r \<longrightarrow> get_array h' a ! i \<ge> p)"
    1.77    using assms
    1.78  proof (induct a l r p arbitrary: h h' rs rule:part1.induct)
    1.79    case (1 a l r p h h' rs)
    1.80 @@ -192,7 +192,7 @@
    1.81    next
    1.82      case False (* recursive case *)
    1.83      note lr = this
    1.84 -    let ?v = "get_array a h ! l"
    1.85 +    let ?v = "get_array h a ! l"
    1.86      show ?thesis
    1.87      proof (cases "?v \<le> p")
    1.88        case True
    1.89 @@ -200,7 +200,7 @@
    1.90        have rec1: "crel (part1 a (l + 1) r p) h h' rs"
    1.91          unfolding part1.simps[of a l r p]
    1.92          by (elim crel_bindE crel_nthE crel_ifE crel_returnE) auto
    1.93 -      from True part_outer_remains[OF rec1] have a_l: "get_array a h' ! l \<le> p"
    1.94 +      from True part_outer_remains[OF rec1] have a_l: "get_array h' a ! l \<le> p"
    1.95          by fastsimp
    1.96        have "\<forall>i. (l \<le> i = (l = i \<or> Suc l \<le> i))" by arith
    1.97        with 1(1)[OF False True rec1] a_l show ?thesis
    1.98 @@ -212,10 +212,10 @@
    1.99          and rec2: "crel (part1 a l (r - 1) p) h1 h' rs"
   1.100          unfolding part1.simps[of a l r p]
   1.101          by (elim crel_bindE crel_nthE crel_ifE crel_returnE) auto
   1.102 -      from swp False have "get_array a h1 ! r \<ge> p"
   1.103 +      from swp False have "get_array h1 a ! r \<ge> p"
   1.104          unfolding swap_def
   1.105          by (auto simp add: Array.length_def elim!: crel_bindE crel_nthE crel_updE crel_returnE)
   1.106 -      with part_outer_remains [OF rec2] lr have a_r: "get_array a h' ! r \<ge> p"
   1.107 +      with part_outer_remains [OF rec2] lr have a_r: "get_array h' a ! r \<ge> p"
   1.108          by fastsimp
   1.109        have "\<forall>i. (i \<le> r = (i = r \<or> i \<le> r - 1))" by arith
   1.110        with 1(2)[OF lr False rec2] a_r show ?thesis
   1.111 @@ -240,8 +240,8 @@
   1.112  
   1.113  lemma partition_permutes:
   1.114    assumes "crel (partition a l r) h h' rs"
   1.115 -  shows "multiset_of (get_array a h') 
   1.116 -  = multiset_of (get_array a h)"
   1.117 +  shows "multiset_of (get_array h' a) 
   1.118 +  = multiset_of (get_array h a)"
   1.119  proof -
   1.120      from assms part_permutes swap_permutes show ?thesis
   1.121        unfolding partition.simps
   1.122 @@ -260,7 +260,7 @@
   1.123  lemma partition_outer_remains:
   1.124    assumes "crel (partition a l r) h h' rs"
   1.125    assumes "l < r"
   1.126 -  shows "\<forall>i. i < l \<or> r < i \<longrightarrow> get_array (a::nat array) h ! i = get_array a h' ! i"
   1.127 +  shows "\<forall>i. i < l \<or> r < i \<longrightarrow> get_array h (a::nat array) ! i = get_array h' a ! i"
   1.128  proof -
   1.129    from assms part_outer_remains part_returns_index_in_bounds show ?thesis
   1.130      unfolding partition.simps swap_def
   1.131 @@ -273,10 +273,10 @@
   1.132    shows "l \<le> rs \<and> rs \<le> r"
   1.133  proof -
   1.134    from crel obtain middle h'' p where part: "crel (part1 a l (r - 1) p) h h'' middle"
   1.135 -    and rs_equals: "rs = (if get_array a h'' ! middle \<le> get_array a h ! r then middle + 1
   1.136 +    and rs_equals: "rs = (if get_array h'' a ! middle \<le> get_array h a ! r then middle + 1
   1.137           else middle)"
   1.138      unfolding partition.simps
   1.139 -    by (elim crel_bindE crel_returnE crel_nthE crel_ifE crel_updE) simp
   1.140 +    by (elim crel_bindE crel_returnE crel_nthE crel_ifE crel_updE) simp 
   1.141    from `l < r` have "l \<le> r - 1" by arith
   1.142    from part_returns_index_in_bounds[OF part this] rs_equals `l < r` show ?thesis by auto
   1.143  qed
   1.144 @@ -284,18 +284,18 @@
   1.145  lemma partition_partitions:
   1.146    assumes crel: "crel (partition a l r) h h' rs"
   1.147    assumes "l < r"
   1.148 -  shows "(\<forall>i. l \<le> i \<and> i < rs \<longrightarrow> get_array (a::nat array) h' ! i \<le> get_array a h' ! rs) \<and>
   1.149 -  (\<forall>i. rs < i \<and> i \<le> r \<longrightarrow> get_array a h' ! rs \<le> get_array a h' ! i)"
   1.150 +  shows "(\<forall>i. l \<le> i \<and> i < rs \<longrightarrow> get_array h' (a::nat array) ! i \<le> get_array h' a ! rs) \<and>
   1.151 +  (\<forall>i. rs < i \<and> i \<le> r \<longrightarrow> get_array h' a ! rs \<le> get_array h' a ! i)"
   1.152  proof -
   1.153 -  let ?pivot = "get_array a h ! r" 
   1.154 +  let ?pivot = "get_array h a ! r" 
   1.155    from crel obtain middle h1 where part: "crel (part1 a l (r - 1) ?pivot) h h1 middle"
   1.156      and swap: "crel (swap a rs r) h1 h' ()"
   1.157 -    and rs_equals: "rs = (if get_array a h1 ! middle \<le> ?pivot then middle + 1
   1.158 +    and rs_equals: "rs = (if get_array h1 a ! middle \<le> ?pivot then middle + 1
   1.159           else middle)"
   1.160      unfolding partition.simps
   1.161      by (elim crel_bindE crel_returnE crel_nthE crel_ifE crel_updE) simp
   1.162 -  from swap have h'_def: "h' = Array.update a r (get_array a h1 ! rs)
   1.163 -    (Array.update a rs (get_array a h1 ! r) h1)"
   1.164 +  from swap have h'_def: "h' = Array.update a r (get_array h1 a ! rs)
   1.165 +    (Array.update a rs (get_array h1 a ! r) h1)"
   1.166      unfolding swap_def
   1.167      by (elim crel_bindE crel_returnE crel_nthE crel_updE) simp
   1.168    from swap have in_bounds: "r < Array.length h1 a \<and> rs < Array.length h1 a"
   1.169 @@ -306,15 +306,15 @@
   1.170    from `l < r` have "l \<le> r - 1" by simp
   1.171    note middle_in_bounds = part_returns_index_in_bounds[OF part this]
   1.172    from part_outer_remains[OF part] `l < r`
   1.173 -  have "get_array a h ! r = get_array a h1 ! r"
   1.174 +  have "get_array h a ! r = get_array h1 a ! r"
   1.175      by fastsimp
   1.176    with swap
   1.177 -  have right_remains: "get_array a h ! r = get_array a h' ! rs"
   1.178 +  have right_remains: "get_array h a ! r = get_array h' a ! rs"
   1.179      unfolding swap_def
   1.180      by (auto simp add: Array.length_def elim!: crel_bindE crel_returnE crel_nthE crel_updE) (cases "r = rs", auto)
   1.181    from part_partitions [OF part]
   1.182    show ?thesis
   1.183 -  proof (cases "get_array a h1 ! middle \<le> ?pivot")
   1.184 +  proof (cases "get_array h1 a ! middle \<le> ?pivot")
   1.185      case True
   1.186      with rs_equals have rs_equals: "rs = middle + 1" by simp
   1.187      { 
   1.188 @@ -324,8 +324,8 @@
   1.189        have i_props: "i < Array.length h' a" "i \<noteq> r" "i \<noteq> rs" by auto
   1.190        from i_is_left rs_equals have "l \<le> i \<and> i < middle \<or> i = middle" by arith
   1.191        with part_partitions[OF part] right_remains True
   1.192 -      have "get_array a h1 ! i \<le> get_array a h' ! rs" by fastsimp
   1.193 -      with i_props h'_def in_bounds have "get_array a h' ! i \<le> get_array a h' ! rs"
   1.194 +      have "get_array h1 a ! i \<le> get_array h' a ! rs" by fastsimp
   1.195 +      with i_props h'_def in_bounds have "get_array h' a ! i \<le> get_array h' a ! rs"
   1.196          unfolding Array.update_def Array.length_def by simp
   1.197      }
   1.198      moreover
   1.199 @@ -334,13 +334,13 @@
   1.200        assume "rs < i \<and> i \<le> r"
   1.201  
   1.202        hence "(rs < i \<and> i \<le> r - 1) \<or> (rs < i \<and> i = r)" by arith
   1.203 -      hence "get_array a h' ! rs \<le> get_array a h' ! i"
   1.204 +      hence "get_array h' a ! rs \<le> get_array h' a ! i"
   1.205        proof
   1.206          assume i_is: "rs < i \<and> i \<le> r - 1"
   1.207          with swap_length_remains in_bounds middle_in_bounds rs_equals
   1.208          have i_props: "i < Array.length h' a" "i \<noteq> r" "i \<noteq> rs" by auto
   1.209          from part_partitions[OF part] rs_equals right_remains i_is
   1.210 -        have "get_array a h' ! rs \<le> get_array a h1 ! i"
   1.211 +        have "get_array h' a ! rs \<le> get_array h1 a ! i"
   1.212            by fastsimp
   1.213          with i_props h'_def show ?thesis by fastsimp
   1.214        next
   1.215 @@ -348,7 +348,7 @@
   1.216          with rs_equals have "Suc middle \<noteq> r" by arith
   1.217          with middle_in_bounds `l < r` have "Suc middle \<le> r - 1" by arith
   1.218          with part_partitions[OF part] right_remains 
   1.219 -        have "get_array a h' ! rs \<le> get_array a h1 ! (Suc middle)"
   1.220 +        have "get_array h' a ! rs \<le> get_array h1 a ! (Suc middle)"
   1.221            by fastsimp
   1.222          with i_is True rs_equals right_remains h'_def
   1.223          show ?thesis using in_bounds
   1.224 @@ -366,8 +366,8 @@
   1.225        with swap_length_remains in_bounds middle_in_bounds rs_equals
   1.226        have i_props: "i < Array.length h' a" "i \<noteq> r" "i \<noteq> rs" by auto
   1.227        from part_partitions[OF part] rs_equals right_remains i_is_left
   1.228 -      have "get_array a h1 ! i \<le> get_array a h' ! rs" by fastsimp
   1.229 -      with i_props h'_def have "get_array a h' ! i \<le> get_array a h' ! rs"
   1.230 +      have "get_array h1 a ! i \<le> get_array h' a ! rs" by fastsimp
   1.231 +      with i_props h'_def have "get_array h' a ! i \<le> get_array h' a ! rs"
   1.232          unfolding Array.update_def by simp
   1.233      }
   1.234      moreover
   1.235 @@ -375,13 +375,13 @@
   1.236        fix i
   1.237        assume "rs < i \<and> i \<le> r"
   1.238        hence "(rs < i \<and> i \<le> r - 1) \<or> i = r" by arith
   1.239 -      hence "get_array a h' ! rs \<le> get_array a h' ! i"
   1.240 +      hence "get_array h' a ! rs \<le> get_array h' a ! i"
   1.241        proof
   1.242          assume i_is: "rs < i \<and> i \<le> r - 1"
   1.243          with swap_length_remains in_bounds middle_in_bounds rs_equals
   1.244          have i_props: "i < Array.length h' a" "i \<noteq> r" "i \<noteq> rs" by auto
   1.245          from part_partitions[OF part] rs_equals right_remains i_is
   1.246 -        have "get_array a h' ! rs \<le> get_array a h1 ! i"
   1.247 +        have "get_array h' a ! rs \<le> get_array h1 a ! i"
   1.248            by fastsimp
   1.249          with i_props h'_def show ?thesis by fastsimp
   1.250        next
   1.251 @@ -420,8 +420,8 @@
   1.252  
   1.253  lemma quicksort_permutes:
   1.254    assumes "crel (quicksort a l r) h h' rs"
   1.255 -  shows "multiset_of (get_array a h') 
   1.256 -  = multiset_of (get_array a h)"
   1.257 +  shows "multiset_of (get_array h' a) 
   1.258 +  = multiset_of (get_array h a)"
   1.259    using assms
   1.260  proof (induct a l r arbitrary: h h' rs rule: quicksort.induct)
   1.261    case (1 a l r h h' rs)
   1.262 @@ -443,7 +443,7 @@
   1.263  
   1.264  lemma quicksort_outer_remains:
   1.265    assumes "crel (quicksort a l r) h h' rs"
   1.266 -   shows "\<forall>i. i < l \<or> r < i \<longrightarrow> get_array (a::nat array) h ! i = get_array a h' ! i"
   1.267 +   shows "\<forall>i. i < l \<or> r < i \<longrightarrow> get_array h (a::nat array) ! i = get_array h' a ! i"
   1.268    using assms
   1.269  proof (induct a l r arbitrary: h h' rs rule: quicksort.induct)
   1.270    case (1 a l r h h' rs)
   1.271 @@ -465,14 +465,14 @@
   1.272        assume pivot: "l \<le> p \<and> p \<le> r"
   1.273        assume i_outer: "i < l \<or> r < i"
   1.274        from  partition_outer_remains [OF part True] i_outer
   1.275 -      have "get_array a h !i = get_array a h1 ! i" by fastsimp
   1.276 +      have "get_array h a !i = get_array h1 a ! i" by fastsimp
   1.277        moreover
   1.278        with 1(1) [OF True pivot qs1] pivot i_outer
   1.279 -      have "get_array a h1 ! i = get_array a h2 ! i" by auto
   1.280 +      have "get_array h1 a ! i = get_array h2 a ! i" by auto
   1.281        moreover
   1.282        with qs2 1(2) [of p h2 h' ret2] True pivot i_outer
   1.283 -      have "get_array a h2 ! i = get_array a h' ! i" by auto
   1.284 -      ultimately have "get_array a h ! i= get_array a h' ! i" by simp
   1.285 +      have "get_array h2 a ! i = get_array h' a ! i" by auto
   1.286 +      ultimately have "get_array h a ! i= get_array h' a ! i" by simp
   1.287      }
   1.288      with cr show ?thesis
   1.289        unfolding quicksort.simps [of a l r]
   1.290 @@ -512,7 +512,7 @@
   1.291        have pivot: "l\<le> p \<and> p \<le> r" .
   1.292       note length_remains = length_remains[OF qs2] length_remains[OF qs1] partition_length_remains[OF part]
   1.293        from quicksort_outer_remains [OF qs2] quicksort_outer_remains [OF qs1] pivot quicksort_is_skip[OF qs1]
   1.294 -      have pivot_unchanged: "get_array a h1 ! p = get_array a h' ! p" by (cases p, auto)
   1.295 +      have pivot_unchanged: "get_array h1 a ! p = get_array h' a ! p" by (cases p, auto)
   1.296          (*-- First of all, by induction hypothesis both sublists are sorted. *)
   1.297        from 1(1)[OF True pivot qs1] length_remains pivot 1(5) 
   1.298        have IH1: "sorted (subarray l p a h2)"  by (cases p, auto simp add: subarray_Nil)
   1.299 @@ -525,35 +525,35 @@
   1.300          by (cases "Suc p \<le> r", auto simp add: subarray_Nil)
   1.301             (* -- Secondly, both sublists remain partitioned. *)
   1.302        from partition_partitions[OF part True]
   1.303 -      have part_conds1: "\<forall>j. j \<in> set (subarray l p a h1) \<longrightarrow> j \<le> get_array a h1 ! p "
   1.304 -        and part_conds2: "\<forall>j. j \<in> set (subarray (p + 1) (r + 1) a h1) \<longrightarrow> get_array a h1 ! p \<le> j"
   1.305 +      have part_conds1: "\<forall>j. j \<in> set (subarray l p a h1) \<longrightarrow> j \<le> get_array h1 a ! p "
   1.306 +        and part_conds2: "\<forall>j. j \<in> set (subarray (p + 1) (r + 1) a h1) \<longrightarrow> get_array h1 a ! p \<le> j"
   1.307          by (auto simp add: all_in_set_subarray_conv)
   1.308        from quicksort_outer_remains [OF qs1] quicksort_permutes [OF qs1] True
   1.309 -        length_remains 1(5) pivot multiset_of_sublist [of l p "get_array a h1" "get_array a h2"]
   1.310 +        length_remains 1(5) pivot multiset_of_sublist [of l p "get_array h1 a" "get_array h2 a"]
   1.311        have multiset_partconds1: "multiset_of (subarray l p a h2) = multiset_of (subarray l p a h1)"
   1.312          unfolding Array.length_def subarray_def by (cases p, auto)
   1.313        with left_subarray_remains part_conds1 pivot_unchanged
   1.314 -      have part_conds2': "\<forall>j. j \<in> set (subarray l p a h') \<longrightarrow> j \<le> get_array a h' ! p"
   1.315 +      have part_conds2': "\<forall>j. j \<in> set (subarray l p a h') \<longrightarrow> j \<le> get_array h' a ! p"
   1.316          by (simp, subst set_of_multiset_of[symmetric], simp)
   1.317            (* -- These steps are the analogous for the right sublist \<dots> *)
   1.318        from quicksort_outer_remains [OF qs1] length_remains
   1.319        have right_subarray_remains: "subarray (p + 1) (r + 1) a h1 = subarray (p + 1) (r + 1) a h2"
   1.320          by (auto simp add: subarray_eq_samelength_iff)
   1.321        from quicksort_outer_remains [OF qs2] quicksort_permutes [OF qs2] True
   1.322 -        length_remains 1(5) pivot multiset_of_sublist [of "p + 1" "r + 1" "get_array a h2" "get_array a h'"]
   1.323 +        length_remains 1(5) pivot multiset_of_sublist [of "p + 1" "r + 1" "get_array h2 a" "get_array h' a"]
   1.324        have multiset_partconds2: "multiset_of (subarray (p + 1) (r + 1) a h') = multiset_of (subarray (p + 1) (r + 1) a h2)"
   1.325          unfolding Array.length_def subarray_def by auto
   1.326        with right_subarray_remains part_conds2 pivot_unchanged
   1.327 -      have part_conds1': "\<forall>j. j \<in> set (subarray (p + 1) (r + 1) a h') \<longrightarrow> get_array a h' ! p \<le> j"
   1.328 +      have part_conds1': "\<forall>j. j \<in> set (subarray (p + 1) (r + 1) a h') \<longrightarrow> get_array h' a ! p \<le> j"
   1.329          by (simp, subst set_of_multiset_of[symmetric], simp)
   1.330            (* -- Thirdly and finally, we show that the array is sorted
   1.331            following from the facts above. *)
   1.332 -      from True pivot 1(5) length_remains have "subarray l (r + 1) a h' = subarray l p a h' @ [get_array a h' ! p] @ subarray (p + 1) (r + 1) a h'"
   1.333 +      from True pivot 1(5) length_remains have "subarray l (r + 1) a h' = subarray l p a h' @ [get_array h' a ! p] @ subarray (p + 1) (r + 1) a h'"
   1.334          by (simp add: subarray_nth_array_Cons, cases "l < p") (auto simp add: subarray_append subarray_Nil)
   1.335        with IH1' IH2 part_conds1' part_conds2' pivot have ?thesis
   1.336          unfolding subarray_def
   1.337          apply (auto simp add: sorted_append sorted_Cons all_in_set_sublist'_conv)
   1.338 -        by (auto simp add: set_sublist' dest: le_trans [of _ "get_array a h' ! p"])
   1.339 +        by (auto simp add: set_sublist' dest: le_trans [of _ "get_array h' a ! p"])
   1.340      }
   1.341      with True cr show ?thesis
   1.342        unfolding quicksort.simps [of a l r]
   1.343 @@ -564,16 +564,16 @@
   1.344  
   1.345  lemma quicksort_is_sort:
   1.346    assumes crel: "crel (quicksort a 0 (Array.length h a - 1)) h h' rs"
   1.347 -  shows "get_array a h' = sort (get_array a h)"
   1.348 -proof (cases "get_array a h = []")
   1.349 +  shows "get_array h' a = sort (get_array h a)"
   1.350 +proof (cases "get_array h a = []")
   1.351    case True
   1.352    with quicksort_is_skip[OF crel] show ?thesis
   1.353    unfolding Array.length_def by simp
   1.354  next
   1.355    case False
   1.356 -  from quicksort_sorts [OF crel] False have "sorted (sublist' 0 (List.length (get_array a h)) (get_array a h'))"
   1.357 +  from quicksort_sorts [OF crel] False have "sorted (sublist' 0 (List.length (get_array h a)) (get_array h' a))"
   1.358      unfolding Array.length_def subarray_def by auto
   1.359 -  with length_remains[OF crel] have "sorted (get_array a h')"
   1.360 +  with length_remains[OF crel] have "sorted (get_array h' a)"
   1.361      unfolding Array.length_def by simp
   1.362    with quicksort_permutes [OF crel] properties_for_sort show ?thesis by fastsimp
   1.363  qed