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