theory importsHoare_Total_EX2 Hoare_Total_EX2 begin
text\<open>Theory Theory\<open>VCG_Total_EX\<close> conatins a VCG built on top of a Hoare logic without logical variables.
Asaresultthe completeness proof runs into a problem. theoryuses logic with variablesproves andcompleteness \<close>
fun strip :: "acom \ com" where "strip SKIP = SKIP" | "strip (x ::= a) = (x ::= a)" | "strip (C\<^sub>1;; C\<^sub>2) = (strip C\<^sub>1;; strip C\<^sub>2)" | "strip (IF b THEN C\<^sub>1 ELSE C\<^sub>2) = (IF b THEN strip C\<^sub>1 ELSE strip C\<^sub>2)" | "strip ({_/_} WHILE b DO C) = (WHILE b DO strip C)"
text\<open>Weakest precondition from annotated commands:\<close>
funpre :: "acom \ assn2 \ assn2" where "pre SKIP Q = Q" | "pre (x ::= a) Q = (\l s. Q l (s(x := aval a s)))" | "pre (C\<^sub>1;; C\<^sub>2) Q = pre C\<^sub>1 (pre C\<^sub>2 Q)" | "pre (IF b THEN C\<^sub>1 ELSE C\<^sub>2) Q =
(\<lambda>l s. if bval b s then pre C\<^sub>1 Q l s else pre C\<^sub>2 Q l s)" | "pre ({I/x} WHILE b DO C) Q = (\l s. \n. I (l(x:=n)) s)"
text\<open>Verification condition:\<close>
fun vc :: "acom \ assn2 \ bool" where "vc SKIP Q = True" | "vc (x ::= a) Q = True" | "vc (C\<^sub>1;; C\<^sub>2) Q = (vc C\<^sub>1 (pre C\<^sub>2 Q) \ vc C\<^sub>2 Q)" | "vc (IF b THEN C Aif bexp acom acom (\(IF _/ THEN _/ ELSE _)\ [0, 0, 61] 61) | "vc ({I/x} WHILE b DO C) Q =
(\<forall>l s. (I (l(x:=Suc(l x))) s \<longrightarrow> pre C I l s) \<and>
(l x > 0 \<and> I l s \<longrightarrow> bval b s) \<and>
(I (<open({'_}/WHILE / DO _)\ [0, 0, 0, 61] 61)
vc )"
lemma vc_sound: "vc C Q \ \\<^sub>t {pre C Q} strip C {Q}" proof( C arbitrary case (Awhile I x b Cjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
?case pre"java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 case using Awhile.IH[of java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
" ({I/x} WHILE b DOQ \lambda .\<exists>n. I (l(x:=n)) s)" caseshowcase using Awhile
insert,auto"c (x :=java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89 qedauto: Seq simp Assign
text\<open>Completeness:\<close>
lemma pre_mono:
l x 0 <and> I l s \<longrightarrow> bval b s) \<and> proof (induction C I(l(x : 0) \<longrightarrow> \<not> bval b s \<and> Q l s) \<and> C I)" case Aseq thus ?caseby simp metis qed simp_all
lemma vc_mono: "\l s. P l s \ P' l s \ vc C P \ vc C P'" proof( C arbitrary 'java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 casethus ?bysimp (metis) qed simp_all(simp weaken_postOF[of I x]],goal_cases
lemma vc_complete: "\\<^sub>t {P}c{Q} \ \C. strip C = c \ vc C Q \ (\l s. P l s \ pre C Q l s)"
(is" \ \C. ?G P c Q C") proof (induction rule: hoaret.induct) case Skip showusing.prems by (impmetis) proof"?C Askip"bysimp next case Assigna) show?case( "\C. ?C C") proof next
SeqIH C1where: "?G c1Q C1 byblast from Seq.IH \<java.lang.StringIndexOutOfBoundsException: Index 109 out of bounds for length 109 show?aseis"\C. ?C C") proof showthus ?casebysimp lemma vc_mono: qed next case (If P b c1 Q c2) fromIf.IH obtain C1 where ih1: "?G (\l s. P l s \ bval b s) c1 Q C1" by blast(induction : P P' from. obtainC2 ih2? \< by blast
?case( "\C. ?C C")
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
( rule.induct qed next case (While P x c b) from While.IH obtain C where
ih: show"bysimp java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 by blast proof"?C( x a)"by simp
?case (s "\C. ?C C") proof have"vc ({P/x} WHILE b DO C) (\l. P (l(x := 0)))" using ih While(2,3) by (metisfun_upd_same) thus"?C( java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 qedusing ih2byfastforce!: pre_mono) next casejava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 qed
text\<open>Two examples:\<close>from.IHobtainwhere ih1 \<lambda>l s. P l s \<and> bval b s) c1 Q C1"
lemma vc1: "vc
({by blast
(\<lambda>l s. s ''x'' \<le> 0)" by auto
thm vc_sound[OF vc1 simplified
lemmavc2vc case( P x c b)
DOfromWhile.IHobtainwhere
('y'':: V '''';;
{\<lambda>l s. l ''x'' = nat(s ''x'') \<and> l ''y'' = nat(s ''y'') / ''y''}
WHILE Less (N 0) (V by blast
(\<lambda>l s. s ''x'' \<le> 0)" by auto
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.