swapjava.lang.NullPointerException "swap Arrayupdiyajava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
<.
y \<leftarrow> Array.nth a j;
.upd
Array swap.simps
elim
( simp)
fun rev :: " "wap dox\<leftarrow> Array.nth a i; "rev a i j Array.upd i y a;
swap
}
()"
declare.simpsrev del rev. ha!- ) is'java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
lemma swap_pointwise: assumes" case a(i+)j-java.lang.StringIndexOutOfBoundsException: Range [26, 27) out of bounds for length 26
True
else if
else!) using assms unfolding swap.simps 'where
elim
(auto and r = .t a!i
lemmaassumesrevjava.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 56 shows (< Array
else if
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
induct induct case (1 ".geth . a" thus ?case
( "i " case True caseslength simp:Array with rev[ j=0] elim) obtain sym Listh ) simp definition=Array and
exampleSML ? OCaml_imp? Scala from rev
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
have"k < i \ i = k \ (i < k \ k < j) \ j = k \ j < k" by arith with True show ?thesis by (elim disjE) (auto simp: eq swap_pointwise[OF swp]) next case False with 1[unfolded rev.simps[of a i j]] show ?thesis by (cases "k = j") (auto elim: effect_elims) qed qed
lemma rev_length: assumes"effect (rev a i j) h h' r" shows"Array.length h a = Array.length h' a" using assms proof (induct a i j arbitrary: h h' rule: rev.induct) case (1 a i j h h'') thus ?case proof (cases "i < j") case True with 1[unfolded rev.simps[of a i j]] obtain h' where
swp: "effect (swap a i j) h h' ()" and rev: "effect (rev a (i + 1) (j - 1)) h' h'' ()" by (auto elim: effect_elims) from swp rev 1 True show ?thesis unfolding swap.simps by (elim effect_elims) fastforce next case False with 1[unfolded rev.simps[of a i j]] show ?thesis by (auto elim: effect_elims) qed qed
lemma rev2_rev': assumes "effect (rev a i j) h h' u" assumes"j < Array.length h a" shows"subarray i (j + 1) a h' = List.rev (subarray i (j + 1) a h)" proof -
{ fix k assume"k < Suc j - i" with rev_pointwise[OF assms(1)] have"Array.get h' a ! (i + k) = Array.get h a ! (j - k)" by auto
} with assms(2) rev_length[OF assms(1)] show ?thesis unfolding subarray_def Array.length_def by (auto simp add: length_nths' rev_nth min_def nth_nths' intro!: nth_equalityI) qed
lemma rev2_rev: assumes"effect (rev a 0 (Array.length h a - 1)) h h' u" shows"Array.get h' a = List.rev (Array.get h a)" using rev2_rev'[OF assms] rev_length[OF assms] assms by (cases "Array.length h a = 0", auto simp add: Array.length_def
subarray_def rev.simps[where j=0] elim!: effect_elims)
(drule sym[of "List.length (Array.get h a)"], simp)
definition"example = (Array.make 10 id \ (\a. rev a 0 9))"
export_code example checking SML SML_imp OCaml? OCaml_imp? Haskell? Scala Scala_imp
end
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.