equal
deleted
inserted
replaced
158 below, which is by induction on the number of iterations is the main |
158 below, which is by induction on the number of iterations is the main |
159 point to be proven; the rest is by routine application of the |
159 point to be proven; the rest is by routine application of the |
160 semantics of \texttt{WHILE}. |
160 semantics of \texttt{WHILE}. |
161 *} |
161 *} |
162 |
162 |
163 theorem while: "|- (P Int b) c P ==> |- P (While b X c) (P Int -b)" |
163 theorem while: |
|
164 assumes body: "|- (P Int b) c P" |
|
165 shows "|- P (While b X c) (P Int -b)" |
164 proof |
166 proof |
165 assume body: "|- (P Int b) c P" |
|
166 fix s s' assume s: "s : P" |
167 fix s s' assume s: "s : P" |
167 assume "Sem (While b X c) s s'" |
168 assume "Sem (While b X c) s s'" |
168 then obtain n where iter: "iter n b (Sem c) s s'" by auto |
169 then obtain n where "iter n b (Sem c) s s'" by auto |
169 have "!!s. iter n b (Sem c) s s' ==> s : P ==> s' : P Int -b" |
170 from this and s show "s' : P Int -b" |
170 proof (induct n) |
171 proof (induct n fixing: s) |
171 case (0 s) |
172 case (0 s) |
172 thus ?case by auto |
173 thus ?case by auto |
173 next |
174 next |
174 case (Suc n s) |
175 case (Suc n s) |
175 then obtain s'' where b: "s : b" and sem: "Sem c s s''" |
176 then obtain s'' where b: "s : b" and sem: "Sem c s s''" |
177 by auto |
178 by auto |
178 from Suc and b have "s : P Int b" by simp |
179 from Suc and b have "s : P Int b" by simp |
179 with body sem have "s'' : P" .. |
180 with body sem have "s'' : P" .. |
180 with iter show ?case by (rule Suc) |
181 with iter show ?case by (rule Suc) |
181 qed |
182 qed |
182 from this iter s show "s' : P Int -b" . |
|
183 qed |
183 qed |
184 |
184 |
185 |
185 |
186 subsection {* Concrete syntax for assertions *} |
186 subsection {* Concrete syntax for assertions *} |
187 |
187 |
422 lemma CondRule: |
422 lemma CondRule: |
423 "p \<subseteq> {s. (s \<in> b \<longrightarrow> s \<in> w) \<and> (s \<notin> b \<longrightarrow> s \<in> w')} |
423 "p \<subseteq> {s. (s \<in> b \<longrightarrow> s \<in> w) \<and> (s \<notin> b \<longrightarrow> s \<in> w')} |
424 \<Longrightarrow> Valid w c1 q \<Longrightarrow> Valid w' c2 q \<Longrightarrow> Valid p (Cond b c1 c2) q" |
424 \<Longrightarrow> Valid w c1 q \<Longrightarrow> Valid w' c2 q \<Longrightarrow> Valid p (Cond b c1 c2) q" |
425 by (auto simp: Valid_def) |
425 by (auto simp: Valid_def) |
426 |
426 |
427 lemma iter_aux: " |
427 lemma iter_aux: |
428 \<forall>s s'. Sem c s s' --> s : I & s : b --> s' : I ==> |
428 "\<forall>s s'. Sem c s s' --> s : I & s : b --> s' : I ==> |
429 (\<And>s s'. s : I \<Longrightarrow> iter n b (Sem c) s s' \<Longrightarrow> s' : I & s' ~: b)" |
429 (\<And>s s'. s : I \<Longrightarrow> iter n b (Sem c) s s' \<Longrightarrow> s' : I & s' ~: b)" |
430 apply(induct n) |
430 apply(induct n) |
431 apply clarsimp |
431 apply clarsimp |
432 apply (simp (no_asm_use)) |
432 apply (simp (no_asm_use)) |
433 apply blast |
433 apply blast |