equal
deleted
inserted
replaced
37 text {* |
37 text {* |
38 Using the basic \name{assign} rule directly is a bit cumbersome. |
38 Using the basic \name{assign} rule directly is a bit cumbersome. |
39 *} |
39 *} |
40 |
40 |
41 lemma |
41 lemma |
42 "|- .{\<acute>(N_update (2 * \<acute>N)) : .{\<acute>N = #10}.}. \<acute>N := 2 * \<acute>N .{\<acute>N = #10}." |
42 "|- .{\<acute>(N_update (# 2 * \<acute>N)) : .{\<acute>N = # 10}.}. \<acute>N := # 2 * \<acute>N .{\<acute>N = # 10}." |
43 by (rule assign) |
43 by (rule assign) |
44 |
44 |
45 text {* |
45 text {* |
46 Certainly we want the state modification already done, e.g.\ by |
46 Certainly we want the state modification already done, e.g.\ by |
47 simplification. The \name{hoare} method performs the basic state |
47 simplification. The \name{hoare} method performs the basic state |
48 update for us; we may apply the Simplifier afterwards to achieve |
48 update for us; we may apply the Simplifier afterwards to achieve |
49 ``obvious'' consequences as well. |
49 ``obvious'' consequences as well. |
50 *} |
50 *} |
51 |
51 |
52 lemma "|- .{True}. \<acute>N := #10 .{\<acute>N = #10}." |
52 lemma "|- .{True}. \<acute>N := # 10 .{\<acute>N = # 10}." |
53 by hoare |
53 by hoare |
54 |
54 |
55 lemma "|- .{2 * \<acute>N = #10}. \<acute>N := 2 * \<acute>N .{\<acute>N = #10}." |
55 lemma "|- .{# 2 * \<acute>N = # 10}. \<acute>N := # 2 * \<acute>N .{\<acute>N = # 10}." |
56 by hoare |
56 by hoare |
57 |
57 |
58 lemma "|- .{\<acute>N = #5}. \<acute>N := 2 * \<acute>N .{\<acute>N = #10}." |
58 lemma "|- .{\<acute>N = # 5}. \<acute>N := # 2 * \<acute>N .{\<acute>N = # 10}." |
59 by hoare simp |
59 by hoare simp |
60 |
60 |
61 lemma "|- .{\<acute>N + 1 = a + 1}. \<acute>N := \<acute>N + 1 .{\<acute>N = a + 1}." |
61 lemma "|- .{\<acute>N + 1 = a + 1}. \<acute>N := \<acute>N + 1 .{\<acute>N = a + 1}." |
62 by hoare |
62 by hoare |
63 |
63 |
110 finally show ?thesis . |
110 finally show ?thesis . |
111 qed |
111 qed |
112 |
112 |
113 lemma "|- .{\<acute>M = \<acute>N}. \<acute>M := \<acute>M + 1 .{\<acute>M ~= \<acute>N}." |
113 lemma "|- .{\<acute>M = \<acute>N}. \<acute>M := \<acute>M + 1 .{\<acute>M ~= \<acute>N}." |
114 proof - |
114 proof - |
115 have "!!m n. m = n --> m + 1 ~= n" |
115 have "!!m n::nat. m = n --> m + 1 ~= n" |
116 -- {* inclusion of assertions expressed in ``pure'' logic, *} |
116 -- {* inclusion of assertions expressed in ``pure'' logic, *} |
117 -- {* without mentioning the state space *} |
117 -- {* without mentioning the state space *} |
118 by simp |
118 by simp |
119 also have "|- .{\<acute>M + 1 ~= \<acute>N}. \<acute>M := \<acute>M + 1 .{\<acute>M ~= \<acute>N}." |
119 also have "|- .{\<acute>M + 1 ~= \<acute>N}. \<acute>M := \<acute>M + 1 .{\<acute>M ~= \<acute>N}." |
120 by hoare |
120 by hoare |