src/HOL/MicroJava/J/Eval.thy
changeset 10042 7164dc0d24d8
parent 9671 8741740ea6d6
child 10056 9f84ffa4a8d0
     1.1 --- a/src/HOL/MicroJava/J/Eval.thy	Wed Sep 20 21:20:41 2000 +0200
     1.2 +++ b/src/HOL/MicroJava/J/Eval.thy	Thu Sep 21 10:42:49 2000 +0200
     1.3 @@ -10,118 +10,118 @@
     1.4  Eval = State + WellType +
     1.5  
     1.6  consts
     1.7 -  eval  :: "java_mb prog \\<Rightarrow> (xstate \\<times> expr      \\<times> val      \\<times> xstate) set"
     1.8 -  evals :: "java_mb prog \\<Rightarrow> (xstate \\<times> expr list \\<times> val list \\<times> xstate) set"
     1.9 -  exec  :: "java_mb prog \\<Rightarrow> (xstate \\<times> stmt                 \\<times> xstate) set"
    1.10 +  eval  :: "java_mb prog => (xstate \\<times> expr      \\<times> val      \\<times> xstate) set"
    1.11 +  evals :: "java_mb prog => (xstate \\<times> expr list \\<times> val list \\<times> xstate) set"
    1.12 +  exec  :: "java_mb prog => (xstate \\<times> stmt                 \\<times> xstate) set"
    1.13  
    1.14  syntax
    1.15 -  eval :: "[java_mb prog,xstate,expr,val,xstate] \\<Rightarrow> bool "("_\\<turnstile>_ -_\\<succ>_\\<rightarrow> _"[51,82,82,82,82]81)
    1.16 +  eval :: "[java_mb prog,xstate,expr,val,xstate] => bool "("_\\<turnstile>_ -_\\<succ>_-> _"[51,82,82,82,82]81)
    1.17    evals:: "[java_mb prog,xstate,expr list,
    1.18 -	                      val list,xstate] \\<Rightarrow> bool "("_\\<turnstile>_ -_[\\<succ>]_\\<rightarrow> _"[51,82,51,51,82]81)
    1.19 -  exec :: "[java_mb prog,xstate,stmt,    xstate] \\<Rightarrow> bool "("_\\<turnstile>_ -_\\<rightarrow> _"  [51,82,82,   82]81)
    1.20 +	                      val list,xstate] => bool "("_\\<turnstile>_ -_[\\<succ>]_-> _"[51,82,51,51,82]81)
    1.21 +  exec :: "[java_mb prog,xstate,stmt,    xstate] => bool "("_\\<turnstile>_ -_-> _"  [51,82,82,   82]81)
    1.22  
    1.23  translations
    1.24 -  "G\\<turnstile>s -e \\<succ> v\\<rightarrow> (x,s')" <= "(s, e, v, x, s') \\<in> eval  G"
    1.25 -  "G\\<turnstile>s -e \\<succ> v\\<rightarrow>    s' " == "(s, e, v,    s' ) \\<in> eval  G"
    1.26 -  "G\\<turnstile>s -e[\\<succ>]v\\<rightarrow> (x,s')" <= "(s, e, v, x, s') \\<in> evals G"
    1.27 -  "G\\<turnstile>s -e[\\<succ>]v\\<rightarrow>    s' " == "(s, e, v,    s' ) \\<in> evals G"
    1.28 -  "G\\<turnstile>s -c    \\<rightarrow> (x,s')" <= "(s, c, x, s') \\<in> exec  G"
    1.29 -  "G\\<turnstile>s -c    \\<rightarrow>    s' " == "(s, c,    s') \\<in> exec  G"
    1.30 +  "G\\<turnstile>s -e \\<succ> v-> (x,s')" <= "(s, e, v, x, s') \\<in> eval  G"
    1.31 +  "G\\<turnstile>s -e \\<succ> v->    s' " == "(s, e, v,    s' ) \\<in> eval  G"
    1.32 +  "G\\<turnstile>s -e[\\<succ>]v-> (x,s')" <= "(s, e, v, x, s') \\<in> evals G"
    1.33 +  "G\\<turnstile>s -e[\\<succ>]v->    s' " == "(s, e, v,    s' ) \\<in> evals G"
    1.34 +  "G\\<turnstile>s -c    -> (x,s')" <= "(s, c, x, s') \\<in> exec  G"
    1.35 +  "G\\<turnstile>s -c    ->    s' " == "(s, c,    s') \\<in> exec  G"
    1.36  
    1.37  inductive "eval G" "evals G" "exec G" intrs
    1.38  
    1.39  (* evaluation of expressions *)
    1.40  
    1.41    (* cf. 15.5 *)
    1.42 -  XcptE				  "G\\<turnstile>(Some xc,s) -e\\<succ>arbitrary\\<rightarrow> (Some xc,s)"
    1.43 +  XcptE				  "G\\<turnstile>(Some xc,s) -e\\<succ>arbitrary-> (Some xc,s)"
    1.44  
    1.45    (* cf. 15.8.1 *)
    1.46 -  NewC	"\\<lbrakk>h = heap s; (a,x) = new_Addr h;
    1.47 -	  h'= h(a\\<mapsto>(C,init_vars (fields (G,C))))\\<rbrakk> \\<Longrightarrow>
    1.48 -				   G\\<turnstile>Norm s -NewC C\\<succ>Addr a\\<rightarrow> c_hupd h' (x,s)"
    1.49 +  NewC	"[|h = heap s; (a,x) = new_Addr h;
    1.50 +	  h'= h(a\\<mapsto>(C,init_vars (fields (G,C))))|] ==>
    1.51 +				   G\\<turnstile>Norm s -NewC C\\<succ>Addr a-> c_hupd h' (x,s)"
    1.52  
    1.53    (* cf. 15.15 *)
    1.54 -  Cast	"\\<lbrakk>G\\<turnstile>Norm s0 -e\\<succ>v\\<rightarrow> (x1,s1);
    1.55 -	  x2=raise_if (\\<not> cast_ok G C (heap s1) v) ClassCast x1\\<rbrakk> \\<Longrightarrow>
    1.56 -			        G\\<turnstile>Norm s0 -Cast C e\\<succ>v\\<rightarrow> (x2,s1)"
    1.57 +  Cast	"[|G\\<turnstile>Norm s0 -e\\<succ>v-> (x1,s1);
    1.58 +	  x2=raise_if (\\<not> cast_ok G C (heap s1) v) ClassCast x1|] ==>
    1.59 +			        G\\<turnstile>Norm s0 -Cast C e\\<succ>v-> (x2,s1)"
    1.60  
    1.61    (* cf. 15.7.1 *)
    1.62 -  Lit				   "G\\<turnstile>Norm s -Lit v\\<succ>v\\<rightarrow> Norm s"
    1.63 +  Lit				   "G\\<turnstile>Norm s -Lit v\\<succ>v-> Norm s"
    1.64  
    1.65 -  BinOp "\\<lbrakk>G\\<turnstile>Norm s -e1\\<succ>v1\\<rightarrow> s1;
    1.66 -	  G\\<turnstile>s1     -e2\\<succ>v2\\<rightarrow> s2;
    1.67 -	  v = (case bop of Eq  \\<Rightarrow> Bool (v1 = v2)
    1.68 -	                 | Add \\<Rightarrow> Intg (the_Intg v1 + the_Intg v2))\\<rbrakk> \\<Longrightarrow>
    1.69 -				   G\\<turnstile>Norm s -BinOp bop e1 e2\\<succ>v\\<rightarrow> s2"
    1.70 +  BinOp "[|G\\<turnstile>Norm s -e1\\<succ>v1-> s1;
    1.71 +	  G\\<turnstile>s1     -e2\\<succ>v2-> s2;
    1.72 +	  v = (case bop of Eq  => Bool (v1 = v2)
    1.73 +	                 | Add => Intg (the_Intg v1 + the_Intg v2))|] ==>
    1.74 +				   G\\<turnstile>Norm s -BinOp bop e1 e2\\<succ>v-> s2"
    1.75  
    1.76    (* cf. 15.13.1, 15.2 *)
    1.77 -  LAcc				  "G\\<turnstile>Norm s -LAcc v\\<succ>the (locals s v)\\<rightarrow> Norm s"
    1.78 +  LAcc				  "G\\<turnstile>Norm s -LAcc v\\<succ>the (locals s v)-> Norm s"
    1.79  
    1.80    (* cf. 15.25.1 *)
    1.81 -  LAss  "\\<lbrakk>G\\<turnstile>Norm s -e\\<succ>v\\<rightarrow>  (x,(h,l));
    1.82 -	  l' = (if x = None then l(va\\<mapsto>v) else l)\\<rbrakk> \\<Longrightarrow>
    1.83 -				   G\\<turnstile>Norm s -va\\<Colon>=e\\<succ>v\\<rightarrow> (x,(h,l'))"
    1.84 +  LAss  "[|G\\<turnstile>Norm s -e\\<succ>v->  (x,(h,l));
    1.85 +	  l' = (if x = None then l(va\\<mapsto>v) else l)|] ==>
    1.86 +				   G\\<turnstile>Norm s -va::=e\\<succ>v-> (x,(h,l'))"
    1.87  
    1.88  
    1.89    (* cf. 15.10.1, 15.2 *)
    1.90 -  FAcc	"\\<lbrakk>G\\<turnstile>Norm s0 -e\\<succ>a'\\<rightarrow> (x1,s1); 
    1.91 -	  v = the (snd (the (heap s1 (the_Addr a'))) (fn,T))\\<rbrakk> \\<Longrightarrow>
    1.92 -				 G\\<turnstile>Norm s0 -{T}e..fn\\<succ>v\\<rightarrow> (np a' x1,s1)"
    1.93 +  FAcc	"[|G\\<turnstile>Norm s0 -e\\<succ>a'-> (x1,s1); 
    1.94 +	  v = the (snd (the (heap s1 (the_Addr a'))) (fn,T))|] ==>
    1.95 +				 G\\<turnstile>Norm s0 -{T}e..fn\\<succ>v-> (np a' x1,s1)"
    1.96  
    1.97    (* cf. 15.25.1 *)
    1.98 -  FAss  "\\<lbrakk>G\\<turnstile>     Norm s0  -e1\\<succ>a'\\<rightarrow> (x1,s1); a = the_Addr a';
    1.99 -	  G\\<turnstile>(np a' x1,s1) -e2\\<succ>v \\<rightarrow> (x2,s2);
   1.100 +  FAss  "[|G\\<turnstile>     Norm s0  -e1\\<succ>a'-> (x1,s1); a = the_Addr a';
   1.101 +	  G\\<turnstile>(np a' x1,s1) -e2\\<succ>v -> (x2,s2);
   1.102  	  h = heap s2; (c,fs) = the (h a);
   1.103 -	  h' = h(a\\<mapsto>(c,(fs((fn,T)\\<mapsto>v))))\\<rbrakk> \\<Longrightarrow>
   1.104 -			  G\\<turnstile>Norm s0 -{T}e1..fn:=e2\\<succ>v\\<rightarrow> c_hupd h' (x2,s2)"
   1.105 +	  h' = h(a\\<mapsto>(c,(fs((fn,T)\\<mapsto>v))))|] ==>
   1.106 +			  G\\<turnstile>Norm s0 -{T}e1..fn:=e2\\<succ>v-> c_hupd h' (x2,s2)"
   1.107  
   1.108    (* cf. 15.11.4.1, 15.11.4.2, 15.11.4.4, 15.11.4.5, 14.15 *)
   1.109 -  Call	"\\<lbrakk>G\\<turnstile>Norm s0 -e\\<succ>a'\\<rightarrow> s1; a = the_Addr a';
   1.110 -	   G\\<turnstile>s1 -ps[\\<succ>]pvs\\<rightarrow> (x,(h,l)); dynT = fst (the (h a));
   1.111 +  Call	"[|G\\<turnstile>Norm s0 -e\\<succ>a'-> s1; a = the_Addr a';
   1.112 +	   G\\<turnstile>s1 -ps[\\<succ>]pvs-> (x,(h,l)); dynT = fst (the (h a));
   1.113  	   (md,rT,pns,lvars,blk,res) = the (method (G,dynT) (mn,pTs));
   1.114 -	   G\\<turnstile>(np a' x,(h,(init_vars lvars)(pns[\\<mapsto>]pvs)(This\\<mapsto>a'))) -blk\\<rightarrow> s3;
   1.115 -	   G\\<turnstile>     s3 -res\\<succ>v \\<rightarrow> (x4,s4)\\<rbrakk> \\<Longrightarrow>
   1.116 -			    G\\<turnstile>Norm s0 -e..mn({pTs}ps)\\<succ>v\\<rightarrow> (x4,(heap s4,l))"
   1.117 +	   G\\<turnstile>(np a' x,(h,(init_vars lvars)(pns[\\<mapsto>]pvs)(This\\<mapsto>a'))) -blk-> s3;
   1.118 +	   G\\<turnstile>     s3 -res\\<succ>v -> (x4,s4)|] ==>
   1.119 +			    G\\<turnstile>Norm s0 -e..mn({pTs}ps)\\<succ>v-> (x4,(heap s4,l))"
   1.120  
   1.121  
   1.122  (* evaluation of expression lists *)
   1.123  
   1.124    (* cf. 15.5 *)
   1.125 -  XcptEs			  "G\\<turnstile>(Some xc,s) -e[\\<succ>]arbitrary\\<rightarrow> (Some xc,s)"
   1.126 +  XcptEs			  "G\\<turnstile>(Some xc,s) -e[\\<succ>]arbitrary-> (Some xc,s)"
   1.127  
   1.128    (* cf. 15.11.??? *)
   1.129    Nil
   1.130 -				    "G\\<turnstile>Norm s0 -[][\\<succ>][]\\<rightarrow> Norm s0"
   1.131 +				    "G\\<turnstile>Norm s0 -[][\\<succ>][]-> Norm s0"
   1.132  
   1.133    (* cf. 15.6.4 *)
   1.134 -  Cons	"\\<lbrakk>G\\<turnstile>Norm s0 -e  \\<succ> v \\<rightarrow> s1;
   1.135 -           G\\<turnstile>     s1 -es[\\<succ>]vs\\<rightarrow> s2\\<rbrakk> \\<Longrightarrow>
   1.136 -				   G\\<turnstile>Norm s0 -e#es[\\<succ>]v#vs\\<rightarrow> s2"
   1.137 +  Cons	"[|G\\<turnstile>Norm s0 -e  \\<succ> v -> s1;
   1.138 +           G\\<turnstile>     s1 -es[\\<succ>]vs-> s2|] ==>
   1.139 +				   G\\<turnstile>Norm s0 -e#es[\\<succ>]v#vs-> s2"
   1.140  
   1.141  (* execution of statements *)
   1.142  
   1.143    (* cf. 14.1 *)
   1.144 -  XcptS				 "G\\<turnstile>(Some xc,s) -s0\\<rightarrow> (Some xc,s)"
   1.145 +  XcptS				 "G\\<turnstile>(Some xc,s) -s0-> (Some xc,s)"
   1.146  
   1.147    (* cf. 14.5 *)
   1.148 -  Skip	 			    "G\\<turnstile>Norm s -Skip\\<rightarrow> Norm s"
   1.149 +  Skip	 			    "G\\<turnstile>Norm s -Skip-> Norm s"
   1.150  
   1.151    (* cf. 14.7 *)
   1.152 -  Expr	"\\<lbrakk>G\\<turnstile>Norm s0 -e\\<succ>v\\<rightarrow> s1\\<rbrakk> \\<Longrightarrow>
   1.153 -				  G\\<turnstile>Norm s0 -Expr e\\<rightarrow> s1"
   1.154 +  Expr	"[|G\\<turnstile>Norm s0 -e\\<succ>v-> s1|] ==>
   1.155 +				  G\\<turnstile>Norm s0 -Expr e-> s1"
   1.156  
   1.157    (* cf. 14.2 *)
   1.158 -  Comp	"\\<lbrakk>G\\<turnstile>Norm s0 -s \\<rightarrow> s1;
   1.159 -	  G\\<turnstile>     s1 -t \\<rightarrow> s2\\<rbrakk> \\<Longrightarrow>
   1.160 -				 G\\<turnstile>Norm s0 -(s;; t)\\<rightarrow> s2"
   1.161 +  Comp	"[|G\\<turnstile>Norm s0 -s -> s1;
   1.162 +	  G\\<turnstile>     s1 -t -> s2|] ==>
   1.163 +				 G\\<turnstile>Norm s0 -(s;; t)-> s2"
   1.164  
   1.165    (* cf. 14.8.2 *)
   1.166 -  Cond	"\\<lbrakk>G\\<turnstile>Norm s0  -e \\<succ>v\\<rightarrow> s1;
   1.167 -	  G\\<turnstile>     s1 -(if  the_Bool v then s else t)\\<rightarrow> s2\\<rbrakk> \\<Longrightarrow>
   1.168 -		        G\\<turnstile>Norm s0 -(If(e) s Else t)\\<rightarrow> s2"
   1.169 +  Cond	"[|G\\<turnstile>Norm s0  -e \\<succ>v-> s1;
   1.170 +	  G\\<turnstile>     s1 -(if  the_Bool v then s else t)-> s2|] ==>
   1.171 +		        G\\<turnstile>Norm s0 -(If(e) s Else t)-> s2"
   1.172  
   1.173    (* cf. 14.10, 14.10.1 *)
   1.174 -  Loop	"\\<lbrakk>G\\<turnstile>Norm s0 -(If(e) (s;; While(e) s) Else Skip)\\<rightarrow> s1\\<rbrakk> \\<Longrightarrow>
   1.175 -			    G\\<turnstile>Norm s0 -(While(e) s)\\<rightarrow> s1"
   1.176 +  Loop	"[|G\\<turnstile>Norm s0 -(If(e) (s;; While(e) s) Else Skip)-> s1|] ==>
   1.177 +			    G\\<turnstile>Norm s0 -(While(e) s)-> s1"
   1.178  
   1.179  end