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