author | wenzelm |
Wed, 30 Mar 2011 23:26:40 +0200 | |
changeset 42174 | d0be2722ce9f |
parent 41589 | bbd861837ebc |
child 43143 | 1aeafba76f21 |
permissions | -rw-r--r-- |
1476 | 1 |
(* Title: HOL/IMP/Denotation.thy |
2 |
Author: Heiko Loetzbeyer & Robert Sandner, TUM |
|
924
806721cfbf46
new version of HOL/IMP with curried function application
clasohm
parents:
diff
changeset
|
3 |
*) |
806721cfbf46
new version of HOL/IMP with curried function application
clasohm
parents:
diff
changeset
|
4 |
|
12431 | 5 |
header "Denotational Semantics of Commands" |
924
806721cfbf46
new version of HOL/IMP with curried function application
clasohm
parents:
diff
changeset
|
6 |
|
16417 | 7 |
theory Denotation imports Natural begin |
12431 | 8 |
|
42174 | 9 |
type_synonym com_den = "(state \<times> state) set" |
1696 | 10 |
|
27362 | 11 |
definition |
12 |
Gamma :: "[bexp,com_den] => (com_den => com_den)" where |
|
32235
8f9b8d14fc9f
"more standard" argument order of relation composition (op O)
krauss
parents:
27362
diff
changeset
|
13 |
"Gamma b cd = (\<lambda>phi. {(s,t). (s,t) \<in> (cd O phi) \<and> b s} \<union> |
12434 | 14 |
{(s,t). s=t \<and> \<not>b s})" |
18372 | 15 |
|
27362 | 16 |
primrec C :: "com => com_den" |
17 |
where |
|
12431 | 18 |
C_skip: "C \<SKIP> = Id" |
27362 | 19 |
| C_assign: "C (x :== a) = {(s,t). t = s[x\<mapsto>a(s)]}" |
32235
8f9b8d14fc9f
"more standard" argument order of relation composition (op O)
krauss
parents:
27362
diff
changeset
|
20 |
| C_comp: "C (c0;c1) = C(c0) O C(c1)" |
27362 | 21 |
| C_if: "C (\<IF> b \<THEN> c1 \<ELSE> c2) = {(s,t). (s,t) \<in> C c1 \<and> b s} \<union> |
12434 | 22 |
{(s,t). (s,t) \<in> C c2 \<and> \<not>b s}" |
27362 | 23 |
| C_while: "C(\<WHILE> b \<DO> c) = lfp (Gamma b (C c))" |
12431 | 24 |
|
25 |
||
26 |
(**** mono (Gamma(b,c)) ****) |
|
27 |
||
28 |
lemma Gamma_mono: "mono (Gamma b c)" |
|
29 |
by (unfold Gamma_def mono_def) fast |
|
30 |
||
31 |
lemma C_While_If: "C(\<WHILE> b \<DO> c) = C(\<IF> b \<THEN> c;\<WHILE> b \<DO> c \<ELSE> \<SKIP>)" |
|
18372 | 32 |
apply simp |
15481 | 33 |
apply (subst lfp_unfold [OF Gamma_mono]) --{*lhs only*} |
34 |
apply (simp add: Gamma_def) |
|
12431 | 35 |
done |
36 |
||
37 |
(* Operational Semantics implies Denotational Semantics *) |
|
38 |
||
39 |
lemma com1: "\<langle>c,s\<rangle> \<longrightarrow>\<^sub>c t \<Longrightarrow> (s,t) \<in> C(c)" |
|
40 |
(* start with rule induction *) |
|
18372 | 41 |
apply (induct set: evalc) |
12431 | 42 |
apply auto |
43 |
(* while *) |
|
44 |
apply (unfold Gamma_def) |
|
45 |
apply (subst lfp_unfold[OF Gamma_mono, simplified Gamma_def]) |
|
46 |
apply fast |
|
47 |
apply (subst lfp_unfold[OF Gamma_mono, simplified Gamma_def]) |
|
34055 | 48 |
apply auto |
12431 | 49 |
done |
50 |
||
51 |
(* Denotational Semantics implies Operational Semantics *) |
|
52 |
||
18372 | 53 |
lemma com2: "(s,t) \<in> C(c) \<Longrightarrow> \<langle>c,s\<rangle> \<longrightarrow>\<^sub>c t" |
20503 | 54 |
apply (induct c arbitrary: s t) |
34055 | 55 |
apply auto |
56 |
apply blast |
|
12431 | 57 |
|
58 |
(* while *) |
|
23746 | 59 |
apply (erule lfp_induct2 [OF _ Gamma_mono]) |
12431 | 60 |
apply (unfold Gamma_def) |
34055 | 61 |
apply auto |
12431 | 62 |
done |
63 |
||
64 |
||
65 |
(**** Proof of Equivalence ****) |
|
66 |
||
67 |
lemma denotational_is_natural: "(s,t) \<in> C(c) = (\<langle>c,s\<rangle> \<longrightarrow>\<^sub>c t)" |
|
18372 | 68 |
by (fast elim: com2 dest: com1) |
924
806721cfbf46
new version of HOL/IMP with curried function application
clasohm
parents:
diff
changeset
|
69 |
|
806721cfbf46
new version of HOL/IMP with curried function application
clasohm
parents:
diff
changeset
|
70 |
end |