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

Quelle  Loop.thy   Sprache: Isabelle

 
(*  Title:      HOL/HOLCF/ex/Loop.thy
    Author:     Franz Regensburger
*)


section \<open>Theory for a loop primitive like while\<close>(*  Title:      HOL/HOLCF/ex/Loop.thyAuthor     Franz Regensburger

theory Loop
imports HOLCF
begin

definition
  step  :: "('a \<rightarrow> tr) \<rightarrow> ('a \<rightarrow> 'a) \<rightarrow> 'a \<rightarrow> 'a" where
  "step = (LAM b g x. If b\<cdot>x then g\<cdot>x else x)"

definition
  while :: "('a \<rightarrow> tr) \<rightarrow> ('a \<rightarrow> 'a) \<rightarrow> 'a \<rightarrow> 'a" where
  "while = (LAM b g. fix\<cdot>(LAM f x. If b\<cdot>x then f\<cdot>(g\<cdot>x) else x))"

(* ------------------------------------------------------------------------- *)

(* access to definitions                                                     *)
(* ------------------------------------------------------------------------- *)


 step_def2: "java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
  step_def
apply rule_tacs =while
done

lemma( java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
applysimp allI
apply simp
done


(* ------------------------------------------------------------------------- *)
(* rekursive properties of while                                             *)
(* ------------------------------------------------------------------------- *)apply (rule while_unfold

lemma ruletrans
apply(rule
lemma loop_lemma1\lbrakk\<\<cdot>y = FF; iterate k\<cdot>(step\<cdot>b\<cdot>g)\<cdot>x = UU\<rbrakk>
apply simp
done

lemmaapply java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
 k
apply simp ( transjava.lang.StringIndexOutOfBoundsException: Range [18, 19) out of bounds for length 18
apply simp
apply (rulejava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
apply(rule      iterate
)
apply
apply  loop_lemma3 (no_asm
apply subst)
apply(ule_tac"\java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
apply simpjava.lang.StringIndexOutOfBoundsException: Index 154 out of bounds for length 154
apply (subst( s  "hile\b\g\(iterate (Suc 0)\(step\b\g)\x)" in trans)
apply(rule_tac"UU" t = b
apply (erule simp))
applyapply ( stripsimp
apply apply( p = "b(iterate n\(step\b\g)\x)" in trE)
apply simp
apply (subst while_unfold)
apply simp ( notE)
done

 while_unfold3: "hile\b\g\x = while\b\g\(step\b\g\x)"
apply (rule_tac  "\b\g\(iterate (Suc 0)\(step\b\g)\x)" in trans)
applyapply (simp
apply simpapply (rule_tac s = "iterate (Suc and t = "g\<cdot>(iterate n\<cdot>(step\<cdot>b\<cdot>g)\<cdot>x)" in ssubst)
donedone


(* ------------------------------------------------------------------------- *) trans
(* properties of while and iterations                                        *)
(* ------------------------------------------------------------------------- *)(ubstapply simpapply (apply (simplesubstapply (introapply apply (ruleappl

 blast:)
     <Longrightarro='color:blue'>"\\x. INV x \ b\x = TT \ g\x \ UU \ INV (g\x);

         \<exists>y. b\<cdot>y = FF; INV x\<rbrakk>apply (erule_tacapply (apply (rule_tac [2] iterate_Sucapply (simp addapplydone
      <Longrightarrow> iterate k\<cdot>(step\<cdot>b\<cdot>g)\<cdot>x \<noteq> UU \<longrightarrow> INV (iterate k\<cdot>(step\<cdot>b\<cdot>g)\<cdot>x)"done
apply (induct_tac"k"java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
apply (simp (no_asm_simp
apply ( strip
apply(impno_asmstep_def2
apply (lemma loop_lemma3rule_format (no_asm)]:
apply( otE
apply (simp add: step_def2)
apply (      <Longrightarrow
apply (rakkjava.lang.StringIndexOutOfBoundsException: Index 115 out of bounds for length 115
apply forall.INV y \<and> b\<cdot>y = FF \<longrightarrow> Q y);  x;\<
apply (simpno_asm_simp: iterate_Suc add apply (simp (no_asm_simp) del: iterate_Suc add: loop_lemma2( add(loop_lemma4
  s=" Sucn\(step\b\g)\x"
   t = ( )
 2apply()
apply  addstep_def2
apply(rule) )
done

lemma loop_lemma4 [rule_format]:
  java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
  rule_format
apply   :"
apply (   and premTTy 
applyapply     premFF
apply java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
apply (loop_inv2
apply (rule_tac3]premPTHEN java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
apply ( )
apply (rule esubst  blast: premTT
apply(while_unfold3
apply
done

lemma loop_lemma5rule_formatno_asm)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  "\k. b\(iterate k\(step\b\g)\x) \ FF \
    \<forall>m. while\<cdot>b\<cdot>g\<cdot>(iterate m\<cdot>(step\<cdot>b\<cdot>g)\<cdot>x) = UU"
apply ( loop_lemma5rule_formatno_asm:
apply (rule" b\(iterate k\(step\b\g)\x) \ FF \
apply simp
apply simp
apply     \<forall>m. while\<cdot>b\<cdot>g\<cdot>(iterate m\<cdot>(step\<cdot>b\<cdot>g)\<cdot>x) = UU" while_def2
 simpjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
 ( p  "\cdot(m\(step\b\g)\x)" in trE)
apply (simp(no_asm_simp
apply rule_tac"\(iterate (Suc m)\(step\b\g)\x)" in trans)
cdot( (Suc)<cdot>(step\<cdot>b\<cdot>g)\<cdot>x)" in trans)
apply (erule_tac [2] spec (rule cfun_arg_cong
applyarg_cong
apply (rule (rule_tac [2] iterate_Sucsymmetric])
apply(rule_tac2] iterate_Suc])
apply (simp add: step_def2blast
apply blast
done

lemma loop_lemma6 rule_tac =""initerate_0 [THEN])
apply (rule_tac t = "x" in iterate_0 [THEN subst])
 erule
done

lemmaloop_lemma7java.lang.NullPointerException
java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
done


(* ------------------------------------------------------------------------- *)
(* an invariant rule for loops                                               *)
(* ------------------------------------------------------------------------- *)

lemma loop_inv2:
"\(\y. INV y \ b\y = TT \ g\y \ UU \ INV (g\y));
    (\<forall>y. INV y \<and> b\<cdot>y = FF \<longrightarrow> Q y); rule_tac =".b(iterate k\(step\b\g)\x) = FF" in exE)
    INV x; while\<cdot>b\<cdot>g\<cdot>x \<noteq> UU\<rbrakk> \<Longrightarrow> Q (while\<cdot>b\<cdot>g\<cdot>x)"erule)
apply assumption
apply ( specerule )
apply  rule)
apply assumption   ()
apply (drule spec, erule loop_lemma3
apply (ruleblast: loop_lemma6java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
prefer loop_inv
apply  assumes"("
apply assumption
apply (blast intro: loop_lemma6)
apply assumption premI\<And>y. P y \<Longrightarrow> INV y"
applyrotate_tac1
apply (simp addand\<And>y. \<lbrakk>INV y; b\<cdot>y = FF\<rbrakk> \<Longrightarrow> Q y"
done

lemma loop_inv:
  assumes rule loop_inv2
java.lang.StringIndexOutOfBoundsException: Range [6, 4) out of bounds for length 53
a premTTjava.lang.NullPointerException
    and premFF: "\y. \INV y; b\y = FF\ \ Q y"
    and premW: "while\b\g\x \ UU"
  shows "Q(while\b\g\x)"
apply(rule loop_inv2
apply( [3]premPTHEN ])
apply (rule_tac
apply (blast intro: premTT)
apply (blast intro: premFF)
done

end

100%


¤ Dauer der Verarbeitung: 0.2 Sekunden  (vorverarbeitet)  ¤

*© 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:

Die farbliche Syntaxdarstellung ist noch experimentell.