src/HOL/Bali/Trans.thy
changeset 12854 00d4a435777f
child 12857 a4386cc9b1c3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Bali/Trans.thy	Mon Jan 28 17:00:19 2002 +0100
     1.3 @@ -0,0 +1,144 @@
     1.4 +(*  Title:      isabelle/Bali/Trans.thy
     1.5 +    ID:         $Id$
     1.6 +    Author:     David von Oheimb
     1.7 +    Copyright   1997 Technische Universitaet Muenchen
     1.8 +
     1.9 +Operational transition (small-step) semantics of the 
    1.10 +execution of Java expressions and statements
    1.11 +
    1.12 +PRELIMINARY!!!!!!!!
    1.13 +
    1.14 +*)
    1.15 +
    1.16 +Trans = Eval +
    1.17 +
    1.18 +consts
    1.19 +  texpr_tstmt	:: "prog \<Rightarrow> (((expr \<times> state) \<times> (expr \<times> state)) +
    1.20 +		            ((stmt \<times> state) \<times> (stmt \<times> state))) set"
    1.21 +
    1.22 +syntax (symbols)
    1.23 +  texpr :: "[prog, expr \<times> state, expr \<times> state] \<Rightarrow> bool "("_\<turnstile>_ \<rightarrow>1 _"[61,82,82] 81)
    1.24 +  tstmt :: "[prog, stmt \<times> state, stmt \<times> state] \<Rightarrow> bool "("_\<turnstile>_ \<mapsto>1 _"[61,82,82] 81)
    1.25 +  Ref   :: "loc \<Rightarrow> expr"
    1.26 +
    1.27 +translations
    1.28 +
    1.29 +  "G\<turnstile>e_s \<rightarrow>1 ex_s'" == "Inl (e_s, ex_s') \<in> texpr_tstmt G"
    1.30 +  "G\<turnstile>s_s \<mapsto>1 s'_s'" == "Inr (s_s, s'_s') \<in> texpr_tstmt G"
    1.31 +  "Ref a" == "Lit (Addr a)"
    1.32 +
    1.33 +inductive "texpr_tstmt G" intrs 
    1.34 +
    1.35 +(* evaluation of expression *)
    1.36 +  (* cf. 15.5 *)
    1.37 +  XcptE	"\<lbrakk>\<forall>v. e \<noteq> Lit v\<rbrakk> \\<Longrightarrow>
    1.38 +				  G\<turnstile>(e,Some xc,s) \<rightarrow>1 (Lit arbitrary,Some xc,s)"
    1.39 +
    1.40 +  (* cf. 15.8.1 *)
    1.41 +  NewC	"\<lbrakk>new_Addr (heap s) = Some (a,x);
    1.42 +	  s' = assign (hupd[a\<mapsto>init_Obj G C]s) (x,s)\<rbrakk> \\<Longrightarrow>
    1.43 +				G\<turnstile>(NewC C,None,s) \<rightarrow>1 (Ref a,s')"
    1.44 +
    1.45 +  (* cf. 15.9.1 *)
    1.46 +  NewA1	"\<lbrakk>G\<turnstile>(e,None,s) \<rightarrow>1 (e',s')\<rbrakk> \\<Longrightarrow>
    1.47 +			      G\<turnstile>(New T[e],None,s) \<rightarrow>1 (New T[e'],s')"
    1.48 +  NewA	"\<lbrakk>i = the_Intg i'; new_Addr (heap s) = Some (a, x);
    1.49 +	  s' = assign (hupd[a\<mapsto>init_Arr T i]s)(raise_if (i<#0) NegArrSize x,s)\<rbrakk> \\<Longrightarrow>
    1.50 +			G\<turnstile>(New T[Lit i'],None,s) \<rightarrow>1 (Ref a,s')"
    1.51 +  (* cf. 15.15 *)
    1.52 +  Cast1	"\<lbrakk>G\<turnstile>(e,None,s) \<rightarrow>1 (e',s')\<rbrakk> \\<Longrightarrow>
    1.53 +			      G\<turnstile>(Cast T e,None,s) \<rightarrow>1 (Cast T e',s')"
    1.54 +  Cast	"\<lbrakk>x'= raise_if (\<questiondown>G,s\<turnstile>v fits T) ClassCast None\<rbrakk> \\<Longrightarrow>
    1.55 +		        G\<turnstile>(Cast T (Lit v),None,s) \<rightarrow>1 (Lit v,x',s)"
    1.56 +
    1.57 +  (* cf. 15.7.1 *)
    1.58 +(*Lit				"G\<turnstile>(Lit v,None,s) \<rightarrow>1 (Lit v,None,s)"*)
    1.59 +
    1.60 +  (* cf. 15.13.1, 15.2 *)
    1.61 +  LAcc	"\<lbrakk>v = the (locals s vn)\<rbrakk> \\<Longrightarrow>
    1.62 +			       G\<turnstile>(LAcc vn,None,s) \<rightarrow>1 (Lit v,None,s)"
    1.63 +
    1.64 +  (* cf. 15.25.1 *)
    1.65 +  LAss1	"\<lbrakk>G\<turnstile>(e,None,s) \<rightarrow>1 (e',s')\<rbrakk> \\<Longrightarrow>
    1.66 +				 G\<turnstile>(f vn:=e,None,s) \<rightarrow>1 (vn:=e',s')"
    1.67 +  LAss			    "G\<turnstile>(f vn:=Lit v,None,s) \<rightarrow>1 (Lit v,None,lupd[vn\<mapsto>v]s)"
    1.68 +
    1.69 +  (* cf. 15.10.1, 15.2 *)
    1.70 +  FAcc1	"\<lbrakk>G\<turnstile>(e,None,s) \<rightarrow>1 (e',s')\<rbrakk> \\<Longrightarrow>
    1.71 +			       G\<turnstile>({T}e..fn,None,s) \<rightarrow>1 ({T}e'..fn,s')"
    1.72 +  FAcc	"\<lbrakk>v = the (snd (the_Obj (heap s (the_Addr a'))) (fn,T))\<rbrakk> \\<Longrightarrow>
    1.73 +			  G\<turnstile>({T}Lit a'..fn,None,s) \<rightarrow>1 (Lit v,np a' None,s)"
    1.74 +
    1.75 +  (* cf. 15.25.1 *)
    1.76 +  FAss1	"\<lbrakk>G\<turnstile>(e1,None,s) \<rightarrow>1 (e1',s')\<rbrakk> \\<Longrightarrow>
    1.77 +			  G\<turnstile>(f ({T}e1..fn):=e2,None,s) \<rightarrow>1 (f({T}e1'..fn):=e2,s')"
    1.78 +  FAss2	"\<lbrakk>G\<turnstile>(e2,np a' None,s) \<rightarrow>1 (e2',s')\<rbrakk> \\<Longrightarrow>
    1.79 +		      G\<turnstile>(f({T}Lit a'..fn):=e2,None,s) \<rightarrow>1 (f({T}Lit a'..fn):=e2',s')"
    1.80 +  FAss	"\<lbrakk>a = the_Addr a'; (c,fs) = the_Obj (heap s a);
    1.81 +	  s'= assign (hupd[a\<mapsto>Obj c (fs[(fn,T)\<mapsto>v])]s) (None,s)\<rbrakk> \\<Longrightarrow>
    1.82 +		   G\<turnstile>(f({T}Lit a'..fn):=Lit v,None,s) \<rightarrow>1 (Lit v,s')"
    1.83 +
    1.84 +
    1.85 +
    1.86 +
    1.87 +
    1.88 +  (* cf. 15.12.1 *)
    1.89 +  AAcc1	"\<lbrakk>G\<turnstile>(e1,None,s) \<rightarrow>1 (e1',s')\<rbrakk> \\<Longrightarrow>
    1.90 +				G\<turnstile>(e1[e2],None,s) \<rightarrow>1 (e1'[e2],s')"
    1.91 +  AAcc2	"\<lbrakk>G\<turnstile>(e2,None,s) \<rightarrow>1 (e2',s')\<rbrakk> \\<Longrightarrow>
    1.92 +			    G\<turnstile>(Lit a'[e2],None,s) \<rightarrow>1 (Lit a'[e2'],s')"
    1.93 +  AAcc	"\<lbrakk>vo = snd (the_Arr (heap s (the_Addr a'))) (the_Intg i');
    1.94 +	  x' = raise_if (vo = None) IndOutBound (np a' None)\<rbrakk> \\<Longrightarrow>
    1.95 +			G\<turnstile>(Lit a'[Lit i'],None,s) \<rightarrow>1 (Lit (the vo),x',s)"
    1.96 +
    1.97 +
    1.98 +  (* cf. 15.11.4.1, 15.11.4.2, 15.11.4.4, 15.11.4.5, 14.15 *)
    1.99 +  Call1	"\<lbrakk>G\<turnstile>(e,None,s) \<rightarrow>1 (e',s')\<rbrakk> \\<Longrightarrow>
   1.100 +			  G\<turnstile>(e..mn({pT}p),None,s) \<rightarrow>1 (e'..mn({pT}p),s')"
   1.101 +  Call2	"\<lbrakk>G\<turnstile>(p,None,s) \<rightarrow>1 (p',s')\<rbrakk> \\<Longrightarrow>
   1.102 +		     G\<turnstile>(Lit a'..mn({pT}p),None,s) \<rightarrow>1 (Lit a'..mn({pT}p'),s')"
   1.103 +  Call	"\<lbrakk>a = the_Addr a'; (md,(pn,rT),lvars,blk,res) = 
   1.104 + 			   the (cmethd G (fst (the_Obj (h a))) (mn,pT))\<rbrakk> \\<Longrightarrow>
   1.105 +	    G\<turnstile>(Lit a'..mn({pT}Lit pv),None,(h,l)) \<rightarrow>1 
   1.106 +      (Body blk res l,np a' x,(h,init_vals lvars[This\<mapsto>a'][Super\<mapsto>a'][pn\<mapsto>pv]))"
   1.107 +  Body1	"\<lbrakk>G\<turnstile>(s0,None,s) \<mapsto>1 (s0',s')\<rbrakk> \\<Longrightarrow>
   1.108 +		   G\<turnstile>(Body s0    e      l,None,s) \<rightarrow>1 (Body s0'  e  l,s')"
   1.109 +  Body2	"\<lbrakk>G\<turnstile>(e ,None,s) \<rightarrow>1 (e',s')\<rbrakk> \\<Longrightarrow>
   1.110 +		   G\<turnstile>(Body Skip  e      l,None,s) \<rightarrow>1 (Body Skip e' l,s')"
   1.111 +  Body		  "G\<turnstile>(Body Skip (Lit v) l,None,s) \<rightarrow>1 (Lit v,None,(heap s,l))"
   1.112 +
   1.113 +(* execution of statements *)
   1.114 +
   1.115 +  (* cf. 14.1 *)
   1.116 +  XcptS	"\<lbrakk>s0 \<noteq> Skip\<rbrakk> \\<Longrightarrow>
   1.117 +				 G\<turnstile>(s0,Some xc,s) \<mapsto>1 (Skip,Some xc,s)"
   1.118 +
   1.119 +  (* cf. 14.5 *)
   1.120 +(*Skip	 			 "G\<turnstile>(Skip,None,s) \<mapsto>1 (Skip,None,s)"*)
   1.121 +
   1.122 +  (* cf. 14.2 *)
   1.123 +  Comp1	"\<lbrakk>G\<turnstile>(s1,None,s) \<mapsto>1 (s1',s')\<rbrakk> \\<Longrightarrow>
   1.124 +			       G\<turnstile>(s1;; s2,None,s) \<mapsto>1 (s1';; s2,s')"
   1.125 +  Comp			    "G\<turnstile>(Skip;; s2,None,s) \<mapsto>1 (s2,None,s)"
   1.126 +
   1.127 +
   1.128 +
   1.129 +
   1.130 +
   1.131 +
   1.132 +  (* cf. 14.7 *)
   1.133 +  Expr1	"\<lbrakk>G\<turnstile>(e ,None,s) \<rightarrow>1 (e',s')\<rbrakk> \\<Longrightarrow>
   1.134 +				G\<turnstile>(Expr e,None,s) \<mapsto>1 (Expr e',s')"
   1.135 +  Expr			 "G\<turnstile>(Expr (Lit v),None,s) \<mapsto>1 (Skip,None,s)"
   1.136 +
   1.137 +  (* cf. 14.8.2 *)
   1.138 +  If1	"\<lbrakk>G\<turnstile>(e ,None,s) \<rightarrow>1 (e',s')\<rbrakk> \\<Longrightarrow>
   1.139 +		      G\<turnstile>(If(e) s1 Else s2,None,s) \<mapsto>1 (If(e') s1 Else s2,s')"
   1.140 +  If		 "G\<turnstile>(If(Lit v) s1 Else s2,None,s) \<mapsto>1 
   1.141 +		    (if the_Bool v then s1 else s2,None,s)"
   1.142 +
   1.143 +  (* cf. 14.10, 14.10.1 *)
   1.144 +  Loop			  "G\<turnstile>(While(e) s0,None,s) \<mapsto>1 
   1.145 +			     (If(e) (s0;; While(e) s0) Else Skip,None,s)"
   1.146 +
   1.147 +end