src/HOL/MicroJava/BV/Correct.thy
changeset 8045 816f566c414f
parent 8034 6fc37b5c5e98
child 8047 3a0c996cf2b2
equal deleted inserted replaced
8044:296b03b79505 8045:816f566c414f
    18 
    18 
    19  approx_stk :: "[jvm_prog,aheap,opstack,opstack_type] \\<Rightarrow> bool"
    19  approx_stk :: "[jvm_prog,aheap,opstack,opstack_type] \\<Rightarrow> bool"
    20 "approx_stk G hp stk ST \\<equiv> approx_loc G hp stk (map Some ST)"
    20 "approx_stk G hp stk ST \\<equiv> approx_loc G hp stk (map Some ST)"
    21 
    21 
    22  correct_frame  :: "[jvm_prog,aheap,state_type,nat,bytecode] \\<Rightarrow> frame \\<Rightarrow> bool"
    22  correct_frame  :: "[jvm_prog,aheap,state_type,nat,bytecode] \\<Rightarrow> frame \\<Rightarrow> bool"
    23 "correct_frame G hp \\<equiv> \\<lambda>(ST,LT) maxl ins (stk,loc,C,ml,pc).
    23 "correct_frame G hp \\<equiv> \\<lambda>(ST,LT) maxl ins (stk,loc,C,sig,pc).
    24    approx_stk G hp stk ST  \\<and> approx_loc G hp loc LT \\<and> 
    24    approx_stk G hp stk ST  \\<and> approx_loc G hp loc LT \\<and> 
    25    pc < length ins \\<and> length loc=length(snd ml)+maxl+1"
    25    pc < length ins \\<and> length loc=length(snd sig)+maxl+1"
    26 
    26 
    27 consts
    27 consts
    28  correct_frames  :: "[jvm_prog,aheap,prog_type,ty,cname,sig,frame list] \\<Rightarrow> bool"
    28  correct_frames  :: "[jvm_prog,aheap,prog_type,ty,sig,frame list] \\<Rightarrow> bool"
    29 primrec
    29 primrec
    30 "correct_frames G hp phi rT0 C0 ml0 [] = False"
    30 "correct_frames G hp phi rT0 sig0 [] = True"
    31 
    31 
    32 "correct_frames G hp phi rT0 C0 ml0 (f#frs) =
    32 "correct_frames G hp phi rT0 sig0 (f#frs) =
    33 	(let (stk,loc,C,ml,pc) = f;
    33 	(let (stk,loc,C,sig,pc) = f;
    34 	     (ST,LT) = (phi C ml) ! pc
    34 	     (ST,LT) = (phi C sig) ! pc
    35 	 in
    35 	 in
    36          (\\<exists>rT maxl ins.
    36          (\\<exists>rT maxl ins.
    37          method (G,C) ml = Some(C,rT,(maxl,ins)) \\<and>
    37          method (G,C) sig = Some(C,rT,(maxl,ins)) \\<and>
    38 	 (\\<exists>mn pTs k. pc = k+1 \\<and> ins!k = MI(Invoke mn pTs) \\<and>
    38 	 (\\<exists>mn pTs k. pc = k+1 \\<and> ins!k = MI(Invoke mn pTs) \\<and>
    39          (mn,pTs) = ml0 \\<and> 
    39          (mn,pTs) = sig0 \\<and> 
    40          (\\<exists>apTs D ST'.
    40          (\\<exists>apTs D ST'.
    41          fst((phi C ml)!k) = (rev apTs) @ (Class D) # ST' \\<and>
    41          fst((phi C sig)!k) = (rev apTs) @ (Class D) # ST' \\<and>
    42          length apTs = length pTs \\<and>
    42          length apTs = length pTs \\<and>
    43          (\\<exists>D' rT' maxl' ins'.
    43          (\\<exists>D' rT' maxl' ins'.
    44            method (G,D) (mn,pTs) = Some(D',rT',(maxl',ins')) \\<and>
    44            method (G,D) (mn,pTs) = Some(D',rT',(maxl',ins')) \\<and>
    45            G \\<turnstile> rT0 \\<preceq> rT') \\<and>
    45            G \\<turnstile> rT0 \\<preceq> rT') \\<and>
    46 	 correct_frame G hp (tl ST, LT) maxl ins f \\<and> 
    46 	 correct_frame G hp (tl ST, LT) maxl ins f \\<and> 
    47 	 correct_frames G hp phi rT C ml frs))))"
    47 	 correct_frames G hp phi rT sig frs))))"
    48 
    48 
    49 
    49 
    50 constdefs
    50 constdefs
    51  correct_state :: "[jvm_prog,prog_type,jvm_state] \\<Rightarrow> bool"
    51  correct_state :: "[jvm_prog,prog_type,jvm_state] \\<Rightarrow> bool"
    52                   ("_,_\\<turnstile>JVM _\\<surd>"  [51,51] 50)
    52                   ("_,_\\<turnstile>JVM _\\<surd>"  [51,51] 50)
    53 "correct_state G phi \\<equiv> \\<lambda>(xp,hp,frs).
    53 "correct_state G phi \\<equiv> \\<lambda>(xp,hp,frs).
    54    case xp of
    54    case xp of
    55      None \\<Rightarrow> (case frs of
    55      None \\<Rightarrow> (case frs of
    56 	           [] \\<Rightarrow> True
    56 	           [] \\<Rightarrow> True
    57              | (f#fs) \\<Rightarrow> (let (stk,loc,C,ml,pc) = f
    57              | (f#fs) \\<Rightarrow> G\\<turnstile>h hp\\<surd> \\<and>
       
    58 			(let (stk,loc,C,sig,pc) = f
    58 		         in
    59 		         in
    59                          \\<exists>rT maxl ins.
    60                          \\<exists>rT maxl ins.
    60                          method (G,C) ml = Some(C,rT,(maxl,ins)) \\<and>
    61                          method (G,C) sig = Some(C,rT,(maxl,ins)) \\<and>
    61 		         G\\<turnstile>h hp\\<surd> \\<and> 
    62 			 correct_frame G hp ((phi C sig) ! pc) maxl ins f \\<and> 
    62 			 correct_frame G hp ((phi C ml) ! pc) maxl ins f \\<and> 
    63 		         correct_frames G hp phi rT sig fs))
    63 		         correct_frames G hp phi rT C ml fs))
       
    64    | Some x \\<Rightarrow> True" 
    64    | Some x \\<Rightarrow> True" 
    65 
    65 
    66 end
    66 end