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