diff -r 7c49988afd0e -r 982f3e02f3c4 src/HOL/MicroJava/BV/BVSpec.thy --- a/src/HOL/MicroJava/BV/BVSpec.thy Fri Jun 11 17:14:01 2010 +0200 +++ b/src/HOL/MicroJava/BV/BVSpec.thy Fri Jun 11 17:14:01 2010 +0200 @@ -15,48 +15,53 @@ to type \emph{checking}. *} -constdefs +definition -- "The program counter will always be inside the method:" - check_bounded :: "instr list \ exception_table \ bool" - "check_bounded ins et \ + check_bounded :: "instr list \ exception_table \ bool" where + "check_bounded ins et \ (\pc < length ins. \pc' \ set (succs (ins!pc) pc). pc' < length ins) \ (\e \ set et. fst (snd (snd e)) < length ins)" +definition -- "The method type only contains declared classes:" - check_types :: "jvm_prog \ nat \ nat \ JVMType.state list \ bool" - "check_types G mxs mxr phi \ set phi \ states G mxs mxr" + check_types :: "jvm_prog \ nat \ nat \ JVMType.state list \ bool" where + "check_types G mxs mxr phi \ set phi \ states G mxs mxr" +definition -- "An instruction is welltyped if it is applicable and its effect" -- "is compatible with the type at all successor instructions:" wt_instr :: "[instr,jvm_prog,ty,method_type,nat,p_count, - exception_table,p_count] \ bool" - "wt_instr i G rT phi mxs max_pc et pc \ + exception_table,p_count] \ bool" where + "wt_instr i G rT phi mxs max_pc et pc \ app i G mxs rT pc et (phi!pc) \ (\(pc',s') \ set (eff i G pc et (phi!pc)). pc' < max_pc \ G \ s' <=' phi!pc')" +definition -- {* The type at @{text "pc=0"} conforms to the method calling convention: *} - wt_start :: "[jvm_prog,cname,ty list,nat,method_type] \ bool" - "wt_start G C pTs mxl phi == + wt_start :: "[jvm_prog,cname,ty list,nat,method_type] \ bool" where + "wt_start G C pTs mxl phi \ G \ Some ([],(OK (Class C))#((map OK pTs))@(replicate mxl Err)) <=' phi!0" +definition -- "A method is welltyped if the body is not empty, if execution does not" -- "leave the body, if the method type covers all instructions and mentions" -- "declared classes only, if the method calling convention is respected, and" -- "if all instructions are welltyped." wt_method :: "[jvm_prog,cname,ty list,ty,nat,nat,instr list, - exception_table,method_type] \ bool" - "wt_method G C pTs rT mxs mxl ins et phi \ - let max_pc = length ins in + exception_table,method_type] \ bool" where + "wt_method G C pTs rT mxs mxl ins et phi \ + (let max_pc = length ins in 0 < max_pc \ length phi = length ins \ check_bounded ins et \ check_types G mxs (1+length pTs+mxl) (map OK phi) \ wt_start G C pTs mxl phi \ - (\pc. pc wt_instr (ins!pc) G rT phi mxs max_pc et pc)" + (\pc. pc wt_instr (ins!pc) G rT phi mxs max_pc et pc))" +definition -- "A program is welltyped if it is wellformed and all methods are welltyped" - wt_jvm_prog :: "[jvm_prog,prog_type] \ bool" - "wt_jvm_prog G phi == + wt_jvm_prog :: "[jvm_prog,prog_type] \ bool" where + "wt_jvm_prog G phi \ wf_prog (\G C (sig,rT,(maxs,maxl,b,et)). wt_method G C (snd sig) rT maxs maxl b et (phi C sig)) G"