src/HOL/Bali/Eval.thy
changeset 21765 89275a3ed7be
parent 18249 4398f0f12579
child 23747 b07cff284683
equal deleted inserted replaced
21764:720b0add5206 21765:89275a3ed7be
   472                   AccessViolation)
   472                   AccessViolation)
   473         s"
   473         s"
   474        
   474        
   475 section "evaluation judgments"
   475 section "evaluation judgments"
   476 
   476 
   477 consts
   477 inductive2
   478   eval   :: "prog \<Rightarrow> (state \<times> term    \<times> vals \<times> state) set"
   478   halloc :: "[prog,state,obj_tag,loc,state]\<Rightarrow>bool" ("_\<turnstile>_ \<midarrow>halloc _\<succ>_\<rightarrow> _"[61,61,61,61,61]60) for G::prog
   479   halloc::  "prog \<Rightarrow> (state \<times> obj_tag \<times> loc  \<times> state) set"
   479 where --{* allocating objects on the heap, cf. 12.5 *}
   480   sxalloc:: "prog \<Rightarrow> (state                  \<times> state) set"
       
   481 
       
   482 
       
   483 syntax
       
   484 eval ::"[prog,state,term,vals*state]=>bool"("_|-_ -_>-> _"  [61,61,80,   61]60)
       
   485 exec ::"[prog,state,stmt      ,state]=>bool"("_|-_ -_-> _"   [61,61,65,   61]60)
       
   486 evar ::"[prog,state,var  ,vvar,state]=>bool"("_|-_ -_=>_-> _"[61,61,90,61,61]60)
       
   487 eval_::"[prog,state,expr ,val, state]=>bool"("_|-_ -_->_-> _"[61,61,80,61,61]60)
       
   488 evals::"[prog,state,expr list ,
       
   489 		    val  list ,state]=>bool"("_|-_ -_#>_-> _"[61,61,61,61,61]60)
       
   490 hallo::"[prog,state,obj_tag,
       
   491 	             loc,state]=>bool"("_|-_ -halloc _>_-> _"[61,61,61,61,61]60)
       
   492 sallo::"[prog,state        ,state]=>bool"("_|-_ -sxalloc-> _"[61,61,      61]60)
       
   493 
       
   494 syntax (xsymbols)
       
   495 eval ::"[prog,state,term,vals\<times>state]\<Rightarrow>bool" ("_\<turnstile>_ \<midarrow>_\<succ>\<rightarrow> _"  [61,61,80,   61]60)
       
   496 exec ::"[prog,state,stmt      ,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_\<rightarrow> _"   [61,61,65,   61]60)
       
   497 evar ::"[prog,state,var  ,vvar,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_=\<succ>_\<rightarrow> _"[61,61,90,61,61]60)
       
   498 eval_::"[prog,state,expr ,val ,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_-\<succ>_\<rightarrow> _"[61,61,80,61,61]60)
       
   499 evals::"[prog,state,expr list ,
       
   500 		    val  list ,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_\<doteq>\<succ>_\<rightarrow> _"[61,61,61,61,61]60)
       
   501 hallo::"[prog,state,obj_tag,
       
   502 	             loc,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>halloc _\<succ>_\<rightarrow> _"[61,61,61,61,61]60)
       
   503 sallo::"[prog,state,        state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>sxalloc\<rightarrow> _"[61,61,      61]60)
       
   504 
       
   505 translations
       
   506   "G\<turnstile>s \<midarrow>t   \<succ>\<rightarrow>  w___s' " == "(s,t,w___s') \<in> eval G"
       
   507   "G\<turnstile>s \<midarrow>t   \<succ>\<rightarrow> (w,  s')" <= "(s,t,w,  s') \<in> eval G"
       
   508   "G\<turnstile>s \<midarrow>t   \<succ>\<rightarrow> (w,x,s')" <= "(s,t,w,x,s') \<in> eval G"
       
   509   "G\<turnstile>s \<midarrow>c    \<rightarrow>  (x,s')" <= "G\<turnstile>s \<midarrow>In1r c\<succ>\<rightarrow> (\<diamondsuit>,x,s')"
       
   510   "G\<turnstile>s \<midarrow>c    \<rightarrow>     s' " == "G\<turnstile>s \<midarrow>In1r c\<succ>\<rightarrow> (\<diamondsuit>  ,  s')"
       
   511   "G\<turnstile>s \<midarrow>e-\<succ>v \<rightarrow>  (x,s')" <= "G\<turnstile>s \<midarrow>In1l e\<succ>\<rightarrow> (In1 v ,x,s')"
       
   512   "G\<turnstile>s \<midarrow>e-\<succ>v \<rightarrow>     s' " == "G\<turnstile>s \<midarrow>In1l e\<succ>\<rightarrow> (In1 v ,  s')"
       
   513   "G\<turnstile>s \<midarrow>e=\<succ>vf\<rightarrow>  (x,s')" <= "G\<turnstile>s \<midarrow>In2  e\<succ>\<rightarrow> (In2 vf,x,s')"
       
   514   "G\<turnstile>s \<midarrow>e=\<succ>vf\<rightarrow>     s' " == "G\<turnstile>s \<midarrow>In2  e\<succ>\<rightarrow> (In2 vf,  s')"
       
   515   "G\<turnstile>s \<midarrow>e\<doteq>\<succ>v \<rightarrow>  (x,s')" <= "G\<turnstile>s \<midarrow>In3  e\<succ>\<rightarrow> (In3 v ,x,s')"
       
   516   "G\<turnstile>s \<midarrow>e\<doteq>\<succ>v \<rightarrow>     s' " == "G\<turnstile>s \<midarrow>In3  e\<succ>\<rightarrow> (In3 v ,  s')"
       
   517   "G\<turnstile>s \<midarrow>halloc oi\<succ>a\<rightarrow> (x,s')" <= "(s,oi,a,x,s') \<in> halloc G"
       
   518   "G\<turnstile>s \<midarrow>halloc oi\<succ>a\<rightarrow>    s' " == "(s,oi,a,  s') \<in> halloc G"
       
   519   "G\<turnstile>s \<midarrow>sxalloc\<rightarrow>     (x,s')" <= "(s     ,x,s') \<in> sxalloc G"
       
   520   "G\<turnstile>s \<midarrow>sxalloc\<rightarrow>        s' " == "(s     ,  s') \<in> sxalloc G"
       
   521 
       
   522 inductive "halloc G" intros --{* allocating objects on the heap, cf. 12.5 *}
       
   523 
   480 
   524   Abrupt: 
   481   Abrupt: 
   525   "G\<turnstile>(Some x,s) \<midarrow>halloc oi\<succ>arbitrary\<rightarrow> (Some x,s)"
   482   "G\<turnstile>(Some x,s) \<midarrow>halloc oi\<succ>arbitrary\<rightarrow> (Some x,s)"
   526 
   483 
   527   New:	  "\<lbrakk>new_Addr (heap s) = Some a; 
   484 | New:	  "\<lbrakk>new_Addr (heap s) = Some a; 
   528 	    (x,oi') = (if atleast_free (heap s) (Suc (Suc 0)) then (None,oi)
   485 	    (x,oi') = (if atleast_free (heap s) (Suc (Suc 0)) then (None,oi)
   529 		       else (Some (Xcpt (Loc a)),CInst (SXcpt OutOfMemory)))\<rbrakk>
   486 		       else (Some (Xcpt (Loc a)),CInst (SXcpt OutOfMemory)))\<rbrakk>
   530             \<Longrightarrow>
   487             \<Longrightarrow>
   531 	    G\<turnstile>Norm s \<midarrow>halloc oi\<succ>a\<rightarrow> (x,init_obj G oi' (Heap a) s)"
   488 	    G\<turnstile>Norm s \<midarrow>halloc oi\<succ>a\<rightarrow> (x,init_obj G oi' (Heap a) s)"
   532 
   489 
   533 inductive "sxalloc G" intros --{* allocating exception objects for
   490 inductive2 sxalloc :: "[prog,state,state]\<Rightarrow>bool" ("_\<turnstile>_ \<midarrow>sxalloc\<rightarrow> _"[61,61,61]60) for G::prog
   534 	 	 	      standard exceptions (other than OutOfMemory) *}
   491 where --{* allocating exception objects for
       
   492   standard exceptions (other than OutOfMemory) *}
   535 
   493 
   536   Norm:	 "G\<turnstile> Norm              s   \<midarrow>sxalloc\<rightarrow>  Norm             s"
   494   Norm:	 "G\<turnstile> Norm              s   \<midarrow>sxalloc\<rightarrow>  Norm             s"
   537 
   495 
   538   Jmp:   "G\<turnstile>(Some (Jump j), s)  \<midarrow>sxalloc\<rightarrow> (Some (Jump j), s)"
   496 | Jmp:   "G\<turnstile>(Some (Jump j), s)  \<midarrow>sxalloc\<rightarrow> (Some (Jump j), s)"
   539 
   497 
   540   Error: "G\<turnstile>(Some (Error e), s)  \<midarrow>sxalloc\<rightarrow> (Some (Error e), s)"
   498 | Error: "G\<turnstile>(Some (Error e), s)  \<midarrow>sxalloc\<rightarrow> (Some (Error e), s)"
   541 
   499 
   542   XcptL: "G\<turnstile>(Some (Xcpt (Loc a) ),s)  \<midarrow>sxalloc\<rightarrow> (Some (Xcpt (Loc a)),s)"
   500 | XcptL: "G\<turnstile>(Some (Xcpt (Loc a) ),s)  \<midarrow>sxalloc\<rightarrow> (Some (Xcpt (Loc a)),s)"
   543 
   501 
   544   SXcpt: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>halloc (CInst (SXcpt xn))\<succ>a\<rightarrow> (x,s1)\<rbrakk> \<Longrightarrow>
   502 | SXcpt: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>halloc (CInst (SXcpt xn))\<succ>a\<rightarrow> (x,s1)\<rbrakk> \<Longrightarrow>
   545 	  G\<turnstile>(Some (Xcpt (Std xn)),s0) \<midarrow>sxalloc\<rightarrow> (Some (Xcpt (Loc a)),s1)"
   503 	  G\<turnstile>(Some (Xcpt (Std xn)),s0) \<midarrow>sxalloc\<rightarrow> (Some (Xcpt (Loc a)),s1)"
   546 
   504 
   547 
   505 
   548 inductive "eval G" intros
   506 inductive2
       
   507   eval :: "[prog,state,term,vals,state]\<Rightarrow>bool" ("_\<turnstile>_ \<midarrow>_\<succ>\<rightarrow> '(_, _')"  [61,61,80,0,0]60)
       
   508   and exec ::"[prog,state,stmt      ,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_\<rightarrow> _"   [61,61,65,   61]60)
       
   509   and evar ::"[prog,state,var  ,vvar,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_=\<succ>_\<rightarrow> _"[61,61,90,61,61]60)
       
   510   and eval'::"[prog,state,expr ,val ,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_-\<succ>_\<rightarrow> _"[61,61,80,61,61]60)
       
   511   and evals::"[prog,state,expr list ,
       
   512 		    val  list ,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_\<doteq>\<succ>_\<rightarrow> _"[61,61,61,61,61]60)
       
   513   for G::prog
       
   514 where
       
   515 
       
   516   "G\<turnstile>s \<midarrow>c    \<rightarrow>     s' \<equiv> G\<turnstile>s \<midarrow>In1r c\<succ>\<rightarrow> (\<diamondsuit>,  s')"
       
   517 | "G\<turnstile>s \<midarrow>e-\<succ>v \<rightarrow>     s' \<equiv> G\<turnstile>s \<midarrow>In1l e\<succ>\<rightarrow> (In1 v,  s')"
       
   518 | "G\<turnstile>s \<midarrow>e=\<succ>vf\<rightarrow>     s' \<equiv> G\<turnstile>s \<midarrow>In2  e\<succ>\<rightarrow> (In2 vf, s')"
       
   519 | "G\<turnstile>s \<midarrow>e\<doteq>\<succ>v \<rightarrow>     s' \<equiv> G\<turnstile>s \<midarrow>In3  e\<succ>\<rightarrow> (In3 v,  s')"
   549 
   520 
   550 --{* propagation of abrupt completion *}
   521 --{* propagation of abrupt completion *}
   551 
   522 
   552   --{* cf. 14.1, 15.5 *}
   523   --{* cf. 14.1, 15.5 *}
   553   Abrupt: 
   524 | Abrupt: 
   554    "G\<turnstile>(Some xc,s) \<midarrow>t\<succ>\<rightarrow> (arbitrary3 t,(Some xc,s))"
   525    "G\<turnstile>(Some xc,s) \<midarrow>t\<succ>\<rightarrow> (arbitrary3 t, (Some xc, s))"
   555 
   526 
   556 
   527 
   557 --{* execution of statements *}
   528 --{* execution of statements *}
   558 
   529 
   559   --{* cf. 14.5 *}
   530   --{* cf. 14.5 *}
   560   Skip:	 			    "G\<turnstile>Norm s \<midarrow>Skip\<rightarrow> Norm s"
   531 | Skip:	 			    "G\<turnstile>Norm s \<midarrow>Skip\<rightarrow> Norm s"
   561 
   532 
   562   --{* cf. 14.7 *}
   533   --{* cf. 14.7 *}
   563   Expr:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1\<rbrakk> \<Longrightarrow>
   534 | Expr:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1\<rbrakk> \<Longrightarrow>
   564 				  G\<turnstile>Norm s0 \<midarrow>Expr e\<rightarrow> s1"
   535 				  G\<turnstile>Norm s0 \<midarrow>Expr e\<rightarrow> s1"
   565 
   536 
   566   Lab:  "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c \<rightarrow> s1\<rbrakk> \<Longrightarrow>
   537 | Lab:  "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c \<rightarrow> s1\<rbrakk> \<Longrightarrow>
   567                                 G\<turnstile>Norm s0 \<midarrow>l\<bullet> c\<rightarrow> abupd (absorb l) s1"
   538                                 G\<turnstile>Norm s0 \<midarrow>l\<bullet> c\<rightarrow> abupd (absorb l) s1"
   568   --{* cf. 14.2 *}
   539   --{* cf. 14.2 *}
   569   Comp:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c1 \<rightarrow> s1;
   540 | Comp:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c1 \<rightarrow> s1;
   570 	  G\<turnstile>     s1 \<midarrow>c2 \<rightarrow> s2\<rbrakk> \<Longrightarrow>
   541 	  G\<turnstile>     s1 \<midarrow>c2 \<rightarrow> s2\<rbrakk> \<Longrightarrow>
   571 				 G\<turnstile>Norm s0 \<midarrow>c1;; c2\<rightarrow> s2"
   542 				 G\<turnstile>Norm s0 \<midarrow>c1;; c2\<rightarrow> s2"
   572 
   543 
   573   --{* cf. 14.8.2 *}
   544   --{* cf. 14.8.2 *}
   574   If:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>b\<rightarrow> s1;
   545 | If:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>b\<rightarrow> s1;
   575 	  G\<turnstile>     s1\<midarrow>(if the_Bool b then c1 else c2)\<rightarrow> s2\<rbrakk> \<Longrightarrow>
   546 	  G\<turnstile>     s1\<midarrow>(if the_Bool b then c1 else c2)\<rightarrow> s2\<rbrakk> \<Longrightarrow>
   576 		       G\<turnstile>Norm s0 \<midarrow>If(e) c1 Else c2 \<rightarrow> s2"
   547 		       G\<turnstile>Norm s0 \<midarrow>If(e) c1 Else c2 \<rightarrow> s2"
   577 
   548 
   578   --{* cf. 14.10, 14.10.1 *}
   549   --{* cf. 14.10, 14.10.1 *}
   579   
   550   
   581      this rule. If a continue jump with the proper label was invoked inside 
   552      this rule. If a continue jump with the proper label was invoked inside 
   582      @{term c} this label (Cont l) is deleted out of the abrupt component of 
   553      @{term c} this label (Cont l) is deleted out of the abrupt component of 
   583      the state before the iterative evaluation of the while statement.
   554      the state before the iterative evaluation of the while statement.
   584      A break jump is handled by the Lab Statement @{text "Lab l (while\<dots>)"}.
   555      A break jump is handled by the Lab Statement @{text "Lab l (while\<dots>)"}.
   585   *}
   556   *}
   586   Loop:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>b\<rightarrow> s1;
   557 | Loop:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>b\<rightarrow> s1;
   587 	  if the_Bool b 
   558 	  if the_Bool b 
   588              then (G\<turnstile>s1 \<midarrow>c\<rightarrow> s2 \<and> 
   559              then (G\<turnstile>s1 \<midarrow>c\<rightarrow> s2 \<and> 
   589                    G\<turnstile>(abupd (absorb (Cont l)) s2) \<midarrow>l\<bullet> While(e) c\<rightarrow> s3)
   560                    G\<turnstile>(abupd (absorb (Cont l)) s2) \<midarrow>l\<bullet> While(e) c\<rightarrow> s3)
   590 	     else s3 = s1\<rbrakk> \<Longrightarrow>
   561 	     else s3 = s1\<rbrakk> \<Longrightarrow>
   591 			      G\<turnstile>Norm s0 \<midarrow>l\<bullet> While(e) c\<rightarrow> s3"
   562 			      G\<turnstile>Norm s0 \<midarrow>l\<bullet> While(e) c\<rightarrow> s3"
   592 
   563 
   593   Jmp: "G\<turnstile>Norm s \<midarrow>Jmp j\<rightarrow> (Some (Jump j), s)"
   564 | Jmp: "G\<turnstile>Norm s \<midarrow>Jmp j\<rightarrow> (Some (Jump j), s)"
   594    
   565    
   595   --{* cf. 14.16 *}
   566   --{* cf. 14.16 *}
   596   Throw: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>a'\<rightarrow> s1\<rbrakk> \<Longrightarrow>
   567 | Throw: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>a'\<rightarrow> s1\<rbrakk> \<Longrightarrow>
   597 				 G\<turnstile>Norm s0 \<midarrow>Throw e\<rightarrow> abupd (throw a') s1"
   568 				 G\<turnstile>Norm s0 \<midarrow>Throw e\<rightarrow> abupd (throw a') s1"
   598 
   569 
   599   --{* cf. 14.18.1 *}
   570   --{* cf. 14.18.1 *}
   600   Try:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c1\<rightarrow> s1; G\<turnstile>s1 \<midarrow>sxalloc\<rightarrow> s2; 
   571 | Try:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c1\<rightarrow> s1; G\<turnstile>s1 \<midarrow>sxalloc\<rightarrow> s2; 
   601 	  if G,s2\<turnstile>catch C then G\<turnstile>new_xcpt_var vn s2 \<midarrow>c2\<rightarrow> s3 else s3 = s2\<rbrakk> \<Longrightarrow>
   572 	  if G,s2\<turnstile>catch C then G\<turnstile>new_xcpt_var vn s2 \<midarrow>c2\<rightarrow> s3 else s3 = s2\<rbrakk> \<Longrightarrow>
   602 		  G\<turnstile>Norm s0 \<midarrow>Try c1 Catch(C vn) c2\<rightarrow> s3"
   573 		  G\<turnstile>Norm s0 \<midarrow>Try c1 Catch(C vn) c2\<rightarrow> s3"
   603 
   574 
   604   --{* cf. 14.18.2 *}
   575   --{* cf. 14.18.2 *}
   605   Fin:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c1\<rightarrow> (x1,s1);
   576 | Fin:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c1\<rightarrow> (x1,s1);
   606 	  G\<turnstile>Norm s1 \<midarrow>c2\<rightarrow> s2;
   577 	  G\<turnstile>Norm s1 \<midarrow>c2\<rightarrow> s2;
   607           s3=(if (\<exists> err. x1=Some (Error err)) 
   578           s3=(if (\<exists> err. x1=Some (Error err)) 
   608               then (x1,s1) 
   579               then (x1,s1) 
   609               else abupd (abrupt_if (x1\<noteq>None) x1) s2) \<rbrakk> 
   580               else abupd (abrupt_if (x1\<noteq>None) x1) s2) \<rbrakk> 
   610           \<Longrightarrow>
   581           \<Longrightarrow>
   611           G\<turnstile>Norm s0 \<midarrow>c1 Finally c2\<rightarrow> s3"
   582           G\<turnstile>Norm s0 \<midarrow>c1 Finally c2\<rightarrow> s3"
   612   --{* cf. 12.4.2, 8.5 *}
   583   --{* cf. 12.4.2, 8.5 *}
   613   Init:	"\<lbrakk>the (class G C) = c;
   584 | Init:	"\<lbrakk>the (class G C) = c;
   614 	  if inited C (globs s0) then s3 = Norm s0
   585 	  if inited C (globs s0) then s3 = Norm s0
   615 	  else (G\<turnstile>Norm (init_class_obj G C s0) 
   586 	  else (G\<turnstile>Norm (init_class_obj G C s0) 
   616 		  \<midarrow>(if C = Object then Skip else Init (super c))\<rightarrow> s1 \<and>
   587 		  \<midarrow>(if C = Object then Skip else Init (super c))\<rightarrow> s1 \<and>
   617 	       G\<turnstile>set_lvars empty s1 \<midarrow>init c\<rightarrow> s2 \<and> s3 = restore_lvars s1 s2)\<rbrakk> 
   588 	       G\<turnstile>set_lvars empty s1 \<midarrow>init c\<rightarrow> s2 \<and> s3 = restore_lvars s1 s2)\<rbrakk> 
   618               \<Longrightarrow>
   589               \<Longrightarrow>
   640       convenience. 
   611       convenience. 
   641    *}
   612    *}
   642 --{* evaluation of expressions *}
   613 --{* evaluation of expressions *}
   643 
   614 
   644   --{* cf. 15.8.1, 12.4.1 *}
   615   --{* cf. 15.8.1, 12.4.1 *}
   645   NewC:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>Init C\<rightarrow> s1;
   616 | NewC:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>Init C\<rightarrow> s1;
   646 	  G\<turnstile>     s1 \<midarrow>halloc (CInst C)\<succ>a\<rightarrow> s2\<rbrakk> \<Longrightarrow>
   617 	  G\<turnstile>     s1 \<midarrow>halloc (CInst C)\<succ>a\<rightarrow> s2\<rbrakk> \<Longrightarrow>
   647 	                          G\<turnstile>Norm s0 \<midarrow>NewC C-\<succ>Addr a\<rightarrow> s2"
   618 	                          G\<turnstile>Norm s0 \<midarrow>NewC C-\<succ>Addr a\<rightarrow> s2"
   648 
   619 
   649   --{* cf. 15.9.1, 12.4.1 *}
   620   --{* cf. 15.9.1, 12.4.1 *}
   650   NewA:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>init_comp_ty T\<rightarrow> s1; G\<turnstile>s1 \<midarrow>e-\<succ>i'\<rightarrow> s2; 
   621 | NewA:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>init_comp_ty T\<rightarrow> s1; G\<turnstile>s1 \<midarrow>e-\<succ>i'\<rightarrow> s2; 
   651 	  G\<turnstile>abupd (check_neg i') s2 \<midarrow>halloc (Arr T (the_Intg i'))\<succ>a\<rightarrow> s3\<rbrakk> \<Longrightarrow>
   622 	  G\<turnstile>abupd (check_neg i') s2 \<midarrow>halloc (Arr T (the_Intg i'))\<succ>a\<rightarrow> s3\<rbrakk> \<Longrightarrow>
   652 	                        G\<turnstile>Norm s0 \<midarrow>New T[e]-\<succ>Addr a\<rightarrow> s3"
   623 	                        G\<turnstile>Norm s0 \<midarrow>New T[e]-\<succ>Addr a\<rightarrow> s3"
   653 
   624 
   654   --{* cf. 15.15 *}
   625   --{* cf. 15.15 *}
   655   Cast:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1;
   626 | Cast:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1;
   656 	  s2 = abupd (raise_if (\<not>G,store s1\<turnstile>v fits T) ClassCast) s1\<rbrakk> \<Longrightarrow>
   627 	  s2 = abupd (raise_if (\<not>G,store s1\<turnstile>v fits T) ClassCast) s1\<rbrakk> \<Longrightarrow>
   657 			        G\<turnstile>Norm s0 \<midarrow>Cast T e-\<succ>v\<rightarrow> s2"
   628 			        G\<turnstile>Norm s0 \<midarrow>Cast T e-\<succ>v\<rightarrow> s2"
   658 
   629 
   659   --{* cf. 15.19.2 *}
   630   --{* cf. 15.19.2 *}
   660   Inst:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1;
   631 | Inst:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1;
   661 	  b = (v\<noteq>Null \<and> G,store s1\<turnstile>v fits RefT T)\<rbrakk> \<Longrightarrow>
   632 	  b = (v\<noteq>Null \<and> G,store s1\<turnstile>v fits RefT T)\<rbrakk> \<Longrightarrow>
   662 			      G\<turnstile>Norm s0 \<midarrow>e InstOf T-\<succ>Bool b\<rightarrow> s1"
   633 			      G\<turnstile>Norm s0 \<midarrow>e InstOf T-\<succ>Bool b\<rightarrow> s1"
   663 
   634 
   664   --{* cf. 15.7.1 *}
   635   --{* cf. 15.7.1 *}
   665   Lit:	"G\<turnstile>Norm s \<midarrow>Lit v-\<succ>v\<rightarrow> Norm s"
   636 | Lit:	"G\<turnstile>Norm s \<midarrow>Lit v-\<succ>v\<rightarrow> Norm s"
   666 
   637 
   667   UnOp: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1\<rbrakk> 
   638 | UnOp: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1\<rbrakk> 
   668          \<Longrightarrow> G\<turnstile>Norm s0 \<midarrow>UnOp unop e-\<succ>(eval_unop unop v)\<rightarrow> s1"
   639          \<Longrightarrow> G\<turnstile>Norm s0 \<midarrow>UnOp unop e-\<succ>(eval_unop unop v)\<rightarrow> s1"
   669  
   640  
   670   BinOp: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e1-\<succ>v1\<rightarrow> s1; 
   641 | BinOp: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e1-\<succ>v1\<rightarrow> s1; 
   671           G\<turnstile>s1 \<midarrow>(if need_second_arg binop v1 then (In1l e2) else (In1r Skip))
   642           G\<turnstile>s1 \<midarrow>(if need_second_arg binop v1 then (In1l e2) else (In1r Skip))
   672                 \<succ>\<rightarrow> (In1 v2,s2)
   643                 \<succ>\<rightarrow> (In1 v2, s2)
   673           \<rbrakk> 
   644           \<rbrakk> 
   674          \<Longrightarrow> G\<turnstile>Norm s0 \<midarrow>BinOp binop e1 e2-\<succ>(eval_binop binop v1 v2)\<rightarrow> s2"
   645          \<Longrightarrow> G\<turnstile>Norm s0 \<midarrow>BinOp binop e1 e2-\<succ>(eval_binop binop v1 v2)\<rightarrow> s2"
   675    
   646    
   676   --{* cf. 15.10.2 *}
   647   --{* cf. 15.10.2 *}
   677   Super: "G\<turnstile>Norm s \<midarrow>Super-\<succ>val_this s\<rightarrow> Norm s"
   648 | Super: "G\<turnstile>Norm s \<midarrow>Super-\<succ>val_this s\<rightarrow> Norm s"
   678 
   649 
   679   --{* cf. 15.2 *}
   650   --{* cf. 15.2 *}
   680   Acc:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>va=\<succ>(v,f)\<rightarrow> s1\<rbrakk> \<Longrightarrow>
   651 | Acc:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>va=\<succ>(v,f)\<rightarrow> s1\<rbrakk> \<Longrightarrow>
   681 	                          G\<turnstile>Norm s0 \<midarrow>Acc va-\<succ>v\<rightarrow> s1"
   652 	                          G\<turnstile>Norm s0 \<midarrow>Acc va-\<succ>v\<rightarrow> s1"
   682 
   653 
   683   --{* cf. 15.25.1 *}
   654   --{* cf. 15.25.1 *}
   684   Ass:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>va=\<succ>(w,f)\<rightarrow> s1;
   655 | Ass:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>va=\<succ>(w,f)\<rightarrow> s1;
   685           G\<turnstile>     s1 \<midarrow>e-\<succ>v  \<rightarrow> s2\<rbrakk> \<Longrightarrow>
   656           G\<turnstile>     s1 \<midarrow>e-\<succ>v  \<rightarrow> s2\<rbrakk> \<Longrightarrow>
   686 				   G\<turnstile>Norm s0 \<midarrow>va:=e-\<succ>v\<rightarrow> assign f v s2"
   657 				   G\<turnstile>Norm s0 \<midarrow>va:=e-\<succ>v\<rightarrow> assign f v s2"
   687 
   658 
   688   --{* cf. 15.24 *}
   659   --{* cf. 15.24 *}
   689   Cond:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e0-\<succ>b\<rightarrow> s1;
   660 | Cond:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e0-\<succ>b\<rightarrow> s1;
   690           G\<turnstile>     s1 \<midarrow>(if the_Bool b then e1 else e2)-\<succ>v\<rightarrow> s2\<rbrakk> \<Longrightarrow>
   661           G\<turnstile>     s1 \<midarrow>(if the_Bool b then e1 else e2)-\<succ>v\<rightarrow> s2\<rbrakk> \<Longrightarrow>
   691 			    G\<turnstile>Norm s0 \<midarrow>e0 ? e1 : e2-\<succ>v\<rightarrow> s2"
   662 			    G\<turnstile>Norm s0 \<midarrow>e0 ? e1 : e2-\<succ>v\<rightarrow> s2"
   692 
   663 
   693 
   664 
   694 -- {* The interplay of  @{term Call}, @{term Methd} and @{term Body}:
   665 -- {* The interplay of  @{term Call}, @{term Methd} and @{term Body}:
   708                            initialisation. Without class initialisation we 
   679                            initialisation. Without class initialisation we 
   709                            could just evaluate the body statement. 
   680                            could just evaluate the body statement. 
   710       \end{itemize}
   681       \end{itemize}
   711    *}
   682    *}
   712   --{* cf. 15.11.4.1, 15.11.4.2, 15.11.4.4, 15.11.4.5 *}
   683   --{* cf. 15.11.4.1, 15.11.4.2, 15.11.4.4, 15.11.4.5 *}
   713   Call:	
   684 | Call:	
   714   "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>a'\<rightarrow> s1; G\<turnstile>s1 \<midarrow>args\<doteq>\<succ>vs\<rightarrow> s2;
   685   "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>a'\<rightarrow> s1; G\<turnstile>s1 \<midarrow>args\<doteq>\<succ>vs\<rightarrow> s2;
   715     D = invocation_declclass G mode (store s2) a' statT \<lparr>name=mn,parTs=pTs\<rparr>;
   686     D = invocation_declclass G mode (store s2) a' statT \<lparr>name=mn,parTs=pTs\<rparr>;
   716     s3=init_lvars G D \<lparr>name=mn,parTs=pTs\<rparr> mode a' vs s2;
   687     s3=init_lvars G D \<lparr>name=mn,parTs=pTs\<rparr> mode a' vs s2;
   717     s3' = check_method_access G accC statT mode \<lparr>name=mn,parTs=pTs\<rparr> a' s3;
   688     s3' = check_method_access G accC statT mode \<lparr>name=mn,parTs=pTs\<rparr> a' s3;
   718     G\<turnstile>s3' \<midarrow>Methd D \<lparr>name=mn,parTs=pTs\<rparr>-\<succ>v\<rightarrow> s4\<rbrakk>
   689     G\<turnstile>s3' \<midarrow>Methd D \<lparr>name=mn,parTs=pTs\<rparr>-\<succ>v\<rightarrow> s4\<rbrakk>
   721 --{* The accessibility check is after @{term init_lvars}, to keep it simple. 
   692 --{* The accessibility check is after @{term init_lvars}, to keep it simple. 
   722    @{term init_lvars} already tests for the absence of a null-pointer 
   693    @{term init_lvars} already tests for the absence of a null-pointer 
   723    reference in case of an instance method invocation.
   694    reference in case of an instance method invocation.
   724 *}
   695 *}
   725 
   696 
   726   Methd:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>body G D sig-\<succ>v\<rightarrow> s1\<rbrakk> \<Longrightarrow>
   697 | Methd:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>body G D sig-\<succ>v\<rightarrow> s1\<rbrakk> \<Longrightarrow>
   727 				G\<turnstile>Norm s0 \<midarrow>Methd D sig-\<succ>v\<rightarrow> s1"
   698 				G\<turnstile>Norm s0 \<midarrow>Methd D sig-\<succ>v\<rightarrow> s1"
   728   
   699   
   729   Body:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>Init D\<rightarrow> s1; G\<turnstile>s1 \<midarrow>c\<rightarrow> s2; 
   700 | Body:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>Init D\<rightarrow> s1; G\<turnstile>s1 \<midarrow>c\<rightarrow> s2; 
   730           s3 = (if (\<exists> l. abrupt s2 = Some (Jump (Break l)) \<or>  
   701           s3 = (if (\<exists> l. abrupt s2 = Some (Jump (Break l)) \<or>  
   731                          abrupt s2 = Some (Jump (Cont l)))
   702                          abrupt s2 = Some (Jump (Cont l)))
   732                   then abupd (\<lambda> x. Some (Error CrossMethodJump)) s2 
   703                   then abupd (\<lambda> x. Some (Error CrossMethodJump)) s2 
   733                   else s2)\<rbrakk> \<Longrightarrow>
   704                   else s2)\<rbrakk> \<Longrightarrow>
   734            G\<turnstile>Norm s0 \<midarrow>Body D c-\<succ>the (locals (store s2) Result)
   705            G\<turnstile>Norm s0 \<midarrow>Body D c-\<succ>the (locals (store s2) Result)
   740      different parts of the typesafety proof can be disentangled a little. *}
   711      different parts of the typesafety proof can be disentangled a little. *}
   741 
   712 
   742 --{* evaluation of variables *}
   713 --{* evaluation of variables *}
   743 
   714 
   744   --{* cf. 15.13.1, 15.7.2 *}
   715   --{* cf. 15.13.1, 15.7.2 *}
   745   LVar:	"G\<turnstile>Norm s \<midarrow>LVar vn=\<succ>lvar vn s\<rightarrow> Norm s"
   716 | LVar:	"G\<turnstile>Norm s \<midarrow>LVar vn=\<succ>lvar vn s\<rightarrow> Norm s"
   746 
   717 
   747   --{* cf. 15.10.1, 12.4.1 *}
   718   --{* cf. 15.10.1, 12.4.1 *}
   748   FVar:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>Init statDeclC\<rightarrow> s1; G\<turnstile>s1 \<midarrow>e-\<succ>a\<rightarrow> s2;
   719 | FVar:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>Init statDeclC\<rightarrow> s1; G\<turnstile>s1 \<midarrow>e-\<succ>a\<rightarrow> s2;
   749 	  (v,s2') = fvar statDeclC stat fn a s2;
   720 	  (v,s2') = fvar statDeclC stat fn a s2;
   750           s3 = check_field_access G accC statDeclC fn stat a s2' \<rbrakk> \<Longrightarrow>
   721           s3 = check_field_access G accC statDeclC fn stat a s2' \<rbrakk> \<Longrightarrow>
   751 	  G\<turnstile>Norm s0 \<midarrow>{accC,statDeclC,stat}e..fn=\<succ>v\<rightarrow> s3"
   722 	  G\<turnstile>Norm s0 \<midarrow>{accC,statDeclC,stat}e..fn=\<succ>v\<rightarrow> s3"
   752  --{* The accessibility check is after @{term fvar}, to keep it simple. 
   723  --{* The accessibility check is after @{term fvar}, to keep it simple. 
   753     @{term fvar} already tests for the absence of a null-pointer reference 
   724     @{term fvar} already tests for the absence of a null-pointer reference 
   754     in case of an instance field
   725     in case of an instance field
   755   *}
   726   *}
   756 
   727 
   757   --{* cf. 15.12.1, 15.25.1 *}
   728   --{* cf. 15.12.1, 15.25.1 *}
   758   AVar:	"\<lbrakk>G\<turnstile> Norm s0 \<midarrow>e1-\<succ>a\<rightarrow> s1; G\<turnstile>s1 \<midarrow>e2-\<succ>i\<rightarrow> s2;
   729 | AVar:	"\<lbrakk>G\<turnstile> Norm s0 \<midarrow>e1-\<succ>a\<rightarrow> s1; G\<turnstile>s1 \<midarrow>e2-\<succ>i\<rightarrow> s2;
   759 	  (v,s2') = avar G i a s2\<rbrakk> \<Longrightarrow>
   730 	  (v,s2') = avar G i a s2\<rbrakk> \<Longrightarrow>
   760 	              G\<turnstile>Norm s0 \<midarrow>e1.[e2]=\<succ>v\<rightarrow> s2'"
   731 	              G\<turnstile>Norm s0 \<midarrow>e1.[e2]=\<succ>v\<rightarrow> s2'"
   761 
   732 
   762 
   733 
   763 --{* evaluation of expression lists *}
   734 --{* evaluation of expression lists *}
   764 
   735 
   765   --{* cf. 15.11.4.2 *}
   736   --{* cf. 15.11.4.2 *}
   766   Nil:
   737 | Nil:
   767 				    "G\<turnstile>Norm s0 \<midarrow>[]\<doteq>\<succ>[]\<rightarrow> Norm s0"
   738 				    "G\<turnstile>Norm s0 \<midarrow>[]\<doteq>\<succ>[]\<rightarrow> Norm s0"
   768 
   739 
   769   --{* cf. 15.6.4 *}
   740   --{* cf. 15.6.4 *}
   770   Cons:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e -\<succ> v \<rightarrow> s1;
   741 | Cons:	"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e -\<succ> v \<rightarrow> s1;
   771           G\<turnstile>     s1 \<midarrow>es\<doteq>\<succ>vs\<rightarrow> s2\<rbrakk> \<Longrightarrow>
   742           G\<turnstile>     s1 \<midarrow>es\<doteq>\<succ>vs\<rightarrow> s2\<rbrakk> \<Longrightarrow>
   772 				   G\<turnstile>Norm s0 \<midarrow>e#es\<doteq>\<succ>v#vs\<rightarrow> s2"
   743 				   G\<turnstile>Norm s0 \<midarrow>e#es\<doteq>\<succ>v#vs\<rightarrow> s2"
   773 
   744 
   774 (* Rearrangement of premisses:
   745 (* Rearrangement of premisses:
   775 [0,1(Abrupt),2(Skip),8(Jmp),4(Lab),30(Nil),31(Cons),27(LVar),17(Cast),18(Inst),
   746 [0,1(Abrupt),2(Skip),8(Jmp),4(Lab),30(Nil),31(Cons),27(LVar),17(Cast),18(Inst),
   792    and and 
   763    and and 
   793    s2 (* Fin *) and and s2 (* NewC *)] 
   764    s2 (* Fin *) and and s2 (* NewC *)] 
   794 
   765 
   795 declare split_if     [split del] split_if_asm     [split del] 
   766 declare split_if     [split del] split_if_asm     [split del] 
   796         option.split [split del] option.split_asm [split del]
   767         option.split [split del] option.split_asm [split del]
   797 inductive_cases halloc_elim_cases: 
   768 inductive_cases2 halloc_elim_cases: 
   798   "G\<turnstile>(Some xc,s) \<midarrow>halloc oi\<succ>a\<rightarrow> s'"
   769   "G\<turnstile>(Some xc,s) \<midarrow>halloc oi\<succ>a\<rightarrow> s'"
   799   "G\<turnstile>(Norm    s) \<midarrow>halloc oi\<succ>a\<rightarrow> s'"
   770   "G\<turnstile>(Norm    s) \<midarrow>halloc oi\<succ>a\<rightarrow> s'"
   800 
   771 
   801 inductive_cases sxalloc_elim_cases:
   772 inductive_cases2 sxalloc_elim_cases:
   802  	"G\<turnstile> Norm                 s  \<midarrow>sxalloc\<rightarrow> s'"
   773  	"G\<turnstile> Norm                 s  \<midarrow>sxalloc\<rightarrow> s'"
   803         "G\<turnstile>(Some (Jump j),s) \<midarrow>sxalloc\<rightarrow> s'"
   774         "G\<turnstile>(Some (Jump j),s) \<midarrow>sxalloc\<rightarrow> s'"
   804  	"G\<turnstile>(Some (Error e),s) \<midarrow>sxalloc\<rightarrow> s'"
   775  	"G\<turnstile>(Some (Error e),s) \<midarrow>sxalloc\<rightarrow> s'"
   805         "G\<turnstile>(Some (Xcpt (Loc a )),s) \<midarrow>sxalloc\<rightarrow> s'"
   776         "G\<turnstile>(Some (Xcpt (Loc a )),s) \<midarrow>sxalloc\<rightarrow> s'"
   806  	"G\<turnstile>(Some (Xcpt (Std xn)),s) \<midarrow>sxalloc\<rightarrow> s'"
   777  	"G\<turnstile>(Some (Xcpt (Std xn)),s) \<midarrow>sxalloc\<rightarrow> s'"
   807 inductive_cases sxalloc_cases: "G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s'"
   778 inductive_cases2 sxalloc_cases: "G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s'"
   808 
   779 
   809 lemma sxalloc_elim_cases2: "\<lbrakk>G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s';  
   780 lemma sxalloc_elim_cases2: "\<lbrakk>G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s';  
   810        \<And>s.   \<lbrakk>s' = Norm s\<rbrakk> \<Longrightarrow> P;  
   781        \<And>s.   \<lbrakk>s' = Norm s\<rbrakk> \<Longrightarrow> P;  
   811        \<And>j s. \<lbrakk>s' = (Some (Jump j),s)\<rbrakk> \<Longrightarrow> P;
   782        \<And>j s. \<lbrakk>s' = (Some (Jump j),s)\<rbrakk> \<Longrightarrow> P;
   812        \<And>e s. \<lbrakk>s' = (Some (Error e),s)\<rbrakk> \<Longrightarrow> P;
   783        \<And>e s. \<lbrakk>s' = (Some (Error e),s)\<rbrakk> \<Longrightarrow> P;
   820 declare not_None_eq [simp del] (* IntDef.Zero_def [simp del] *)
   791 declare not_None_eq [simp del] (* IntDef.Zero_def [simp del] *)
   821 declare split_paired_All [simp del] split_paired_Ex [simp del]
   792 declare split_paired_All [simp del] split_paired_Ex [simp del]
   822 ML_setup {*
   793 ML_setup {*
   823 change_simpset (fn ss => ss delloop "split_all_tac");
   794 change_simpset (fn ss => ss delloop "split_all_tac");
   824 *}
   795 *}
   825 inductive_cases eval_cases: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> vs'"
   796 inductive_cases2 eval_cases: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v, s')"
   826 
   797 
   827 inductive_cases eval_elim_cases [cases set]:
   798 inductive_cases2 eval_elim_cases [cases set]:
   828         "G\<turnstile>(Some xc,s) \<midarrow>t                              \<succ>\<rightarrow> vs'"
   799         "G\<turnstile>(Some xc,s) \<midarrow>t                              \<succ>\<rightarrow> (v, s')"
   829 	"G\<turnstile>Norm s \<midarrow>In1r Skip                           \<succ>\<rightarrow> xs'"
   800 	"G\<turnstile>Norm s \<midarrow>In1r Skip                           \<succ>\<rightarrow> (x, s')"
   830         "G\<turnstile>Norm s \<midarrow>In1r (Jmp j)                        \<succ>\<rightarrow> xs'"
   801         "G\<turnstile>Norm s \<midarrow>In1r (Jmp j)                        \<succ>\<rightarrow> (x, s')"
   831         "G\<turnstile>Norm s \<midarrow>In1r (l\<bullet> c)                         \<succ>\<rightarrow> xs'"
   802         "G\<turnstile>Norm s \<midarrow>In1r (l\<bullet> c)                         \<succ>\<rightarrow> (x, s')"
   832 	"G\<turnstile>Norm s \<midarrow>In3  ([])                           \<succ>\<rightarrow> vs'"
   803 	"G\<turnstile>Norm s \<midarrow>In3  ([])                           \<succ>\<rightarrow> (v, s')"
   833 	"G\<turnstile>Norm s \<midarrow>In3  (e#es)                         \<succ>\<rightarrow> vs'"
   804 	"G\<turnstile>Norm s \<midarrow>In3  (e#es)                         \<succ>\<rightarrow> (v, s')"
   834 	"G\<turnstile>Norm s \<midarrow>In1l (Lit w)                        \<succ>\<rightarrow> vs'"
   805 	"G\<turnstile>Norm s \<midarrow>In1l (Lit w)                        \<succ>\<rightarrow> (v, s')"
   835         "G\<turnstile>Norm s \<midarrow>In1l (UnOp unop e)                  \<succ>\<rightarrow> vs'"
   806         "G\<turnstile>Norm s \<midarrow>In1l (UnOp unop e)                  \<succ>\<rightarrow> (v, s')"
   836         "G\<turnstile>Norm s \<midarrow>In1l (BinOp binop e1 e2)            \<succ>\<rightarrow> vs'"
   807         "G\<turnstile>Norm s \<midarrow>In1l (BinOp binop e1 e2)            \<succ>\<rightarrow> (v, s')"
   837 	"G\<turnstile>Norm s \<midarrow>In2  (LVar vn)                      \<succ>\<rightarrow> vs'"
   808 	"G\<turnstile>Norm s \<midarrow>In2  (LVar vn)                      \<succ>\<rightarrow> (v, s')"
   838 	"G\<turnstile>Norm s \<midarrow>In1l (Cast T e)                     \<succ>\<rightarrow> vs'"
   809 	"G\<turnstile>Norm s \<midarrow>In1l (Cast T e)                     \<succ>\<rightarrow> (v, s')"
   839 	"G\<turnstile>Norm s \<midarrow>In1l (e InstOf T)                   \<succ>\<rightarrow> vs'"
   810 	"G\<turnstile>Norm s \<midarrow>In1l (e InstOf T)                   \<succ>\<rightarrow> (v, s')"
   840 	"G\<turnstile>Norm s \<midarrow>In1l (Super)                        \<succ>\<rightarrow> vs'"
   811 	"G\<turnstile>Norm s \<midarrow>In1l (Super)                        \<succ>\<rightarrow> (v, s')"
   841 	"G\<turnstile>Norm s \<midarrow>In1l (Acc va)                       \<succ>\<rightarrow> vs'"
   812 	"G\<turnstile>Norm s \<midarrow>In1l (Acc va)                       \<succ>\<rightarrow> (v, s')"
   842 	"G\<turnstile>Norm s \<midarrow>In1r (Expr e)                       \<succ>\<rightarrow> xs'"
   813 	"G\<turnstile>Norm s \<midarrow>In1r (Expr e)                       \<succ>\<rightarrow> (x, s')"
   843 	"G\<turnstile>Norm s \<midarrow>In1r (c1;; c2)                      \<succ>\<rightarrow> xs'"
   814 	"G\<turnstile>Norm s \<midarrow>In1r (c1;; c2)                      \<succ>\<rightarrow> (x, s')"
   844 	"G\<turnstile>Norm s \<midarrow>In1l (Methd C sig)                  \<succ>\<rightarrow> xs'"
   815 	"G\<turnstile>Norm s \<midarrow>In1l (Methd C sig)                  \<succ>\<rightarrow> (x, s')"
   845 	"G\<turnstile>Norm s \<midarrow>In1l (Body D c)                     \<succ>\<rightarrow> xs'"
   816 	"G\<turnstile>Norm s \<midarrow>In1l (Body D c)                     \<succ>\<rightarrow> (x, s')"
   846 	"G\<turnstile>Norm s \<midarrow>In1l (e0 ? e1 : e2)                 \<succ>\<rightarrow> vs'"
   817 	"G\<turnstile>Norm s \<midarrow>In1l (e0 ? e1 : e2)                 \<succ>\<rightarrow> (v, s')"
   847 	"G\<turnstile>Norm s \<midarrow>In1r (If(e) c1 Else c2)             \<succ>\<rightarrow> xs'"
   818 	"G\<turnstile>Norm s \<midarrow>In1r (If(e) c1 Else c2)             \<succ>\<rightarrow> (x, s')"
   848 	"G\<turnstile>Norm s \<midarrow>In1r (l\<bullet> While(e) c)                \<succ>\<rightarrow> xs'"
   819 	"G\<turnstile>Norm s \<midarrow>In1r (l\<bullet> While(e) c)                \<succ>\<rightarrow> (x, s')"
   849 	"G\<turnstile>Norm s \<midarrow>In1r (c1 Finally c2)                \<succ>\<rightarrow> xs'"
   820 	"G\<turnstile>Norm s \<midarrow>In1r (c1 Finally c2)                \<succ>\<rightarrow> (x, s')"
   850 	"G\<turnstile>Norm s \<midarrow>In1r (Throw e)                      \<succ>\<rightarrow> xs'"
   821 	"G\<turnstile>Norm s \<midarrow>In1r (Throw e)                      \<succ>\<rightarrow> (x, s')"
   851 	"G\<turnstile>Norm s \<midarrow>In1l (NewC C)                       \<succ>\<rightarrow> vs'"
   822 	"G\<turnstile>Norm s \<midarrow>In1l (NewC C)                       \<succ>\<rightarrow> (v, s')"
   852 	"G\<turnstile>Norm s \<midarrow>In1l (New T[e])                     \<succ>\<rightarrow> vs'"
   823 	"G\<turnstile>Norm s \<midarrow>In1l (New T[e])                     \<succ>\<rightarrow> (v, s')"
   853 	"G\<turnstile>Norm s \<midarrow>In1l (Ass va e)                     \<succ>\<rightarrow> vs'"
   824 	"G\<turnstile>Norm s \<midarrow>In1l (Ass va e)                     \<succ>\<rightarrow> (v, s')"
   854 	"G\<turnstile>Norm s \<midarrow>In1r (Try c1 Catch(tn vn) c2)       \<succ>\<rightarrow> xs'"
   825 	"G\<turnstile>Norm s \<midarrow>In1r (Try c1 Catch(tn vn) c2)       \<succ>\<rightarrow> (x, s')"
   855 	"G\<turnstile>Norm s \<midarrow>In2  ({accC,statDeclC,stat}e..fn)   \<succ>\<rightarrow> vs'"
   826 	"G\<turnstile>Norm s \<midarrow>In2  ({accC,statDeclC,stat}e..fn)   \<succ>\<rightarrow> (v, s')"
   856 	"G\<turnstile>Norm s \<midarrow>In2  (e1.[e2])                      \<succ>\<rightarrow> vs'"
   827 	"G\<turnstile>Norm s \<midarrow>In2  (e1.[e2])                      \<succ>\<rightarrow> (v, s')"
   857 	"G\<turnstile>Norm s \<midarrow>In1l ({accC,statT,mode}e\<cdot>mn({pT}p)) \<succ>\<rightarrow> vs'"
   828 	"G\<turnstile>Norm s \<midarrow>In1l ({accC,statT,mode}e\<cdot>mn({pT}p)) \<succ>\<rightarrow> (v, s')"
   858 	"G\<turnstile>Norm s \<midarrow>In1r (Init C)                       \<succ>\<rightarrow> xs'"
   829 	"G\<turnstile>Norm s \<midarrow>In1r (Init C)                       \<succ>\<rightarrow> (x, s')"
   859 declare not_None_eq [simp]  (* IntDef.Zero_def [simp] *)
   830 declare not_None_eq [simp]  (* IntDef.Zero_def [simp] *)
   860 declare split_paired_All [simp] split_paired_Ex [simp]
   831 declare split_paired_All [simp] split_paired_Ex [simp]
   861 ML_setup {*
   832 ML_setup {*
   862 change_simpset (fn ss => ss addloop ("split_all_tac", split_all_tac));
   833 change_simpset (fn ss => ss addloop ("split_all_tac", split_all_tac));
   863 *}
   834 *}
   883  terms and their corresponding values in the evaluation relation:
   854  terms and their corresponding values in the evaluation relation:
   884  E.g. an expression 
   855  E.g. an expression 
   885  (injection @{term In1l} into terms) always evaluates to ordinary values 
   856  (injection @{term In1l} into terms) always evaluates to ordinary values 
   886  (injection @{term In1} into generalised values @{term vals}). 
   857  (injection @{term In1} into generalised values @{term vals}). 
   887 *}
   858 *}
       
   859 
       
   860 lemma eval_expr_eq: "G\<turnstile>s \<midarrow>In1l t\<succ>\<rightarrow> (w, s') = (\<exists>v. w=In1 v \<and> G\<turnstile>s \<midarrow>t-\<succ>v \<rightarrow> s')"
       
   861   by (auto, frule eval_Inj_elim, auto)
       
   862 
       
   863 lemma eval_var_eq: "G\<turnstile>s \<midarrow>In2 t\<succ>\<rightarrow> (w, s') = (\<exists>vf. w=In2 vf \<and> G\<turnstile>s \<midarrow>t=\<succ>vf\<rightarrow> s')"
       
   864   by (auto, frule eval_Inj_elim, auto)
       
   865 
       
   866 lemma eval_exprs_eq: "G\<turnstile>s \<midarrow>In3 t\<succ>\<rightarrow> (w, s') = (\<exists>vs. w=In3 vs \<and> G\<turnstile>s \<midarrow>t\<doteq>\<succ>vs\<rightarrow> s')"
       
   867   by (auto, frule eval_Inj_elim, auto)
       
   868 
       
   869 lemma eval_stmt_eq: "G\<turnstile>s \<midarrow>In1r t\<succ>\<rightarrow> (w, s') = (w=\<diamondsuit> \<and> G\<turnstile>s \<midarrow>t \<rightarrow> s')"
       
   870   by (auto, frule eval_Inj_elim, auto, frule eval_Inj_elim, auto)
       
   871 
   888 ML_setup {*
   872 ML_setup {*
   889 fun eval_fun nam inj rhs =
   873 fun eval_fun name lhs =
   890 let
   874 let
   891   val name = "eval_" ^ nam ^ "_eq"
       
   892   val lhs = "G\<turnstile>s \<midarrow>" ^ inj ^ " t\<succ>\<rightarrow> (w, s')"
       
   893   val () = qed_goal name (the_context()) (lhs ^ " = (" ^ rhs ^ ")") 
       
   894 	(K [Auto_tac, ALLGOALS (ftac (thm "eval_Inj_elim")) THEN Auto_tac])
       
   895   fun is_Inj (Const (inj,_) $ _) = true
   875   fun is_Inj (Const (inj,_) $ _) = true
   896     | is_Inj _                   = false
   876     | is_Inj _                   = false
   897   fun pred (_ $ (Const ("Pair",_) $ _ $ 
   877   fun pred (_ $ _ $ _ $ _ $ x $ _) = is_Inj x
   898       (Const ("Pair", _) $ _ $ (Const ("Pair", _) $ x $ _ ))) $ _ ) = is_Inj x
       
   899 in
   878 in
   900   cond_simproc name lhs pred (thm name)
   879   cond_simproc name lhs pred (thm name)
   901 end
   880 end
   902 
   881 
   903 val eval_expr_proc =eval_fun "expr" "In1l" "\<exists>v.  w=In1 v   \<and> G\<turnstile>s \<midarrow>t-\<succ>v \<rightarrow> s'"
   882 val eval_expr_proc  = eval_fun "eval_expr_eq"  "G\<turnstile>s \<midarrow>In1l t\<succ>\<rightarrow> (w, s')";
   904 val eval_var_proc  =eval_fun "var"  "In2"  "\<exists>vf. w=In2 vf  \<and> G\<turnstile>s \<midarrow>t=\<succ>vf\<rightarrow> s'"
   883 val eval_var_proc   = eval_fun "eval_var_eq"   "G\<turnstile>s \<midarrow>In2 t\<succ>\<rightarrow> (w, s')";
   905 val eval_exprs_proc=eval_fun "exprs""In3"  "\<exists>vs. w=In3 vs  \<and> G\<turnstile>s \<midarrow>t\<doteq>\<succ>vs\<rightarrow> s'"
   884 val eval_exprs_proc = eval_fun "eval_exprs_eq" "G\<turnstile>s \<midarrow>In3 t\<succ>\<rightarrow> (w, s')";
   906 val eval_stmt_proc =eval_fun "stmt" "In1r" "     w=\<diamondsuit> \<and> G\<turnstile>s \<midarrow>t    \<rightarrow> s'";
   885 val eval_stmt_proc  = eval_fun "eval_stmt_eq"  "G\<turnstile>s \<midarrow>In1r t\<succ>\<rightarrow> (w, s')";
   907 Addsimprocs [eval_expr_proc,eval_var_proc,eval_exprs_proc,eval_stmt_proc];
   886 Addsimprocs [eval_expr_proc,eval_var_proc,eval_exprs_proc,eval_stmt_proc];
   908 bind_thms ("AbruptIs", sum3_instantiate (thm "eval.Abrupt"))
   887 bind_thms ("AbruptIs", sum3_instantiate (thm "eval.Abrupt"))
   909 *}
   888 *}
   910 
   889 
   911 declare halloc.Abrupt [intro!] eval.Abrupt [intro!]  AbruptIs [intro!] 
   890 declare halloc.Abrupt [intro!] eval.Abrupt [intro!]  AbruptIs [intro!] 
   920 proof -
   899 proof -
   921   { fix s t v s'
   900   { fix s t v s'
   922     assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and
   901     assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and
   923          normal: "normal s" and
   902          normal: "normal s" and
   924          callee: "t=In1l (Callee l e)"
   903          callee: "t=In1l (Callee l e)"
   925     then have "False"
   904     then have "False" by induct auto
   926     proof (induct)
       
   927     qed (auto)
       
   928   }  
   905   }  
   929   then show ?thesis
   906   then show ?thesis
   930     by (cases s') fastsimp
   907     by (cases s') fastsimp
   931 qed
   908 qed
   932 
   909 
   935 proof -
   912 proof -
   936   { fix s t v s'
   913   { fix s t v s'
   937     assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and
   914     assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and
   938          normal: "normal s" and
   915          normal: "normal s" and
   939          callee: "t=In1l (InsInitE c e)"
   916          callee: "t=In1l (InsInitE c e)"
   940     then have "False"
   917     then have "False" by induct auto
   941     proof (induct)
       
   942     qed (auto)
       
   943   }
   918   }
   944   then show ?thesis
   919   then show ?thesis
   945     by (cases s') fastsimp
   920     by (cases s') fastsimp
   946 qed
   921 qed
   947 
   922 
   949 proof -
   924 proof -
   950   { fix s t v s'
   925   { fix s t v s'
   951     assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and
   926     assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and
   952          normal: "normal s" and
   927          normal: "normal s" and
   953          callee: "t=In2 (InsInitV c w)"
   928          callee: "t=In2 (InsInitV c w)"
   954     then have "False"
   929     then have "False" by induct auto
   955     proof (induct)
       
   956     qed (auto)
       
   957   }  
   930   }  
   958   then show ?thesis
   931   then show ?thesis
   959     by (cases s') fastsimp
   932     by (cases s') fastsimp
   960 qed
   933 qed
   961 
   934 
   963 proof -
   936 proof -
   964   { fix s t v s'
   937   { fix s t v s'
   965     assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and
   938     assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and
   966          normal: "normal s" and
   939          normal: "normal s" and
   967          callee: "t=In1r (FinA a c)"
   940          callee: "t=In1r (FinA a c)"
   968     then have "False"
   941     then have "False" by induct auto
   969     proof (induct)
       
   970     qed (auto)
       
   971   }  
   942   }  
   972   then show ?thesis
   943   then show ?thesis
   973     by (cases s') fastsimp 
   944     by (cases s') fastsimp 
   974 qed
   945 qed
   975 
   946 
   986 
   957 
   987 ML {*
   958 ML {*
   988 local
   959 local
   989   fun is_None (Const ("Datatype.option.None",_)) = true
   960   fun is_None (Const ("Datatype.option.None",_)) = true
   990     | is_None _ = false
   961     | is_None _ = false
   991   fun pred (t as (_ $ (Const ("Pair",_) $
   962   fun pred (_ $ _ $ (Const ("Pair", _) $ x $ _) $ _  $ _ $ _) = is_None x
   992      (Const ("Pair", _) $ x $ _) $ _ ) $ _)) = is_None x
       
   993 in
   963 in
   994   val eval_no_abrupt_proc = 
   964   val eval_no_abrupt_proc = 
   995   cond_simproc "eval_no_abrupt" "G\<turnstile>(x,s) \<midarrow>e\<succ>\<rightarrow> (w,Norm s')" pred 
   965   cond_simproc "eval_no_abrupt" "G\<turnstile>(x,s) \<midarrow>e\<succ>\<rightarrow> (w,Norm s')" pred 
   996           (thm "eval_no_abrupt")
   966           (thm "eval_no_abrupt")
   997 end;
   967 end;
  1013 
   983 
  1014 ML {*
   984 ML {*
  1015 local
   985 local
  1016   fun is_Some (Const ("Pair",_) $ (Const ("Datatype.option.Some",_) $ _)$ _) =true
   986   fun is_Some (Const ("Pair",_) $ (Const ("Datatype.option.Some",_) $ _)$ _) =true
  1017     | is_Some _ = false
   987     | is_Some _ = false
  1018   fun pred (_ $ (Const ("Pair",_) $
   988   fun pred (_ $ _ $ _ $ _ $ _ $ x) = is_Some x
  1019      _ $ (Const ("Pair", _) $ _ $ (Const ("Pair", _) $ _ $
       
  1020        x))) $ _ ) = is_Some x
       
  1021 in
   989 in
  1022   val eval_abrupt_proc = 
   990   val eval_abrupt_proc = 
  1023   cond_simproc "eval_abrupt" 
   991   cond_simproc "eval_abrupt" 
  1024                "G\<turnstile>(Some xc,s) \<midarrow>e\<succ>\<rightarrow> (w,s')" pred (thm "eval_abrupt")
   992                "G\<turnstile>(Some xc,s) \<midarrow>e\<succ>\<rightarrow> (w,s')" pred (thm "eval_abrupt")
  1025 end;
   993 end;
  1172 
  1140 
  1173 
  1141 
  1174 section "single valued"
  1142 section "single valued"
  1175 
  1143 
  1176 lemma unique_halloc [rule_format (no_asm)]: 
  1144 lemma unique_halloc [rule_format (no_asm)]: 
  1177   "\<And>s as as'. (s,oi,as)\<in>halloc G \<Longrightarrow> (s,oi,as')\<in>halloc G \<longrightarrow> as'=as"
  1145   "G\<turnstile>s \<midarrow>halloc oi\<succ>a \<rightarrow> s' \<Longrightarrow> G\<turnstile>s \<midarrow>halloc oi\<succ>a' \<rightarrow> s'' \<longrightarrow> a' = a \<and> s'' = s'"
  1178 apply (simp (no_asm_simp) only: split_tupled_all)
       
  1179 apply (erule halloc.induct)
  1146 apply (erule halloc.induct)
  1180 apply  (auto elim!: halloc_elim_cases split del: split_if split_if_asm)
  1147 apply  (auto elim!: halloc_elim_cases split del: split_if split_if_asm)
  1181 apply (drule trans [THEN sym], erule sym) 
  1148 apply (drule trans [THEN sym], erule sym) 
  1182 defer
  1149 defer
  1183 apply (drule trans [THEN sym], erule sym)
  1150 apply (drule trans [THEN sym], erule sym)
  1190 apply (unfold single_valued_def)
  1157 apply (unfold single_valued_def)
  1191 by (clarsimp, drule (1) unique_halloc, auto)
  1158 by (clarsimp, drule (1) unique_halloc, auto)
  1192 
  1159 
  1193 
  1160 
  1194 lemma unique_sxalloc [rule_format (no_asm)]: 
  1161 lemma unique_sxalloc [rule_format (no_asm)]: 
  1195   "\<And>s s'. G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s' \<Longrightarrow> G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s'' \<longrightarrow> s'' = s'"
  1162   "G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s' \<Longrightarrow> G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s'' \<longrightarrow> s'' = s'"
  1196 apply (simp (no_asm_simp) only: split_tupled_all)
       
  1197 apply (erule sxalloc.induct)
  1163 apply (erule sxalloc.induct)
  1198 apply   (auto dest: unique_halloc elim!: sxalloc_elim_cases 
  1164 apply   (auto dest: unique_halloc elim!: sxalloc_elim_cases 
  1199               split del: split_if split_if_asm)
  1165               split del: split_if split_if_asm)
  1200 done
  1166 done
  1201 
  1167 
  1208 by auto
  1174 by auto
  1209 
  1175 
  1210 
  1176 
  1211 
  1177 
  1212 lemma unique_eval [rule_format (no_asm)]: 
  1178 lemma unique_eval [rule_format (no_asm)]: 
  1213   "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> ws \<Longrightarrow> (\<forall>ws'. G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> ws' \<longrightarrow> ws' = ws)"
  1179   "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (w, s') \<Longrightarrow> (\<forall>w' s''. G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (w', s'') \<longrightarrow> w' = w \<and> s'' = s')"
  1214 apply (case_tac "ws")
       
  1215 apply hypsubst
       
  1216 apply (erule eval_induct)
  1180 apply (erule eval_induct)
  1217 apply (tactic {* ALLGOALS (EVERY'
  1181 apply (tactic {* ALLGOALS (EVERY'
  1218       [strip_tac, rotate_tac ~1, eresolve_tac (thms "eval_elim_cases")]) *})
  1182       [strip_tac, rotate_tac ~1, eresolve_tac (thms "eval_elim_cases")]) *})
  1219 (* 31 subgoals *)
  1183 (* 31 subgoals *)
  1220 prefer 28 (* Try *) 
  1184 prefer 28 (* Try *) 
  1221 apply (simp (no_asm_use) only: split add: split_if_asm)
  1185 apply (simp (no_asm_use) only: split add: split_if_asm)
  1222 (* 34 subgoals *)
  1186 (* 34 subgoals *)
  1223 prefer 30 (* Init *)
  1187 prefer 30 (* Init *)
  1224 apply (case_tac "inited C (globs s0)", (simp only: if_True if_False)+)
  1188 apply (case_tac "inited C (globs s0)", (simp only: if_True if_False simp_thms)+)
  1225 prefer 26 (* While *)
  1189 prefer 26 (* While *)
  1226 apply (simp (no_asm_use) only: split add: split_if_asm, blast)
  1190 apply (simp (no_asm_use) only: split add: split_if_asm, blast)
  1227 apply (drule_tac x="(In1 bb, s1a)" in spec, drule (1) mp, simp)
  1191 (* 36 subgoals *)
  1228 apply (drule_tac x="(In1 bb, s1a)" in spec, drule (1) mp, simp)
       
  1229 apply blast
       
  1230 (* 33 subgoals *)
       
  1231 apply (blast dest: unique_sxalloc unique_halloc split_pairD)+
  1192 apply (blast dest: unique_sxalloc unique_halloc split_pairD)+
  1232 done
  1193 done
  1233 
  1194 
  1234 (* unused *)
  1195 (* unused *)
  1235 lemma single_valued_eval: 
  1196 lemma single_valued_eval: 
  1236  "single_valued {((s,t),vs'). G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> vs'}"
  1197  "single_valued {((s, t), (v, s')). G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v, s')}"
  1237 apply (unfold single_valued_def)
  1198 apply (unfold single_valued_def)
  1238 by (clarify, drule (1) unique_eval, auto)
  1199 by (clarify, drule (1) unique_eval, auto)
  1239 
  1200 
  1240 end
  1201 end