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