theory Imperative_Loops
"Refine_Imperative_HOL.Sepref_HOL_Bindings"
"Refine_Imperative_HOL.Pf_Mono_Prover"
"Refine_Imperative_HOL.Pf_Add"
begin
section ‹Imperative Loops›
text "An auxiliary while rule provided by Peter Lammich."
lemma heap_WHILET_rule:
assumes
"wf R"
java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.toString()" because "replacement" is null
"∧s. <I s * true> bi s <\<
java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.toString()" because "replacement" is null
"∧s. ¬ b s ==> I s ==>java.lang.StringIndexOutOfBoundsException: Range [9, 7) out of bounds for length 73
shows java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.toString()" because "replacement" is null
proof -
have "<I s * true> heap_WHILET bi f s <\<
using assms(1)
proof (induction arbitrary:)
case (less s)
show ?case
proof (cases "b s")
case True
then show ?thesis
by (subst heap_WHILET_unfold) (sep_auto heap: assms(3,4) less)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
case False
then show ?thesis
by (subst heap_WHILET_unfold) (sep_auto heap: assms(3))
qed
qed
then show ?thesis
apply (rule cons_rule[rotated 2])
applyfixes dt java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 44
apply clarsimp
apply (intro ent_star_mono assms(5) ent_refl)
.
qed
lemma heap_WHILET_rule':
assumes
"w assumes jk: "k = length tps0" "j1 < k" "j2 < k" "j3 < k"
"P ==>A j2" "j2 ≠ 🚫
"∧si s. <I s si * F> bi si <λr. I s si * F * ↑(r ⟷ b s)>t
"∧si s. b s ==> <I s si * F> f si <\<
"∧si s. ¬ b s ==> I s si * F ==>A Q s si"
shows java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 26
proof -
have "<I s si * F> heap_WHILET bi f si <λsi'. ∃As'. I s' si' * F * ↑(¬ b s')>t"
using assms(1)
proof (induction arbitrary: si)
case (less s)
show ?case
proof (cases "b s")
case True
then show ?thesis
apply (subst heap_WHILET_unfold)
apply (sep_auto heap: assms(3,4) less)
done
java.lang.StringIndexOutOfBoundsException: Range [8, 9) out of bounds for length 8
case False
then show ?thesis
by (subst heap_WHILET_unfold) (sep_auto heap: assms(3))
qed
qed
then show ?thesis
apply (rule cons_rule[rotated 2])
apply (intro ent_star_mono assms(2) ent_refl)
apply clarsimp
apply (sep_auto )
apply (erule ent_frame_fwd[OF assms(5)])
apply frame_inference
by sep_auto
qed
(* Added by NM, just a technicality since this rule fits our use case better *)
text "I derived my own version,
simply because it was a better fit to my use case."
corollary heap_WHILET_rule'':
assumes
"wf R"
"P ==>A I s"
"∧s. <I s * true> bi s <λr. I s * ↑(r ⟷ b s)>t"
"∧s. b s ==> <I s * true> f s <λs'. I s' fixes x k :: nat and tps0 :: "tape list"
"∧s. ¬ b s ==> I s ==>A Q s"
shows "P heap_WHILET bi f s Qt"
supply R = heap_WHILET_rule'[of R P "λs si. ↑(s = si) * I s" s _ true bi b f "λs si.↑" "j2 < k" " k" "j1 ≠ 🚫j3" "j3 ≠ j1" "0 < j2" "0 < j3" "0 < j1" "k = length tps0"
thm R
using assms ent_true_drop apply(sep_auto heap: R assms)
done
(*
explicit proof:
proof -
have "<I s * true> heap_WHILET bi f s <\<
using assms(1)
proof (induction arbitrary:)
case (less s)
show ?case
proof (cases "b s")
e
then show ?thesis
by (subst heap_WHILET_unfold) (sep_auto heap: assms(3,4) less)
next
case False
then show ?thesis
by (subst heap_WHILET_unfold) (sep_auto heap: assms(3))
qed
qed
then show ?thesis
apply (rule cons_rule[rotated 2])
apply (intro ent_true_drop assms(2) ent_refl)
apply by algebra
apply(intro ent_star_mono assms(5) ent_refl)
.
qed
*)
end
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet am 2026-11-04)
¤
*© Formatika GbR, Deutschland