(* Title: HOL/MicroJava/BV/Typing_Framework_JVM.thy Author: Tobias Nipkow, Gerwin Klein Copyright 2000 TUM
*)
section \<open>The Typing Framework for the JVM \label{sec:JVM}\<close>
theory Typing_Framework_JVM imports"../DFA/Abstract_BV" JVMType EffectMono BVSpec begin
definition exec :: "jvm_prog \ nat \ ty \ exception_table \ instr list \ JVMType.state step_type" where "exec G maxs rT et bs ==
err_step (size bs) (\<lambda>pc. app (bs!pc) G maxs rT pc et) (\<lambda>pc. eff (bs!pc) G pc et)"
definition opt_states :: "'c prog \ nat \ nat \ (ty list \ ty err list) option set" where "opt_states G maxs maxr \ opt (\{list n (types G) |n. n \ maxs} \ list maxr (err (types G)))"
subsection \<open>Executability of \<^term>\<open>check_bounded\<close>\<close>
primrec list_all'_rec :: "('a \<Rightarrow> nat \<Rightarrow> bool) \<Rightarrow> nat \<Rightarrow> 'a list \<Rightarrow> bool" where "list_all'_rec P n [] = True"
| "list_all'_rec P n (x#xs) = (P x n \ list_all'_rec P (Suc n) xs)"
definition list_all' :: "('a \<Rightarrow> nat \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> bool" where "list_all' P xs \ list_all'_rec P 0 xs"
lemma list_all'_rec: "list_all'_rec P n xs = (\p < size xs. P (xs!p) (p+n))" apply (induct xs arbitrary: n) apply auto apply (case_tac p) apply auto done
lemma list_all' [iff]: "list_all' P xs = (\n < size xs. P (xs!n) n)" by (unfold list_all'_def) (simp add: list_all'_rec)
lemma [code]: "check_bounded ins et =
(list_all' (\i pc. list_all (\pc'. pc' < length ins) (succs i pc)) ins \
list_all (\<lambda>e. fst (snd (snd e)) < length ins) et)" by (simp add: list_all_iff check_bounded_def)
subsection \<open>Connecting JVM and Framework\<close>
lemma check_bounded_is_bounded: "check_bounded ins et \ bounded (\pc. eff (ins!pc) G pc et) (length ins)" by (unfold bounded_def) (blast dest: check_boundedD)
lemma special_ex_swap_lemma [iff]: "(\X. (\n. X = A n \ P n) & Q X) = (\n. Q(A n) \ P n)" by blast
lemma sl_triple_conv: "JVMType.sl G maxs maxr ==
(states G maxs maxr, JVMType.le G maxs maxr, JVMType.sup G maxs maxr)" by (simp (no_asm) add: states_def JVMType.le_def JVMType.sup_def)
lemma is_type_pTs: "\ wf_prog wf_mb G; (C,S,fs,mdecls) \ set G; ((mn,pTs),rT,code) \ set mdecls \ \<Longrightarrow> set pTs \<subseteq> types G" proof assume"wf_prog wf_mb G" "(C,S,fs,mdecls) \ set G" "((mn,pTs),rT,code) \ set mdecls" hence"wf_mdecl wf_mb G C ((mn,pTs),rT,code)" by (rule wf_prog_wf_mdecl) hence"\t \ set pTs. is_type G t" by (unfold wf_mdecl_def wf_mhead_def) auto moreover fix t assume"t \ set pTs" ultimately have"is_type G t"by blast thus"t \ types G" .. qed
lemma jvm_prog_lift: assumes wf: "wf_prog (\G C bd. P G C bd) G"
assumes rule: "\wf_mb C mn pTs C rT maxs maxl b et bd.
wf_prog wf_mb G \<Longrightarrow>
method (G,C) (mn,pTs) = Some (C,rT,maxs,maxl,b,et) \<Longrightarrow>
is_class G C \<Longrightarrow>
set pTs \<subseteq> types G \<Longrightarrow>
bd = ((mn,pTs),rT,maxs,maxl,b,et) \<Longrightarrow>
P G C bd \<Longrightarrow>
Q G C bd"
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.