src/HOL/IMP/Def_Ass_Sound_Small.thy
author bulwahn
Fri Oct 21 11:17:14 2011 +0200 (2011-10-21)
changeset 45231 d85a2fdc586c
parent 45015 fdac1e9880eb
child 47818 151d137f1095
permissions -rw-r--r--
replacing code_inline by code_unfold, removing obsolete code_unfold, code_inline del now that the ancient code generator is removed
kleing@43158
     1
(* Author: Tobias Nipkow *)
kleing@43158
     2
kleing@43158
     3
theory Def_Ass_Sound_Small imports Def_Ass Def_Ass_Small
kleing@43158
     4
begin
kleing@43158
     5
kleing@43158
     6
subsection "Soundness wrt Small Steps"
kleing@43158
     7
kleing@43158
     8
theorem progress:
kleing@43158
     9
  "D (dom s) c A' \<Longrightarrow> c \<noteq> SKIP \<Longrightarrow> EX cs'. (c,s) \<rightarrow> cs'"
nipkow@45015
    10
proof (induction c arbitrary: s A')
kleing@43158
    11
  case Assign thus ?case by auto (metis aval_Some small_step.Assign)
kleing@43158
    12
next
kleing@43158
    13
  case (If b c1 c2)
kleing@43158
    14
  then obtain bv where "bval b s = Some bv" by (auto dest!:bval_Some)
kleing@43158
    15
  then show ?case
kleing@43158
    16
    by(cases bv)(auto intro: small_step.IfTrue small_step.IfFalse)
nipkow@44890
    17
qed (fastforce intro: small_step.intros)+
kleing@43158
    18
kleing@43158
    19
lemma D_mono:  "D A c M \<Longrightarrow> A \<subseteq> A' \<Longrightarrow> EX M'. D A' c M' & M <= M'"
nipkow@45015
    20
proof (induction c arbitrary: A A' M)
kleing@43158
    21
  case Semi thus ?case by auto (metis D.intros(3))
kleing@43158
    22
next
kleing@43158
    23
  case (If b c1 c2)
kleing@43158
    24
  then obtain M1 M2 where "vars b \<subseteq> A" "D A c1 M1" "D A c2 M2" "M = M1 \<inter> M2"
kleing@43158
    25
    by auto
nipkow@45015
    26
  with If.IH `A \<subseteq> A'` obtain M1' M2'
kleing@43158
    27
    where "D A' c1 M1'" "D A' c2 M2'" and "M1 \<subseteq> M1'" "M2 \<subseteq> M2'" by metis
kleing@43158
    28
  hence "D A' (IF b THEN c1 ELSE c2) (M1' \<inter> M2')" and "M \<subseteq> M1' \<inter> M2'"
nipkow@44890
    29
    using `vars b \<subseteq> A` `A \<subseteq> A'` `M = M1 \<inter> M2` by(fastforce intro: D.intros)+
kleing@43158
    30
  thus ?case by metis
kleing@43158
    31
next
kleing@43158
    32
  case While thus ?case by auto (metis D.intros(5) subset_trans)
kleing@43158
    33
qed (auto intro: D.intros)
kleing@43158
    34
kleing@43158
    35
theorem D_preservation:
kleing@43158
    36
  "(c,s) \<rightarrow> (c',s') \<Longrightarrow> D (dom s) c A \<Longrightarrow> EX A'. D (dom s') c' A' & A <= A'"
nipkow@45015
    37
proof (induction arbitrary: A rule: small_step_induct)
kleing@43158
    38
  case (While b c s)
kleing@43158
    39
  then obtain A' where "vars b \<subseteq> dom s" "A = dom s" "D (dom s) c A'" by blast
kleing@43158
    40
  moreover
kleing@43158
    41
  then obtain A'' where "D A' c A''" by (metis D_incr D_mono)
kleing@43158
    42
  ultimately have "D (dom s) (IF b THEN c; WHILE b DO c ELSE SKIP) (dom s)"
kleing@43158
    43
    by (metis D.If[OF `vars b \<subseteq> dom s` D.Semi[OF `D (dom s) c A'` D.While[OF _ `D A' c A''`]] D.Skip] D_incr Int_absorb1 subset_trans)
kleing@43158
    44
  thus ?case by (metis D_incr `A = dom s`)
kleing@43158
    45
next
kleing@43158
    46
  case Semi2 thus ?case by auto (metis D_mono D.intros(3))
kleing@43158
    47
qed (auto intro: D.intros)
kleing@43158
    48
kleing@43158
    49
theorem D_sound:
kleing@43158
    50
  "(c,s) \<rightarrow>* (c',s') \<Longrightarrow> D (dom s) c A' \<Longrightarrow> c' \<noteq> SKIP
kleing@43158
    51
   \<Longrightarrow> \<exists>cs''. (c',s') \<rightarrow> cs''"
nipkow@45015
    52
apply(induction arbitrary: A' rule:star_induct)
kleing@43158
    53
apply (metis progress)
kleing@43158
    54
by (metis D_preservation)
kleing@43158
    55
kleing@43158
    56
end