author  haftmann 
Tue, 24 Nov 2009 14:37:23 +0100  
changeset 33954  1bc3b688548c 
parent 32461  eee4fa79398f 
child 35416  d8d7d1b785af 
permissions  rwxrxrx 
8011  1 
(* Title: HOL/MicroJava/J/TypeRel.thy 
2 
ID: $Id$ 

3 
Author: David von Oheimb 

4 
Copyright 1999 Technische Universitaet Muenchen 

11070  5 
*) 
8011  6 

12911  7 
header {* \isaheader{Relations between Java Types} *} 
8011  8 

16417  9 
theory TypeRel imports Decl begin 
8011  10 

22271  11 
 "direct subclass, cf. 8.1.3" 
33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

12 

1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

13 
inductive_set 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

14 
subcls1 :: "'c prog => (cname \<times> cname) set" 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

15 
and subcls1' :: "'c prog => cname \<Rightarrow> cname => bool" ("_ \<turnstile> _ \<prec>C1 _" [71,71,71] 70) 
22271  16 
for G :: "'c prog" 
17 
where 

33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

18 
"G \<turnstile> C \<prec>C1 D \<equiv> (C, D) \<in> subcls1 G" 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

19 
 subcls1I: "\<lbrakk>class G C = Some (D,rest); C \<noteq> Object\<rbrakk> \<Longrightarrow> G \<turnstile> C \<prec>C1 D" 
10061
fe82134773dc
added HTML syntax; added spaces in normal syntax for better documents
kleing
parents:
10042
diff
changeset

20 

22271  21 
abbreviation 
33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

22 
subcls :: "'c prog => cname \<Rightarrow> cname => bool" ("_ \<turnstile> _ \<preceq>C _" [71,71,71] 70) 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

23 
where "G \<turnstile> C \<preceq>C D \<equiv> (C, D) \<in> (subcls1 G)^*" 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

24 

11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

25 
lemma subcls1D: 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

26 
"G\<turnstile>C\<prec>C1D \<Longrightarrow> C \<noteq> Object \<and> (\<exists>fs ms. class G C = Some (D,fs,ms))" 
22271  27 
apply (erule subcls1.cases) 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

28 
apply auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

29 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

30 

33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

31 
lemma subcls1_def2: 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

32 
"subcls1 P = 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

33 
(SIGMA C:{C. is_class P C}. {D. C\<noteq>Object \<and> fst (the (class P C))=D})" 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

34 
by (auto simp add: is_class_def dest: subcls1D intro: subcls1I) 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

35 

33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

36 
lemma finite_subcls1: "finite (subcls1 G)" 
23757  37 
apply(simp add: subcls1_def2 del: mem_Sigma_iff) 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

38 
apply(rule finite_SigmaI [OF finite_is_class]) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

39 
apply(rule_tac B = "{fst (the (class G C))}" in finite_subset) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

40 
apply auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

41 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

42 

33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

43 
lemma subcls_is_class: "(C, D) \<in> (subcls1 G)^+ ==> is_class G C" 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

44 
apply (unfold is_class_def) 
33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

45 
apply(erule trancl_trans_induct) 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

46 
apply (auto dest!: subcls1D) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

47 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

48 

11266  49 
lemma subcls_is_class2 [rule_format (no_asm)]: 
50 
"G\<turnstile>C\<preceq>C D \<Longrightarrow> is_class G D \<longrightarrow> is_class G C" 

11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

51 
apply (unfold is_class_def) 
33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

52 
apply (erule rtrancl_induct) 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

53 
apply (drule_tac [2] subcls1D) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

54 
apply auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

55 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

56 

13090
4fb7a2f2c1df
Improved definition of class_rec: no longer mixes algorithm and
berghofe
parents:
12911
diff
changeset

57 
constdefs 
4fb7a2f2c1df
Improved definition of class_rec: no longer mixes algorithm and
berghofe
parents:
12911
diff
changeset

