src/HOL/IMP/Denotation.thy
author wenzelm
Sun, 16 Jan 2011 15:53:03 +0100
changeset 41589 bbd861837ebc
parent 34055 fdf294ee08b2
child 42174 d0be2722ce9f
permissions -rw-r--r--
tuned headers;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1374
diff changeset
     1
(*  Title:      HOL/IMP/Denotation.thy
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1374
diff changeset
     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
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
     5
header "Denotational Semantics of Commands"
924
806721cfbf46 new version of HOL/IMP with curried function application
clasohm
parents:
diff changeset
     6
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15481
diff changeset
     7
theory Denotation imports Natural begin
12431
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
     8
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
     9
types com_den = "(state\<times>state)set"
1696
e84bff5c519b A completely new version of IMP.
nipkow
parents: 1481
diff changeset
    10
27362
a6dc1769fdda modernized specifications;
wenzelm
parents: 23746
diff changeset
    11
definition
a6dc1769fdda modernized specifications;
wenzelm
parents: 23746
diff changeset
    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
kleing
parents: 12431
diff changeset
    14
                       {(s,t). s=t \<and> \<not>b s})"
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
    15
27362
a6dc1769fdda modernized specifications;
wenzelm
parents: 23746
diff changeset
    16
primrec C :: "com => com_den"
a6dc1769fdda modernized specifications;
wenzelm
parents: 23746
diff changeset
    17
where
12431
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    18
  C_skip:   "C \<SKIP>   = Id"
27362
a6dc1769fdda modernized specifications;
wenzelm
parents: 23746
diff changeset
    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
a6dc1769fdda modernized specifications;
wenzelm
parents: 23746
diff changeset
    21
| C_if:     "C (\<IF> b \<THEN> c1 \<ELSE> c2) = {(s,t). (s,t) \<in> C c1 \<and> b s} \<union>
12434
kleing
parents: 12431
diff changeset
    22
                                                {(s,t). (s,t) \<in> C c2 \<and> \<not>b s}"
27362
a6dc1769fdda modernized specifications;
wenzelm
parents: 23746
diff changeset
    23
| C_while:  "C(\<WHILE> b \<DO> c) = lfp (Gamma b (C c))"
12431
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    24
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    25
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    26
(**** mono (Gamma(b,c)) ****)
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    27
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    28
lemma Gamma_mono: "mono (Gamma b c)"
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    29
  by (unfold Gamma_def mono_def) fast
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    30
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    31
lemma C_While_If: "C(\<WHILE> b \<DO> c) = C(\<IF> b \<THEN> c;\<WHILE> b \<DO> c \<ELSE> \<SKIP>)"
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
    32
apply simp
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 12434
diff changeset
    33
apply (subst lfp_unfold [OF Gamma_mono])  --{*lhs only*}
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 12434
diff changeset
    34
apply (simp add: Gamma_def)
12431
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    35
done
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    36
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    37
(* Operational Semantics implies Denotational Semantics *)
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    38
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    39
lemma com1: "\<langle>c,s\<rangle> \<longrightarrow>\<^sub>c t \<Longrightarrow> (s,t) \<in> C(c)"
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    40
(* start with rule induction *)
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
    41
apply (induct set: evalc)
12431
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    42
apply auto
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    43
(* while *)
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    44
apply (unfold Gamma_def)
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    45
apply (subst lfp_unfold[OF Gamma_mono, simplified Gamma_def])
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    46
apply fast
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    47
apply (subst lfp_unfold[OF Gamma_mono, simplified Gamma_def])
34055
fdf294ee08b2 streamlined proofs
paulson
parents: 32235
diff changeset
    48
apply auto 
12431
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    49
done
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    50
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    51
(* Denotational Semantics implies Operational Semantics *)
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    52
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
    53
lemma com2: "(s,t) \<in> C(c) \<Longrightarrow> \<langle>c,s\<rangle> \<longrightarrow>\<^sub>c t"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 18372
diff changeset
    54
apply (induct c arbitrary: s t)
34055
fdf294ee08b2 streamlined proofs
paulson
parents: 32235
diff changeset
    55
apply auto 
fdf294ee08b2 streamlined proofs
paulson
parents: 32235
diff changeset
    56
apply blast
12431
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    57
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    58
(* while *)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21020
diff changeset
    59
apply (erule lfp_induct2 [OF _ Gamma_mono])
12431
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    60
apply (unfold Gamma_def)
34055
fdf294ee08b2 streamlined proofs
paulson
parents: 32235
diff changeset
    61
apply auto
12431
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    62
done
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    63
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    64
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    65
(**** Proof of Equivalence ****)
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    66
07ec657249e5 converted to Isar
kleing
parents: 9241
diff changeset
    67
lemma denotational_is_natural: "(s,t) \<in> C(c)  =  (\<langle>c,s\<rangle> \<longrightarrow>\<^sub>c t)"
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 16417
diff changeset
    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