src/HOL/IMP/Abs_Int0.thy
changeset 46063 81ebd0cdb300
parent 46039 698de142f6f9
child 46066 e81411bfa7ef
equal deleted inserted replaced
46062:9bc924006136 46063:81ebd0cdb300
    10 functions. *}
    10 functions. *}
    11 
    11 
    12 context Val_abs
    12 context Val_abs
    13 begin
    13 begin
    14 
    14 
    15 fun aval' :: "aexp \<Rightarrow> 'a st \<Rightarrow> 'a" where
    15 fun aval' :: "aexp \<Rightarrow> 'av st \<Rightarrow> 'av" where
    16 "aval' (N n) S = num' n" |
    16 "aval' (N n) S = num' n" |
    17 "aval' (V x) S = lookup S x" |
    17 "aval' (V x) S = lookup S x" |
    18 "aval' (Plus a1 a2) S = plus' (aval' a1 S) (aval' a2 S)"
    18 "aval' (Plus a1 a2) S = plus' (aval' a1 S) (aval' a2 S)"
    19 
    19 
    20 lemma aval'_sound: "s : \<gamma>\<^isub>f S \<Longrightarrow> aval a s : \<gamma>(aval' a S)"
    20 lemma aval'_sound: "s : \<gamma>\<^isub>f S \<Longrightarrow> aval a s : \<gamma>(aval' a S)"
    21 by (induct a) (auto simp: gamma_num' gamma_plus' \<gamma>_st_def lookup_def)
    21 by (induct a) (auto simp: gamma_num' gamma_plus' \<gamma>_st_def lookup_def)
    22 
    22 
    23 end
    23 end
    24 
    24 
    25 locale Abs_Int = Val_abs
    25 text{* The for-clause (here and elsewhere) only serves the purpose of fixing
       
    26 the name of the type parameter @{typ 'av} which would otherwise be renamed to
       
    27 @{typ 'a}. *}
       
    28 
       
    29 locale Abs_Int = Val_abs \<gamma> for \<gamma> :: "'av::SL_top \<Rightarrow> val set"
    26 begin
    30 begin
    27 
    31 
    28 fun step' :: "'a st option \<Rightarrow> 'a st option acom \<Rightarrow> 'a st option acom" where
    32 fun step' :: "'av st option \<Rightarrow> 'av st option acom \<Rightarrow> 'av st option acom" where
    29 "step' S (SKIP {P}) = (SKIP {S})" |
    33 "step' S (SKIP {P}) = (SKIP {S})" |
    30 "step' S (x ::= e {P}) =
    34 "step' S (x ::= e {P}) =
    31   x ::= e {case S of None \<Rightarrow> None | Some S \<Rightarrow> Some(update S x (aval' e S))}" |
    35   x ::= e {case S of None \<Rightarrow> None | Some S \<Rightarrow> Some(update S x (aval' e S))}" |
    32 "step' S (c1; c2) = step' S c1; step' (post c1) c2" |
    36 "step' S (c1; c2) = step' S c1; step' (post c1) c2" |
    33 "step' S (IF b THEN c1 ELSE c2 {P}) =
    37 "step' S (IF b THEN c1 ELSE c2 {P}) =
    34   (let c1' = step' S c1; c2' = step' S c2
    38   (let c1' = step' S c1; c2' = step' S c2
    35    in IF b THEN c1' ELSE c2' {post c1 \<squnion> post c2})" |
    39    in IF b THEN c1' ELSE c2' {post c1 \<squnion> post c2})" |
    36 "step' S ({Inv} WHILE b DO c {P}) =
    40 "step' S ({Inv} WHILE b DO c {P}) =
    37    {S \<squnion> post c} WHILE b DO step' Inv c {Inv}"
    41    {S \<squnion> post c} WHILE b DO step' Inv c {Inv}"
    38 
    42 
    39 definition AI :: "com \<Rightarrow> 'a st option acom option" where
    43 definition AI :: "com \<Rightarrow> 'av st option acom option" where
    40 "AI = lpfp\<^isub>c (step' \<top>)"
    44 "AI = lpfp\<^isub>c (step' \<top>)"
    41 
    45 
    42 
    46 
    43 lemma strip_step'[simp]: "strip(step' S c) = strip c"
    47 lemma strip_step'[simp]: "strip(step' S c) = strip c"
    44 by(induct c arbitrary: S) (simp_all add: Let_def)
    48 by(induct c arbitrary: S) (simp_all add: Let_def)