58 
class_rec :: "'c prog \<Rightarrow> cname \<Rightarrow> 'a \<Rightarrow> 
4fb7a2f2c1df
Improved definition of class_rec: no longer mixes algorithm and
berghofe
parents:
12911
diff
changeset

59 
(cname \<Rightarrow> fdecl list \<Rightarrow> 'c mdecl list \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> 'a" 
33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

60 
"class_rec G == wfrec ((subcls1 G)^1) 
13090
4fb7a2f2c1df
Improved definition of class_rec: no longer mixes algorithm and
berghofe
parents:
12911
diff
changeset

61 
(\<lambda>r C t f. case class G C of 
28524  62 
None \<Rightarrow> undefined 
13090
4fb7a2f2c1df
Improved definition of class_rec: no longer mixes algorithm and
berghofe
parents:
12911
diff
changeset

63 
 Some (D,fs,ms) \<Rightarrow> 
4fb7a2f2c1df
Improved definition of class_rec: no longer mixes algorithm and
berghofe
parents:
12911
diff
changeset

64 
f C fs ms (if C = Object then t else r D t f))" 
11284  65 

33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

66 
lemma class_rec_lemma: 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

67 
assumes wf: "wf ((subcls1 G)^1)" 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

68 
and cls: "class G C = Some (D, fs, ms)" 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

69 
shows "class_rec G C t f = f C fs ms (if C=Object then t else class_rec G D t f)" 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

70 
proof  
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

71 
from wf have step: "\<And>H a. wfrec ((subcls1 G)\<inverse>) H a = 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

72 
H (cut (wfrec ((subcls1 G)\<inverse>) H) ((subcls1 G)\<inverse>) a) a" 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

73 
by (rule wfrec) 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

74 
have cut: "\<And>f. C \<noteq> Object \<Longrightarrow> cut f ((subcls1 G)\<inverse>) C D = f D" 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

75 
by (rule cut_apply [where r="(subcls1 G)^1", simplified, OF subcls1I, OF cls]) 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

76 
from cls show ?thesis by (simp add: step cut class_rec_def) 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

77 
qed 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

78 

20970  79 
definition 
33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

80 
"wf_class G = wf ((subcls1 G)^1)" 
20970  81 

82 

32461
eee4fa79398f
no consts_code for wfrec, as it violates the "code generation = equational reasoning" principle
krauss
parents:
28562
diff
changeset

83 
text {* Code generator setup (FIXME!) *} 
eee4fa79398f
no consts_code for wfrec, as it violates the "code generation = equational reasoning" principle
krauss
parents:
28562
diff
changeset

84 

eee4fa79398f
no consts_code for wfrec, as it violates the "code generation = equational reasoning" principle
krauss
parents:
28562
diff
changeset

85 
consts_code 
eee4fa79398f
no consts_code for wfrec, as it violates the "code generation = equational reasoning" principle
krauss
parents:
28562
diff
changeset

86 
"wfrec" ("\<module>wfrec?") 
eee4fa79398f
no consts_code for wfrec, as it violates the "code generation = equational reasoning" principle
krauss
parents:
28562
diff
changeset

87 
attach {* 
eee4fa79398f
no consts_code for wfrec, as it violates the "code generation = equational reasoning" principle
krauss
parents:
28562
diff
changeset

88 
fun wfrec f x = f (wfrec f) x; 
eee4fa79398f
no consts_code for wfrec, as it violates the "code generation = equational reasoning" principle
krauss
parents:
28562
diff
changeset

89 
*} 
eee4fa79398f
no consts_code for wfrec, as it violates the "code generation = equational reasoning" principle
krauss
parents:
28562
diff
changeset

90 

8011  91 
consts 
92 

14134  93 
method :: "'c prog \<times> cname => ( sig \<rightharpoonup> cname \<times> ty \<times> 'c)" (* ###curry *) 
94 
field :: "'c prog \<times> cname => ( vname \<rightharpoonup> cname \<times> ty )" (* ###curry *) 

11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

95 
fields :: "'c prog \<times> cname => ((vname \<times> cname) \<times> ty) list" (* ###curry *) 
8011  96 

12517  97 
 "methods of a class, with inheritance, overriding and hiding, cf. 8.4.6" 
13090
4fb7a2f2c1df
Improved definition of class_rec: no longer mixes algorithm and
berghofe
parents:
12911
diff
changeset

98 
defs method_def: "method \<equiv> \<lambda>(G,C). class_rec G C empty (\<lambda>C fs ms ts. 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

99 
ts ++ map_of (map (\<lambda>(s,m). (s,(C,m))) ms))" 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

100 

33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

101 
lemma method_rec_lemma: "[class G C = Some (D,fs,ms); wf ((subcls1 G)^1)] ==> 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

102 
method (G,C) = (if C = Object then empty else method (G,D)) ++ 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

103 
map_of (map (\<lambda>(s,m). (s,(C,m))) ms)" 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

104 
apply (unfold method_def) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

105 
apply (simp split del: split_if) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

106 
apply (erule (1) class_rec_lemma [THEN trans]); 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

107 
apply auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

108 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

109 

8011  110 

12517  111 
 "list of fields of a class, including inherited and hidden ones" 
13090
4fb7a2f2c1df
Improved definition of class_rec: no longer mixes algorithm and
berghofe
parents:
12911
diff
changeset

112 
defs fields_def: "fields \<equiv> \<lambda>(G,C). class_rec G C [] (\<lambda>C fs ms ts. 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

113 
map (\<lambda>(fn,ft). ((fn,C),ft)) fs @ ts)" 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

114 

33954
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents:
32461
diff
changeset

115 
lemma fields_rec_lemma: "[class G C = Some (D,fs,ms); wf ((subcls1 G)^1)] ==> 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

116 
fields (G,C) = 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

117 
map (\<lambda>(fn,ft). ((fn,C),ft)) fs @ (if C = Object then [] else fields (G,D))" 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

118 
apply (unfold fields_def) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

119 
apply (simp split del: split_if) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

120 
apply (erule (1) class_rec_lemma [THEN trans]); 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

121 
apply auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

122 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

123 

a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

124 

a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

125 
defs field_def: "field == map_of o (map (\<lambda>((fn,fd),ft). (fn,(fd,ft)))) o fields" 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

126 

a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

127 
lemma field_fields: 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

128 
"field (G,C) fn = Some (fd, fT) \<Longrightarrow> map_of (fields (G,C)) (fn, fd) = Some fT" 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

129 
apply (unfold field_def) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

130 
apply (rule table_of_remap_SomeD) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

131 
apply simp 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

132 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

133 

a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

134 

12517  135 
 "widening, viz. method invocation conversion,cf. 5.3 i.e. sort of syntactic subtyping" 
23757  136 
inductive 
22271  137 
widen :: "'c prog => [ty , ty ] => bool" ("_ \<turnstile> _ \<preceq> _" [71,71,71] 70) 
138 
for G :: "'c prog" 

139 
where 

12517  140 
refl [intro!, simp]: "G\<turnstile> T \<preceq> T"  "identity conv., cf. 5.1.1" 
22271  141 
 subcls : "G\<turnstile>C\<preceq>C D ==> G\<turnstile>Class C \<preceq> Class D" 
142 
 null [intro!]: "G\<turnstile> NT \<preceq> RefT R" 

8011  143 

22597  144 
lemmas refl = HOL.refl 
145 

12517  146 
 "casting conversion, cf. 5.5 / 5.1.5" 
147 
 "left out casts on primitve types" 

23757  148 
inductive 
22271  149 
cast :: "'c prog => [ty , ty ] => bool" ("_ \<turnstile> _ \<preceq>? _" [71,71,71] 70) 
150 
for G :: "'c prog" 

151 
where 

14045  152 
widen: "G\<turnstile> C\<preceq> D ==> G\<turnstile>C \<preceq>? D" 
22271  153 
 subcls: "G\<turnstile> D\<preceq>C C ==> G\<turnstile>Class C \<preceq>? Class D" 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

154 

a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

155 
lemma widen_PrimT_RefT [iff]: "(G\<turnstile>PrimT pT\<preceq>RefT rT) = False" 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

156 
apply (rule iffI) 
22271  157 
apply (erule widen.cases) 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

158 
apply auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

159 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

160 

a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

161 
lemma widen_RefT: "G\<turnstile>RefT R\<preceq>T ==> \<exists>t. T=RefT t" 
23757  162 
apply (ind_cases "G\<turnstile>RefT R\<preceq>T") 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

163 
apply auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

164 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

165 

a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

166 
lemma widen_RefT2: "G\<turnstile>S\<preceq>RefT R ==> \<exists>t. S=RefT t" 
23757  167 
apply (ind_cases "G\<turnstile>S\<preceq>RefT R") 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

168 
apply auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

169 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

170 

a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

171 
lemma widen_Class: "G\<turnstile>Class C\<preceq>T ==> \<exists>D. T=Class D" 
23757  172 
apply (ind_cases "G\<turnstile>Class C\<preceq>T") 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

173 
apply auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

174 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

175 

a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

176 
lemma widen_Class_NullT [iff]: "(G\<turnstile>Class C\<preceq>NT) = False" 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

177 
apply (rule iffI) 
23757  178 
apply (ind_cases "G\<turnstile>Class C\<preceq>NT") 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

179 
apply auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

180 
done 
8011  181 

11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

182 
lemma widen_Class_Class [iff]: "(G\<turnstile>Class C\<preceq> Class D) = (G\<turnstile>C\<preceq>C D)" 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

183 
apply (rule iffI) 
23757  184 
apply (ind_cases "G\<turnstile>Class C \<preceq> Class D") 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

185 
apply (auto elim: widen.subcls) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

186 
done 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

187 

14045  188 
lemma widen_NT_Class [simp]: "G \<turnstile> T \<preceq> NT \<Longrightarrow> G \<turnstile> T \<preceq> Class D" 
23757  189 
by (ind_cases "G \<turnstile> T \<preceq> NT", auto) 
14045  190 

191 
lemma cast_PrimT_RefT [iff]: "(G\<turnstile>PrimT pT\<preceq>? RefT rT) = False" 

192 
apply (rule iffI) 

22271  193 
apply (erule cast.cases) 
14045  194 
apply auto 
195 
done 

196 

197 
lemma cast_RefT: "G \<turnstile> C \<preceq>? Class D \<Longrightarrow> \<exists> rT. C = RefT rT" 

198 
apply (erule cast.cases) 

199 
apply simp apply (erule widen.cases) 

200 
apply auto 

201 
done 

202 

12517  203 
theorem widen_trans[trans]: "\<lbrakk>G\<turnstile>S\<preceq>U; G\<turnstile>U\<preceq>T\<rbrakk> \<Longrightarrow> G\<turnstile>S\<preceq>T" 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

204 
proof  
12517  205 
assume "G\<turnstile>S\<preceq>U" thus "\<And>T. G\<turnstile>U\<preceq>T \<Longrightarrow> G\<turnstile>S\<preceq>T" 
11987  206 
proof induct 
12517  207 
case (refl T T') thus "G\<turnstile>T\<preceq>T'" . 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

208 
next 
11987  209 
case (subcls C D T) 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

210 
then obtain E where "T = Class E" by (blast dest: widen_Class) 
22271  211 
with subcls show "G\<turnstile>Class C\<preceq>T" by auto 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

212 
next 
11987  213 
case (null R RT) 
11026
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

214 
then obtain rt where "RT = RefT rt" by (blast dest: widen_RefT) 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

215 
thus "G\<turnstile>NT\<preceq>RT" by auto 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

216 
qed 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

217 
qed 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
oheimb
parents:
10613
diff
changeset

218 

8011  219 
end 