src/HOL/Bali/Trans.thy
author haftmann
Fri Jun 11 17:14:02 2010 +0200 (2010-06-11)
changeset 37407 61dd8c145da7
parent 35416 d8d7d1b785af
child 37597 a02ea93e88c6
permissions -rw-r--r--
declare lex_prod_def [code del]
     1 (*  Title:      HOL/Bali/Trans.thy
     2     Author:     David von Oheimb and Norbert Schirmer
     3 
     4 Operational transition (small-step) semantics of the 
     5 execution of Java expressions and statements
     6 
     7 PRELIMINARY!!!!!!!!
     8 *)
     9 
    10 theory Trans imports Evaln begin
    11 
    12 definition groundVar :: "var \<Rightarrow> bool" where
    13 "groundVar v \<equiv> (case v of
    14                    LVar ln \<Rightarrow> True
    15                  | {accC,statDeclC,stat}e..fn \<Rightarrow> \<exists> a. e=Lit a
    16                  | e1.[e2] \<Rightarrow> \<exists> a i. e1= Lit a \<and> e2 = Lit i
    17                  | InsInitV c v \<Rightarrow> False)"
    18 
    19 lemma groundVar_cases [consumes 1, case_names LVar FVar AVar]:
    20   assumes ground: "groundVar v" and
    21           LVar: "\<And> ln. \<lbrakk>v=LVar ln\<rbrakk> \<Longrightarrow> P" and
    22           FVar: "\<And> accC statDeclC stat a fn. 
    23                     \<lbrakk>v={accC,statDeclC,stat}(Lit a)..fn\<rbrakk> \<Longrightarrow> P" and
    24           AVar: "\<And> a i. \<lbrakk>v=(Lit a).[Lit i]\<rbrakk> \<Longrightarrow> P"
    25   shows "P"
    26 proof -
    27   from ground LVar FVar AVar
    28   show ?thesis
    29     apply (cases v)
    30     apply (simp add: groundVar_def)
    31     apply (simp add: groundVar_def,blast)
    32     apply (simp add: groundVar_def,blast)
    33     apply (simp add: groundVar_def)
    34     done
    35 qed
    36 
    37 definition groundExprs :: "expr list \<Rightarrow> bool" where
    38 "groundExprs es \<equiv> list_all (\<lambda> e. \<exists> v. e=Lit v) es"
    39   
    40 consts the_val:: "expr \<Rightarrow> val"
    41 primrec
    42 "the_val (Lit v) = v"
    43 
    44 consts the_var:: "prog \<Rightarrow> state \<Rightarrow> var \<Rightarrow> (vvar \<times> state)"
    45 primrec
    46 "the_var G s (LVar ln)                    =(lvar ln (store s),s)"
    47 the_var_FVar_def:
    48 "the_var G s ({accC,statDeclC,stat}a..fn) =fvar statDeclC stat fn (the_val a) s"
    49 the_var_AVar_def:
    50 "the_var G s(a.[i])                       =avar G (the_val i) (the_val a) s"
    51 
    52 lemma the_var_FVar_simp[simp]:
    53 "the_var G s ({accC,statDeclC,stat}(Lit a)..fn) = fvar statDeclC stat fn a s"
    54 by (simp)
    55 declare the_var_FVar_def [simp del]
    56 
    57 lemma the_var_AVar_simp:
    58 "the_var G s ((Lit a).[Lit i]) = avar G i a s"
    59 by (simp)
    60 declare the_var_AVar_def [simp del]
    61 
    62 abbreviation
    63   Ref :: "loc \<Rightarrow> expr"
    64   where "Ref a == Lit (Addr a)"
    65 
    66 abbreviation
    67   SKIP :: "expr"
    68   where "SKIP == Lit Unit"
    69 
    70 inductive
    71   step :: "[prog,term \<times> state,term \<times> state] \<Rightarrow> bool" ("_\<turnstile>_ \<mapsto>1 _"[61,82,82] 81)
    72   for G :: prog
    73 where
    74 
    75 (* evaluation of expression *)
    76   (* cf. 15.5 *)
    77   Abrupt:       "\<lbrakk>\<forall>v. t \<noteq> \<langle>Lit v\<rangle>;
    78                   \<forall> t. t \<noteq> \<langle>l\<bullet> Skip\<rangle>;
    79                   \<forall> C vn c.  t \<noteq> \<langle>Try Skip Catch(C vn) c\<rangle>;
    80                   \<forall> x c. t \<noteq> \<langle>Skip Finally c\<rangle> \<and> xc \<noteq> Xcpt x;
    81                   \<forall> a c. t \<noteq> \<langle>FinA a c\<rangle>\<rbrakk> 
    82                 \<Longrightarrow> 
    83                   G\<turnstile>(t,Some xc,s) \<mapsto>1 (\<langle>Lit undefined\<rangle>,Some xc,s)"
    84 
    85 | InsInitE: "\<lbrakk>G\<turnstile>(\<langle>c\<rangle>,Norm s) \<mapsto>1 (\<langle>c'\<rangle>, s')\<rbrakk>
    86              \<Longrightarrow> 
    87              G\<turnstile>(\<langle>InsInitE c e\<rangle>,Norm s) \<mapsto>1 (\<langle>InsInitE c' e\<rangle>, s')"
    88 
    89 (* SeqE: "G\<turnstile>(\<langle>Seq Skip e\<rangle>,Norm s) \<mapsto>1 (\<langle>e\<rangle>, Norm s)" *)
    90 (* Specialised rules to evaluate: 
    91    InsInitE Skip (NewC C), InisInitE Skip (NewA T[e]) *)
    92  
    93   (* cf. 15.8.1 *)
    94 | NewC: "G\<turnstile>(\<langle>NewC C\<rangle>,Norm s) \<mapsto>1 (\<langle>InsInitE (Init C) (NewC C)\<rangle>, Norm s)"
    95 | NewCInited: "\<lbrakk>G\<turnstile> Norm s \<midarrow>halloc (CInst C)\<succ>a\<rightarrow> s'\<rbrakk> 
    96                \<Longrightarrow> 
    97                G\<turnstile>(\<langle>InsInitE Skip (NewC C)\<rangle>,Norm s) \<mapsto>1 (\<langle>Ref a\<rangle>, s')"
    98 
    99 
   100 
   101 (* Alternative when rule SeqE is present 
   102 NewCInited: "\<lbrakk>inited C (globs s); 
   103               G\<turnstile> Norm s \<midarrow>halloc (CInst C)\<succ>a\<rightarrow> s'\<rbrakk> 
   104              \<Longrightarrow> 
   105               G\<turnstile>(\<langle>NewC C\<rangle>,Norm s) \<mapsto>1 (\<langle>Ref a\<rangle>, s')"
   106 
   107 NewC:
   108      "\<lbrakk>\<not> inited C (globs s)\<rbrakk> 
   109      \<Longrightarrow> 
   110       G\<turnstile>(\<langle>NewC C\<rangle>,Norm s) \<mapsto>1 (\<langle>Seq (Init C) (NewC C)\<rangle>, Norm s)"
   111 
   112 *)
   113   (* cf. 15.9.1 *)
   114 | NewA: 
   115    "G\<turnstile>(\<langle>New T[e]\<rangle>,Norm s) \<mapsto>1 (\<langle>InsInitE (init_comp_ty T) (New T[e])\<rangle>,Norm s)"
   116 | InsInitNewAIdx: 
   117    "\<lbrakk>G\<turnstile>(\<langle>e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'\<rangle>, s')\<rbrakk>
   118     \<Longrightarrow>  
   119     G\<turnstile>(\<langle>InsInitE Skip (New T[e])\<rangle>,Norm s) \<mapsto>1 (\<langle>InsInitE Skip (New T[e'])\<rangle>,s')"
   120 | InsInitNewA: 
   121    "\<lbrakk>G\<turnstile>abupd (check_neg i) (Norm s) \<midarrow>halloc (Arr T (the_Intg i))\<succ>a\<rightarrow> s' \<rbrakk>
   122     \<Longrightarrow>
   123     G\<turnstile>(\<langle>InsInitE Skip (New T[Lit i])\<rangle>,Norm s) \<mapsto>1 (\<langle>Ref a\<rangle>,s')"
   124  
   125   (* cf. 15.15 *)
   126 | CastE:
   127    "\<lbrakk>G\<turnstile>(\<langle>e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'\<rangle>,s')\<rbrakk> 
   128     \<Longrightarrow>
   129     G\<turnstile>(\<langle>Cast T e\<rangle>,None,s) \<mapsto>1 (\<langle>Cast T e'\<rangle>,s')" 
   130 | Cast:
   131    "\<lbrakk>s' = abupd (raise_if (\<not>G,s\<turnstile>v fits T)  ClassCast) (Norm s)\<rbrakk> 
   132     \<Longrightarrow> 
   133     G\<turnstile>(\<langle>Cast T (Lit v)\<rangle>,Norm s) \<mapsto>1 (\<langle>Lit v\<rangle>,s')"
   134   (* can be written without abupd, since we know Norm s *)
   135 
   136 
   137 | InstE: "\<lbrakk>G\<turnstile>(\<langle>e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'::expr\<rangle>,s')\<rbrakk> 
   138         \<Longrightarrow> 
   139         G\<turnstile>(\<langle>e InstOf T\<rangle>,Norm s) \<mapsto>1 (\<langle>e'\<rangle>,s')" 
   140 | Inst:  "\<lbrakk>b = (v\<noteq>Null \<and> G,s\<turnstile>v fits RefT T)\<rbrakk> 
   141           \<Longrightarrow> 
   142           G\<turnstile>(\<langle>(Lit v) InstOf T\<rangle>,Norm s) \<mapsto>1 (\<langle>Lit (Bool b)\<rangle>,s')"
   143 
   144   (* cf. 15.7.1 *)
   145 (*Lit                           "G\<turnstile>(Lit v,None,s) \<mapsto>1 (Lit v,None,s)"*)
   146 
   147 | UnOpE:  "\<lbrakk>G\<turnstile>(\<langle>e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'\<rangle>,s') \<rbrakk>
   148            \<Longrightarrow> 
   149            G\<turnstile>(\<langle>UnOp unop e\<rangle>,Norm s) \<mapsto>1 (\<langle>UnOp unop e'\<rangle>,s')"
   150 | UnOp:   "G\<turnstile>(\<langle>UnOp unop (Lit v)\<rangle>,Norm s) \<mapsto>1 (\<langle>Lit (eval_unop unop v)\<rangle>,Norm s)"
   151 
   152 | BinOpE1:  "\<lbrakk>G\<turnstile>(\<langle>e1\<rangle>,Norm s) \<mapsto>1 (\<langle>e1'\<rangle>,s') \<rbrakk>
   153              \<Longrightarrow> 
   154              G\<turnstile>(\<langle>BinOp binop e1 e2\<rangle>,Norm s) \<mapsto>1 (\<langle>BinOp binop e1' e2\<rangle>,s')"
   155 | BinOpE2:  "\<lbrakk>need_second_arg binop v1; G\<turnstile>(\<langle>e2\<rangle>,Norm s) \<mapsto>1 (\<langle>e2'\<rangle>,s') \<rbrakk>
   156              \<Longrightarrow> 
   157              G\<turnstile>(\<langle>BinOp binop (Lit v1) e2\<rangle>,Norm s) 
   158               \<mapsto>1 (\<langle>BinOp binop (Lit v1) e2'\<rangle>,s')"
   159 | BinOpTerm:  "\<lbrakk>\<not> need_second_arg binop v1\<rbrakk>
   160                \<Longrightarrow> 
   161                G\<turnstile>(\<langle>BinOp binop (Lit v1) e2\<rangle>,Norm s) 
   162                 \<mapsto>1 (\<langle>Lit v1\<rangle>,Norm s)"
   163 | BinOp:    "G\<turnstile>(\<langle>BinOp binop (Lit v1) (Lit v2)\<rangle>,Norm s) 
   164               \<mapsto>1 (\<langle>Lit (eval_binop binop v1 v2)\<rangle>,Norm s)"
   165 (* Maybe its more convenient to add: need_second_arg as precondition to BinOp 
   166    to make the choice between BinOpTerm and BinOp deterministic *)
   167    
   168 | Super: "G\<turnstile>(\<langle>Super\<rangle>,Norm s) \<mapsto>1 (\<langle>Lit (val_this s)\<rangle>,Norm s)"
   169 
   170 | AccVA: "\<lbrakk>G\<turnstile>(\<langle>va\<rangle>,Norm s) \<mapsto>1 (\<langle>va'\<rangle>,s') \<rbrakk>
   171           \<Longrightarrow> 
   172           G\<turnstile>(\<langle>Acc va\<rangle>,Norm s) \<mapsto>1 (\<langle>Acc va'\<rangle>,s')"
   173 | Acc:  "\<lbrakk>groundVar va; ((v,vf),s') = the_var G (Norm s) va\<rbrakk>
   174          \<Longrightarrow>  
   175          G\<turnstile>(\<langle>Acc va\<rangle>,Norm s) \<mapsto>1 (\<langle>Lit v\<rangle>,s')"
   176 
   177 (*
   178 AccLVar: "G\<turnstile>(\<langle>Acc (LVar vn)\<rangle>,Norm s) \<mapsto>1 (\<langle>Lit (fst (lvar vn s))\<rangle>,Norm s)"
   179 AccFVar: "\<lbrakk>((v,vf),s') = fvar statDeclC stat fn a (Norm s)\<rbrakk>
   180           \<Longrightarrow>  
   181           G\<turnstile>(\<langle>Acc ({accC,statDeclC,stat}(Lit a)..fn)\<rangle>,Norm s) 
   182            \<mapsto>1 (\<langle>Lit v\<rangle>,s')"
   183 AccAVar: "\<lbrakk>((v,vf),s') = avar G i a (Norm s)\<rbrakk>
   184           \<Longrightarrow>  
   185           G\<turnstile>(\<langle>Acc ((Lit a).[Lit i])\<rangle>,Norm s) \<mapsto>1 (\<langle>Lit v\<rangle>,s')"
   186 *) 
   187 | AssVA:  "\<lbrakk>G\<turnstile>(\<langle>va\<rangle>,Norm s) \<mapsto>1 (\<langle>va'\<rangle>,s')\<rbrakk> 
   188            \<Longrightarrow> 
   189            G\<turnstile>(\<langle>va:=e\<rangle>,Norm s) \<mapsto>1 (\<langle>va':=e\<rangle>,s')"
   190 | AssE:   "\<lbrakk>groundVar va; G\<turnstile>(\<langle>e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'\<rangle>,s')\<rbrakk> 
   191            \<Longrightarrow> 
   192            G\<turnstile>(\<langle>va:=e\<rangle>,Norm s) \<mapsto>1 (\<langle>va:=e'\<rangle>,s')"
   193 | Ass:    "\<lbrakk>groundVar va; ((w,f),s') = the_var G (Norm s) va\<rbrakk> 
   194            \<Longrightarrow> 
   195            G\<turnstile>(\<langle>va:=(Lit v)\<rangle>,Norm s) \<mapsto>1 (\<langle>Lit v\<rangle>,assign f v s')"
   196 
   197 | CondC: "\<lbrakk>G\<turnstile>(\<langle>e0\<rangle>,Norm s) \<mapsto>1 (\<langle>e0'\<rangle>,s')\<rbrakk> 
   198           \<Longrightarrow> 
   199           G\<turnstile>(\<langle>e0? e1:e2\<rangle>,Norm s) \<mapsto>1 (\<langle>e0'? e1:e2\<rangle>,s')"
   200 | Cond:  "G\<turnstile>(\<langle>Lit b? e1:e2\<rangle>,Norm s) \<mapsto>1 (\<langle>if the_Bool b then e1 else e2\<rangle>,Norm s)"
   201 
   202 
   203 | CallTarget: "\<lbrakk>G\<turnstile>(\<langle>e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'\<rangle>,s')\<rbrakk> 
   204                \<Longrightarrow>
   205                G\<turnstile>(\<langle>{accC,statT,mode}e\<cdot>mn({pTs}args)\<rangle>,Norm s) 
   206                 \<mapsto>1 (\<langle>{accC,statT,mode}e'\<cdot>mn({pTs}args)\<rangle>,s')"
   207 | CallArgs:   "\<lbrakk>G\<turnstile>(\<langle>args\<rangle>,Norm s) \<mapsto>1 (\<langle>args'\<rangle>,s')\<rbrakk> 
   208                \<Longrightarrow>
   209                G\<turnstile>(\<langle>{accC,statT,mode}Lit a\<cdot>mn({pTs}args)\<rangle>,Norm s) 
   210                 \<mapsto>1 (\<langle>{accC,statT,mode}Lit a\<cdot>mn({pTs}args')\<rangle>,s')"
   211 | Call:       "\<lbrakk>groundExprs args; vs = map the_val args;
   212                 D = invocation_declclass G mode s a statT \<lparr>name=mn,parTs=pTs\<rparr>;
   213                 s'=init_lvars G D \<lparr>name=mn,parTs=pTs\<rparr> mode a' vs (Norm s)\<rbrakk> 
   214                \<Longrightarrow> 
   215                G\<turnstile>(\<langle>{accC,statT,mode}Lit a\<cdot>mn({pTs}args)\<rangle>,Norm s) 
   216                 \<mapsto>1 (\<langle>Callee (locals s) (Methd D \<lparr>name=mn,parTs=pTs\<rparr>)\<rangle>,s')"
   217            
   218 | Callee:     "\<lbrakk>G\<turnstile>(\<langle>e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'::expr\<rangle>,s')\<rbrakk>
   219                \<Longrightarrow> 
   220                G\<turnstile>(\<langle>Callee lcls_caller e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'\<rangle>,s')"
   221 
   222 | CalleeRet:   "G\<turnstile>(\<langle>Callee lcls_caller (Lit v)\<rangle>,Norm s) 
   223                  \<mapsto>1 (\<langle>Lit v\<rangle>,(set_lvars lcls_caller (Norm s)))"
   224 
   225 | Methd: "G\<turnstile>(\<langle>Methd D sig\<rangle>,Norm s) \<mapsto>1 (\<langle>body G D sig\<rangle>,Norm s)"
   226 
   227 | Body: "G\<turnstile>(\<langle>Body D c\<rangle>,Norm s) \<mapsto>1 (\<langle>InsInitE (Init D) (Body D c)\<rangle>,Norm s)"
   228 
   229 | InsInitBody: 
   230     "\<lbrakk>G\<turnstile>(\<langle>c\<rangle>,Norm s) \<mapsto>1 (\<langle>c'\<rangle>,s')\<rbrakk>
   231      \<Longrightarrow> 
   232      G\<turnstile>(\<langle>InsInitE Skip (Body D c)\<rangle>,Norm s) \<mapsto>1(\<langle>InsInitE Skip (Body D c')\<rangle>,s')"
   233 | InsInitBodyRet: 
   234      "G\<turnstile>(\<langle>InsInitE Skip (Body D Skip)\<rangle>,Norm s)
   235        \<mapsto>1 (\<langle>Lit (the ((locals s) Result))\<rangle>,abupd (absorb Ret) (Norm s))"
   236 
   237 (*   LVar: "G\<turnstile>(LVar vn,Norm s)" is already evaluated *)
   238   
   239 | FVar: "\<lbrakk>\<not> inited statDeclC (globs s)\<rbrakk>
   240          \<Longrightarrow> 
   241          G\<turnstile>(\<langle>{accC,statDeclC,stat}e..fn\<rangle>,Norm s) 
   242           \<mapsto>1 (\<langle>InsInitV (Init statDeclC) ({accC,statDeclC,stat}e..fn)\<rangle>,Norm s)"
   243 | InsInitFVarE:
   244       "\<lbrakk>G\<turnstile>(\<langle>e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'\<rangle>,s')\<rbrakk>
   245        \<Longrightarrow>
   246        G\<turnstile>(\<langle>InsInitV Skip ({accC,statDeclC,stat}e..fn)\<rangle>,Norm s) 
   247         \<mapsto>1 (\<langle>InsInitV Skip ({accC,statDeclC,stat}e'..fn)\<rangle>,s')"
   248 | InsInitFVar:
   249       "G\<turnstile>(\<langle>InsInitV Skip ({accC,statDeclC,stat}Lit a..fn)\<rangle>,Norm s) 
   250         \<mapsto>1 (\<langle>{accC,statDeclC,stat}Lit a..fn\<rangle>,Norm s)"
   251 --  {* Notice, that we do not have literal values for @{text vars}. 
   252 The rules for accessing variables (@{text Acc}) and assigning to variables 
   253 (@{text Ass}), test this with the predicate @{text groundVar}.  After 
   254 initialisation is done and the @{text FVar} is evaluated, we can't just 
   255 throw away the @{text InsInitFVar} term and return a literal value, as in the 
   256 cases of @{text New}  or @{text NewC}. Instead we just return the evaluated 
   257 @{text FVar} and test for initialisation in the rule @{text FVar}. 
   258 *}
   259 
   260 
   261 | AVarE1: "\<lbrakk>G\<turnstile>(\<langle>e1\<rangle>,Norm s) \<mapsto>1 (\<langle>e1'\<rangle>,s')\<rbrakk> 
   262            \<Longrightarrow> 
   263            G\<turnstile>(\<langle>e1.[e2]\<rangle>,Norm s) \<mapsto>1 (\<langle>e1'.[e2]\<rangle>,s')"
   264 
   265 | AVarE2: "G\<turnstile>(\<langle>e2\<rangle>,Norm s) \<mapsto>1 (\<langle>e2'\<rangle>,s') 
   266            \<Longrightarrow> 
   267            G\<turnstile>(\<langle>Lit a.[e2]\<rangle>,Norm s) \<mapsto>1 (\<langle>Lit a.[e2']\<rangle>,s')"
   268 
   269 (* AVar: \<langle>(Lit a).[Lit i]\<rangle> is fully evaluated *)
   270 
   271 (* evaluation of expression lists *)
   272 
   273   -- {* @{text Nil}  is fully evaluated *}
   274 
   275 | ConsHd: "\<lbrakk>G\<turnstile>(\<langle>e::expr\<rangle>,Norm s) \<mapsto>1 (\<langle>e'::expr\<rangle>,s')\<rbrakk> 
   276            \<Longrightarrow>
   277            G\<turnstile>(\<langle>e#es\<rangle>,Norm s) \<mapsto>1 (\<langle>e'#es\<rangle>,s')"
   278   
   279 | ConsTl: "\<lbrakk>G\<turnstile>(\<langle>es\<rangle>,Norm s) \<mapsto>1 (\<langle>es'\<rangle>,s')\<rbrakk> 
   280            \<Longrightarrow>
   281            G\<turnstile>(\<langle>(Lit v)#es\<rangle>,Norm s) \<mapsto>1 (\<langle>(Lit v)#es'\<rangle>,s')"
   282 
   283 (* execution of statements *)
   284 
   285   (* cf. 14.5 *)
   286 | Skip: "G\<turnstile>(\<langle>Skip\<rangle>,Norm s) \<mapsto>1 (\<langle>SKIP\<rangle>,Norm s)"
   287 
   288 | ExprE: "\<lbrakk>G\<turnstile>(\<langle>e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'\<rangle>,s')\<rbrakk> 
   289           \<Longrightarrow> 
   290           G\<turnstile>(\<langle>Expr e\<rangle>,Norm s) \<mapsto>1 (\<langle>Expr e'\<rangle>,s')"
   291 | Expr:  "G\<turnstile>(\<langle>Expr (Lit v)\<rangle>,Norm s) \<mapsto>1 (\<langle>Skip\<rangle>,Norm s)"
   292 
   293 
   294 | LabC: "\<lbrakk>G\<turnstile>(\<langle>c\<rangle>,Norm s) \<mapsto>1 (\<langle>c'\<rangle>,s')\<rbrakk> 
   295          \<Longrightarrow>  
   296          G\<turnstile>(\<langle>l\<bullet> c\<rangle>,Norm s) \<mapsto>1 (\<langle>l\<bullet> c'\<rangle>,s')"
   297 | Lab:  "G\<turnstile>(\<langle>l\<bullet> Skip\<rangle>,s) \<mapsto>1 (\<langle>Skip\<rangle>, abupd (absorb l) s)"
   298 
   299   (* cf. 14.2 *)
   300 | CompC1: "\<lbrakk>G\<turnstile>(\<langle>c1\<rangle>,Norm s) \<mapsto>1 (\<langle>c1'\<rangle>,s')\<rbrakk> 
   301            \<Longrightarrow> 
   302            G\<turnstile>(\<langle>c1;; c2\<rangle>,Norm s) \<mapsto>1 (\<langle>c1';; c2\<rangle>,s')"
   303 
   304 | Comp:   "G\<turnstile>(\<langle>Skip;; c2\<rangle>,Norm s) \<mapsto>1 (\<langle>c2\<rangle>,Norm s)"
   305 
   306   (* cf. 14.8.2 *)
   307 | IfE: "\<lbrakk>G\<turnstile>(\<langle>e\<rangle> ,Norm s) \<mapsto>1 (\<langle>e'\<rangle>,s')\<rbrakk> 
   308         \<Longrightarrow>
   309         G\<turnstile>(\<langle>If(e) s1 Else s2\<rangle>,Norm s) \<mapsto>1 (\<langle>If(e') s1 Else s2\<rangle>,s')"
   310 | If:  "G\<turnstile>(\<langle>If(Lit v) s1 Else s2\<rangle>,Norm s) 
   311          \<mapsto>1 (\<langle>if the_Bool v then s1 else s2\<rangle>,Norm s)"
   312 
   313   (* cf. 14.10, 14.10.1 *)
   314 | Loop: "G\<turnstile>(\<langle>l\<bullet> While(e) c\<rangle>,Norm s) 
   315           \<mapsto>1 (\<langle>If(e) (Cont l\<bullet>c;; l\<bullet> While(e) c) Else Skip\<rangle>,Norm s)"
   316 
   317 | Jmp: "G\<turnstile>(\<langle>Jmp j\<rangle>,Norm s) \<mapsto>1 (\<langle>Skip\<rangle>,(Some (Jump j), s))"
   318 
   319 | ThrowE: "\<lbrakk>G\<turnstile>(\<langle>e\<rangle>,Norm s) \<mapsto>1 (\<langle>e'\<rangle>,s')\<rbrakk> 
   320            \<Longrightarrow>
   321            G\<turnstile>(\<langle>Throw e\<rangle>,Norm s) \<mapsto>1 (\<langle>Throw e'\<rangle>,s')"
   322 | Throw:  "G\<turnstile>(\<langle>Throw (Lit a)\<rangle>,Norm s) \<mapsto>1 (\<langle>Skip\<rangle>,abupd (throw a) (Norm s))"
   323 
   324 | TryC1: "\<lbrakk>G\<turnstile>(\<langle>c1\<rangle>,Norm s) \<mapsto>1 (\<langle>c1'\<rangle>,s')\<rbrakk> 
   325           \<Longrightarrow>
   326           G\<turnstile>(\<langle>Try c1 Catch(C vn) c2\<rangle>, Norm s) \<mapsto>1 (\<langle>Try c1' Catch(C vn) c2\<rangle>,s')"
   327 | Try:   "\<lbrakk>G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s'\<rbrakk>
   328           \<Longrightarrow>
   329           G\<turnstile>(\<langle>Try Skip Catch(C vn) c2\<rangle>, s) 
   330            \<mapsto>1 (if G,s'\<turnstile>catch C then (\<langle>c2\<rangle>,new_xcpt_var vn s')
   331                                 else (\<langle>Skip\<rangle>,s'))"
   332 
   333 | FinC1: "\<lbrakk>G\<turnstile>(\<langle>c1\<rangle>,Norm s) \<mapsto>1 (\<langle>c1'\<rangle>,s')\<rbrakk> 
   334           \<Longrightarrow>
   335           G\<turnstile>(\<langle>c1 Finally c2\<rangle>,Norm s) \<mapsto>1 (\<langle>c1' Finally c2\<rangle>,s')"
   336 
   337 | Fin:    "G\<turnstile>(\<langle>Skip Finally c2\<rangle>,(a,s)) \<mapsto>1 (\<langle>FinA a c2\<rangle>,Norm s)"
   338 
   339 | FinAC: "\<lbrakk>G\<turnstile>(\<langle>c\<rangle>,s) \<mapsto>1 (\<langle>c'\<rangle>,s')\<rbrakk>
   340           \<Longrightarrow>
   341           G\<turnstile>(\<langle>FinA a c\<rangle>,s) \<mapsto>1 (\<langle>FinA a c'\<rangle>,s')"
   342 | FinA: "G\<turnstile>(\<langle>FinA a Skip\<rangle>,s) \<mapsto>1 (\<langle>Skip\<rangle>,abupd (abrupt_if (a\<noteq>None) a) s)"
   343 
   344 
   345 | Init1: "\<lbrakk>inited C (globs s)\<rbrakk> 
   346           \<Longrightarrow> 
   347           G\<turnstile>(\<langle>Init C\<rangle>,Norm s) \<mapsto>1 (\<langle>Skip\<rangle>,Norm s)"
   348 | Init: "\<lbrakk>the (class G C)=c; \<not> inited C (globs s)\<rbrakk>  
   349          \<Longrightarrow> 
   350          G\<turnstile>(\<langle>Init C\<rangle>,Norm s) 
   351           \<mapsto>1 (\<langle>(if C = Object then Skip else (Init (super c)));;
   352                 Expr (Callee (locals s) (InsInitE (init c) SKIP))\<rangle>
   353                ,Norm (init_class_obj G C s))"
   354 -- {* @{text InsInitE} is just used as trick to embed the statement 
   355 @{text "init c"} into an expression*} 
   356 | InsInitESKIP:
   357     "G\<turnstile>(\<langle>InsInitE Skip SKIP\<rangle>,Norm s) \<mapsto>1 (\<langle>SKIP\<rangle>,Norm s)"
   358 
   359 abbreviation
   360   stepn:: "[prog, term \<times> state,nat,term \<times> state] \<Rightarrow> bool" ("_\<turnstile>_ \<mapsto>_ _"[61,82,82] 81)
   361   where "G\<turnstile>p \<mapsto>n p' \<equiv> (p,p') \<in> {(x, y). step G x y}^^n"
   362 
   363 abbreviation
   364   steptr:: "[prog,term \<times> state,term \<times> state] \<Rightarrow> bool" ("_\<turnstile>_ \<mapsto>* _"[61,82,82] 81)
   365   where "G\<turnstile>p \<mapsto>* p' \<equiv> (p,p') \<in> {(x, y). step G x y}\<^sup>*"
   366          
   367 (* Equivalenzen:
   368   Bigstep zu Smallstep komplett.
   369   Smallstep zu Bigstep, nur wenn nicht die Ausdrücke Callee, FinA ,\<dots>
   370 *)
   371 
   372 (*
   373 lemma imp_eval_trans:
   374   assumes eval: "G\<turnstile>s0 \<midarrow>t\<succ>\<rightarrow> (v,s1)" 
   375     shows trans: "G\<turnstile>(t,s0) \<mapsto>* (\<langle>Lit v\<rangle>,s1)"
   376 *)
   377 (* Jetzt muss man bei trans natürlich wieder unterscheiden: Stmt, Expr, Var!
   378    Sowas blödes:
   379    Am besten den Terminus ground auf Var,Stmt,Expr hochziehen und dann
   380    the_vals definieren\<dots>
   381   G\<turnstile>(t,s0) \<mapsto>* (t',s1) \<and> the_vals t' = v
   382 *)
   383 
   384 
   385 end