equal
deleted
inserted
replaced
1 (* Title: HOL/Bali/WellType.thy |
1 (* Title: HOL/Bali/WellType.thy |
2 Author: David von Oheimb |
2 Author: David von Oheimb |
3 *) |
3 *) |
4 header {* Well-typedness of Java programs *} |
4 subsection {* Well-typedness of Java programs *} |
5 |
5 |
6 theory WellType |
6 theory WellType |
7 imports DeclConcepts |
7 imports DeclConcepts |
8 begin |
8 begin |
9 |
9 |
45 |
45 |
46 abbreviation |
46 abbreviation |
47 pkg :: "env \<Rightarrow> pname" --{* select the current package from an environment *} |
47 pkg :: "env \<Rightarrow> pname" --{* select the current package from an environment *} |
48 where "pkg e == pid (cls e)" |
48 where "pkg e == pid (cls e)" |
49 |
49 |
50 section "Static overloading: maximally specific methods " |
50 subsubsection "Static overloading: maximally specific methods " |
51 |
51 |
52 type_synonym |
52 type_synonym |
53 emhead = "ref_ty \<times> mhead" |
53 emhead = "ref_ty \<times> mhead" |
54 |
54 |
55 --{* Some mnemotic selectors for emhead *} |
55 --{* Some mnemotic selectors for emhead *} |
172 lemma Null_staticD: |
172 lemma Null_staticD: |
173 "a'=Null \<longrightarrow> (is_static m) \<Longrightarrow> invmode m e = IntVir \<longrightarrow> a' \<noteq> Null" |
173 "a'=Null \<longrightarrow> (is_static m) \<Longrightarrow> invmode m e = IntVir \<longrightarrow> a' \<noteq> Null" |
174 apply (clarsimp simp add: invmode_IntVir_eq) |
174 apply (clarsimp simp add: invmode_IntVir_eq) |
175 done |
175 done |
176 |
176 |
177 section "Typing for unary operations" |
177 subsubsection "Typing for unary operations" |
178 |
178 |
179 primrec unop_type :: "unop \<Rightarrow> prim_ty" |
179 primrec unop_type :: "unop \<Rightarrow> prim_ty" |
180 where |
180 where |
181 "unop_type UPlus = Integer" |
181 "unop_type UPlus = Integer" |
182 | "unop_type UMinus = Integer" |
182 | "unop_type UMinus = Integer" |
188 "wt_unop UPlus t = (t = PrimT Integer)" |
188 "wt_unop UPlus t = (t = PrimT Integer)" |
189 | "wt_unop UMinus t = (t = PrimT Integer)" |
189 | "wt_unop UMinus t = (t = PrimT Integer)" |
190 | "wt_unop UBitNot t = (t = PrimT Integer)" |
190 | "wt_unop UBitNot t = (t = PrimT Integer)" |
191 | "wt_unop UNot t = (t = PrimT Boolean)" |
191 | "wt_unop UNot t = (t = PrimT Boolean)" |
192 |
192 |
193 section "Typing for binary operations" |
193 subsubsection "Typing for binary operations" |
194 |
194 |
195 primrec binop_type :: "binop \<Rightarrow> prim_ty" |
195 primrec binop_type :: "binop \<Rightarrow> prim_ty" |
196 where |
196 where |
197 "binop_type Mul = Integer" |
197 "binop_type Mul = Integer" |
198 | "binop_type Div = Integer" |
198 | "binop_type Div = Integer" |
240 | "wt_binop G BitOr t1 t2 = ((t1 = PrimT Integer) \<and> (t2 = PrimT Integer))" |
240 | "wt_binop G BitOr t1 t2 = ((t1 = PrimT Integer) \<and> (t2 = PrimT Integer))" |
241 | "wt_binop G Or t1 t2 = ((t1 = PrimT Boolean) \<and> (t2 = PrimT Boolean))" |
241 | "wt_binop G Or t1 t2 = ((t1 = PrimT Boolean) \<and> (t2 = PrimT Boolean))" |
242 | "wt_binop G CondAnd t1 t2 = ((t1 = PrimT Boolean) \<and> (t2 = PrimT Boolean))" |
242 | "wt_binop G CondAnd t1 t2 = ((t1 = PrimT Boolean) \<and> (t2 = PrimT Boolean))" |
243 | "wt_binop G CondOr t1 t2 = ((t1 = PrimT Boolean) \<and> (t2 = PrimT Boolean))" |
243 | "wt_binop G CondOr t1 t2 = ((t1 = PrimT Boolean) \<and> (t2 = PrimT Boolean))" |
244 |
244 |
245 section "Typing for terms" |
245 subsubsection "Typing for terms" |
246 |
246 |
247 type_synonym tys = "ty + ty list" |
247 type_synonym tys = "ty + ty list" |
248 translations |
248 translations |
249 (type) "tys" <= (type) "ty + ty list" |
249 (type) "tys" <= (type) "ty + ty list" |
250 |
250 |