src/HOL/MicroJava/BV/BVExample.thy
changeset 80914 d97fdabd9e2b
parent 69597 ff784d5a5bfb
equal deleted inserted replaced
80913:46f59511b7bb 80914:d97fdabd9e2b
   161 
   161 
   162   \<open>\<dots>\<close>
   162   \<open>\<dots>\<close>
   163 
   163 
   164   @{prop [display] "P n"} 
   164   @{prop [display] "P n"} 
   165 \<close>
   165 \<close>
   166 definition intervall :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> bool" ("_ \<in> [_, _')") where
   166 definition intervall :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> bool" (\<open>_ \<in> [_, _')\<close>) where
   167   "x \<in> [a, b) \<equiv> a \<le> x \<and> x < b"
   167   "x \<in> [a, b) \<equiv> a \<le> x \<and> x < b"
   168 
   168 
   169 lemma pc_0: "x < n \<Longrightarrow> (x \<in> [0, n) \<Longrightarrow> P x) \<Longrightarrow> P x"
   169 lemma pc_0: "x < n \<Longrightarrow> (x \<in> [0, n) \<Longrightarrow> P x) \<Longrightarrow> P x"
   170   by (simp add: intervall_def)
   170   by (simp add: intervall_def)
   171 
   171 
   231   and \<^term>\<open>makelist_name\<close> in class \<^term>\<open>test_name\<close>:
   231   and \<^term>\<open>makelist_name\<close> in class \<^term>\<open>test_name\<close>:
   232 \<close>
   232 \<close>
   233 lemmas eff_simps [simp] = eff_def norm_eff_def xcpt_eff_def
   233 lemmas eff_simps [simp] = eff_def norm_eff_def xcpt_eff_def
   234 declare appInvoke [simp del]
   234 declare appInvoke [simp del]
   235 
   235 
   236 definition phi_append :: method_type ("\<phi>\<^sub>a") where
   236 definition phi_append :: method_type (\<open>\<phi>\<^sub>a\<close>) where
   237   "\<phi>\<^sub>a \<equiv> map (\<lambda>(x,y). Some (x, map OK y)) [ 
   237   "\<phi>\<^sub>a \<equiv> map (\<lambda>(x,y). Some (x, map OK y)) [ 
   238    (                                    [], [Class list_name, Class list_name]),
   238    (                                    [], [Class list_name, Class list_name]),
   239    (                     [Class list_name], [Class list_name, Class list_name]),
   239    (                     [Class list_name], [Class list_name, Class list_name]),
   240    (                     [Class list_name], [Class list_name, Class list_name]),
   240    (                     [Class list_name], [Class list_name, Class list_name]),
   241    (    [Class list_name, Class list_name], [Class list_name, Class list_name]),
   241    (    [Class list_name, Class list_name], [Class list_name, Class list_name]),
   293 abbreviation Clist :: ty 
   293 abbreviation Clist :: ty 
   294   where "Clist == Class list_name"
   294   where "Clist == Class list_name"
   295 abbreviation Ctest :: ty
   295 abbreviation Ctest :: ty
   296   where "Ctest == Class test_name"
   296   where "Ctest == Class test_name"
   297 
   297 
   298 definition phi_makelist :: method_type ("\<phi>\<^sub>m") where
   298 definition phi_makelist :: method_type (\<open>\<phi>\<^sub>m\<close>) where
   299   "\<phi>\<^sub>m \<equiv> map (\<lambda>(x,y). Some (x, y)) [ 
   299   "\<phi>\<^sub>m \<equiv> map (\<lambda>(x,y). Some (x, y)) [ 
   300     (                                   [], [OK Ctest, Err     , Err     ]),
   300     (                                   [], [OK Ctest, Err     , Err     ]),
   301     (                              [Clist], [OK Ctest, Err     , Err     ]),
   301     (                              [Clist], [OK Ctest, Err     , Err     ]),
   302     (                       [Clist, Clist], [OK Ctest, Err     , Err     ]),
   302     (                       [Clist, Clist], [OK Ctest, Err     , Err     ]),
   303     (                              [Clist], [OK Clist, Err     , Err     ]),
   303     (                              [Clist], [OK Clist, Err     , Err     ]),
   367   apply (simp add: app_def xcpt_app_def) 
   367   apply (simp add: app_def xcpt_app_def) 
   368   apply simp
   368   apply simp
   369   done
   369   done
   370 
   370 
   371 text \<open>The whole program is welltyped:\<close>
   371 text \<open>The whole program is welltyped:\<close>
   372 definition Phi :: prog_type ("\<Phi>") where
   372 definition Phi :: prog_type (\<open>\<Phi>\<close>) where
   373   "\<Phi> C sg \<equiv> if C = test_name \<and> sg = (makelist_name, []) then \<phi>\<^sub>m else          
   373   "\<Phi> C sg \<equiv> if C = test_name \<and> sg = (makelist_name, []) then \<phi>\<^sub>m else          
   374              if C = list_name \<and> sg = (append_name, [Class list_name]) then \<phi>\<^sub>a else []"
   374              if C = list_name \<and> sg = (append_name, [Class list_name]) then \<phi>\<^sub>a else []"
   375 
   375 
   376 lemma wf_prog:
   376 lemma wf_prog:
   377   "wt_jvm_prog E \<Phi>" 
   377   "wt_jvm_prog E \<Phi>"