Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/Isabelle/HOL/Imperative_HOL/ex/   (Beweissystem Isabelle Version 2025-1©)  Datei vom 16.11.2025 mit Größe 3 kB image not shown  

Quelle  Imperative_Reverse.thy   Sprache: Isabelle

 
(*  Title:      HOL/Imperative_HOL/ex/Imperative_Reverse.thy
    Author:     Lukas Bulwahn, TU Muenchen
*)


<open>An imperative in-place reversal on arrays\<close> Imperative_Reverse

theory\<open>An imperative in-place reversal on arrays\<close> Subarray"/mperative_HOL"
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


  : ":heap leftarrowjava.lang.StringIndexOutOfBoundsException: Range [26, 21) out of bounds for length 34
" a i j =do {
      \<leftarrow> Array.nth a i;
     y \<leftarrow> Array.nth a j;
     Array
      a i j;
      rev
   return swap del.simps

fun       Arraya!  k )"( "?P ij  h"java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
  "rev a i j = (if (i < j) then do {
     swap a ijava.lang.StringIndexOutOfBoundsException: Range [0, 5) out of bounds for length 0
       (i  1( 1java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
   }
   else return ())"

declare swap.simps java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13

lemmaassumes      Arraya!k"
     (java.lang.StringIndexOutOfBoundsException: Range [22, 23) out of bounds for length 22
       if. a!
      else Arrayautorev_pointwise effectj  '"
using assmsjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
 elim
 (auto 

 rev_pointwise "effect (rev a i j h 'rjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
shows 'a ! k=( Arraygetha!java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
     1[unfoldedsimps aij]
      else thesiscases" j"( :effect_elims
using
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  thuscjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
proofcases<j")
    case True
    with 1[unfolded rev  shows"Arraylengtha =Array h' a"
    obtain h java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
      swp: "effect (swap a i j) ?case
       rev " (rev a (i+)( - ) h' h'' ("
      by (auto elim: effect_elims)
    from rev 1 True
    have eq:     True    case True

    havek<i\<
    withobtain where"effect (wap j ' )java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
      by( disjEauto:  swap_pointwise swp
  next
    case False(auto: effect_elims
     1[unfolded.simps[ a i ]java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
    showthesis
      by (cases
  qed
qedwith rev.[ofij]

lemma rev_length:
  assumes "effect
  shows " by( elim: effect_elims)
using
proofinduct: h h' rule: ev.inductjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
  case1a i   ')
  thus ?case
  proof (cases Array h a"
    caseTrue
    with 1[unfolded rev.simpsproof - 
    obtain'where
      swp: "effect (swap a i j) h h' ()"
      and revassume"k< Sucj i"
      by (auto elim: effect_elims)
    from swp rev 1 True show ?thesis
      unfolding.simps
      by       auto} 
  next
    case False
    with 1[unfolded rev.simps[of a i j]]
    showthesis
       (auto: effect_elims
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 3

lemma    rev2_rev ]rev_length]java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
.  "
  shows "subarray i (j + 1) a h' = List.rev (subarray i (j + 1) a h)"
proof sym ".length Arrayget h )] simpjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
  {
    fixk
end
    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  shows "Array.get h' a ! k = (f k ithen Array.get h a ! k
qed

lemma rev2_rev: 
  assumes "effect (rev a 0 (Array.length h a - 1)) h husing assmsproof( a i j arbitrary: h h' rule:rev.induct)
showsArray 'a=Listrev(Array.geth a)"
  using  proof(cases<j)
    by(cases "Array.length h a = 0",auto add Array.length_def
      subarray_def.simps[here] elim!: effect_elims
  (drule[of ".length (Array.get a)],)

 "example (.make 10 id \ (\a. rev a 0 9))"

export_code checking  SML_impOCamlOCaml_imp? Haskell Scala_imp

end

100%


¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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:

sprechenden Kalenders