text‹This theoryshows that in the small-step semantics one can only reach
a finite number of commands from any given command. Hence one can see the
command component of a small-step configuration as a combination of the
program to be executed and a pc.›
definition reachable :: "com \ com set"where "reachable c = {c'. \s t. (c,s) \* (c',t)}"
text‹Proofs need induction on the length of a small-step reduction sequence.›
fun small_stepsn :: "com * state \ nat \ com * state \ bool"
(‹_ →'(_') _› [55,0,55] 55) where "(cs \(0) cs') = (cs' = cs)" | "cs \(Suc n) cs'' = (\cs'. cs \ cs' \ cs' \(n) cs'')"
lemma stepsn_if_star: "cs \* cs' \ \n. cs \(n) cs'" proof(induction rule: star.induct) case refl show ?caseby (metis small_stepsn.simps(1)) next case step thus ?caseby (metis small_stepsn.simps(2)) qed
lemma If_starD: "(IF b THEN c1 ELSE c2, s) \* (c,t) \
c = IF b THEN c1 ELSE c2 ∨ (c1,s) →* (c,t) ∨ (c2,s) →* (c,t)" by(induction"IF b THEN c1 ELSE c2" s c t rule: star_induct) auto
lemma reachable_If: "reachable (IF b THEN c1 ELSE c2) \
{IF b THEN c1 ELSE c2} ∪ reachable c1 ∪ reachable c2" by(auto simp: reachable_def dest!: If_starD)
lemma While_stepsnD: "(WHILE b DO c, s) \(n) (c2,t) \
c2 ∈ {WHILE b DO c, IF b THEN c ;; WHILE b DO c ELSE SKIP, SKIP} ∨ (∃c1. c2 = c1 ;; WHILE b DO c ∧ (∃ s1 s2. (c,s1) →* (c1,s2)))" proof(induction n arbitrary: s rule: less_induct) case (less n1) show ?case proof(cases n1) case 0 thus ?thesis using less.prems by (simp) next case (Suc n2) let ?w = "WHILE b DO c" let ?iw = "IF b THEN c ;; ?w ELSE SKIP" from Suc less.prems have n2: "(?iw,s) \(n2) (c2,t)"by(auto elim!: WhileE) show ?thesis proof(cases n2) case 0 thus ?thesis using n2 by auto next case (Suc n3) thenobtain iw' s'where"(?iw,s) \ (iw',s')" and n3: "(iw',s') \(n3) (c2,t)"using n2 by auto from this(1) show ?thesis proof assume"(iw', s') = (c;; WHILE b DO c, s)" with n3 have"(c;;?w, s) \(n3) (c2,t)"by auto from Seq_stepsnD[OF this] show ?thesis proof assume"\c1' m. c2 = c1';; ?w \ (c,s) \(m) (c1', t) \ m \ n3" thus ?thesis by (metis star_if_stepsn) next assume"\s2 m1 m2. (c, s) \(m1) (SKIP, s2) \
(WHILE b DO c, s2) →(m2) (c2, t) ∧ m1 + m2 < n3" (is "∃x y z. ?P x y z") thenobtain s2 m1 m2 where"?P s2 m1 m2"by blast with‹n2 = Suc n3›‹n1 = Suc n2›have"m2 < n1"by arith from less.IH[OF this] ‹?P s2 m1 m2›show ?thesis by blast qed next assume"(iw', s') = (SKIP, s)" thus ?thesis using star_if_stepsn[OF n3] by(auto dest!: SKIP_starD) qed qed qed qed
lemma reachable_While: "reachable (WHILE b DO c) \
{WHILE b DO c, IF b THEN c ;; WHILE b DO c ELSE SKIP, SKIP} ∪
(λc'. c' ;; WHILE b DO c) ` reachable c" apply(auto simp: reachable_def image_def) by (metis While_stepsnD insertE singletonE stepsn_if_star)
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 und die Messung sind noch experimentell.